@osdk/maker 0.37.0 → 0.38.0
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 +6 -0
- package/build/browser/api/defineAction.js +27 -0
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/cjs/index.cjs +107 -83
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/api/defineAction.js +27 -0
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/package.json +3 -3
package/build/cjs/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var fs2 = require('fs');
|
|
6
6
|
var path4 = require('path');
|
|
7
|
-
var
|
|
7
|
+
var invariant9 = require('tiny-invariant');
|
|
8
8
|
var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
|
|
9
9
|
var consola = require('consola');
|
|
10
10
|
var Mustache = require('mustache');
|
|
@@ -36,7 +36,7 @@ function _interopNamespace(e) {
|
|
|
36
36
|
|
|
37
37
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
38
38
|
var path4__namespace = /*#__PURE__*/_interopNamespace(path4);
|
|
39
|
-
var
|
|
39
|
+
var invariant9__default = /*#__PURE__*/_interopDefault(invariant9);
|
|
40
40
|
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
41
41
|
var fs4__namespace = /*#__PURE__*/_interopNamespace(fs4);
|
|
42
42
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
@@ -226,10 +226,10 @@ function validateLink(linkDefinition) {
|
|
|
226
226
|
object: toManyObject
|
|
227
227
|
} = getObject(linkDefinition.toMany.object);
|
|
228
228
|
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
229
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
230
|
-
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
229
|
+
!(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;
|
|
230
|
+
!/([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;
|
|
231
231
|
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
232
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
232
|
+
!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;
|
|
233
233
|
}
|
|
234
234
|
if ("intermediaryObjectType" in linkDefinition) {
|
|
235
235
|
const {
|
|
@@ -244,18 +244,18 @@ function validateLink(linkDefinition) {
|
|
|
244
244
|
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
245
245
|
const {
|
|
246
246
|
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
247
|
-
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
247
|
+
!("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;
|
|
248
248
|
const {
|
|
249
249
|
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
250
250
|
const {
|
|
251
251
|
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
252
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
252
|
+
!("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;
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
function getObject(object) {
|
|
256
256
|
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
257
257
|
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName] ?? importedTypes[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
258
|
-
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
258
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object ${objectApiName} is not defined`) : invariant9__default.default(false) : void 0;
|
|
259
259
|
return {
|
|
260
260
|
apiName: objectApiName,
|
|
261
261
|
object: fullObject
|
|
@@ -369,23 +369,23 @@ function defineObject(objectDefInput) {
|
|
|
369
369
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
370
370
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
371
371
|
}
|
|
372
|
-
!isValidObjectApiName(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
372
|
+
!isValidObjectApiName(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${OBJECT_API_NAME_PATTERN}.`) : invariant9__default.default(false) : void 0;
|
|
373
373
|
propertyApiNames.forEach((apiName2) => {
|
|
374
|
-
!isValidApiName(apiName2) ? process.env.NODE_ENV !== "production" ?
|
|
374
|
+
!isValidApiName(apiName2) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name ${apiName2} for property on object ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant9__default.default(false) : void 0;
|
|
375
375
|
});
|
|
376
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
377
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
378
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
376
|
+
!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;
|
|
377
|
+
!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;
|
|
378
|
+
!!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;
|
|
379
379
|
if (objectDef.includeEmptyBackingDatasource && objectDef.datasources) {
|
|
380
380
|
const nonDatasetDatasources = objectDef.datasources.filter((ds) => ds.type !== "dataset");
|
|
381
|
-
!(nonDatasetDatasources.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
381
|
+
!(nonDatasetDatasources.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object type "${objectDef.apiName}" has non-dataset datasources (${nonDatasetDatasources.map((ds) => ds.type).join(", ")}) and cannot use includeEmptyBackingDatasource. Empty backing datasources are only supported for object types with dataset datasources.`) : invariant9__default.default(false) : void 0;
|
|
382
382
|
}
|
|
383
383
|
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
384
384
|
retentionPeriods.forEach((retentionPeriod) => {
|
|
385
|
-
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ?
|
|
385
|
+
!(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;
|
|
386
386
|
});
|
|
387
387
|
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
388
|
-
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ?
|
|
388
|
+
!(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;
|
|
389
389
|
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
390
390
|
if (derivedDatasources.length > 0) {
|
|
391
391
|
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
@@ -401,15 +401,15 @@ function defineObject(objectDefInput) {
|
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
});
|
|
404
|
-
!(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
404
|
+
!(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;
|
|
405
405
|
}
|
|
406
406
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
407
407
|
const deadline = objectDef.status.deadline;
|
|
408
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
408
|
+
!(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;
|
|
409
409
|
}
|
|
410
410
|
const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
|
|
411
|
-
!(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ?
|
|
412
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
411
|
+
!(!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;
|
|
412
|
+
!!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;
|
|
413
413
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
414
414
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
415
415
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -429,7 +429,7 @@ function defineObject(objectDefInput) {
|
|
|
429
429
|
};
|
|
430
430
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
431
431
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
432
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
432
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant9__default.default(false) : void 0;
|
|
433
433
|
});
|
|
434
434
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
435
435
|
const finalObject = {
|
|
@@ -481,13 +481,13 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
483
|
function validateDerivedDatasource(objectDef, datasource) {
|
|
484
|
-
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
484
|
+
!(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;
|
|
485
485
|
datasource.linkDefinition.forEach((link) => {
|
|
486
486
|
const linkApiName = link.linkType.apiName;
|
|
487
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
487
|
+
!(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;
|
|
488
488
|
});
|
|
489
489
|
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
490
|
-
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
490
|
+
!(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;
|
|
491
491
|
});
|
|
492
492
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
493
493
|
if (isLinkedProperties) {
|
|
@@ -522,7 +522,7 @@ function validateLinkedProperties(datasource, objectDef) {
|
|
|
522
522
|
hasProperty
|
|
523
523
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
524
524
|
foreignProperties.forEach((prop) => {
|
|
525
|
-
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ?
|
|
525
|
+
!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;
|
|
526
526
|
});
|
|
527
527
|
}
|
|
528
528
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -532,18 +532,18 @@ function validateAggregations(datasource, objectDef) {
|
|
|
532
532
|
switch (agg.type) {
|
|
533
533
|
case "collectList":
|
|
534
534
|
case "collectSet":
|
|
535
|
-
!isCollectible(property) ? process.env.NODE_ENV !== "production" ?
|
|
536
|
-
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ?
|
|
535
|
+
!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;
|
|
536
|
+
!(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;
|
|
537
537
|
break;
|
|
538
538
|
case "avg":
|
|
539
539
|
case "sum":
|
|
540
|
-
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
540
|
+
!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;
|
|
541
541
|
break;
|
|
542
542
|
case "min":
|
|
543
543
|
case "max":
|
|
544
544
|
case "approximateCardinality":
|
|
545
545
|
case "exactCardinality":
|
|
546
|
-
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
546
|
+
!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;
|
|
547
547
|
break;
|
|
548
548
|
}
|
|
549
549
|
if (agg.type !== "count") {
|
|
@@ -553,7 +553,7 @@ function validateAggregations(datasource, objectDef) {
|
|
|
553
553
|
apiName,
|
|
554
554
|
hasProperty
|
|
555
555
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
556
|
-
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ?
|
|
556
|
+
!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;
|
|
557
557
|
}
|
|
558
558
|
});
|
|
559
559
|
}
|
|
@@ -662,7 +662,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
662
662
|
}
|
|
663
663
|
};
|
|
664
664
|
case "parameter":
|
|
665
|
-
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
665
|
+
!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;
|
|
666
666
|
return {
|
|
667
667
|
type: "comparison",
|
|
668
668
|
comparison: {
|
|
@@ -888,7 +888,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
888
888
|
}
|
|
889
889
|
};
|
|
890
890
|
}
|
|
891
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
891
|
+
!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;
|
|
892
892
|
return {
|
|
893
893
|
propertyTypeConstraints: [],
|
|
894
894
|
nullability: void 0,
|
|
@@ -904,7 +904,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
904
904
|
function convertReducers(type, apiName, reducers, sharedPropertyType) {
|
|
905
905
|
reducers?.forEach((reducer) => {
|
|
906
906
|
if (reducer.structField) {
|
|
907
|
-
!(isStruct(type) && Object.keys(type.structDefinition).includes(reducer.structField)) ? process.env.NODE_ENV !== "production" ?
|
|
907
|
+
!(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;
|
|
908
908
|
}
|
|
909
909
|
});
|
|
910
910
|
if (sharedPropertyType) {
|
|
@@ -1447,9 +1447,9 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1447
1447
|
const usedProperties = /* @__PURE__ */ new Set();
|
|
1448
1448
|
ds.propertySecurityGroups?.forEach((psg) => {
|
|
1449
1449
|
psg.properties.forEach((propertyName) => {
|
|
1450
|
-
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1451
|
-
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1452
|
-
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
1450
|
+
!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;
|
|
1451
|
+
!!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;
|
|
1452
|
+
!(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;
|
|
1453
1453
|
usedProperties.add(propertyName);
|
|
1454
1454
|
});
|
|
1455
1455
|
});
|
|
@@ -1727,7 +1727,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1727
1727
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1728
1728
|
function convertObjectPropertyType(property) {
|
|
1729
1729
|
const apiName = namespace + property.apiName;
|
|
1730
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1730
|
+
!(!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;
|
|
1731
1731
|
const output = {
|
|
1732
1732
|
apiName: property.apiName,
|
|
1733
1733
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1771,7 +1771,7 @@ function convertObject(objectType) {
|
|
|
1771
1771
|
const implementations = objectType.implementsInterfaces ?? [];
|
|
1772
1772
|
for (const impl of implementations) {
|
|
1773
1773
|
const requiredConstraints = (impl.implements.actionTypeConstraints ?? []).filter((constraint) => constraint.requireImplementation);
|
|
1774
|
-
!(requiredConstraints.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
1774
|
+
!(requiredConstraints.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object "${objectType.apiName}" implements interface "${impl.implements.apiName}" which has required action type constraints: ${requiredConstraints.map((constraint) => constraint.metadata.apiName).join(", ")}. Action type constraint implementation is not yet supported in OAC. Set requireImplementation to false and manually implement the constraint after installation.`) : invariant9__default.default(false) : void 0;
|
|
1775
1775
|
}
|
|
1776
1776
|
return {
|
|
1777
1777
|
objectType: {
|
|
@@ -1860,7 +1860,7 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1860
1860
|
function extractDerivedDatasources(objectType) {
|
|
1861
1861
|
const inputDerivedDatasources = (objectType.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
1862
1862
|
const propertyApiNames = new Set((objectType.properties ?? []).map((prop) => prop.apiName));
|
|
1863
|
-
inputDerivedDatasources.forEach((ds) => Object.keys(ds.propertyMapping).forEach((prop) => !propertyApiNames.has(prop) ? process.env.NODE_ENV !== "production" ?
|
|
1863
|
+
inputDerivedDatasources.forEach((ds) => Object.keys(ds.propertyMapping).forEach((prop) => !propertyApiNames.has(prop) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${prop}' used in derived datasource for object '${objectType.apiName}' is not defined.`) : invariant9__default.default(false) : void 0));
|
|
1864
1864
|
const derivedDatasources = inputDerivedDatasources.map((ds, i) => buildDerivedDatasource(ds, i, objectType.apiName));
|
|
1865
1865
|
const derivedPropertyNames = inputDerivedDatasources.flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
1866
1866
|
return {
|
|
@@ -2914,39 +2914,45 @@ function defineAction(actionDefInput) {
|
|
|
2914
2914
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2915
2915
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2916
2916
|
}
|
|
2917
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2917
|
+
!/^[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;
|
|
2918
2918
|
const parameterIdsSet = new Set(parameterIds);
|
|
2919
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2919
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter ids must be unique`) : invariant9__default.default(false) : void 0;
|
|
2920
2920
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2921
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2921
|
+
!(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;
|
|
2922
2922
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2923
2923
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2924
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2925
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2924
|
+
!(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;
|
|
2925
|
+
!(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;
|
|
2926
2926
|
actionDef.rules.forEach((rule) => {
|
|
2927
2927
|
if (rule.type === "modifyObjectRule") {
|
|
2928
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2928
|
+
!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;
|
|
2929
2929
|
}
|
|
2930
2930
|
if (rule.type === "deleteObjectRule") {
|
|
2931
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2931
|
+
!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;
|
|
2932
2932
|
}
|
|
2933
2933
|
if (rule.type === "modifyInterfaceRule") {
|
|
2934
2934
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2935
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2935
|
+
!(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;
|
|
2936
2936
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2937
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2937
|
+
!(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;
|
|
2938
2938
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2939
2939
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2940
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2940
|
+
!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;
|
|
2941
2941
|
});
|
|
2942
2942
|
}
|
|
2943
2943
|
if (rule.type === "addInterfaceRule") {
|
|
2944
2944
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2945
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2945
|
+
!(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;
|
|
2946
2946
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2947
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2947
|
+
!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;
|
|
2948
2948
|
});
|
|
2949
2949
|
}
|
|
2950
|
+
if (rule.type === "addInterfaceLinkRuleV2") {
|
|
2951
|
+
const ilr = rule.addInterfaceLinkRuleV2;
|
|
2952
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[ilr.interfaceTypeRid] ?? importedTypes.INTERFACE_TYPE[ilr.interfaceTypeRid];
|
|
2953
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface type ${ilr.interfaceTypeRid} does not exist`) : invariant9__default.default(false) : void 0;
|
|
2954
|
+
!interfaceType.links.some((link) => link.metadata.apiName === ilr.interfaceLinkTypeRid) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface link type ${ilr.interfaceLinkTypeRid} does not exist on interface ${ilr.interfaceTypeRid}`) : invariant9__default.default(false) : void 0;
|
|
2955
|
+
}
|
|
2950
2956
|
});
|
|
2951
2957
|
const fullAction = {
|
|
2952
2958
|
...actionDef,
|
|
@@ -3257,6 +3263,24 @@ function referencedParameterIds(actionDef) {
|
|
|
3257
3263
|
}
|
|
3258
3264
|
});
|
|
3259
3265
|
break;
|
|
3266
|
+
case "addInterfaceLinkRuleV2":
|
|
3267
|
+
rule.addInterfaceLinkRuleV2.interfaceTypeRid = sanitize(rule.addInterfaceLinkRuleV2.interfaceTypeRid);
|
|
3268
|
+
rule.addInterfaceLinkRuleV2.interfaceLinkTypeRid = sanitize(rule.addInterfaceLinkRuleV2.interfaceLinkTypeRid);
|
|
3269
|
+
[...rule.addInterfaceLinkRuleV2.sourceObjects, ...rule.addInterfaceLinkRuleV2.targetObjects].forEach((ref) => {
|
|
3270
|
+
switch (ref.type) {
|
|
3271
|
+
case "existingObject":
|
|
3272
|
+
parameterIds.add(ref.existingObject);
|
|
3273
|
+
break;
|
|
3274
|
+
case "createdInterfaceObjectReferenceByPk":
|
|
3275
|
+
parameterIds.add(ref.createdInterfaceObjectReferenceByPk.objectType);
|
|
3276
|
+
parameterIds.add(ref.createdInterfaceObjectReferenceByPk.primaryKey);
|
|
3277
|
+
break;
|
|
3278
|
+
case "createdInterfaceObjectReferenceByUniqueIdentifier":
|
|
3279
|
+
parameterIds.add(ref.createdInterfaceObjectReferenceByUniqueIdentifier.objectType);
|
|
3280
|
+
break;
|
|
3281
|
+
}
|
|
3282
|
+
});
|
|
3283
|
+
break;
|
|
3260
3284
|
}
|
|
3261
3285
|
});
|
|
3262
3286
|
return parameterIds;
|
|
@@ -3517,9 +3541,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
3517
3541
|
switch (condition.type) {
|
|
3518
3542
|
case "parameter":
|
|
3519
3543
|
const overrideParamId = condition.parameterId;
|
|
3520
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3521
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3522
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3544
|
+
!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;
|
|
3545
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant9__default.default(false) : void 0;
|
|
3546
|
+
!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;
|
|
3523
3547
|
break;
|
|
3524
3548
|
case "and":
|
|
3525
3549
|
if ("conditions" in condition) {
|
|
@@ -3547,11 +3571,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3547
3571
|
if (!defaultValue) return;
|
|
3548
3572
|
switch (defaultValue.type) {
|
|
3549
3573
|
case "objectParameterPropertyValue":
|
|
3550
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3551
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3574
|
+
!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;
|
|
3575
|
+
!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;
|
|
3552
3576
|
break;
|
|
3553
3577
|
case "staticValue":
|
|
3554
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
3578
|
+
!(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;
|
|
3555
3579
|
break;
|
|
3556
3580
|
case "staticObject":
|
|
3557
3581
|
case "interfaceParameterPropertyValue":
|
|
@@ -3566,10 +3590,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3566
3590
|
}
|
|
3567
3591
|
function validateActionParameters(def, properties, name) {
|
|
3568
3592
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3569
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ?
|
|
3593
|
+
!(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;
|
|
3570
3594
|
});
|
|
3571
3595
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3572
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ?
|
|
3596
|
+
!(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;
|
|
3573
3597
|
});
|
|
3574
3598
|
}
|
|
3575
3599
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -3579,7 +3603,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
3579
3603
|
const orderingSet = new Set(parameterOrdering);
|
|
3580
3604
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3581
3605
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3582
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
3606
|
+
!(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;
|
|
3583
3607
|
}
|
|
3584
3608
|
function isTargetParameter(parameterId) {
|
|
3585
3609
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -4018,8 +4042,8 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
4018
4042
|
function defineInterface(interfaceDefInput) {
|
|
4019
4043
|
const interfaceDef = cloneDefinition(interfaceDefInput);
|
|
4020
4044
|
const apiName = namespace + interfaceDef.apiName;
|
|
4021
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4022
|
-
!isValidApiName(interfaceDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
4045
|
+
!(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;
|
|
4046
|
+
!isValidApiName(interfaceDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant9__default.default(false) : void 0;
|
|
4023
4047
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
4024
4048
|
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
4025
4049
|
}).map(([s, spt]) => {
|
|
@@ -4037,7 +4061,7 @@ function defineInterface(interfaceDefInput) {
|
|
|
4037
4061
|
}];
|
|
4038
4062
|
}));
|
|
4039
4063
|
const propertiesV3 = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([apiName2, prop]) => {
|
|
4040
|
-
!isValidApiName(apiName2) ? process.env.NODE_ENV !== "production" ?
|
|
4064
|
+
!isValidApiName(apiName2) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name ${apiName2} for property on interface ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant9__default.default(false) : void 0;
|
|
4041
4065
|
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
4042
4066
|
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
4043
4067
|
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
@@ -4053,7 +4077,7 @@ function defineInterface(interfaceDefInput) {
|
|
|
4053
4077
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
4054
4078
|
type: "active"
|
|
4055
4079
|
});
|
|
4056
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
4080
|
+
!(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;
|
|
4057
4081
|
const fullInterface = {
|
|
4058
4082
|
apiName,
|
|
4059
4083
|
displayMetadata: {
|
|
@@ -4083,22 +4107,22 @@ function defineInterface(interfaceDefInput) {
|
|
|
4083
4107
|
}
|
|
4084
4108
|
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
4085
4109
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
4086
|
-
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ?
|
|
4087
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
4110
|
+
!(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;
|
|
4111
|
+
!(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({
|
|
4088
4112
|
key: apiName,
|
|
4089
4113
|
apiName: type.apiName
|
|
4090
|
-
})}`) :
|
|
4114
|
+
})}`) : invariant9__default.default(false) : void 0;
|
|
4091
4115
|
return type;
|
|
4092
4116
|
}
|
|
4093
4117
|
function defineInterfaceActionTypeConstraint(input) {
|
|
4094
4118
|
const def = cloneDefinition(input);
|
|
4095
|
-
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][def.interfaceType.apiName] == null) ? process.env.NODE_ENV !== "production" ?
|
|
4119
|
+
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][def.interfaceType.apiName] == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Cannot define an action type constraint on imported interface ${def.interfaceType.apiName}. The interface must be locally defined.`) : invariant9__default.default(false) : void 0;
|
|
4096
4120
|
const apiNameWithNamespace = combineApiNamespaceIfMissing(namespace, def.apiName);
|
|
4097
|
-
!(def.interfaceType.actionTypeConstraints.find((a) => a.metadata.apiName === apiNameWithNamespace) == null) ? process.env.NODE_ENV !== "production" ?
|
|
4121
|
+
!(def.interfaceType.actionTypeConstraints.find((a) => a.metadata.apiName === apiNameWithNamespace) == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action type constraint with apiName ${apiNameWithNamespace} already exists on interface ${def.interfaceType.apiName}`) : invariant9__default.default(false) : void 0;
|
|
4098
4122
|
const parameters = {};
|
|
4099
4123
|
const seenParamApiNames = /* @__PURE__ */ new Set();
|
|
4100
4124
|
for (const param of def.parameters) {
|
|
4101
|
-
!!seenParamApiNames.has(param.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
4125
|
+
!!seenParamApiNames.has(param.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Duplicate parameter constraint apiName "${param.apiName}" in action type constraint ${apiNameWithNamespace}`) : invariant9__default.default(false) : void 0;
|
|
4102
4126
|
seenParamApiNames.add(param.apiName);
|
|
4103
4127
|
parameters[param.apiName] = {
|
|
4104
4128
|
displayMetadata: {
|
|
@@ -4121,9 +4145,9 @@ function defineInterfaceActionTypeConstraint(input) {
|
|
|
4121
4145
|
}
|
|
4122
4146
|
function defineInterfaceLinkConstraint(linkDefInput) {
|
|
4123
4147
|
const linkDef = cloneDefinition(linkDefInput);
|
|
4124
|
-
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][linkDef.from.apiName] == null) ? process.env.NODE_ENV !== "production" ?
|
|
4148
|
+
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][linkDef.from.apiName] == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Cannot define a link constraint from imported interface ${linkDef.from.apiName}. The "from" side must be a locally defined interface.`) : invariant9__default.default(false) : void 0;
|
|
4125
4149
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
4126
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
4150
|
+
!(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;
|
|
4127
4151
|
linkDef.from.links.push({
|
|
4128
4152
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
4129
4153
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -4202,7 +4226,7 @@ function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
|
4202
4226
|
};
|
|
4203
4227
|
}
|
|
4204
4228
|
function convertLinkTypeMetadata(metadata) {
|
|
4205
|
-
!isValidApiName(metadata.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
4229
|
+
!isValidApiName(metadata.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name for link: ${metadata.apiName}`) : invariant9__default.default(false) : void 0;
|
|
4206
4230
|
return {
|
|
4207
4231
|
apiName: metadata.apiName,
|
|
4208
4232
|
displayMetadata: {
|
|
@@ -4397,8 +4421,8 @@ function defineModifyObjectAction(defInput) {
|
|
|
4397
4421
|
function defineSharedPropertyType(sptDefInput) {
|
|
4398
4422
|
const sptDef = cloneDefinition(sptDefInput);
|
|
4399
4423
|
const apiName = namespace + sptDef.apiName;
|
|
4400
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4401
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
4424
|
+
!(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;
|
|
4425
|
+
!(!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;
|
|
4402
4426
|
const fullSpt = {
|
|
4403
4427
|
...sptDef,
|
|
4404
4428
|
apiName,
|
|
@@ -4466,10 +4490,10 @@ function defineValueType(valueTypeDefInput) {
|
|
|
4466
4490
|
} = valueTypeDef;
|
|
4467
4491
|
const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;
|
|
4468
4492
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
4469
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
4493
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Version is not a valid semver") : invariant9__default.default(false) : void 0;
|
|
4470
4494
|
const existingVersions = ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];
|
|
4471
4495
|
const duplicateVersion = existingVersions.find((vt2) => vt2.version === version);
|
|
4472
|
-
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4496
|
+
!(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;
|
|
4473
4497
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
4474
4498
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
4475
4499
|
const output = {
|
|
@@ -4538,8 +4562,8 @@ function importSharedPropertyType(opts) {
|
|
|
4538
4562
|
} = opts;
|
|
4539
4563
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
4540
4564
|
if (packageName !== void 0) {
|
|
4541
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
4542
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
4565
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Package name format invalid ends with period") : invariant9__default.default(false) : void 0;
|
|
4566
|
+
!(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;
|
|
4543
4567
|
}
|
|
4544
4568
|
const spt = {
|
|
4545
4569
|
apiName: fullApiName,
|
|
@@ -4564,7 +4588,7 @@ function wrapWithProxy(entity) {
|
|
|
4564
4588
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
4565
4589
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
4566
4590
|
async function main(args = process.argv) {
|
|
4567
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
4591
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.38.0").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
4568
4592
|
input: {
|
|
4569
4593
|
alias: "i",
|
|
4570
4594
|
describe: "Input file",
|
|
@@ -4632,15 +4656,15 @@ async function main(args = process.argv) {
|
|
|
4632
4656
|
let apiNamespace = "";
|
|
4633
4657
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
4634
4658
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
4635
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
4636
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
4659
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "API namespace is too long.") : invariant9__default.default(false) : void 0;
|
|
4660
|
+
!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;
|
|
4637
4661
|
}
|
|
4638
4662
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
4639
4663
|
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path4__namespace.resolve("./"))) {
|
|
4640
4664
|
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
4641
4665
|
}
|
|
4642
4666
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
4643
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
4667
|
+
!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;
|
|
4644
4668
|
}
|
|
4645
4669
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
4646
4670
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|