@finos/legend-application-studio 28.21.51 → 28.21.53
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/editor/Editor.d.ts.map +1 -1
- package/lib/components/editor/Editor.js +2 -1
- package/lib/components/editor/Editor.js.map +1 -1
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.js +14 -2
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.js.map +1 -1
- package/lib/components/editor/embedded-cube/EmbeddedCube.d.ts +23 -0
- package/lib/components/editor/embedded-cube/EmbeddedCube.d.ts.map +1 -0
- package/lib/components/editor/embedded-cube/EmbeddedCube.js +38 -0
- package/lib/components/editor/embedded-cube/EmbeddedCube.js.map +1 -0
- package/lib/components/editor/embedded-cube/EmbeddedCubeEditor.d.ts +35 -0
- package/lib/components/editor/embedded-cube/EmbeddedCubeEditor.d.ts.map +1 -0
- package/lib/components/editor/embedded-cube/EmbeddedCubeEditor.js +179 -0
- package/lib/components/editor/embedded-cube/EmbeddedCubeEditor.js.map +1 -0
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js +4 -0
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +3 -1
- package/lib/stores/editor/EditorStore.d.ts +2 -0
- package/lib/stores/editor/EditorStore.d.ts.map +1 -1
- package/lib/stores/editor/EditorStore.js +6 -1
- package/lib/stores/editor/EditorStore.js.map +1 -1
- package/lib/stores/editor/embedded-cube/EmbeddedCubeState.d.ts +86 -0
- package/lib/stores/editor/embedded-cube/EmbeddedCubeState.d.ts.map +1 -0
- package/lib/stores/editor/embedded-cube/EmbeddedCubeState.js +206 -0
- package/lib/stores/editor/embedded-cube/EmbeddedCubeState.js.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeDataProductCatalog.d.ts +51 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeDataProductCatalog.d.ts.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeDataProductCatalog.js +148 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeDataProductCatalog.js.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeHost.d.ts +39 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeHost.d.ts.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeHost.js +60 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeHost.js.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeIngestCatalog.d.ts +57 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeIngestCatalog.d.ts.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeIngestCatalog.js +148 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeIngestCatalog.js.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeWorkspace.d.ts +58 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeWorkspace.d.ts.map +1 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeWorkspace.js +94 -0
- package/lib/stores/editor/embedded-cube/LegendStudioCubeWorkspace.js.map +1 -0
- package/lib/stores/graph-modifier/DSL_Ingest_GraphModifierHelper.d.ts +57 -0
- package/lib/stores/graph-modifier/DSL_Ingest_GraphModifierHelper.d.ts.map +1 -0
- package/lib/stores/graph-modifier/DSL_Ingest_GraphModifierHelper.js +151 -0
- package/lib/stores/graph-modifier/DSL_Ingest_GraphModifierHelper.js.map +1 -0
- package/package.json +13 -11
- package/src/components/editor/Editor.tsx +2 -0
- package/src/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.tsx +62 -0
- package/src/components/editor/embedded-cube/EmbeddedCube.tsx +57 -0
- package/src/components/editor/embedded-cube/EmbeddedCubeEditor.tsx +452 -0
- package/src/components/extensions/Core_LegendStudioApplicationPlugin.tsx +4 -0
- package/src/stores/editor/EditorStore.ts +6 -1
- package/src/stores/editor/embedded-cube/EmbeddedCubeState.ts +284 -0
- package/src/stores/editor/embedded-cube/LegendStudioCubeDataProductCatalog.ts +242 -0
- package/src/stores/editor/embedded-cube/LegendStudioCubeHost.ts +82 -0
- package/src/stores/editor/embedded-cube/LegendStudioCubeIngestCatalog.ts +235 -0
- package/src/stores/editor/embedded-cube/LegendStudioCubeWorkspace.ts +151 -0
- package/src/stores/graph-modifier/DSL_Ingest_GraphModifierHelper.ts +214 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-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 type { Schema } from '@finos/legend-cube';
|
|
18
|
+
import {
|
|
19
|
+
CubeDataProductEnvironmentType,
|
|
20
|
+
CubeEngineError,
|
|
21
|
+
CubeEngineErrorKind,
|
|
22
|
+
CubeIngestDefinitionCandidate,
|
|
23
|
+
CubeIngestEnvironment,
|
|
24
|
+
CubeIngestProducer,
|
|
25
|
+
formatCubeIngestUrn,
|
|
26
|
+
parseCubeIngestUrn,
|
|
27
|
+
readCubeIngestDataSets,
|
|
28
|
+
type CubeIngestCatalog,
|
|
29
|
+
type CubeIngestDataSet,
|
|
30
|
+
type CubeIngestDataSetLocation,
|
|
31
|
+
type CubeIngestDefinitionList,
|
|
32
|
+
type CubeIngestDefinitionSource,
|
|
33
|
+
type NodeId,
|
|
34
|
+
} from '@finos/legend-cube-builder';
|
|
35
|
+
import type { IngestDefinition } from '@finos/legend-graph';
|
|
36
|
+
import type { PlainObject } from '@finos/legend-shared';
|
|
37
|
+
import type { EditorStore } from '../EditorStore.js';
|
|
38
|
+
import type { LegendStudioCubeWorkspace } from './LegendStudioCubeWorkspace.js';
|
|
39
|
+
|
|
40
|
+
// Legend Cube in Studio: a cube reads the ingest definitions of the project
|
|
41
|
+
// being edited, as the workspace holds them, and runs on the project's
|
|
42
|
+
// lakehouse runtime, as Studio's own queries of an ingest definition do. The
|
|
43
|
+
// Ingest tab lists every definition of the project, under one producer that
|
|
44
|
+
// stands for the project, each named by the URN it would have if this
|
|
45
|
+
// project deployed it.
|
|
46
|
+
|
|
47
|
+
/** The one class a Studio cube reads the project's definitions as, so the Ingest tab offers no other */
|
|
48
|
+
const STUDIO_CUBE_INGEST_CLASS = CubeDataProductEnvironmentType.PRODUCTION;
|
|
49
|
+
|
|
50
|
+
/** The one producer deployment the tab lists: the project itself, whatever its definitions' deployments */
|
|
51
|
+
export const LEGEND_STUDIO_CUBE_PROJECT_PRODUCER = '0';
|
|
52
|
+
|
|
53
|
+
export const LEGEND_STUDIO_CUBE_MESSAGE = {
|
|
54
|
+
GONE: (definition: string): string =>
|
|
55
|
+
`The project has no ingest definition ${definition} any more.`,
|
|
56
|
+
UNREADABLE: (definition: string): string =>
|
|
57
|
+
`Cube can't read the data sets of ingest definition ${definition}.`,
|
|
58
|
+
NO_DATA_SET: (dataSet: string, definition: string): string =>
|
|
59
|
+
`Ingest definition ${definition} has no data set "${dataSet}".`,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The project's own ingest definitions, for the Ingest tab and for the
|
|
64
|
+
* engine, which types and runs on them as the workspace holds them now
|
|
65
|
+
*/
|
|
66
|
+
export class LegendStudioCubeIngestCatalog
|
|
67
|
+
implements CubeIngestCatalog, CubeIngestDefinitionSource
|
|
68
|
+
{
|
|
69
|
+
readonly environmentTypes = [STUDIO_CUBE_INGEST_CLASS];
|
|
70
|
+
readonly editorStore: EditorStore;
|
|
71
|
+
readonly workspace: LegendStudioCubeWorkspace;
|
|
72
|
+
|
|
73
|
+
constructor(editorStore: EditorStore, workspace: LegendStudioCubeWorkspace) {
|
|
74
|
+
this.editorStore = editorStore;
|
|
75
|
+
this.workspace = workspace;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The project's own definitions, not its dependencies' */
|
|
79
|
+
private get definitions(): IngestDefinition[] {
|
|
80
|
+
return this.editorStore.graphManagerState.graph.ownIngests;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The URN a cube names the project's definition by */
|
|
84
|
+
urnOf(definition: IngestDefinition): string {
|
|
85
|
+
return formatCubeIngestUrn({
|
|
86
|
+
environmentType: STUDIO_CUBE_INGEST_CLASS,
|
|
87
|
+
...this.workspace.project,
|
|
88
|
+
definition: definition.path,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private definitionOf(urn: string): IngestDefinition {
|
|
93
|
+
const definition = this.definitions.find(
|
|
94
|
+
(each) => this.urnOf(each) === urn,
|
|
95
|
+
);
|
|
96
|
+
if (!definition) {
|
|
97
|
+
throw new CubeEngineError(
|
|
98
|
+
CubeEngineErrorKind.COMPILE,
|
|
99
|
+
LEGEND_STUDIO_CUBE_MESSAGE.GONE(
|
|
100
|
+
parseCubeIngestUrn(urn)?.definition ?? urn,
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return definition;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The project's lakehouse runtime, which a run names, with its warehouse */
|
|
108
|
+
async resolveEnvironment(
|
|
109
|
+
environmentType: CubeDataProductEnvironmentType,
|
|
110
|
+
): Promise<CubeIngestEnvironment> {
|
|
111
|
+
const runtime = await this.workspace.resolveRuntime();
|
|
112
|
+
return new CubeIngestEnvironment({
|
|
113
|
+
environmentType,
|
|
114
|
+
name: runtime.label,
|
|
115
|
+
runtimeEnvironment: runtime.environment,
|
|
116
|
+
warehouse: runtime.warehouse,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async getRuntimeEnvironment(): Promise<string> {
|
|
121
|
+
return (await this.workspace.resolveRuntime()).environment;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** One producer, the project, so the tab lists every definition at once */
|
|
125
|
+
async listProducers(): Promise<readonly CubeIngestProducer[]> {
|
|
126
|
+
const { groupId, artifactId } = this.workspace.project;
|
|
127
|
+
return [
|
|
128
|
+
new CubeIngestProducer({
|
|
129
|
+
deploymentId: LEGEND_STUDIO_CUBE_PROJECT_PRODUCER,
|
|
130
|
+
urn: `${groupId}:${artifactId}`,
|
|
131
|
+
}),
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Every definition of the project, whatever its app directory deployment */
|
|
136
|
+
async listDefinitions(): Promise<CubeIngestDefinitionList> {
|
|
137
|
+
return {
|
|
138
|
+
candidates: this.definitions.map(
|
|
139
|
+
(each) =>
|
|
140
|
+
new CubeIngestDefinitionCandidate({
|
|
141
|
+
urn: this.urnOf(each),
|
|
142
|
+
definition: each.path,
|
|
143
|
+
...this.workspace.project,
|
|
144
|
+
}),
|
|
145
|
+
),
|
|
146
|
+
droppedCount: 0,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The workspace's elements, which a typing's or a run's model holds */
|
|
151
|
+
getModelElements(): Promise<readonly PlainObject[]> {
|
|
152
|
+
return this.workspace.getModelElements();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The definition's element, as the workspace holds it now */
|
|
156
|
+
async getDefinitionElement(urn: string): Promise<PlainObject> {
|
|
157
|
+
return this.editorStore.graphManagerState.graphManager.elementToEntity(
|
|
158
|
+
this.definitionOf(urn),
|
|
159
|
+
{ pruneSourceInformation: true },
|
|
160
|
+
).content;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async describe(urn: string): Promise<readonly CubeIngestDataSet[]> {
|
|
164
|
+
const element = await this.getDefinitionElement(urn);
|
|
165
|
+
try {
|
|
166
|
+
return readCubeIngestDataSets(element);
|
|
167
|
+
} catch {
|
|
168
|
+
throw new CubeEngineError(
|
|
169
|
+
CubeEngineErrorKind.COMPILE,
|
|
170
|
+
LEGEND_STUDIO_CUBE_MESSAGE.UNREADABLE(this.definitionOf(urn).path),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async resolveSchemas(
|
|
176
|
+
environmentType: CubeDataProductEnvironmentType,
|
|
177
|
+
sources: ReadonlyMap<NodeId, CubeIngestDataSetLocation>,
|
|
178
|
+
): Promise<Map<NodeId, Schema | CubeEngineError>> {
|
|
179
|
+
const described = new Map<
|
|
180
|
+
string,
|
|
181
|
+
readonly CubeIngestDataSet[] | CubeEngineError
|
|
182
|
+
>();
|
|
183
|
+
for (const { ingestDefinitionUrn } of sources.values()) {
|
|
184
|
+
if (!described.has(ingestDefinitionUrn)) {
|
|
185
|
+
try {
|
|
186
|
+
described.set(
|
|
187
|
+
ingestDefinitionUrn,
|
|
188
|
+
await this.describe(ingestDefinitionUrn),
|
|
189
|
+
);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
described.set(
|
|
192
|
+
ingestDefinitionUrn,
|
|
193
|
+
error instanceof CubeEngineError
|
|
194
|
+
? error
|
|
195
|
+
: new CubeEngineError(
|
|
196
|
+
CubeEngineErrorKind.COMPILE,
|
|
197
|
+
error instanceof Error ? error.message : String(error),
|
|
198
|
+
),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return new Map(
|
|
204
|
+
[...sources].map(([nodeId, source]) => {
|
|
205
|
+
const read = described.get(source.ingestDefinitionUrn);
|
|
206
|
+
if (read instanceof CubeEngineError || read === undefined) {
|
|
207
|
+
return [
|
|
208
|
+
nodeId,
|
|
209
|
+
new CubeEngineError(
|
|
210
|
+
read?.kind ?? CubeEngineErrorKind.COMPILE,
|
|
211
|
+
read?.detail ??
|
|
212
|
+
LEGEND_STUDIO_CUBE_MESSAGE.GONE(source.ingestDefinition),
|
|
213
|
+
nodeId,
|
|
214
|
+
),
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
const dataSet = read.find((each) => each.name === source.dataSet);
|
|
218
|
+
return [
|
|
219
|
+
nodeId,
|
|
220
|
+
dataSet?.schema && dataSet.isPickable
|
|
221
|
+
? dataSet.schema
|
|
222
|
+
: new CubeEngineError(
|
|
223
|
+
CubeEngineErrorKind.COMPILE,
|
|
224
|
+
dataSet?.disabledReason ??
|
|
225
|
+
LEGEND_STUDIO_CUBE_MESSAGE.NO_DATA_SET(
|
|
226
|
+
source.dataSet,
|
|
227
|
+
source.ingestDefinition,
|
|
228
|
+
),
|
|
229
|
+
nodeId,
|
|
230
|
+
),
|
|
231
|
+
];
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-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
|
+
CubeEngineError,
|
|
19
|
+
CubeEngineErrorKind,
|
|
20
|
+
type CubeDataProductModelSource,
|
|
21
|
+
type CubeHostProject,
|
|
22
|
+
type CubeHostProjectRuntime,
|
|
23
|
+
type CubeLakehouseEnvironment,
|
|
24
|
+
} from '@finos/legend-cube-builder';
|
|
25
|
+
import {
|
|
26
|
+
LakehouseBaseRuntime,
|
|
27
|
+
LakehouseRuntime,
|
|
28
|
+
ModelStore,
|
|
29
|
+
PrimitiveType,
|
|
30
|
+
type PackageableElement,
|
|
31
|
+
type PackageableRuntime,
|
|
32
|
+
} from '@finos/legend-graph';
|
|
33
|
+
import type { PlainObject } from '@finos/legend-shared';
|
|
34
|
+
import type { EditorStore } from '../EditorStore.js';
|
|
35
|
+
|
|
36
|
+
// The project Studio edits, as Legend Cube reads it: its coordinates, the
|
|
37
|
+
// lakehouse runtime its runs use, and the model its typing and runs read,
|
|
38
|
+
// the workspace as it is now. A cube in Studio reads only the project's own
|
|
39
|
+
// ingest definitions and data products, which aren't deployed: they are
|
|
40
|
+
// typed and run on the workspace, as Studio's own queries of them are.
|
|
41
|
+
|
|
42
|
+
/** The project's coordinates when Studio has no project configuration, which Cube's sources still name */
|
|
43
|
+
const UNKNOWN_PROJECT = { groupId: 'studio', artifactId: 'workspace' };
|
|
44
|
+
|
|
45
|
+
/** The version a cube of the workspace's data products names: the workspace, never a release */
|
|
46
|
+
export const LEGEND_STUDIO_CUBE_WORKSPACE_VERSION = 'workspace';
|
|
47
|
+
|
|
48
|
+
export const LEGEND_STUDIO_CUBE_WORKSPACE_MESSAGE = {
|
|
49
|
+
NO_RUNTIME:
|
|
50
|
+
"Add a lakehouse runtime to the project: a cube runs the project's ingest data sets and data products on it, as Studio's own queries do.",
|
|
51
|
+
NO_ENVIRONMENT: (runtime: string): string =>
|
|
52
|
+
`The project's lakehouse runtime ${runtime} names no environment.`,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** The lakehouse runtime a run uses, read from the project */
|
|
56
|
+
export interface LegendStudioCubeRuntime extends CubeHostProjectRuntime {
|
|
57
|
+
readonly path: string;
|
|
58
|
+
readonly environment: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class LegendStudioCubeWorkspace
|
|
62
|
+
implements
|
|
63
|
+
CubeHostProject,
|
|
64
|
+
CubeLakehouseEnvironment,
|
|
65
|
+
CubeDataProductModelSource
|
|
66
|
+
{
|
|
67
|
+
readonly editorStore: EditorStore;
|
|
68
|
+
|
|
69
|
+
constructor(editorStore: EditorStore) {
|
|
70
|
+
this.editorStore = editorStore;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The project's coordinates, which the URNs and models of Cube's sources carry */
|
|
74
|
+
get project(): { groupId: string; artifactId: string } {
|
|
75
|
+
const configuration =
|
|
76
|
+
this.editorStore.projectConfigurationEditorState.projectConfiguration;
|
|
77
|
+
return configuration
|
|
78
|
+
? {
|
|
79
|
+
groupId: configuration.groupId,
|
|
80
|
+
artifactId: configuration.artifactId,
|
|
81
|
+
}
|
|
82
|
+
: UNKNOWN_PROJECT;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The lakehouse runtime a run uses: the project's first, as Studio's own
|
|
87
|
+
* queries of an ingest definition or a data product pick
|
|
88
|
+
* (`getCompatibleRuntimesFromAccessorOwner`, `LakehouseDataProductExecutionState`)
|
|
89
|
+
*/
|
|
90
|
+
get lakehouseRuntime(): PackageableRuntime | undefined {
|
|
91
|
+
return this.editorStore.graphManagerState.usableRuntimes.find(
|
|
92
|
+
(runtime) => runtime.runtimeValue instanceof LakehouseBaseRuntime,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async resolveRuntime(): Promise<LegendStudioCubeRuntime> {
|
|
97
|
+
const runtime = this.lakehouseRuntime;
|
|
98
|
+
if (!runtime) {
|
|
99
|
+
throw new CubeEngineError(
|
|
100
|
+
CubeEngineErrorKind.UNSUPPORTED_MODEL,
|
|
101
|
+
LEGEND_STUDIO_CUBE_WORKSPACE_MESSAGE.NO_RUNTIME,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const value = runtime.runtimeValue as LakehouseBaseRuntime;
|
|
105
|
+
if (!value.environment) {
|
|
106
|
+
throw new CubeEngineError(
|
|
107
|
+
CubeEngineErrorKind.UNSUPPORTED_MODEL,
|
|
108
|
+
LEGEND_STUDIO_CUBE_WORKSPACE_MESSAGE.NO_ENVIRONMENT(runtime.path),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
path: runtime.path,
|
|
113
|
+
environment: value.environment,
|
|
114
|
+
label: `${value.environment}, from ${runtime.path}`,
|
|
115
|
+
warehouse:
|
|
116
|
+
value instanceof LakehouseRuntime ? value.warehouse : undefined,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The environment a data product run's lakehouse runtime names: the project runtime's */
|
|
121
|
+
async resolveEnvironment(): Promise<string> {
|
|
122
|
+
return (await this.resolveRuntime()).environment;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The elements a cube's typing and runs read, as protocol JSON: the
|
|
127
|
+
* workspace's own and its dependencies', as Studio's own queries send
|
|
128
|
+
* them, so a definition's materialized views and a data product's access
|
|
129
|
+
* points find what they read
|
|
130
|
+
*/
|
|
131
|
+
async getModelElements(): Promise<readonly PlainObject[]> {
|
|
132
|
+
const { graph, graphManager } = this.editorStore.graphManagerState;
|
|
133
|
+
return [...graph.allOwnElements, ...graph.dependencyManager.allOwnElements]
|
|
134
|
+
.filter(
|
|
135
|
+
(element: PackageableElement) =>
|
|
136
|
+
!(element instanceof PrimitiveType) &&
|
|
137
|
+
!(element instanceof ModelStore),
|
|
138
|
+
)
|
|
139
|
+
.map(
|
|
140
|
+
(element) =>
|
|
141
|
+
graphManager.elementToEntity(element, {
|
|
142
|
+
pruneSourceInformation: true,
|
|
143
|
+
}).content,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The model a cube of the workspace's data products reads them from: the workspace */
|
|
148
|
+
async getProjectModel(): Promise<PlainObject> {
|
|
149
|
+
return { _type: 'data', elements: await this.getModelElements() };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-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 { RawLambda, type IngestDefinition } from '@finos/legend-graph';
|
|
18
|
+
import { isObject, isString, type PlainObject } from '@finos/legend-shared';
|
|
19
|
+
import { action } from 'mobx';
|
|
20
|
+
|
|
21
|
+
/** The source of a data set whose rows a function computes: a materialized view */
|
|
22
|
+
const MATERIALIZED_VIEW_SOURCE_TYPE = 'FunctionSource';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The lists the engine gives every data set it parses, and reads: a data set
|
|
26
|
+
* Studio writes holds each, empty when it has none
|
|
27
|
+
*/
|
|
28
|
+
const DATA_SET_LIST_KEYS = [
|
|
29
|
+
'ingestPartitionColumns',
|
|
30
|
+
'preprocessors',
|
|
31
|
+
'storageLayoutClusterColumns',
|
|
32
|
+
'storageLayoutPartitionColumns',
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
/** The ingest definition's data sets, as its content holds them */
|
|
36
|
+
export const getIngestDataSetNames = (ingest: IngestDefinition): string[] =>
|
|
37
|
+
(Array.isArray(ingest.content.datasets) ? ingest.content.datasets : [])
|
|
38
|
+
.map((dataSet: unknown) =>
|
|
39
|
+
isObject(dataSet) ? (dataSet as PlainObject).name : undefined,
|
|
40
|
+
)
|
|
41
|
+
.filter(isString);
|
|
42
|
+
|
|
43
|
+
/** What a materialized view's data set says besides its name and its query */
|
|
44
|
+
export interface IngestMaterializedViewOptions {
|
|
45
|
+
/** The columns that identify a row, in the order of the view's columns; none for no key */
|
|
46
|
+
readonly primaryKey: readonly string[];
|
|
47
|
+
/** The classification of its data, e.g. `DP10`, as a data product's access points take one */
|
|
48
|
+
readonly sensitivity: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A materialized view of an ingest definition, as its content holds it */
|
|
52
|
+
export interface IngestMaterializedView {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/** Its query, as protocol JSON */
|
|
55
|
+
readonly lambda: PlainObject;
|
|
56
|
+
readonly primaryKey: readonly string[];
|
|
57
|
+
/** The classification of its data; none for a view without one */
|
|
58
|
+
readonly sensitivity: string | undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The materialized views of the ingest definition, as its content holds them */
|
|
62
|
+
export const getIngestMaterializedViews = (
|
|
63
|
+
ingest: IngestDefinition,
|
|
64
|
+
): IngestMaterializedView[] =>
|
|
65
|
+
(Array.isArray(ingest.content.datasets) ? ingest.content.datasets : [])
|
|
66
|
+
.filter(isObject)
|
|
67
|
+
.flatMap((dataSet) => {
|
|
68
|
+
const { name, source, primaryKey, privacyClassification } =
|
|
69
|
+
dataSet as PlainObject;
|
|
70
|
+
const lambda = isObject(source)
|
|
71
|
+
? (source as PlainObject).function
|
|
72
|
+
: undefined;
|
|
73
|
+
const sensitivity = isObject(privacyClassification)
|
|
74
|
+
? (privacyClassification as PlainObject).sensitivity
|
|
75
|
+
: undefined;
|
|
76
|
+
return isString(name) &&
|
|
77
|
+
(source as PlainObject | undefined)?._type ===
|
|
78
|
+
MATERIALIZED_VIEW_SOURCE_TYPE &&
|
|
79
|
+
isObject(lambda)
|
|
80
|
+
? [
|
|
81
|
+
{
|
|
82
|
+
name,
|
|
83
|
+
lambda: lambda as PlainObject,
|
|
84
|
+
primaryKey: Array.isArray(primaryKey)
|
|
85
|
+
? primaryKey.filter(isString)
|
|
86
|
+
: [],
|
|
87
|
+
sensitivity: isString(sensitivity) ? sensitivity : undefined,
|
|
88
|
+
},
|
|
89
|
+
]
|
|
90
|
+
: [];
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Adds a materialized view to the ingest definition: a data set whose rows
|
|
95
|
+
* the lambda (protocol JSON) computes, with its primary key and the
|
|
96
|
+
* classification of its data. It holds every key the engine gives a data
|
|
97
|
+
* set it parses, its lists empty, as the engine reads them all: a view
|
|
98
|
+
* without a `privacyClassification` failed with a NullPointerException.
|
|
99
|
+
* The content is replaced, so the change is seen, and the view is listed
|
|
100
|
+
* for Lineage and View SQL as one read from the definition would be
|
|
101
|
+
*/
|
|
102
|
+
export const ingestDefinition_addMaterializedView = action(
|
|
103
|
+
(
|
|
104
|
+
ingest: IngestDefinition,
|
|
105
|
+
name: string,
|
|
106
|
+
lambda: PlainObject,
|
|
107
|
+
options: IngestMaterializedViewOptions,
|
|
108
|
+
): void => {
|
|
109
|
+
const dataSets = Array.isArray(ingest.content.datasets)
|
|
110
|
+
? (ingest.content.datasets as unknown[])
|
|
111
|
+
: [];
|
|
112
|
+
ingest.content = {
|
|
113
|
+
...ingest.content,
|
|
114
|
+
datasets: [
|
|
115
|
+
...dataSets,
|
|
116
|
+
{
|
|
117
|
+
name,
|
|
118
|
+
primaryKey: [...options.primaryKey],
|
|
119
|
+
privacyClassification: { sensitivity: options.sensitivity },
|
|
120
|
+
source: { _type: MATERIALIZED_VIEW_SOURCE_TYPE, function: lambda },
|
|
121
|
+
...Object.fromEntries(DATA_SET_LIST_KEYS.map((key) => [key, []])),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
ingest.TEMPORARY_MATVIEW_FUNCTION_DATA_SETS = [
|
|
126
|
+
...(ingest.TEMPORARY_MATVIEW_FUNCTION_DATA_SETS ?? []),
|
|
127
|
+
{
|
|
128
|
+
name,
|
|
129
|
+
source: {
|
|
130
|
+
function: new RawLambda(
|
|
131
|
+
Array.isArray(lambda.parameters) ? lambda.parameters : [],
|
|
132
|
+
lambda.body as object | undefined,
|
|
133
|
+
),
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Replaces a materialized view's lambda (protocol JSON) in place: its name,
|
|
142
|
+
* its place among the data sets and its other keys stay, as does its place
|
|
143
|
+
* among the views listed for Lineage and View SQL. A primary key and a
|
|
144
|
+
* classification given replace the view's, and the lists the engine reads
|
|
145
|
+
* that the view lacks, e.g. as Studio wrote a view before it wrote them, are
|
|
146
|
+
* added empty
|
|
147
|
+
*/
|
|
148
|
+
export const ingestDefinition_updateMaterializedView = action(
|
|
149
|
+
(
|
|
150
|
+
ingest: IngestDefinition,
|
|
151
|
+
name: string,
|
|
152
|
+
lambda: PlainObject,
|
|
153
|
+
options?: IngestMaterializedViewOptions,
|
|
154
|
+
): void => {
|
|
155
|
+
const dataSets = Array.isArray(ingest.content.datasets)
|
|
156
|
+
? (ingest.content.datasets as unknown[])
|
|
157
|
+
: [];
|
|
158
|
+
ingest.content = {
|
|
159
|
+
...ingest.content,
|
|
160
|
+
datasets: dataSets.map((dataSet) => {
|
|
161
|
+
if (!isObject(dataSet)) {
|
|
162
|
+
return dataSet;
|
|
163
|
+
}
|
|
164
|
+
const {
|
|
165
|
+
name: dataSetName,
|
|
166
|
+
source,
|
|
167
|
+
privacyClassification,
|
|
168
|
+
} = dataSet as PlainObject;
|
|
169
|
+
if (
|
|
170
|
+
dataSetName !== name ||
|
|
171
|
+
!isObject(source) ||
|
|
172
|
+
(source as PlainObject)._type !== MATERIALIZED_VIEW_SOURCE_TYPE
|
|
173
|
+
) {
|
|
174
|
+
return dataSet;
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
...dataSet,
|
|
178
|
+
...(options
|
|
179
|
+
? {
|
|
180
|
+
primaryKey: [...options.primaryKey],
|
|
181
|
+
privacyClassification: {
|
|
182
|
+
...(isObject(privacyClassification)
|
|
183
|
+
? (privacyClassification as PlainObject)
|
|
184
|
+
: {}),
|
|
185
|
+
sensitivity: options.sensitivity,
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
: {}),
|
|
189
|
+
source: { ...source, function: lambda },
|
|
190
|
+
...Object.fromEntries(
|
|
191
|
+
DATA_SET_LIST_KEYS.filter(
|
|
192
|
+
(key) => !Array.isArray((dataSet as PlainObject)[key]),
|
|
193
|
+
).map((key) => [key, []]),
|
|
194
|
+
),
|
|
195
|
+
};
|
|
196
|
+
}),
|
|
197
|
+
};
|
|
198
|
+
ingest.TEMPORARY_MATVIEW_FUNCTION_DATA_SETS =
|
|
199
|
+
ingest.TEMPORARY_MATVIEW_FUNCTION_DATA_SETS?.map((view) =>
|
|
200
|
+
view.name === name
|
|
201
|
+
? {
|
|
202
|
+
...view,
|
|
203
|
+
source: {
|
|
204
|
+
...view.source,
|
|
205
|
+
function: new RawLambda(
|
|
206
|
+
Array.isArray(lambda.parameters) ? lambda.parameters : [],
|
|
207
|
+
lambda.body as object | undefined,
|
|
208
|
+
),
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
: view,
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
);
|
package/tsconfig.json
CHANGED
|
@@ -187,6 +187,11 @@
|
|
|
187
187
|
"./src/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.ts",
|
|
188
188
|
"./src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts",
|
|
189
189
|
"./src/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts",
|
|
190
|
+
"./src/stores/editor/embedded-cube/EmbeddedCubeState.ts",
|
|
191
|
+
"./src/stores/editor/embedded-cube/LegendStudioCubeDataProductCatalog.ts",
|
|
192
|
+
"./src/stores/editor/embedded-cube/LegendStudioCubeHost.ts",
|
|
193
|
+
"./src/stores/editor/embedded-cube/LegendStudioCubeIngestCatalog.ts",
|
|
194
|
+
"./src/stores/editor/embedded-cube/LegendStudioCubeWorkspace.ts",
|
|
190
195
|
"./src/stores/editor/panel-group/DevToolPanelState.ts",
|
|
191
196
|
"./src/stores/editor/panel-group/StudioSQLPlaygroundPanelState.ts",
|
|
192
197
|
"./src/stores/editor/sidebar-state/BulkServiceRegistrationState.ts",
|
|
@@ -221,6 +226,7 @@
|
|
|
221
226
|
"./src/stores/graph-modifier/DSL_ExternalFormat_GraphModifierHelper.ts",
|
|
222
227
|
"./src/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.ts",
|
|
223
228
|
"./src/stores/graph-modifier/DSL_Generation_GraphModifierHelper.ts",
|
|
229
|
+
"./src/stores/graph-modifier/DSL_Ingest_GraphModifierHelper.ts",
|
|
224
230
|
"./src/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.ts",
|
|
225
231
|
"./src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts",
|
|
226
232
|
"./src/stores/graph-modifier/DSL_Service_GraphModifierHelper.ts",
|
|
@@ -360,6 +366,8 @@
|
|
|
360
366
|
"./src/components/editor/editor-group/uml-editor/StereotypeSelector.tsx",
|
|
361
367
|
"./src/components/editor/editor-group/uml-editor/TaggedValueEditor.tsx",
|
|
362
368
|
"./src/components/editor/editor-group/uml-editor/UMLEditor.tsx",
|
|
369
|
+
"./src/components/editor/embedded-cube/EmbeddedCube.tsx",
|
|
370
|
+
"./src/components/editor/embedded-cube/EmbeddedCubeEditor.tsx",
|
|
363
371
|
"./src/components/editor/panel-group/ConsolePanel.tsx",
|
|
364
372
|
"./src/components/editor/panel-group/DevToolPanel.tsx",
|
|
365
373
|
"./src/components/editor/panel-group/PanelGroup.tsx",
|