@osdk/maker 0.15.0-beta.9 → 0.16.0-beta.1
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/README.md +49 -0
- package/build/browser/api/defineAction.js +4 -0
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/object/SecurityCondition.js +2 -0
- package/build/browser/api/object/SecurityCondition.js.map +1 -0
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/propertyConversionUtils.js +5 -1
- package/build/browser/api/propertyConversionUtils.js.map +1 -1
- package/build/browser/api/test/actions.test.js +52 -0
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/links.test.js +36 -0
- package/build/browser/api/test/links.test.js.map +1 -1
- package/build/browser/api/test/misc.test.js +4 -0
- package/build/browser/api/test/misc.test.js.map +1 -1
- package/build/browser/api/test/objects.test.js +804 -0
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +179 -0
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertNullabilityToDataConstraint.js +0 -1
- package/build/browser/conversion/toMarketplace/convertNullabilityToDataConstraint.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObject.js +4 -0
- package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +2 -2
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +5 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/cjs/index.cjs +265 -73
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +33 -2
- package/build/esm/api/defineAction.js +4 -0
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/object/SecurityCondition.js +2 -0
- package/build/esm/api/object/SecurityCondition.js.map +1 -0
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/propertyConversionUtils.js +5 -1
- package/build/esm/api/propertyConversionUtils.js.map +1 -1
- package/build/esm/api/test/actions.test.js +52 -0
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/links.test.js +36 -0
- package/build/esm/api/test/links.test.js.map +1 -1
- package/build/esm/api/test/misc.test.js +4 -0
- package/build/esm/api/test/misc.test.js.map +1 -1
- package/build/esm/api/test/objects.test.js +804 -0
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +179 -0
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertNullabilityToDataConstraint.js +0 -1
- package/build/esm/conversion/toMarketplace/convertNullabilityToDataConstraint.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObject.js +4 -0
- package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +2 -2
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +5 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +15 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/api/object/SecurityCondition.d.ts +18 -0
- package/build/types/api/object/SecurityCondition.d.ts.map +1 -0
- package/build/types/api/properties/PropertyTypeType.d.ts +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/propertyConversionUtils.d.ts +1 -0
- package/build/types/api/propertyConversionUtils.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertDatasourceDefinition.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.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 invariant8 = 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 invariant8__default = /*#__PURE__*/_interopDefault(invariant8);
|
|
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" ? invariant8__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`) : invariant8__default.default(false) : void 0;
|
|
221
|
+
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant8__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`) : invariant8__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" ? invariant8__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant8__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" ? invariant8__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`) : invariant8__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" ? invariant8__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`) : invariant8__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" ? invariant8__default.default(false, `Object ${objectApiName} is not defined`) : invariant8__default.default(false) : void 0;
|
|
250
250
|
return {
|
|
251
251
|
apiName: objectApiName,
|
|
252
252
|
object: fullObject
|
|
@@ -336,16 +336,16 @@ 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" ? invariant8__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant8__default.default(false) : void 0;
|
|
340
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant8__default.default(false) : void 0;
|
|
341
|
+
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant8__default.default(false) : void 0;
|
|
342
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant8__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" ? invariant8__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant8__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" ? invariant8__default.default(false, `Object ${objectDef.apiName} has more than one base datasource (got: [${baseDatasources.map((ds) => ds.type).join(", ")}])`) : invariant8__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));
|
|
@@ -357,14 +357,14 @@ function defineObject(objectDef) {
|
|
|
357
357
|
activeProperties.push(apiName2);
|
|
358
358
|
}
|
|
359
359
|
});
|
|
360
|
-
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
360
|
+
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `When object "${objectDef.apiName}" has experimental status, no properties can have "active" status, but found active properties: ${activeProperties.join(", ")}`) : invariant8__default.default(false) : void 0;
|
|
361
361
|
}
|
|
362
362
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
363
363
|
const deadline = objectDef.status.deadline;
|
|
364
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
364
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant8__default.default(false) : void 0;
|
|
365
365
|
}
|
|
366
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
367
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
366
|
+
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant8__default.default(false) : void 0;
|
|
367
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant8__default.default(false) : void 0;
|
|
368
368
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
369
369
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
370
370
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -384,7 +384,7 @@ function defineObject(objectDef) {
|
|
|
384
384
|
};
|
|
385
385
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
386
386
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
387
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
387
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant8__default.default(false) : void 0;
|
|
388
388
|
});
|
|
389
389
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
390
390
|
const finalObject = {
|
|
@@ -436,13 +436,13 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
438
|
function validateDerivedDatasource(objectDef, datasource) {
|
|
439
|
-
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
439
|
+
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Derived datasource for object '${objectDef.apiName}' must have at least one link.`) : invariant8__default.default(false) : void 0;
|
|
440
440
|
datasource.linkDefinition.forEach((link) => {
|
|
441
441
|
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" ?
|
|
442
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant8__default.default(false) : void 0;
|
|
443
443
|
});
|
|
444
444
|
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
445
|
-
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
445
|
+
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant8__default.default(false) : void 0;
|
|
446
446
|
});
|
|
447
447
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
448
448
|
if (isLinkedProperties) {
|
|
@@ -477,7 +477,7 @@ function validateLinkedProperties(datasource, objectDef) {
|
|
|
477
477
|
hasProperty
|
|
478
478
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
479
479
|
foreignProperties.forEach((prop) => {
|
|
480
|
-
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ?
|
|
480
|
+
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property '${prop}' on object '${apiName}' is not defined`) : invariant8__default.default(false) : void 0;
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
483
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -487,18 +487,18 @@ function validateAggregations(datasource, objectDef) {
|
|
|
487
487
|
switch (agg.type) {
|
|
488
488
|
case "collectList":
|
|
489
489
|
case "collectSet":
|
|
490
|
-
!isCollectible(property) ? process.env.NODE_ENV !== "production" ?
|
|
491
|
-
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ?
|
|
490
|
+
!isCollectible(property) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not collectible`) : invariant8__default.default(false) : void 0;
|
|
491
|
+
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`) : invariant8__default.default(false) : void 0;
|
|
492
492
|
break;
|
|
493
493
|
case "avg":
|
|
494
494
|
case "sum":
|
|
495
|
-
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
495
|
+
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not numeric`) : invariant8__default.default(false) : void 0;
|
|
496
496
|
break;
|
|
497
497
|
case "min":
|
|
498
498
|
case "max":
|
|
499
499
|
case "approximateCardinality":
|
|
500
500
|
case "exactCardinality":
|
|
501
|
-
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
501
|
+
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not primitive`) : invariant8__default.default(false) : void 0;
|
|
502
502
|
break;
|
|
503
503
|
}
|
|
504
504
|
if (agg.type !== "count") {
|
|
@@ -508,7 +508,7 @@ function validateAggregations(datasource, objectDef) {
|
|
|
508
508
|
apiName,
|
|
509
509
|
hasProperty
|
|
510
510
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
511
|
-
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ?
|
|
511
|
+
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property '${foreignProperty}' on object '${apiName}' is not defined`) : invariant8__default.default(false) : void 0;
|
|
512
512
|
}
|
|
513
513
|
});
|
|
514
514
|
}
|
|
@@ -608,7 +608,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
608
608
|
}
|
|
609
609
|
};
|
|
610
610
|
case "parameter":
|
|
611
|
-
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
611
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant8__default.default(false) : void 0;
|
|
612
612
|
return {
|
|
613
613
|
type: "comparison",
|
|
614
614
|
comparison: {
|
|
@@ -829,12 +829,11 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
829
829
|
propertyTypeConstraints: [],
|
|
830
830
|
nullability: void 0,
|
|
831
831
|
nullabilityV2: {
|
|
832
|
-
noEmptyCollections: true,
|
|
833
832
|
noNulls: true
|
|
834
833
|
}
|
|
835
834
|
};
|
|
836
835
|
}
|
|
837
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
836
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant8__default.default(false) : void 0;
|
|
838
837
|
return {
|
|
839
838
|
propertyTypeConstraints: [],
|
|
840
839
|
nullability: void 0,
|
|
@@ -970,6 +969,11 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
970
969
|
type: "geotimeSeriesReference",
|
|
971
970
|
geotimeSeriesReference: {}
|
|
972
971
|
};
|
|
972
|
+
case type === "attachment":
|
|
973
|
+
return {
|
|
974
|
+
type: "attachment",
|
|
975
|
+
attachment: {}
|
|
976
|
+
};
|
|
973
977
|
default:
|
|
974
978
|
if (typeof type === "object") {
|
|
975
979
|
throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);
|
|
@@ -1227,8 +1231,6 @@ function convertInterface(interfaceType) {
|
|
|
1227
1231
|
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName)))
|
|
1228
1232
|
};
|
|
1229
1233
|
}
|
|
1230
|
-
|
|
1231
|
-
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
1232
1234
|
function convertDatasourceDefinition(objectType, properties) {
|
|
1233
1235
|
const baseDatasource = objectType.datasources?.find((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
1234
1236
|
switch (baseDatasource?.type) {
|
|
@@ -1261,8 +1263,27 @@ function convertDatasourceDefinition(objectType, properties) {
|
|
|
1261
1263
|
propertyMapping: buildPropertyMapping(properties)
|
|
1262
1264
|
}
|
|
1263
1265
|
};
|
|
1266
|
+
case "derived":
|
|
1267
|
+
return {
|
|
1268
|
+
type: "datasetV2",
|
|
1269
|
+
datasetV2: {
|
|
1270
|
+
datasetRid: objectType.apiName,
|
|
1271
|
+
propertyMapping: buildPropertyMapping(properties)
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1264
1274
|
case "dataset":
|
|
1265
1275
|
default:
|
|
1276
|
+
if (objectType.properties?.some((prop) => typeof prop.type === "object" && prop.type.type === "marking") || baseDatasource?.objectSecurityPolicy || baseDatasource?.propertySecurityGroups) {
|
|
1277
|
+
return {
|
|
1278
|
+
type: "datasetV3",
|
|
1279
|
+
datasetV3: {
|
|
1280
|
+
datasetRid: objectType.apiName,
|
|
1281
|
+
propertyMapping: buildPropertyMapping(properties),
|
|
1282
|
+
branchId: "master",
|
|
1283
|
+
propertySecurityGroups: convertPropertySecurityGroups(baseDatasource, properties, objectType.primaryKeyPropertyApiName)
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1266
1287
|
return {
|
|
1267
1288
|
type: "datasetV2",
|
|
1268
1289
|
datasetV2: {
|
|
@@ -1272,6 +1293,165 @@ function convertDatasourceDefinition(objectType, properties) {
|
|
|
1272
1293
|
};
|
|
1273
1294
|
}
|
|
1274
1295
|
}
|
|
1296
|
+
function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName) {
|
|
1297
|
+
if (!ds || !("objectSecurityPolicy" in ds) && !("propertySecurityGroups" in ds)) {
|
|
1298
|
+
return {
|
|
1299
|
+
groups: [{
|
|
1300
|
+
properties: properties.map((prop) => prop.apiName),
|
|
1301
|
+
rid: "defaultObjectSecurityPolicy",
|
|
1302
|
+
security: {
|
|
1303
|
+
type: "granular",
|
|
1304
|
+
granular: {
|
|
1305
|
+
viewPolicy: {
|
|
1306
|
+
granularPolicyCondition: {
|
|
1307
|
+
type: "and",
|
|
1308
|
+
and: {
|
|
1309
|
+
conditions: []
|
|
1310
|
+
}
|
|
1311
|
+
},
|
|
1312
|
+
additionalMandatory: {
|
|
1313
|
+
markings: {},
|
|
1314
|
+
assumedMarkings: []
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
type: {
|
|
1320
|
+
type: "primaryKey",
|
|
1321
|
+
primaryKey: {}
|
|
1322
|
+
}
|
|
1323
|
+
}]
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
const validPropertyNames = new Set(properties.map((prop) => prop.apiName));
|
|
1327
|
+
const usedProperties = /* @__PURE__ */ new Set();
|
|
1328
|
+
ds.propertySecurityGroups?.forEach((psg) => {
|
|
1329
|
+
psg.properties.forEach((propertyName) => {
|
|
1330
|
+
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property "${propertyName}" in property security group ${psg.name} does not exist in the properties list`) : invariant8__default.default(false) : void 0;
|
|
1331
|
+
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property "${propertyName}" is used in multiple property security groups`) : invariant8__default.default(false) : void 0;
|
|
1332
|
+
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property "${propertyName}" in property security group ${psg.name} cannot be the primary key`) : invariant8__default.default(false) : void 0;
|
|
1333
|
+
usedProperties.add(propertyName);
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1336
|
+
const objectSecurityPolicyGroup = {
|
|
1337
|
+
rid: ds.objectSecurityPolicy?.name || "defaultObjectSecurityPolicy",
|
|
1338
|
+
security: {
|
|
1339
|
+
type: "granular",
|
|
1340
|
+
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.additionalMandatoryMarkings)
|
|
1341
|
+
},
|
|
1342
|
+
type: {
|
|
1343
|
+
type: "primaryKey",
|
|
1344
|
+
primaryKey: {}
|
|
1345
|
+
},
|
|
1346
|
+
properties: properties.filter((prop) => !usedProperties.has(prop.apiName)).map((prop) => prop.apiName)
|
|
1347
|
+
};
|
|
1348
|
+
return {
|
|
1349
|
+
groups: [objectSecurityPolicyGroup, ...ds.propertySecurityGroups?.map((psg) => ({
|
|
1350
|
+
rid: psg.name,
|
|
1351
|
+
security: {
|
|
1352
|
+
type: "granular",
|
|
1353
|
+
granular: convertGranularPolicy(psg.granularPolicy, psg.additionalMandatoryMarkings)
|
|
1354
|
+
},
|
|
1355
|
+
type: {
|
|
1356
|
+
type: "property",
|
|
1357
|
+
property: {
|
|
1358
|
+
name: psg.name
|
|
1359
|
+
}
|
|
1360
|
+
},
|
|
1361
|
+
properties: psg.properties ?? []
|
|
1362
|
+
})) ?? []]
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
function convertGranularPolicy(granularPolicy, additionalMandatoryMarkings) {
|
|
1366
|
+
return {
|
|
1367
|
+
viewPolicy: {
|
|
1368
|
+
granularPolicyCondition: granularPolicy ? convertSecurityCondition(granularPolicy) : {
|
|
1369
|
+
type: "and",
|
|
1370
|
+
and: {
|
|
1371
|
+
conditions: []
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1374
|
+
additionalMandatory: {
|
|
1375
|
+
markings: additionalMandatoryMarkings ?? {},
|
|
1376
|
+
assumedMarkings: []
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
function convertSecurityCondition(condition) {
|
|
1382
|
+
switch (condition.type) {
|
|
1383
|
+
case "and":
|
|
1384
|
+
if ("conditions" in condition) {
|
|
1385
|
+
return {
|
|
1386
|
+
type: "and",
|
|
1387
|
+
and: {
|
|
1388
|
+
conditions: condition.conditions.map((c) => convertSecurityCondition(c))
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
} else {
|
|
1392
|
+
return condition;
|
|
1393
|
+
}
|
|
1394
|
+
case "or":
|
|
1395
|
+
if ("conditions" in condition) {
|
|
1396
|
+
return {
|
|
1397
|
+
type: "or",
|
|
1398
|
+
or: {
|
|
1399
|
+
conditions: condition.conditions.map((c) => convertSecurityCondition(c))
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
} else {
|
|
1403
|
+
return condition;
|
|
1404
|
+
}
|
|
1405
|
+
case "markingProperty":
|
|
1406
|
+
return {
|
|
1407
|
+
type: "markings",
|
|
1408
|
+
markings: {
|
|
1409
|
+
property: condition.property
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
case "groupProperty":
|
|
1413
|
+
return {
|
|
1414
|
+
type: "comparison",
|
|
1415
|
+
comparison: {
|
|
1416
|
+
operator: "INTERSECTS",
|
|
1417
|
+
left: {
|
|
1418
|
+
type: "userProperty",
|
|
1419
|
+
userProperty: {
|
|
1420
|
+
type: "groupIds",
|
|
1421
|
+
groupIds: {}
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
right: {
|
|
1425
|
+
type: "property",
|
|
1426
|
+
property: condition.property
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
case "group":
|
|
1431
|
+
return {
|
|
1432
|
+
type: "comparison",
|
|
1433
|
+
comparison: {
|
|
1434
|
+
operator: "INTERSECTS",
|
|
1435
|
+
left: {
|
|
1436
|
+
type: "userProperty",
|
|
1437
|
+
userProperty: {
|
|
1438
|
+
type: "groupIds",
|
|
1439
|
+
groupIds: {}
|
|
1440
|
+
}
|
|
1441
|
+
},
|
|
1442
|
+
right: {
|
|
1443
|
+
type: "constant",
|
|
1444
|
+
constant: {
|
|
1445
|
+
type: "strings",
|
|
1446
|
+
strings: [condition.name]
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
default:
|
|
1452
|
+
return condition;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1275
1455
|
function buildPropertyMapping(properties) {
|
|
1276
1456
|
return Object.fromEntries(properties.map((prop) => {
|
|
1277
1457
|
if (prop.editOnly) {
|
|
@@ -1309,7 +1489,7 @@ var defaultTypeClasses = [{
|
|
|
1309
1489
|
name: "SORTABLE"
|
|
1310
1490
|
}];
|
|
1311
1491
|
function shouldNotHaveRenderHints(type) {
|
|
1312
|
-
return ["struct", "mediaReference", "geotimeSeries"].includes(getPropertyTypeName(type));
|
|
1492
|
+
return ["struct", "mediaReference", "geotimeSeries", "attachment"].includes(getPropertyTypeName(type));
|
|
1313
1493
|
}
|
|
1314
1494
|
function hasRenderHints(typeClasses) {
|
|
1315
1495
|
return (typeClasses ?? []).some((tc) => tc.kind.toLowerCase() === "render_hint");
|
|
@@ -1317,6 +1497,10 @@ function hasRenderHints(typeClasses) {
|
|
|
1317
1497
|
function getPropertyTypeName(type) {
|
|
1318
1498
|
return typeof type === "object" ? type.type : type;
|
|
1319
1499
|
}
|
|
1500
|
+
function shouldBeIndexedForSearch(type) {
|
|
1501
|
+
getPropertyTypeName(type);
|
|
1502
|
+
return !["attachment"].includes(getPropertyTypeName(type));
|
|
1503
|
+
}
|
|
1320
1504
|
|
|
1321
1505
|
// src/conversion/toMarketplace/convertValueType.ts
|
|
1322
1506
|
function convertValueType(valueType) {
|
|
@@ -1422,7 +1606,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1422
1606
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1423
1607
|
function convertObjectPropertyType(property) {
|
|
1424
1608
|
const apiName = namespace + property.apiName;
|
|
1425
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1609
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant8__default.default(false) : void 0;
|
|
1426
1610
|
const output = {
|
|
1427
1611
|
apiName: property.apiName,
|
|
1428
1612
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1431,7 +1615,7 @@ function convertObjectPropertyType(property) {
|
|
|
1431
1615
|
description: property.description,
|
|
1432
1616
|
visibility: property.visibility ?? "NORMAL"
|
|
1433
1617
|
},
|
|
1434
|
-
indexedForSearch: property.indexedForSearch ??
|
|
1618
|
+
indexedForSearch: property.indexedForSearch ?? shouldBeIndexedForSearch(property.type),
|
|
1435
1619
|
ruleSetBinding: void 0,
|
|
1436
1620
|
baseFormatter: property.baseFormatter,
|
|
1437
1621
|
type: property.array ? {
|
|
@@ -1501,6 +1685,10 @@ function convertObject(objectType) {
|
|
|
1501
1685
|
entityMetadata: {
|
|
1502
1686
|
arePatchesEnabled: objectType.editsEnabled ?? false,
|
|
1503
1687
|
aliases: objectType.aliases ?? []
|
|
1688
|
+
},
|
|
1689
|
+
propertySecurityGroupPackagingVersion: {
|
|
1690
|
+
type: "v2",
|
|
1691
|
+
v2: {}
|
|
1504
1692
|
}
|
|
1505
1693
|
};
|
|
1506
1694
|
}
|
|
@@ -2343,7 +2531,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2343
2531
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2344
2532
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2345
2533
|
async function main(args = process.argv) {
|
|
2346
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
2534
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.1").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2347
2535
|
input: {
|
|
2348
2536
|
alias: "i",
|
|
2349
2537
|
describe: "Input file",
|
|
@@ -2412,15 +2600,15 @@ async function main(args = process.argv) {
|
|
|
2412
2600
|
let apiNamespace = "";
|
|
2413
2601
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
2414
2602
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
2415
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
2416
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
2603
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "API namespace is too long.") : invariant8__default.default(false) : void 0;
|
|
2604
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant8__default.default(false) : void 0;
|
|
2417
2605
|
}
|
|
2418
2606
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2419
2607
|
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2420
2608
|
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2421
2609
|
}
|
|
2422
2610
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
2423
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
2611
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant8__default.default(false) : void 0;
|
|
2424
2612
|
}
|
|
2425
2613
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
2426
2614
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -2471,37 +2659,37 @@ function defineAction(actionDef) {
|
|
|
2471
2659
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2472
2660
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2473
2661
|
}
|
|
2474
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2662
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant8__default.default(false) : void 0;
|
|
2475
2663
|
const parameterIdsSet = new Set(parameterIds);
|
|
2476
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2664
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Parameter ids must be unique`) : invariant8__default.default(false) : void 0;
|
|
2477
2665
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2478
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2666
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant8__default.default(false) : void 0;
|
|
2479
2667
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2480
2668
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2481
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2482
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2669
|
+
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant8__default.default(false) : void 0;
|
|
2670
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant8__default.default(false) : void 0;
|
|
2483
2671
|
actionDef.rules.forEach((rule) => {
|
|
2484
2672
|
if (rule.type === "modifyObjectRule") {
|
|
2485
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2673
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant8__default.default(false) : void 0;
|
|
2486
2674
|
}
|
|
2487
2675
|
if (rule.type === "deleteObjectRule") {
|
|
2488
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2676
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant8__default.default(false) : void 0;
|
|
2489
2677
|
}
|
|
2490
2678
|
if (rule.type === "modifyInterfaceRule") {
|
|
2491
2679
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2492
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2680
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant8__default.default(false) : void 0;
|
|
2493
2681
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2494
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2682
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant8__default.default(false) : void 0;
|
|
2495
2683
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2496
2684
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2497
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2685
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant8__default.default(false) : void 0;
|
|
2498
2686
|
});
|
|
2499
2687
|
}
|
|
2500
2688
|
if (rule.type === "addInterfaceRule") {
|
|
2501
2689
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2502
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2690
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant8__default.default(false) : void 0;
|
|
2503
2691
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2504
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2692
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant8__default.default(false) : void 0;
|
|
2505
2693
|
});
|
|
2506
2694
|
}
|
|
2507
2695
|
});
|
|
@@ -2966,6 +3154,10 @@ function extractAllowedValuesFromPropertyType(type) {
|
|
|
2966
3154
|
return {
|
|
2967
3155
|
type: "geotimeSeriesReference"
|
|
2968
3156
|
};
|
|
3157
|
+
case "attachment":
|
|
3158
|
+
return {
|
|
3159
|
+
type: "attachment"
|
|
3160
|
+
};
|
|
2969
3161
|
default:
|
|
2970
3162
|
switch (type.type) {
|
|
2971
3163
|
case "marking":
|
|
@@ -3055,9 +3247,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
3055
3247
|
switch (condition.type) {
|
|
3056
3248
|
case "parameter":
|
|
3057
3249
|
const overrideParamId = condition.parameterId;
|
|
3058
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3059
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3060
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3250
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant8__default.default(false) : void 0;
|
|
3251
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant8__default.default(false) : void 0;
|
|
3252
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant8__default.default(false) : void 0;
|
|
3061
3253
|
break;
|
|
3062
3254
|
case "and":
|
|
3063
3255
|
if ("conditions" in condition) {
|
|
@@ -3085,11 +3277,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3085
3277
|
if (!defaultValue) return;
|
|
3086
3278
|
switch (defaultValue.type) {
|
|
3087
3279
|
case "objectParameterPropertyValue":
|
|
3088
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3089
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3280
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant8__default.default(false) : void 0;
|
|
3281
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant8__default.default(false) : void 0;
|
|
3090
3282
|
break;
|
|
3091
3283
|
case "staticValue":
|
|
3092
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
3284
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant8__default.default(false) : void 0;
|
|
3093
3285
|
break;
|
|
3094
3286
|
case "staticObject":
|
|
3095
3287
|
case "interfaceParameterPropertyValue":
|
|
@@ -3104,10 +3296,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3104
3296
|
}
|
|
3105
3297
|
function validateActionParameters(def, properties, name) {
|
|
3106
3298
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3107
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ?
|
|
3299
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant8__default.default(false) : void 0;
|
|
3108
3300
|
});
|
|
3109
3301
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3110
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ?
|
|
3302
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant8__default.default(false) : void 0;
|
|
3111
3303
|
});
|
|
3112
3304
|
}
|
|
3113
3305
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -3117,7 +3309,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
3117
3309
|
const orderingSet = new Set(parameterOrdering);
|
|
3118
3310
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3119
3311
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3120
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
3312
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant8__default.default(false) : void 0;
|
|
3121
3313
|
}
|
|
3122
3314
|
function isTargetParameter(parameterId) {
|
|
3123
3315
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -3533,7 +3725,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3533
3725
|
// src/api/defineInterface.ts
|
|
3534
3726
|
function defineInterface(interfaceDef) {
|
|
3535
3727
|
const apiName = namespace + interfaceDef.apiName;
|
|
3536
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3728
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Interface ${apiName} already exists`) : invariant8__default.default(false) : void 0;
|
|
3537
3729
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
3538
3730
|
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
3539
3731
|
}).map(([s, spt]) => {
|
|
@@ -3566,7 +3758,7 @@ function defineInterface(interfaceDef) {
|
|
|
3566
3758
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
3567
3759
|
type: "active"
|
|
3568
3760
|
});
|
|
3569
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
3761
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant8__default.default(false) : void 0;
|
|
3570
3762
|
const fullInterface = {
|
|
3571
3763
|
apiName,
|
|
3572
3764
|
displayMetadata: {
|
|
@@ -3593,16 +3785,16 @@ function defineInterface(interfaceDef) {
|
|
|
3593
3785
|
}
|
|
3594
3786
|
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
3595
3787
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3596
|
-
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ?
|
|
3597
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3788
|
+
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant8__default.default(false) : void 0;
|
|
3789
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
3598
3790
|
key: apiName,
|
|
3599
3791
|
apiName: type.apiName
|
|
3600
|
-
})}`) :
|
|
3792
|
+
})}`) : invariant8__default.default(false) : void 0;
|
|
3601
3793
|
return type;
|
|
3602
3794
|
}
|
|
3603
3795
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
3604
3796
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
3605
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3797
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant8__default.default(false) : void 0;
|
|
3606
3798
|
linkDef.from.links.push({
|
|
3607
3799
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
3608
3800
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -3865,8 +4057,8 @@ function defineModifyObjectAction(def) {
|
|
|
3865
4057
|
}
|
|
3866
4058
|
function defineSharedPropertyType(sptDef) {
|
|
3867
4059
|
const apiName = namespace + sptDef.apiName;
|
|
3868
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3869
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
4060
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Shared property type ${apiName} already exists`) : invariant8__default.default(false) : void 0;
|
|
4061
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant8__default.default(false) : void 0;
|
|
3870
4062
|
const fullSpt = {
|
|
3871
4063
|
...sptDef,
|
|
3872
4064
|
apiName,
|
|
@@ -3933,10 +4125,10 @@ function defineValueType(valueTypeDef) {
|
|
|
3933
4125
|
} = valueTypeDef;
|
|
3934
4126
|
const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;
|
|
3935
4127
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
3936
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
4128
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "Version is not a valid semver") : invariant8__default.default(false) : void 0;
|
|
3937
4129
|
const existingVersions = ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];
|
|
3938
4130
|
const duplicateVersion = existingVersions.find((vt2) => vt2.version === version);
|
|
3939
|
-
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4131
|
+
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, `Value type with apiName ${apiName} and version ${version} is already defined`) : invariant8__default.default(false) : void 0;
|
|
3940
4132
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
3941
4133
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
3942
4134
|
const output = {
|
|
@@ -4005,8 +4197,8 @@ function importSharedPropertyType(opts) {
|
|
|
4005
4197
|
} = opts;
|
|
4006
4198
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
4007
4199
|
if (packageName !== void 0) {
|
|
4008
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
4009
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
4200
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "Package name format invalid ends with period") : invariant8__default.default(false) : void 0;
|
|
4201
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant8__default.default(false, "Package name includes upper case characters") : invariant8__default.default(false) : void 0;
|
|
4010
4202
|
}
|
|
4011
4203
|
const spt = {
|
|
4012
4204
|
apiName: fullApiName,
|