@osdk/maker 0.16.0-beta.8 → 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 +142 -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 -147
- 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 -218
- 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 -147
- 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 -7
- 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/cjs/defineFunction-7ORD7HD4.cjs +0 -72
- package/build/cjs/defineFunction-7ORD7HD4.cjs.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
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var generatorConverters_ontologyir = require('@osdk/generator-converters.ontologyir');
|
|
6
5
|
var consola = require('consola');
|
|
7
|
-
var execa = require('execa');
|
|
8
|
-
var jiti = require('jiti');
|
|
9
6
|
var fs3 = require('fs/promises');
|
|
10
7
|
var path3 = require('path');
|
|
11
|
-
var
|
|
8
|
+
var url = require('url');
|
|
9
|
+
var invariant2 = require('tiny-invariant');
|
|
12
10
|
var yargs = require('yargs');
|
|
13
11
|
var helpers = require('yargs/helpers');
|
|
14
12
|
var fs2 = require('fs');
|
|
@@ -16,7 +14,6 @@ var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
|
|
|
16
14
|
var Mustache = require('mustache');
|
|
17
15
|
var crypto = require('crypto');
|
|
18
16
|
|
|
19
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
20
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
18
|
|
|
22
19
|
function _interopNamespace(e) {
|
|
@@ -39,7 +36,7 @@ function _interopNamespace(e) {
|
|
|
39
36
|
|
|
40
37
|
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
41
38
|
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
42
|
-
var
|
|
39
|
+
var invariant2__default = /*#__PURE__*/_interopDefault(invariant2);
|
|
43
40
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
44
41
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
45
42
|
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
@@ -139,6 +136,11 @@ function convertLink(linkType) {
|
|
|
139
136
|
apiName: toManyObjectApiName,
|
|
140
137
|
object: toManyObject
|
|
141
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;
|
|
142
144
|
definition = {
|
|
143
145
|
type: "manyToMany",
|
|
144
146
|
manyToMany: {
|
|
@@ -181,14 +183,14 @@ function convertLink(linkType) {
|
|
|
181
183
|
apiName: manyObject.primaryKeyPropertyApiName,
|
|
182
184
|
object: manyObjectApiName
|
|
183
185
|
},
|
|
184
|
-
column:
|
|
186
|
+
column: resolvedColumnA
|
|
185
187
|
}],
|
|
186
188
|
objectTypeBPrimaryKeyMapping: [{
|
|
187
189
|
property: {
|
|
188
190
|
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
189
191
|
object: toManyObjectApiName
|
|
190
192
|
},
|
|
191
|
-
column:
|
|
193
|
+
column: resolvedColumnB
|
|
192
194
|
}]
|
|
193
195
|
}
|
|
194
196
|
},
|
|
@@ -221,10 +223,10 @@ function validateLink(linkDefinition) {
|
|
|
221
223
|
object: toManyObject
|
|
222
224
|
} = getObject(linkDefinition.toMany.object);
|
|
223
225
|
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
224
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
225
|
-
!/([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;
|
|
226
228
|
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
227
|
-
!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;
|
|
228
230
|
}
|
|
229
231
|
if ("intermediaryObjectType" in linkDefinition) {
|
|
230
232
|
const {
|
|
@@ -239,18 +241,18 @@ function validateLink(linkDefinition) {
|
|
|
239
241
|
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
240
242
|
const {
|
|
241
243
|
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
242
|
-
!("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;
|
|
243
245
|
const {
|
|
244
246
|
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
245
247
|
const {
|
|
246
248
|
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
247
|
-
!("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;
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
function getObject(object) {
|
|
251
253
|
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
252
|
-
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
253
|
-
!(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;
|
|
254
256
|
return {
|
|
255
257
|
apiName: objectApiName,
|
|
256
258
|
object: fullObject
|
|
@@ -286,6 +288,17 @@ function convertLinkStatus(status) {
|
|
|
286
288
|
}
|
|
287
289
|
}
|
|
288
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
|
+
|
|
289
302
|
// src/api/cloneDefinition.ts
|
|
290
303
|
function cloneDefinition(input) {
|
|
291
304
|
const clone = {
|
|
@@ -346,7 +359,6 @@ function isStruct(type) {
|
|
|
346
359
|
// src/api/defineObject.ts
|
|
347
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))$/;
|
|
348
361
|
var ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
349
|
-
var API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
350
362
|
function defineObject(objectDefInput) {
|
|
351
363
|
const objectDef = cloneDefinition(objectDefInput);
|
|
352
364
|
const apiName = namespace + objectDef.apiName;
|
|
@@ -354,16 +366,23 @@ function defineObject(objectDefInput) {
|
|
|
354
366
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
355
367
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
356
368
|
}
|
|
357
|
-
!
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
+
}
|
|
361
380
|
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
362
381
|
retentionPeriods.forEach((retentionPeriod) => {
|
|
363
|
-
!(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;
|
|
364
383
|
});
|
|
365
384
|
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
366
|
-
!(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;
|
|
367
386
|
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
368
387
|
if (derivedDatasources.length > 0) {
|
|
369
388
|
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
@@ -379,15 +398,15 @@ function defineObject(objectDefInput) {
|
|
|
379
398
|
}
|
|
380
399
|
}
|
|
381
400
|
});
|
|
382
|
-
!(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;
|
|
383
402
|
}
|
|
384
403
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
385
404
|
const deadline = objectDef.status.deadline;
|
|
386
|
-
!(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;
|
|
387
406
|
}
|
|
388
407
|
const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
|
|
389
|
-
!(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ?
|
|
390
|
-
!!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;
|
|
391
410
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
392
411
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
393
412
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0 && allInterfaceProperties[withoutNamespace(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -407,7 +426,7 @@ function defineObject(objectDefInput) {
|
|
|
407
426
|
};
|
|
408
427
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
409
428
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
410
|
-
!(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;
|
|
411
430
|
});
|
|
412
431
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
413
432
|
const finalObject = {
|
|
@@ -459,13 +478,13 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
459
478
|
};
|
|
460
479
|
}
|
|
461
480
|
function validateDerivedDatasource(objectDef, datasource) {
|
|
462
|
-
!(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;
|
|
463
482
|
datasource.linkDefinition.forEach((link) => {
|
|
464
483
|
const linkApiName = link.linkType.apiName;
|
|
465
|
-
!(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;
|
|
466
485
|
});
|
|
467
486
|
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
468
|
-
!(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;
|
|
469
488
|
});
|
|
470
489
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
471
490
|
if (isLinkedProperties) {
|
|
@@ -500,7 +519,7 @@ function validateLinkedProperties(datasource, objectDef) {
|
|
|
500
519
|
hasProperty
|
|
501
520
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
502
521
|
foreignProperties.forEach((prop) => {
|
|
503
|
-
!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;
|
|
504
523
|
});
|
|
505
524
|
}
|
|
506
525
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -510,18 +529,18 @@ function validateAggregations(datasource, objectDef) {
|
|
|
510
529
|
switch (agg.type) {
|
|
511
530
|
case "collectList":
|
|
512
531
|
case "collectSet":
|
|
513
|
-
!isCollectible(property) ? process.env.NODE_ENV !== "production" ?
|
|
514
|
-
!(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;
|
|
515
534
|
break;
|
|
516
535
|
case "avg":
|
|
517
536
|
case "sum":
|
|
518
|
-
!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;
|
|
519
538
|
break;
|
|
520
539
|
case "min":
|
|
521
540
|
case "max":
|
|
522
541
|
case "approximateCardinality":
|
|
523
542
|
case "exactCardinality":
|
|
524
|
-
!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;
|
|
525
544
|
break;
|
|
526
545
|
}
|
|
527
546
|
if (agg.type !== "count") {
|
|
@@ -531,7 +550,7 @@ function validateAggregations(datasource, objectDef) {
|
|
|
531
550
|
apiName,
|
|
532
551
|
hasProperty
|
|
533
552
|
} = getPropertiesForValidation(targetObject, objectDef);
|
|
534
|
-
!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;
|
|
535
554
|
}
|
|
536
555
|
});
|
|
537
556
|
}
|
|
@@ -640,7 +659,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
640
659
|
}
|
|
641
660
|
};
|
|
642
661
|
case "parameter":
|
|
643
|
-
!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;
|
|
644
663
|
return {
|
|
645
664
|
type: "comparison",
|
|
646
665
|
comparison: {
|
|
@@ -865,7 +884,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
865
884
|
}
|
|
866
885
|
};
|
|
867
886
|
}
|
|
868
|
-
!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;
|
|
869
888
|
return {
|
|
870
889
|
propertyTypeConstraints: [],
|
|
871
890
|
nullability: void 0,
|
|
@@ -881,7 +900,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
881
900
|
function convertReducers(type, apiName, reducers, sharedPropertyType) {
|
|
882
901
|
reducers?.forEach((reducer) => {
|
|
883
902
|
if (reducer.structField) {
|
|
884
|
-
!(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;
|
|
885
904
|
}
|
|
886
905
|
});
|
|
887
906
|
if (sharedPropertyType) {
|
|
@@ -1314,7 +1333,8 @@ function convertInterface(interfaceType) {
|
|
|
1314
1333
|
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
1315
1334
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
1316
1335
|
properties: [],
|
|
1317
|
-
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))
|
|
1318
1338
|
};
|
|
1319
1339
|
}
|
|
1320
1340
|
function convertDatasourceDefinition(objectType, properties) {
|
|
@@ -1423,9 +1443,9 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1423
1443
|
const usedProperties = /* @__PURE__ */ new Set();
|
|
1424
1444
|
ds.propertySecurityGroups?.forEach((psg) => {
|
|
1425
1445
|
psg.properties.forEach((propertyName) => {
|
|
1426
|
-
!validPropertyNames.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1427
|
-
!!usedProperties.has(propertyName) ? process.env.NODE_ENV !== "production" ?
|
|
1428
|
-
!(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;
|
|
1429
1449
|
usedProperties.add(propertyName);
|
|
1430
1450
|
});
|
|
1431
1451
|
});
|
|
@@ -1703,7 +1723,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1703
1723
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1704
1724
|
function convertObjectPropertyType(property) {
|
|
1705
1725
|
const apiName = namespace + property.apiName;
|
|
1706
|
-
!(!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;
|
|
1707
1727
|
const output = {
|
|
1708
1728
|
apiName: property.apiName,
|
|
1709
1729
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -2657,21 +2677,10 @@ function getNamespace() {
|
|
|
2657
2677
|
}
|
|
2658
2678
|
|
|
2659
2679
|
// src/cli/main.ts
|
|
2660
|
-
var generateFunctionsIr;
|
|
2661
|
-
async function loadFunctionDiscoveryDeps() {
|
|
2662
|
-
try {
|
|
2663
|
-
const defineFunctionModule = await import('./defineFunction-7ORD7HD4.cjs');
|
|
2664
|
-
generateFunctionsIr = defineFunctionModule.generateFunctionsIr;
|
|
2665
|
-
return true;
|
|
2666
|
-
} catch (e) {
|
|
2667
|
-
consola.consola.warn("Failed to load function discovery dependencies:", e instanceof Error ? e.message : e);
|
|
2668
|
-
return false;
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
2680
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2672
2681
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2673
2682
|
async function main(args = process.argv) {
|
|
2674
|
-
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({
|
|
2675
2684
|
input: {
|
|
2676
2685
|
alias: "i",
|
|
2677
2686
|
describe: "Input file",
|
|
@@ -2733,57 +2742,21 @@ async function main(args = process.argv) {
|
|
|
2733
2742
|
},
|
|
2734
2743
|
randomnessKey: {
|
|
2735
2744
|
describe: "Value used to assure uniqueness of entities",
|
|
2736
|
-
type: "string"
|
|
2737
|
-
coerce: path3__namespace.resolve
|
|
2738
|
-
},
|
|
2739
|
-
generateFunctionsOsdk: {
|
|
2740
|
-
describe: "Output folder for generated OSDK for functions",
|
|
2741
|
-
type: "string",
|
|
2742
|
-
coerce: path3__namespace.resolve
|
|
2743
|
-
},
|
|
2744
|
-
functionsRootDir: {
|
|
2745
|
-
describe: "Root folder containing function definitions",
|
|
2746
|
-
type: "string",
|
|
2747
|
-
coerce: path3__namespace.resolve
|
|
2748
|
-
},
|
|
2749
|
-
functionsOutput: {
|
|
2750
|
-
describe: "Output folder for function IR",
|
|
2751
|
-
type: "string",
|
|
2752
|
-
coerce: path3__namespace.resolve
|
|
2753
|
-
},
|
|
2754
|
-
configPath: {
|
|
2755
|
-
describe: "Path to the TypeScript config file",
|
|
2756
|
-
type: "string",
|
|
2757
|
-
coerce: path3__namespace.resolve
|
|
2758
|
-
},
|
|
2759
|
-
pythonFunctionsDir: {
|
|
2760
|
-
describe: "Path to Python functions source directory (enables Python function discovery)",
|
|
2761
|
-
type: "string",
|
|
2762
|
-
coerce: path3__namespace.resolve
|
|
2763
|
-
},
|
|
2764
|
-
pythonBinary: {
|
|
2765
|
-
describe: "Path to Python binary (required when using --pythonFunctionsDir)",
|
|
2766
|
-
type: "string",
|
|
2767
|
-
coerce: path3__namespace.resolve
|
|
2768
|
-
},
|
|
2769
|
-
pythonRootProjectDir: {
|
|
2770
|
-
describe: "Root project directory for Python functions (defaults to parent of pythonFunctionsDir)",
|
|
2771
|
-
type: "string",
|
|
2772
|
-
coerce: path3__namespace.resolve
|
|
2745
|
+
type: "string"
|
|
2773
2746
|
}
|
|
2774
2747
|
}).parseAsync();
|
|
2775
2748
|
let apiNamespace = "";
|
|
2776
2749
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
2777
2750
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
2778
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
2779
|
-
!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;
|
|
2780
2753
|
}
|
|
2781
2754
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2782
2755
|
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2783
2756
|
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2784
2757
|
}
|
|
2785
2758
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
2786
|
-
!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;
|
|
2787
2760
|
}
|
|
2788
2761
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
2789
2762
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -2791,96 +2764,11 @@ async function main(args = process.argv) {
|
|
|
2791
2764
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
2792
2765
|
await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
2793
2766
|
}
|
|
2794
|
-
if (commandLineOpts.pythonFunctionsDir && !commandLineOpts.pythonBinary) {
|
|
2795
|
-
consola.consola.error("--pythonBinary is required when using --pythonFunctionsDir");
|
|
2796
|
-
return;
|
|
2797
|
-
}
|
|
2798
|
-
if (commandLineOpts.functionsOutput !== void 0 && commandLineOpts.functionsRootDir !== void 0) {
|
|
2799
|
-
const hasFunctionDeps = await loadFunctionDiscoveryDeps();
|
|
2800
|
-
if (!hasFunctionDeps || !generateFunctionsIr) {
|
|
2801
|
-
consola.consola.error("Function discovery requires optional dependencies. Install @foundry/functions-typescript-* packages.");
|
|
2802
|
-
return;
|
|
2803
|
-
}
|
|
2804
|
-
consola.consola.info(`Loading function IR`);
|
|
2805
|
-
const functionsIr = await generateFunctionsIr(commandLineOpts.functionsRootDir, commandLineOpts.configPath, createEntityMappings(ontologyIr));
|
|
2806
|
-
await fs3__namespace.writeFile(commandLineOpts.functionsOutput, JSON.stringify(functionsIr, null, 2));
|
|
2807
|
-
return;
|
|
2808
|
-
}
|
|
2809
|
-
if (commandLineOpts.generateFunctionsOsdk !== void 0) {
|
|
2810
|
-
const fullMetadata = generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ontologyIr.ontology);
|
|
2811
|
-
if (commandLineOpts.pythonFunctionsDir) {
|
|
2812
|
-
const effectivePythonRootDir = commandLineOpts.pythonRootProjectDir ?? path3__namespace.dirname(commandLineOpts.pythonFunctionsDir);
|
|
2813
|
-
const queryTypes = await generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getOsdkQueryTypes(commandLineOpts.pythonBinary, void 0, void 0, commandLineOpts.pythonFunctionsDir, effectivePythonRootDir);
|
|
2814
|
-
const functionNames = Object.keys(queryTypes);
|
|
2815
|
-
if (functionNames.length > 0) {
|
|
2816
|
-
fullMetadata.queryTypes = queryTypes;
|
|
2817
|
-
consola.consola.info(`Discovered ${functionNames.length} Python function(s): ${functionNames.join(", ")}`);
|
|
2818
|
-
} else {
|
|
2819
|
-
consola.consola.info("No Python functions discovered.");
|
|
2820
|
-
}
|
|
2821
|
-
}
|
|
2822
|
-
consola.consola.info(`Saving full ontology metadata to ${commandLineOpts.generateFunctionsOsdk}`);
|
|
2823
|
-
await fs3__namespace.writeFile(path3__namespace.join(commandLineOpts.generateFunctionsOsdk, ".ontology.json"), JSON.stringify(fullMetadata, null, 2));
|
|
2824
|
-
await fullMetadataToOsdk(commandLineOpts.generateFunctionsOsdk);
|
|
2825
|
-
}
|
|
2826
2767
|
}
|
|
2827
2768
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
2828
|
-
const q = await defineOntology(apiNamespace, async () =>
|
|
2829
|
-
const jiti$1 = jiti.createJiti(undefined, {
|
|
2830
|
-
moduleCache: true,
|
|
2831
|
-
debug: false,
|
|
2832
|
-
importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })
|
|
2833
|
-
});
|
|
2834
|
-
await jiti$1.import(input);
|
|
2835
|
-
}, 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);
|
|
2836
2770
|
return q;
|
|
2837
2771
|
}
|
|
2838
|
-
async function fullMetadataToOsdk(workDir) {
|
|
2839
|
-
const functionOsdkDir = path3__namespace.join(workDir, "generated");
|
|
2840
|
-
await fs3__namespace.rm(functionOsdkDir, {
|
|
2841
|
-
recursive: true,
|
|
2842
|
-
force: true
|
|
2843
|
-
});
|
|
2844
|
-
await fs3__namespace.mkdir(functionOsdkDir, {
|
|
2845
|
-
recursive: true
|
|
2846
|
-
});
|
|
2847
|
-
try {
|
|
2848
|
-
await execa.execa("pnpm", ["exec", "osdk", "unstable", "typescript", "generate", "--outDir", functionOsdkDir, "--ontologyPath", path3__namespace.join(workDir, ".ontology.json"), "--beta", "true", "--packageType", "module", "--version", "dev"]);
|
|
2849
|
-
} catch (error) {
|
|
2850
|
-
await fs3__namespace.rm(functionOsdkDir, {
|
|
2851
|
-
recursive: true,
|
|
2852
|
-
force: true
|
|
2853
|
-
});
|
|
2854
|
-
throw error;
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
function createEntityMappings(ontologyIr) {
|
|
2858
|
-
const entityMappings = {
|
|
2859
|
-
ontologies: {}
|
|
2860
|
-
};
|
|
2861
|
-
const ontologyRid = "ontology";
|
|
2862
|
-
entityMappings.ontologies[ontologyRid] = {
|
|
2863
|
-
objectTypes: {},
|
|
2864
|
-
interfaceTypes: {}
|
|
2865
|
-
};
|
|
2866
|
-
for (const [apiName, blockData] of Object.entries(ontologyIr.ontology.objectTypes)) {
|
|
2867
|
-
const propertyTypesMap = {};
|
|
2868
|
-
Object.keys(blockData.objectType.propertyTypes).forEach((propertyName) => {
|
|
2869
|
-
propertyTypesMap[propertyName] = {
|
|
2870
|
-
propertyId: propertyName
|
|
2871
|
-
};
|
|
2872
|
-
});
|
|
2873
|
-
entityMappings.ontologies[ontologyRid].objectTypes[apiName] = {
|
|
2874
|
-
objectTypeId: apiName,
|
|
2875
|
-
primaryKey: {
|
|
2876
|
-
propertyId: blockData.objectType.primaryKeys[0]
|
|
2877
|
-
},
|
|
2878
|
-
propertyTypes: propertyTypesMap,
|
|
2879
|
-
linkTypes: {}
|
|
2880
|
-
};
|
|
2881
|
-
}
|
|
2882
|
-
return entityMappings;
|
|
2883
|
-
}
|
|
2884
2772
|
var MAX_SEARCH_DEPTH = 5;
|
|
2885
2773
|
function addDependency(namespaceNoDot, fileInPackage) {
|
|
2886
2774
|
let dir = path3__namespace.dirname(fileInPackage);
|
|
@@ -2920,37 +2808,37 @@ function defineAction(actionDefInput) {
|
|
|
2920
2808
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2921
2809
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2922
2810
|
}
|
|
2923
|
-
!/^[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;
|
|
2924
2812
|
const parameterIdsSet = new Set(parameterIds);
|
|
2925
|
-
!(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;
|
|
2926
2814
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2927
|
-
!(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;
|
|
2928
2816
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2929
2817
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2930
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2931
|
-
!(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;
|
|
2932
2820
|
actionDef.rules.forEach((rule) => {
|
|
2933
2821
|
if (rule.type === "modifyObjectRule") {
|
|
2934
|
-
!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;
|
|
2935
2823
|
}
|
|
2936
2824
|
if (rule.type === "deleteObjectRule") {
|
|
2937
|
-
!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;
|
|
2938
2826
|
}
|
|
2939
2827
|
if (rule.type === "modifyInterfaceRule") {
|
|
2940
2828
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2941
|
-
!(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;
|
|
2942
2830
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2943
|
-
!(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;
|
|
2944
2832
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2945
2833
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2946
|
-
!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;
|
|
2947
2835
|
});
|
|
2948
2836
|
}
|
|
2949
2837
|
if (rule.type === "addInterfaceRule") {
|
|
2950
2838
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2951
|
-
!(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;
|
|
2952
2840
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2953
|
-
!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;
|
|
2954
2842
|
});
|
|
2955
2843
|
}
|
|
2956
2844
|
});
|
|
@@ -3514,9 +3402,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
3514
3402
|
switch (condition.type) {
|
|
3515
3403
|
case "parameter":
|
|
3516
3404
|
const overrideParamId = condition.parameterId;
|
|
3517
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
3518
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3519
|
-
!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;
|
|
3520
3408
|
break;
|
|
3521
3409
|
case "and":
|
|
3522
3410
|
if ("conditions" in condition) {
|
|
@@ -3544,11 +3432,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3544
3432
|
if (!defaultValue) return;
|
|
3545
3433
|
switch (defaultValue.type) {
|
|
3546
3434
|
case "objectParameterPropertyValue":
|
|
3547
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
3548
|
-
!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;
|
|
3549
3437
|
break;
|
|
3550
3438
|
case "staticValue":
|
|
3551
|
-
!(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;
|
|
3552
3440
|
break;
|
|
3553
3441
|
case "staticObject":
|
|
3554
3442
|
case "interfaceParameterPropertyValue":
|
|
@@ -3563,10 +3451,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
3563
3451
|
}
|
|
3564
3452
|
function validateActionParameters(def, properties, name) {
|
|
3565
3453
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3566
|
-
!(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;
|
|
3567
3455
|
});
|
|
3568
3456
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3569
|
-
!(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;
|
|
3570
3458
|
});
|
|
3571
3459
|
}
|
|
3572
3460
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -3576,7 +3464,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
3576
3464
|
const orderingSet = new Set(parameterOrdering);
|
|
3577
3465
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3578
3466
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3579
|
-
!(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;
|
|
3580
3468
|
}
|
|
3581
3469
|
function isTargetParameter(parameterId) {
|
|
3582
3470
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -3998,7 +3886,8 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
3998
3886
|
function defineInterface(interfaceDefInput) {
|
|
3999
3887
|
const interfaceDef = cloneDefinition(interfaceDefInput);
|
|
4000
3888
|
const apiName = namespace + interfaceDef.apiName;
|
|
4001
|
-
!(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;
|
|
4002
3891
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
4003
3892
|
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
4004
3893
|
}).map(([s, spt]) => {
|
|
@@ -4016,6 +3905,7 @@ function defineInterface(interfaceDefInput) {
|
|
|
4016
3905
|
}];
|
|
4017
3906
|
}));
|
|
4018
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;
|
|
4019
3909
|
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
4020
3910
|
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
4021
3911
|
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
@@ -4031,7 +3921,7 @@ function defineInterface(interfaceDefInput) {
|
|
|
4031
3921
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
4032
3922
|
type: "active"
|
|
4033
3923
|
});
|
|
4034
|
-
!(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;
|
|
4035
3925
|
const fullInterface = {
|
|
4036
3926
|
apiName,
|
|
4037
3927
|
displayMetadata: {
|
|
@@ -4058,18 +3948,18 @@ function defineInterface(interfaceDefInput) {
|
|
|
4058
3948
|
}
|
|
4059
3949
|
function verifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
4060
3950
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
4061
|
-
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ?
|
|
4062
|
-
!(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({
|
|
4063
3953
|
key: apiName,
|
|
4064
3954
|
apiName: type.apiName
|
|
4065
|
-
})}`) :
|
|
3955
|
+
})}`) : invariant2__default.default(false) : void 0;
|
|
4066
3956
|
return type;
|
|
4067
3957
|
}
|
|
4068
3958
|
function defineInterfaceLinkConstraint(linkDefInput) {
|
|
4069
3959
|
const linkDef = cloneDefinition(linkDefInput);
|
|
4070
|
-
!(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;
|
|
4071
3961
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
4072
|
-
!(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;
|
|
4073
3963
|
linkDef.from.links.push({
|
|
4074
3964
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
4075
3965
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -4097,8 +3987,6 @@ function getLinkMeta(meta) {
|
|
|
4097
3987
|
description: description ?? displayName ?? apiNameWithoutNamespace
|
|
4098
3988
|
};
|
|
4099
3989
|
}
|
|
4100
|
-
|
|
4101
|
-
// src/api/defineLink.ts
|
|
4102
3990
|
function defineLink(linkDefinitionInput) {
|
|
4103
3991
|
const linkDefinition = cloneDefinition(linkDefinitionInput);
|
|
4104
3992
|
let fullLinkDefinition;
|
|
@@ -4149,6 +4037,7 @@ function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
|
4149
4037
|
};
|
|
4150
4038
|
}
|
|
4151
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;
|
|
4152
4041
|
return {
|
|
4153
4042
|
apiName: metadata.apiName,
|
|
4154
4043
|
displayMetadata: {
|
|
@@ -4336,8 +4225,8 @@ function defineModifyObjectAction(defInput) {
|
|
|
4336
4225
|
function defineSharedPropertyType(sptDefInput) {
|
|
4337
4226
|
const sptDef = cloneDefinition(sptDefInput);
|
|
4338
4227
|
const apiName = namespace + sptDef.apiName;
|
|
4339
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
4340
|
-
!(!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;
|
|
4341
4230
|
const fullSpt = {
|
|
4342
4231
|
...sptDef,
|
|
4343
4232
|
apiName,
|
|
@@ -4405,10 +4294,10 @@ function defineValueType(valueTypeDefInput) {
|
|
|
4405
4294
|
} = valueTypeDef;
|
|
4406
4295
|
const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;
|
|
4407
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-]+)*))?)$/;
|
|
4408
|
-
!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;
|
|
4409
4298
|
const existingVersions = ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];
|
|
4410
4299
|
const duplicateVersion = existingVersions.find((vt2) => vt2.version === version);
|
|
4411
|
-
!(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;
|
|
4412
4301
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
4413
4302
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
4414
4303
|
const output = {
|
|
@@ -4477,8 +4366,8 @@ function importSharedPropertyType(opts) {
|
|
|
4477
4366
|
} = opts;
|
|
4478
4367
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
4479
4368
|
if (packageName !== void 0) {
|
|
4480
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
4481
|
-
!(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;
|
|
4482
4371
|
}
|
|
4483
4372
|
const spt = {
|
|
4484
4373
|
apiName: fullApiName,
|