@osdk/maker 0.15.0-beta.6 → 0.15.0-beta.7
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 +11 -0
- package/build/browser/api/action/ActionParameter.js.map +1 -1
- package/build/browser/api/action/ActionParameterConfiguration.js.map +1 -1
- package/build/browser/api/defineAction.js +65 -22
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +28 -8
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineInterface.js +40 -34
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +31 -8
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +13 -9
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/interface/InterfacePropertyType.js +22 -1
- package/build/browser/api/interface/InterfacePropertyType.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/interface/getFlattenedInterfaceProperties.js +9 -3
- package/build/browser/api/interface/getFlattenedInterfaceProperties.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
- package/build/browser/api/test/actions.test.js +6105 -5850
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/interfaces.test.js +723 -470
- package/build/browser/api/test/interfaces.test.js.map +1 -1
- package/build/browser/api/test/links.test.js +1334 -1325
- package/build/browser/api/test/links.test.js.map +1 -1
- package/build/browser/api/test/misc.test.js +262 -11
- package/build/browser/api/test/misc.test.js.map +1 -1
- package/build/browser/api/test/objects.test.js +1019 -960
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +250 -103
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +2 -2
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterfacePropertyType.js +66 -0
- package/build/browser/conversion/toMarketplace/convertInterfacePropertyType.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertMappingValue.js +35 -0
- package/build/browser/conversion/toMarketplace/convertMappingValue.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObject.js +4 -2
- package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +2 -1
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertSpt.js +4 -2
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js +143 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js.map +1 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +386 -109
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +28 -13
- package/build/esm/api/action/ActionParameter.js.map +1 -1
- package/build/esm/api/action/ActionParameterConfiguration.js.map +1 -1
- package/build/esm/api/defineAction.js +65 -22
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +28 -8
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineInterface.js +40 -34
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +31 -8
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +13 -9
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/interface/InterfacePropertyType.js +22 -1
- package/build/esm/api/interface/InterfacePropertyType.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/interface/getFlattenedInterfaceProperties.js +9 -3
- package/build/esm/api/interface/getFlattenedInterfaceProperties.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
- package/build/esm/api/test/actions.test.js +6105 -5850
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/interfaces.test.js +723 -470
- package/build/esm/api/test/interfaces.test.js.map +1 -1
- package/build/esm/api/test/links.test.js +1334 -1325
- package/build/esm/api/test/links.test.js.map +1 -1
- package/build/esm/api/test/misc.test.js +262 -11
- package/build/esm/api/test/misc.test.js.map +1 -1
- package/build/esm/api/test/objects.test.js +1019 -960
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +250 -103
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +2 -2
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterfacePropertyType.js +66 -0
- package/build/esm/conversion/toMarketplace/convertInterfacePropertyType.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertMappingValue.js +35 -0
- package/build/esm/conversion/toMarketplace/convertMappingValue.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObject.js +4 -2
- package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +2 -1
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertSpt.js +4 -2
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js +143 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js.map +1 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/api/action/ActionParameter.d.ts +2 -1
- package/build/types/api/action/ActionParameter.d.ts.map +1 -1
- package/build/types/api/action/ActionParameterConfiguration.d.ts +2 -1
- package/build/types/api/action/ActionParameterConfiguration.d.ts.map +1 -1
- package/build/types/api/defineAction.d.ts +4 -3
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts +5 -5
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +3 -0
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/interface/InterfacePropertyType.d.ts +12 -2
- package/build/types/api/interface/InterfacePropertyType.d.ts.map +1 -1
- package/build/types/api/interface/InterfaceType.d.ts +3 -2
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
- package/build/types/api/interface/getFlattenedInterfaceProperties.d.ts +1 -1
- package/build/types/api/interface/getFlattenedInterfaceProperties.d.ts.map +1 -1
- package/build/types/api/object/ObjectType.d.ts +1 -0
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +1 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/properties/SharedPropertyType.d.ts +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertInterface.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertInterfacePropertyType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertInterfacePropertyType.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertMappingValue.d.ts +2 -1
- package/build/types/conversion/toMarketplace/convertMappingValue.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertSpt.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertSpt.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/package.json +4 -4
package/build/cjs/index.cjs
CHANGED
|
@@ -256,13 +256,26 @@ function getObject(object) {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
// src/api/interface/InterfacePropertyType.ts
|
|
260
|
+
function isInterfaceSharedPropertyType(interfacePropertyType) {
|
|
261
|
+
return "sharedPropertyType" in interfacePropertyType;
|
|
262
|
+
}
|
|
263
|
+
function getInterfacePropertyTypeType(interfacePropertyType) {
|
|
264
|
+
return isInterfaceSharedPropertyType(interfacePropertyType) ? interfacePropertyType.sharedPropertyType.type : interfacePropertyType.type;
|
|
265
|
+
}
|
|
266
|
+
|
|
259
267
|
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
260
268
|
function getFlattenedInterfaceProperties(interfaceType) {
|
|
261
|
-
let properties = interfaceType.
|
|
269
|
+
let properties = Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([key, value]) => [isInterfaceSharedPropertyType(value) ? value.sharedPropertyType.apiName : key, value]));
|
|
270
|
+
Object.entries(interfaceType.propertiesV2).forEach(([apiName, spt]) => {
|
|
271
|
+
if (!(apiName in properties)) {
|
|
272
|
+
properties[apiName] = spt;
|
|
273
|
+
}
|
|
274
|
+
});
|
|
262
275
|
interfaceType.extendsInterfaces.forEach((ext) => {
|
|
263
276
|
properties = {
|
|
264
|
-
...
|
|
265
|
-
...
|
|
277
|
+
...getFlattenedInterfaceProperties(ext),
|
|
278
|
+
...properties
|
|
266
279
|
};
|
|
267
280
|
});
|
|
268
281
|
return properties;
|
|
@@ -279,7 +292,7 @@ function isExotic(type) {
|
|
|
279
292
|
if (typeof type === "string") {
|
|
280
293
|
return ["geopoint", "geoshape", "mediaReference", "geotimeSeries"].includes(type);
|
|
281
294
|
} else if (typeof type === "object" && type != null) {
|
|
282
|
-
return type.type === "marking" || type.type === "struct";
|
|
295
|
+
return type.type === "marking" || type.type === "struct" || type.type === "string" || type.type === "decimal";
|
|
283
296
|
}
|
|
284
297
|
return false;
|
|
285
298
|
}
|
|
@@ -328,18 +341,19 @@ function defineObject(objectDef) {
|
|
|
328
341
|
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant7__default.default(false) : void 0;
|
|
329
342
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
330
343
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
331
|
-
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
344
|
+
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
332
345
|
type: "invalid",
|
|
333
346
|
reason: `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
|
|
334
347
|
}));
|
|
335
|
-
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map((mapping) => [
|
|
348
|
+
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map((mapping) => [mapping.interfaceProperty, mapping.mapsTo]));
|
|
336
349
|
const validateProperty = (interfaceProp) => {
|
|
337
|
-
|
|
338
|
-
|
|
350
|
+
const apiName2 = isInterfaceSharedPropertyType(interfaceProp[1]) ? interfaceProp[1].sharedPropertyType.apiName : interfaceProp[0];
|
|
351
|
+
if (apiName2 in interfaceToObjectProperties) {
|
|
352
|
+
return validateInterfaceImplProperty(interfaceProp[1], apiName2, interfaceToObjectProperties[interfaceProp[0]], objectDef);
|
|
339
353
|
}
|
|
340
354
|
return {
|
|
341
355
|
type: "invalid",
|
|
342
|
-
reason: `Interface
|
|
356
|
+
reason: `Interface spt ${apiName2} not implemented by ${objectDef.apiName} object definition`
|
|
343
357
|
};
|
|
344
358
|
};
|
|
345
359
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
@@ -361,7 +375,7 @@ function formatValidationErrors(error) {
|
|
|
361
375
|
return `Ontology Definition Error: ${error.reason}
|
|
362
376
|
`;
|
|
363
377
|
}
|
|
364
|
-
function validateInterfaceImplProperty(
|
|
378
|
+
function validateInterfaceImplProperty(type, apiName, mappedObjectProp, object) {
|
|
365
379
|
const objProp = object.properties?.[mappedObjectProp];
|
|
366
380
|
if (objProp === void 0) {
|
|
367
381
|
return {
|
|
@@ -369,10 +383,11 @@ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
|
|
|
369
383
|
reason: `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`
|
|
370
384
|
};
|
|
371
385
|
}
|
|
372
|
-
|
|
386
|
+
const propertyType = getInterfacePropertyTypeType(type);
|
|
387
|
+
if (JSON.stringify(propertyType) !== JSON.stringify(objProp?.type)) {
|
|
373
388
|
return {
|
|
374
389
|
type: "invalid",
|
|
375
|
-
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${
|
|
390
|
+
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${apiName}, objectProperty: ${mappedObjectProp}`
|
|
376
391
|
};
|
|
377
392
|
}
|
|
378
393
|
return {
|
|
@@ -719,7 +734,7 @@ function convertActionValidation(action) {
|
|
|
719
734
|
return [p.id, {
|
|
720
735
|
defaultValidation: {
|
|
721
736
|
display: {
|
|
722
|
-
renderHint: renderHintFromBaseType(p, p.validation),
|
|
737
|
+
renderHint: p.renderHint ?? renderHintFromBaseType(p, p.validation),
|
|
723
738
|
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
724
739
|
...p.defaultValue && {
|
|
725
740
|
prefill: p.defaultValue
|
|
@@ -839,6 +854,10 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
839
854
|
...fieldTypeDefinition,
|
|
840
855
|
apiName: key,
|
|
841
856
|
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition.fieldType),
|
|
857
|
+
displayMetadata: fieldTypeDefinition.displayMetadata ?? {
|
|
858
|
+
displayName: key,
|
|
859
|
+
description: void 0
|
|
860
|
+
},
|
|
842
861
|
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
843
862
|
aliases: fieldTypeDefinition.aliases ?? []
|
|
844
863
|
};
|
|
@@ -935,6 +954,7 @@ function convertSpt({
|
|
|
935
954
|
visibility,
|
|
936
955
|
gothamMapping,
|
|
937
956
|
typeClasses,
|
|
957
|
+
aliases,
|
|
938
958
|
valueType,
|
|
939
959
|
nullability,
|
|
940
960
|
baseFormatter
|
|
@@ -953,10 +973,11 @@ function convertSpt({
|
|
|
953
973
|
type: array ? {
|
|
954
974
|
type: "array",
|
|
955
975
|
array: {
|
|
956
|
-
subtype: propertyTypeTypeToOntologyIrType(type)
|
|
976
|
+
subtype: propertyTypeTypeToOntologyIrType(type),
|
|
977
|
+
reducers: []
|
|
957
978
|
}
|
|
958
979
|
} : propertyTypeTypeToOntologyIrType(type),
|
|
959
|
-
aliases: [],
|
|
980
|
+
aliases: aliases ?? [],
|
|
960
981
|
baseFormatter,
|
|
961
982
|
dataConstraints: dataConstraint,
|
|
962
983
|
gothamMapping,
|
|
@@ -971,6 +992,178 @@ function convertSpt({
|
|
|
971
992
|
};
|
|
972
993
|
}
|
|
973
994
|
|
|
995
|
+
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.ts
|
|
996
|
+
function propertyTypeTypeToOntologyIrInterfaceType(type) {
|
|
997
|
+
switch (true) {
|
|
998
|
+
case (typeof type === "object" && type.type === "marking"):
|
|
999
|
+
return {
|
|
1000
|
+
"type": "marking",
|
|
1001
|
+
marking: {
|
|
1002
|
+
markingType: type.markingType
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
case (typeof type === "object" && type.type === "struct"):
|
|
1006
|
+
const structFields = new Array();
|
|
1007
|
+
for (const key in type.structDefinition) {
|
|
1008
|
+
const fieldTypeDefinition = type.structDefinition[key];
|
|
1009
|
+
let field;
|
|
1010
|
+
if (typeof fieldTypeDefinition === "string") {
|
|
1011
|
+
field = {
|
|
1012
|
+
apiName: key,
|
|
1013
|
+
displayMetadata: {
|
|
1014
|
+
displayName: key,
|
|
1015
|
+
description: void 0
|
|
1016
|
+
},
|
|
1017
|
+
typeClasses: [],
|
|
1018
|
+
aliases: [],
|
|
1019
|
+
fieldType: propertyTypeTypeToOntologyIrInterfaceType(fieldTypeDefinition),
|
|
1020
|
+
requireImplementation: true
|
|
1021
|
+
};
|
|
1022
|
+
} else {
|
|
1023
|
+
if (typeof fieldTypeDefinition === "object" && "fieldType" in fieldTypeDefinition) {
|
|
1024
|
+
field = {
|
|
1025
|
+
...fieldTypeDefinition,
|
|
1026
|
+
apiName: key,
|
|
1027
|
+
fieldType: propertyTypeTypeToOntologyIrInterfaceType(fieldTypeDefinition.fieldType),
|
|
1028
|
+
displayMetadata: fieldTypeDefinition.displayMetadata ?? {
|
|
1029
|
+
displayName: key,
|
|
1030
|
+
description: void 0
|
|
1031
|
+
},
|
|
1032
|
+
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
1033
|
+
aliases: fieldTypeDefinition.aliases ?? [],
|
|
1034
|
+
requireImplementation: fieldTypeDefinition.requireImplementation ?? true
|
|
1035
|
+
};
|
|
1036
|
+
} else {
|
|
1037
|
+
field = {
|
|
1038
|
+
apiName: key,
|
|
1039
|
+
displayMetadata: {
|
|
1040
|
+
displayName: key,
|
|
1041
|
+
description: void 0
|
|
1042
|
+
},
|
|
1043
|
+
typeClasses: [],
|
|
1044
|
+
aliases: [],
|
|
1045
|
+
fieldType: propertyTypeTypeToOntologyIrInterfaceType(fieldTypeDefinition),
|
|
1046
|
+
requireImplementation: true
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
structFields.push(field);
|
|
1051
|
+
}
|
|
1052
|
+
return {
|
|
1053
|
+
type: "struct",
|
|
1054
|
+
struct: {
|
|
1055
|
+
structFields
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
case (typeof type === "object" && type.type === "string"):
|
|
1059
|
+
return {
|
|
1060
|
+
"type": "string",
|
|
1061
|
+
"string": {
|
|
1062
|
+
analyzerOverride: void 0,
|
|
1063
|
+
enableAsciiFolding: type.enableAsciiFolding,
|
|
1064
|
+
isLongText: type.isLongText ?? false,
|
|
1065
|
+
supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard ?? false,
|
|
1066
|
+
supportsExactMatching: type.supportsExactMatching ?? true,
|
|
1067
|
+
supportsFullTextRegex: type.supportsFullTextRegex
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
case (typeof type === "object" && type.type === "decimal"):
|
|
1071
|
+
return {
|
|
1072
|
+
"type": "decimal",
|
|
1073
|
+
"decimal": {
|
|
1074
|
+
precision: type.precision,
|
|
1075
|
+
scale: type.scale
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
case type === "geopoint":
|
|
1079
|
+
return {
|
|
1080
|
+
type: "geohash",
|
|
1081
|
+
geohash: {}
|
|
1082
|
+
};
|
|
1083
|
+
case type === "decimal":
|
|
1084
|
+
return {
|
|
1085
|
+
type,
|
|
1086
|
+
[type]: {
|
|
1087
|
+
precision: void 0,
|
|
1088
|
+
scale: void 0
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
case type === "string":
|
|
1092
|
+
return {
|
|
1093
|
+
type,
|
|
1094
|
+
[type]: {
|
|
1095
|
+
analyzerOverride: void 0,
|
|
1096
|
+
enableAsciiFolding: void 0,
|
|
1097
|
+
isLongText: false,
|
|
1098
|
+
supportsEfficientLeadingWildcard: false,
|
|
1099
|
+
supportsExactMatching: true
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
case type === "mediaReference":
|
|
1103
|
+
return {
|
|
1104
|
+
type,
|
|
1105
|
+
mediaReference: {}
|
|
1106
|
+
};
|
|
1107
|
+
case type === "geotimeSeries":
|
|
1108
|
+
return {
|
|
1109
|
+
type: "geotimeSeriesReference",
|
|
1110
|
+
geotimeSeriesReference: {}
|
|
1111
|
+
};
|
|
1112
|
+
default:
|
|
1113
|
+
if (typeof type === "object") {
|
|
1114
|
+
throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);
|
|
1115
|
+
}
|
|
1116
|
+
return distributeTypeHelper(type);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// src/conversion/toMarketplace/convertInterfacePropertyType.ts
|
|
1121
|
+
function convertInterfaceProperty(prop, apiName) {
|
|
1122
|
+
if (isInterfaceSharedPropertyType(prop)) {
|
|
1123
|
+
return [prop.sharedPropertyType.apiName, {
|
|
1124
|
+
type: "sharedPropertyBasedPropertyType",
|
|
1125
|
+
sharedPropertyBasedPropertyType: {
|
|
1126
|
+
requireImplementation: prop.required,
|
|
1127
|
+
sharedPropertyType: convertSpt(prop.sharedPropertyType)
|
|
1128
|
+
}
|
|
1129
|
+
}];
|
|
1130
|
+
} else {
|
|
1131
|
+
return [apiName, {
|
|
1132
|
+
type: "interfaceDefinedPropertyType",
|
|
1133
|
+
interfaceDefinedPropertyType: {
|
|
1134
|
+
apiName,
|
|
1135
|
+
displayMetadata: {
|
|
1136
|
+
displayName: prop.displayName ?? apiName,
|
|
1137
|
+
visibility: prop.visibility ?? "NORMAL",
|
|
1138
|
+
description: prop.description
|
|
1139
|
+
},
|
|
1140
|
+
type: prop.array ? {
|
|
1141
|
+
type: "array",
|
|
1142
|
+
array: {
|
|
1143
|
+
subtype: propertyTypeTypeToOntologyIrInterfaceType(prop.type)
|
|
1144
|
+
}
|
|
1145
|
+
} : propertyTypeTypeToOntologyIrInterfaceType(prop.type),
|
|
1146
|
+
constraints: {
|
|
1147
|
+
primaryKeyConstraint: prop.primaryKeyConstraint ?? "NO_RESTRICTION",
|
|
1148
|
+
requireImplementation: prop.required ?? true,
|
|
1149
|
+
indexedForSearch: true,
|
|
1150
|
+
typeClasses: prop.typeClasses ?? [],
|
|
1151
|
+
dataConstraints: convertNullabilityToDataConstraint({
|
|
1152
|
+
type: prop.type,
|
|
1153
|
+
nullability: prop.nullability
|
|
1154
|
+
}),
|
|
1155
|
+
valueType: prop.valueType ? {
|
|
1156
|
+
apiName: prop.valueType.apiName,
|
|
1157
|
+
version: prop.valueType.version,
|
|
1158
|
+
packageNamespace: prop.valueType.packageNamespace,
|
|
1159
|
+
displayMetadata: prop.valueType.displayMetadata
|
|
1160
|
+
} : void 0
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}];
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
|
|
974
1167
|
// src/conversion/toMarketplace/convertInterface.ts
|
|
975
1168
|
function convertInterface(interfaceType) {
|
|
976
1169
|
const {
|
|
@@ -997,8 +1190,7 @@ function convertInterface(interfaceType) {
|
|
|
997
1190
|
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
998
1191
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
999
1192
|
properties: [],
|
|
1000
|
-
|
|
1001
|
-
propertiesV3: {}
|
|
1193
|
+
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName)))
|
|
1002
1194
|
};
|
|
1003
1195
|
}
|
|
1004
1196
|
|
|
@@ -1211,7 +1403,8 @@ function convertObjectPropertyType(property) {
|
|
|
1211
1403
|
type: property.array ? {
|
|
1212
1404
|
type: "array",
|
|
1213
1405
|
array: {
|
|
1214
|
-
subtype: propertyTypeTypeToOntologyIrType(property.type)
|
|
1406
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type),
|
|
1407
|
+
reducers: []
|
|
1215
1408
|
}
|
|
1216
1409
|
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1217
1410
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
@@ -1271,7 +1464,8 @@ function convertObject(objectType) {
|
|
|
1271
1464
|
},
|
|
1272
1465
|
datasources: [...propertyDatasources, ...derivedDatasources, objectDatasource],
|
|
1273
1466
|
entityMetadata: {
|
|
1274
|
-
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1467
|
+
arePatchesEnabled: objectType.editsEnabled ?? false,
|
|
1468
|
+
aliases: objectType.aliases ?? []
|
|
1275
1469
|
}
|
|
1276
1470
|
};
|
|
1277
1471
|
}
|
|
@@ -1304,7 +1498,8 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1304
1498
|
mediaSetView: {
|
|
1305
1499
|
assumedMarkings: [],
|
|
1306
1500
|
mediaSetViewLocator: identifier,
|
|
1307
|
-
properties: [property.apiName]
|
|
1501
|
+
properties: [property.apiName],
|
|
1502
|
+
uploadProperties: []
|
|
1308
1503
|
}
|
|
1309
1504
|
};
|
|
1310
1505
|
return [buildDatasource(property.apiName, mediaSetDefinition)];
|
|
@@ -2107,7 +2302,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2107
2302
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2108
2303
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2109
2304
|
async function main(args = process.argv) {
|
|
2110
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.
|
|
2305
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.7").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2111
2306
|
input: {
|
|
2112
2307
|
alias: "i",
|
|
2113
2308
|
describe: "Input file",
|
|
@@ -2285,29 +2480,39 @@ function defineAction(actionDef) {
|
|
|
2285
2480
|
return fullAction;
|
|
2286
2481
|
}
|
|
2287
2482
|
function isPropertyParameter(def, name, type) {
|
|
2288
|
-
|
|
2483
|
+
if ("interfaceType" in def) {
|
|
2484
|
+
return Object.keys(getFlattenedInterfaceProperties(def.interfaceType)).includes(name) && !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2485
|
+
}
|
|
2486
|
+
return Object.keys(def.objectType.properties ?? {}).includes(name) && !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2289
2487
|
}
|
|
2290
2488
|
function createParameters(def, propertyMap, parameterSet, requiredMap) {
|
|
2291
2489
|
const targetParams = getTargetParameters(def, parameterSet);
|
|
2292
|
-
return [...targetParams, ...Array.from(parameterSet).map((id) =>
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
} :
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2490
|
+
return [...targetParams, ...Array.from(parameterSet).map((id) => {
|
|
2491
|
+
let propertyMetadata = void 0;
|
|
2492
|
+
if (id in propertyMap) {
|
|
2493
|
+
propertyMetadata = "sharedPropertyType" in propertyMap[id] ? propertyMap[id].sharedPropertyType : propertyMap[id];
|
|
2494
|
+
}
|
|
2495
|
+
return {
|
|
2496
|
+
id,
|
|
2497
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? propertyMetadata?.displayName ?? uppercaseFirstLetter(id),
|
|
2498
|
+
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(propertyMetadata),
|
|
2499
|
+
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2500
|
+
...def.parameterConfiguration?.[id],
|
|
2501
|
+
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(propertyMetadata.type)),
|
|
2502
|
+
required: def.parameterConfiguration?.[id].required ?? propertyMetadata?.nullability?.noNulls ?? false
|
|
2503
|
+
} : {
|
|
2504
|
+
required: propertyMetadata.array ?? false ? {
|
|
2505
|
+
listLength: propertyMetadata.nullability?.noEmptyCollections ? {
|
|
2506
|
+
min: 1
|
|
2507
|
+
} : {}
|
|
2508
|
+
} : requiredMap?.[id] ?? propertyMetadata?.nullability?.noNulls ?? false,
|
|
2509
|
+
allowedValues: extractAllowedValuesFromPropertyType(propertyMetadata?.type)
|
|
2510
|
+
},
|
|
2511
|
+
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2512
|
+
description: def.parameterConfiguration?.[id]?.description,
|
|
2513
|
+
renderHint: def.parameterConfiguration?.[id]?.renderHint
|
|
2514
|
+
};
|
|
2515
|
+
})];
|
|
2311
2516
|
}
|
|
2312
2517
|
function getTargetParameters(def, parameterSet) {
|
|
2313
2518
|
const targetParams = [];
|
|
@@ -2861,7 +3066,7 @@ function validateActionParameters(def, properties, name) {
|
|
|
2861
3066
|
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant7__default.default(false) : void 0;
|
|
2862
3067
|
});
|
|
2863
3068
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2864
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id))) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant7__default.default(false) : void 0;
|
|
3069
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant7__default.default(false) : void 0;
|
|
2865
3070
|
});
|
|
2866
3071
|
}
|
|
2867
3072
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -2876,15 +3081,6 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2876
3081
|
function isTargetParameter(parameterId) {
|
|
2877
3082
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
2878
3083
|
}
|
|
2879
|
-
function addNamespaceToActionDefinition(def) {
|
|
2880
|
-
def.parameterConfiguration = Object.fromEntries(Object.entries(def.parameterConfiguration ?? {}).map(([id, config]) => [getInterfaceParameterName(def, id), config]));
|
|
2881
|
-
def.nonParameterMappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [addNamespaceIfNone(id), value]));
|
|
2882
|
-
def.excludedProperties = (def.excludedProperties ?? []).map((id) => addNamespaceIfNone(id));
|
|
2883
|
-
def.sections = def.sections?.map((section) => ({
|
|
2884
|
-
...section,
|
|
2885
|
-
parameters: section.parameters.map((p) => getInterfaceParameterName(def, p))
|
|
2886
|
-
}));
|
|
2887
|
-
}
|
|
2888
3084
|
function getInterfaceParameterName(def, parameter) {
|
|
2889
3085
|
if (def.useNonNamespacedParameters) {
|
|
2890
3086
|
return getNonNamespacedParameterName(def, parameter);
|
|
@@ -2894,6 +3090,41 @@ function getInterfaceParameterName(def, parameter) {
|
|
|
2894
3090
|
function getNonNamespacedParameterName(def, parameter) {
|
|
2895
3091
|
return def.conflictingParameterOverrides?.[parameter] ?? (parameter.split(".").pop() || parameter);
|
|
2896
3092
|
}
|
|
3093
|
+
function convertInterfacePropertyMappingValue(value) {
|
|
3094
|
+
switch (value.type) {
|
|
3095
|
+
case "uuid":
|
|
3096
|
+
return {
|
|
3097
|
+
type: "logicRuleValue",
|
|
3098
|
+
logicRuleValue: {
|
|
3099
|
+
type: "uniqueIdentifier",
|
|
3100
|
+
uniqueIdentifier: {
|
|
3101
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
case "currentTime":
|
|
3106
|
+
return {
|
|
3107
|
+
type: "logicRuleValue",
|
|
3108
|
+
logicRuleValue: {
|
|
3109
|
+
type: "currentTime",
|
|
3110
|
+
currentTime: {}
|
|
3111
|
+
}
|
|
3112
|
+
};
|
|
3113
|
+
case "currentUser":
|
|
3114
|
+
return {
|
|
3115
|
+
type: "logicRuleValue",
|
|
3116
|
+
logicRuleValue: {
|
|
3117
|
+
type: "currentUser",
|
|
3118
|
+
currentUser: {}
|
|
3119
|
+
}
|
|
3120
|
+
};
|
|
3121
|
+
default:
|
|
3122
|
+
return {
|
|
3123
|
+
type: "logicRuleValue",
|
|
3124
|
+
logicRuleValue: value
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
2897
3128
|
function convertMappingValue(value) {
|
|
2898
3129
|
switch (value.type) {
|
|
2899
3130
|
case "uuid":
|
|
@@ -2920,12 +3151,12 @@ function convertMappingValue(value) {
|
|
|
2920
3151
|
|
|
2921
3152
|
// src/api/defineCreateInterfaceObjectAction.ts
|
|
2922
3153
|
function defineCreateInterfaceObjectAction(def) {
|
|
2923
|
-
addNamespaceToActionDefinition(def);
|
|
2924
3154
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2925
3155
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2926
|
-
const
|
|
2927
|
-
const
|
|
2928
|
-
const
|
|
3156
|
+
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => isPropertyParameter(def, apiName, getInterfacePropertyTypeType(type)));
|
|
3157
|
+
const sptNames = actionInterfaceProperties.filter(([_apiName, type]) => isInterfaceSharedPropertyType(type)).map(([apiName]) => apiName);
|
|
3158
|
+
const parameterNames = new Set(actionInterfaceProperties.map(([apiName, _type]) => getInterfaceParameterName(def, apiName)));
|
|
3159
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop]));
|
|
2929
3160
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
2930
3161
|
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2931
3162
|
const actionApiName = def.apiName ?? `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
@@ -2935,8 +3166,17 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2935
3166
|
}
|
|
2936
3167
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2937
3168
|
}
|
|
2938
|
-
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2939
|
-
|
|
3169
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required ?? true])));
|
|
3170
|
+
let sptMappings = {};
|
|
3171
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => {
|
|
3172
|
+
if (sptNames.includes(id)) {
|
|
3173
|
+
sptMappings = {
|
|
3174
|
+
...sptMappings,
|
|
3175
|
+
[id]: convertMappingValue(value)
|
|
3176
|
+
};
|
|
3177
|
+
}
|
|
3178
|
+
return [id, convertInterfacePropertyMappingValue(value)];
|
|
3179
|
+
}));
|
|
2940
3180
|
return defineAction({
|
|
2941
3181
|
apiName: actionApiName,
|
|
2942
3182
|
displayName: def.displayName ?? `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -2958,6 +3198,16 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2958
3198
|
type: "parameterId",
|
|
2959
3199
|
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
2960
3200
|
}])),
|
|
3201
|
+
...sptMappings
|
|
3202
|
+
},
|
|
3203
|
+
interfacePropertyValues: {
|
|
3204
|
+
...Object.fromEntries(actionInterfaceProperties.map(([id, _type]) => [id, {
|
|
3205
|
+
type: "logicRuleValue",
|
|
3206
|
+
logicRuleValue: {
|
|
3207
|
+
type: "parameterId",
|
|
3208
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3209
|
+
}
|
|
3210
|
+
}])),
|
|
2961
3211
|
...mappings
|
|
2962
3212
|
}
|
|
2963
3213
|
}
|
|
@@ -3201,22 +3451,6 @@ function defineDeleteObjectAction(def) {
|
|
|
3201
3451
|
}
|
|
3202
3452
|
});
|
|
3203
3453
|
}
|
|
3204
|
-
function defineSharedPropertyType(sptDef) {
|
|
3205
|
-
const apiName = namespace + sptDef.apiName;
|
|
3206
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${apiName} already exists`) : invariant7__default.default(false) : void 0;
|
|
3207
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant7__default.default(false) : void 0;
|
|
3208
|
-
const fullSpt = {
|
|
3209
|
-
...sptDef,
|
|
3210
|
-
apiName,
|
|
3211
|
-
nonNameSpacedApiName: sptDef.apiName,
|
|
3212
|
-
displayName: sptDef.displayName ?? sptDef.apiName,
|
|
3213
|
-
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
3214
|
-
typeClasses: sptDef.typeClasses ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),
|
|
3215
|
-
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
3216
|
-
};
|
|
3217
|
-
updateOntology(fullSpt);
|
|
3218
|
-
return fullSpt;
|
|
3219
|
-
}
|
|
3220
3454
|
|
|
3221
3455
|
// src/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.ts
|
|
3222
3456
|
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
@@ -3254,19 +3488,33 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3254
3488
|
function defineInterface(interfaceDef) {
|
|
3255
3489
|
const apiName = namespace + interfaceDef.apiName;
|
|
3256
3490
|
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Interface ${apiName} already exists`) : invariant7__default.default(false) : void 0;
|
|
3257
|
-
const
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3491
|
+
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
3492
|
+
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
3493
|
+
}).map(([s, spt]) => {
|
|
3494
|
+
const required = isInterfaceSharedPropertyType(spt) ? spt.required : true;
|
|
3495
|
+
return [s, {
|
|
3496
|
+
sharedPropertyType: isInterfaceSharedPropertyType(spt) ? spt.sharedPropertyType : spt,
|
|
3497
|
+
required
|
|
3498
|
+
}];
|
|
3499
|
+
}));
|
|
3500
|
+
const propertiesV2 = Object.fromEntries(Object.entries(spts).map(([propName, type]) => {
|
|
3501
|
+
const sptApiName = combineApiNamespaceIfMissing(namespace, type.sharedPropertyType.apiName);
|
|
3502
|
+
return [sptApiName, {
|
|
3503
|
+
required: type.required,
|
|
3504
|
+
sharedPropertyType: verifyBasePropertyDefinition(namespace, propName, type.sharedPropertyType)
|
|
3505
|
+
}];
|
|
3506
|
+
}));
|
|
3507
|
+
const propertiesV3 = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([apiName2, prop]) => {
|
|
3508
|
+
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
3509
|
+
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
3510
|
+
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
3511
|
+
return [apiName2, {
|
|
3512
|
+
required,
|
|
3513
|
+
sharedPropertyType: propertyBase
|
|
3263
3514
|
}];
|
|
3515
|
+
} else {
|
|
3516
|
+
return [apiName2, propertyBase];
|
|
3264
3517
|
}
|
|
3265
|
-
const apiName2 = combineApiNamespaceIfMissing(namespace, typeof type === "object" && "apiName" in type ? type.apiName : unNamespacedPropApiName);
|
|
3266
|
-
return [apiName2, {
|
|
3267
|
-
required: true,
|
|
3268
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type)
|
|
3269
|
-
}];
|
|
3270
3518
|
}));
|
|
3271
3519
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
3272
3520
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
@@ -3289,31 +3537,22 @@ function defineInterface(interfaceDef) {
|
|
|
3289
3537
|
extendsInterfaces,
|
|
3290
3538
|
links: [],
|
|
3291
3539
|
status,
|
|
3292
|
-
propertiesV2
|
|
3540
|
+
propertiesV2,
|
|
3541
|
+
propertiesV3,
|
|
3293
3542
|
searchable: interfaceDef.searchable ?? true,
|
|
3294
3543
|
__type: OntologyEntityTypeEnum.INTERFACE_TYPE
|
|
3295
3544
|
};
|
|
3296
3545
|
updateOntology(fullInterface);
|
|
3297
3546
|
return fullInterface;
|
|
3298
3547
|
}
|
|
3299
|
-
function
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
});
|
|
3308
|
-
return spt;
|
|
3309
|
-
} else {
|
|
3310
|
-
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3311
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
3312
|
-
key: apiName,
|
|
3313
|
-
apiName: type.apiName
|
|
3314
|
-
})}`) : invariant7__default.default(false) : void 0;
|
|
3315
|
-
return type;
|
|
3316
|
-
}
|
|
3548
|
+
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
3549
|
+
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3550
|
+
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant7__default.default(false) : void 0;
|
|
3551
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
3552
|
+
key: apiName,
|
|
3553
|
+
apiName: type.apiName
|
|
3554
|
+
})}`) : invariant7__default.default(false) : void 0;
|
|
3555
|
+
return type;
|
|
3317
3556
|
}
|
|
3318
3557
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
3319
3558
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
@@ -3410,12 +3649,14 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
3410
3649
|
|
|
3411
3650
|
// src/api/defineModifyInterfaceObjectAction.ts
|
|
3412
3651
|
function defineModifyInterfaceObjectAction(def) {
|
|
3413
|
-
addNamespaceToActionDefinition(def);
|
|
3414
3652
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3415
3653
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3416
|
-
const
|
|
3417
|
-
|
|
3418
|
-
|
|
3654
|
+
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => {
|
|
3655
|
+
return isPropertyParameter(def, apiName, getInterfacePropertyTypeType(type));
|
|
3656
|
+
});
|
|
3657
|
+
const sptNames = actionInterfaceProperties.filter(([_apiName, type]) => isInterfaceSharedPropertyType(type)).map(([apiName]) => apiName);
|
|
3658
|
+
const parameterNames = new Set(actionInterfaceProperties.map(([apiName, _type]) => getInterfaceParameterName(def, apiName)));
|
|
3659
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop]));
|
|
3419
3660
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3420
3661
|
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3421
3662
|
const actionApiName = def.apiName ?? `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
@@ -3425,8 +3666,17 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3425
3666
|
}
|
|
3426
3667
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3427
3668
|
}
|
|
3428
|
-
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
3429
|
-
|
|
3669
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required ?? true])));
|
|
3670
|
+
let sptMappings = {};
|
|
3671
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => {
|
|
3672
|
+
if (sptNames.includes(id)) {
|
|
3673
|
+
sptMappings = {
|
|
3674
|
+
...sptMappings,
|
|
3675
|
+
[id]: convertMappingValue(value)
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
return [id, convertInterfacePropertyMappingValue(value)];
|
|
3679
|
+
}));
|
|
3430
3680
|
return defineAction({
|
|
3431
3681
|
apiName: actionApiName,
|
|
3432
3682
|
displayName: def.displayName ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -3441,12 +3691,23 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3441
3691
|
rules: [{
|
|
3442
3692
|
type: "modifyInterfaceRule",
|
|
3443
3693
|
modifyInterfaceRule: {
|
|
3694
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
3444
3695
|
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
3445
3696
|
sharedPropertyValues: {
|
|
3446
3697
|
...Object.fromEntries(sptNames.map((id) => [id, {
|
|
3447
3698
|
type: "parameterId",
|
|
3448
3699
|
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3449
3700
|
}])),
|
|
3701
|
+
...sptMappings
|
|
3702
|
+
},
|
|
3703
|
+
interfacePropertyValues: {
|
|
3704
|
+
...Object.fromEntries(actionInterfaceProperties.map(([id, _type]) => [id, {
|
|
3705
|
+
type: "logicRuleValue",
|
|
3706
|
+
logicRuleValue: {
|
|
3707
|
+
type: "parameterId",
|
|
3708
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3709
|
+
}
|
|
3710
|
+
}])),
|
|
3450
3711
|
...mappings
|
|
3451
3712
|
}
|
|
3452
3713
|
}
|
|
@@ -3556,6 +3817,22 @@ function defineModifyObjectAction(def) {
|
|
|
3556
3817
|
}
|
|
3557
3818
|
});
|
|
3558
3819
|
}
|
|
3820
|
+
function defineSharedPropertyType(sptDef) {
|
|
3821
|
+
const apiName = namespace + sptDef.apiName;
|
|
3822
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${apiName} already exists`) : invariant7__default.default(false) : void 0;
|
|
3823
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant7__default.default(false) : void 0;
|
|
3824
|
+
const fullSpt = {
|
|
3825
|
+
...sptDef,
|
|
3826
|
+
apiName,
|
|
3827
|
+
nonNameSpacedApiName: sptDef.apiName,
|
|
3828
|
+
displayName: sptDef.displayName ?? sptDef.apiName,
|
|
3829
|
+
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
3830
|
+
typeClasses: sptDef.typeClasses ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),
|
|
3831
|
+
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
3832
|
+
};
|
|
3833
|
+
updateOntology(fullSpt);
|
|
3834
|
+
return fullSpt;
|
|
3835
|
+
}
|
|
3559
3836
|
function convertValueTypeTypeToBaseType(valueType) {
|
|
3560
3837
|
switch (true) {
|
|
3561
3838
|
case (typeof valueType === "object" && valueType.type === "array"):
|