@finos/legend-application 8.0.2 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts +4 -2
- package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts.map +1 -1
- package/lib/components/LegendApplicationComponentFrameworkProvider.js +7 -4
- package/lib/components/LegendApplicationComponentFrameworkProvider.js.map +1 -1
- package/lib/components/NotificationManager.js +1 -1
- package/lib/components/NotificationManager.js.map +1 -1
- package/lib/components/WebApplicationNavigatorProvider.d.ts.map +1 -1
- package/lib/components/WebApplicationNavigatorProvider.js +1 -1
- package/lib/components/WebApplicationNavigatorProvider.js.map +1 -1
- package/lib/components/{shared/execution-plan-viewer → execution-plan-viewer}/ExecutionPlanViewer.d.ts +1 -1
- package/lib/components/execution-plan-viewer/ExecutionPlanViewer.d.ts.map +1 -0
- package/lib/components/{shared/execution-plan-viewer → execution-plan-viewer}/ExecutionPlanViewer.js +3 -3
- package/lib/components/execution-plan-viewer/ExecutionPlanViewer.js.map +1 -0
- package/lib/components/{shared/execution-plan-viewer → execution-plan-viewer}/SQLExecutionNodeViewer.d.ts +1 -1
- package/lib/components/execution-plan-viewer/SQLExecutionNodeViewer.d.ts.map +1 -0
- package/lib/components/{shared/execution-plan-viewer → execution-plan-viewer}/SQLExecutionNodeViewer.js +2 -2
- package/lib/components/execution-plan-viewer/SQLExecutionNodeViewer.js.map +1 -0
- package/lib/components/shared/DocumentationLink.d.ts +5 -0
- package/lib/components/shared/DocumentationLink.d.ts.map +1 -1
- package/lib/components/shared/DocumentationLink.js +12 -2
- package/lib/components/shared/DocumentationLink.js.map +1 -1
- package/lib/components/shared/{PackageableElementOptionRenderer.d.ts → PackageableElementOptionLabel.d.ts} +1 -1
- package/lib/components/shared/PackageableElementOptionLabel.d.ts.map +1 -0
- package/lib/components/shared/{PackageableElementOptionRenderer.js → PackageableElementOptionLabel.js} +5 -5
- package/lib/components/shared/PackageableElementOptionLabel.js.map +1 -0
- package/lib/components/shared/TextInputEditor.d.ts.map +1 -1
- package/lib/components/shared/TextInputEditor.js +1 -2
- package/lib/components/shared/TextInputEditor.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +8 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -9
- package/lib/index.js.map +1 -1
- package/lib/stores/ApplicationStore.d.ts +2 -0
- package/lib/stores/ApplicationStore.d.ts.map +1 -1
- package/lib/stores/ApplicationStore.js +13 -10
- package/lib/stores/ApplicationStore.js.map +1 -1
- package/lib/stores/AssistantService.js +1 -1
- package/lib/stores/AssistantService.js.map +1 -1
- package/lib/stores/{shared/ExecutionPlanState.d.ts → ExecutionPlanState.d.ts} +1 -1
- package/lib/stores/ExecutionPlanState.d.ts.map +1 -0
- package/lib/stores/{shared/ExecutionPlanState.js → ExecutionPlanState.js} +0 -0
- package/lib/stores/ExecutionPlanState.js.map +1 -0
- package/lib/stores/LegendApplicationDocumentation.d.ts +2 -1
- package/lib/stores/LegendApplicationDocumentation.d.ts.map +1 -1
- package/lib/stores/LegendApplicationDocumentation.js +1 -0
- package/lib/stores/LegendApplicationDocumentation.js.map +1 -1
- package/lib/stores/WebApplicationNavigator.d.ts +62 -30
- package/lib/stores/WebApplicationNavigator.d.ts.map +1 -1
- package/lib/stores/WebApplicationNavigator.js +80 -15
- package/lib/stores/WebApplicationNavigator.js.map +1 -1
- package/lib/{components/ApplicationTestID.js → stores/WebApplicationRouter.d.ts} +4 -5
- package/lib/stores/WebApplicationRouter.d.ts.map +1 -0
- package/{src/components/ApplicationTestID.ts → lib/stores/WebApplicationRouter.js} +4 -4
- package/lib/stores/WebApplicationRouter.js.map +1 -0
- package/package.json +9 -11
- package/src/components/LegendApplicationComponentFrameworkProvider.tsx +18 -14
- package/src/components/NotificationManager.tsx +1 -1
- package/src/components/WebApplicationNavigatorProvider.tsx +1 -1
- package/src/components/{shared/execution-plan-viewer → execution-plan-viewer}/ExecutionPlanViewer.tsx +3 -3
- package/src/components/{shared/execution-plan-viewer → execution-plan-viewer}/SQLExecutionNodeViewer.tsx +3 -3
- package/src/components/shared/DocumentationLink.tsx +25 -1
- package/src/components/shared/{PackageableElementOptionRenderer.tsx → PackageableElementOptionLabel.tsx} +4 -4
- package/src/components/shared/TextInputEditor.tsx +1 -2
- package/src/index.ts +9 -9
- package/src/stores/ApplicationStore.ts +15 -12
- package/src/stores/AssistantService.ts +1 -1
- package/src/stores/{shared/ExecutionPlanState.ts → ExecutionPlanState.ts} +1 -1
- package/src/stores/LegendApplicationDocumentation.ts +1 -0
- package/src/stores/WebApplicationNavigator.ts +149 -39
- package/{lib/components/ApplicationTestID.d.ts → src/stores/WebApplicationRouter.ts} +12 -4
- package/tsconfig.json +7 -16
- package/lib/components/ApplicationTestID.d.ts.map +0 -1
- package/lib/components/ApplicationTestID.js.map +0 -1
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts +0 -52
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +0 -1
- package/lib/components/shared/BasicValueSpecificationEditor.js +0 -323
- package/lib/components/shared/BasicValueSpecificationEditor.js.map +0 -1
- package/lib/components/shared/CustomDatePicker.d.ts +0 -38
- package/lib/components/shared/CustomDatePicker.d.ts.map +0 -1
- package/lib/components/shared/CustomDatePicker.js +0 -616
- package/lib/components/shared/CustomDatePicker.js.map +0 -1
- package/lib/components/shared/LambdaEditor.d.ts +0 -92
- package/lib/components/shared/LambdaEditor.d.ts.map +0 -1
- package/lib/components/shared/LambdaEditor.js +0 -434
- package/lib/components/shared/LambdaEditor.js.map +0 -1
- package/lib/components/shared/LambdaParameterValuesEditor.d.ts +0 -25
- package/lib/components/shared/LambdaParameterValuesEditor.d.ts.map +0 -1
- package/lib/components/shared/LambdaParameterValuesEditor.js +0 -52
- package/lib/components/shared/LambdaParameterValuesEditor.js.map +0 -1
- package/lib/components/shared/PackageableElementOptionRenderer.d.ts.map +0 -1
- package/lib/components/shared/PackageableElementOptionRenderer.js.map +0 -1
- package/lib/components/shared/execution-plan-viewer/ExecutionPlanViewer.d.ts.map +0 -1
- package/lib/components/shared/execution-plan-viewer/ExecutionPlanViewer.js.map +0 -1
- package/lib/components/shared/execution-plan-viewer/SQLExecutionNodeViewer.d.ts.map +0 -1
- package/lib/components/shared/execution-plan-viewer/SQLExecutionNodeViewer.js.map +0 -1
- package/lib/stores/CJS__Fuse.cjs +0 -35
- package/lib/stores/CJS__Fuse.cjs.map +0 -1
- package/lib/stores/CJS__Fuse.d.cts +0 -28
- package/lib/stores/CJS__Fuse.d.cts.map +0 -1
- package/lib/stores/shared/ExecutionPlanState.d.ts.map +0 -1
- package/lib/stores/shared/ExecutionPlanState.js.map +0 -1
- package/lib/stores/shared/LambdaEditorState.d.ts +0 -40
- package/lib/stores/shared/LambdaEditorState.d.ts.map +0 -1
- package/lib/stores/shared/LambdaEditorState.js +0 -81
- package/lib/stores/shared/LambdaEditorState.js.map +0 -1
- package/lib/stores/shared/LambdaParameterState.d.ts +0 -62
- package/lib/stores/shared/LambdaParameterState.d.ts.map +0 -1
- package/lib/stores/shared/LambdaParameterState.js +0 -160
- package/lib/stores/shared/LambdaParameterState.js.map +0 -1
- package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts +0 -27
- package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts.map +0 -1
- package/lib/stores/shared/ValueSpecificationModifierHelper.js +0 -49
- package/lib/stores/shared/ValueSpecificationModifierHelper.js.map +0 -1
- package/src/components/shared/BasicValueSpecificationEditor.tsx +0 -828
- package/src/components/shared/CustomDatePicker.tsx +0 -1292
- package/src/components/shared/LambdaEditor.tsx +0 -854
- package/src/components/shared/LambdaParameterValuesEditor.tsx +0 -118
- package/src/stores/CJS__Fuse.cts +0 -28
- package/src/stores/shared/LambdaEditorState.ts +0 -118
- package/src/stores/shared/LambdaParameterState.ts +0 -253
- package/src/stores/shared/ValueSpecificationModifierHelper.ts +0 -104
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Dialog } from '@finos/legend-art';
|
|
18
|
-
import {
|
|
19
|
-
type PureModel,
|
|
20
|
-
type ValueSpecification,
|
|
21
|
-
PRIMITIVE_TYPE,
|
|
22
|
-
} from '@finos/legend-graph';
|
|
23
|
-
import { prettyCONSTName } from '@finos/legend-shared';
|
|
24
|
-
import { observer } from 'mobx-react-lite';
|
|
25
|
-
import type { LambdaParametersState } from '../../stores/shared/LambdaParameterState.js';
|
|
26
|
-
import { useApplicationStore } from '../ApplicationStoreProvider.js';
|
|
27
|
-
import { BasicValueSpecificationEditor } from './BasicValueSpecificationEditor.js';
|
|
28
|
-
|
|
29
|
-
// TODO we may want to further componentize this by removing the dialog wrapper
|
|
30
|
-
export const LambdaParameterValuesEditor = observer(
|
|
31
|
-
(props: {
|
|
32
|
-
graph: PureModel;
|
|
33
|
-
lambdaParametersState: LambdaParametersState;
|
|
34
|
-
}) => {
|
|
35
|
-
const { lambdaParametersState, graph } = props;
|
|
36
|
-
const valuesEdtiorState = lambdaParametersState.parameterValuesEditorState;
|
|
37
|
-
const close = (): void => valuesEdtiorState.close();
|
|
38
|
-
const applicationStore = useApplicationStore();
|
|
39
|
-
const submitAction = valuesEdtiorState.submitAction;
|
|
40
|
-
const submit = applicationStore.guardUnhandledError(async () => {
|
|
41
|
-
if (submitAction) {
|
|
42
|
-
close();
|
|
43
|
-
await submitAction.handler();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return (
|
|
47
|
-
<Dialog
|
|
48
|
-
open={Boolean(valuesEdtiorState.showModal)}
|
|
49
|
-
onClose={close}
|
|
50
|
-
classes={{
|
|
51
|
-
root: 'editor-modal__root-container',
|
|
52
|
-
container: 'editor-modal__container',
|
|
53
|
-
paper: 'editor-modal__content',
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
<div className="modal modal--dark editor-modal lambda-parameter-values__modal">
|
|
57
|
-
<div className="modal__header">
|
|
58
|
-
<div className="modal__title">Set Parameter Values</div>
|
|
59
|
-
</div>
|
|
60
|
-
<div className="modal__body lambda-parameter-values__modal__body">
|
|
61
|
-
{lambdaParametersState.parameterStates.map((paramState) => {
|
|
62
|
-
const stringType = graph.getPrimitiveType(PRIMITIVE_TYPE.STRING);
|
|
63
|
-
const variableType = paramState.variableType ?? stringType;
|
|
64
|
-
return (
|
|
65
|
-
<div
|
|
66
|
-
key={paramState.uuid}
|
|
67
|
-
className="panel__content__form__section"
|
|
68
|
-
>
|
|
69
|
-
<div className="lambda-parameter-values__value__label">
|
|
70
|
-
<div className="lambda-parameter-values__value__label__name">
|
|
71
|
-
{paramState.parameter.name}
|
|
72
|
-
</div>
|
|
73
|
-
<div className="lambda-parameter-values__value__label__type">
|
|
74
|
-
{variableType.name}
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
{paramState.value && (
|
|
78
|
-
<BasicValueSpecificationEditor
|
|
79
|
-
valueSpecification={paramState.value}
|
|
80
|
-
setValueSpecification={(
|
|
81
|
-
val: ValueSpecification,
|
|
82
|
-
): void => {
|
|
83
|
-
paramState.setValue(val);
|
|
84
|
-
}}
|
|
85
|
-
graph={graph}
|
|
86
|
-
typeCheckOption={{
|
|
87
|
-
expectedType: variableType,
|
|
88
|
-
match:
|
|
89
|
-
variableType ===
|
|
90
|
-
graph.getPrimitiveType(PRIMITIVE_TYPE.DATETIME),
|
|
91
|
-
}}
|
|
92
|
-
className="query-builder__parameters__value__editor"
|
|
93
|
-
resetValue={(): void => paramState.mockParameterValue()}
|
|
94
|
-
/>
|
|
95
|
-
)}
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
})}
|
|
99
|
-
</div>
|
|
100
|
-
<div className="modal__footer">
|
|
101
|
-
{submitAction && (
|
|
102
|
-
<button
|
|
103
|
-
className="btn modal__footer__close-btn"
|
|
104
|
-
title={submitAction.label}
|
|
105
|
-
onClick={submit}
|
|
106
|
-
>
|
|
107
|
-
{prettyCONSTName(submitAction.label)}
|
|
108
|
-
</button>
|
|
109
|
-
)}
|
|
110
|
-
<button className="btn modal__footer__close-btn" onClick={close}>
|
|
111
|
-
Close
|
|
112
|
-
</button>
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
</Dialog>
|
|
116
|
-
);
|
|
117
|
-
},
|
|
118
|
-
);
|
package/src/stores/CJS__Fuse.cts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Previously, these exports rely on ES module interop to expose `default` export
|
|
19
|
-
* properly. But since we use `ESM` for Typescript resolution now, we lose this
|
|
20
|
-
* so we have to workaround by importing these and re-export them from CJS
|
|
21
|
-
*
|
|
22
|
-
* TODO: remove these when the package properly work with Typescript's nodenext
|
|
23
|
-
* module resolution
|
|
24
|
-
*
|
|
25
|
-
* @workaround ESM
|
|
26
|
-
* See https://github.com/microsoft/TypeScript/issues/49298
|
|
27
|
-
*/
|
|
28
|
-
export { default as Fuse } from 'fuse.js';
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { observable, action, computed, makeObservable, flow } from 'mobx';
|
|
18
|
-
import { type GeneratorFn, uuid } from '@finos/legend-shared';
|
|
19
|
-
import {
|
|
20
|
-
type ParserError,
|
|
21
|
-
type CompilationError,
|
|
22
|
-
SourceInformation,
|
|
23
|
-
} from '@finos/legend-graph';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* This is not strictly meant for lambda. The idea is to create an editor that allows
|
|
27
|
-
* editing _something_ but allows user to edit via text.
|
|
28
|
-
*/
|
|
29
|
-
export abstract class LambdaEditorState {
|
|
30
|
-
readonly uuid = uuid();
|
|
31
|
-
lambdaPrefix: string;
|
|
32
|
-
lambdaString: string; // value shown in lambda editor which can be edited
|
|
33
|
-
parserError?: ParserError | undefined;
|
|
34
|
-
compilationError?: CompilationError | undefined;
|
|
35
|
-
|
|
36
|
-
constructor(lambdaString: string, lambdaPrefix: string) {
|
|
37
|
-
makeObservable(this, {
|
|
38
|
-
lambdaString: observable,
|
|
39
|
-
parserError: observable,
|
|
40
|
-
compilationError: observable,
|
|
41
|
-
lambdaId: computed,
|
|
42
|
-
fullLambdaString: computed,
|
|
43
|
-
setLambdaString: action,
|
|
44
|
-
clearErrors: action,
|
|
45
|
-
setCompilationError: action,
|
|
46
|
-
setParserError: action,
|
|
47
|
-
convertLambdaGrammarStringToObject: flow,
|
|
48
|
-
convertLambdaObjectToGrammarString: flow,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
this.lambdaString = lambdaString;
|
|
52
|
-
this.lambdaPrefix = lambdaPrefix;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
abstract get lambdaId(): string;
|
|
56
|
-
|
|
57
|
-
// value shown in lambda editor with the prefix, used to send to the server to transformation from text to JSON
|
|
58
|
-
get fullLambdaString(): string {
|
|
59
|
-
return `${this.lambdaPrefix}${this.lambdaString}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
setLambdaString(val: string): void {
|
|
63
|
-
this.lambdaString = val;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
clearErrors(): void {
|
|
67
|
-
this.setCompilationError(undefined);
|
|
68
|
-
this.setParserError(undefined);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
setCompilationError(compilationError: CompilationError | undefined): void {
|
|
72
|
-
// account for the lambda prefix offset in source information
|
|
73
|
-
if (compilationError?.sourceInformation) {
|
|
74
|
-
compilationError.sourceInformation = this.processSourceInformation(
|
|
75
|
-
compilationError.sourceInformation,
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
this.compilationError = compilationError;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
setParserError(parserError: ParserError | undefined): void {
|
|
82
|
-
// account for the lambda prefix offset in source information
|
|
83
|
-
if (parserError?.sourceInformation) {
|
|
84
|
-
parserError.sourceInformation = this.processSourceInformation(
|
|
85
|
-
parserError.sourceInformation,
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
this.parserError = parserError;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
processSourceInformation(
|
|
92
|
-
sourceInformation: SourceInformation,
|
|
93
|
-
): SourceInformation {
|
|
94
|
-
const { sourceId, startLine, startColumn, endLine, endColumn } =
|
|
95
|
-
sourceInformation;
|
|
96
|
-
const lineOffset = 0;
|
|
97
|
-
const columnOffset = this.lambdaPrefix.length;
|
|
98
|
-
return new SourceInformation(
|
|
99
|
-
sourceId,
|
|
100
|
-
startLine + lineOffset,
|
|
101
|
-
startColumn - (startLine === 1 ? columnOffset : 0),
|
|
102
|
-
endLine + lineOffset,
|
|
103
|
-
endColumn - (endLine === 1 ? columnOffset : 0),
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
extractLambdaString(fullLambdaString: string): string {
|
|
108
|
-
return fullLambdaString.substring(
|
|
109
|
-
fullLambdaString.indexOf(this.lambdaPrefix) + this.lambdaPrefix.length,
|
|
110
|
-
fullLambdaString.length,
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
abstract convertLambdaGrammarStringToObject(): GeneratorFn<void>;
|
|
115
|
-
abstract convertLambdaObjectToGrammarString(
|
|
116
|
-
pretty: boolean,
|
|
117
|
-
): GeneratorFn<void>;
|
|
118
|
-
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
type ObserverContext,
|
|
19
|
-
type Type,
|
|
20
|
-
type ValueSpecification,
|
|
21
|
-
type PureModel,
|
|
22
|
-
GenericType,
|
|
23
|
-
GenericTypeExplicitReference,
|
|
24
|
-
observe_ValueSpecification,
|
|
25
|
-
observe_VariableExpression,
|
|
26
|
-
PrimitiveInstanceValue,
|
|
27
|
-
PRIMITIVE_TYPE,
|
|
28
|
-
VariableExpression,
|
|
29
|
-
LambdaFunction,
|
|
30
|
-
TYPICAL_MULTIPLICITY_TYPE,
|
|
31
|
-
CORE_PURE_PATH,
|
|
32
|
-
FunctionType,
|
|
33
|
-
SimpleFunctionExpression,
|
|
34
|
-
SUPPORTED_FUNCTIONS,
|
|
35
|
-
extractElementNameFromPath,
|
|
36
|
-
generateVariableExpressionMockValue,
|
|
37
|
-
} from '@finos/legend-graph';
|
|
38
|
-
import {
|
|
39
|
-
addUniqueEntry,
|
|
40
|
-
deleteEntry,
|
|
41
|
-
type Hashable,
|
|
42
|
-
hashArray,
|
|
43
|
-
IllegalStateError,
|
|
44
|
-
isNonNullable,
|
|
45
|
-
uuid,
|
|
46
|
-
} from '@finos/legend-shared';
|
|
47
|
-
import { makeObservable, observable, action, computed } from 'mobx';
|
|
48
|
-
import {
|
|
49
|
-
genericType_setRawType,
|
|
50
|
-
multiplicity_setLowerBound,
|
|
51
|
-
multiplicity_setUpperBound,
|
|
52
|
-
} from './ValueSpecificationModifierHelper.js';
|
|
53
|
-
|
|
54
|
-
export enum PARAMETER_SUBMIT_ACTION {
|
|
55
|
-
EXECUTE = 'EXECUTE',
|
|
56
|
-
EXPORT = 'EXPORT',
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
enum LAMABA_PARAMETER_HASH_STRUCTURE {
|
|
60
|
-
LAMBDA_PARAMETER_STATE = 'LAMBDA_PARAMETER_STATE',
|
|
61
|
-
LAMBDA_PARAMETERS_STATE = 'LAMBDA_PARAMETERS_STATE',
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const buildParametersLetLambdaFunc = (
|
|
65
|
-
graph: PureModel,
|
|
66
|
-
lambdaParametersStates: LambdaParameterState[],
|
|
67
|
-
): LambdaFunction => {
|
|
68
|
-
const multiplicityOne = graph.getTypicalMultiplicity(
|
|
69
|
-
TYPICAL_MULTIPLICITY_TYPE.ONE,
|
|
70
|
-
);
|
|
71
|
-
const typeString = graph.getPrimitiveType(PRIMITIVE_TYPE.STRING);
|
|
72
|
-
const typeAny = graph.getType(CORE_PURE_PATH.ANY);
|
|
73
|
-
const letlambdaFunction = new LambdaFunction(
|
|
74
|
-
new FunctionType(typeAny, multiplicityOne),
|
|
75
|
-
);
|
|
76
|
-
letlambdaFunction.expressionSequence = lambdaParametersStates
|
|
77
|
-
.map((queryParamState) => {
|
|
78
|
-
if (queryParamState.value) {
|
|
79
|
-
const letFunc = new SimpleFunctionExpression(
|
|
80
|
-
extractElementNameFromPath(SUPPORTED_FUNCTIONS.LET),
|
|
81
|
-
multiplicityOne,
|
|
82
|
-
);
|
|
83
|
-
const letVar = new PrimitiveInstanceValue(
|
|
84
|
-
GenericTypeExplicitReference.create(new GenericType(typeString)),
|
|
85
|
-
multiplicityOne,
|
|
86
|
-
);
|
|
87
|
-
letVar.values = [queryParamState.variableName];
|
|
88
|
-
letFunc.parametersValues.push(letVar);
|
|
89
|
-
letFunc.parametersValues.push(queryParamState.value);
|
|
90
|
-
return letFunc;
|
|
91
|
-
}
|
|
92
|
-
return undefined;
|
|
93
|
-
})
|
|
94
|
-
.filter(isNonNullable);
|
|
95
|
-
return letlambdaFunction;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export class LambdaParameterState implements Hashable {
|
|
99
|
-
readonly uuid = uuid();
|
|
100
|
-
readonly parameter: VariableExpression;
|
|
101
|
-
readonly graph: PureModel;
|
|
102
|
-
readonly observableContext: ObserverContext;
|
|
103
|
-
|
|
104
|
-
value: ValueSpecification | undefined;
|
|
105
|
-
|
|
106
|
-
constructor(
|
|
107
|
-
variableExpression: VariableExpression,
|
|
108
|
-
observableContext: ObserverContext,
|
|
109
|
-
graph: PureModel,
|
|
110
|
-
) {
|
|
111
|
-
makeObservable(this, {
|
|
112
|
-
value: observable,
|
|
113
|
-
setValue: action,
|
|
114
|
-
mockParameterValue: action,
|
|
115
|
-
hashCode: computed,
|
|
116
|
-
});
|
|
117
|
-
this.observableContext = observableContext;
|
|
118
|
-
this.parameter = observe_VariableExpression(variableExpression);
|
|
119
|
-
this.graph = graph;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
get hashCode(): string {
|
|
123
|
-
return hashArray([
|
|
124
|
-
LAMABA_PARAMETER_HASH_STRUCTURE.LAMBDA_PARAMETER_STATE,
|
|
125
|
-
this.parameter,
|
|
126
|
-
]);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
mockParameterValue(): void {
|
|
130
|
-
this.setValue(
|
|
131
|
-
generateVariableExpressionMockValue(this.parameter, this.graph),
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
setValue(value: ValueSpecification | undefined): void {
|
|
136
|
-
if (value instanceof VariableExpression) {
|
|
137
|
-
throw new IllegalStateError(
|
|
138
|
-
'Can not assign a parameter to another parameter',
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
this.value = value
|
|
142
|
-
? observe_ValueSpecification(value, this.observableContext)
|
|
143
|
-
: undefined;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
changeVariableType(type: Type): void {
|
|
147
|
-
if (type !== this.variableType) {
|
|
148
|
-
const genricType = this.parameter.genericType?.value;
|
|
149
|
-
if (genricType) {
|
|
150
|
-
genericType_setRawType(genricType, type);
|
|
151
|
-
}
|
|
152
|
-
this.mockParameterValue();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
changeMultiplicity(
|
|
157
|
-
lowerBound: number,
|
|
158
|
-
uppderBound: number | undefined,
|
|
159
|
-
): void {
|
|
160
|
-
const current = this.parameter.multiplicity;
|
|
161
|
-
if (
|
|
162
|
-
current.lowerBound !== lowerBound ||
|
|
163
|
-
current.upperBound !== uppderBound
|
|
164
|
-
) {
|
|
165
|
-
multiplicity_setLowerBound(current, lowerBound);
|
|
166
|
-
multiplicity_setUpperBound(current, uppderBound);
|
|
167
|
-
this.mockParameterValue();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
get variableName(): string {
|
|
172
|
-
return this.parameter.name;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get variableType(): Type | undefined {
|
|
176
|
-
return this.parameter.genericType?.value.rawType;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export class ParameterInstanceValuesEditorState {
|
|
181
|
-
showModal = false;
|
|
182
|
-
submitAction:
|
|
183
|
-
| {
|
|
184
|
-
handler: () => Promise<void>;
|
|
185
|
-
label: string;
|
|
186
|
-
}
|
|
187
|
-
| undefined;
|
|
188
|
-
|
|
189
|
-
constructor() {
|
|
190
|
-
makeObservable(this, {
|
|
191
|
-
showModal: observable,
|
|
192
|
-
submitAction: observable,
|
|
193
|
-
setShowModal: action,
|
|
194
|
-
open: action,
|
|
195
|
-
setSubmitAction: action,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
setShowModal(val: boolean): void {
|
|
200
|
-
this.showModal = val;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
setSubmitAction(
|
|
204
|
-
val:
|
|
205
|
-
| {
|
|
206
|
-
handler: () => Promise<void>;
|
|
207
|
-
label: string;
|
|
208
|
-
}
|
|
209
|
-
| undefined,
|
|
210
|
-
): void {
|
|
211
|
-
this.submitAction = val;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
open(handler: () => Promise<void>, label: string): void {
|
|
215
|
-
this.setSubmitAction({ handler, label });
|
|
216
|
-
this.setShowModal(true);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
close(): void {
|
|
220
|
-
this.setSubmitAction(undefined);
|
|
221
|
-
this.setShowModal(false);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export class LambdaParametersState implements Hashable {
|
|
226
|
-
parameterStates: LambdaParameterState[] = [];
|
|
227
|
-
parameterValuesEditorState = new ParameterInstanceValuesEditorState();
|
|
228
|
-
|
|
229
|
-
constructor() {
|
|
230
|
-
makeObservable(this, {
|
|
231
|
-
hashCode: computed,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
get hashCode(): string {
|
|
236
|
-
return hashArray([
|
|
237
|
-
LAMABA_PARAMETER_HASH_STRUCTURE.LAMBDA_PARAMETERS_STATE,
|
|
238
|
-
hashArray(this.parameterStates),
|
|
239
|
-
]);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
addParameter(val: LambdaParameterState): void {
|
|
243
|
-
addUniqueEntry(this.parameterStates, val);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
removeParameter(val: LambdaParameterState): void {
|
|
247
|
-
deleteEntry(this.parameterStates, val);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
setParameters(val: LambdaParameterState[]): void {
|
|
251
|
-
this.parameterStates = val;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
type GenericType,
|
|
19
|
-
type Type,
|
|
20
|
-
type Multiplicity,
|
|
21
|
-
type FunctionExpression,
|
|
22
|
-
type ValueSpecification,
|
|
23
|
-
type ObserverContext,
|
|
24
|
-
type VariableExpression,
|
|
25
|
-
type InstanceValue,
|
|
26
|
-
type GraphFetchTree,
|
|
27
|
-
type AbstractPropertyExpression,
|
|
28
|
-
observe_ValueSpecification,
|
|
29
|
-
} from '@finos/legend-graph';
|
|
30
|
-
import { addUniqueEntry, deleteEntry } from '@finos/legend-shared';
|
|
31
|
-
import { action } from 'mobx';
|
|
32
|
-
|
|
33
|
-
export const genericType_setRawType = action(
|
|
34
|
-
(genericType: GenericType, type: Type): void => {
|
|
35
|
-
genericType.rawType = type;
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
export const multiplicity_setLowerBound = action(
|
|
40
|
-
(_m: Multiplicity, val: number): void => {
|
|
41
|
-
_m.lowerBound = val;
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
export const multiplicity_setUpperBound = action(
|
|
45
|
-
(_m: Multiplicity, val: number | undefined): void => {
|
|
46
|
-
_m.upperBound = val;
|
|
47
|
-
},
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
export const functionExpression_setParametersValues = action(
|
|
51
|
-
(
|
|
52
|
-
functionExpression: FunctionExpression,
|
|
53
|
-
val: ValueSpecification[],
|
|
54
|
-
context: ObserverContext,
|
|
55
|
-
): void => {
|
|
56
|
-
functionExpression.parametersValues = val.map((v) =>
|
|
57
|
-
observe_ValueSpecification(v, context),
|
|
58
|
-
);
|
|
59
|
-
},
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
export const variableExpression_setName = action(
|
|
63
|
-
(v: VariableExpression, val: string): void => {
|
|
64
|
-
v.name = val;
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
export const instanceValue_changeValue = action(
|
|
69
|
-
(instanceValue: InstanceValue, val: unknown, idx: number) => {
|
|
70
|
-
instanceValue.values[idx] = val;
|
|
71
|
-
},
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
export const instanceValue_changeValues = action(
|
|
75
|
-
(instanceValue: InstanceValue, val: unknown[]) => {
|
|
76
|
-
instanceValue.values = val;
|
|
77
|
-
},
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
export const graphFetchTree_addSubTree = action(
|
|
81
|
-
(tree: GraphFetchTree, val: GraphFetchTree): void => {
|
|
82
|
-
addUniqueEntry(tree.subTrees, val);
|
|
83
|
-
},
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
export const graphFetchTree_removeSubTree = action(
|
|
87
|
-
(tree: GraphFetchTree, val: GraphFetchTree): void => {
|
|
88
|
-
deleteEntry(tree.subTrees, val);
|
|
89
|
-
},
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
export const propertyExpression_setParametersValue = action(
|
|
93
|
-
(
|
|
94
|
-
propertyExpression: AbstractPropertyExpression,
|
|
95
|
-
idx: number,
|
|
96
|
-
val: ValueSpecification,
|
|
97
|
-
context: ObserverContext,
|
|
98
|
-
): void => {
|
|
99
|
-
propertyExpression.parametersValues[idx] = observe_ValueSpecification(
|
|
100
|
-
val,
|
|
101
|
-
context,
|
|
102
|
-
);
|
|
103
|
-
},
|
|
104
|
-
);
|