@osdk/maker 0.16.0-beta.2 → 0.16.0-beta.4
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 +25 -0
- package/README.md +14 -0
- package/build/browser/api/cloneDefinition.js +36 -0
- package/build/browser/api/cloneDefinition.js.map +1 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/browser/api/defineAction.js +3 -1
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateObjectAction.js +3 -1
- package/build/browser/api/defineCreateObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js +3 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteObjectAction.js +3 -1
- package/build/browser/api/defineDeleteObjectAction.js.map +1 -1
- package/build/browser/api/defineInterface.js +3 -1
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +6 -2
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/browser/api/defineLink.js +3 -1
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineModifyObjectAction.js +3 -1
- package/build/browser/api/defineModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +29 -10
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineSpt.js +3 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +3 -1
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/object/ObjectPropertyType.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/properties/ReducerType.js +2 -0
- package/build/browser/api/properties/ReducerType.js.map +1 -0
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
- package/build/browser/api/test/actions.test.js +5 -0
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/objectStatus.test.js +93 -1
- package/build/browser/api/test/objectStatus.test.js.map +1 -1
- package/build/browser/api/test/objects.test.js +576 -0
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +62 -61
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/browser/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/browser/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/cjs/index.cjs +194 -98
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +27 -15
- package/build/esm/api/cloneDefinition.js +36 -0
- package/build/esm/api/cloneDefinition.js.map +1 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/esm/api/defineAction.js +3 -1
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateObjectAction.js +3 -1
- package/build/esm/api/defineCreateObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js +3 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteObjectAction.js +3 -1
- package/build/esm/api/defineDeleteObjectAction.js.map +1 -1
- package/build/esm/api/defineInterface.js +3 -1
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +6 -2
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/esm/api/defineLink.js +3 -1
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineModifyObjectAction.js +3 -1
- package/build/esm/api/defineModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +29 -10
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineSpt.js +3 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +3 -1
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/object/ObjectPropertyType.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/properties/ReducerType.js +2 -0
- package/build/esm/api/properties/ReducerType.js.map +1 -0
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
- package/build/esm/api/test/actions.test.js +5 -0
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/objectStatus.test.js +93 -1
- package/build/esm/api/test/objectStatus.test.js.map +1 -1
- package/build/esm/api/test/objects.test.js +576 -0
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +62 -61
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/esm/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/esm/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/types/api/cloneDefinition.d.ts +9 -0
- package/build/types/api/cloneDefinition.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteObjectAction.d.ts +1 -1
- package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineInterfaceLinkConstraint.d.ts +1 -1
- package/build/types/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
- package/build/types/api/defineLink.d.ts +1 -1
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +3 -1
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/defineValueType.d.ts +1 -1
- package/build/types/api/defineValueType.d.ts.map +1 -1
- package/build/types/api/object/ObjectPropertyType.d.ts +2 -0
- package/build/types/api/object/ObjectPropertyType.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +4 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/properties/ReducerType.d.ts +4 -0
- package/build/types/api/properties/ReducerType.d.ts.map +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts +2 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertReducers.d.ts +6 -0
- package/build/types/conversion/toMarketplace/convertReducers.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertSpt.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertSpt.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts +2 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts.map +1 -1
- package/package.json +3 -3
package/build/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var consola = require('consola');
|
|
6
6
|
var fs3 = require('fs/promises');
|
|
7
7
|
var path3 = require('path');
|
|
8
|
-
var
|
|
8
|
+
var invariant9 = require('tiny-invariant');
|
|
9
9
|
var yargs = require('yargs');
|
|
10
10
|
var helpers = require('yargs/helpers');
|
|
11
11
|
var fs2 = require('fs');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
|
|
36
36
|
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
37
37
|
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
38
|
-
var
|
|
38
|
+
var invariant9__default = /*#__PURE__*/_interopDefault(invariant9);
|
|
39
39
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
40
40
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
41
41
|
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
@@ -217,10 +217,10 @@ function validateLink(linkDefinition) {
|
|
|
217
217
|
object: toManyObject
|
|
218
218
|
} = getObject(linkDefinition.toMany.object);
|
|
219
219
|
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
220
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
221
|
-
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
220
|
+
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`) : invariant9__default.default(false) : void 0;
|
|
221
|
+
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant9__default.default(false) : void 0;
|
|
222
222
|
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
223
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
223
|
+
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant9__default.default(false) : void 0;
|
|
224
224
|
}
|
|
225
225
|
if ("intermediaryObjectType" in linkDefinition) {
|
|
226
226
|
const {
|
|
@@ -235,18 +235,18 @@ function validateLink(linkDefinition) {
|
|
|
235
235
|
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
236
236
|
const {
|
|
237
237
|
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
238
|
-
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
238
|
+
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`) : invariant9__default.default(false) : void 0;
|
|
239
239
|
const {
|
|
240
240
|
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
241
241
|
const {
|
|
242
242
|
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
243
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
243
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`) : invariant9__default.default(false) : void 0;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
function getObject(object) {
|
|
247
247
|
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
248
248
|
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
249
|
-
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
249
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object ${objectApiName} is not defined`) : invariant9__default.default(false) : void 0;
|
|
250
250
|
return {
|
|
251
251
|
apiName: objectApiName,
|
|
252
252
|
object: fullObject
|
|
@@ -282,6 +282,19 @@ function convertLinkStatus(status) {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
// src/api/cloneDefinition.ts
|
|
286
|
+
function cloneDefinition(input) {
|
|
287
|
+
const clone = {
|
|
288
|
+
...input
|
|
289
|
+
};
|
|
290
|
+
for (const key in clone) {
|
|
291
|
+
if (Object.prototype.hasOwnProperty.call(clone, key) && Array.isArray(clone[key])) {
|
|
292
|
+
clone[key] = [...clone[key]];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return clone;
|
|
296
|
+
}
|
|
297
|
+
|
|
285
298
|
// src/api/interface/InterfacePropertyType.ts
|
|
286
299
|
function isInterfaceSharedPropertyType(interfacePropertyType) {
|
|
287
300
|
return "sharedPropertyType" in interfacePropertyType;
|
|
@@ -330,41 +343,47 @@ function isStruct(type) {
|
|
|
330
343
|
var ISO_8601_DURATION = /^P(?!$)(?:(?:((?:\d+Y)|(?:\d+(?:\.|,)\d+Y$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+D)|(?:\d+(?:\.|,)\d+D$))?(T((?:\d+H)|(?:\d+(?:\.|,)\d+H$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+S)|(?:\d+(?:\.|,)\d+S$))?)?)|(?:\d+(?:(?:\.|,)\d+)?W))$/;
|
|
331
344
|
var ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
332
345
|
var API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
333
|
-
function defineObject(
|
|
346
|
+
function defineObject(objectDefInput) {
|
|
347
|
+
const objectDef = cloneDefinition(objectDefInput);
|
|
334
348
|
const apiName = namespace + objectDef.apiName;
|
|
335
349
|
const propertyApiNames = objectDef.properties ? Object.keys(objectDef.properties) : [];
|
|
336
350
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
337
351
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
338
352
|
}
|
|
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" ?
|
|
353
|
+
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant9__default.default(false) : void 0;
|
|
354
|
+
!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;
|
|
355
|
+
!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;
|
|
356
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant9__default.default(false) : void 0;
|
|
343
357
|
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
344
358
|
retentionPeriods.forEach((retentionPeriod) => {
|
|
345
|
-
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ?
|
|
359
|
+
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant9__default.default(false) : void 0;
|
|
346
360
|
});
|
|
347
361
|
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
348
|
-
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ?
|
|
362
|
+
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object ${objectDef.apiName} has more than one base datasource (got: [${baseDatasources.map((ds) => ds.type).join(", ")}])`) : invariant9__default.default(false) : void 0;
|
|
349
363
|
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
350
364
|
if (derivedDatasources.length > 0) {
|
|
351
365
|
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
352
366
|
}
|
|
353
|
-
|
|
354
|
-
|
|
367
|
+
const objectStatusType = getStatusType(objectDef.status);
|
|
368
|
+
if (objectStatusType === "experimental" || objectStatusType === "deprecated" || objectStatusType === "example") {
|
|
369
|
+
const mismatchedProperties = [];
|
|
355
370
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
356
|
-
if (property.status
|
|
357
|
-
|
|
371
|
+
if (property.status !== void 0) {
|
|
372
|
+
const propertyStatusType = getStatusType(property.status);
|
|
373
|
+
if (propertyStatusType !== objectStatusType) {
|
|
374
|
+
mismatchedProperties.push(apiName2);
|
|
375
|
+
}
|
|
358
376
|
}
|
|
359
377
|
});
|
|
360
|
-
!(
|
|
378
|
+
!(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object "${objectDef.apiName}" has "${objectStatusType}" status, but the following properties have a different status: ${mismatchedProperties.join(", ")}`) : invariant9__default.default(false) : void 0;
|
|
361
379
|
}
|
|
362
380
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
363
381
|
const deadline = objectDef.status.deadline;
|
|
364
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
382
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant9__default.default(false) : void 0;
|
|
365
383
|
}
|
|
366
|
-
|
|
367
|
-
|
|
384
|
+
const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
|
|
385
|
+
!(!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;
|
|
386
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant9__default.default(false) : void 0;
|
|
368
387
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
369
388
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
370
389
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -384,7 +403,7 @@ function defineObject(objectDef) {
|
|
|
384
403
|
};
|
|
385
404
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
386
405
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
387
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
406
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant9__default.default(false) : void 0;
|
|
388
407
|
});
|
|
389
408
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
390
409
|
const finalObject = {
|
|
@@ -436,13 +455,13 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
436
455
|
};
|
|
437
456
|
}
|
|
438
457
|
function validateDerivedDatasource(objectDef, datasource) {
|
|
439
|
-
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
458
|
+
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Derived datasource for object '${objectDef.apiName}' must have at least one link.`) : invariant9__default.default(false) : void 0;
|
|
440
459
|
datasource.linkDefinition.forEach((link) => {
|
|
441
460
|
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" ?
|
|
461
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant9__default.default(false) : void 0;
|
|
443
462
|
});
|
|
444
463
|
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
445
|
-
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
464
|
+
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant9__default.default(false) : void 0;
|
|
446
465
|
});
|
|
447
466
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
448
467
|
if (isLinkedProperties) {
|
|
@@ -477,7 +496,7 @@ function validateLinkedProperties(datasource, objectDef) {
|
|
|
477
496
|
hasProperty
|
|
478
497
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
479
498
|
foreignProperties.forEach((prop) => {
|
|
480
|
-
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ?
|
|
499
|
+
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${prop}' on object '${apiName}' is not defined`) : invariant9__default.default(false) : void 0;
|
|
481
500
|
});
|
|
482
501
|
}
|
|
483
502
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -487,18 +506,18 @@ function validateAggregations(datasource, objectDef) {
|
|
|
487
506
|
switch (agg.type) {
|
|
488
507
|
case "collectList":
|
|
489
508
|
case "collectSet":
|
|
490
|
-
!isCollectible(property) ? process.env.NODE_ENV !== "production" ?
|
|
491
|
-
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ?
|
|
509
|
+
!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;
|
|
510
|
+
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`) : invariant9__default.default(false) : void 0;
|
|
492
511
|
break;
|
|
493
512
|
case "avg":
|
|
494
513
|
case "sum":
|
|
495
|
-
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
514
|
+
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not numeric`) : invariant9__default.default(false) : void 0;
|
|
496
515
|
break;
|
|
497
516
|
case "min":
|
|
498
517
|
case "max":
|
|
499
518
|
case "approximateCardinality":
|
|
500
519
|
case "exactCardinality":
|
|
501
|
-
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
520
|
+
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not primitive`) : invariant9__default.default(false) : void 0;
|
|
502
521
|
break;
|
|
503
522
|
}
|
|
504
523
|
if (agg.type !== "count") {
|
|
@@ -508,7 +527,7 @@ function validateAggregations(datasource, objectDef) {
|
|
|
508
527
|
apiName,
|
|
509
528
|
hasProperty
|
|
510
529
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
511
|
-
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ?
|
|
530
|
+
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property '${foreignProperty}' on object '${apiName}' is not defined`) : invariant9__default.default(false) : void 0;
|
|
512
531
|
}
|
|
513
532
|
});
|
|
514
533
|
}
|
|
@@ -527,6 +546,15 @@ function isPrimitive(type) {
|
|
|
527
546
|
const typeType = typeof type === "string" ? type : type.type;
|
|
528
547
|
return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
|
|
529
548
|
}
|
|
549
|
+
function getStatusType(status) {
|
|
550
|
+
if (status === void 0) {
|
|
551
|
+
return "active";
|
|
552
|
+
}
|
|
553
|
+
if (typeof status === "string") {
|
|
554
|
+
return status;
|
|
555
|
+
}
|
|
556
|
+
return status.type;
|
|
557
|
+
}
|
|
530
558
|
|
|
531
559
|
// src/conversion/toMarketplace/convertActionSections.ts
|
|
532
560
|
function convertActionSections(action) {
|
|
@@ -608,7 +636,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
608
636
|
}
|
|
609
637
|
};
|
|
610
638
|
case "parameter":
|
|
611
|
-
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
639
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant9__default.default(false) : void 0;
|
|
612
640
|
return {
|
|
613
641
|
type: "comparison",
|
|
614
642
|
comparison: {
|
|
@@ -833,7 +861,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
833
861
|
}
|
|
834
862
|
};
|
|
835
863
|
}
|
|
836
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
864
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant9__default.default(false) : void 0;
|
|
837
865
|
return {
|
|
838
866
|
propertyTypeConstraints: [],
|
|
839
867
|
nullability: void 0,
|
|
@@ -846,6 +874,39 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
846
874
|
nullabilityV2: prop.nullability
|
|
847
875
|
};
|
|
848
876
|
}
|
|
877
|
+
function convertReducers(type, apiName, reducers, sharedPropertyType) {
|
|
878
|
+
reducers?.forEach((reducer) => {
|
|
879
|
+
if (reducer.structField) {
|
|
880
|
+
!(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;
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
if (sharedPropertyType) {
|
|
884
|
+
return mapReducers(sharedPropertyType.apiName, sharedPropertyType.reducers);
|
|
885
|
+
} else {
|
|
886
|
+
return mapReducers(apiName, reducers);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function mapReducers(apiName, reducers) {
|
|
890
|
+
return reducers?.map((reducer) => {
|
|
891
|
+
switch (reducer.direction) {
|
|
892
|
+
case "ascending":
|
|
893
|
+
return {
|
|
894
|
+
direction: "ASCENDING_NULLS_LAST",
|
|
895
|
+
structApiName: reducer.structField ? apiName : void 0,
|
|
896
|
+
fieldApiName: reducer.structField
|
|
897
|
+
};
|
|
898
|
+
case "descending":
|
|
899
|
+
return {
|
|
900
|
+
direction: "DESCENDING_NULLS_LAST",
|
|
901
|
+
structApiName: reducer.structField ? apiName : void 0,
|
|
902
|
+
fieldApiName: reducer.structField
|
|
903
|
+
};
|
|
904
|
+
default: {
|
|
905
|
+
throw new Error(`Unsupported reducer direction: ${reducer.direction}`);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}) ?? [];
|
|
909
|
+
}
|
|
849
910
|
|
|
850
911
|
// src/conversion/toConjure/distributeTypeHelper.ts
|
|
851
912
|
function distributeTypeHelper(type) {
|
|
@@ -855,8 +916,27 @@ function distributeTypeHelper(type) {
|
|
|
855
916
|
};
|
|
856
917
|
}
|
|
857
918
|
|
|
919
|
+
// src/conversion/toMarketplace/convertMainValue.ts
|
|
920
|
+
function convertMainValue(type, apiName, sharedPropertyType) {
|
|
921
|
+
if (sharedPropertyType && isStruct(sharedPropertyType.type) && sharedPropertyType.type.mainValue) {
|
|
922
|
+
return {
|
|
923
|
+
fieldApiNames: Array.isArray(sharedPropertyType.type.mainValue.fields) ? sharedPropertyType.type.mainValue.fields : [sharedPropertyType.type.mainValue.fields],
|
|
924
|
+
structApiName: sharedPropertyType.apiName,
|
|
925
|
+
type: propertyTypeTypeToOntologyIrType(sharedPropertyType.type.mainValue.type)
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
if (isStruct(type) && type.mainValue) {
|
|
929
|
+
return {
|
|
930
|
+
fieldApiNames: Array.isArray(type.mainValue.fields) ? type.mainValue.fields : [type.mainValue.fields],
|
|
931
|
+
structApiName: apiName,
|
|
932
|
+
type: propertyTypeTypeToOntologyIrType(type.mainValue.type)
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
return void 0;
|
|
936
|
+
}
|
|
937
|
+
|
|
858
938
|
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.ts
|
|
859
|
-
function propertyTypeTypeToOntologyIrType(type) {
|
|
939
|
+
function propertyTypeTypeToOntologyIrType(type, apiName, sharedPropertyType) {
|
|
860
940
|
switch (true) {
|
|
861
941
|
case (typeof type === "object" && type.type === "marking"):
|
|
862
942
|
return {
|
|
@@ -912,7 +992,8 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
912
992
|
return {
|
|
913
993
|
type: "struct",
|
|
914
994
|
struct: {
|
|
915
|
-
structFields
|
|
995
|
+
structFields,
|
|
996
|
+
mainValue: convertMainValue(type, apiName, sharedPropertyType)
|
|
916
997
|
}
|
|
917
998
|
};
|
|
918
999
|
case (typeof type === "object" && type.type === "string"):
|
|
@@ -986,6 +1067,7 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
986
1067
|
function convertSpt({
|
|
987
1068
|
type,
|
|
988
1069
|
array,
|
|
1070
|
+
reducers,
|
|
989
1071
|
description,
|
|
990
1072
|
apiName,
|
|
991
1073
|
displayName,
|
|
@@ -1011,10 +1093,10 @@ function convertSpt({
|
|
|
1011
1093
|
type: array ? {
|
|
1012
1094
|
type: "array",
|
|
1013
1095
|
array: {
|
|
1014
|
-
subtype: propertyTypeTypeToOntologyIrType(type),
|
|
1015
|
-
reducers:
|
|
1096
|
+
subtype: propertyTypeTypeToOntologyIrType(type, apiName),
|
|
1097
|
+
reducers: convertReducers(type, apiName, reducers)
|
|
1016
1098
|
}
|
|
1017
|
-
} : propertyTypeTypeToOntologyIrType(type),
|
|
1099
|
+
} : propertyTypeTypeToOntologyIrType(type, apiName),
|
|
1018
1100
|
aliases: aliases ?? [],
|
|
1019
1101
|
baseFormatter,
|
|
1020
1102
|
dataConstraints: dataConstraint,
|
|
@@ -1327,9 +1409,9 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1327
1409
|
const usedProperties = /* @__PURE__ */ new Set();
|
|
1328
1410
|
ds.propertySecurityGroups?.forEach((psg) => {
|
|
1329
1411
|
psg.properties.forEach((propertyName) => {
|
|
1330
|
-
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1331
|
-
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1332
|
-
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
1412
|
+
!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;
|
|
1413
|
+
!!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;
|
|
1414
|
+
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property "${propertyName}" in property security group ${psg.name} cannot be the primary key`) : invariant9__default.default(false) : void 0;
|
|
1333
1415
|
usedProperties.add(propertyName);
|
|
1334
1416
|
});
|
|
1335
1417
|
});
|
|
@@ -1606,7 +1688,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1606
1688
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1607
1689
|
function convertObjectPropertyType(property) {
|
|
1608
1690
|
const apiName = namespace + property.apiName;
|
|
1609
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1691
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant9__default.default(false) : void 0;
|
|
1610
1692
|
const output = {
|
|
1611
1693
|
apiName: property.apiName,
|
|
1612
1694
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1621,10 +1703,10 @@ function convertObjectPropertyType(property) {
|
|
|
1621
1703
|
type: property.array ? {
|
|
1622
1704
|
type: "array",
|
|
1623
1705
|
array: {
|
|
1624
|
-
subtype: propertyTypeTypeToOntologyIrType(property.type),
|
|
1625
|
-
reducers: []
|
|
1706
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type, property.apiName, property.sharedPropertyType),
|
|
1707
|
+
reducers: convertReducers(property.type, property.apiName, property.reducers ?? [], property.sharedPropertyType)
|
|
1626
1708
|
}
|
|
1627
|
-
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1709
|
+
} : propertyTypeTypeToOntologyIrType(property.type, property.apiName),
|
|
1628
1710
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
1629
1711
|
status: convertObjectStatus(property.status),
|
|
1630
1712
|
inlineAction: void 0,
|
|
@@ -1971,7 +2053,7 @@ function generateInterfaceSnippet(interfaceType, packageName) {
|
|
|
1971
2053
|
"interfaceApiName": interfaceType.apiName,
|
|
1972
2054
|
"packageName": packageName,
|
|
1973
2055
|
"objectOrInterfaceApiName": interfaceType.apiName,
|
|
1974
|
-
"propertyNames": Object.keys(interfaceType.
|
|
2056
|
+
"propertyNames": Object.keys(interfaceType.propertiesV3),
|
|
1975
2057
|
"interfaceName": interfaceType.displayMetadata.displayName
|
|
1976
2058
|
};
|
|
1977
2059
|
return getSnippets(interfaceSnippets, interfaceContext);
|
|
@@ -2531,7 +2613,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2531
2613
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2532
2614
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2533
2615
|
async function main(args = process.argv) {
|
|
2534
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.
|
|
2616
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.4").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2535
2617
|
input: {
|
|
2536
2618
|
alias: "i",
|
|
2537
2619
|
describe: "Input file",
|
|
@@ -2600,15 +2682,15 @@ async function main(args = process.argv) {
|
|
|
2600
2682
|
let apiNamespace = "";
|
|
2601
2683
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
2602
2684
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
2603
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
2604
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
2685
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "API namespace is too long.") : invariant9__default.default(false) : void 0;
|
|
2686
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant9__default.default(false) : void 0;
|
|
2605
2687
|
}
|
|
2606
2688
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2607
2689
|
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2608
2690
|
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2609
2691
|
}
|
|
2610
2692
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
2611
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
2693
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant9__default.default(false) : void 0;
|
|
2612
2694
|
}
|
|
2613
2695
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
2614
2696
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -2653,43 +2735,44 @@ var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
|
2653
2735
|
var DELETE_OBJECT_PARAMETER = "objectToDeleteParameter";
|
|
2654
2736
|
var CREATE_INTERFACE_OBJECT_PARAMETER = "objectTypeParameter";
|
|
2655
2737
|
var MODIFY_INTERFACE_OBJECT_PARAMETER = "interfaceObjectToModifyParameter";
|
|
2656
|
-
function defineAction(
|
|
2738
|
+
function defineAction(actionDefInput) {
|
|
2739
|
+
const actionDef = cloneDefinition(actionDefInput);
|
|
2657
2740
|
const apiName = namespace + actionDef.apiName;
|
|
2658
2741
|
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
2659
2742
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2660
2743
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2661
2744
|
}
|
|
2662
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2745
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant9__default.default(false) : void 0;
|
|
2663
2746
|
const parameterIdsSet = new Set(parameterIds);
|
|
2664
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2747
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter ids must be unique`) : invariant9__default.default(false) : void 0;
|
|
2665
2748
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2666
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2749
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant9__default.default(false) : void 0;
|
|
2667
2750
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2668
2751
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2669
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2670
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2752
|
+
!(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;
|
|
2753
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant9__default.default(false) : void 0;
|
|
2671
2754
|
actionDef.rules.forEach((rule) => {
|
|
2672
2755
|
if (rule.type === "modifyObjectRule") {
|
|
2673
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2756
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant9__default.default(false) : void 0;
|
|
2674
2757
|
}
|
|
2675
2758
|
if (rule.type === "deleteObjectRule") {
|
|
2676
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2759
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant9__default.default(false) : void 0;
|
|
2677
2760
|
}
|
|
2678
2761
|
if (rule.type === "modifyInterfaceRule") {
|
|
2679
2762
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2680
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2763
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant9__default.default(false) : void 0;
|
|
2681
2764
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2682
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2765
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant9__default.default(false) : void 0;
|
|
2683
2766
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2684
2767
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2685
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2768
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant9__default.default(false) : void 0;
|
|
2686
2769
|
});
|
|
2687
2770
|
}
|
|
2688
2771
|
if (rule.type === "addInterfaceRule") {
|
|
2689
2772
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2690
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2773
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant9__default.default(false) : void 0;
|
|
2691
2774
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2692
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2775
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant9__default.default(false) : void 0;
|
|
2693
2776
|
});
|
|
2694
2777
|
}
|
|
2695
2778
|
});
|
|
@@ -3247,9 +3330,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
3247
3330
|
switch (condition.type) {
|
|
3248
3331
|
case "parameter":
|
|
3249
3332
|
const overrideParamId = condition.parameterId;
|
|
3250
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3251
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3252
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3333
|
+
!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;
|
|
3334
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant9__default.default(false) : void 0;
|
|
3335
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant9__default.default(false) : void 0;
|
|
3253
3336
|
break;
|
|
3254
3337
|
case "and":
|
|
3255
3338
|
if ("conditions" in condition) {
|
|
@@ -3277,11 +3360,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3277
3360
|
if (!defaultValue) return;
|
|
3278
3361
|
switch (defaultValue.type) {
|
|
3279
3362
|
case "objectParameterPropertyValue":
|
|
3280
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3281
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3363
|
+
!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;
|
|
3364
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant9__default.default(false) : void 0;
|
|
3282
3365
|
break;
|
|
3283
3366
|
case "staticValue":
|
|
3284
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
3367
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant9__default.default(false) : void 0;
|
|
3285
3368
|
break;
|
|
3286
3369
|
case "staticObject":
|
|
3287
3370
|
case "interfaceParameterPropertyValue":
|
|
@@ -3296,10 +3379,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3296
3379
|
}
|
|
3297
3380
|
function validateActionParameters(def, properties, name) {
|
|
3298
3381
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3299
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ?
|
|
3382
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant9__default.default(false) : void 0;
|
|
3300
3383
|
});
|
|
3301
3384
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3302
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ?
|
|
3385
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant9__default.default(false) : void 0;
|
|
3303
3386
|
});
|
|
3304
3387
|
}
|
|
3305
3388
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -3309,7 +3392,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
3309
3392
|
const orderingSet = new Set(parameterOrdering);
|
|
3310
3393
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3311
3394
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3312
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
3395
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant9__default.default(false) : void 0;
|
|
3313
3396
|
}
|
|
3314
3397
|
function isTargetParameter(parameterId) {
|
|
3315
3398
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -3383,7 +3466,8 @@ function convertMappingValue(value) {
|
|
|
3383
3466
|
}
|
|
3384
3467
|
|
|
3385
3468
|
// src/api/defineCreateInterfaceObjectAction.ts
|
|
3386
|
-
function defineCreateInterfaceObjectAction(
|
|
3469
|
+
function defineCreateInterfaceObjectAction(defInput) {
|
|
3470
|
+
const def = cloneDefinition(defInput);
|
|
3387
3471
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3388
3472
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3389
3473
|
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => isPropertyParameter(def, apiName, getInterfacePropertyTypeType(type)));
|
|
@@ -3473,7 +3557,8 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
3473
3557
|
}
|
|
3474
3558
|
|
|
3475
3559
|
// src/api/defineCreateObjectAction.ts
|
|
3476
|
-
function defineCreateObjectAction(
|
|
3560
|
+
function defineCreateObjectAction(defInput) {
|
|
3561
|
+
const def = cloneDefinition(defInput);
|
|
3477
3562
|
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3478
3563
|
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
3479
3564
|
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && !isStruct(def.objectType.properties?.[id].type) && !propertiesWithDerivedDatasources.includes(id));
|
|
@@ -3538,7 +3623,8 @@ function defineCreateObjectAction(def) {
|
|
|
3538
3623
|
}
|
|
3539
3624
|
|
|
3540
3625
|
// src/api/defineCreateOrModifyObjectAction.ts
|
|
3541
|
-
function defineCreateOrModifyObjectAction(
|
|
3626
|
+
function defineCreateOrModifyObjectAction(defInput) {
|
|
3627
|
+
const def = cloneDefinition(defInput);
|
|
3542
3628
|
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3543
3629
|
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
3544
3630
|
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName && !propertiesWithDerivedDatasources.includes(id));
|
|
@@ -3618,7 +3704,8 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
3618
3704
|
}
|
|
3619
3705
|
|
|
3620
3706
|
// src/api/defineDeleteInterfaceObjectAction.ts
|
|
3621
|
-
function defineDeleteInterfaceObjectAction(
|
|
3707
|
+
function defineDeleteInterfaceObjectAction(defInput) {
|
|
3708
|
+
const def = cloneDefinition(defInput);
|
|
3622
3709
|
return defineAction({
|
|
3623
3710
|
apiName: def.apiName ?? `delete-interface-object-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}`,
|
|
3624
3711
|
displayName: def.displayName ?? `Delete ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -3658,7 +3745,8 @@ function defineDeleteInterfaceObjectAction(def) {
|
|
|
3658
3745
|
}
|
|
3659
3746
|
|
|
3660
3747
|
// src/api/defineDeleteObjectAction.ts
|
|
3661
|
-
function defineDeleteObjectAction(
|
|
3748
|
+
function defineDeleteObjectAction(defInput) {
|
|
3749
|
+
const def = cloneDefinition(defInput);
|
|
3662
3750
|
return defineAction({
|
|
3663
3751
|
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
3664
3752
|
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
@@ -3723,9 +3811,10 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3723
3811
|
}
|
|
3724
3812
|
|
|
3725
3813
|
// src/api/defineInterface.ts
|
|
3726
|
-
function defineInterface(
|
|
3814
|
+
function defineInterface(interfaceDefInput) {
|
|
3815
|
+
const interfaceDef = cloneDefinition(interfaceDefInput);
|
|
3727
3816
|
const apiName = namespace + interfaceDef.apiName;
|
|
3728
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3817
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Interface ${apiName} already exists`) : invariant9__default.default(false) : void 0;
|
|
3729
3818
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
3730
3819
|
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
3731
3820
|
}).map(([s, spt]) => {
|
|
@@ -3758,7 +3847,7 @@ function defineInterface(interfaceDef) {
|
|
|
3758
3847
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
3759
3848
|
type: "active"
|
|
3760
3849
|
});
|
|
3761
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
3850
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant9__default.default(false) : void 0;
|
|
3762
3851
|
const fullInterface = {
|
|
3763
3852
|
apiName,
|
|
3764
3853
|
displayMetadata: {
|
|
@@ -3785,16 +3874,18 @@ function defineInterface(interfaceDef) {
|
|
|
3785
3874
|
}
|
|
3786
3875
|
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
3787
3876
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3788
|
-
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ?
|
|
3789
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3877
|
+
!(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;
|
|
3878
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
3790
3879
|
key: apiName,
|
|
3791
3880
|
apiName: type.apiName
|
|
3792
|
-
})}`) :
|
|
3881
|
+
})}`) : invariant9__default.default(false) : void 0;
|
|
3793
3882
|
return type;
|
|
3794
3883
|
}
|
|
3795
|
-
function defineInterfaceLinkConstraint(
|
|
3884
|
+
function defineInterfaceLinkConstraint(linkDefInput) {
|
|
3885
|
+
const linkDef = cloneDefinition(linkDefInput);
|
|
3886
|
+
!(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;
|
|
3796
3887
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
3797
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3888
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant9__default.default(false) : void 0;
|
|
3798
3889
|
linkDef.from.links.push({
|
|
3799
3890
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
3800
3891
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -3824,7 +3915,8 @@ function getLinkMeta(meta) {
|
|
|
3824
3915
|
}
|
|
3825
3916
|
|
|
3826
3917
|
// src/api/defineLink.ts
|
|
3827
|
-
function defineLink(
|
|
3918
|
+
function defineLink(linkDefinitionInput) {
|
|
3919
|
+
const linkDefinition = cloneDefinition(linkDefinitionInput);
|
|
3828
3920
|
let fullLinkDefinition;
|
|
3829
3921
|
if ("one" in linkDefinition) {
|
|
3830
3922
|
fullLinkDefinition = {
|
|
@@ -3886,7 +3978,8 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
3886
3978
|
}
|
|
3887
3979
|
|
|
3888
3980
|
// src/api/defineModifyInterfaceObjectAction.ts
|
|
3889
|
-
function defineModifyInterfaceObjectAction(
|
|
3981
|
+
function defineModifyInterfaceObjectAction(defInput) {
|
|
3982
|
+
const def = cloneDefinition(defInput);
|
|
3890
3983
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3891
3984
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3892
3985
|
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => {
|
|
@@ -3978,7 +4071,8 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3978
4071
|
}
|
|
3979
4072
|
|
|
3980
4073
|
// src/api/defineModifyObjectAction.ts
|
|
3981
|
-
function defineModifyObjectAction(
|
|
4074
|
+
function defineModifyObjectAction(defInput) {
|
|
4075
|
+
const def = cloneDefinition(defInput);
|
|
3982
4076
|
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3983
4077
|
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
3984
4078
|
const parameterNames = new Set(propertyParameters);
|
|
@@ -4055,10 +4149,11 @@ function defineModifyObjectAction(def) {
|
|
|
4055
4149
|
}
|
|
4056
4150
|
});
|
|
4057
4151
|
}
|
|
4058
|
-
function defineSharedPropertyType(
|
|
4152
|
+
function defineSharedPropertyType(sptDefInput) {
|
|
4153
|
+
const sptDef = cloneDefinition(sptDefInput);
|
|
4059
4154
|
const apiName = namespace + sptDef.apiName;
|
|
4060
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4061
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
4155
|
+
!(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;
|
|
4156
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant9__default.default(false) : void 0;
|
|
4062
4157
|
const fullSpt = {
|
|
4063
4158
|
...sptDef,
|
|
4064
4159
|
apiName,
|
|
@@ -4114,7 +4209,8 @@ function convertValueTypeTypeToBaseType(valueType) {
|
|
|
4114
4209
|
throw new Error("Invalid ValueTypeType");
|
|
4115
4210
|
}
|
|
4116
4211
|
}
|
|
4117
|
-
function defineValueType(
|
|
4212
|
+
function defineValueType(valueTypeDefInput) {
|
|
4213
|
+
const valueTypeDef = cloneDefinition(valueTypeDefInput);
|
|
4118
4214
|
const {
|
|
4119
4215
|
apiName: inputApiName,
|
|
4120
4216
|
displayName,
|
|
@@ -4125,10 +4221,10 @@ function defineValueType(valueTypeDef) {
|
|
|
4125
4221
|
} = valueTypeDef;
|
|
4126
4222
|
const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;
|
|
4127
4223
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
4128
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
4224
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Version is not a valid semver") : invariant9__default.default(false) : void 0;
|
|
4129
4225
|
const existingVersions = ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];
|
|
4130
4226
|
const duplicateVersion = existingVersions.find((vt2) => vt2.version === version);
|
|
4131
|
-
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4227
|
+
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, `Value type with apiName ${apiName} and version ${version} is already defined`) : invariant9__default.default(false) : void 0;
|
|
4132
4228
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
4133
4229
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
4134
4230
|
const output = {
|
|
@@ -4197,8 +4293,8 @@ function importSharedPropertyType(opts) {
|
|
|
4197
4293
|
} = opts;
|
|
4198
4294
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
4199
4295
|
if (packageName !== void 0) {
|
|
4200
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
4201
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
4296
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Package name format invalid ends with period") : invariant9__default.default(false) : void 0;
|
|
4297
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant9__default.default(false, "Package name includes upper case characters") : invariant9__default.default(false) : void 0;
|
|
4202
4298
|
}
|
|
4203
4299
|
const spt = {
|
|
4204
4300
|
apiName: fullApiName,
|