@osdk/maker-experimental 0.6.0-beta.3 → 0.6.0-beta.5
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/CHANGELOG.md +31 -0
- package/build/browser/api/defineOntologyV2.js +9 -3
- package/build/browser/api/defineOntologyV2.js.map +1 -1
- package/build/browser/cli/generateBackingDataset.js +250 -0
- package/build/browser/cli/generateBackingDataset.js.map +1 -0
- package/build/browser/cli/main.js +60 -7
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/cli/marketplaceSerialization/BlockGeneratorResult.js.map +1 -1
- package/build/browser/util/generateRid.js +10 -4
- package/build/browser/util/generateRid.js.map +1 -1
- package/build/cjs/{ActionTypeShapeExtractor-5IVLHAPH.cjs → ActionTypeShapeExtractor-UWC4CVHX.cjs} +4 -4
- package/build/cjs/{ActionTypeShapeExtractor-5IVLHAPH.cjs.map → ActionTypeShapeExtractor-UWC4CVHX.cjs.map} +1 -1
- package/build/cjs/{chunk-AWYOBJ25.cjs → chunk-JC573VYW.cjs} +13 -6
- package/build/cjs/chunk-JC573VYW.cjs.map +1 -0
- package/build/cjs/index.cjs +270 -38
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +6 -1
- package/build/esm/api/defineOntologyV2.js +9 -3
- package/build/esm/api/defineOntologyV2.js.map +1 -1
- package/build/esm/cli/generateBackingDataset.js +250 -0
- package/build/esm/cli/generateBackingDataset.js.map +1 -0
- package/build/esm/cli/main.js +60 -7
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/cli/marketplaceSerialization/BlockGeneratorResult.js.map +1 -1
- package/build/esm/util/generateRid.js +10 -4
- package/build/esm/util/generateRid.js.map +1 -1
- package/build/types/api/defineOntologyV2.d.ts +6 -1
- package/build/types/api/defineOntologyV2.d.ts.map +1 -1
- package/build/types/cli/generateBackingDataset.d.ts +16 -0
- package/build/types/cli/generateBackingDataset.d.ts.map +1 -0
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/cli/marketplaceSerialization/BlockGeneratorResult.d.ts +2 -2
- package/build/types/cli/marketplaceSerialization/BlockGeneratorResult.d.ts.map +1 -1
- package/build/types/util/generateRid.d.ts +4 -2
- package/build/types/util/generateRid.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/browser/api/overall.test.js +0 -713
- package/build/browser/api/overall.test.js.map +0 -1
- package/build/browser/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js +0 -562
- package/build/browser/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js.map +0 -1
- package/build/browser/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js +0 -677
- package/build/browser/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js.map +0 -1
- package/build/cjs/chunk-AWYOBJ25.cjs.map +0 -1
- package/build/esm/api/overall.test.js +0 -713
- package/build/esm/api/overall.test.js.map +0 -1
- package/build/esm/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js +0 -562
- package/build/esm/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js.map +0 -1
- package/build/esm/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js +0 -677
- package/build/esm/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js.map +0 -1
- package/build/types/api/overall.test.d.ts +0 -1
- package/build/types/api/overall.test.d.ts.map +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.d.ts +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.d.ts.map +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.d.ts +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.d.ts.map +0 -1
package/build/cjs/index.cjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var chunkJC573VYW_cjs = require('./chunk-JC573VYW.cjs');
|
|
6
6
|
var consola = require('consola');
|
|
7
7
|
var jiti = require('jiti');
|
|
8
8
|
var fs = require('fs');
|
|
9
|
-
var
|
|
9
|
+
var path2 = require('path');
|
|
10
10
|
var invariant5 = require('tiny-invariant');
|
|
11
11
|
var yargs = require('yargs');
|
|
12
12
|
var helpers = require('yargs/helpers');
|
|
@@ -34,7 +34,7 @@ function _interopNamespace(e) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
37
|
-
var
|
|
37
|
+
var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
|
|
38
38
|
var invariant5__default = /*#__PURE__*/_interopDefault(invariant5);
|
|
39
39
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
40
40
|
|
|
@@ -328,7 +328,7 @@ function registerGroupsFromCondition(condition, ridGenerator) {
|
|
|
328
328
|
switch (condition.type) {
|
|
329
329
|
case "group":
|
|
330
330
|
if (condition.name) {
|
|
331
|
-
ridGenerator.getGroupIds().put(
|
|
331
|
+
ridGenerator.getGroupIds().put(chunkJC573VYW_cjs.ReadableIdGenerator.getForGroup(condition.name), condition.name);
|
|
332
332
|
}
|
|
333
333
|
break;
|
|
334
334
|
case "comparison":
|
|
@@ -336,7 +336,7 @@ function registerGroupsFromCondition(condition, ridGenerator) {
|
|
|
336
336
|
const strings = condition.comparison?.right?.staticValue?.stringList?.strings;
|
|
337
337
|
if (Array.isArray(strings)) {
|
|
338
338
|
strings.forEach((groupName) => {
|
|
339
|
-
ridGenerator.getGroupIds().put(
|
|
339
|
+
ridGenerator.getGroupIds().put(chunkJC573VYW_cjs.ReadableIdGenerator.getForGroup(groupName), groupName);
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
342
|
}
|
|
@@ -558,7 +558,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
558
558
|
switch (condition.type) {
|
|
559
559
|
case "group":
|
|
560
560
|
const groupId = condition.name;
|
|
561
|
-
ridGenerator.getGroupIds().put(
|
|
561
|
+
ridGenerator.getGroupIds().put(chunkJC573VYW_cjs.ReadableIdGenerator.getForGroup(groupId), groupId);
|
|
562
562
|
break;
|
|
563
563
|
case "and":
|
|
564
564
|
case "or":
|
|
@@ -1334,7 +1334,7 @@ function convertAction(action, ridGenerator) {
|
|
|
1334
1334
|
const parameterOrdering = action.parameterOrdering ?? (action.parameters ?? []).map((p) => p.id);
|
|
1335
1335
|
const parameterIds = {};
|
|
1336
1336
|
(action.parameters ?? []).forEach((p) => {
|
|
1337
|
-
const readableId =
|
|
1337
|
+
const readableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForParameter(action.apiName, p.id);
|
|
1338
1338
|
const uuid = ridGenerator.toBlockInternalId(readableId);
|
|
1339
1339
|
parameterIds[uuid] = p.id;
|
|
1340
1340
|
});
|
|
@@ -1605,7 +1605,7 @@ function extractAllowedValues(allowedValues, ridGenerator) {
|
|
|
1605
1605
|
user: {
|
|
1606
1606
|
filter: (allowedValues.fromGroups ?? []).map((group) => {
|
|
1607
1607
|
if (group.type === "static") {
|
|
1608
|
-
ridGenerator.getGroupIds().put(
|
|
1608
|
+
ridGenerator.getGroupIds().put(chunkJC573VYW_cjs.ReadableIdGenerator.getForGroup(group.name), group.name);
|
|
1609
1609
|
}
|
|
1610
1610
|
return {
|
|
1611
1611
|
type: "groupFilter",
|
|
@@ -3476,7 +3476,7 @@ async function getShapes(ontologyBlockDataV2, ridGenerator, randomnessKey) {
|
|
|
3476
3476
|
}
|
|
3477
3477
|
const {
|
|
3478
3478
|
ActionTypeShapeExtractor
|
|
3479
|
-
} = await import('./ActionTypeShapeExtractor-
|
|
3479
|
+
} = await import('./ActionTypeShapeExtractor-UWC4CVHX.cjs');
|
|
3480
3480
|
for (const [_rid, actionType] of Object.entries(ontologyBlockDataV2.actionTypes || {})) {
|
|
3481
3481
|
const actionExtractor = new ActionTypeShapeExtractor();
|
|
3482
3482
|
const actionShapes = actionExtractor.extract(actionType, ridGenerator, ontologyBlockDataV2.knownIdentifiers);
|
|
@@ -3687,7 +3687,7 @@ function getMarkingShapes(ontologyBlockDataV2, ridGenerator) {
|
|
|
3687
3687
|
const markingType = markingData?.markingType;
|
|
3688
3688
|
const propertyApiName = propertyType.apiName ?? propertyType.displayMetadata?.displayName;
|
|
3689
3689
|
if (propertyApiName) {
|
|
3690
|
-
const readableId =
|
|
3690
|
+
const readableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForObjectProperty(objectApiName, propertyApiName);
|
|
3691
3691
|
if (markingType === "CBAC") {
|
|
3692
3692
|
cbacReadableIdsByRid.set(propertyRid, readableId);
|
|
3693
3693
|
} else if (markingType === "MANDATORY") {
|
|
@@ -3753,7 +3753,7 @@ function getMarkingShapes(ontologyBlockDataV2, ridGenerator) {
|
|
|
3753
3753
|
if (propType) {
|
|
3754
3754
|
const propApiName = propType.apiName ?? propType.displayMetadata?.displayName;
|
|
3755
3755
|
if (propApiName) {
|
|
3756
|
-
existing.add(
|
|
3756
|
+
existing.add(chunkJC573VYW_cjs.ReadableIdGenerator.getForObjectProperty(objectApiName, propApiName));
|
|
3757
3757
|
}
|
|
3758
3758
|
}
|
|
3759
3759
|
}
|
|
@@ -3764,7 +3764,7 @@ function getMarkingShapes(ontologyBlockDataV2, ridGenerator) {
|
|
|
3764
3764
|
}
|
|
3765
3765
|
const inputShapes = /* @__PURE__ */ new Map();
|
|
3766
3766
|
for (const [markingId, props] of cbacMarkingsAndAffectedProps) {
|
|
3767
|
-
const readableId =
|
|
3767
|
+
const readableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForMarking(markingId, "CBAC");
|
|
3768
3768
|
const shape = {
|
|
3769
3769
|
about: createLocalizedAbout3(`Max Classification ${markingId}`, MAX_CLASS_DESC),
|
|
3770
3770
|
operation: "USE",
|
|
@@ -3778,7 +3778,7 @@ function getMarkingShapes(ontologyBlockDataV2, ridGenerator) {
|
|
|
3778
3778
|
});
|
|
3779
3779
|
}
|
|
3780
3780
|
for (const [markingId, props] of additionalCbacMarkingsAndAffectedProps) {
|
|
3781
|
-
const readableId =
|
|
3781
|
+
const readableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForMarking(markingId, "CBAC");
|
|
3782
3782
|
const shape = {
|
|
3783
3783
|
about: createLocalizedAbout3(`Marking ${markingId}`, "Marking"),
|
|
3784
3784
|
operation: "USE",
|
|
@@ -3792,7 +3792,7 @@ function getMarkingShapes(ontologyBlockDataV2, ridGenerator) {
|
|
|
3792
3792
|
});
|
|
3793
3793
|
}
|
|
3794
3794
|
for (const [markingId, props] of mandatoryMarkingsAndAffectedProps) {
|
|
3795
|
-
const readableId =
|
|
3795
|
+
const readableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForMarking(markingId, "MANDATORY");
|
|
3796
3796
|
const shape = {
|
|
3797
3797
|
about: createLocalizedAbout3(`Max Marking ${markingId}`, "Max Marking"),
|
|
3798
3798
|
operation: "USE",
|
|
@@ -3823,13 +3823,13 @@ function consumeBlockShapes(target, source) {
|
|
|
3823
3823
|
}
|
|
3824
3824
|
}
|
|
3825
3825
|
function getReadableIdForSpt(apiName) {
|
|
3826
|
-
return
|
|
3826
|
+
return chunkJC573VYW_cjs.ReadableIdGenerator.getForSpt(apiName);
|
|
3827
3827
|
}
|
|
3828
3828
|
function getReadableIdForInterface(apiName) {
|
|
3829
|
-
return
|
|
3829
|
+
return chunkJC573VYW_cjs.ReadableIdGenerator.getForInterface(apiName);
|
|
3830
3830
|
}
|
|
3831
3831
|
function getReadableIdForInterfaceLink(interfaceApiName, linkApiName) {
|
|
3832
|
-
return
|
|
3832
|
+
return chunkJC573VYW_cjs.ReadableIdGenerator.getForInterfaceLinkType(interfaceApiName, linkApiName);
|
|
3833
3833
|
}
|
|
3834
3834
|
|
|
3835
3835
|
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
@@ -3883,21 +3883,21 @@ function buildKnownIdentifiers(ontology, ridGenerator) {
|
|
|
3883
3883
|
const backingDatasourceMappings = Object.fromEntries(Array.from(ridGenerator.getDatasourceLocators().entries()).map(([readableId, locator]) => [ridGenerator.toBlockInternalId(readableId), locator]));
|
|
3884
3884
|
const filesDatasourceMappings = Object.fromEntries(Array.from(ridGenerator.getFilesDatasourceLocators().entries()).map(([readableId, locator]) => [ridGenerator.toBlockInternalId(readableId), locator]));
|
|
3885
3885
|
const objectTypeRids = Object.fromEntries(Array.from(ridGenerator.getObjectTypeRids().inverse().entries()).map(([rid, readableId]) => [rid, ridGenerator.toBlockInternalId(readableId)]));
|
|
3886
|
-
const objectTypeIds = Object.fromEntries(Object.entries(ontology[maker.OntologyEntityTypeEnum.OBJECT_TYPE]).map(([objectTypeApiName, objectType]) => [ridGenerator.getObjectTypeIds().get(
|
|
3886
|
+
const objectTypeIds = Object.fromEntries(Object.entries(ontology[maker.OntologyEntityTypeEnum.OBJECT_TYPE]).map(([objectTypeApiName, objectType]) => [ridGenerator.getObjectTypeIds().get(chunkJC573VYW_cjs.ReadableIdGenerator.getForObjectType(objectTypeApiName)), ridGenerator.toBlockInternalId(chunkJC573VYW_cjs.ReadableIdGenerator.getForObjectType(objectTypeApiName))]));
|
|
3887
3887
|
const propertyTypeIds = {};
|
|
3888
3888
|
Object.entries(ontology[maker.OntologyEntityTypeEnum.OBJECT_TYPE]).forEach(([objectTypeApiName, objectType]) => {
|
|
3889
3889
|
const propMap = {};
|
|
3890
3890
|
(objectType.properties ?? []).forEach((property) => {
|
|
3891
|
-
propMap[property.apiName] = ridGenerator.toBlockInternalId(
|
|
3891
|
+
propMap[property.apiName] = ridGenerator.toBlockInternalId(chunkJC573VYW_cjs.ReadableIdGenerator.getForObjectProperty(objectTypeApiName, property.apiName));
|
|
3892
3892
|
});
|
|
3893
|
-
const objTypeId = ridGenerator.getObjectTypeIds().get(
|
|
3893
|
+
const objTypeId = ridGenerator.getObjectTypeIds().get(chunkJC573VYW_cjs.ReadableIdGenerator.getForObjectType(objectTypeApiName));
|
|
3894
3894
|
propertyTypeIds[objTypeId] = propMap;
|
|
3895
3895
|
});
|
|
3896
3896
|
const propertyRids = Object.fromEntries(Array.from(ridGenerator.getPropertyTypeRids().inverse().entries()).map(([rid, readableId]) => [rid, ridGenerator.toBlockInternalId(readableId)]));
|
|
3897
3897
|
const datasourceColumns = Object.fromEntries(Array.from(ridGenerator.getColumnShapes().entries()).map(([readableId, shape]) => [ridGenerator.toBlockInternalId(readableId), shape]));
|
|
3898
3898
|
const timeSeriesSyncs = Object.fromEntries(Array.from(ridGenerator.getTimeSeriesSyncs().inverse().entries()).map(([rid, readableId]) => [rid, ridGenerator.toBlockInternalId(readableId)]));
|
|
3899
3899
|
const geotimeSeriesSyncs = Object.fromEntries(Array.from(ridGenerator.getGeotimeSeriesIntegrationRids().inverse().entries()).map(([rid, readableId]) => [rid, ridGenerator.toBlockInternalId(readableId)]));
|
|
3900
|
-
const linkTypeIds = Object.fromEntries(Object.keys(ontology[maker.OntologyEntityTypeEnum.LINK_TYPE]).map((linkTypeId, link) => [maker.cleanAndValidateLinkTypeId(linkTypeId), ridGenerator.toBlockInternalId(
|
|
3900
|
+
const linkTypeIds = Object.fromEntries(Object.keys(ontology[maker.OntologyEntityTypeEnum.LINK_TYPE]).map((linkTypeId, link) => [maker.cleanAndValidateLinkTypeId(linkTypeId), ridGenerator.toBlockInternalId(chunkJC573VYW_cjs.ReadableIdGenerator.getForLinkType(maker.cleanAndValidateLinkTypeId(linkTypeId)))]));
|
|
3901
3901
|
const linkTypeRids = Object.fromEntries(Array.from(ridGenerator.getLinkTypeRids().inverse().entries()).map(([rid, readableId]) => [rid, ridGenerator.toBlockInternalId(readableId)]));
|
|
3902
3902
|
const actionTypeMappings = Object.fromEntries(Array.from(ridGenerator.getActionTypeRids().inverse().entries()).map(([rid, readableId]) => [rid, ridGenerator.toBlockInternalId(readableId)]));
|
|
3903
3903
|
const actionParameterMappings = {};
|
|
@@ -3961,7 +3961,7 @@ function buildKnownIdentifiers(ontology, ridGenerator) {
|
|
|
3961
3961
|
const key = `${markingId}-${markingType}`;
|
|
3962
3962
|
if (seenMarkings.has(key)) return;
|
|
3963
3963
|
seenMarkings.add(key);
|
|
3964
|
-
const readableId =
|
|
3964
|
+
const readableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForMarking(markingId, markingType);
|
|
3965
3965
|
const blockInternalId = ridGenerator.toBlockInternalId(readableId);
|
|
3966
3966
|
markingsMappings[blockInternalId] = [markingId];
|
|
3967
3967
|
});
|
|
@@ -4041,10 +4041,203 @@ async function defineOntologyV2(ns, body, randomnessKey) {
|
|
|
4041
4041
|
console.error("Unexpected error while processing the body of the ontology", e);
|
|
4042
4042
|
throw e;
|
|
4043
4043
|
}
|
|
4044
|
-
const
|
|
4045
|
-
const
|
|
4044
|
+
const ontologyDefinition = maker.getOntologyDefinition();
|
|
4045
|
+
const ridGenerator = new chunkJC573VYW_cjs.OntologyRidGeneratorImpl();
|
|
4046
|
+
const ontDef = convertOntologyDefinition(ontologyDefinition, ridGenerator, randomnessKey);
|
|
4046
4047
|
const shapes = await getShapes(ontDef.ontology, ridGenerator, randomnessKey);
|
|
4047
|
-
|
|
4048
|
+
const backingDatasourceApiNames = Object.entries(ontologyDefinition[maker.OntologyEntityTypeEnum.OBJECT_TYPE]).filter(([_, obj]) => obj.includeEmptyBackingDatasource === true).map(([apiName]) => apiName);
|
|
4049
|
+
return {
|
|
4050
|
+
ontologyIr: ontDef,
|
|
4051
|
+
shapes,
|
|
4052
|
+
backingDatasourceApiNames
|
|
4053
|
+
};
|
|
4054
|
+
}
|
|
4055
|
+
function propertyTypeToSchemaType(propType) {
|
|
4056
|
+
const typeStr = typeof propType === "string" ? propType : propType.type;
|
|
4057
|
+
switch (typeStr) {
|
|
4058
|
+
case "string":
|
|
4059
|
+
return "STRING";
|
|
4060
|
+
case "boolean":
|
|
4061
|
+
return "BOOLEAN";
|
|
4062
|
+
case "integer":
|
|
4063
|
+
return "INTEGER";
|
|
4064
|
+
case "long":
|
|
4065
|
+
return "LONG";
|
|
4066
|
+
case "double":
|
|
4067
|
+
return "DOUBLE";
|
|
4068
|
+
case "float":
|
|
4069
|
+
return "FLOAT";
|
|
4070
|
+
case "byte":
|
|
4071
|
+
return "BYTE";
|
|
4072
|
+
case "short":
|
|
4073
|
+
return "SHORT";
|
|
4074
|
+
case "date":
|
|
4075
|
+
return "DATE";
|
|
4076
|
+
case "timestamp":
|
|
4077
|
+
return "TIMESTAMP";
|
|
4078
|
+
default:
|
|
4079
|
+
throw new Error(`Unsupported property type "${typeStr}" for empty backing datasource. If using a property type that doesn't support empty backing datasources please make the property an edit only property.`);
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
function getEditOnlyPropertyRids(datasources) {
|
|
4083
|
+
const editOnlyRids = /* @__PURE__ */ new Set();
|
|
4084
|
+
for (const ds of datasources) {
|
|
4085
|
+
const def = ds.datasource;
|
|
4086
|
+
let propertyMapping;
|
|
4087
|
+
if (def.type === "datasetV2") {
|
|
4088
|
+
propertyMapping = def.datasetV2.propertyMapping;
|
|
4089
|
+
} else if (def.type === "datasetV3") {
|
|
4090
|
+
propertyMapping = def.datasetV3.propertyMapping;
|
|
4091
|
+
}
|
|
4092
|
+
if (propertyMapping) {
|
|
4093
|
+
for (const [rid, mapping] of Object.entries(propertyMapping)) {
|
|
4094
|
+
if (mapping.type === "editOnly") {
|
|
4095
|
+
editOnlyRids.add(rid);
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
return editOnlyRids;
|
|
4101
|
+
}
|
|
4102
|
+
function getNonEditOnlyProperties(objectTypeBlockData) {
|
|
4103
|
+
const editOnlyRids = getEditOnlyPropertyRids(objectTypeBlockData.datasources);
|
|
4104
|
+
return Object.entries(objectTypeBlockData.objectType.propertyTypes).filter(([rid]) => !editOnlyRids.has(rid)).map(([_, prop]) => prop);
|
|
4105
|
+
}
|
|
4106
|
+
async function generateBackingDatasetBlockResult(objectTypeBlockData, buildDir, randomnessKey) {
|
|
4107
|
+
const apiName = objectTypeBlockData.objectType.apiName;
|
|
4108
|
+
const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);
|
|
4109
|
+
const dsName = `${apiName}-backing-ds`;
|
|
4110
|
+
const outputs = {};
|
|
4111
|
+
const datasourceReadableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForDatasetOutput(apiName);
|
|
4112
|
+
const columnReadableIds = [];
|
|
4113
|
+
for (const prop of nonEditOnlyProps) {
|
|
4114
|
+
const colReadableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForDatasetColumnOutput(apiName, prop.apiName);
|
|
4115
|
+
columnReadableIds.push(colReadableId);
|
|
4116
|
+
}
|
|
4117
|
+
const datasourceBlockInternalId = chunkJC573VYW_cjs.toBlockShapeId(datasourceReadableId, randomnessKey);
|
|
4118
|
+
outputs[datasourceReadableId] = {
|
|
4119
|
+
type: "tabularDatasource",
|
|
4120
|
+
tabularDatasource: {
|
|
4121
|
+
about: {
|
|
4122
|
+
fallbackTitle: dsName,
|
|
4123
|
+
fallbackDescription: "",
|
|
4124
|
+
localizedTitle: {},
|
|
4125
|
+
localizedDescription: {}
|
|
4126
|
+
},
|
|
4127
|
+
schema: columnReadableIds.map((id) => chunkJC573VYW_cjs.toBlockShapeId(id, randomnessKey)),
|
|
4128
|
+
type: "DATASET",
|
|
4129
|
+
buildRequirements: {
|
|
4130
|
+
isBuildable: false
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
};
|
|
4134
|
+
for (let i = 0; i < nonEditOnlyProps.length; i++) {
|
|
4135
|
+
const prop = nonEditOnlyProps[i];
|
|
4136
|
+
const colReadableId = columnReadableIds[i];
|
|
4137
|
+
outputs[colReadableId] = {
|
|
4138
|
+
type: "datasourceColumn",
|
|
4139
|
+
datasourceColumn: {
|
|
4140
|
+
about: {
|
|
4141
|
+
fallbackTitle: prop.apiName,
|
|
4142
|
+
fallbackDescription: "",
|
|
4143
|
+
localizedTitle: {},
|
|
4144
|
+
localizedDescription: {}
|
|
4145
|
+
},
|
|
4146
|
+
type: {
|
|
4147
|
+
type: "concrete",
|
|
4148
|
+
concrete: typeToConcreteDataType(prop.type)
|
|
4149
|
+
},
|
|
4150
|
+
datasource: datasourceBlockInternalId,
|
|
4151
|
+
typeclasses: []
|
|
4152
|
+
}
|
|
4153
|
+
};
|
|
4154
|
+
}
|
|
4155
|
+
const columnInternalIds = nonEditOnlyProps.map((prop) => chunkJC573VYW_cjs.toBlockShapeId(`column-internal-${apiName}-${prop.apiName}`, randomnessKey));
|
|
4156
|
+
const compassReadableId = `${dsName}-compass-resource`;
|
|
4157
|
+
const compassBlockShapeId = chunkJC573VYW_cjs.toBlockShapeId(compassReadableId, randomnessKey);
|
|
4158
|
+
const datasourceInternalId = chunkJC573VYW_cjs.toBlockShapeId(`datasource-internal-${apiName}`, randomnessKey);
|
|
4159
|
+
const locationInternalId = chunkJC573VYW_cjs.toBlockShapeId(`location-internal-${apiName}`, randomnessKey);
|
|
4160
|
+
const addOnOverride = {
|
|
4161
|
+
idToBlockShapeId: {
|
|
4162
|
+
"dataset-internal-shape-id": datasourceBlockInternalId,
|
|
4163
|
+
[datasourceInternalId]: datasourceBlockInternalId,
|
|
4164
|
+
[locationInternalId]: compassBlockShapeId,
|
|
4165
|
+
...Object.fromEntries(columnInternalIds.map((internalId, i) => [internalId, chunkJC573VYW_cjs.toBlockShapeId(columnReadableIds[i], randomnessKey)]))
|
|
4166
|
+
},
|
|
4167
|
+
idToInputGroupId: {},
|
|
4168
|
+
outputToLocationInput: {
|
|
4169
|
+
[datasourceBlockInternalId]: compassBlockShapeId
|
|
4170
|
+
}
|
|
4171
|
+
};
|
|
4172
|
+
const dsBlockDataDir = path2__namespace.join(buildDir, `temp_block_data_${apiName}_backing_ds`);
|
|
4173
|
+
await fs__namespace.promises.mkdir(dsBlockDataDir, {
|
|
4174
|
+
recursive: true
|
|
4175
|
+
});
|
|
4176
|
+
const schemaJson = {
|
|
4177
|
+
fieldSchemaList: nonEditOnlyProps.map((prop) => ({
|
|
4178
|
+
type: propertyTypeToSchemaType(prop.type),
|
|
4179
|
+
name: prop.apiName,
|
|
4180
|
+
nullable: null,
|
|
4181
|
+
userDefinedTypeClass: null,
|
|
4182
|
+
customMetadata: {},
|
|
4183
|
+
arraySubtype: null,
|
|
4184
|
+
precision: null,
|
|
4185
|
+
scale: null,
|
|
4186
|
+
mapKeyType: null,
|
|
4187
|
+
mapValueType: null,
|
|
4188
|
+
subSchemas: null
|
|
4189
|
+
})),
|
|
4190
|
+
primaryKey: null,
|
|
4191
|
+
dataFrameReaderClass: "com.palantir.foundry.spark.input.ParquetDataFrameReader",
|
|
4192
|
+
customMetadata: {
|
|
4193
|
+
format: "parquet",
|
|
4194
|
+
options: {}
|
|
4195
|
+
}
|
|
4196
|
+
};
|
|
4197
|
+
await fs__namespace.promises.writeFile(path2__namespace.join(dsBlockDataDir, "schema.json"), JSON.stringify(schemaJson, null, 2));
|
|
4198
|
+
const blockDataJson = {
|
|
4199
|
+
type: "v1",
|
|
4200
|
+
v1: {
|
|
4201
|
+
columns: Object.fromEntries(nonEditOnlyProps.map((prop, i) => [columnInternalIds[i], prop.apiName])),
|
|
4202
|
+
hasSchema: true
|
|
4203
|
+
}
|
|
4204
|
+
};
|
|
4205
|
+
await fs__namespace.promises.writeFile(path2__namespace.join(dsBlockDataDir, "block-data.json"), JSON.stringify(blockDataJson, null, 2));
|
|
4206
|
+
await fs__namespace.promises.writeFile(path2__namespace.join(dsBlockDataDir, "VERSION"), '"1"');
|
|
4207
|
+
const emptyZip = Buffer.from([80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
4208
|
+
await fs__namespace.promises.writeFile(path2__namespace.join(dsBlockDataDir, "files.zip"), emptyZip);
|
|
4209
|
+
const inputs = {};
|
|
4210
|
+
inputs[compassReadableId] = {
|
|
4211
|
+
type: "compassResource",
|
|
4212
|
+
compassResource: {
|
|
4213
|
+
about: {
|
|
4214
|
+
fallbackTitle: dsName,
|
|
4215
|
+
fallbackDescription: "",
|
|
4216
|
+
localizedTitle: {},
|
|
4217
|
+
localizedDescription: {}
|
|
4218
|
+
},
|
|
4219
|
+
allowedTypes: [],
|
|
4220
|
+
typeConstraints: [{
|
|
4221
|
+
type: "compassFolderTypeConstraints",
|
|
4222
|
+
compassFolderTypeConstraints: {
|
|
4223
|
+
constraints: ["INSTALL_LOCATION"]
|
|
4224
|
+
}
|
|
4225
|
+
}]
|
|
4226
|
+
}
|
|
4227
|
+
};
|
|
4228
|
+
return {
|
|
4229
|
+
block_identifier: dsName,
|
|
4230
|
+
block_data_directory: dsBlockDataDir,
|
|
4231
|
+
oci_block_data_metadata: void 0,
|
|
4232
|
+
maven_block_data_metadata: void 0,
|
|
4233
|
+
inputs,
|
|
4234
|
+
outputs,
|
|
4235
|
+
input_mapping_entries: [],
|
|
4236
|
+
external_recommendations: [],
|
|
4237
|
+
add_on_override: addOnOverride,
|
|
4238
|
+
input_shape_metadata: {},
|
|
4239
|
+
block_type: "STATIC_DATASET"
|
|
4240
|
+
};
|
|
4048
4241
|
}
|
|
4049
4242
|
|
|
4050
4243
|
// src/cli/main.ts
|
|
@@ -4052,20 +4245,20 @@ var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
|
4052
4245
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
4053
4246
|
async function main(args = process.argv) {
|
|
4054
4247
|
consola.consola.log("Generating BlockGeneratorResult for ontology...");
|
|
4055
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.6.0-beta.
|
|
4248
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.6.0-beta.5").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
4056
4249
|
input: {
|
|
4057
4250
|
alias: "i",
|
|
4058
4251
|
describe: "Input file",
|
|
4059
4252
|
type: "string",
|
|
4060
4253
|
default: ".ontology/ontology.ts",
|
|
4061
|
-
coerce:
|
|
4254
|
+
coerce: path2__namespace.resolve
|
|
4062
4255
|
},
|
|
4063
4256
|
output: {
|
|
4064
4257
|
alias: "o",
|
|
4065
4258
|
describe: "Output file for BlockGeneratorResult JSON",
|
|
4066
4259
|
type: "string",
|
|
4067
4260
|
default: "build/block_generator_result.json",
|
|
4068
|
-
coerce:
|
|
4261
|
+
coerce: path2__namespace.resolve
|
|
4069
4262
|
},
|
|
4070
4263
|
apiNamespace: {
|
|
4071
4264
|
describe: "Api name prefix for namespaced ontology types",
|
|
@@ -4077,12 +4270,12 @@ async function main(args = process.argv) {
|
|
|
4077
4270
|
describe: "Directory for build files",
|
|
4078
4271
|
type: "string",
|
|
4079
4272
|
default: "build/",
|
|
4080
|
-
coerce:
|
|
4273
|
+
coerce: path2__namespace.resolve
|
|
4081
4274
|
},
|
|
4082
4275
|
randomnessKey: {
|
|
4083
4276
|
describe: "Value used to assure uniqueness of entities",
|
|
4084
4277
|
type: "string",
|
|
4085
|
-
coerce:
|
|
4278
|
+
coerce: path2__namespace.resolve
|
|
4086
4279
|
}
|
|
4087
4280
|
}).parseAsync();
|
|
4088
4281
|
let apiNamespace = "";
|
|
@@ -4095,17 +4288,53 @@ async function main(args = process.argv) {
|
|
|
4095
4288
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
4096
4289
|
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant5__default.default(false) : void 0;
|
|
4097
4290
|
}
|
|
4098
|
-
const
|
|
4099
|
-
|
|
4291
|
+
const {
|
|
4292
|
+
ontologyIr,
|
|
4293
|
+
shapes,
|
|
4294
|
+
backingDatasourceApiNames
|
|
4295
|
+
} = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.randomnessKey);
|
|
4296
|
+
const blockDataDir = path2__namespace.join(commandLineOpts.buildDir, "temp_block_data");
|
|
4100
4297
|
if (!fs__namespace.existsSync(blockDataDir)) {
|
|
4101
4298
|
await fs__namespace.promises.mkdir(blockDataDir, {
|
|
4102
4299
|
recursive: true
|
|
4103
4300
|
});
|
|
4104
4301
|
}
|
|
4105
|
-
const ontologyJsonPath =
|
|
4106
|
-
const ontologyJson = JSON.stringify(
|
|
4302
|
+
const ontologyJsonPath = path2__namespace.join(blockDataDir, "ontology.json");
|
|
4303
|
+
const ontologyJson = JSON.stringify(ontologyIr.ontology, null, 2);
|
|
4107
4304
|
await fs__namespace.promises.writeFile(ontologyJsonPath, ontologyJson);
|
|
4108
4305
|
consola.consola.info(`Wrote ontology.json to ${ontologyJsonPath}`);
|
|
4306
|
+
const ontologyInputMappingEntries = [];
|
|
4307
|
+
for (const apiName of backingDatasourceApiNames) {
|
|
4308
|
+
const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
|
|
4309
|
+
if (!objectTypeBlockData) continue;
|
|
4310
|
+
const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);
|
|
4311
|
+
const inputDatasetReadableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForDataset(apiName);
|
|
4312
|
+
const outputDatasetReadableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForDatasetOutput(apiName);
|
|
4313
|
+
if (shapes.inputShapes.has(inputDatasetReadableId)) {
|
|
4314
|
+
ontologyInputMappingEntries.push({
|
|
4315
|
+
input: inputDatasetReadableId,
|
|
4316
|
+
output: outputDatasetReadableId
|
|
4317
|
+
});
|
|
4318
|
+
}
|
|
4319
|
+
for (const prop of nonEditOnlyProps) {
|
|
4320
|
+
const colInputReadableId = chunkJC573VYW_cjs.ReadableIdGenerator.getForDatasetColumn(apiName, prop.apiName);
|
|
4321
|
+
const getForDatasetColumnOutput = chunkJC573VYW_cjs.ReadableIdGenerator.getForDatasetColumnOutput(apiName, prop.apiName);
|
|
4322
|
+
if (shapes.inputShapes.has(colInputReadableId)) {
|
|
4323
|
+
ontologyInputMappingEntries.push({
|
|
4324
|
+
input: colInputReadableId,
|
|
4325
|
+
output: getForDatasetColumnOutput
|
|
4326
|
+
});
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4330
|
+
const backingDsGeneratorResults = await Promise.all(backingDatasourceApiNames.filter((apiName) => {
|
|
4331
|
+
const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
|
|
4332
|
+
return objectTypeBlockData !== void 0;
|
|
4333
|
+
}).map(async (apiName) => {
|
|
4334
|
+
const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
|
|
4335
|
+
consola.consola.info(`Generating backing datasource BlockGeneratorResult for ${apiName}...`);
|
|
4336
|
+
return await generateBackingDatasetBlockResult(objectTypeBlockData, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
4337
|
+
}));
|
|
4109
4338
|
const blockGeneratorResult = {
|
|
4110
4339
|
block_identifier: "ontology",
|
|
4111
4340
|
block_data_directory: blockDataDir,
|
|
@@ -4113,19 +4342,19 @@ async function main(args = process.argv) {
|
|
|
4113
4342
|
maven_block_data_metadata: void 0,
|
|
4114
4343
|
inputs: Object.fromEntries(shapes.inputShapes),
|
|
4115
4344
|
outputs: Object.fromEntries(shapes.outputShapes),
|
|
4116
|
-
input_mapping_entries:
|
|
4345
|
+
input_mapping_entries: ontologyInputMappingEntries,
|
|
4117
4346
|
external_recommendations: [],
|
|
4118
4347
|
add_on_override: void 0,
|
|
4119
4348
|
input_shape_metadata: Object.fromEntries(shapes.inputShapeMetadata),
|
|
4120
4349
|
block_type: "ONTOLOGY"
|
|
4121
4350
|
};
|
|
4122
|
-
const blockGeneratorResultJson = JSON.stringify(blockGeneratorResult, null, 2);
|
|
4351
|
+
const blockGeneratorResultJson = JSON.stringify([blockGeneratorResult, ...backingDsGeneratorResults], null, 2);
|
|
4123
4352
|
await fs__namespace.promises.writeFile(commandLineOpts.output, blockGeneratorResultJson);
|
|
4124
4353
|
consola.consola.success(`BlockGeneratorResult written to ${commandLineOpts.output}`);
|
|
4125
4354
|
consola.consola.info(`Block data directory: ${blockDataDir}`);
|
|
4126
4355
|
}
|
|
4127
4356
|
async function loadOntology(input, apiNamespace, randomnessKey) {
|
|
4128
|
-
const
|
|
4357
|
+
const result = await defineOntologyV2(apiNamespace, async () => {
|
|
4129
4358
|
const jiti$1 = jiti.createJiti(undefined, {
|
|
4130
4359
|
moduleCache: true,
|
|
4131
4360
|
debug: false,
|
|
@@ -4133,7 +4362,10 @@ async function loadOntology(input, apiNamespace, randomnessKey) {
|
|
|
4133
4362
|
});
|
|
4134
4363
|
const module = await jiti$1.import(input);
|
|
4135
4364
|
}, randomnessKey);
|
|
4136
|
-
return
|
|
4365
|
+
return result;
|
|
4366
|
+
}
|
|
4367
|
+
function findObjectTypeByApiName(objectTypes, apiName) {
|
|
4368
|
+
return Object.values(objectTypes).find((objectTypeBlockData) => objectTypeBlockData.objectType.apiName === apiName);
|
|
4137
4369
|
}
|
|
4138
4370
|
function defineImportObject(objectDef) {
|
|
4139
4371
|
const properties = Object.entries(objectDef.properties ?? {}).map(([apiName, type]) => ({
|