@finos/legend-graph
Version:
Legend graph and graph manager
49 lines • 2.09 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { uniq } from '@finos/legend-shared';
import { RuntimePointer, EngineRuntime, } from '../metamodel/pure/packageableElements/runtime/Runtime.js';
import { PureExecution, PureMultiExecution, PureSingleExecution, } from '../metamodel/pure/packageableElements/service/ServiceExecution.js';
export const getAllIdentifiedConnectionsFromRuntime = (runtime) => {
const resolvedRuntimes = [];
if (runtime instanceof RuntimePointer) {
resolvedRuntimes.push(runtime.packageableRuntime.value.runtimeValue);
}
else if (runtime instanceof EngineRuntime) {
resolvedRuntimes.push(runtime);
}
return resolvedRuntimes
.flatMap((e) => e.connections.map((connection) => connection.storeConnections))
.flat();
};
export const getAllIdentifiedServiceConnections = (service) => {
const execution = service.execution;
let runtimes = [];
if (execution instanceof PureSingleExecution && execution.runtime) {
runtimes = [execution.runtime];
}
else if (execution instanceof PureMultiExecution) {
runtimes = execution.executionParameters?.map((t) => t.runtime) ?? [];
}
return uniq(runtimes.flatMap(getAllIdentifiedConnectionsFromRuntime));
};
export const resolveServiceQueryRawLambda = (service) => {
const execution = service.execution;
if (execution instanceof PureExecution) {
return execution.func;
}
return undefined;
};
//# sourceMappingURL=DSL_Service_Helper.js.map