@finos/legend-application-data-cube 0.7.5 → 0.7.6
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/builder/LegendDataCubeSourceViewer.d.ts.map +1 -1
- package/lib/components/builder/LegendDataCubeSourceViewer.js +2 -1
- package/lib/components/builder/LegendDataCubeSourceViewer.js.map +1 -1
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceBuilder.d.ts.map +1 -1
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceBuilder.js +16 -15
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceBuilder.js.map +1 -1
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceLoader.d.ts +22 -0
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceLoader.d.ts.map +1 -0
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceLoader.js +35 -0
- package/lib/components/builder/source/LakehouseConsumerDataCubeSourceLoader.js.map +1 -0
- package/lib/components/builder/source/LegendDataCubeSourceLoader.d.ts.map +1 -1
- package/lib/components/builder/source/LegendDataCubeSourceLoader.js +3 -1
- package/lib/components/builder/source/LegendDataCubeSourceLoader.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/LegendDataCubeDataCubeEngine.d.ts +2 -0
- package/lib/stores/LegendDataCubeDataCubeEngine.d.ts.map +1 -1
- package/lib/stores/LegendDataCubeDataCubeEngine.js +16 -4
- package/lib/stores/LegendDataCubeDataCubeEngine.js.map +1 -1
- package/lib/stores/builder/LegendDataCubeBuilderStore.d.ts.map +1 -1
- package/lib/stores/builder/LegendDataCubeBuilderStore.js +4 -0
- package/lib/stores/builder/LegendDataCubeBuilderStore.js.map +1 -1
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceBuilderState.d.ts +9 -2
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceBuilderState.d.ts.map +1 -1
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceBuilderState.js +81 -22
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceBuilderState.js.map +1 -1
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceLoaderState.d.ts +38 -0
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceLoaderState.d.ts.map +1 -0
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceLoaderState.js +87 -0
- package/lib/stores/builder/source/LakehouseConsumerDataCubeSourceLoaderState.js.map +1 -0
- package/lib/stores/builder/source/LakehouseProducerDataCubeSourceLoaderState.d.ts +1 -2
- package/lib/stores/builder/source/LakehouseProducerDataCubeSourceLoaderState.d.ts.map +1 -1
- package/lib/stores/builder/source/LakehouseProducerDataCubeSourceLoaderState.js +1 -2
- package/lib/stores/builder/source/LakehouseProducerDataCubeSourceLoaderState.js.map +1 -1
- package/lib/stores/model/LakehouseConsumerDataCubeSource.d.ts +16 -3
- package/lib/stores/model/LakehouseConsumerDataCubeSource.d.ts.map +1 -1
- package/lib/stores/model/LakehouseConsumerDataCubeSource.js +57 -4
- package/lib/stores/model/LakehouseConsumerDataCubeSource.js.map +1 -1
- package/package.json +8 -8
- package/src/components/builder/LegendDataCubeSourceViewer.tsx +13 -11
- package/src/components/builder/source/LakehouseConsumerDataCubeSourceBuilder.tsx +35 -34
- package/src/components/builder/source/LakehouseConsumerDataCubeSourceLoader.tsx +69 -0
- package/src/components/builder/source/LegendDataCubeSourceLoader.tsx +10 -0
- package/src/stores/LegendDataCubeDataCubeEngine.ts +24 -8
- package/src/stores/builder/LegendDataCubeBuilderStore.tsx +12 -0
- package/src/stores/builder/source/LakehouseConsumerDataCubeSourceBuilderState.ts +122 -29
- package/src/stores/builder/source/LakehouseConsumerDataCubeSourceLoaderState.ts +169 -0
- package/src/stores/builder/source/LakehouseProducerDataCubeSourceLoaderState.ts +0 -3
- package/src/stores/model/LakehouseConsumerDataCubeSource.ts +96 -7
- package/tsconfig.json +2 -0
|
@@ -163,6 +163,7 @@ import {
|
|
|
163
163
|
LAKEHOUSE_CONSUMER_DATA_CUBE_SOURCE_TYPE,
|
|
164
164
|
LakehouseConsumerDataCubeSource,
|
|
165
165
|
RawLakehouseConsumerDataCubeSource,
|
|
166
|
+
RawLakehouseSdlcOrigin,
|
|
166
167
|
} from './model/LakehouseConsumerDataCubeSource.js';
|
|
167
168
|
|
|
168
169
|
export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
|
|
@@ -172,6 +173,7 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
|
|
|
172
173
|
private readonly _graphManager: V1_PureGraphManager;
|
|
173
174
|
private readonly _duckDBEngine: LegendDataCubeDuckDBEngine;
|
|
174
175
|
private _ingestDefinition: PlainObject | undefined;
|
|
176
|
+
private _adhocDataProductGraphGrammar: string | undefined;
|
|
175
177
|
|
|
176
178
|
constructor(
|
|
177
179
|
application: LegendDataCubeApplicationStore,
|
|
@@ -394,7 +396,6 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
|
|
|
394
396
|
warehouse: rawSource.warehouse,
|
|
395
397
|
path: rawSource.paths[0],
|
|
396
398
|
accessPoint: rawSource.paths[1],
|
|
397
|
-
dpCoordinates: rawSource.dpCoordinates,
|
|
398
399
|
},
|
|
399
400
|
sourceType: source._type,
|
|
400
401
|
};
|
|
@@ -746,7 +747,9 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
|
|
|
746
747
|
source.environment = rawSource.environment;
|
|
747
748
|
source.paths = rawSource.paths;
|
|
748
749
|
source.warehouse = rawSource.warehouse;
|
|
749
|
-
|
|
750
|
+
if (rawSource.origin instanceof RawLakehouseSdlcOrigin) {
|
|
751
|
+
source.dpCoordinates = rawSource.origin.dpCoordinates;
|
|
752
|
+
}
|
|
750
753
|
|
|
751
754
|
//TODO: add support for parameters
|
|
752
755
|
try {
|
|
@@ -1267,6 +1270,10 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
|
|
|
1267
1270
|
this._ingestDefinition = ingestDefinition;
|
|
1268
1271
|
}
|
|
1269
1272
|
|
|
1273
|
+
registerAdhocDataProductGraphGrammar(fullGraphGrammar: string | undefined) {
|
|
1274
|
+
this._adhocDataProductGraphGrammar = fullGraphGrammar;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1270
1277
|
// ---------------------------------- CACHING --------------------------------------
|
|
1271
1278
|
|
|
1272
1279
|
override async initializeCache(
|
|
@@ -1800,12 +1807,21 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
|
|
|
1800
1807
|
rawSource: RawLakehouseConsumerDataCubeSource,
|
|
1801
1808
|
source: LakehouseConsumerDataCubeSource,
|
|
1802
1809
|
) {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
rawSource.dpCoordinates
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1810
|
+
let pmcd: PlainObject<V1_PureModelContextData> | undefined;
|
|
1811
|
+
if (rawSource.origin instanceof RawLakehouseSdlcOrigin) {
|
|
1812
|
+
const coordinates = guaranteeNonNullable(rawSource.origin.dpCoordinates);
|
|
1813
|
+
pmcd = await this._depotServerClient.getPureModelContextData(
|
|
1814
|
+
coordinates.groupId,
|
|
1815
|
+
coordinates.artifactId,
|
|
1816
|
+
coordinates.versionId,
|
|
1817
|
+
true,
|
|
1818
|
+
);
|
|
1819
|
+
} else {
|
|
1820
|
+
pmcd = await this.parseCompatibleModel(
|
|
1821
|
+
guaranteeNonNullable(this._adhocDataProductGraphGrammar),
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1809
1825
|
const deserializedPMCD = guaranteeType(
|
|
1810
1826
|
V1_deserializePureModelContext(pmcd),
|
|
1811
1827
|
V1_PureModelContextData,
|
|
@@ -77,6 +77,8 @@ import type {
|
|
|
77
77
|
} from '@finos/legend-server-lakehouse';
|
|
78
78
|
import { LAKEHOUSE_PRODUCER_DATA_CUBE_SOURCE_TYPE } from '../model/LakehouseProducerDataCubeSource.js';
|
|
79
79
|
import { LakehouseProducerDataCubeSourceLoaderState } from './source/LakehouseProducerDataCubeSourceLoaderState.js';
|
|
80
|
+
import { LAKEHOUSE_CONSUMER_DATA_CUBE_SOURCE_TYPE } from '../model/LakehouseConsumerDataCubeSource.js';
|
|
81
|
+
import { LakehouseConsumerDataCubeSourceLoaderState } from './source/LakehouseConsumerDataCubeSourceLoaderState.js';
|
|
80
82
|
|
|
81
83
|
export class LegendDataCubeBuilderState {
|
|
82
84
|
readonly uuid = uuid();
|
|
@@ -359,6 +361,16 @@ export class LegendDataCubeBuilderStore {
|
|
|
359
361
|
onSuccess,
|
|
360
362
|
onError,
|
|
361
363
|
);
|
|
364
|
+
case LAKEHOUSE_CONSUMER_DATA_CUBE_SOURCE_TYPE:
|
|
365
|
+
return new LakehouseConsumerDataCubeSourceLoaderState(
|
|
366
|
+
this.application,
|
|
367
|
+
this.engine,
|
|
368
|
+
this.alertService,
|
|
369
|
+
sourceData,
|
|
370
|
+
persistentDataCube,
|
|
371
|
+
onSuccess,
|
|
372
|
+
onError,
|
|
373
|
+
);
|
|
362
374
|
default:
|
|
363
375
|
throw new UnsupportedOperationError(
|
|
364
376
|
`Can't create source loader for unsupported type '${sourceData._type}'`,
|
|
@@ -41,19 +41,32 @@ import {
|
|
|
41
41
|
type V1_EntitlementsDataProductLite,
|
|
42
42
|
type V1_EntitlementsDataProductLiteResponse,
|
|
43
43
|
V1_entitlementsDataProductDetailsResponseToDataProductDetails,
|
|
44
|
+
V1_DataProductOriginType,
|
|
45
|
+
V1_AdHocDeploymentDataProductOrigin,
|
|
46
|
+
type V1_EntitlementsDataProductDetails,
|
|
44
47
|
} from '@finos/legend-graph';
|
|
45
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
LakehouseEnvironmentType,
|
|
50
|
+
RawLakehouseAdhocOrigin,
|
|
51
|
+
RawLakehouseConsumerDataCubeSource,
|
|
52
|
+
RawLakehouseSdlcOrigin,
|
|
53
|
+
} from '../../model/LakehouseConsumerDataCubeSource.js';
|
|
46
54
|
|
|
47
55
|
export class LakehouseConsumerDataCubeSourceBuilderState extends LegendDataCubeSourceBuilderState {
|
|
48
56
|
warehouse: string | undefined;
|
|
49
57
|
selectedDataProduct: string | undefined;
|
|
50
58
|
selectedAccessPoint: string | undefined;
|
|
51
59
|
paths: string[] = [];
|
|
60
|
+
allEnvironments: string[] = [];
|
|
52
61
|
environments: string[] = [];
|
|
53
62
|
selectedEnvironment: string | undefined;
|
|
54
63
|
dataProducts: V1_EntitlementsDataProductLite[] = [];
|
|
55
64
|
accessPoints: string[] = [];
|
|
56
65
|
dpCoordinates: VersionedProjectData | undefined;
|
|
66
|
+
origin: string | undefined;
|
|
67
|
+
fullGraphGrammar: string | undefined;
|
|
68
|
+
|
|
69
|
+
dataProductDetails: V1_EntitlementsDataProductDetails[] = [];
|
|
57
70
|
|
|
58
71
|
DEFAULT_CONSUMER_WAREHOUSE = 'LAKEHOUSE_CONSUMER_DEFAULT_WH';
|
|
59
72
|
|
|
@@ -114,6 +127,10 @@ export class LakehouseConsumerDataCubeSourceBuilderState extends LegendDataCubeS
|
|
|
114
127
|
this.environments = environments;
|
|
115
128
|
}
|
|
116
129
|
|
|
130
|
+
setAllEnvironments(environments: string[]) {
|
|
131
|
+
this.allEnvironments = environments;
|
|
132
|
+
}
|
|
133
|
+
|
|
117
134
|
setSelectedAccessPoint(accessPoint: string | undefined) {
|
|
118
135
|
this.selectedAccessPoint = accessPoint;
|
|
119
136
|
}
|
|
@@ -138,51 +155,114 @@ export class LakehouseConsumerDataCubeSourceBuilderState extends LegendDataCubeS
|
|
|
138
155
|
}
|
|
139
156
|
}
|
|
140
157
|
|
|
141
|
-
async
|
|
158
|
+
async fetchDataProduct(access_token?: string) {
|
|
142
159
|
this.resetEnvironment();
|
|
143
160
|
|
|
144
161
|
const selectedDp = guaranteeNonNullable(this.selectedDataProduct);
|
|
145
|
-
|
|
162
|
+
this.dataProductDetails =
|
|
146
163
|
V1_entitlementsDataProductDetailsResponseToDataProductDetails(
|
|
147
164
|
await this._contractServerClient.getDataProduct(
|
|
148
165
|
selectedDp.split('::').pop() ?? '',
|
|
149
166
|
access_token,
|
|
150
167
|
),
|
|
151
168
|
);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
|
|
170
|
+
const filterEnvironments = (
|
|
171
|
+
type: V1_EntitlementsLakehouseEnvironmentType,
|
|
172
|
+
environments: string[],
|
|
173
|
+
): string[] => {
|
|
174
|
+
switch (type) {
|
|
175
|
+
case V1_EntitlementsLakehouseEnvironmentType.PRODUCTION:
|
|
176
|
+
return environments.filter(
|
|
177
|
+
(env) =>
|
|
178
|
+
!env.includes(LakehouseEnvironmentType.PRODUCTION_PARALLEL) &&
|
|
179
|
+
!env.includes(LakehouseEnvironmentType.DEVELOPMENT),
|
|
180
|
+
);
|
|
181
|
+
case V1_EntitlementsLakehouseEnvironmentType.PRODUCTION_PARALLEL:
|
|
182
|
+
return environments.filter((env) =>
|
|
183
|
+
env.includes(LakehouseEnvironmentType.PRODUCTION_PARALLEL),
|
|
184
|
+
);
|
|
185
|
+
case V1_EntitlementsLakehouseEnvironmentType.DEVELOPMENT:
|
|
186
|
+
return environments.filter((env) =>
|
|
187
|
+
env.includes(LakehouseEnvironmentType.DEVELOPMENT),
|
|
188
|
+
);
|
|
189
|
+
default:
|
|
190
|
+
return environments;
|
|
170
191
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
if (this.dataProductDetails.length === 1) {
|
|
195
|
+
const environmentType =
|
|
196
|
+
this.dataProductDetails.at(0)?.lakehouseEnvironment?.type;
|
|
197
|
+
if (environmentType) {
|
|
198
|
+
this.setEnvironments(
|
|
199
|
+
filterEnvironments(environmentType, this.allEnvironments),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} else if (this.dataProductDetails.length > 1) {
|
|
203
|
+
const allEnvironments = new Set<string>();
|
|
204
|
+
this.dataProductDetails.forEach((dataProduct) => {
|
|
205
|
+
const environmentType = dataProduct.lakehouseEnvironment?.type;
|
|
206
|
+
if (environmentType) {
|
|
207
|
+
filterEnvironments(environmentType, this.allEnvironments).forEach(
|
|
208
|
+
(env) => allEnvironments.add(env),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
this.setEnvironments(Array.from(allEnvironments));
|
|
176
213
|
}
|
|
177
214
|
}
|
|
178
215
|
|
|
216
|
+
fetchAccessPoints() {
|
|
217
|
+
this.resetAccessPoint();
|
|
218
|
+
const selectedEnv = guaranteeNonNullable(this.selectedEnvironment);
|
|
219
|
+
const dataProduct = selectedEnv.includes(
|
|
220
|
+
LakehouseEnvironmentType.DEVELOPMENT,
|
|
221
|
+
)
|
|
222
|
+
? this.dataProductDetails.find(
|
|
223
|
+
(dp) =>
|
|
224
|
+
dp.lakehouseEnvironment?.type ===
|
|
225
|
+
V1_EntitlementsLakehouseEnvironmentType.DEVELOPMENT,
|
|
226
|
+
)
|
|
227
|
+
: selectedEnv.includes(LakehouseEnvironmentType.PRODUCTION_PARALLEL)
|
|
228
|
+
? this.dataProductDetails.find(
|
|
229
|
+
(dp) =>
|
|
230
|
+
dp.lakehouseEnvironment?.type ===
|
|
231
|
+
V1_EntitlementsLakehouseEnvironmentType.PRODUCTION_PARALLEL,
|
|
232
|
+
)
|
|
233
|
+
: this.dataProductDetails.find(
|
|
234
|
+
(dp) =>
|
|
235
|
+
dp.lakehouseEnvironment?.type ===
|
|
236
|
+
V1_EntitlementsLakehouseEnvironmentType.PRODUCTION,
|
|
237
|
+
);
|
|
238
|
+
if (dataProduct?.origin instanceof V1_SdlcDeploymentDataProductOrigin) {
|
|
239
|
+
const versionedData = new VersionedProjectData();
|
|
240
|
+
versionedData.groupId = dataProduct.origin.group;
|
|
241
|
+
versionedData.artifactId = dataProduct.origin.artifact;
|
|
242
|
+
versionedData.versionId = dataProduct.origin.version;
|
|
243
|
+
this.dpCoordinates = versionedData;
|
|
244
|
+
this.origin = V1_DataProductOriginType.SDLC_DEPLOYMENT;
|
|
245
|
+
} else if (
|
|
246
|
+
dataProduct?.origin instanceof V1_AdHocDeploymentDataProductOrigin
|
|
247
|
+
) {
|
|
248
|
+
this.dpCoordinates = undefined;
|
|
249
|
+
this.origin = V1_DataProductOriginType.AD_HOC_DEPLOYMENT;
|
|
250
|
+
this.fullGraphGrammar = dataProduct.origin.definition;
|
|
251
|
+
}
|
|
252
|
+
this.setAccessPoints(
|
|
253
|
+
dataProduct?.dataProduct.accessPoints.map(
|
|
254
|
+
(accessPoint) => accessPoint.name,
|
|
255
|
+
) ?? [],
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
179
259
|
*fetchEnvironment(access_token: string | undefined): GeneratorFn<void> {
|
|
180
260
|
this.ingestEnvLoadingState.inProgress();
|
|
181
261
|
const ingestServerConfigs =
|
|
182
262
|
(yield this._platformServerClient.getIngestEnvironmentSummaries(
|
|
183
263
|
access_token,
|
|
184
264
|
)) as IngestDeploymentServerConfig[];
|
|
185
|
-
this.
|
|
265
|
+
this.setAllEnvironments(
|
|
186
266
|
ingestServerConfigs
|
|
187
267
|
.map((config) => {
|
|
188
268
|
const baseUrl = new URL(config.ingestServerUrl).hostname;
|
|
@@ -213,6 +293,13 @@ export class LakehouseConsumerDataCubeSourceBuilderState extends LegendDataCubeS
|
|
|
213
293
|
this.dpCoordinates = undefined;
|
|
214
294
|
}
|
|
215
295
|
|
|
296
|
+
resetAccessPoint() {
|
|
297
|
+
this.setWarehouse(undefined);
|
|
298
|
+
this.setAccessPoints([]);
|
|
299
|
+
this.setSelectedAccessPoint(undefined);
|
|
300
|
+
this.dpCoordinates = undefined;
|
|
301
|
+
}
|
|
302
|
+
|
|
216
303
|
override get label(): LegendDataCubeSourceBuilderType {
|
|
217
304
|
return LegendDataCubeSourceBuilderType.LAKEHOUSE_CONSUMER;
|
|
218
305
|
}
|
|
@@ -222,7 +309,6 @@ export class LakehouseConsumerDataCubeSourceBuilderState extends LegendDataCubeS
|
|
|
222
309
|
Boolean(this.warehouse) &&
|
|
223
310
|
Boolean(this.selectedAccessPoint) &&
|
|
224
311
|
Boolean(this.selectedDataProduct) &&
|
|
225
|
-
Boolean(this.dpCoordinates) &&
|
|
226
312
|
Boolean(this.selectedEnvironment)
|
|
227
313
|
);
|
|
228
314
|
}
|
|
@@ -239,7 +325,14 @@ export class LakehouseConsumerDataCubeSourceBuilderState extends LegendDataCubeS
|
|
|
239
325
|
|
|
240
326
|
const rawSource = new RawLakehouseConsumerDataCubeSource();
|
|
241
327
|
rawSource.environment = guaranteeNonNullable(this.selectedEnvironment);
|
|
242
|
-
|
|
328
|
+
if (this.origin === V1_DataProductOriginType.SDLC_DEPLOYMENT) {
|
|
329
|
+
const lakehouseOrigin = new RawLakehouseSdlcOrigin();
|
|
330
|
+
lakehouseOrigin.dpCoordinates = guaranteeNonNullable(this.dpCoordinates);
|
|
331
|
+
rawSource.origin = lakehouseOrigin;
|
|
332
|
+
} else {
|
|
333
|
+
this._engine.registerAdhocDataProductGraphGrammar(this.fullGraphGrammar);
|
|
334
|
+
rawSource.origin = new RawLakehouseAdhocOrigin();
|
|
335
|
+
}
|
|
243
336
|
rawSource.paths = this.paths;
|
|
244
337
|
rawSource.warehouse = guaranteeNonNullable(this.warehouse);
|
|
245
338
|
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025-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
|
+
guaranteeNonNullable,
|
|
19
|
+
guaranteeType,
|
|
20
|
+
type PlainObject,
|
|
21
|
+
} from '@finos/legend-shared';
|
|
22
|
+
import type { LegendDataCubeApplicationStore } from '../../LegendDataCubeBaseStore.js';
|
|
23
|
+
import type { LegendDataCubeDataCubeEngine } from '../../LegendDataCubeDataCubeEngine.js';
|
|
24
|
+
import { LegendDataCubeSourceLoaderState } from './LegendDataCubeSourceLoaderState.js';
|
|
25
|
+
import type { DataCubeAlertService } from '@finos/legend-data-cube';
|
|
26
|
+
import {
|
|
27
|
+
V1_AdHocDeploymentDataProductOrigin,
|
|
28
|
+
V1_entitlementsDataProductDetailsResponseToDataProductDetails,
|
|
29
|
+
V1_EntitlementsLakehouseEnvironmentType,
|
|
30
|
+
type PersistentDataCube,
|
|
31
|
+
} from '@finos/legend-graph';
|
|
32
|
+
import type { LakehouseContractServerClient } from '@finos/legend-server-lakehouse';
|
|
33
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
34
|
+
import { LegendDataCubeSourceBuilderType } from './LegendDataCubeSourceBuilderState.js';
|
|
35
|
+
import {
|
|
36
|
+
LakehouseEnvironmentType,
|
|
37
|
+
RawLakehouseConsumerDataCubeSource,
|
|
38
|
+
RawLakehouseSdlcOrigin,
|
|
39
|
+
} from '../../model/LakehouseConsumerDataCubeSource.js';
|
|
40
|
+
|
|
41
|
+
export class LakehouseConsumerDataCubeSourceLoaderState extends LegendDataCubeSourceLoaderState {
|
|
42
|
+
fullGraphGrammar: string | undefined;
|
|
43
|
+
dataProductId: string | undefined;
|
|
44
|
+
dpLoaded: boolean;
|
|
45
|
+
environment: string | undefined;
|
|
46
|
+
|
|
47
|
+
constructor(
|
|
48
|
+
application: LegendDataCubeApplicationStore,
|
|
49
|
+
engine: LegendDataCubeDataCubeEngine,
|
|
50
|
+
alertService: DataCubeAlertService,
|
|
51
|
+
sourceData: PlainObject,
|
|
52
|
+
persistentDataCube: PersistentDataCube,
|
|
53
|
+
onSuccess: () => Promise<void>,
|
|
54
|
+
onError: (error: unknown) => Promise<void>,
|
|
55
|
+
) {
|
|
56
|
+
super(
|
|
57
|
+
application,
|
|
58
|
+
engine,
|
|
59
|
+
alertService,
|
|
60
|
+
sourceData,
|
|
61
|
+
persistentDataCube,
|
|
62
|
+
onSuccess,
|
|
63
|
+
onError,
|
|
64
|
+
);
|
|
65
|
+
this.dpLoaded = false;
|
|
66
|
+
|
|
67
|
+
makeObservable(this, {
|
|
68
|
+
dpLoaded: observable,
|
|
69
|
+
setDpLoaded: action,
|
|
70
|
+
|
|
71
|
+
dataProductId: observable,
|
|
72
|
+
setDataProductId: action,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setDpLoaded(dpLoaded: boolean) {
|
|
77
|
+
this.dpLoaded = dpLoaded;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setDataProductId(id: string | undefined) {
|
|
81
|
+
this.dataProductId = id;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
override get isValid(): boolean {
|
|
85
|
+
return this.dpLoaded;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
override get label() {
|
|
89
|
+
return LegendDataCubeSourceBuilderType.LAKEHOUSE_CONSUMER;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
reset() {
|
|
93
|
+
const rawSource = RawLakehouseConsumerDataCubeSource.serialization.fromJson(
|
|
94
|
+
this.sourceData,
|
|
95
|
+
);
|
|
96
|
+
if (
|
|
97
|
+
!rawSource.origin ||
|
|
98
|
+
rawSource.origin instanceof RawLakehouseSdlcOrigin
|
|
99
|
+
) {
|
|
100
|
+
this.setDpLoaded(true);
|
|
101
|
+
} else {
|
|
102
|
+
this.setDpLoaded(false);
|
|
103
|
+
}
|
|
104
|
+
this.setDataProductId(rawSource.paths[0]);
|
|
105
|
+
this.environment = rawSource.environment;
|
|
106
|
+
this.fullGraphGrammar = undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async loadAdhocDataProduct(
|
|
110
|
+
access_token: string | undefined,
|
|
111
|
+
lakehouseContractServerClient: LakehouseContractServerClient,
|
|
112
|
+
) {
|
|
113
|
+
const dataProducts =
|
|
114
|
+
V1_entitlementsDataProductDetailsResponseToDataProductDetails(
|
|
115
|
+
await lakehouseContractServerClient.getDataProduct(
|
|
116
|
+
this.dataProductId?.split('::').pop() ?? '',
|
|
117
|
+
access_token,
|
|
118
|
+
),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const selectedEnv = guaranteeNonNullable(this.environment);
|
|
122
|
+
|
|
123
|
+
const dataProduct = selectedEnv.includes(
|
|
124
|
+
LakehouseEnvironmentType.DEVELOPMENT,
|
|
125
|
+
)
|
|
126
|
+
? dataProducts.find(
|
|
127
|
+
(dp) =>
|
|
128
|
+
dp.lakehouseEnvironment?.type ===
|
|
129
|
+
V1_EntitlementsLakehouseEnvironmentType.DEVELOPMENT,
|
|
130
|
+
)
|
|
131
|
+
: selectedEnv.includes(LakehouseEnvironmentType.PRODUCTION_PARALLEL)
|
|
132
|
+
? dataProducts.find(
|
|
133
|
+
(dp) =>
|
|
134
|
+
dp.lakehouseEnvironment?.type ===
|
|
135
|
+
V1_EntitlementsLakehouseEnvironmentType.PRODUCTION_PARALLEL,
|
|
136
|
+
)
|
|
137
|
+
: dataProducts.find(
|
|
138
|
+
(dp) =>
|
|
139
|
+
dp.lakehouseEnvironment?.type ===
|
|
140
|
+
V1_EntitlementsLakehouseEnvironmentType.PRODUCTION,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
if (
|
|
144
|
+
dataProduct?.origin &&
|
|
145
|
+
dataProduct.origin instanceof V1_AdHocDeploymentDataProductOrigin
|
|
146
|
+
) {
|
|
147
|
+
this.fullGraphGrammar = guaranteeType(
|
|
148
|
+
dataProduct.origin,
|
|
149
|
+
V1_AdHocDeploymentDataProductOrigin,
|
|
150
|
+
).definition;
|
|
151
|
+
this.setDpLoaded(true);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
override async load(source: PlainObject | undefined) {
|
|
156
|
+
const deserializedSource =
|
|
157
|
+
RawLakehouseConsumerDataCubeSource.serialization.fromJson(
|
|
158
|
+
guaranteeNonNullable(source),
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if (this.fullGraphGrammar) {
|
|
162
|
+
this._engine.registerAdhocDataProductGraphGrammar(this.fullGraphGrammar);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return RawLakehouseConsumerDataCubeSource.serialization.toJson(
|
|
166
|
+
deserializedSource,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
-
ActionState,
|
|
19
18
|
guaranteeNonNullable,
|
|
20
19
|
guaranteeType,
|
|
21
20
|
type PlainObject,
|
|
@@ -38,8 +37,6 @@ import type { UserManagerSettings } from 'oidc-client-ts';
|
|
|
38
37
|
import { SecondaryOAuthClient } from '../../model/SecondaryOauthClient.js';
|
|
39
38
|
|
|
40
39
|
export class LakehouseProducerDataCubeSourceLoaderState extends LegendDataCubeSourceLoaderState {
|
|
41
|
-
readonly processState = ActionState.create();
|
|
42
|
-
|
|
43
40
|
ingestDefinition: PlainObject | undefined;
|
|
44
41
|
ingestDefinitionUrn: string;
|
|
45
42
|
ingestServerUrl: string;
|
|
@@ -15,42 +15,131 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { DataCubeSource } from '@finos/legend-data-cube';
|
|
18
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
V1_DataProductOriginType,
|
|
20
|
+
type V1_PureModelContextData,
|
|
21
|
+
} from '@finos/legend-graph';
|
|
19
22
|
import { VersionedProjectData } from '@finos/legend-server-depot';
|
|
20
23
|
import {
|
|
24
|
+
optionalCustom,
|
|
21
25
|
SerializationFactory,
|
|
26
|
+
UnsupportedOperationError,
|
|
22
27
|
usingConstantValueSchema,
|
|
23
28
|
usingModelSchema,
|
|
24
29
|
type PlainObject,
|
|
25
30
|
} from '@finos/legend-shared';
|
|
26
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
createModelSchema,
|
|
33
|
+
deserialize,
|
|
34
|
+
list,
|
|
35
|
+
primitive,
|
|
36
|
+
serialize,
|
|
37
|
+
} from 'serializr';
|
|
27
38
|
|
|
28
39
|
export const LAKEHOUSE_CONSUMER_DATA_CUBE_SOURCE_TYPE = 'lakehouseConsumer';
|
|
29
40
|
|
|
30
41
|
export class LakehouseConsumerDataCubeSource extends DataCubeSource {
|
|
31
42
|
model!: PlainObject<V1_PureModelContextData>;
|
|
32
|
-
dpCoordinates
|
|
43
|
+
dpCoordinates?: VersionedProjectData;
|
|
33
44
|
runtime!: string;
|
|
34
45
|
warehouse!: string;
|
|
35
46
|
environment!: string;
|
|
36
47
|
paths!: string[];
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
export
|
|
50
|
+
export enum LakehouseEnvironmentType {
|
|
51
|
+
DEVELOPMENT = 'dev',
|
|
52
|
+
PRODUCTION_PARALLEL = 'pp',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export abstract class RawLakehouseOrigin {}
|
|
56
|
+
|
|
57
|
+
export class RawLakehouseAdhocOrigin extends RawLakehouseOrigin {
|
|
58
|
+
static readonly serialization = new SerializationFactory(
|
|
59
|
+
createModelSchema(RawLakehouseAdhocOrigin, {
|
|
60
|
+
_type: usingConstantValueSchema(
|
|
61
|
+
V1_DataProductOriginType.AD_HOC_DEPLOYMENT,
|
|
62
|
+
),
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class RawLakehouseSdlcOrigin extends RawLakehouseOrigin {
|
|
40
68
|
dpCoordinates!: VersionedProjectData;
|
|
69
|
+
|
|
70
|
+
static readonly serialization = new SerializationFactory(
|
|
71
|
+
createModelSchema(RawLakehouseSdlcOrigin, {
|
|
72
|
+
_type: usingConstantValueSchema(V1_DataProductOriginType.SDLC_DEPLOYMENT),
|
|
73
|
+
dpCoordinates: usingModelSchema(
|
|
74
|
+
VersionedProjectData.serialization.schema,
|
|
75
|
+
),
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class RawLakehouseConsumerDataCubeSource {
|
|
41
81
|
warehouse!: string;
|
|
42
82
|
environment!: string;
|
|
43
83
|
paths!: string[];
|
|
84
|
+
origin?: RawLakehouseOrigin;
|
|
44
85
|
|
|
45
86
|
static readonly serialization = new SerializationFactory(
|
|
46
87
|
createModelSchema(RawLakehouseConsumerDataCubeSource, {
|
|
47
88
|
_type: usingConstantValueSchema(LAKEHOUSE_CONSUMER_DATA_CUBE_SOURCE_TYPE),
|
|
48
|
-
dpCoordinates: usingModelSchema(
|
|
49
|
-
VersionedProjectData.serialization.schema,
|
|
50
|
-
),
|
|
51
89
|
warehouse: primitive(),
|
|
52
90
|
environment: primitive(),
|
|
53
91
|
paths: list(primitive()),
|
|
92
|
+
origin: optionalCustom(
|
|
93
|
+
(value) => {
|
|
94
|
+
if (value instanceof RawLakehouseAdhocOrigin) {
|
|
95
|
+
return serialize(
|
|
96
|
+
RawLakehouseAdhocOrigin.serialization.schema,
|
|
97
|
+
value,
|
|
98
|
+
);
|
|
99
|
+
} else if (value instanceof RawLakehouseSdlcOrigin) {
|
|
100
|
+
return serialize(
|
|
101
|
+
RawLakehouseSdlcOrigin.serialization.schema,
|
|
102
|
+
value,
|
|
103
|
+
);
|
|
104
|
+
} else {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Can't serialize RawLakehouseOrigin: no compatible serialization schema available from the provided value`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
(jsonValue) => {
|
|
111
|
+
switch (jsonValue._type) {
|
|
112
|
+
case V1_DataProductOriginType.AD_HOC_DEPLOYMENT:
|
|
113
|
+
return deserialize(
|
|
114
|
+
RawLakehouseAdhocOrigin.serialization.schema,
|
|
115
|
+
jsonValue,
|
|
116
|
+
);
|
|
117
|
+
case V1_DataProductOriginType.SDLC_DEPLOYMENT:
|
|
118
|
+
return deserialize(
|
|
119
|
+
RawLakehouseSdlcOrigin.serialization.schema,
|
|
120
|
+
jsonValue,
|
|
121
|
+
);
|
|
122
|
+
default:
|
|
123
|
+
throw new UnsupportedOperationError(
|
|
124
|
+
`Can't deserialize RawLakehouseOrigin: no compatible deserialization schema for type '${jsonValue._type}'`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
beforeDeserialize: (callback, jsonValue, jsonParentValue) => {
|
|
130
|
+
/** backward compatibility for dpCoordinates */
|
|
131
|
+
if (!jsonValue && jsonParentValue.dpCoordinates) {
|
|
132
|
+
const origin = {
|
|
133
|
+
_type: V1_DataProductOriginType.SDLC_DEPLOYMENT,
|
|
134
|
+
dpCoordinates: jsonParentValue.dpCoordinates,
|
|
135
|
+
} as PlainObject;
|
|
136
|
+
callback(null, origin);
|
|
137
|
+
} else {
|
|
138
|
+
callback(null, jsonValue);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
),
|
|
54
143
|
}),
|
|
55
144
|
);
|
|
56
145
|
}
|
package/tsconfig.json
CHANGED
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"./src/stores/LegendDataCubeDuckDBEngine.ts",
|
|
69
69
|
"./src/stores/builder/source/FreeformTDSExpressionDataCubeSourceBuilderState.ts",
|
|
70
70
|
"./src/stores/builder/source/LakehouseConsumerDataCubeSourceBuilderState.ts",
|
|
71
|
+
"./src/stores/builder/source/LakehouseConsumerDataCubeSourceLoaderState.ts",
|
|
71
72
|
"./src/stores/builder/source/LakehouseProducerDataCubeSourceBuilderState.ts",
|
|
72
73
|
"./src/stores/builder/source/LakehouseProducerDataCubeSourceLoaderState.ts",
|
|
73
74
|
"./src/stores/builder/source/LegendDataCubeSourceBuilderState.ts",
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
"./src/components/builder/LegendDataCubeSourceViewer.tsx",
|
|
97
98
|
"./src/components/builder/source/FreeformTDSExpressionDataCubeSourceBuilder.tsx",
|
|
98
99
|
"./src/components/builder/source/LakehouseConsumerDataCubeSourceBuilder.tsx",
|
|
100
|
+
"./src/components/builder/source/LakehouseConsumerDataCubeSourceLoader.tsx",
|
|
99
101
|
"./src/components/builder/source/LakehouseProducerDataCubeSourceBuilder.tsx",
|
|
100
102
|
"./src/components/builder/source/LakehouseProducerDataCubeSourceLoader.tsx",
|
|
101
103
|
"./src/components/builder/source/LegendDataCubeSourceLoader.tsx",
|