@osdk/maker 0.15.0-beta.6 → 0.15.0-beta.8
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 +22 -0
- package/README.md +26 -22
- 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/defineOntology.js +6 -0
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +17 -4
- package/build/browser/api/defineValueType.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/interface/mapSimplifiedStatusToInterfaceTypeStatus.js +5 -0
- package/build/browser/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.js.map +1 -1
- package/build/browser/api/links/LinkType.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/object/ObjectTypeStatus.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 +757 -492
- 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/api/test/valueTypes.test.js +69 -0
- package/build/browser/api/test/valueTypes.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/convertLink.js +30 -4
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- 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 +444 -117
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +53 -17
- 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/defineOntology.js +6 -0
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +17 -4
- package/build/esm/api/defineValueType.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/interface/mapSimplifiedStatusToInterfaceTypeStatus.js +5 -0
- package/build/esm/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.js.map +1 -1
- package/build/esm/api/links/LinkType.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/object/ObjectTypeStatus.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 +757 -492
- 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/api/test/valueTypes.test.js +69 -0
- package/build/esm/api/test/valueTypes.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/convertLink.js +30 -4
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- 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 +7 -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/defineOntology.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/defineValueType.d.ts +9 -0
- package/build/types/api/defineValueType.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/links/LinkType.d.ts +16 -4
- package/build/types/api/links/LinkType.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/object/ObjectTypeStatus.d.ts +1 -1
- package/build/types/api/object/ObjectTypeStatus.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/convertLink.d.ts +3 -2
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- 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 +3 -3
package/build/cjs/index.cjs
CHANGED
|
@@ -198,10 +198,7 @@ function convertLink(linkType) {
|
|
|
198
198
|
linkType: {
|
|
199
199
|
definition,
|
|
200
200
|
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
201
|
-
status: linkType.status
|
|
202
|
-
type: "active",
|
|
203
|
-
active: {}
|
|
204
|
-
},
|
|
201
|
+
status: convertLinkStatus(linkType.status),
|
|
205
202
|
redacted: linkType.redacted ?? false
|
|
206
203
|
},
|
|
207
204
|
datasources: datasource !== void 0 ? [datasource] : [],
|
|
@@ -255,14 +252,56 @@ function getObject(object) {
|
|
|
255
252
|
object: fullObject
|
|
256
253
|
};
|
|
257
254
|
}
|
|
255
|
+
function convertLinkStatus(status) {
|
|
256
|
+
if (typeof status === "object" && "type" in status && status.type === "deprecated") {
|
|
257
|
+
return {
|
|
258
|
+
type: "deprecated",
|
|
259
|
+
deprecated: {
|
|
260
|
+
message: status.message,
|
|
261
|
+
deadline: status.deadline
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
switch (status) {
|
|
266
|
+
case "experimental":
|
|
267
|
+
return {
|
|
268
|
+
type: "experimental",
|
|
269
|
+
experimental: {}
|
|
270
|
+
};
|
|
271
|
+
case "example":
|
|
272
|
+
return {
|
|
273
|
+
type: "example",
|
|
274
|
+
example: {}
|
|
275
|
+
};
|
|
276
|
+
case "active":
|
|
277
|
+
default:
|
|
278
|
+
return {
|
|
279
|
+
type: "active",
|
|
280
|
+
active: {}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// src/api/interface/InterfacePropertyType.ts
|
|
286
|
+
function isInterfaceSharedPropertyType(interfacePropertyType) {
|
|
287
|
+
return "sharedPropertyType" in interfacePropertyType;
|
|
288
|
+
}
|
|
289
|
+
function getInterfacePropertyTypeType(interfacePropertyType) {
|
|
290
|
+
return isInterfaceSharedPropertyType(interfacePropertyType) ? interfacePropertyType.sharedPropertyType.type : interfacePropertyType.type;
|
|
291
|
+
}
|
|
258
292
|
|
|
259
293
|
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
260
294
|
function getFlattenedInterfaceProperties(interfaceType) {
|
|
261
|
-
let properties = interfaceType.
|
|
295
|
+
let properties = Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([key, value]) => [isInterfaceSharedPropertyType(value) ? value.sharedPropertyType.apiName : key, value]));
|
|
296
|
+
Object.entries(interfaceType.propertiesV2).forEach(([apiName, spt]) => {
|
|
297
|
+
if (!(apiName in properties)) {
|
|
298
|
+
properties[apiName] = spt;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
262
301
|
interfaceType.extendsInterfaces.forEach((ext) => {
|
|
263
302
|
properties = {
|
|
264
|
-
...
|
|
265
|
-
...
|
|
303
|
+
...getFlattenedInterfaceProperties(ext),
|
|
304
|
+
...properties
|
|
266
305
|
};
|
|
267
306
|
});
|
|
268
307
|
return properties;
|
|
@@ -279,7 +318,7 @@ function isExotic(type) {
|
|
|
279
318
|
if (typeof type === "string") {
|
|
280
319
|
return ["geopoint", "geoshape", "mediaReference", "geotimeSeries"].includes(type);
|
|
281
320
|
} else if (typeof type === "object" && type != null) {
|
|
282
|
-
return type.type === "marking" || type.type === "struct";
|
|
321
|
+
return type.type === "marking" || type.type === "struct" || type.type === "string" || type.type === "decimal";
|
|
283
322
|
}
|
|
284
323
|
return false;
|
|
285
324
|
}
|
|
@@ -328,18 +367,19 @@ function defineObject(objectDef) {
|
|
|
328
367
|
!!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
368
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
330
369
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
331
|
-
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
370
|
+
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
332
371
|
type: "invalid",
|
|
333
372
|
reason: `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
|
|
334
373
|
}));
|
|
335
|
-
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map((mapping) => [
|
|
374
|
+
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map((mapping) => [mapping.interfaceProperty, mapping.mapsTo]));
|
|
336
375
|
const validateProperty = (interfaceProp) => {
|
|
337
|
-
|
|
338
|
-
|
|
376
|
+
const apiName2 = isInterfaceSharedPropertyType(interfaceProp[1]) ? interfaceProp[1].sharedPropertyType.apiName : interfaceProp[0];
|
|
377
|
+
if (apiName2 in interfaceToObjectProperties) {
|
|
378
|
+
return validateInterfaceImplProperty(interfaceProp[1], apiName2, interfaceToObjectProperties[interfaceProp[0]], objectDef);
|
|
339
379
|
}
|
|
340
380
|
return {
|
|
341
381
|
type: "invalid",
|
|
342
|
-
reason: `Interface
|
|
382
|
+
reason: `Interface spt ${apiName2} not implemented by ${objectDef.apiName} object definition`
|
|
343
383
|
};
|
|
344
384
|
};
|
|
345
385
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
@@ -361,7 +401,7 @@ function formatValidationErrors(error) {
|
|
|
361
401
|
return `Ontology Definition Error: ${error.reason}
|
|
362
402
|
`;
|
|
363
403
|
}
|
|
364
|
-
function validateInterfaceImplProperty(
|
|
404
|
+
function validateInterfaceImplProperty(type, apiName, mappedObjectProp, object) {
|
|
365
405
|
const objProp = object.properties?.[mappedObjectProp];
|
|
366
406
|
if (objProp === void 0) {
|
|
367
407
|
return {
|
|
@@ -369,10 +409,11 @@ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
|
|
|
369
409
|
reason: `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`
|
|
370
410
|
};
|
|
371
411
|
}
|
|
372
|
-
|
|
412
|
+
const propertyType = getInterfacePropertyTypeType(type);
|
|
413
|
+
if (JSON.stringify(propertyType) !== JSON.stringify(objProp?.type)) {
|
|
373
414
|
return {
|
|
374
415
|
type: "invalid",
|
|
375
|
-
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${
|
|
416
|
+
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${apiName}, objectProperty: ${mappedObjectProp}`
|
|
376
417
|
};
|
|
377
418
|
}
|
|
378
419
|
return {
|
|
@@ -719,7 +760,7 @@ function convertActionValidation(action) {
|
|
|
719
760
|
return [p.id, {
|
|
720
761
|
defaultValidation: {
|
|
721
762
|
display: {
|
|
722
|
-
renderHint: renderHintFromBaseType(p, p.validation),
|
|
763
|
+
renderHint: p.renderHint ?? renderHintFromBaseType(p, p.validation),
|
|
723
764
|
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
724
765
|
...p.defaultValue && {
|
|
725
766
|
prefill: p.defaultValue
|
|
@@ -839,6 +880,10 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
839
880
|
...fieldTypeDefinition,
|
|
840
881
|
apiName: key,
|
|
841
882
|
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition.fieldType),
|
|
883
|
+
displayMetadata: fieldTypeDefinition.displayMetadata ?? {
|
|
884
|
+
displayName: key,
|
|
885
|
+
description: void 0
|
|
886
|
+
},
|
|
842
887
|
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
843
888
|
aliases: fieldTypeDefinition.aliases ?? []
|
|
844
889
|
};
|
|
@@ -935,6 +980,7 @@ function convertSpt({
|
|
|
935
980
|
visibility,
|
|
936
981
|
gothamMapping,
|
|
937
982
|
typeClasses,
|
|
983
|
+
aliases,
|
|
938
984
|
valueType,
|
|
939
985
|
nullability,
|
|
940
986
|
baseFormatter
|
|
@@ -953,10 +999,11 @@ function convertSpt({
|
|
|
953
999
|
type: array ? {
|
|
954
1000
|
type: "array",
|
|
955
1001
|
array: {
|
|
956
|
-
subtype: propertyTypeTypeToOntologyIrType(type)
|
|
1002
|
+
subtype: propertyTypeTypeToOntologyIrType(type),
|
|
1003
|
+
reducers: []
|
|
957
1004
|
}
|
|
958
1005
|
} : propertyTypeTypeToOntologyIrType(type),
|
|
959
|
-
aliases: [],
|
|
1006
|
+
aliases: aliases ?? [],
|
|
960
1007
|
baseFormatter,
|
|
961
1008
|
dataConstraints: dataConstraint,
|
|
962
1009
|
gothamMapping,
|
|
@@ -971,6 +1018,178 @@ function convertSpt({
|
|
|
971
1018
|
};
|
|
972
1019
|
}
|
|
973
1020
|
|
|
1021
|
+
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.ts
|
|
1022
|
+
function propertyTypeTypeToOntologyIrInterfaceType(type) {
|
|
1023
|
+
switch (true) {
|
|
1024
|
+
case (typeof type === "object" && type.type === "marking"):
|
|
1025
|
+
return {
|
|
1026
|
+
"type": "marking",
|
|
1027
|
+
marking: {
|
|
1028
|
+
markingType: type.markingType
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
case (typeof type === "object" && type.type === "struct"):
|
|
1032
|
+
const structFields = new Array();
|
|
1033
|
+
for (const key in type.structDefinition) {
|
|
1034
|
+
const fieldTypeDefinition = type.structDefinition[key];
|
|
1035
|
+
let field;
|
|
1036
|
+
if (typeof fieldTypeDefinition === "string") {
|
|
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
|
+
} else {
|
|
1049
|
+
if (typeof fieldTypeDefinition === "object" && "fieldType" in fieldTypeDefinition) {
|
|
1050
|
+
field = {
|
|
1051
|
+
...fieldTypeDefinition,
|
|
1052
|
+
apiName: key,
|
|
1053
|
+
fieldType: propertyTypeTypeToOntologyIrInterfaceType(fieldTypeDefinition.fieldType),
|
|
1054
|
+
displayMetadata: fieldTypeDefinition.displayMetadata ?? {
|
|
1055
|
+
displayName: key,
|
|
1056
|
+
description: void 0
|
|
1057
|
+
},
|
|
1058
|
+
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
1059
|
+
aliases: fieldTypeDefinition.aliases ?? [],
|
|
1060
|
+
requireImplementation: fieldTypeDefinition.requireImplementation ?? true
|
|
1061
|
+
};
|
|
1062
|
+
} else {
|
|
1063
|
+
field = {
|
|
1064
|
+
apiName: key,
|
|
1065
|
+
displayMetadata: {
|
|
1066
|
+
displayName: key,
|
|
1067
|
+
description: void 0
|
|
1068
|
+
},
|
|
1069
|
+
typeClasses: [],
|
|
1070
|
+
aliases: [],
|
|
1071
|
+
fieldType: propertyTypeTypeToOntologyIrInterfaceType(fieldTypeDefinition),
|
|
1072
|
+
requireImplementation: true
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
structFields.push(field);
|
|
1077
|
+
}
|
|
1078
|
+
return {
|
|
1079
|
+
type: "struct",
|
|
1080
|
+
struct: {
|
|
1081
|
+
structFields
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
case (typeof type === "object" && type.type === "string"):
|
|
1085
|
+
return {
|
|
1086
|
+
"type": "string",
|
|
1087
|
+
"string": {
|
|
1088
|
+
analyzerOverride: void 0,
|
|
1089
|
+
enableAsciiFolding: type.enableAsciiFolding,
|
|
1090
|
+
isLongText: type.isLongText ?? false,
|
|
1091
|
+
supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard ?? false,
|
|
1092
|
+
supportsExactMatching: type.supportsExactMatching ?? true,
|
|
1093
|
+
supportsFullTextRegex: type.supportsFullTextRegex
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
case (typeof type === "object" && type.type === "decimal"):
|
|
1097
|
+
return {
|
|
1098
|
+
"type": "decimal",
|
|
1099
|
+
"decimal": {
|
|
1100
|
+
precision: type.precision,
|
|
1101
|
+
scale: type.scale
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
case type === "geopoint":
|
|
1105
|
+
return {
|
|
1106
|
+
type: "geohash",
|
|
1107
|
+
geohash: {}
|
|
1108
|
+
};
|
|
1109
|
+
case type === "decimal":
|
|
1110
|
+
return {
|
|
1111
|
+
type,
|
|
1112
|
+
[type]: {
|
|
1113
|
+
precision: void 0,
|
|
1114
|
+
scale: void 0
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
case type === "string":
|
|
1118
|
+
return {
|
|
1119
|
+
type,
|
|
1120
|
+
[type]: {
|
|
1121
|
+
analyzerOverride: void 0,
|
|
1122
|
+
enableAsciiFolding: void 0,
|
|
1123
|
+
isLongText: false,
|
|
1124
|
+
supportsEfficientLeadingWildcard: false,
|
|
1125
|
+
supportsExactMatching: true
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
case type === "mediaReference":
|
|
1129
|
+
return {
|
|
1130
|
+
type,
|
|
1131
|
+
mediaReference: {}
|
|
1132
|
+
};
|
|
1133
|
+
case type === "geotimeSeries":
|
|
1134
|
+
return {
|
|
1135
|
+
type: "geotimeSeriesReference",
|
|
1136
|
+
geotimeSeriesReference: {}
|
|
1137
|
+
};
|
|
1138
|
+
default:
|
|
1139
|
+
if (typeof type === "object") {
|
|
1140
|
+
throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);
|
|
1141
|
+
}
|
|
1142
|
+
return distributeTypeHelper(type);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// src/conversion/toMarketplace/convertInterfacePropertyType.ts
|
|
1147
|
+
function convertInterfaceProperty(prop, apiName) {
|
|
1148
|
+
if (isInterfaceSharedPropertyType(prop)) {
|
|
1149
|
+
return [prop.sharedPropertyType.apiName, {
|
|
1150
|
+
type: "sharedPropertyBasedPropertyType",
|
|
1151
|
+
sharedPropertyBasedPropertyType: {
|
|
1152
|
+
requireImplementation: prop.required,
|
|
1153
|
+
sharedPropertyType: convertSpt(prop.sharedPropertyType)
|
|
1154
|
+
}
|
|
1155
|
+
}];
|
|
1156
|
+
} else {
|
|
1157
|
+
return [apiName, {
|
|
1158
|
+
type: "interfaceDefinedPropertyType",
|
|
1159
|
+
interfaceDefinedPropertyType: {
|
|
1160
|
+
apiName,
|
|
1161
|
+
displayMetadata: {
|
|
1162
|
+
displayName: prop.displayName ?? apiName,
|
|
1163
|
+
visibility: prop.visibility ?? "NORMAL",
|
|
1164
|
+
description: prop.description
|
|
1165
|
+
},
|
|
1166
|
+
type: prop.array ? {
|
|
1167
|
+
type: "array",
|
|
1168
|
+
array: {
|
|
1169
|
+
subtype: propertyTypeTypeToOntologyIrInterfaceType(prop.type)
|
|
1170
|
+
}
|
|
1171
|
+
} : propertyTypeTypeToOntologyIrInterfaceType(prop.type),
|
|
1172
|
+
constraints: {
|
|
1173
|
+
primaryKeyConstraint: prop.primaryKeyConstraint ?? "NO_RESTRICTION",
|
|
1174
|
+
requireImplementation: prop.required ?? true,
|
|
1175
|
+
indexedForSearch: true,
|
|
1176
|
+
typeClasses: prop.typeClasses ?? [],
|
|
1177
|
+
dataConstraints: convertNullabilityToDataConstraint({
|
|
1178
|
+
type: prop.type,
|
|
1179
|
+
nullability: prop.nullability
|
|
1180
|
+
}),
|
|
1181
|
+
valueType: prop.valueType ? {
|
|
1182
|
+
apiName: prop.valueType.apiName,
|
|
1183
|
+
version: prop.valueType.version,
|
|
1184
|
+
packageNamespace: prop.valueType.packageNamespace,
|
|
1185
|
+
displayMetadata: prop.valueType.displayMetadata
|
|
1186
|
+
} : void 0
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}];
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
974
1193
|
// src/conversion/toMarketplace/convertInterface.ts
|
|
975
1194
|
function convertInterface(interfaceType) {
|
|
976
1195
|
const {
|
|
@@ -997,8 +1216,7 @@ function convertInterface(interfaceType) {
|
|
|
997
1216
|
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
998
1217
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
999
1218
|
properties: [],
|
|
1000
|
-
|
|
1001
|
-
propertiesV3: {}
|
|
1219
|
+
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName)))
|
|
1002
1220
|
};
|
|
1003
1221
|
}
|
|
1004
1222
|
|
|
@@ -1211,7 +1429,8 @@ function convertObjectPropertyType(property) {
|
|
|
1211
1429
|
type: property.array ? {
|
|
1212
1430
|
type: "array",
|
|
1213
1431
|
array: {
|
|
1214
|
-
subtype: propertyTypeTypeToOntologyIrType(property.type)
|
|
1432
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type),
|
|
1433
|
+
reducers: []
|
|
1215
1434
|
}
|
|
1216
1435
|
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1217
1436
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
@@ -1271,7 +1490,8 @@ function convertObject(objectType) {
|
|
|
1271
1490
|
},
|
|
1272
1491
|
datasources: [...propertyDatasources, ...derivedDatasources, objectDatasource],
|
|
1273
1492
|
entityMetadata: {
|
|
1274
|
-
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1493
|
+
arePatchesEnabled: objectType.editsEnabled ?? false,
|
|
1494
|
+
aliases: objectType.aliases ?? []
|
|
1275
1495
|
}
|
|
1276
1496
|
};
|
|
1277
1497
|
}
|
|
@@ -1304,7 +1524,8 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1304
1524
|
mediaSetView: {
|
|
1305
1525
|
assumedMarkings: [],
|
|
1306
1526
|
mediaSetViewLocator: identifier,
|
|
1307
|
-
properties: [property.apiName]
|
|
1527
|
+
properties: [property.apiName],
|
|
1528
|
+
uploadProperties: []
|
|
1308
1529
|
}
|
|
1309
1530
|
};
|
|
1310
1531
|
return [buildDatasource(property.apiName, mediaSetDefinition)];
|
|
@@ -1752,6 +1973,12 @@ function convertObjectStatus(status) {
|
|
|
1752
1973
|
experimental: {}
|
|
1753
1974
|
};
|
|
1754
1975
|
}
|
|
1976
|
+
if (status === "example") {
|
|
1977
|
+
return {
|
|
1978
|
+
type: "example",
|
|
1979
|
+
example: {}
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1755
1982
|
if (typeof status === "object" && status.type === "deprecated") {
|
|
1756
1983
|
return {
|
|
1757
1984
|
type: "deprecated",
|
|
@@ -2107,7 +2334,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2107
2334
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2108
2335
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2109
2336
|
async function main(args = process.argv) {
|
|
2110
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.
|
|
2337
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.8").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2111
2338
|
input: {
|
|
2112
2339
|
alias: "i",
|
|
2113
2340
|
describe: "Input file",
|
|
@@ -2285,29 +2512,39 @@ function defineAction(actionDef) {
|
|
|
2285
2512
|
return fullAction;
|
|
2286
2513
|
}
|
|
2287
2514
|
function isPropertyParameter(def, name, type) {
|
|
2288
|
-
|
|
2515
|
+
if ("interfaceType" in def) {
|
|
2516
|
+
return Object.keys(getFlattenedInterfaceProperties(def.interfaceType)).includes(name) && !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2517
|
+
}
|
|
2518
|
+
return Object.keys(def.objectType.properties ?? {}).includes(name) && !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2289
2519
|
}
|
|
2290
2520
|
function createParameters(def, propertyMap, parameterSet, requiredMap) {
|
|
2291
2521
|
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
|
-
|
|
2522
|
+
return [...targetParams, ...Array.from(parameterSet).map((id) => {
|
|
2523
|
+
let propertyMetadata = void 0;
|
|
2524
|
+
if (id in propertyMap) {
|
|
2525
|
+
propertyMetadata = "sharedPropertyType" in propertyMap[id] ? propertyMap[id].sharedPropertyType : propertyMap[id];
|
|
2526
|
+
}
|
|
2527
|
+
return {
|
|
2528
|
+
id,
|
|
2529
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? propertyMetadata?.displayName ?? uppercaseFirstLetter(id),
|
|
2530
|
+
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(propertyMetadata),
|
|
2531
|
+
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2532
|
+
...def.parameterConfiguration?.[id],
|
|
2533
|
+
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(propertyMetadata.type)),
|
|
2534
|
+
required: def.parameterConfiguration?.[id].required ?? propertyMetadata?.nullability?.noNulls ?? false
|
|
2535
|
+
} : {
|
|
2536
|
+
required: propertyMetadata.array ?? false ? {
|
|
2537
|
+
listLength: propertyMetadata.nullability?.noEmptyCollections ? {
|
|
2538
|
+
min: 1
|
|
2539
|
+
} : {}
|
|
2540
|
+
} : requiredMap?.[id] ?? propertyMetadata?.nullability?.noNulls ?? false,
|
|
2541
|
+
allowedValues: extractAllowedValuesFromPropertyType(propertyMetadata?.type)
|
|
2542
|
+
},
|
|
2543
|
+
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2544
|
+
description: def.parameterConfiguration?.[id]?.description,
|
|
2545
|
+
renderHint: def.parameterConfiguration?.[id]?.renderHint
|
|
2546
|
+
};
|
|
2547
|
+
})];
|
|
2311
2548
|
}
|
|
2312
2549
|
function getTargetParameters(def, parameterSet) {
|
|
2313
2550
|
const targetParams = [];
|
|
@@ -2861,7 +3098,7 @@ function validateActionParameters(def, properties, name) {
|
|
|
2861
3098
|
!(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
3099
|
});
|
|
2863
3100
|
[...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;
|
|
3101
|
+
!(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
3102
|
});
|
|
2866
3103
|
}
|
|
2867
3104
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -2876,15 +3113,6 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2876
3113
|
function isTargetParameter(parameterId) {
|
|
2877
3114
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
2878
3115
|
}
|
|
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
3116
|
function getInterfaceParameterName(def, parameter) {
|
|
2889
3117
|
if (def.useNonNamespacedParameters) {
|
|
2890
3118
|
return getNonNamespacedParameterName(def, parameter);
|
|
@@ -2894,6 +3122,41 @@ function getInterfaceParameterName(def, parameter) {
|
|
|
2894
3122
|
function getNonNamespacedParameterName(def, parameter) {
|
|
2895
3123
|
return def.conflictingParameterOverrides?.[parameter] ?? (parameter.split(".").pop() || parameter);
|
|
2896
3124
|
}
|
|
3125
|
+
function convertInterfacePropertyMappingValue(value) {
|
|
3126
|
+
switch (value.type) {
|
|
3127
|
+
case "uuid":
|
|
3128
|
+
return {
|
|
3129
|
+
type: "logicRuleValue",
|
|
3130
|
+
logicRuleValue: {
|
|
3131
|
+
type: "uniqueIdentifier",
|
|
3132
|
+
uniqueIdentifier: {
|
|
3133
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
};
|
|
3137
|
+
case "currentTime":
|
|
3138
|
+
return {
|
|
3139
|
+
type: "logicRuleValue",
|
|
3140
|
+
logicRuleValue: {
|
|
3141
|
+
type: "currentTime",
|
|
3142
|
+
currentTime: {}
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
case "currentUser":
|
|
3146
|
+
return {
|
|
3147
|
+
type: "logicRuleValue",
|
|
3148
|
+
logicRuleValue: {
|
|
3149
|
+
type: "currentUser",
|
|
3150
|
+
currentUser: {}
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
default:
|
|
3154
|
+
return {
|
|
3155
|
+
type: "logicRuleValue",
|
|
3156
|
+
logicRuleValue: value
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
2897
3160
|
function convertMappingValue(value) {
|
|
2898
3161
|
switch (value.type) {
|
|
2899
3162
|
case "uuid":
|
|
@@ -2920,12 +3183,12 @@ function convertMappingValue(value) {
|
|
|
2920
3183
|
|
|
2921
3184
|
// src/api/defineCreateInterfaceObjectAction.ts
|
|
2922
3185
|
function defineCreateInterfaceObjectAction(def) {
|
|
2923
|
-
addNamespaceToActionDefinition(def);
|
|
2924
3186
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2925
3187
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2926
|
-
const
|
|
2927
|
-
const
|
|
2928
|
-
const
|
|
3188
|
+
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => isPropertyParameter(def, apiName, getInterfacePropertyTypeType(type)));
|
|
3189
|
+
const sptNames = actionInterfaceProperties.filter(([_apiName, type]) => isInterfaceSharedPropertyType(type)).map(([apiName]) => apiName);
|
|
3190
|
+
const parameterNames = new Set(actionInterfaceProperties.map(([apiName, _type]) => getInterfaceParameterName(def, apiName)));
|
|
3191
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop]));
|
|
2929
3192
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
2930
3193
|
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2931
3194
|
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 +3198,17 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2935
3198
|
}
|
|
2936
3199
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2937
3200
|
}
|
|
2938
|
-
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2939
|
-
|
|
3201
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required ?? true])));
|
|
3202
|
+
let sptMappings = {};
|
|
3203
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => {
|
|
3204
|
+
if (sptNames.includes(id)) {
|
|
3205
|
+
sptMappings = {
|
|
3206
|
+
...sptMappings,
|
|
3207
|
+
[id]: convertMappingValue(value)
|
|
3208
|
+
};
|
|
3209
|
+
}
|
|
3210
|
+
return [id, convertInterfacePropertyMappingValue(value)];
|
|
3211
|
+
}));
|
|
2940
3212
|
return defineAction({
|
|
2941
3213
|
apiName: actionApiName,
|
|
2942
3214
|
displayName: def.displayName ?? `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -2958,6 +3230,16 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2958
3230
|
type: "parameterId",
|
|
2959
3231
|
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
2960
3232
|
}])),
|
|
3233
|
+
...sptMappings
|
|
3234
|
+
},
|
|
3235
|
+
interfacePropertyValues: {
|
|
3236
|
+
...Object.fromEntries(actionInterfaceProperties.map(([id, _type]) => [id, {
|
|
3237
|
+
type: "logicRuleValue",
|
|
3238
|
+
logicRuleValue: {
|
|
3239
|
+
type: "parameterId",
|
|
3240
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3241
|
+
}
|
|
3242
|
+
}])),
|
|
2961
3243
|
...mappings
|
|
2962
3244
|
}
|
|
2963
3245
|
}
|
|
@@ -3201,22 +3483,6 @@ function defineDeleteObjectAction(def) {
|
|
|
3201
3483
|
}
|
|
3202
3484
|
});
|
|
3203
3485
|
}
|
|
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
3486
|
|
|
3221
3487
|
// src/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.ts
|
|
3222
3488
|
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
@@ -3240,6 +3506,11 @@ function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
|
3240
3506
|
type: "experimental",
|
|
3241
3507
|
experimental: {}
|
|
3242
3508
|
};
|
|
3509
|
+
case "example":
|
|
3510
|
+
return {
|
|
3511
|
+
type: "example",
|
|
3512
|
+
example: {}
|
|
3513
|
+
};
|
|
3243
3514
|
default:
|
|
3244
3515
|
throw new Error(`Invalid status type: ${status.type}`);
|
|
3245
3516
|
}
|
|
@@ -3254,19 +3525,33 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3254
3525
|
function defineInterface(interfaceDef) {
|
|
3255
3526
|
const apiName = namespace + interfaceDef.apiName;
|
|
3256
3527
|
!(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
|
-
|
|
3528
|
+
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
3529
|
+
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
3530
|
+
}).map(([s, spt]) => {
|
|
3531
|
+
const required = isInterfaceSharedPropertyType(spt) ? spt.required : true;
|
|
3532
|
+
return [s, {
|
|
3533
|
+
sharedPropertyType: isInterfaceSharedPropertyType(spt) ? spt.sharedPropertyType : spt,
|
|
3534
|
+
required
|
|
3535
|
+
}];
|
|
3536
|
+
}));
|
|
3537
|
+
const propertiesV2 = Object.fromEntries(Object.entries(spts).map(([propName, type]) => {
|
|
3538
|
+
const sptApiName = combineApiNamespaceIfMissing(namespace, type.sharedPropertyType.apiName);
|
|
3539
|
+
return [sptApiName, {
|
|
3540
|
+
required: type.required,
|
|
3541
|
+
sharedPropertyType: verifyBasePropertyDefinition(namespace, propName, type.sharedPropertyType)
|
|
3542
|
+
}];
|
|
3543
|
+
}));
|
|
3544
|
+
const propertiesV3 = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([apiName2, prop]) => {
|
|
3545
|
+
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
3546
|
+
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
3547
|
+
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
3548
|
+
return [apiName2, {
|
|
3549
|
+
required,
|
|
3550
|
+
sharedPropertyType: propertyBase
|
|
3263
3551
|
}];
|
|
3552
|
+
} else {
|
|
3553
|
+
return [apiName2, propertyBase];
|
|
3264
3554
|
}
|
|
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
3555
|
}));
|
|
3271
3556
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
3272
3557
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
@@ -3289,31 +3574,22 @@ function defineInterface(interfaceDef) {
|
|
|
3289
3574
|
extendsInterfaces,
|
|
3290
3575
|
links: [],
|
|
3291
3576
|
status,
|
|
3292
|
-
propertiesV2
|
|
3577
|
+
propertiesV2,
|
|
3578
|
+
propertiesV3,
|
|
3293
3579
|
searchable: interfaceDef.searchable ?? true,
|
|
3294
3580
|
__type: OntologyEntityTypeEnum.INTERFACE_TYPE
|
|
3295
3581
|
};
|
|
3296
3582
|
updateOntology(fullInterface);
|
|
3297
3583
|
return fullInterface;
|
|
3298
3584
|
}
|
|
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
|
-
}
|
|
3585
|
+
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
3586
|
+
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3587
|
+
!(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;
|
|
3588
|
+
!(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({
|
|
3589
|
+
key: apiName,
|
|
3590
|
+
apiName: type.apiName
|
|
3591
|
+
})}`) : invariant7__default.default(false) : void 0;
|
|
3592
|
+
return type;
|
|
3317
3593
|
}
|
|
3318
3594
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
3319
3595
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
@@ -3410,12 +3686,14 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
3410
3686
|
|
|
3411
3687
|
// src/api/defineModifyInterfaceObjectAction.ts
|
|
3412
3688
|
function defineModifyInterfaceObjectAction(def) {
|
|
3413
|
-
addNamespaceToActionDefinition(def);
|
|
3414
3689
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3415
3690
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3416
|
-
const
|
|
3417
|
-
|
|
3418
|
-
|
|
3691
|
+
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => {
|
|
3692
|
+
return isPropertyParameter(def, apiName, getInterfacePropertyTypeType(type));
|
|
3693
|
+
});
|
|
3694
|
+
const sptNames = actionInterfaceProperties.filter(([_apiName, type]) => isInterfaceSharedPropertyType(type)).map(([apiName]) => apiName);
|
|
3695
|
+
const parameterNames = new Set(actionInterfaceProperties.map(([apiName, _type]) => getInterfaceParameterName(def, apiName)));
|
|
3696
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop]));
|
|
3419
3697
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3420
3698
|
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3421
3699
|
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 +3703,17 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3425
3703
|
}
|
|
3426
3704
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3427
3705
|
}
|
|
3428
|
-
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
3429
|
-
|
|
3706
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required ?? true])));
|
|
3707
|
+
let sptMappings = {};
|
|
3708
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => {
|
|
3709
|
+
if (sptNames.includes(id)) {
|
|
3710
|
+
sptMappings = {
|
|
3711
|
+
...sptMappings,
|
|
3712
|
+
[id]: convertMappingValue(value)
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3715
|
+
return [id, convertInterfacePropertyMappingValue(value)];
|
|
3716
|
+
}));
|
|
3430
3717
|
return defineAction({
|
|
3431
3718
|
apiName: actionApiName,
|
|
3432
3719
|
displayName: def.displayName ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -3441,12 +3728,23 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3441
3728
|
rules: [{
|
|
3442
3729
|
type: "modifyInterfaceRule",
|
|
3443
3730
|
modifyInterfaceRule: {
|
|
3731
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
3444
3732
|
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
3445
3733
|
sharedPropertyValues: {
|
|
3446
3734
|
...Object.fromEntries(sptNames.map((id) => [id, {
|
|
3447
3735
|
type: "parameterId",
|
|
3448
3736
|
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3449
3737
|
}])),
|
|
3738
|
+
...sptMappings
|
|
3739
|
+
},
|
|
3740
|
+
interfacePropertyValues: {
|
|
3741
|
+
...Object.fromEntries(actionInterfaceProperties.map(([id, _type]) => [id, {
|
|
3742
|
+
type: "logicRuleValue",
|
|
3743
|
+
logicRuleValue: {
|
|
3744
|
+
type: "parameterId",
|
|
3745
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3746
|
+
}
|
|
3747
|
+
}])),
|
|
3450
3748
|
...mappings
|
|
3451
3749
|
}
|
|
3452
3750
|
}
|
|
@@ -3556,6 +3854,22 @@ function defineModifyObjectAction(def) {
|
|
|
3556
3854
|
}
|
|
3557
3855
|
});
|
|
3558
3856
|
}
|
|
3857
|
+
function defineSharedPropertyType(sptDef) {
|
|
3858
|
+
const apiName = namespace + sptDef.apiName;
|
|
3859
|
+
!(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;
|
|
3860
|
+
!(!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;
|
|
3861
|
+
const fullSpt = {
|
|
3862
|
+
...sptDef,
|
|
3863
|
+
apiName,
|
|
3864
|
+
nonNameSpacedApiName: sptDef.apiName,
|
|
3865
|
+
displayName: sptDef.displayName ?? sptDef.apiName,
|
|
3866
|
+
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
3867
|
+
typeClasses: sptDef.typeClasses ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),
|
|
3868
|
+
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
3869
|
+
};
|
|
3870
|
+
updateOntology(fullSpt);
|
|
3871
|
+
return fullSpt;
|
|
3872
|
+
}
|
|
3559
3873
|
function convertValueTypeTypeToBaseType(valueType) {
|
|
3560
3874
|
switch (true) {
|
|
3561
3875
|
case (typeof valueType === "object" && valueType.type === "array"):
|
|
@@ -3630,10 +3944,7 @@ function defineValueType(valueTypeDef) {
|
|
|
3630
3944
|
displayName,
|
|
3631
3945
|
description: description ?? ""
|
|
3632
3946
|
},
|
|
3633
|
-
status:
|
|
3634
|
-
type: "active",
|
|
3635
|
-
active: {}
|
|
3636
|
-
},
|
|
3947
|
+
status: convertUserValueTypeStatusToValueTypeStatus(valueTypeDef.status),
|
|
3637
3948
|
version,
|
|
3638
3949
|
baseType,
|
|
3639
3950
|
constraints,
|
|
@@ -3643,6 +3954,22 @@ function defineValueType(valueTypeDef) {
|
|
|
3643
3954
|
updateOntology(vt);
|
|
3644
3955
|
return vt;
|
|
3645
3956
|
}
|
|
3957
|
+
function convertUserValueTypeStatusToValueTypeStatus(status) {
|
|
3958
|
+
if (typeof status === "object" && status.type === "deprecated") {
|
|
3959
|
+
return {
|
|
3960
|
+
type: "deprecated",
|
|
3961
|
+
deprecated: {
|
|
3962
|
+
message: status.message,
|
|
3963
|
+
deadline: status.deadline,
|
|
3964
|
+
replacedBy: status.replacedBy
|
|
3965
|
+
}
|
|
3966
|
+
};
|
|
3967
|
+
}
|
|
3968
|
+
return {
|
|
3969
|
+
type: "active",
|
|
3970
|
+
active: {}
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3646
3973
|
|
|
3647
3974
|
// src/api/importOntologyEntity.ts
|
|
3648
3975
|
function importOntologyEntity(e) {
|