@finos/legend-application-data-cube 0.3.0 → 0.3.2

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.
Files changed (31) hide show
  1. package/lib/components/builder/LegendDataCubeCreator.d.ts.map +1 -1
  2. package/lib/components/builder/LegendDataCubeCreator.js +5 -1
  3. package/lib/components/builder/LegendDataCubeCreator.js.map +1 -1
  4. package/lib/components/builder/source/UserDefinedFunctionDataCubeSourceBuilder.d.ts +46 -0
  5. package/lib/components/builder/source/UserDefinedFunctionDataCubeSourceBuilder.d.ts.map +1 -0
  6. package/lib/components/builder/source/UserDefinedFunctionDataCubeSourceBuilder.js +203 -0
  7. package/lib/components/builder/source/UserDefinedFunctionDataCubeSourceBuilder.js.map +1 -0
  8. package/lib/index.css +1 -1
  9. package/lib/package.json +5 -5
  10. package/lib/stores/LegendDataCubeDataCubeEngine.d.ts.map +1 -1
  11. package/lib/stores/LegendDataCubeDataCubeEngine.js +25 -2
  12. package/lib/stores/LegendDataCubeDataCubeEngine.js.map +1 -1
  13. package/lib/stores/builder/LegendDataCubeCreatorState.d.ts.map +1 -1
  14. package/lib/stores/builder/LegendDataCubeCreatorState.js +3 -0
  15. package/lib/stores/builder/LegendDataCubeCreatorState.js.map +1 -1
  16. package/lib/stores/builder/source/LegendDataCubeSourceBuilderState.d.ts +2 -1
  17. package/lib/stores/builder/source/LegendDataCubeSourceBuilderState.d.ts.map +1 -1
  18. package/lib/stores/builder/source/LegendDataCubeSourceBuilderState.js +1 -0
  19. package/lib/stores/builder/source/LegendDataCubeSourceBuilderState.js.map +1 -1
  20. package/lib/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.d.ts +50 -0
  21. package/lib/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.d.ts.map +1 -0
  22. package/lib/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.js +120 -0
  23. package/lib/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.js.map +1 -0
  24. package/package.json +15 -15
  25. package/src/components/builder/LegendDataCubeCreator.tsx +10 -0
  26. package/src/components/builder/source/UserDefinedFunctionDataCubeSourceBuilder.tsx +373 -0
  27. package/src/stores/LegendDataCubeDataCubeEngine.ts +56 -0
  28. package/src/stores/builder/LegendDataCubeCreatorState.tsx +7 -0
  29. package/src/stores/builder/source/LegendDataCubeSourceBuilderState.ts +1 -0
  30. package/src/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.ts +176 -0
  31. package/tsconfig.json +2 -0
@@ -19,6 +19,7 @@ export var LegendDataCubeSourceBuilderType;
19
19
  LegendDataCubeSourceBuilderType["LEGEND_QUERY"] = "Legend Query";
20
20
  LegendDataCubeSourceBuilderType["ADHOC_QUERY"] = "Ad hoc Query";
21
21
  LegendDataCubeSourceBuilderType["LOCAL_FILE"] = "Local File";
22
+ LegendDataCubeSourceBuilderType["USER_DEFINED_FUNCTION"] = "User Defined Function";
22
23
  })(LegendDataCubeSourceBuilderType || (LegendDataCubeSourceBuilderType = {}));
23
24
  export class LegendDataCubeSourceBuilderState {
24
25
  _application;
@@ -1 +1 @@
1
- {"version":3,"file":"LegendDataCubeSourceBuilderState.js","sourceRoot":"","sources":["../../../../src/stores/builder/source/LegendDataCubeSourceBuilderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAKxD,MAAM,CAAN,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACzC,gEAA6B,CAAA;IAC7B,+DAA4B,CAAA;IAC5B,4DAAyB,CAAA;AAC3B,CAAC,EAJW,+BAA+B,KAA/B,+BAA+B,QAI1C;AAED,MAAM,OAAgB,gCAAgC;IACjC,YAAY,CAAiC;IAC7C,OAAO,CAA+B;IAEzD,YACE,WAA2C,EAC3C,MAAoC;QAEpC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAMD;;OAEG;IACH,qBAAqB,CAAC,aAAoC;QACxD,aAAa;IACf,CAAC;CACF"}
1
+ {"version":3,"file":"LegendDataCubeSourceBuilderState.js","sourceRoot":"","sources":["../../../../src/stores/builder/source/LegendDataCubeSourceBuilderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAKxD,MAAM,CAAN,IAAY,+BAKX;AALD,WAAY,+BAA+B;IACzC,gEAA6B,CAAA;IAC7B,+DAA4B,CAAA;IAC5B,4DAAyB,CAAA;IACzB,kFAA+C,CAAA;AACjD,CAAC,EALW,+BAA+B,KAA/B,+BAA+B,QAK1C;AAED,MAAM,OAAgB,gCAAgC;IACjC,YAAY,CAAiC;IAC7C,OAAO,CAA+B;IAEzD,YACE,WAA2C,EAC3C,MAAoC;QAEpC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAMD;;OAEG;IACH,qBAAqB,CAAC,aAAoC;QACxD,aAAa;IACf,CAAC;CACF"}
@@ -0,0 +1,50 @@
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
+ import { ActionState, type PlainObject } from '@finos/legend-shared';
17
+ import { LegendDataCubeSourceBuilderState, LegendDataCubeSourceBuilderType } from './LegendDataCubeSourceBuilderState.js';
18
+ import { StoreProjectData } from '@finos/legend-server-depot';
19
+ import type { LegendDataCubeBuilderStore } from '../LegendDataCubeBuilderStore.js';
20
+ import type { LegendDataCubeDataCubeEngine } from '../../LegendDataCubeDataCubeEngine.js';
21
+ import type { LegendDataCubeApplicationStore } from '../../LegendDataCubeBaseStore.js';
22
+ import { type V1_PackageableRuntime, type V1_ConcreteFunctionDefinition } from '@finos/legend-graph';
23
+ import { type DataCubeConfiguration } from '@finos/legend-data-cube';
24
+ export declare class UserDefinedFunctionDataCubeSourceBuilderState extends LegendDataCubeSourceBuilderState {
25
+ projects: StoreProjectData[];
26
+ currentProject?: StoreProjectData | undefined;
27
+ currentProjectVersions?: string[] | undefined;
28
+ currentVersionId?: string | undefined;
29
+ builderStore: LegendDataCubeBuilderStore;
30
+ functions: V1_ConcreteFunctionDefinition[] | undefined;
31
+ currentFunction?: V1_ConcreteFunctionDefinition | undefined;
32
+ currentRuntime?: V1_PackageableRuntime | undefined;
33
+ runtimes?: V1_PackageableRuntime[] | undefined;
34
+ readonly loadProjectsState: ActionState;
35
+ constructor(application: LegendDataCubeApplicationStore, engine: LegendDataCubeDataCubeEngine, builderStore: LegendDataCubeBuilderStore);
36
+ setCurrentProject(val: StoreProjectData | undefined): void;
37
+ setCurrentProjectVersions(val: string[] | undefined): void;
38
+ setCurrentVersionId(val: string | undefined): void;
39
+ getProjects(): StoreProjectData[];
40
+ setFunctions(val: V1_ConcreteFunctionDefinition[] | undefined): void;
41
+ setCurrentFunction(val: V1_ConcreteFunctionDefinition | undefined): void;
42
+ setCurrentRuntime(val: V1_PackageableRuntime | undefined): void;
43
+ setRuntimes(val: V1_PackageableRuntime[] | undefined): void;
44
+ loadProjects(): Generator<Promise<PlainObject<T>[]>, void, PlainObject<T>[]>;
45
+ get label(): LegendDataCubeSourceBuilderType;
46
+ get isValid(): boolean;
47
+ generateSourceData(): Promise<PlainObject>;
48
+ finalizeConfiguration(configuration: DataCubeConfiguration): void;
49
+ }
50
+ //# sourceMappingURL=UserDefinedFunctionDataCubeSourceBuilderState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserDefinedFunctionDataCubeSourceBuilderState.d.ts","sourceRoot":"","sources":["../../../../src/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,WAAW,EAGX,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAEvF,OAAO,EAEL,KAAK,qBAAqB,EAG1B,KAAK,6BAA6B,EACnC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,6CAA8C,SAAQ,gCAAgC;IACjG,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAClC,cAAc,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC9C,sBAAsB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9C,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,YAAY,EAAE,0BAA0B,CAAC;IACzC,SAAS,EAAE,6BAA6B,EAAE,GAAG,SAAS,CAAC;IACvD,eAAe,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;IAC5D,cAAc,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACnD,QAAQ,CAAC,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC;IAE/C,QAAQ,CAAC,iBAAiB,cAAwB;gBAGhD,WAAW,EAAE,8BAA8B,EAC3C,MAAM,EAAE,4BAA4B,EACpC,YAAY,EAAE,0BAA0B;IAoB1C,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI;IAI1D,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAI1D,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIlD,WAAW,IAAI,gBAAgB,EAAE;IAIjC,YAAY,CAAC,GAAG,EAAE,6BAA6B,EAAE,GAAG,SAAS,GAAG,IAAI;IAIpE,kBAAkB,CAAC,GAAG,EAAE,6BAA6B,GAAG,SAAS,GAAG,IAAI;IAMxE,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,GAAG,SAAS,GAAG,IAAI;IAI/D,WAAW,CAAC,GAAG,EAAE,qBAAqB,EAAE,GAAG,SAAS,GAAG,IAAI;IAI1D,YAAY;IAcb,IAAa,KAAK,IAAI,+BAA+B,CAEpD;IAED,IAAa,OAAO,IAAI,OAAO,CAO9B;IAEc,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC;IA8BhD,qBAAqB,CAAC,aAAa,EAAE,qBAAqB;CAKpE"}
@@ -0,0 +1,120 @@
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
+ import { ActionState, IllegalStateError, assertErrorThrown, } from '@finos/legend-shared';
17
+ import { LegendDataCubeSourceBuilderState, LegendDataCubeSourceBuilderType, } from './LegendDataCubeSourceBuilderState.js';
18
+ import { StoreProjectData } from '@finos/legend-server-depot';
19
+ import { action, flow, makeObservable, observable, runInAction } from 'mobx';
20
+ import { V1_LegendSDLC, V1_PureModelContextPointer, V1_serializePureModelContext, } from '@finos/legend-graph';
21
+ import { RawUserDefinedFunctionDataCubeSource, } from '@finos/legend-data-cube';
22
+ export class UserDefinedFunctionDataCubeSourceBuilderState extends LegendDataCubeSourceBuilderState {
23
+ projects = [];
24
+ currentProject;
25
+ currentProjectVersions;
26
+ currentVersionId;
27
+ builderStore;
28
+ functions;
29
+ currentFunction;
30
+ currentRuntime;
31
+ runtimes;
32
+ loadProjectsState = ActionState.create();
33
+ constructor(application, engine, builderStore) {
34
+ super(application, engine);
35
+ this.builderStore = builderStore;
36
+ makeObservable(this, {
37
+ loadProjects: flow,
38
+ currentFunction: observable,
39
+ projects: observable,
40
+ currentProject: observable,
41
+ currentProjectVersions: observable,
42
+ currentVersionId: observable,
43
+ currentRuntime: observable,
44
+ setCurrentProject: action,
45
+ setCurrentProjectVersions: action,
46
+ setCurrentVersionId: action,
47
+ setCurrentRuntime: action,
48
+ });
49
+ }
50
+ setCurrentProject(val) {
51
+ this.currentProject = val;
52
+ }
53
+ setCurrentProjectVersions(val) {
54
+ this.currentProjectVersions = val;
55
+ }
56
+ setCurrentVersionId(val) {
57
+ this.currentVersionId = val;
58
+ }
59
+ getProjects() {
60
+ return this.projects;
61
+ }
62
+ setFunctions(val) {
63
+ this.functions = val;
64
+ }
65
+ setCurrentFunction(val) {
66
+ runInAction(() => {
67
+ this.currentFunction = val;
68
+ });
69
+ }
70
+ setCurrentRuntime(val) {
71
+ this.currentRuntime = val;
72
+ }
73
+ setRuntimes(val) {
74
+ this.runtimes = val;
75
+ }
76
+ *loadProjects() {
77
+ this.loadProjectsState.inProgress();
78
+ try {
79
+ this.projects = (yield this.builderStore.depotServerClient.getProjects()).map((v) => StoreProjectData.serialization.fromJson(v));
80
+ this.loadProjectsState.pass();
81
+ }
82
+ catch (error) {
83
+ assertErrorThrown(error);
84
+ this.builderStore.application.notificationService.notifyError(error);
85
+ this.loadProjectsState.fail();
86
+ }
87
+ }
88
+ get label() {
89
+ return LegendDataCubeSourceBuilderType.USER_DEFINED_FUNCTION;
90
+ }
91
+ get isValid() {
92
+ return Boolean(this.currentFunction &&
93
+ this.currentRuntime &&
94
+ this.currentProject &&
95
+ this.currentVersionId);
96
+ }
97
+ async generateSourceData() {
98
+ if (!this.isValid) {
99
+ throw new IllegalStateError(`Can't generate source data: project, version, function, or runtime are not set`);
100
+ }
101
+ const source = new RawUserDefinedFunctionDataCubeSource();
102
+ if (this.currentProject &&
103
+ this.currentVersionId &&
104
+ this.currentRuntime &&
105
+ this.currentFunction) {
106
+ source.functionPath = this.currentFunction.path;
107
+ source.runtime = this.currentRuntime.path;
108
+ const sdlc = new V1_LegendSDLC(this.currentProject.groupId, this.currentProject.artifactId, this.currentVersionId);
109
+ const modelContextPointer = new V1_PureModelContextPointer(undefined, sdlc);
110
+ source.model = V1_serializePureModelContext(modelContextPointer);
111
+ }
112
+ return RawUserDefinedFunctionDataCubeSource.serialization.toJson(source);
113
+ }
114
+ finalizeConfiguration(configuration) {
115
+ if (this.currentFunction) {
116
+ configuration.name = this.currentFunction.name;
117
+ }
118
+ }
119
+ }
120
+ //# sourceMappingURL=UserDefinedFunctionDataCubeSourceBuilderState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserDefinedFunctionDataCubeSourceBuilderState.js","sourceRoot":"","sources":["../../../../src/stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,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AAK,CAAC,kBAAkB;QAC/B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,CACjF,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,oCAAoC,EAAE,CAAC;QAC1D,IACE,IAAI,CAAC,cAAc;YACnB,IAAI,CAAC,gBAAgB;YACrB,IAAI,CAAC,cAAc;YACnB,IAAI,CAAC,eAAe,EACpB,CAAC;YACD,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YAChD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC1C,MAAM,IAAI,GAAG,IAAI,aAAa,CAC5B,IAAI,CAAC,cAAc,CAAC,OAAO,EAC3B,IAAI,CAAC,cAAc,CAAC,UAAU,EAC9B,IAAI,CAAC,gBAAgB,CACtB,CAAC;YACF,MAAM,mBAAmB,GAAG,IAAI,0BAA0B,CACxD,SAAS,EACT,IAAI,CACL,CAAC;YACF,MAAM,CAAC,KAAK,GAAG,4BAA4B,CAAC,mBAAmB,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,oCAAoC,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;IAEQ,qBAAqB,CAAC,aAAoC;QACjE,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;QACjD,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finos/legend-application-data-cube",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Legend DataCube application core",
5
5
  "keywords": [
6
6
  "legend",
@@ -43,17 +43,17 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@duckdb/duckdb-wasm": "1.29.0",
46
- "@finos/legend-application": "16.0.26",
47
- "@finos/legend-art": "7.1.83",
48
- "@finos/legend-code-editor": "2.0.47",
49
- "@finos/legend-data-cube": "0.1.7",
50
- "@finos/legend-graph": "32.1.5",
51
- "@finos/legend-query-builder": "4.16.7",
52
- "@finos/legend-server-depot": "6.0.82",
53
- "@finos/legend-shared": "11.0.5",
54
- "@finos/legend-storage": "3.0.124",
55
- "@types/react": "19.0.8",
56
- "@types/react-dom": "19.0.3",
46
+ "@finos/legend-application": "16.0.27",
47
+ "@finos/legend-art": "7.1.84",
48
+ "@finos/legend-code-editor": "2.0.49",
49
+ "@finos/legend-data-cube": "0.1.9",
50
+ "@finos/legend-graph": "32.1.7",
51
+ "@finos/legend-query-builder": "4.16.9",
52
+ "@finos/legend-server-depot": "6.0.83",
53
+ "@finos/legend-shared": "11.0.6",
54
+ "@finos/legend-storage": "3.0.125",
55
+ "@types/react": "19.0.10",
56
+ "@types/react-dom": "19.0.4",
57
57
  "apache-arrow": "19.0.0",
58
58
  "mobx": "6.13.6",
59
59
  "mobx-react-lite": "4.1.0",
@@ -62,14 +62,14 @@
62
62
  "serializr": "3.0.3"
63
63
  },
64
64
  "devDependencies": {
65
- "@finos/legend-dev-utils": "2.2.1",
65
+ "@finos/legend-dev-utils": "2.2.2",
66
66
  "@jest/globals": "29.7.0",
67
67
  "cross-env": "7.0.3",
68
- "eslint": "9.20.0",
68
+ "eslint": "9.20.1",
69
69
  "jest": "29.7.0",
70
70
  "npm-run-all": "4.1.5",
71
71
  "rimraf": "6.0.1",
72
- "sass": "1.84.0",
72
+ "sass": "1.85.0",
73
73
  "typescript": "5.7.3"
74
74
  },
75
75
  "peerDependencies": {
@@ -31,6 +31,8 @@ import { AdhocQueryDataCubeSourceBuilderState } from '../../stores/builder/sourc
31
31
  import { useLegendDataCubeBuilderStore } from './LegendDataCubeBuilderStoreProvider.js';
32
32
  import { LocalFileDataCubeSourceBuilderState } from '../../stores/builder/source/LocalFileDataCubeSourceBuilderState.js';
33
33
  import { LocalFileDataCubeSourceBuilder } from './source/LocalFileDataCubeSourceBuilder.js';
34
+ import { UserDefinedFunctionDataCubeSourceBuilderState } from '../../stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.js';
35
+ import { UserDefinedFunctionDataCubeSourceBuilder } from './source/UserDefinedFunctionDataCubeSourceBuilder.js';
34
36
 
35
37
  export const LegendDataCubeCreator = observer(() => {
36
38
  const store = useLegendDataCubeBuilderStore();
@@ -72,6 +74,7 @@ export const LegendDataCubeCreator = observer(() => {
72
74
  <FormDropdownMenu className="w-80" {...sourceTypeDropdownProps}>
73
75
  {[
74
76
  LegendDataCubeSourceBuilderType.LEGEND_QUERY,
77
+ LegendDataCubeSourceBuilderType.USER_DEFINED_FUNCTION,
75
78
  LegendDataCubeSourceBuilderType.ADHOC_QUERY,
76
79
  LegendDataCubeSourceBuilderType.LOCAL_FILE,
77
80
  ].map((type) => (
@@ -106,6 +109,13 @@ export const LegendDataCubeCreator = observer(() => {
106
109
  {sourceBuilder instanceof LocalFileDataCubeSourceBuilderState && (
107
110
  <LocalFileDataCubeSourceBuilder sourceBuilder={sourceBuilder} />
108
111
  )}
112
+ {sourceBuilder instanceof
113
+ UserDefinedFunctionDataCubeSourceBuilderState && (
114
+ <UserDefinedFunctionDataCubeSourceBuilder
115
+ sourceBuilder={sourceBuilder}
116
+ store={store}
117
+ />
118
+ )}
109
119
  </div>
110
120
  </div>
111
121
  </div>
@@ -0,0 +1,373 @@
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 { observer } from 'mobx-react-lite';
18
+ import { CustomSelectorInput } from '@finos/legend-art';
19
+ import { useEffect, useState } from 'react';
20
+ import { flowResult } from 'mobx';
21
+ import type { LegendDataCubeBuilderStore } from '../../../stores/builder/LegendDataCubeBuilderStore.js';
22
+ import {
23
+ LATEST_VERSION_ALIAS,
24
+ MASTER_SNAPSHOT_ALIAS,
25
+ SNAPSHOT_VERSION_ALIAS,
26
+ type StoreProjectData,
27
+ } from '@finos/legend-server-depot';
28
+ import {
29
+ ActionState,
30
+ assertErrorThrown,
31
+ compareSemVerVersions,
32
+ guaranteeNonNullable,
33
+ } from '@finos/legend-shared';
34
+ import {
35
+ CORE_PURE_PATH,
36
+ V1_ConcreteFunctionDefinition,
37
+ V1_PackageableRuntime,
38
+ V1_PackageableType,
39
+ V1_deserializePackageableElement,
40
+ } from '@finos/legend-graph';
41
+ import type { Entity } from '@finos/legend-storage';
42
+ import type { UserDefinedFunctionDataCubeSourceBuilderState } from '../../../stores/builder/source/UserDefinedFunctionDataCubeSourceBuilderState.js';
43
+
44
+ export type ProjectOption = { label: string; value: StoreProjectData };
45
+ export const buildProjectOption = (
46
+ project: StoreProjectData,
47
+ ): ProjectOption => ({
48
+ label: `${project.groupId}.${project.artifactId}`,
49
+ value: project,
50
+ });
51
+
52
+ export type VersionOption = { label: string; value: string };
53
+ export const buildVersionOption = (version: string): VersionOption => {
54
+ if (version === MASTER_SNAPSHOT_ALIAS) {
55
+ return {
56
+ label: SNAPSHOT_VERSION_ALIAS,
57
+ value: version,
58
+ };
59
+ }
60
+ return {
61
+ label: version,
62
+ value: version,
63
+ };
64
+ };
65
+
66
+ export type FunctionOption = {
67
+ label: string;
68
+ value: V1_ConcreteFunctionDefinition;
69
+ };
70
+ export const buildFunctionOption = (
71
+ functionDefinition: V1_ConcreteFunctionDefinition,
72
+ ): FunctionOption => ({
73
+ label: functionDefinition.name,
74
+ value: functionDefinition,
75
+ });
76
+
77
+ export type RuntimeOption = {
78
+ label: string;
79
+ value: V1_PackageableRuntime;
80
+ };
81
+ export const buildRuntimeOption = (
82
+ runtime: V1_PackageableRuntime,
83
+ ): RuntimeOption => ({
84
+ label: runtime.name,
85
+ value: runtime,
86
+ });
87
+
88
+ export const UserDefinedFunctionDataCubeSourceBuilder = observer(
89
+ (props: {
90
+ sourceBuilder: UserDefinedFunctionDataCubeSourceBuilderState;
91
+ store: LegendDataCubeBuilderStore;
92
+ }) => {
93
+ const { sourceBuilder, store } = props;
94
+ const [fetchSelectedProjectVersionsStatus] = useState(ActionState.create());
95
+ const [fetchSelectedVersionFunctionsStatus] = useState(
96
+ ActionState.create(),
97
+ );
98
+ const [fetchSelectedVersionRuntimesStatus] = useState(ActionState.create());
99
+
100
+ //projects
101
+ const projectOptions = sourceBuilder.projects.map(buildProjectOption);
102
+ const selectedProjectOption = sourceBuilder.currentProject
103
+ ? buildProjectOption(sourceBuilder.currentProject)
104
+ : null;
105
+ const projectSelectorPlaceholder = sourceBuilder.loadProjectsState
106
+ .isInProgress
107
+ ? 'Loading projects'
108
+ : sourceBuilder.loadProjectsState.hasFailed
109
+ ? 'Error fetching projects'
110
+ : sourceBuilder.projects.length
111
+ ? 'Choose a project'
112
+ : 'No Projects available from depot';
113
+ const onProjectOptionChange = async (
114
+ option: ProjectOption | null,
115
+ ): Promise<void> => {
116
+ if (option?.value !== sourceBuilder.currentProject) {
117
+ sourceBuilder.setCurrentProject(option?.value);
118
+
119
+ // cascade
120
+ sourceBuilder.setCurrentVersionId(undefined);
121
+ sourceBuilder.setCurrentProjectVersions([]);
122
+ sourceBuilder.setCurrentFunction(undefined);
123
+ sourceBuilder.setFunctions([]);
124
+ sourceBuilder.setCurrentRuntime(undefined);
125
+ sourceBuilder.setRuntimes([]);
126
+
127
+ try {
128
+ fetchSelectedProjectVersionsStatus.inProgress();
129
+ const versions = await store.depotServerClient.getVersions(
130
+ guaranteeNonNullable(option?.value.groupId),
131
+ guaranteeNonNullable(option?.value.artifactId),
132
+ true,
133
+ );
134
+ sourceBuilder.setCurrentProjectVersions(versions);
135
+ } catch (error) {
136
+ assertErrorThrown(error);
137
+ store.application.notificationService.notifyError(error);
138
+ } finally {
139
+ fetchSelectedProjectVersionsStatus.reset();
140
+ }
141
+ }
142
+ };
143
+
144
+ //versions
145
+ const versionOptions = [
146
+ LATEST_VERSION_ALIAS,
147
+ ...(sourceBuilder.currentProjectVersions ?? []),
148
+ ]
149
+ .toSorted((v1, v2) => compareSemVerVersions(v2, v1))
150
+ .map(buildVersionOption);
151
+ const selectedVersionOption = sourceBuilder.currentVersionId
152
+ ? buildVersionOption(sourceBuilder.currentVersionId)
153
+ : null;
154
+ const versionSelectorPlaceholder = !sourceBuilder.currentProject
155
+ ? 'No project selected'
156
+ : 'Choose a version';
157
+ const validFunctionReturn = (
158
+ currentPackageableElement: V1_ConcreteFunctionDefinition,
159
+ ) => {
160
+ if (
161
+ currentPackageableElement.returnGenericType.rawType instanceof
162
+ V1_PackageableType
163
+ ) {
164
+ const fullPath =
165
+ currentPackageableElement.returnGenericType.rawType.fullPath;
166
+ return fullPath === CORE_PURE_PATH.RELATION;
167
+ }
168
+ return false;
169
+ };
170
+ const onVersionChange = async (
171
+ option: VersionOption | null,
172
+ ): Promise<void> => {
173
+ if (option?.value !== sourceBuilder.currentVersionId) {
174
+ sourceBuilder.setCurrentVersionId(option?.value);
175
+
176
+ //cascade
177
+ sourceBuilder.setCurrentFunction(undefined);
178
+ sourceBuilder.setFunctions([]);
179
+ sourceBuilder.setCurrentRuntime(undefined);
180
+ sourceBuilder.setRuntimes([]);
181
+
182
+ try {
183
+ const plugins =
184
+ store.application.pluginManager.getPureProtocolProcessorPlugins();
185
+
186
+ //functions
187
+ fetchSelectedVersionFunctionsStatus.inProgress();
188
+ const allFetchedFunctions =
189
+ await store.depotServerClient.getVersionEntities(
190
+ guaranteeNonNullable(sourceBuilder.currentProject?.groupId),
191
+ guaranteeNonNullable(sourceBuilder.currentProject?.artifactId),
192
+ guaranteeNonNullable(option?.value),
193
+ CORE_PURE_PATH.FUNCTION,
194
+ );
195
+
196
+ const fetchedFunctionOptions: V1_ConcreteFunctionDefinition[] = [];
197
+ allFetchedFunctions.forEach((fn) => {
198
+ const functionEntity = fn.entity as Entity;
199
+ const currentFunction = V1_deserializePackageableElement(
200
+ functionEntity.content,
201
+ plugins,
202
+ );
203
+ if (
204
+ currentFunction instanceof V1_ConcreteFunctionDefinition &&
205
+ validFunctionReturn(currentFunction)
206
+ ) {
207
+ fetchedFunctionOptions.push(currentFunction);
208
+ }
209
+ });
210
+ sourceBuilder.setFunctions(fetchedFunctionOptions);
211
+
212
+ //runtimes
213
+ fetchSelectedVersionRuntimesStatus.inProgress();
214
+ const allFetchedRuntimes =
215
+ await store.depotServerClient.getVersionEntities(
216
+ guaranteeNonNullable(sourceBuilder.currentProject?.groupId),
217
+ guaranteeNonNullable(sourceBuilder.currentProject?.artifactId),
218
+ guaranteeNonNullable(option?.value),
219
+ CORE_PURE_PATH.RUNTIME,
220
+ );
221
+
222
+ const fetchedRuntimeOptions: V1_PackageableRuntime[] = [];
223
+ allFetchedRuntimes.forEach((runtime) => {
224
+ const runtimeEntity = runtime.entity as Entity;
225
+ const currentRuntimeElement = V1_deserializePackageableElement(
226
+ runtimeEntity.content,
227
+ plugins,
228
+ );
229
+ if (currentRuntimeElement instanceof V1_PackageableRuntime) {
230
+ fetchedRuntimeOptions.push(currentRuntimeElement);
231
+ }
232
+ });
233
+ sourceBuilder.setRuntimes(fetchedRuntimeOptions);
234
+ } catch (error) {
235
+ assertErrorThrown(error);
236
+ store.application.notificationService.notifyError(error);
237
+ } finally {
238
+ fetchSelectedVersionFunctionsStatus.reset();
239
+ fetchSelectedVersionRuntimesStatus.reset();
240
+ }
241
+ }
242
+ };
243
+
244
+ //functions
245
+ const functionOptions = sourceBuilder.functions?.map((functionDefinition) =>
246
+ buildFunctionOption(functionDefinition),
247
+ );
248
+ const selectedFunctionOption = sourceBuilder.currentFunction
249
+ ? buildFunctionOption(sourceBuilder.currentFunction)
250
+ : null;
251
+ const functionSelectorPlaceholder = !sourceBuilder.currentVersionId
252
+ ? 'No version selected'
253
+ : 'Choose a function';
254
+ const onFunctionChange = (option: FunctionOption | null) => {
255
+ if (option?.value !== sourceBuilder.currentFunction) {
256
+ sourceBuilder.setCurrentFunction(option?.value);
257
+ }
258
+ };
259
+
260
+ //runtimes
261
+ const runtimeOptions = sourceBuilder.runtimes?.map(buildRuntimeOption);
262
+ const selectedRuntimeOption = sourceBuilder.currentRuntime
263
+ ? buildRuntimeOption(sourceBuilder.currentRuntime)
264
+ : null;
265
+ const runtimeSelectorPlaceholder = !sourceBuilder.currentVersionId
266
+ ? 'No version selected'
267
+ : 'Choose a function';
268
+ const onRuntimeChange = (option: RuntimeOption | null) => {
269
+ if (option?.value !== sourceBuilder.currentRuntime) {
270
+ sourceBuilder.setCurrentRuntime(option?.value);
271
+ }
272
+ };
273
+
274
+ useEffect(() => {
275
+ flowResult(sourceBuilder.loadProjects()).catch(
276
+ store.application.alertUnhandledError,
277
+ );
278
+ }, [sourceBuilder, store.application]);
279
+
280
+ return (
281
+ <div className="flex h-full w-full">
282
+ <div className="m-3 flex w-full flex-col items-stretch gap-2 text-neutral-500">
283
+ <div className="query-setup__wizard__group">
284
+ <div className="query-setup__wizard__group__title">Project</div>
285
+ <CustomSelectorInput
286
+ className="query-setup__wizard__selector"
287
+ options={projectOptions}
288
+ disabled={
289
+ sourceBuilder.loadProjectsState.isInProgress ||
290
+ !projectOptions.length
291
+ }
292
+ isLoading={sourceBuilder.loadProjectsState.isInProgress}
293
+ onChange={(option: ProjectOption | null) => {
294
+ onProjectOptionChange(option).catch(
295
+ store.application.alertUnhandledError,
296
+ );
297
+ }}
298
+ value={selectedProjectOption}
299
+ placeholder={projectSelectorPlaceholder}
300
+ isClearable={true}
301
+ escapeClearsValue={true}
302
+ />
303
+ </div>
304
+
305
+ <div className="query-setup__wizard__group">
306
+ <div className="query-setup__wizard__group__title">Version</div>
307
+ <CustomSelectorInput
308
+ className="query-setup__wizard__selector"
309
+ options={versionOptions}
310
+ disabled={
311
+ !sourceBuilder.currentProject ||
312
+ fetchSelectedProjectVersionsStatus.isInProgress ||
313
+ !versionOptions.length
314
+ }
315
+ isLoading={fetchSelectedProjectVersionsStatus.isInProgress}
316
+ onChange={(option: VersionOption | null) => {
317
+ onVersionChange(option).catch(
318
+ store.application.alertUnhandledError,
319
+ );
320
+ }}
321
+ value={selectedVersionOption}
322
+ placeholder={versionSelectorPlaceholder}
323
+ isClearable={true}
324
+ escapeClearsValue={true}
325
+ />
326
+ </div>
327
+
328
+ <div className="query-setup__wizard__group">
329
+ <div className="query-setup__wizard__group__title">Function</div>
330
+ <CustomSelectorInput
331
+ className="query-setup__wizard__selector"
332
+ options={functionOptions}
333
+ disabled={
334
+ !sourceBuilder.currentVersionId ||
335
+ fetchSelectedVersionFunctionsStatus.isInProgress ||
336
+ !versionOptions.length
337
+ }
338
+ isLoading={fetchSelectedVersionFunctionsStatus.isInProgress}
339
+ onChange={(option: FunctionOption | null) => {
340
+ onFunctionChange(option);
341
+ }}
342
+ value={selectedFunctionOption}
343
+ placeholder={functionSelectorPlaceholder}
344
+ isClearable={true}
345
+ escapeClearsValue={true}
346
+ />
347
+ </div>
348
+
349
+ <div className="query-setup__wizard__group">
350
+ <div className="query-setup__wizard__group__title">Runtime</div>
351
+ <CustomSelectorInput
352
+ className="query-setup__wizard__selector"
353
+ options={runtimeOptions}
354
+ disabled={
355
+ !sourceBuilder.currentVersionId ||
356
+ fetchSelectedVersionRuntimesStatus.isInProgress ||
357
+ !versionOptions.length
358
+ }
359
+ isLoading={fetchSelectedVersionRuntimesStatus.isInProgress}
360
+ onChange={(option: RuntimeOption | null) => {
361
+ onRuntimeChange(option);
362
+ }}
363
+ value={selectedRuntimeOption}
364
+ placeholder={runtimeSelectorPlaceholder}
365
+ isClearable={true}
366
+ escapeClearsValue={true}
367
+ />
368
+ </div>
369
+ </div>
370
+ </div>
371
+ );
372
+ },
373
+ );