UNPKG

@finos/legend-application-studio

Version:
33 lines 2.05 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { flowResult } from 'mobx'; import { AccessorQueryBuilderState, QueryBuilderActionConfig, QueryBuilderAdvancedWorkflowState, getCompatibleRuntimesFromAccessorOwner, } from '@finos/legend-query-builder'; import { assertErrorThrown, guaranteeNonNullable } from '@finos/legend-shared'; import { PromoteAccessorQueryToFunctionAction } from './AccessorQueryBuilder.js'; export const queryAccessorSource = async (element, editorStore) => { try { const embeddedQueryBuilderState = editorStore.embeddedQueryBuilderState; await flowResult(embeddedQueryBuilderState.setEmbeddedQueryBuilderConfiguration({ setupQueryBuilderState: async () => { const queryBuilderState = new AccessorQueryBuilderState(editorStore.applicationStore, undefined, editorStore.graphManagerState, QueryBuilderAdvancedWorkflowState.INSTANCE, QueryBuilderActionConfig.INSTANCE, editorStore.applicationStore.config.options.queryBuilderConfig, editorStore.editorMode.getSourceInfo()); queryBuilderState.changeAccessorOwner(element); const compatibleRuntimes = getCompatibleRuntimesFromAccessorOwner(element, editorStore.graphManagerState); if (compatibleRuntimes.length > 0) { queryBuilderState.changeSelectedRuntime(guaranteeNonNullable(compatibleRuntimes[0])); } return queryBuilderState; }, disableCompile: true, actionConfigs: [ { key: 'promote-accessor-query-to-function-btn', renderer: (queryBuilderState) => (_jsx(PromoteAccessorQueryToFunctionAction, { queryBuilderState: queryBuilderState })), }, ], })); } catch (error) { assertErrorThrown(error); editorStore.applicationStore.notificationService.notifyError(`Failed to open query builder: ${error.message}`); } }; //# sourceMappingURL=AccessorQueryBuilderHelper.js.map