@osdk/maker 0.16.0-beta.1 → 0.16.0-beta.3
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 +23 -0
- package/README.md +14 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/browser/api/defineObject.js +26 -9
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/object/ObjectPropertyType.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/properties/ReducerType.js +2 -0
- package/build/browser/api/properties/ReducerType.js.map +1 -0
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
- package/build/browser/api/test/actions.test.js +5 -0
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/objectStatus.test.js +93 -1
- package/build/browser/api/test/objectStatus.test.js.map +1 -1
- package/build/browser/api/test/objects.test.js +576 -0
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +62 -61
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/browser/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/browser/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/cjs/index.cjs +152 -84
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +13 -1
- package/build/esm/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/esm/api/defineObject.js +26 -9
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/object/ObjectPropertyType.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/properties/ReducerType.js +2 -0
- package/build/esm/api/properties/ReducerType.js.map +1 -0
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
- package/build/esm/api/test/actions.test.js +5 -0
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/objectStatus.test.js +93 -1
- package/build/esm/api/test/objectStatus.test.js.map +1 -1
- package/build/esm/api/test/objects.test.js +576 -0
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +62 -61
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/esm/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/esm/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +2 -0
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/object/ObjectPropertyType.d.ts +2 -0
- package/build/types/api/object/ObjectPropertyType.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +4 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/properties/ReducerType.d.ts +4 -0
- package/build/types/api/properties/ReducerType.d.ts.map +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts +2 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertReducers.d.ts +6 -0
- package/build/types/conversion/toMarketplace/convertReducers.d.ts.map +1 -0
- 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/propertyTypeTypeToOntologyIrType.d.ts +2 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts.map +1 -1
- package/package.json +5 -5
package/build/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var consola = require('consola');
|
|
6
6
|
var fs3 = require('fs/promises');
|
|
7
7
|
var path3 = require('path');
|
|
8
|
-
var
|
|
8
|
+
var invariant9 = require('tiny-invariant');
|
|
9
9
|
var yargs = require('yargs');
|
|
10
10
|
var helpers = require('yargs/helpers');
|
|
11
11
|
var fs2 = require('fs');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
|
|
36
36
|
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
37
37
|
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
38
|
-
var
|
|
38
|
+
var invariant9__default = /*#__PURE__*/_interopDefault(invariant9);
|
|
39
39
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
40
40
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
41
41
|
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
@@ -217,10 +217,10 @@ function validateLink(linkDefinition) {
|
|
|
217
217
|
object: toManyObject
|
|
218
218
|
} = getObject(linkDefinition.toMany.object);
|
|
219
219
|
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
220
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
221
|
-
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
220
|
+
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`) : invariant9__default.default(false) : void 0;
|
|
221
|
+
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant9__default.default(false) : void 0;
|
|
222
222
|
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
223
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
223
|
+
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant9__default.default(false) : void 0;
|
|
224
224
|
}
|
|
225
225
|
if ("intermediaryObjectType" in linkDefinition) {
|
|
226
226
|
const {
|
|
@@ -235,18 +235,18 @@ function validateLink(linkDefinition) {
|
|
|
235
235
|
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
236
236
|
const {
|
|
237
237
|
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
238
|
-
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
238
|
+
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`) : invariant9__default.default(false) : void 0;
|
|
239
239
|
const {
|
|
240
240
|
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
241
241
|
const {
|
|
242
242
|
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
243
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
243
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`) : invariant9__default.default(false) : void 0;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
function getObject(object) {
|
|
247
247
|
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
248
248
|
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
249
|
-
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
249
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object ${objectApiName} is not defined`) : invariant9__default.default(false) : void 0;
|
|
250
250
|
return {
|
|
251
251
|
apiName: objectApiName,
|
|
252
252
|
object: fullObject
|
|
@@ -336,35 +336,40 @@ function defineObject(objectDef) {
|
|
|
336
336
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
337
337
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
338
338
|
}
|
|
339
|
-
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
340
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
341
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
342
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
339
|
+
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant9__default.default(false) : void 0;
|
|
340
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant9__default.default(false) : void 0;
|
|
341
|
+
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant9__default.default(false) : void 0;
|
|
342
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant9__default.default(false) : void 0;
|
|
343
343
|
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
344
344
|
retentionPeriods.forEach((retentionPeriod) => {
|
|
345
|
-
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ?
|
|
345
|
+
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant9__default.default(false) : void 0;
|
|
346
346
|
});
|
|
347
347
|
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
348
|
-
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ?
|
|
348
|
+
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object ${objectDef.apiName} has more than one base datasource (got: [${baseDatasources.map((ds) => ds.type).join(", ")}])`) : invariant9__default.default(false) : void 0;
|
|
349
349
|
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
350
350
|
if (derivedDatasources.length > 0) {
|
|
351
351
|
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
const objectStatusType = getStatusType(objectDef.status);
|
|
354
|
+
if (objectStatusType === "experimental" || objectStatusType === "deprecated" || objectStatusType === "example") {
|
|
355
|
+
const mismatchedProperties = [];
|
|
355
356
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
356
|
-
if (property.status
|
|
357
|
-
|
|
357
|
+
if (property.status !== void 0) {
|
|
358
|
+
const propertyStatusType = getStatusType(property.status);
|
|
359
|
+
if (propertyStatusType !== objectStatusType) {
|
|
360
|
+
mismatchedProperties.push(apiName2);
|
|
361
|
+
}
|
|
358
362
|
}
|
|
359
363
|
});
|
|
360
|
-
!(
|
|
364
|
+
!(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object "${objectDef.apiName}" has "${objectStatusType}" status, but the following properties have a different status: ${mismatchedProperties.join(", ")}`) : invariant9__default.default(false) : void 0;
|
|
361
365
|
}
|
|
362
366
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
363
367
|
const deadline = objectDef.status.deadline;
|
|
364
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
368
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant9__default.default(false) : void 0;
|
|
365
369
|
}
|
|
366
|
-
|
|
367
|
-
|
|
370
|
+
const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
|
|
371
|
+
!(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant9__default.default(false) : void 0;
|
|
372
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant9__default.default(false) : void 0;
|
|
368
373
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
369
374
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
370
375
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -384,7 +389,7 @@ function defineObject(objectDef) {
|
|
|
384
389
|
};
|
|
385
390
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
386
391
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
387
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
392
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant9__default.default(false) : void 0;
|
|
388
393
|
});
|
|
389
394
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
390
395
|
const finalObject = {
|
|
@@ -436,13 +441,13 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
436
441
|
};
|
|
437
442
|
}
|
|
438
443
|
function validateDerivedDatasource(objectDef, datasource) {
|
|
439
|
-
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
444
|
+
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Derived datasource for object '${objectDef.apiName}' must have at least one link.`) : invariant9__default.default(false) : void 0;
|
|
440
445
|
datasource.linkDefinition.forEach((link) => {
|
|
441
446
|
const linkApiName = link.linkType.apiName;
|
|
442
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
447
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant9__default.default(false) : void 0;
|
|
443
448
|
});
|
|
444
449
|
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
445
|
-
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
450
|
+
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant9__default.default(false) : void 0;
|
|
446
451
|
});
|
|
447
452
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
448
453
|
if (isLinkedProperties) {
|
|
@@ -477,7 +482,7 @@ function validateLinkedProperties(datasource, objectDef) {
|
|
|
477
482
|
hasProperty
|
|
478
483
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
479
484
|
foreignProperties.forEach((prop) => {
|
|
480
|
-
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ?
|
|
485
|
+
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${prop}' on object '${apiName}' is not defined`) : invariant9__default.default(false) : void 0;
|
|
481
486
|
});
|
|
482
487
|
}
|
|
483
488
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -487,18 +492,18 @@ function validateAggregations(datasource, objectDef) {
|
|
|
487
492
|
switch (agg.type) {
|
|
488
493
|
case "collectList":
|
|
489
494
|
case "collectSet":
|
|
490
|
-
!isCollectible(property) ? process.env.NODE_ENV !== "production" ?
|
|
491
|
-
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ?
|
|
495
|
+
!isCollectible(property) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not collectible`) : invariant9__default.default(false) : void 0;
|
|
496
|
+
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`) : invariant9__default.default(false) : void 0;
|
|
492
497
|
break;
|
|
493
498
|
case "avg":
|
|
494
499
|
case "sum":
|
|
495
|
-
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
500
|
+
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not numeric`) : invariant9__default.default(false) : void 0;
|
|
496
501
|
break;
|
|
497
502
|
case "min":
|
|
498
503
|
case "max":
|
|
499
504
|
case "approximateCardinality":
|
|
500
505
|
case "exactCardinality":
|
|
501
|
-
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
506
|
+
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not primitive`) : invariant9__default.default(false) : void 0;
|
|
502
507
|
break;
|
|
503
508
|
}
|
|
504
509
|
if (agg.type !== "count") {
|
|
@@ -508,7 +513,7 @@ function validateAggregations(datasource, objectDef) {
|
|
|
508
513
|
apiName,
|
|
509
514
|
hasProperty
|
|
510
515
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
511
|
-
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ?
|
|
516
|
+
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${foreignProperty}' on object '${apiName}' is not defined`) : invariant9__default.default(false) : void 0;
|
|
512
517
|
}
|
|
513
518
|
});
|
|
514
519
|
}
|
|
@@ -527,6 +532,15 @@ function isPrimitive(type) {
|
|
|
527
532
|
const typeType = typeof type === "string" ? type : type.type;
|
|
528
533
|
return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
|
|
529
534
|
}
|
|
535
|
+
function getStatusType(status) {
|
|
536
|
+
if (status === void 0) {
|
|
537
|
+
return "active";
|
|
538
|
+
}
|
|
539
|
+
if (typeof status === "string") {
|
|
540
|
+
return status;
|
|
541
|
+
}
|
|
542
|
+
return status.type;
|
|
543
|
+
}
|
|
530
544
|
|
|
531
545
|
// src/conversion/toMarketplace/convertActionSections.ts
|
|
532
546
|
function convertActionSections(action) {
|
|
@@ -608,7 +622,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
608
622
|
}
|
|
609
623
|
};
|
|
610
624
|
case "parameter":
|
|
611
|
-
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
625
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant9__default.default(false) : void 0;
|
|
612
626
|
return {
|
|
613
627
|
type: "comparison",
|
|
614
628
|
comparison: {
|
|
@@ -833,7 +847,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
833
847
|
}
|
|
834
848
|
};
|
|
835
849
|
}
|
|
836
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
850
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant9__default.default(false) : void 0;
|
|
837
851
|
return {
|
|
838
852
|
propertyTypeConstraints: [],
|
|
839
853
|
nullability: void 0,
|
|
@@ -846,6 +860,39 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
846
860
|
nullabilityV2: prop.nullability
|
|
847
861
|
};
|
|
848
862
|
}
|
|
863
|
+
function convertReducers(type, apiName, reducers, sharedPropertyType) {
|
|
864
|
+
reducers?.forEach((reducer) => {
|
|
865
|
+
if (reducer.structField) {
|
|
866
|
+
!(isStruct(type) && Object.keys(type.structDefinition).includes(reducer.structField)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Reducer structField ${reducer.structField} does not exist in struct definition`) : invariant9__default.default(false) : void 0;
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
if (sharedPropertyType) {
|
|
870
|
+
return mapReducers(sharedPropertyType.apiName, sharedPropertyType.reducers);
|
|
871
|
+
} else {
|
|
872
|
+
return mapReducers(apiName, reducers);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function mapReducers(apiName, reducers) {
|
|
876
|
+
return reducers?.map((reducer) => {
|
|
877
|
+
switch (reducer.direction) {
|
|
878
|
+
case "ascending":
|
|
879
|
+
return {
|
|
880
|
+
direction: "ASCENDING_NULLS_LAST",
|
|
881
|
+
structApiName: reducer.structField ? apiName : void 0,
|
|
882
|
+
fieldApiName: reducer.structField
|
|
883
|
+
};
|
|
884
|
+
case "descending":
|
|
885
|
+
return {
|
|
886
|
+
direction: "DESCENDING_NULLS_LAST",
|
|
887
|
+
structApiName: reducer.structField ? apiName : void 0,
|
|
888
|
+
fieldApiName: reducer.structField
|
|
889
|
+
};
|
|
890
|
+
default: {
|
|
891
|
+
throw new Error(`Unsupported reducer direction: ${reducer.direction}`);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}) ?? [];
|
|
895
|
+
}
|
|
849
896
|
|
|
850
897
|
// src/conversion/toConjure/distributeTypeHelper.ts
|
|
851
898
|
function distributeTypeHelper(type) {
|
|
@@ -855,8 +902,27 @@ function distributeTypeHelper(type) {
|
|
|
855
902
|
};
|
|
856
903
|
}
|
|
857
904
|
|
|
905
|
+
// src/conversion/toMarketplace/convertMainValue.ts
|
|
906
|
+
function convertMainValue(type, apiName, sharedPropertyType) {
|
|
907
|
+
if (sharedPropertyType && isStruct(sharedPropertyType.type) && sharedPropertyType.type.mainValue) {
|
|
908
|
+
return {
|
|
909
|
+
fieldApiNames: Array.isArray(sharedPropertyType.type.mainValue.fields) ? sharedPropertyType.type.mainValue.fields : [sharedPropertyType.type.mainValue.fields],
|
|
910
|
+
structApiName: sharedPropertyType.apiName,
|
|
911
|
+
type: propertyTypeTypeToOntologyIrType(sharedPropertyType.type.mainValue.type)
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
if (isStruct(type) && type.mainValue) {
|
|
915
|
+
return {
|
|
916
|
+
fieldApiNames: Array.isArray(type.mainValue.fields) ? type.mainValue.fields : [type.mainValue.fields],
|
|
917
|
+
structApiName: apiName,
|
|
918
|
+
type: propertyTypeTypeToOntologyIrType(type.mainValue.type)
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
return void 0;
|
|
922
|
+
}
|
|
923
|
+
|
|
858
924
|
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.ts
|
|
859
|
-
function propertyTypeTypeToOntologyIrType(type) {
|
|
925
|
+
function propertyTypeTypeToOntologyIrType(type, apiName, sharedPropertyType) {
|
|
860
926
|
switch (true) {
|
|
861
927
|
case (typeof type === "object" && type.type === "marking"):
|
|
862
928
|
return {
|
|
@@ -912,7 +978,8 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
912
978
|
return {
|
|
913
979
|
type: "struct",
|
|
914
980
|
struct: {
|
|
915
|
-
structFields
|
|
981
|
+
structFields,
|
|
982
|
+
mainValue: convertMainValue(type, apiName, sharedPropertyType)
|
|
916
983
|
}
|
|
917
984
|
};
|
|
918
985
|
case (typeof type === "object" && type.type === "string"):
|
|
@@ -986,6 +1053,7 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
986
1053
|
function convertSpt({
|
|
987
1054
|
type,
|
|
988
1055
|
array,
|
|
1056
|
+
reducers,
|
|
989
1057
|
description,
|
|
990
1058
|
apiName,
|
|
991
1059
|
displayName,
|
|
@@ -1011,10 +1079,10 @@ function convertSpt({
|
|
|
1011
1079
|
type: array ? {
|
|
1012
1080
|
type: "array",
|
|
1013
1081
|
array: {
|
|
1014
|
-
subtype: propertyTypeTypeToOntologyIrType(type),
|
|
1015
|
-
reducers:
|
|
1082
|
+
subtype: propertyTypeTypeToOntologyIrType(type, apiName),
|
|
1083
|
+
reducers: convertReducers(type, apiName, reducers)
|
|
1016
1084
|
}
|
|
1017
|
-
} : propertyTypeTypeToOntologyIrType(type),
|
|
1085
|
+
} : propertyTypeTypeToOntologyIrType(type, apiName),
|
|
1018
1086
|
aliases: aliases ?? [],
|
|
1019
1087
|
baseFormatter,
|
|
1020
1088
|
dataConstraints: dataConstraint,
|
|
@@ -1327,9 +1395,9 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1327
1395
|
const usedProperties = /* @__PURE__ */ new Set();
|
|
1328
1396
|
ds.propertySecurityGroups?.forEach((psg) => {
|
|
1329
1397
|
psg.properties.forEach((propertyName) => {
|
|
1330
|
-
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1331
|
-
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1332
|
-
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
1398
|
+
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property "${propertyName}" in property security group ${psg.name} does not exist in the properties list`) : invariant9__default.default(false) : void 0;
|
|
1399
|
+
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property "${propertyName}" is used in multiple property security groups`) : invariant9__default.default(false) : void 0;
|
|
1400
|
+
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property "${propertyName}" in property security group ${psg.name} cannot be the primary key`) : invariant9__default.default(false) : void 0;
|
|
1333
1401
|
usedProperties.add(propertyName);
|
|
1334
1402
|
});
|
|
1335
1403
|
});
|
|
@@ -1606,7 +1674,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1606
1674
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1607
1675
|
function convertObjectPropertyType(property) {
|
|
1608
1676
|
const apiName = namespace + property.apiName;
|
|
1609
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1677
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant9__default.default(false) : void 0;
|
|
1610
1678
|
const output = {
|
|
1611
1679
|
apiName: property.apiName,
|
|
1612
1680
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1621,10 +1689,10 @@ function convertObjectPropertyType(property) {
|
|
|
1621
1689
|
type: property.array ? {
|
|
1622
1690
|
type: "array",
|
|
1623
1691
|
array: {
|
|
1624
|
-
subtype: propertyTypeTypeToOntologyIrType(property.type),
|
|
1625
|
-
reducers: []
|
|
1692
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type, property.apiName, property.sharedPropertyType),
|
|
1693
|
+
reducers: convertReducers(property.type, property.apiName, property.reducers ?? [], property.sharedPropertyType)
|
|
1626
1694
|
}
|
|
1627
|
-
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1695
|
+
} : propertyTypeTypeToOntologyIrType(property.type, property.apiName),
|
|
1628
1696
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
1629
1697
|
status: convertObjectStatus(property.status),
|
|
1630
1698
|
inlineAction: void 0,
|
|
@@ -1971,7 +2039,7 @@ function generateInterfaceSnippet(interfaceType, packageName) {
|
|
|
1971
2039
|
"interfaceApiName": interfaceType.apiName,
|
|
1972
2040
|
"packageName": packageName,
|
|
1973
2041
|
"objectOrInterfaceApiName": interfaceType.apiName,
|
|
1974
|
-
"propertyNames": Object.keys(interfaceType.propertiesV2),
|
|
2042
|
+
"propertyNames": [...Object.keys(interfaceType.propertiesV3), ...Object.keys(interfaceType.propertiesV2)],
|
|
1975
2043
|
"interfaceName": interfaceType.displayMetadata.displayName
|
|
1976
2044
|
};
|
|
1977
2045
|
return getSnippets(interfaceSnippets, interfaceContext);
|
|
@@ -2531,7 +2599,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2531
2599
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2532
2600
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2533
2601
|
async function main(args = process.argv) {
|
|
2534
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.
|
|
2602
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.3").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2535
2603
|
input: {
|
|
2536
2604
|
alias: "i",
|
|
2537
2605
|
describe: "Input file",
|
|
@@ -2600,15 +2668,15 @@ async function main(args = process.argv) {
|
|
|
2600
2668
|
let apiNamespace = "";
|
|
2601
2669
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
2602
2670
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
2603
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
2604
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
2671
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "API namespace is too long.") : invariant9__default.default(false) : void 0;
|
|
2672
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant9__default.default(false) : void 0;
|
|
2605
2673
|
}
|
|
2606
2674
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2607
2675
|
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2608
2676
|
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2609
2677
|
}
|
|
2610
2678
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
2611
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
2679
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant9__default.default(false) : void 0;
|
|
2612
2680
|
}
|
|
2613
2681
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
2614
2682
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -2659,37 +2727,37 @@ function defineAction(actionDef) {
|
|
|
2659
2727
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2660
2728
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2661
2729
|
}
|
|
2662
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2730
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant9__default.default(false) : void 0;
|
|
2663
2731
|
const parameterIdsSet = new Set(parameterIds);
|
|
2664
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2732
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter ids must be unique`) : invariant9__default.default(false) : void 0;
|
|
2665
2733
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2666
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2734
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant9__default.default(false) : void 0;
|
|
2667
2735
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2668
2736
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2669
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2670
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2737
|
+
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant9__default.default(false) : void 0;
|
|
2738
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant9__default.default(false) : void 0;
|
|
2671
2739
|
actionDef.rules.forEach((rule) => {
|
|
2672
2740
|
if (rule.type === "modifyObjectRule") {
|
|
2673
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2741
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant9__default.default(false) : void 0;
|
|
2674
2742
|
}
|
|
2675
2743
|
if (rule.type === "deleteObjectRule") {
|
|
2676
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2744
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant9__default.default(false) : void 0;
|
|
2677
2745
|
}
|
|
2678
2746
|
if (rule.type === "modifyInterfaceRule") {
|
|
2679
2747
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2680
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2748
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant9__default.default(false) : void 0;
|
|
2681
2749
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2682
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2750
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant9__default.default(false) : void 0;
|
|
2683
2751
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2684
2752
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2685
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2753
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant9__default.default(false) : void 0;
|
|
2686
2754
|
});
|
|
2687
2755
|
}
|
|
2688
2756
|
if (rule.type === "addInterfaceRule") {
|
|
2689
2757
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2690
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2758
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant9__default.default(false) : void 0;
|
|
2691
2759
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2692
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2760
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant9__default.default(false) : void 0;
|
|
2693
2761
|
});
|
|
2694
2762
|
}
|
|
2695
2763
|
});
|
|
@@ -3247,9 +3315,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
3247
3315
|
switch (condition.type) {
|
|
3248
3316
|
case "parameter":
|
|
3249
3317
|
const overrideParamId = condition.parameterId;
|
|
3250
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3251
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3252
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3318
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant9__default.default(false) : void 0;
|
|
3319
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant9__default.default(false) : void 0;
|
|
3320
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant9__default.default(false) : void 0;
|
|
3253
3321
|
break;
|
|
3254
3322
|
case "and":
|
|
3255
3323
|
if ("conditions" in condition) {
|
|
@@ -3277,11 +3345,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3277
3345
|
if (!defaultValue) return;
|
|
3278
3346
|
switch (defaultValue.type) {
|
|
3279
3347
|
case "objectParameterPropertyValue":
|
|
3280
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3281
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3348
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant9__default.default(false) : void 0;
|
|
3349
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant9__default.default(false) : void 0;
|
|
3282
3350
|
break;
|
|
3283
3351
|
case "staticValue":
|
|
3284
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
3352
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant9__default.default(false) : void 0;
|
|
3285
3353
|
break;
|
|
3286
3354
|
case "staticObject":
|
|
3287
3355
|
case "interfaceParameterPropertyValue":
|
|
@@ -3296,10 +3364,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3296
3364
|
}
|
|
3297
3365
|
function validateActionParameters(def, properties, name) {
|
|
3298
3366
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3299
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ?
|
|
3367
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant9__default.default(false) : void 0;
|
|
3300
3368
|
});
|
|
3301
3369
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3302
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ?
|
|
3370
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant9__default.default(false) : void 0;
|
|
3303
3371
|
});
|
|
3304
3372
|
}
|
|
3305
3373
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -3309,7 +3377,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
3309
3377
|
const orderingSet = new Set(parameterOrdering);
|
|
3310
3378
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3311
3379
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3312
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
3380
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant9__default.default(false) : void 0;
|
|
3313
3381
|
}
|
|
3314
3382
|
function isTargetParameter(parameterId) {
|
|
3315
3383
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -3725,7 +3793,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3725
3793
|
// src/api/defineInterface.ts
|
|
3726
3794
|
function defineInterface(interfaceDef) {
|
|
3727
3795
|
const apiName = namespace + interfaceDef.apiName;
|
|
3728
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3796
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface ${apiName} already exists`) : invariant9__default.default(false) : void 0;
|
|
3729
3797
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
3730
3798
|
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
3731
3799
|
}).map(([s, spt]) => {
|
|
@@ -3758,7 +3826,7 @@ function defineInterface(interfaceDef) {
|
|
|
3758
3826
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
3759
3827
|
type: "active"
|
|
3760
3828
|
});
|
|
3761
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
3829
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant9__default.default(false) : void 0;
|
|
3762
3830
|
const fullInterface = {
|
|
3763
3831
|
apiName,
|
|
3764
3832
|
displayMetadata: {
|
|
@@ -3785,16 +3853,16 @@ function defineInterface(interfaceDef) {
|
|
|
3785
3853
|
}
|
|
3786
3854
|
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
3787
3855
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3788
|
-
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ?
|
|
3789
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3856
|
+
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant9__default.default(false) : void 0;
|
|
3857
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
3790
3858
|
key: apiName,
|
|
3791
3859
|
apiName: type.apiName
|
|
3792
|
-
})}`) :
|
|
3860
|
+
})}`) : invariant9__default.default(false) : void 0;
|
|
3793
3861
|
return type;
|
|
3794
3862
|
}
|
|
3795
3863
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
3796
3864
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
3797
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3865
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant9__default.default(false) : void 0;
|
|
3798
3866
|
linkDef.from.links.push({
|
|
3799
3867
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
3800
3868
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -4057,8 +4125,8 @@ function defineModifyObjectAction(def) {
|
|
|
4057
4125
|
}
|
|
4058
4126
|
function defineSharedPropertyType(sptDef) {
|
|
4059
4127
|
const apiName = namespace + sptDef.apiName;
|
|
4060
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4061
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
4128
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${apiName} already exists`) : invariant9__default.default(false) : void 0;
|
|
4129
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant9__default.default(false) : void 0;
|
|
4062
4130
|
const fullSpt = {
|
|
4063
4131
|
...sptDef,
|
|
4064
4132
|
apiName,
|
|
@@ -4125,10 +4193,10 @@ function defineValueType(valueTypeDef) {
|
|
|
4125
4193
|
} = valueTypeDef;
|
|
4126
4194
|
const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;
|
|
4127
4195
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
4128
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
4196
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Version is not a valid semver") : invariant9__default.default(false) : void 0;
|
|
4129
4197
|
const existingVersions = ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];
|
|
4130
4198
|
const duplicateVersion = existingVersions.find((vt2) => vt2.version === version);
|
|
4131
|
-
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4199
|
+
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Value type with apiName ${apiName} and version ${version} is already defined`) : invariant9__default.default(false) : void 0;
|
|
4132
4200
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
4133
4201
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
4134
4202
|
const output = {
|
|
@@ -4197,8 +4265,8 @@ function importSharedPropertyType(opts) {
|
|
|
4197
4265
|
} = opts;
|
|
4198
4266
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
4199
4267
|
if (packageName !== void 0) {
|
|
4200
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
4201
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
4268
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Package name format invalid ends with period") : invariant9__default.default(false) : void 0;
|
|
4269
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Package name includes upper case characters") : invariant9__default.default(false) : void 0;
|
|
4202
4270
|
}
|
|
4203
4271
|
const spt = {
|
|
4204
4272
|
apiName: fullApiName,
|