@osdk/maker 0.16.0-beta.9 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +136 -0
- package/build/browser/api/defineFunction.js +6 -5
- package/build/browser/api/defineFunction.js.map +1 -1
- package/build/browser/api/defineInterface.js +3 -0
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineLink.js +3 -0
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineObject.js +9 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/cli/main.js +4 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertLink.js +9 -4
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/browser/util/ApiNameValidator.js +26 -0
- package/build/browser/util/ApiNameValidator.js.map +1 -0
- package/build/cjs/index.cjs +107 -83
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +5 -1
- package/build/esm/api/defineFunction.js +6 -5
- package/build/esm/api/defineFunction.js.map +1 -1
- package/build/esm/api/defineInterface.js +3 -0
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineLink.js +3 -0
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineObject.js +9 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/cli/main.js +4 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertLink.js +9 -4
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/esm/util/ApiNameValidator.js +26 -0
- package/build/esm/util/ApiNameValidator.js.map +1 -0
- package/build/types/api/defineFunction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/interface/InterfaceType.d.ts +1 -1
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
- package/build/types/api/links/LinkType.d.ts +2 -0
- package/build/types/api/links/LinkType.d.ts.map +1 -1
- package/build/types/api/object/ObjectType.d.ts +1 -0
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- package/build/types/util/ApiNameValidator.d.ts +4 -0
- package/build/types/util/ApiNameValidator.d.ts.map +1 -0
- package/package.json +6 -6
- package/build/browser/api/test/actions.test.js +0 -14402
- package/build/browser/api/test/actions.test.js.map +0 -1
- package/build/browser/api/test/interfaces.test.js +0 -1189
- package/build/browser/api/test/interfaces.test.js.map +0 -1
- package/build/browser/api/test/links.test.js +0 -2019
- package/build/browser/api/test/links.test.js.map +0 -1
- package/build/browser/api/test/markingconstraint.test.js +0 -134
- package/build/browser/api/test/markingconstraint.test.js.map +0 -1
- package/build/browser/api/test/misc.test.js +0 -1315
- package/build/browser/api/test/misc.test.js.map +0 -1
- package/build/browser/api/test/objectStatus.test.js +0 -252
- package/build/browser/api/test/objectStatus.test.js.map +0 -1
- package/build/browser/api/test/objects.test.js +0 -4441
- package/build/browser/api/test/objects.test.js.map +0 -1
- package/build/browser/api/test/spt.test.js +0 -751
- package/build/browser/api/test/spt.test.js.map +0 -1
- package/build/browser/api/test/valueTypes.test.js +0 -307
- package/build/browser/api/test/valueTypes.test.js.map +0 -1
- package/build/esm/api/test/actions.test.js +0 -14402
- package/build/esm/api/test/actions.test.js.map +0 -1
- package/build/esm/api/test/interfaces.test.js +0 -1189
- package/build/esm/api/test/interfaces.test.js.map +0 -1
- package/build/esm/api/test/links.test.js +0 -2019
- package/build/esm/api/test/links.test.js.map +0 -1
- package/build/esm/api/test/markingconstraint.test.js +0 -134
- package/build/esm/api/test/markingconstraint.test.js.map +0 -1
- package/build/esm/api/test/misc.test.js +0 -1315
- package/build/esm/api/test/misc.test.js.map +0 -1
- package/build/esm/api/test/objectStatus.test.js +0 -252
- package/build/esm/api/test/objectStatus.test.js.map +0 -1
- package/build/esm/api/test/objects.test.js +0 -4441
- package/build/esm/api/test/objects.test.js.map +0 -1
- package/build/esm/api/test/spt.test.js +0 -751
- package/build/esm/api/test/spt.test.js.map +0 -1
- package/build/esm/api/test/valueTypes.test.js +0 -307
- package/build/esm/api/test/valueTypes.test.js.map +0 -1
- package/build/types/api/test/actions.test.d.ts +0 -1
- package/build/types/api/test/actions.test.d.ts.map +0 -1
- package/build/types/api/test/interfaces.test.d.ts +0 -1
- package/build/types/api/test/interfaces.test.d.ts.map +0 -1
- package/build/types/api/test/links.test.d.ts +0 -1
- package/build/types/api/test/links.test.d.ts.map +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/test/misc.test.d.ts +0 -1
- package/build/types/api/test/misc.test.d.ts.map +0 -1
- package/build/types/api/test/objectStatus.test.d.ts +0 -1
- package/build/types/api/test/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/test/objects.test.d.ts +0 -1
- package/build/types/api/test/objects.test.d.ts.map +0 -1
- package/build/types/api/test/spt.test.d.ts +0 -1
- package/build/types/api/test/spt.test.d.ts.map +0 -1
- package/build/types/api/test/valueTypes.test.d.ts +0 -1
- package/build/types/api/test/valueTypes.test.d.ts.map +0 -1
package/build/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,8 @@ 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 url = require('url');
|
|
9
|
+
var invariant2 = require('tiny-invariant');
|
|
9
10
|
var yargs = require('yargs');
|
|
10
11
|
var helpers = require('yargs/helpers');
|
|
11
12
|
var fs2 = require('fs');
|
|
@@ -35,7 +36,7 @@ function _interopNamespace(e) {
|
|
|
35
36
|
|
|
36
37
|
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
37
38
|
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
38
|
-
var
|
|
39
|
+
var invariant2__default = /*#__PURE__*/_interopDefault(invariant2);
|
|
39
40
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
40
41
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
41
42
|
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
@@ -135,6 +136,11 @@ function convertLink(linkType) {
|
|
|
135
136
|
apiName: toManyObjectApiName,
|
|
136
137
|
object: toManyObject
|
|
137
138
|
} = getObject(linkType.toMany.object);
|
|
139
|
+
const columnA = manyObject.primaryKeyPropertyApiName;
|
|
140
|
+
const columnB = toManyObject.primaryKeyPropertyApiName;
|
|
141
|
+
const hasCollision = columnA === columnB;
|
|
142
|
+
const resolvedColumnA = hasCollision ? `${columnA}_from` : columnA;
|
|
143
|
+
const resolvedColumnB = hasCollision ? `${columnB}_to` : columnB;
|
|
138
144
|
definition = {
|
|
139
145
|
type: "manyToMany",
|
|
140
146
|
manyToMany: {
|
|
@@ -177,14 +183,14 @@ function convertLink(linkType) {
|
|
|
177
183
|
apiName: manyObject.primaryKeyPropertyApiName,
|
|
178
184
|
object: manyObjectApiName
|
|
179
185
|
},
|
|
180
|
-
column:
|
|
186
|
+
column: resolvedColumnA
|
|
181
187
|
}],
|
|
182
188
|
objectTypeBPrimaryKeyMapping: [{
|
|
183
189
|
property: {
|
|
184
190
|
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
185
191
|
object: toManyObjectApiName
|
|
186
192
|
},
|
|
187
|
-
column:
|
|
193
|
+
column: resolvedColumnB
|
|
188
194
|
}]
|
|
189
195
|
}
|
|
190
196
|
},
|
|
@@ -217,10 +223,10 @@ function validateLink(linkDefinition) {
|
|
|
217
223
|
object: toManyObject
|
|
218
224
|
} = getObject(linkDefinition.toMany.object);
|
|
219
225
|
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" ?
|
|
226
|
+
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`) : invariant2__default.default(false) : void 0;
|
|
227
|
+
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant2__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`) : invariant2__default.default(false) : void 0;
|
|
222
228
|
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
223
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
229
|
+
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant2__default.default(false) : void 0;
|
|
224
230
|
}
|
|
225
231
|
if ("intermediaryObjectType" in linkDefinition) {
|
|
226
232
|
const {
|
|
@@ -235,18 +241,18 @@ function validateLink(linkDefinition) {
|
|
|
235
241
|
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
236
242
|
const {
|
|
237
243
|
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
238
|
-
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
244
|
+
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`) : invariant2__default.default(false) : void 0;
|
|
239
245
|
const {
|
|
240
246
|
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
241
247
|
const {
|
|
242
248
|
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
243
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
249
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`) : invariant2__default.default(false) : void 0;
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
function getObject(object) {
|
|
247
253
|
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
248
|
-
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
249
|
-
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
254
|
+
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName] ?? importedTypes[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
255
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Object ${objectApiName} is not defined`) : invariant2__default.default(false) : void 0;
|
|
250
256
|
return {
|
|
251
257
|
apiName: objectApiName,
|
|
252
258
|
object: fullObject
|
|
@@ -282,6 +288,17 @@ function convertLinkStatus(status) {
|
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
290
|
|
|
291
|
+
// src/util/ApiNameValidator.ts
|
|
292
|
+
var RESERVED_KEYWORDS = /* @__PURE__ */ new Set(["ontology", "object", "property", "link", "relation", "rid", "primarykey", "typeid", "ontologyobject"]);
|
|
293
|
+
var OBJECT_API_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9]{0,99}$/;
|
|
294
|
+
var API_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]{0,99}$/;
|
|
295
|
+
function isValidApiName(apiName) {
|
|
296
|
+
return API_NAME_PATTERN.test(apiName) && !RESERVED_KEYWORDS.has(apiName.toLowerCase());
|
|
297
|
+
}
|
|
298
|
+
function isValidObjectApiName(apiName) {
|
|
299
|
+
return OBJECT_API_NAME_PATTERN.test(apiName) && !RESERVED_KEYWORDS.has(apiName.toLowerCase());
|
|
300
|
+
}
|
|
301
|
+
|
|
285
302
|
// src/api/cloneDefinition.ts
|
|
286
303
|
function cloneDefinition(input) {
|
|
287
304
|
const clone = {
|
|
@@ -342,7 +359,6 @@ function isStruct(type) {
|
|
|
342
359
|
// src/api/defineObject.ts
|
|
343
360
|
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))$/;
|
|
344
361
|
var ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
345
|
-
var API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
346
362
|
function defineObject(objectDefInput) {
|
|
347
363
|
const objectDef = cloneDefinition(objectDefInput);
|
|
348
364
|
const apiName = namespace + objectDef.apiName;
|
|
@@ -350,16 +366,23 @@ function defineObject(objectDefInput) {
|
|
|
350
366
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
351
367
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
352
368
|
}
|
|
353
|
-
!
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
369
|
+
!isValidObjectApiName(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${OBJECT_API_NAME_PATTERN}.`) : invariant2__default.default(false) : void 0;
|
|
370
|
+
propertyApiNames.forEach((apiName2) => {
|
|
371
|
+
!isValidApiName(apiName2) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Invalid API name ${apiName2} for property on object ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant2__default.default(false) : void 0;
|
|
372
|
+
});
|
|
373
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant2__default.default(false) : void 0;
|
|
374
|
+
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant2__default.default(false) : void 0;
|
|
375
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant2__default.default(false) : void 0;
|
|
376
|
+
if (objectDef.includeEmptyBackingDatasource && objectDef.datasources) {
|
|
377
|
+
const nonDatasetDatasources = objectDef.datasources.filter((ds) => ds.type !== "dataset");
|
|
378
|
+
!(nonDatasetDatasources.length === 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Object type "${objectDef.apiName}" has non-dataset datasources (${nonDatasetDatasources.map((ds) => ds.type).join(", ")}) and cannot use includeEmptyBackingDatasource. Empty backing datasources are only supported for object types with dataset datasources.`) : invariant2__default.default(false) : void 0;
|
|
379
|
+
}
|
|
357
380
|
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
358
381
|
retentionPeriods.forEach((retentionPeriod) => {
|
|
359
|
-
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ?
|
|
382
|
+
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant2__default.default(false) : void 0;
|
|
360
383
|
});
|
|
361
384
|
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
362
|
-
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ?
|
|
385
|
+
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Object ${objectDef.apiName} has more than one base datasource (got: [${baseDatasources.map((ds) => ds.type).join(", ")}])`) : invariant2__default.default(false) : void 0;
|
|
363
386
|
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
364
387
|
if (derivedDatasources.length > 0) {
|
|
365
388
|
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
@@ -375,15 +398,15 @@ function defineObject(objectDefInput) {
|
|
|
375
398
|
}
|
|
376
399
|
}
|
|
377
400
|
});
|
|
378
|
-
!(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
401
|
+
!(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Object "${objectDef.apiName}" has "${objectStatusType}" status, but the following properties have a different status: ${mismatchedProperties.join(", ")}`) : invariant2__default.default(false) : void 0;
|
|
379
402
|
}
|
|
380
403
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
381
404
|
const deadline = objectDef.status.deadline;
|
|
382
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
405
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant2__default.default(false) : void 0;
|
|
383
406
|
}
|
|
384
407
|
const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
|
|
385
|
-
!(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ?
|
|
386
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
408
|
+
!(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant2__default.default(false) : void 0;
|
|
409
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant2__default.default(false) : void 0;
|
|
387
410
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
388
411
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
389
412
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -403,7 +426,7 @@ function defineObject(objectDefInput) {
|
|
|
403
426
|
};
|
|
404
427
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
405
428
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
406
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
429
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant2__default.default(false) : void 0;
|
|
407
430
|
});
|
|
408
431
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
409
432
|
const finalObject = {
|
|
@@ -455,13 +478,13 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
455
478
|
};
|
|
456
479
|
}
|
|
457
480
|
function validateDerivedDatasource(objectDef, datasource) {
|
|
458
|
-
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
481
|
+
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Derived datasource for object '${objectDef.apiName}' must have at least one link.`) : invariant2__default.default(false) : void 0;
|
|
459
482
|
datasource.linkDefinition.forEach((link) => {
|
|
460
483
|
const linkApiName = link.linkType.apiName;
|
|
461
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
484
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant2__default.default(false) : void 0;
|
|
462
485
|
});
|
|
463
486
|
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
464
|
-
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
487
|
+
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant2__default.default(false) : void 0;
|
|
465
488
|
});
|
|
466
489
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
467
490
|
if (isLinkedProperties) {
|
|
@@ -496,7 +519,7 @@ function validateLinkedProperties(datasource, objectDef) {
|
|
|
496
519
|
hasProperty
|
|
497
520
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
498
521
|
foreignProperties.forEach((prop) => {
|
|
499
|
-
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ?
|
|
522
|
+
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property '${prop}' on object '${apiName}' is not defined`) : invariant2__default.default(false) : void 0;
|
|
500
523
|
});
|
|
501
524
|
}
|
|
502
525
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -506,18 +529,18 @@ function validateAggregations(datasource, objectDef) {
|
|
|
506
529
|
switch (agg.type) {
|
|
507
530
|
case "collectList":
|
|
508
531
|
case "collectSet":
|
|
509
|
-
!isCollectible(property) ? process.env.NODE_ENV !== "production" ?
|
|
510
|
-
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ?
|
|
532
|
+
!isCollectible(property) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not collectible`) : invariant2__default.default(false) : void 0;
|
|
533
|
+
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`) : invariant2__default.default(false) : void 0;
|
|
511
534
|
break;
|
|
512
535
|
case "avg":
|
|
513
536
|
case "sum":
|
|
514
|
-
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
537
|
+
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not numeric`) : invariant2__default.default(false) : void 0;
|
|
515
538
|
break;
|
|
516
539
|
case "min":
|
|
517
540
|
case "max":
|
|
518
541
|
case "approximateCardinality":
|
|
519
542
|
case "exactCardinality":
|
|
520
|
-
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ?
|
|
543
|
+
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not primitive`) : invariant2__default.default(false) : void 0;
|
|
521
544
|
break;
|
|
522
545
|
}
|
|
523
546
|
if (agg.type !== "count") {
|
|
@@ -527,7 +550,7 @@ function validateAggregations(datasource, objectDef) {
|
|
|
527
550
|
apiName,
|
|
528
551
|
hasProperty
|
|
529
552
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
530
|
-
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ?
|
|
553
|
+
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property '${foreignProperty}' on object '${apiName}' is not defined`) : invariant2__default.default(false) : void 0;
|
|
531
554
|
}
|
|
532
555
|
});
|
|
533
556
|
}
|
|
@@ -636,7 +659,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
636
659
|
}
|
|
637
660
|
};
|
|
638
661
|
case "parameter":
|
|
639
|
-
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
662
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant2__default.default(false) : void 0;
|
|
640
663
|
return {
|
|
641
664
|
type: "comparison",
|
|
642
665
|
comparison: {
|
|
@@ -861,7 +884,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
861
884
|
}
|
|
862
885
|
};
|
|
863
886
|
}
|
|
864
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
887
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant2__default.default(false) : void 0;
|
|
865
888
|
return {
|
|
866
889
|
propertyTypeConstraints: [],
|
|
867
890
|
nullability: void 0,
|
|
@@ -877,7 +900,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
877
900
|
function convertReducers(type, apiName, reducers, sharedPropertyType) {
|
|
878
901
|
reducers?.forEach((reducer) => {
|
|
879
902
|
if (reducer.structField) {
|
|
880
|
-
!(isStruct(type) && Object.keys(type.structDefinition).includes(reducer.structField)) ? process.env.NODE_ENV !== "production" ?
|
|
903
|
+
!(isStruct(type) && Object.keys(type.structDefinition).includes(reducer.structField)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Reducer structField ${reducer.structField} does not exist in struct definition`) : invariant2__default.default(false) : void 0;
|
|
881
904
|
}
|
|
882
905
|
});
|
|
883
906
|
if (sharedPropertyType) {
|
|
@@ -1310,7 +1333,8 @@ function convertInterface(interfaceType) {
|
|
|
1310
1333
|
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
1311
1334
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
1312
1335
|
properties: [],
|
|
1313
|
-
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName)))
|
|
1336
|
+
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName))),
|
|
1337
|
+
extendsInterfacesMetadata: interfaceType.extendsInterfaces.map((i) => convertInterface(i))
|
|
1314
1338
|
};
|
|
1315
1339
|
}
|
|
1316
1340
|
function convertDatasourceDefinition(objectType, properties) {
|
|
@@ -1419,9 +1443,9 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1419
1443
|
const usedProperties = /* @__PURE__ */ new Set();
|
|
1420
1444
|
ds.propertySecurityGroups?.forEach((psg) => {
|
|
1421
1445
|
psg.properties.forEach((propertyName) => {
|
|
1422
|
-
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1423
|
-
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1424
|
-
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
1446
|
+
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property "${propertyName}" in property security group ${psg.name} does not exist in the properties list`) : invariant2__default.default(false) : void 0;
|
|
1447
|
+
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property "${propertyName}" is used in multiple property security groups`) : invariant2__default.default(false) : void 0;
|
|
1448
|
+
!(propertyName !== primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property "${propertyName}" in property security group ${psg.name} cannot be the primary key`) : invariant2__default.default(false) : void 0;
|
|
1425
1449
|
usedProperties.add(propertyName);
|
|
1426
1450
|
});
|
|
1427
1451
|
});
|
|
@@ -1699,7 +1723,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1699
1723
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1700
1724
|
function convertObjectPropertyType(property) {
|
|
1701
1725
|
const apiName = namespace + property.apiName;
|
|
1702
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1726
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant2__default.default(false) : void 0;
|
|
1703
1727
|
const output = {
|
|
1704
1728
|
apiName: property.apiName,
|
|
1705
1729
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -2656,7 +2680,7 @@ function getNamespace() {
|
|
|
2656
2680
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2657
2681
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2658
2682
|
async function main(args = process.argv) {
|
|
2659
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0
|
|
2683
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2660
2684
|
input: {
|
|
2661
2685
|
alias: "i",
|
|
2662
2686
|
describe: "Input file",
|
|
@@ -2718,22 +2742,21 @@ async function main(args = process.argv) {
|
|
|
2718
2742
|
},
|
|
2719
2743
|
randomnessKey: {
|
|
2720
2744
|
describe: "Value used to assure uniqueness of entities",
|
|
2721
|
-
type: "string"
|
|
2722
|
-
coerce: path3__namespace.resolve
|
|
2745
|
+
type: "string"
|
|
2723
2746
|
}
|
|
2724
2747
|
}).parseAsync();
|
|
2725
2748
|
let apiNamespace = "";
|
|
2726
2749
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
2727
2750
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
2728
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
2729
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
2751
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "API namespace is too long.") : invariant2__default.default(false) : void 0;
|
|
2752
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant2__default.default(false) : void 0;
|
|
2730
2753
|
}
|
|
2731
2754
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2732
2755
|
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2733
2756
|
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2734
2757
|
}
|
|
2735
2758
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
2736
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
2759
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant2__default.default(false) : void 0;
|
|
2737
2760
|
}
|
|
2738
2761
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
2739
2762
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -2743,7 +2766,7 @@ async function main(args = process.argv) {
|
|
|
2743
2766
|
}
|
|
2744
2767
|
}
|
|
2745
2768
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
2746
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
2769
|
+
const q = await defineOntology(apiNamespace, async () => await import(url.pathToFileURL(input).href), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
2747
2770
|
return q;
|
|
2748
2771
|
}
|
|
2749
2772
|
var MAX_SEARCH_DEPTH = 5;
|
|
@@ -2785,37 +2808,37 @@ function defineAction(actionDefInput) {
|
|
|
2785
2808
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2786
2809
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2787
2810
|
}
|
|
2788
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2811
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant2__default.default(false) : void 0;
|
|
2789
2812
|
const parameterIdsSet = new Set(parameterIds);
|
|
2790
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2813
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Parameter ids must be unique`) : invariant2__default.default(false) : void 0;
|
|
2791
2814
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2792
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2815
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant2__default.default(false) : void 0;
|
|
2793
2816
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2794
2817
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2795
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2796
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2818
|
+
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant2__default.default(false) : void 0;
|
|
2819
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant2__default.default(false) : void 0;
|
|
2797
2820
|
actionDef.rules.forEach((rule) => {
|
|
2798
2821
|
if (rule.type === "modifyObjectRule") {
|
|
2799
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2822
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant2__default.default(false) : void 0;
|
|
2800
2823
|
}
|
|
2801
2824
|
if (rule.type === "deleteObjectRule") {
|
|
2802
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2825
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant2__default.default(false) : void 0;
|
|
2803
2826
|
}
|
|
2804
2827
|
if (rule.type === "modifyInterfaceRule") {
|
|
2805
2828
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2806
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2829
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant2__default.default(false) : void 0;
|
|
2807
2830
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2808
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2831
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant2__default.default(false) : void 0;
|
|
2809
2832
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2810
2833
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2811
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2834
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant2__default.default(false) : void 0;
|
|
2812
2835
|
});
|
|
2813
2836
|
}
|
|
2814
2837
|
if (rule.type === "addInterfaceRule") {
|
|
2815
2838
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2816
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2839
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant2__default.default(false) : void 0;
|
|
2817
2840
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2818
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2841
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant2__default.default(false) : void 0;
|
|
2819
2842
|
});
|
|
2820
2843
|
}
|
|
2821
2844
|
});
|
|
@@ -3379,9 +3402,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
3379
3402
|
switch (condition.type) {
|
|
3380
3403
|
case "parameter":
|
|
3381
3404
|
const overrideParamId = condition.parameterId;
|
|
3382
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3383
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3384
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3405
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant2__default.default(false) : void 0;
|
|
3406
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant2__default.default(false) : void 0;
|
|
3407
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant2__default.default(false) : void 0;
|
|
3385
3408
|
break;
|
|
3386
3409
|
case "and":
|
|
3387
3410
|
if ("conditions" in condition) {
|
|
@@ -3409,11 +3432,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3409
3432
|
if (!defaultValue) return;
|
|
3410
3433
|
switch (defaultValue.type) {
|
|
3411
3434
|
case "objectParameterPropertyValue":
|
|
3412
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3413
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3435
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant2__default.default(false) : void 0;
|
|
3436
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant2__default.default(false) : void 0;
|
|
3414
3437
|
break;
|
|
3415
3438
|
case "staticValue":
|
|
3416
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
3439
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant2__default.default(false) : void 0;
|
|
3417
3440
|
break;
|
|
3418
3441
|
case "staticObject":
|
|
3419
3442
|
case "interfaceParameterPropertyValue":
|
|
@@ -3428,10 +3451,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3428
3451
|
}
|
|
3429
3452
|
function validateActionParameters(def, properties, name) {
|
|
3430
3453
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3431
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ?
|
|
3454
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant2__default.default(false) : void 0;
|
|
3432
3455
|
});
|
|
3433
3456
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3434
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ?
|
|
3457
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || properties.includes(withoutNamespace(id))) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant2__default.default(false) : void 0;
|
|
3435
3458
|
});
|
|
3436
3459
|
}
|
|
3437
3460
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -3441,7 +3464,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
3441
3464
|
const orderingSet = new Set(parameterOrdering);
|
|
3442
3465
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3443
3466
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3444
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
3467
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant2__default.default(false) : void 0;
|
|
3445
3468
|
}
|
|
3446
3469
|
function isTargetParameter(parameterId) {
|
|
3447
3470
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -3863,7 +3886,8 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3863
3886
|
function defineInterface(interfaceDefInput) {
|
|
3864
3887
|
const interfaceDef = cloneDefinition(interfaceDefInput);
|
|
3865
3888
|
const apiName = namespace + interfaceDef.apiName;
|
|
3866
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3889
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Interface ${apiName} already exists`) : invariant2__default.default(false) : void 0;
|
|
3890
|
+
!isValidApiName(interfaceDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Invalid API name ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant2__default.default(false) : void 0;
|
|
3867
3891
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
3868
3892
|
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
3869
3893
|
}).map(([s, spt]) => {
|
|
@@ -3881,6 +3905,7 @@ function defineInterface(interfaceDefInput) {
|
|
|
3881
3905
|
}];
|
|
3882
3906
|
}));
|
|
3883
3907
|
const propertiesV3 = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([apiName2, prop]) => {
|
|
3908
|
+
!isValidApiName(apiName2) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Invalid API name ${apiName2} for property on interface ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant2__default.default(false) : void 0;
|
|
3884
3909
|
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
3885
3910
|
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
3886
3911
|
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
@@ -3896,7 +3921,7 @@ function defineInterface(interfaceDefInput) {
|
|
|
3896
3921
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
3897
3922
|
type: "active"
|
|
3898
3923
|
});
|
|
3899
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
3924
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant2__default.default(false) : void 0;
|
|
3900
3925
|
const fullInterface = {
|
|
3901
3926
|
apiName,
|
|
3902
3927
|
displayMetadata: {
|
|
@@ -3923,18 +3948,18 @@ function defineInterface(interfaceDefInput) {
|
|
|
3923
3948
|
}
|
|
3924
3949
|
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
3925
3950
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
3926
|
-
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ?
|
|
3927
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3951
|
+
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant2__default.default(false) : void 0;
|
|
3952
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
3928
3953
|
key: apiName,
|
|
3929
3954
|
apiName: type.apiName
|
|
3930
|
-
})}`) :
|
|
3955
|
+
})}`) : invariant2__default.default(false) : void 0;
|
|
3931
3956
|
return type;
|
|
3932
3957
|
}
|
|
3933
3958
|
function defineInterfaceLinkConstraint(linkDefInput) {
|
|
3934
3959
|
const linkDef = cloneDefinition(linkDefInput);
|
|
3935
|
-
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][linkDef.from.apiName] == null) ? process.env.NODE_ENV !== "production" ?
|
|
3960
|
+
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][linkDef.from.apiName] == null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Cannot define a link constraint from imported interface ${linkDef.from.apiName}. The "from" side must be a locally defined interface.`) : invariant2__default.default(false) : void 0;
|
|
3936
3961
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
3937
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3962
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant2__default.default(false) : void 0;
|
|
3938
3963
|
linkDef.from.links.push({
|
|
3939
3964
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
3940
3965
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -3962,8 +3987,6 @@ function getLinkMeta(meta) {
|
|
|
3962
3987
|
description: description ?? displayName ?? apiNameWithoutNamespace
|
|
3963
3988
|
};
|
|
3964
3989
|
}
|
|
3965
|
-
|
|
3966
|
-
// src/api/defineLink.ts
|
|
3967
3990
|
function defineLink(linkDefinitionInput) {
|
|
3968
3991
|
const linkDefinition = cloneDefinition(linkDefinitionInput);
|
|
3969
3992
|
let fullLinkDefinition;
|
|
@@ -4014,6 +4037,7 @@ function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
|
4014
4037
|
};
|
|
4015
4038
|
}
|
|
4016
4039
|
function convertLinkTypeMetadata(metadata) {
|
|
4040
|
+
!isValidApiName(metadata.apiName) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Invalid API name for link: ${metadata.apiName}`) : invariant2__default.default(false) : void 0;
|
|
4017
4041
|
return {
|
|
4018
4042
|
apiName: metadata.apiName,
|
|
4019
4043
|
displayMetadata: {
|
|
@@ -4201,8 +4225,8 @@ function defineModifyObjectAction(defInput) {
|
|
|
4201
4225
|
function defineSharedPropertyType(sptDefInput) {
|
|
4202
4226
|
const sptDef = cloneDefinition(sptDefInput);
|
|
4203
4227
|
const apiName = namespace + sptDef.apiName;
|
|
4204
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4205
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
4228
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Shared property type ${apiName} already exists`) : invariant2__default.default(false) : void 0;
|
|
4229
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant2__default.default(false) : void 0;
|
|
4206
4230
|
const fullSpt = {
|
|
4207
4231
|
...sptDef,
|
|
4208
4232
|
apiName,
|
|
@@ -4270,10 +4294,10 @@ function defineValueType(valueTypeDefInput) {
|
|
|
4270
4294
|
} = valueTypeDef;
|
|
4271
4295
|
const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;
|
|
4272
4296
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
4273
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
4297
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Version is not a valid semver") : invariant2__default.default(false) : void 0;
|
|
4274
4298
|
const existingVersions = ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];
|
|
4275
4299
|
const duplicateVersion = existingVersions.find((vt2) => vt2.version === version);
|
|
4276
|
-
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4300
|
+
!(duplicateVersion === void 0) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Value type with apiName ${apiName} and version ${version} is already defined`) : invariant2__default.default(false) : void 0;
|
|
4277
4301
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
4278
4302
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
4279
4303
|
const output = {
|
|
@@ -4342,8 +4366,8 @@ function importSharedPropertyType(opts) {
|
|
|
4342
4366
|
} = opts;
|
|
4343
4367
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
4344
4368
|
if (packageName !== void 0) {
|
|
4345
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
4346
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
4369
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Package name format invalid ends with period") : invariant2__default.default(false) : void 0;
|
|
4370
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Package name includes upper case characters") : invariant2__default.default(false) : void 0;
|
|
4347
4371
|
}
|
|
4348
4372
|
const spt = {
|
|
4349
4373
|
apiName: fullApiName,
|