@osdk/maker 0.13.0-beta.16 → 0.13.0-beta.18
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 +13 -0
- package/build/browser/api/defineAction.js +6 -6
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineOntology.js +1 -0
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/overall.test.js +5 -1
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/cli/main.js +3 -3
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js +16 -2
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +5 -3
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
- package/build/cjs/index.cjs +87 -73
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/api/defineAction.js +6 -6
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineOntology.js +1 -0
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/overall.test.js +5 -1
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/cli/main.js +3 -3
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js +16 -2
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +5 -3
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts +1 -0
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts.map +1 -1
- package/package.json +3 -4
package/build/cjs/index.cjs
CHANGED
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var consola = require('consola');
|
|
6
6
|
var fs2 = require('fs/promises');
|
|
7
7
|
var path2 = require('path');
|
|
8
|
-
var
|
|
9
|
-
var uuid = require('uuid');
|
|
8
|
+
var invariant6 = require('tiny-invariant');
|
|
10
9
|
var yargs = require('yargs');
|
|
11
10
|
var helpers = require('yargs/helpers');
|
|
12
11
|
var fs = require('fs');
|
|
@@ -34,7 +33,7 @@ function _interopNamespace(e) {
|
|
|
34
33
|
|
|
35
34
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
36
35
|
var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
|
|
37
|
-
var
|
|
36
|
+
var invariant6__default = /*#__PURE__*/_interopDefault(invariant6);
|
|
38
37
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
39
38
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
40
39
|
|
|
@@ -108,12 +107,12 @@ function defineObject(objectDef) {
|
|
|
108
107
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
109
108
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
110
109
|
}
|
|
111
|
-
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
112
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
113
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
114
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
110
|
+
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant6__default.default(false) : void 0;
|
|
111
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant6__default.default(false) : void 0;
|
|
112
|
+
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant6__default.default(false) : void 0;
|
|
113
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant6__default.default(false) : void 0;
|
|
115
114
|
const retentionPeriod = objectDef.datasource?.retentionPeriod;
|
|
116
|
-
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ?
|
|
115
|
+
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant6__default.default(false) : void 0;
|
|
117
116
|
if (objectDef.status === "experimental") {
|
|
118
117
|
const activeProperties = [];
|
|
119
118
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -121,14 +120,14 @@ function defineObject(objectDef) {
|
|
|
121
120
|
activeProperties.push(apiName2);
|
|
122
121
|
}
|
|
123
122
|
});
|
|
124
|
-
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
123
|
+
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `When object "${objectDef.apiName}" has experimental status, no properties can have "active" status, but found active properties: ${activeProperties.join(", ")}`) : invariant6__default.default(false) : void 0;
|
|
125
124
|
}
|
|
126
125
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
127
126
|
const deadline = objectDef.status.deadline;
|
|
128
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
127
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant6__default.default(false) : void 0;
|
|
129
128
|
}
|
|
130
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
131
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
129
|
+
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant6__default.default(false) : void 0;
|
|
130
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant6__default.default(false) : void 0;
|
|
132
131
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
133
132
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
134
133
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -147,7 +146,7 @@ function defineObject(objectDef) {
|
|
|
147
146
|
};
|
|
148
147
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
149
148
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
150
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
149
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant6__default.default(false) : void 0;
|
|
151
150
|
});
|
|
152
151
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
153
152
|
const finalObject = {
|
|
@@ -225,16 +224,14 @@ function convertActionSections(action) {
|
|
|
225
224
|
}
|
|
226
225
|
}]));
|
|
227
226
|
}
|
|
228
|
-
|
|
229
|
-
// src/conversion/toMarketplace/convertConditionDefinition.ts
|
|
230
|
-
function convertConditionDefinition(condition) {
|
|
227
|
+
function convertConditionDefinition(condition, objectProperties) {
|
|
231
228
|
switch (condition.type) {
|
|
232
229
|
case "and":
|
|
233
230
|
if ("conditions" in condition) {
|
|
234
231
|
return {
|
|
235
232
|
type: "and",
|
|
236
233
|
and: {
|
|
237
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c))
|
|
234
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, objectProperties))
|
|
238
235
|
}
|
|
239
236
|
};
|
|
240
237
|
} else {
|
|
@@ -245,7 +242,7 @@ function convertConditionDefinition(condition) {
|
|
|
245
242
|
return {
|
|
246
243
|
type: "or",
|
|
247
244
|
or: {
|
|
248
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c))
|
|
245
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, objectProperties))
|
|
249
246
|
}
|
|
250
247
|
};
|
|
251
248
|
} else {
|
|
@@ -281,6 +278,7 @@ function convertConditionDefinition(condition) {
|
|
|
281
278
|
}
|
|
282
279
|
};
|
|
283
280
|
case "parameter":
|
|
281
|
+
!objectProperties?.includes(condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
284
282
|
return {
|
|
285
283
|
type: "comparison",
|
|
286
284
|
comparison: {
|
|
@@ -298,7 +296,7 @@ function convertConditionDefinition(condition) {
|
|
|
298
296
|
}
|
|
299
297
|
|
|
300
298
|
// src/conversion/toMarketplace/convertActionParameterConditionalOverride.ts
|
|
301
|
-
function convertActionParameterConditionalOverride(override, validation) {
|
|
299
|
+
function convertActionParameterConditionalOverride(override, validation, objectProperties) {
|
|
302
300
|
let parameterBlockOverride;
|
|
303
301
|
switch (override.type) {
|
|
304
302
|
case "required":
|
|
@@ -363,7 +361,7 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
363
361
|
throw new Error(`Unknown parameter override type`);
|
|
364
362
|
}
|
|
365
363
|
return {
|
|
366
|
-
condition: convertConditionDefinition(override.condition),
|
|
364
|
+
condition: convertConditionDefinition(override.condition, objectProperties),
|
|
367
365
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
368
366
|
};
|
|
369
367
|
}
|
|
@@ -395,9 +393,9 @@ function convertActionVisibility(visibility) {
|
|
|
395
393
|
}
|
|
396
394
|
|
|
397
395
|
// src/conversion/toMarketplace/convertSectionConditionalOverride.ts
|
|
398
|
-
function convertSectionConditionalOverride(override, defaultVisibility) {
|
|
396
|
+
function convertSectionConditionalOverride(override, defaultVisibility, objectProperties) {
|
|
399
397
|
return {
|
|
400
|
-
condition: convertConditionDefinition(override.condition),
|
|
398
|
+
condition: convertConditionDefinition(override.condition, objectProperties),
|
|
401
399
|
sectionBlockOverrides: [{
|
|
402
400
|
type: "visibility",
|
|
403
401
|
visibility: {
|
|
@@ -443,7 +441,7 @@ function convertActionValidation(action) {
|
|
|
443
441
|
required: convertParameterRequirementConstraint(p.validation.required)
|
|
444
442
|
}
|
|
445
443
|
},
|
|
446
|
-
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation)) ?? []
|
|
444
|
+
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation, getActionTypeObjectParameters(action))) ?? []
|
|
447
445
|
}];
|
|
448
446
|
})),
|
|
449
447
|
sectionValidations: {
|
|
@@ -459,7 +457,7 @@ function convertActionValidation(action) {
|
|
|
459
457
|
visible: {}
|
|
460
458
|
}
|
|
461
459
|
},
|
|
462
|
-
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible")) ?? []
|
|
460
|
+
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible", getActionTypeObjectParameters(action))) ?? []
|
|
463
461
|
}]))
|
|
464
462
|
}
|
|
465
463
|
};
|
|
@@ -486,6 +484,20 @@ function convertParameterRequirementConstraint(required) {
|
|
|
486
484
|
}
|
|
487
485
|
};
|
|
488
486
|
}
|
|
487
|
+
function getActionTypeObjectParameters(actionType) {
|
|
488
|
+
switch (actionType.rules[0].type) {
|
|
489
|
+
case "addObjectRule":
|
|
490
|
+
return Object.keys(actionType.rules[0].addObjectRule.propertyValues);
|
|
491
|
+
case "modifyObjectRule":
|
|
492
|
+
return Object.keys(actionType.rules[0].modifyObjectRule.propertyValues);
|
|
493
|
+
case "addOrModifyObjectRuleV2":
|
|
494
|
+
return Object.keys(actionType.rules[0].addOrModifyObjectRuleV2.propertyValues);
|
|
495
|
+
case "deleteObjectRule":
|
|
496
|
+
return [];
|
|
497
|
+
default:
|
|
498
|
+
return void 0;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
489
501
|
function convertNullabilityToDataConstraint(prop) {
|
|
490
502
|
if (typeof prop.type === "object" && prop.type.type === "marking") {
|
|
491
503
|
if (prop.nullability === void 0) {
|
|
@@ -498,7 +510,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
498
510
|
}
|
|
499
511
|
};
|
|
500
512
|
}
|
|
501
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
513
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant6__default.default(false) : void 0;
|
|
502
514
|
return {
|
|
503
515
|
propertyTypeConstraints: [],
|
|
504
516
|
nullability: void 0,
|
|
@@ -1018,7 +1030,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1018
1030
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1019
1031
|
function convertObjectPropertyType(property) {
|
|
1020
1032
|
const apiName = namespace + property.apiName;
|
|
1021
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1033
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant6__default.default(false) : void 0;
|
|
1022
1034
|
const output = {
|
|
1023
1035
|
apiName: property.apiName,
|
|
1024
1036
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1317,6 +1329,7 @@ function writeStaticObjects(outputDir) {
|
|
|
1317
1329
|
import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
|
|
1318
1330
|
import type { ${entityTypeName} } from '@osdk/maker';
|
|
1319
1331
|
|
|
1332
|
+
/** @type {import('@osdk/maker').${entityTypeName}} */
|
|
1320
1333
|
const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey === "VALUE_TYPE" ? entityJSON.slice(1, -2) : entityJSON} as unknown as ${entityTypeName};
|
|
1321
1334
|
|
|
1322
1335
|
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
@@ -1704,8 +1717,9 @@ function addNamespaceIfNone(apiName) {
|
|
|
1704
1717
|
|
|
1705
1718
|
// src/cli/main.ts
|
|
1706
1719
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1720
|
+
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1707
1721
|
async function main(args = process.argv) {
|
|
1708
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.
|
|
1722
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.18").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1709
1723
|
input: {
|
|
1710
1724
|
alias: "i",
|
|
1711
1725
|
describe: "Input file",
|
|
@@ -1758,12 +1772,12 @@ async function main(args = process.argv) {
|
|
|
1758
1772
|
let apiNamespace = "";
|
|
1759
1773
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1760
1774
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
1761
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
1762
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
1775
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "API namespace is too long.") : invariant6__default.default(false) : void 0;
|
|
1776
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant6__default.default(false) : void 0;
|
|
1763
1777
|
}
|
|
1764
1778
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1765
1779
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1766
|
-
!
|
|
1780
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant6__default.default(false) : void 0;
|
|
1767
1781
|
}
|
|
1768
1782
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
1769
1783
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -1936,7 +1950,7 @@ function defineCreateObjectAction(def) {
|
|
|
1936
1950
|
}],
|
|
1937
1951
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1938
1952
|
...def.actionLevelValidation ? {
|
|
1939
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
1953
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
1940
1954
|
} : {},
|
|
1941
1955
|
...def.defaultFormat && {
|
|
1942
1956
|
defaultFormat: def.defaultFormat
|
|
@@ -2076,7 +2090,7 @@ function defineModifyObjectAction(def) {
|
|
|
2076
2090
|
},
|
|
2077
2091
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2078
2092
|
...def.actionLevelValidation ? {
|
|
2079
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2093
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2080
2094
|
} : {},
|
|
2081
2095
|
...def.defaultFormat && {
|
|
2082
2096
|
defaultFormat: def.defaultFormat
|
|
@@ -2129,7 +2143,7 @@ function defineDeleteObjectAction(def) {
|
|
|
2129
2143
|
typeGroups: []
|
|
2130
2144
|
},
|
|
2131
2145
|
...def.actionLevelValidation ? {
|
|
2132
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2146
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2133
2147
|
} : {}
|
|
2134
2148
|
});
|
|
2135
2149
|
}
|
|
@@ -2186,7 +2200,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2186
2200
|
},
|
|
2187
2201
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2188
2202
|
...def.actionLevelValidation ? {
|
|
2189
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2203
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2190
2204
|
} : {},
|
|
2191
2205
|
...def.defaultFormat && {
|
|
2192
2206
|
defaultFormat: def.defaultFormat
|
|
@@ -2211,37 +2225,37 @@ function defineAction(actionDef) {
|
|
|
2211
2225
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2212
2226
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2213
2227
|
}
|
|
2214
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2228
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant6__default.default(false) : void 0;
|
|
2215
2229
|
const parameterIdsSet = new Set(parameterIds);
|
|
2216
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2230
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ids must be unique`) : invariant6__default.default(false) : void 0;
|
|
2217
2231
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2218
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2232
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant6__default.default(false) : void 0;
|
|
2219
2233
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2220
2234
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2221
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2222
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2235
|
+
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant6__default.default(false) : void 0;
|
|
2236
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant6__default.default(false) : void 0;
|
|
2223
2237
|
actionDef.rules.forEach((rule) => {
|
|
2224
2238
|
if (rule.type === "modifyObjectRule") {
|
|
2225
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2239
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant6__default.default(false) : void 0;
|
|
2226
2240
|
}
|
|
2227
2241
|
if (rule.type === "deleteObjectRule") {
|
|
2228
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2242
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant6__default.default(false) : void 0;
|
|
2229
2243
|
}
|
|
2230
2244
|
if (rule.type === "modifyInterfaceRule") {
|
|
2231
2245
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2232
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2246
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant6__default.default(false) : void 0;
|
|
2233
2247
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2234
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2248
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant6__default.default(false) : void 0;
|
|
2235
2249
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2236
2250
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2237
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2251
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant6__default.default(false) : void 0;
|
|
2238
2252
|
});
|
|
2239
2253
|
}
|
|
2240
2254
|
if (rule.type === "addInterfaceRule") {
|
|
2241
2255
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2242
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2256
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant6__default.default(false) : void 0;
|
|
2243
2257
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2244
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2258
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2245
2259
|
});
|
|
2246
2260
|
}
|
|
2247
2261
|
});
|
|
@@ -2598,10 +2612,10 @@ function kebab(s) {
|
|
|
2598
2612
|
function sanitize(s) {
|
|
2599
2613
|
return s.includes(".") ? s : namespace + s;
|
|
2600
2614
|
}
|
|
2601
|
-
function convertValidationRule(actionValidation) {
|
|
2615
|
+
function convertValidationRule(actionValidation, objectProperties) {
|
|
2602
2616
|
return actionValidation.map((rule) => {
|
|
2603
2617
|
return {
|
|
2604
|
-
condition: convertConditionDefinition(rule.condition),
|
|
2618
|
+
condition: convertConditionDefinition(rule.condition, objectProperties),
|
|
2605
2619
|
displayMetadata: rule.displayMetadata ?? {
|
|
2606
2620
|
failureMessage: "Did not satisfy validation",
|
|
2607
2621
|
typeClasses: []
|
|
@@ -2628,9 +2642,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
2628
2642
|
switch (condition.type) {
|
|
2629
2643
|
case "parameter":
|
|
2630
2644
|
const overrideParamId = condition.parameterId;
|
|
2631
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2632
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2633
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2645
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant6__default.default(false) : void 0;
|
|
2646
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant6__default.default(false) : void 0;
|
|
2647
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant6__default.default(false) : void 0;
|
|
2634
2648
|
break;
|
|
2635
2649
|
case "and":
|
|
2636
2650
|
if ("conditions" in condition) {
|
|
@@ -2658,11 +2672,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2658
2672
|
if (!defaultValue) return;
|
|
2659
2673
|
switch (defaultValue.type) {
|
|
2660
2674
|
case "objectParameterPropertyValue":
|
|
2661
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2662
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2675
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2676
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2663
2677
|
break;
|
|
2664
2678
|
case "staticValue":
|
|
2665
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
2679
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant6__default.default(false) : void 0;
|
|
2666
2680
|
break;
|
|
2667
2681
|
case "staticObject":
|
|
2668
2682
|
case "interfaceParameterPropertyValue":
|
|
@@ -2677,10 +2691,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2677
2691
|
}
|
|
2678
2692
|
function validateActionParameters(def) {
|
|
2679
2693
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2680
|
-
!(def.objectType.properties?.[id] !== void 0 || def.parameterConfiguration?.[id].customParameterType !== void 0 || id === MODIFY_OBJECT_PARAMETER || id === CREATE_OR_MODIFY_OBJECT_PARAMETER) ? process.env.NODE_ENV !== "production" ?
|
|
2694
|
+
!(def.objectType.properties?.[id] !== void 0 || def.parameterConfiguration?.[id].customParameterType !== void 0 || id === MODIFY_OBJECT_PARAMETER || id === CREATE_OR_MODIFY_OBJECT_PARAMETER) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ${id} does not exist as a property on ${def.objectType.apiName} and its type is not explicitly defined`) : invariant6__default.default(false) : void 0;
|
|
2681
2695
|
});
|
|
2682
2696
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2683
|
-
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2697
|
+
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property ${id} does not exist as a property on ${def.objectType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2684
2698
|
});
|
|
2685
2699
|
}
|
|
2686
2700
|
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
@@ -2690,12 +2704,12 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2690
2704
|
const orderingSet = new Set(parameterOrdering);
|
|
2691
2705
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2692
2706
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2693
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2707
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant6__default.default(false) : void 0;
|
|
2694
2708
|
}
|
|
2695
2709
|
function defineSharedPropertyType(sptDef) {
|
|
2696
2710
|
const apiName = namespace + sptDef.apiName;
|
|
2697
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2698
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
2711
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${apiName} already exists`) : invariant6__default.default(false) : void 0;
|
|
2712
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant6__default.default(false) : void 0;
|
|
2699
2713
|
const fullSpt = {
|
|
2700
2714
|
...sptDef,
|
|
2701
2715
|
apiName,
|
|
@@ -2744,7 +2758,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
2744
2758
|
// src/api/defineInterface.ts
|
|
2745
2759
|
function defineInterface(interfaceDef) {
|
|
2746
2760
|
const apiName = namespace + interfaceDef.apiName;
|
|
2747
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2761
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface ${apiName} already exists`) : invariant6__default.default(false) : void 0;
|
|
2748
2762
|
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2749
2763
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2750
2764
|
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
@@ -2763,7 +2777,7 @@ function defineInterface(interfaceDef) {
|
|
|
2763
2777
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2764
2778
|
type: "active"
|
|
2765
2779
|
});
|
|
2766
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
2780
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant6__default.default(false) : void 0;
|
|
2767
2781
|
const fullInterface = {
|
|
2768
2782
|
apiName,
|
|
2769
2783
|
displayMetadata: {
|
|
@@ -2789,7 +2803,7 @@ function defineInterface(interfaceDef) {
|
|
|
2789
2803
|
}
|
|
2790
2804
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2791
2805
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2792
|
-
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ?
|
|
2806
|
+
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant6__default.default(false) : void 0;
|
|
2793
2807
|
const spt = defineSharedPropertyType({
|
|
2794
2808
|
apiName,
|
|
2795
2809
|
displayName: apiName,
|
|
@@ -2799,16 +2813,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2799
2813
|
return spt;
|
|
2800
2814
|
} else {
|
|
2801
2815
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2802
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
2816
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
2803
2817
|
key: apiName,
|
|
2804
2818
|
apiName: type.apiName
|
|
2805
|
-
})}`) :
|
|
2819
|
+
})}`) : invariant6__default.default(false) : void 0;
|
|
2806
2820
|
return type;
|
|
2807
2821
|
}
|
|
2808
2822
|
}
|
|
2809
2823
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2810
2824
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2811
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
2825
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2812
2826
|
linkDef.from.links.push({
|
|
2813
2827
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2814
2828
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2840,14 +2854,14 @@ var typeIdPattern = /([a-z][a-z0-9\\-]*)/;
|
|
|
2840
2854
|
function defineLink(linkDefinition) {
|
|
2841
2855
|
if ("one" in linkDefinition) {
|
|
2842
2856
|
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2843
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2844
|
-
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2857
|
+
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`) : invariant6__default.default(false) : void 0;
|
|
2858
|
+
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__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`) : invariant6__default.default(false) : void 0;
|
|
2845
2859
|
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2846
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
2860
|
+
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant6__default.default(false) : void 0;
|
|
2847
2861
|
}
|
|
2848
2862
|
if ("intermediaryObjectType" in linkDefinition) {
|
|
2849
|
-
!("one" in linkDefinition.many.linkToIntermediary && linkDefinition.many.linkToIntermediary.one.object.apiName === linkDefinition.many.object.apiName && linkDefinition.many.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2850
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && linkDefinition.toMany.linkToIntermediary.one.object.apiName === linkDefinition.toMany.object.apiName && linkDefinition.toMany.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2863
|
+
!("one" in linkDefinition.many.linkToIntermediary && linkDefinition.many.linkToIntermediary.one.object.apiName === linkDefinition.many.object.apiName && linkDefinition.many.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectA ${linkDefinition.many.object.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2864
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && linkDefinition.toMany.linkToIntermediary.one.object.apiName === linkDefinition.toMany.object.apiName && linkDefinition.toMany.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectB ${linkDefinition.toMany.object.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2851
2865
|
}
|
|
2852
2866
|
let fullLinkDefinition;
|
|
2853
2867
|
if ("one" in linkDefinition) {
|
|
@@ -2959,7 +2973,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2959
2973
|
version
|
|
2960
2974
|
} = valueTypeDef;
|
|
2961
2975
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
2962
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
2976
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Version is not a valid semver") : invariant6__default.default(false) : void 0;
|
|
2963
2977
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2964
2978
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2965
2979
|
const output = {
|
|
@@ -3015,8 +3029,8 @@ function importSharedPropertyType(opts) {
|
|
|
3015
3029
|
} = opts;
|
|
3016
3030
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3017
3031
|
if (packageName !== void 0) {
|
|
3018
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
3019
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
3032
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Package name format invalid ends with period") : invariant6__default.default(false) : void 0;
|
|
3033
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Package name includes upper case characters") : invariant6__default.default(false) : void 0;
|
|
3020
3034
|
}
|
|
3021
3035
|
const spt = {
|
|
3022
3036
|
apiName: fullApiName,
|