@osdk/maker 0.12.0-beta.8 → 0.12.0-rc.23
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 +138 -0
- package/README.md +88 -62
- package/build/browser/api/defineAction.js +403 -106
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineLink.js +2 -2
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineObject.js +6 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +80 -35
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/ontologyUtils.js +80 -0
- package/build/browser/api/ontologyUtils.js.map +1 -1
- package/build/browser/api/overall.test.js +4741 -2358
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/api/types.js +2 -0
- package/build/browser/api/types.js.map +1 -1
- package/build/browser/cli/main.js +2 -10
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/index.js +5 -4
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +575 -153
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +98 -20
- package/build/esm/api/defineAction.js +403 -106
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineLink.js +2 -2
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineObject.js +6 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +80 -35
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/ontologyUtils.js +80 -0
- package/build/esm/api/ontologyUtils.js.map +1 -1
- package/build/esm/api/overall.test.js +4741 -2358
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/api/types.js +2 -0
- package/build/esm/api/types.js.map +1 -1
- package/build/esm/cli/main.js +2 -10
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/index.js +5 -4
- package/build/esm/index.js.map +1 -1
- package/build/types/api/defineAction.d.ts +7 -6
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts +2 -2
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +3 -2
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +2 -2
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/ontologyUtils.d.ts +5 -2
- package/build/types/api/ontologyUtils.d.ts.map +1 -1
- package/build/types/api/types.d.ts +83 -12
- package/build/types/api/types.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/index.d.ts +6 -5
- package/build/types/index.d.ts.map +1 -1
- package/package.json +4 -4
package/build/cjs/index.cjs
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var consola = require('consola');
|
|
6
|
-
var jiti = require('jiti');
|
|
7
6
|
var fs2 = require('fs/promises');
|
|
8
7
|
var path2 = require('path');
|
|
9
8
|
var invariant5 = require('tiny-invariant');
|
|
10
9
|
var yargs = require('yargs');
|
|
11
10
|
var helpers = require('yargs/helpers');
|
|
12
11
|
var fs = require('fs');
|
|
12
|
+
var crypto = require('crypto');
|
|
13
13
|
|
|
14
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
15
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
|
|
17
16
|
function _interopNamespace(e) {
|
|
@@ -50,6 +49,8 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ function(OntologyEntityTypeEnum2) {
|
|
|
50
49
|
OntologyEntityTypeEnum2["VALUE_TYPE"] = "VALUE_TYPE";
|
|
51
50
|
return OntologyEntityTypeEnum2;
|
|
52
51
|
}({});
|
|
52
|
+
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
53
|
+
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
53
54
|
|
|
54
55
|
// src/api/defineObject.ts
|
|
55
56
|
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))$/;
|
|
@@ -100,7 +101,7 @@ function defineObject(objectDef) {
|
|
|
100
101
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
101
102
|
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant5__default.default(false) : void 0;
|
|
102
103
|
});
|
|
103
|
-
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
104
|
+
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
104
105
|
const finalObject = {
|
|
105
106
|
...objectDef,
|
|
106
107
|
apiName,
|
|
@@ -108,7 +109,8 @@ function defineObject(objectDef) {
|
|
|
108
109
|
properties: flattenedProperties
|
|
109
110
|
};
|
|
110
111
|
updateOntology(finalObject);
|
|
111
|
-
|
|
112
|
+
objectDef.apiName = apiName;
|
|
113
|
+
return objectDef;
|
|
112
114
|
}
|
|
113
115
|
function isExotic(type) {
|
|
114
116
|
if (type === void 0) {
|
|
@@ -160,6 +162,8 @@ function getAllInterfaceProperties(interfaceType) {
|
|
|
160
162
|
return properties;
|
|
161
163
|
}
|
|
162
164
|
function convertUserObjectPropertyType(apiName, property) {
|
|
165
|
+
property.apiName = apiName;
|
|
166
|
+
property.displayName = property.displayName ?? convertToDisplayName(apiName);
|
|
163
167
|
return {
|
|
164
168
|
...property,
|
|
165
169
|
apiName,
|
|
@@ -167,8 +171,6 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
167
171
|
type: property.type
|
|
168
172
|
};
|
|
169
173
|
}
|
|
170
|
-
|
|
171
|
-
// src/api/ontologyUtils.ts
|
|
172
174
|
function convertActionVisibility(visibility) {
|
|
173
175
|
switch (visibility) {
|
|
174
176
|
case "editable":
|
|
@@ -238,6 +240,22 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
238
240
|
}
|
|
239
241
|
};
|
|
240
242
|
break;
|
|
243
|
+
case "defaultValue":
|
|
244
|
+
parameterBlockOverride = {
|
|
245
|
+
type: "prefill",
|
|
246
|
+
prefill: {
|
|
247
|
+
prefill: override.defaultValue
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
break;
|
|
251
|
+
case "constraint":
|
|
252
|
+
parameterBlockOverride = {
|
|
253
|
+
type: "allowedValues",
|
|
254
|
+
allowedValues: {
|
|
255
|
+
allowedValues: extractAllowedValues(override.constraint)
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
break;
|
|
241
259
|
default:
|
|
242
260
|
throw new Error(`Unknown parameter override type`);
|
|
243
261
|
}
|
|
@@ -246,6 +264,23 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
246
264
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
247
265
|
};
|
|
248
266
|
}
|
|
267
|
+
function convertSectionConditionalOverride(override, defaultVisibility) {
|
|
268
|
+
return {
|
|
269
|
+
condition: convertConditionDefinition(override.condition),
|
|
270
|
+
sectionBlockOverrides: [{
|
|
271
|
+
type: "visibility",
|
|
272
|
+
visibility: {
|
|
273
|
+
visibility: defaultVisibility === "visible" ? {
|
|
274
|
+
type: "hidden",
|
|
275
|
+
hidden: {}
|
|
276
|
+
} : {
|
|
277
|
+
type: "visible",
|
|
278
|
+
visible: {}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}]
|
|
282
|
+
};
|
|
283
|
+
}
|
|
249
284
|
function convertConditionDefinition(condition) {
|
|
250
285
|
switch (condition.type) {
|
|
251
286
|
case "and":
|
|
@@ -315,6 +350,51 @@ function convertConditionDefinition(condition) {
|
|
|
315
350
|
return condition;
|
|
316
351
|
}
|
|
317
352
|
}
|
|
353
|
+
function getFormContentOrdering(action, parameterOrdering) {
|
|
354
|
+
if (!action.sections) return [];
|
|
355
|
+
const parametersToSection = Object.fromEntries(Object.entries(action.sections).flatMap(([sectionId, section]) => section.parameters.map((param) => [param, sectionId])));
|
|
356
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
357
|
+
const formContentOrdering = [];
|
|
358
|
+
parameterOrdering.forEach((param) => {
|
|
359
|
+
if (param in parametersToSection && !seenIds.has(parametersToSection[param])) {
|
|
360
|
+
formContentOrdering.push({
|
|
361
|
+
type: "sectionId",
|
|
362
|
+
sectionId: parametersToSection[param]
|
|
363
|
+
});
|
|
364
|
+
seenIds.add(parametersToSection[param]);
|
|
365
|
+
} else if (!(param in parametersToSection)) {
|
|
366
|
+
formContentOrdering.push({
|
|
367
|
+
type: "parameterId",
|
|
368
|
+
parameterId: param
|
|
369
|
+
});
|
|
370
|
+
seenIds.add(param);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
return formContentOrdering;
|
|
374
|
+
}
|
|
375
|
+
function convertMappingValue(value) {
|
|
376
|
+
switch (value.type) {
|
|
377
|
+
case "uuid":
|
|
378
|
+
return {
|
|
379
|
+
type: "uniqueIdentifier",
|
|
380
|
+
uniqueIdentifier: {
|
|
381
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
case "currentTime":
|
|
385
|
+
return {
|
|
386
|
+
type: "currentTime",
|
|
387
|
+
currentTime: {}
|
|
388
|
+
};
|
|
389
|
+
case "currentUser":
|
|
390
|
+
return {
|
|
391
|
+
type: "currentUser",
|
|
392
|
+
currentUser: {}
|
|
393
|
+
};
|
|
394
|
+
default:
|
|
395
|
+
return value;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
318
398
|
var defaultTypeClasses = [{
|
|
319
399
|
kind: "render_hint",
|
|
320
400
|
name: "SELECTABLE"
|
|
@@ -701,7 +781,11 @@ function convertToWireImportedTypes(importedTypes2) {
|
|
|
701
781
|
apiName: spt.sharedPropertyType.apiName,
|
|
702
782
|
displayName: spt.sharedPropertyType.displayMetadata.displayName,
|
|
703
783
|
description: spt.sharedPropertyType.displayMetadata.description,
|
|
704
|
-
type: spt.sharedPropertyType.type
|
|
784
|
+
type: spt.sharedPropertyType.type,
|
|
785
|
+
valueType: spt.sharedPropertyType.valueType === void 0 ? void 0 : {
|
|
786
|
+
apiName: spt.sharedPropertyType.valueType.apiName,
|
|
787
|
+
version: spt.sharedPropertyType.valueType.version
|
|
788
|
+
}
|
|
705
789
|
})),
|
|
706
790
|
objectTypes: Object.values(asBlockData.objectTypes).map((ot) => ({
|
|
707
791
|
apiName: ot.objectType.apiName,
|
|
@@ -1087,7 +1171,7 @@ function convertLink(linkType) {
|
|
|
1087
1171
|
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1088
1172
|
object: linkType.toMany.object.apiName
|
|
1089
1173
|
},
|
|
1090
|
-
column: linkType.
|
|
1174
|
+
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
1091
1175
|
}]
|
|
1092
1176
|
}
|
|
1093
1177
|
},
|
|
@@ -1140,6 +1224,9 @@ function convertInterface(interfaceType) {
|
|
|
1140
1224
|
properties: []
|
|
1141
1225
|
};
|
|
1142
1226
|
}
|
|
1227
|
+
function dumpOntologyFullMetadata() {
|
|
1228
|
+
return convertToWireOntologyIr(ontologyDefinition);
|
|
1229
|
+
}
|
|
1143
1230
|
function convertSpt({
|
|
1144
1231
|
type,
|
|
1145
1232
|
array,
|
|
@@ -1175,7 +1262,10 @@ function convertSpt({
|
|
|
1175
1262
|
gothamMapping,
|
|
1176
1263
|
indexedForSearch: true,
|
|
1177
1264
|
typeClasses: typeClasses ?? [],
|
|
1178
|
-
valueType
|
|
1265
|
+
valueType: valueType === void 0 ? void 0 : {
|
|
1266
|
+
apiName: valueType.apiName,
|
|
1267
|
+
version: valueType.version
|
|
1268
|
+
}
|
|
1179
1269
|
};
|
|
1180
1270
|
}
|
|
1181
1271
|
function convertObjectStatus(status) {
|
|
@@ -1213,6 +1303,7 @@ function convertAction(action) {
|
|
|
1213
1303
|
const actionValidation = convertActionValidation(action);
|
|
1214
1304
|
const actionParameters = convertActionParameters(action);
|
|
1215
1305
|
const actionSections = convertActionSections(action);
|
|
1306
|
+
const parameterOrdering = action.parameterOrdering ?? (action.parameters ?? []).map((p) => p.id);
|
|
1216
1307
|
return {
|
|
1217
1308
|
actionType: {
|
|
1218
1309
|
actionTypeLogic: {
|
|
@@ -1225,8 +1316,8 @@ function convertAction(action) {
|
|
|
1225
1316
|
apiName: action.apiName,
|
|
1226
1317
|
displayMetadata: {
|
|
1227
1318
|
configuration: {
|
|
1228
|
-
defaultLayout: "FORM",
|
|
1229
|
-
displayAndFormat: {
|
|
1319
|
+
defaultLayout: action.defaultFormat ?? "FORM",
|
|
1320
|
+
displayAndFormat: action.displayAndFormat ?? {
|
|
1230
1321
|
table: {
|
|
1231
1322
|
columnWidthByParameterRid: {},
|
|
1232
1323
|
enableFileImport: true,
|
|
@@ -1235,7 +1326,7 @@ function convertAction(action) {
|
|
|
1235
1326
|
rowHeightInLines: 1
|
|
1236
1327
|
}
|
|
1237
1328
|
},
|
|
1238
|
-
enableLayoutUserSwitch: false
|
|
1329
|
+
enableLayoutUserSwitch: action.enableLayoutSwitch ?? false
|
|
1239
1330
|
},
|
|
1240
1331
|
description: action.description ?? "",
|
|
1241
1332
|
displayName: action.displayName,
|
|
@@ -1246,11 +1337,20 @@ function convertAction(action) {
|
|
|
1246
1337
|
color: "#000000"
|
|
1247
1338
|
}
|
|
1248
1339
|
},
|
|
1249
|
-
successMessage: [
|
|
1250
|
-
|
|
1340
|
+
successMessage: action.submissionMetadata?.successMessage ? [{
|
|
1341
|
+
type: "message",
|
|
1342
|
+
message: action.submissionMetadata.successMessage
|
|
1343
|
+
}] : [],
|
|
1344
|
+
typeClasses: action.typeClasses ?? [],
|
|
1345
|
+
...action.submissionMetadata?.submitButtonDisplayMetadata && {
|
|
1346
|
+
submitButtonDisplayMetadata: action.submissionMetadata.submitButtonDisplayMetadata
|
|
1347
|
+
},
|
|
1348
|
+
...action.submissionMetadata?.undoButtonConfiguration && {
|
|
1349
|
+
undoButtonConfiguration: action.submissionMetadata.undoButtonConfiguration
|
|
1350
|
+
}
|
|
1251
1351
|
},
|
|
1252
|
-
|
|
1253
|
-
|
|
1352
|
+
parameterOrdering,
|
|
1353
|
+
formContentOrdering: getFormContentOrdering(action, parameterOrdering),
|
|
1254
1354
|
parameters: actionParameters,
|
|
1255
1355
|
sections: actionSections,
|
|
1256
1356
|
status: typeof action.status === "string" ? {
|
|
@@ -1281,16 +1381,35 @@ function convertActionValidation(action) {
|
|
|
1281
1381
|
defaultValidation: {
|
|
1282
1382
|
display: {
|
|
1283
1383
|
renderHint: renderHintFromBaseType(p),
|
|
1284
|
-
visibility: convertActionVisibility(p.validation.defaultVisibility)
|
|
1384
|
+
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
1385
|
+
...p.defaultValue && {
|
|
1386
|
+
prefill: p.defaultValue
|
|
1387
|
+
}
|
|
1285
1388
|
},
|
|
1286
1389
|
validation: {
|
|
1287
|
-
allowedValues: extractAllowedValues(p),
|
|
1390
|
+
allowedValues: extractAllowedValues(p.validation.allowedValues),
|
|
1288
1391
|
required: convertParameterRequirementConstraint(p.validation.required)
|
|
1289
1392
|
}
|
|
1290
1393
|
},
|
|
1291
1394
|
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation)) ?? []
|
|
1292
1395
|
}];
|
|
1293
|
-
}))
|
|
1396
|
+
})),
|
|
1397
|
+
sectionValidations: {
|
|
1398
|
+
...Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [section.id, {
|
|
1399
|
+
defaultDisplayMetadata: section.defaultVisibility === "hidden" ? {
|
|
1400
|
+
visibility: {
|
|
1401
|
+
type: "hidden",
|
|
1402
|
+
hidden: {}
|
|
1403
|
+
}
|
|
1404
|
+
} : {
|
|
1405
|
+
visibility: {
|
|
1406
|
+
type: "visible",
|
|
1407
|
+
visible: {}
|
|
1408
|
+
}
|
|
1409
|
+
},
|
|
1410
|
+
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible")) ?? []
|
|
1411
|
+
}]))
|
|
1412
|
+
}
|
|
1294
1413
|
};
|
|
1295
1414
|
}
|
|
1296
1415
|
function convertActionParameters(action) {
|
|
@@ -1308,32 +1427,41 @@ function convertActionParameters(action) {
|
|
|
1308
1427
|
}]));
|
|
1309
1428
|
}
|
|
1310
1429
|
function convertActionSections(action) {
|
|
1311
|
-
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId,
|
|
1430
|
+
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [sectionId, {
|
|
1312
1431
|
id: sectionId,
|
|
1313
|
-
content:
|
|
1432
|
+
content: section.parameters.map((p) => ({
|
|
1314
1433
|
type: "parameterId",
|
|
1315
1434
|
parameterId: p
|
|
1316
1435
|
})),
|
|
1317
1436
|
displayMetadata: {
|
|
1318
|
-
collapsedByDefault: false,
|
|
1319
|
-
columnCount: 1,
|
|
1320
|
-
description: "",
|
|
1321
|
-
displayName: sectionId,
|
|
1322
|
-
showTitleBar: true
|
|
1437
|
+
collapsedByDefault: section.collapsedByDefault ?? false,
|
|
1438
|
+
columnCount: section.columnCount ?? 1,
|
|
1439
|
+
description: section.description ?? "",
|
|
1440
|
+
displayName: section.displayName ?? convertToDisplayName(sectionId),
|
|
1441
|
+
showTitleBar: section.showTitleBar ?? true,
|
|
1442
|
+
...section.style && {
|
|
1443
|
+
style: section.style === "box" ? {
|
|
1444
|
+
type: "box",
|
|
1445
|
+
box: {}
|
|
1446
|
+
} : {
|
|
1447
|
+
type: "minimal",
|
|
1448
|
+
minimal: {}
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1323
1451
|
}
|
|
1324
1452
|
}]));
|
|
1325
1453
|
}
|
|
1326
|
-
function extractAllowedValues(
|
|
1327
|
-
switch (
|
|
1454
|
+
function extractAllowedValues(allowedValues) {
|
|
1455
|
+
switch (allowedValues.type) {
|
|
1328
1456
|
case "oneOf":
|
|
1329
1457
|
return {
|
|
1330
1458
|
type: "oneOf",
|
|
1331
1459
|
oneOf: {
|
|
1332
1460
|
type: "oneOf",
|
|
1333
1461
|
oneOf: {
|
|
1334
|
-
labelledValues:
|
|
1462
|
+
labelledValues: allowedValues.oneOf,
|
|
1335
1463
|
otherValueAllowed: {
|
|
1336
|
-
allowed: false
|
|
1464
|
+
allowed: allowedValues.otherValueAllowed ?? false
|
|
1337
1465
|
}
|
|
1338
1466
|
}
|
|
1339
1467
|
}
|
|
@@ -1342,7 +1470,7 @@ function extractAllowedValues(parameter) {
|
|
|
1342
1470
|
const {
|
|
1343
1471
|
min,
|
|
1344
1472
|
max
|
|
1345
|
-
} =
|
|
1473
|
+
} = allowedValues;
|
|
1346
1474
|
return {
|
|
1347
1475
|
type: "range",
|
|
1348
1476
|
range: {
|
|
@@ -1368,17 +1496,17 @@ function extractAllowedValues(parameter) {
|
|
|
1368
1496
|
minLength,
|
|
1369
1497
|
maxLength,
|
|
1370
1498
|
regex
|
|
1371
|
-
} =
|
|
1499
|
+
} = allowedValues;
|
|
1372
1500
|
return {
|
|
1373
1501
|
type: "text",
|
|
1374
1502
|
text: {
|
|
1375
1503
|
type: "text",
|
|
1376
1504
|
text: {
|
|
1377
1505
|
...minLength === void 0 ? {} : {
|
|
1378
|
-
|
|
1506
|
+
minLength
|
|
1379
1507
|
},
|
|
1380
1508
|
...maxLength === void 0 ? {} : {
|
|
1381
|
-
|
|
1509
|
+
maxLength
|
|
1382
1510
|
},
|
|
1383
1511
|
...regex === void 0 ? {} : {
|
|
1384
1512
|
regex: {
|
|
@@ -1393,7 +1521,7 @@ function extractAllowedValues(parameter) {
|
|
|
1393
1521
|
const {
|
|
1394
1522
|
minimum,
|
|
1395
1523
|
maximum
|
|
1396
|
-
} =
|
|
1524
|
+
} = allowedValues;
|
|
1397
1525
|
return {
|
|
1398
1526
|
type: "datetime",
|
|
1399
1527
|
datetime: {
|
|
@@ -1410,7 +1538,7 @@ function extractAllowedValues(parameter) {
|
|
|
1410
1538
|
objectTypeReference: {
|
|
1411
1539
|
type: "objectTypeReference",
|
|
1412
1540
|
objectTypeReference: {
|
|
1413
|
-
interfaceTypeRids:
|
|
1541
|
+
interfaceTypeRids: allowedValues.interfaceTypes
|
|
1414
1542
|
}
|
|
1415
1543
|
}
|
|
1416
1544
|
};
|
|
@@ -1428,7 +1556,7 @@ function extractAllowedValues(parameter) {
|
|
|
1428
1556
|
}
|
|
1429
1557
|
};
|
|
1430
1558
|
default:
|
|
1431
|
-
const k =
|
|
1559
|
+
const k = allowedValues.type;
|
|
1432
1560
|
return {
|
|
1433
1561
|
type: k,
|
|
1434
1562
|
[k]: {
|
|
@@ -1486,12 +1614,12 @@ function renderHintFromBaseType(parameter) {
|
|
|
1486
1614
|
};
|
|
1487
1615
|
case "marking":
|
|
1488
1616
|
case "markingList":
|
|
1489
|
-
if (parameter.validation.allowedValues
|
|
1617
|
+
if (parameter.validation.allowedValues?.type === "mandatoryMarking") {
|
|
1490
1618
|
return {
|
|
1491
1619
|
type: "mandatoryMarkingPicker",
|
|
1492
1620
|
mandatoryMarkingPicker: {}
|
|
1493
1621
|
};
|
|
1494
|
-
} else if (parameter.validation.allowedValues
|
|
1622
|
+
} else if (parameter.validation.allowedValues?.type === "cbacMarking") {
|
|
1495
1623
|
return {
|
|
1496
1624
|
type: "cbacMarkingPicker",
|
|
1497
1625
|
cbacMarkingPicker: {}
|
|
@@ -1593,7 +1721,7 @@ function convertCardinality(cardinality) {
|
|
|
1593
1721
|
// src/cli/main.ts
|
|
1594
1722
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1595
1723
|
async function main(args = process.argv) {
|
|
1596
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.12.0-
|
|
1724
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.12.0-rc.23").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1597
1725
|
input: {
|
|
1598
1726
|
alias: "i",
|
|
1599
1727
|
describe: "Input file",
|
|
@@ -1653,14 +1781,7 @@ async function main(args = process.argv) {
|
|
|
1653
1781
|
}
|
|
1654
1782
|
}
|
|
1655
1783
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
1656
|
-
const q = await defineOntology(apiNamespace, async () =>
|
|
1657
|
-
const jiti$1 = jiti.createJiti(undefined, {
|
|
1658
|
-
moduleCache: true,
|
|
1659
|
-
debug: false,
|
|
1660
|
-
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)) })
|
|
1661
|
-
});
|
|
1662
|
-
const module = await jiti$1.import(input);
|
|
1663
|
-
}, outputDir, dependencyFile);
|
|
1784
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile);
|
|
1664
1785
|
return q;
|
|
1665
1786
|
}
|
|
1666
1787
|
var MAX_SEARCH_DEPTH = 5;
|
|
@@ -1727,7 +1848,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1727
1848
|
required: prop.sharedPropertyType.array ?? false ? {
|
|
1728
1849
|
listLength: {}
|
|
1729
1850
|
} : prop.required,
|
|
1730
|
-
allowedValues:
|
|
1851
|
+
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1731
1852
|
}
|
|
1732
1853
|
}))],
|
|
1733
1854
|
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
@@ -1753,49 +1874,61 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1753
1874
|
} : {}
|
|
1754
1875
|
});
|
|
1755
1876
|
}
|
|
1756
|
-
function defineCreateObjectAction(
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1877
|
+
function defineCreateObjectAction(def) {
|
|
1878
|
+
validateActionParameters(def);
|
|
1879
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type));
|
|
1880
|
+
const parameterNames = new Set(propertyParameters);
|
|
1881
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
1882
|
+
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
1883
|
+
if (def.parameterOrdering) {
|
|
1884
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
1760
1885
|
}
|
|
1886
|
+
const parameters = createParameters(def, parameterNames, true);
|
|
1887
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
1761
1888
|
return defineAction({
|
|
1762
|
-
apiName:
|
|
1763
|
-
displayName: `Create ${objectType.displayName}`,
|
|
1764
|
-
parameters
|
|
1765
|
-
|
|
1766
|
-
displayName: prop.displayName,
|
|
1767
|
-
type: extractActionParameterType(prop),
|
|
1768
|
-
typeClasses: prop.typeClasses ?? [],
|
|
1769
|
-
validation: {
|
|
1770
|
-
required: prop.array ?? false ? {
|
|
1771
|
-
listLength: prop.nullability?.noEmptyCollections ? {
|
|
1772
|
-
min: 1
|
|
1773
|
-
} : {}
|
|
1774
|
-
} : prop.nullability?.noNulls ?? true,
|
|
1775
|
-
allowedValues: extractAllowedValuesFromType(prop.type)
|
|
1776
|
-
}
|
|
1777
|
-
}))],
|
|
1778
|
-
status: "active",
|
|
1889
|
+
apiName: actionApiName,
|
|
1890
|
+
displayName: def.displayName ?? `Create ${def.objectType.displayName}`,
|
|
1891
|
+
parameters,
|
|
1892
|
+
status: def.status ?? "active",
|
|
1779
1893
|
entities: {
|
|
1780
1894
|
affectedInterfaceTypes: [],
|
|
1781
|
-
affectedObjectTypes: [objectType.apiName],
|
|
1895
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
1782
1896
|
affectedLinkTypes: [],
|
|
1783
1897
|
typeGroups: []
|
|
1784
1898
|
},
|
|
1785
1899
|
rules: [{
|
|
1786
1900
|
type: "addObjectRule",
|
|
1787
1901
|
addObjectRule: {
|
|
1788
|
-
objectTypeId: objectType.apiName,
|
|
1789
|
-
propertyValues:
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1902
|
+
objectTypeId: def.objectType.apiName,
|
|
1903
|
+
propertyValues: {
|
|
1904
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
1905
|
+
type: "parameterId",
|
|
1906
|
+
parameterId: p
|
|
1907
|
+
}])),
|
|
1908
|
+
...mappings
|
|
1909
|
+
},
|
|
1793
1910
|
structFieldValues: {}
|
|
1794
1911
|
}
|
|
1795
1912
|
}],
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1913
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1914
|
+
...def.actionLevelValidation ? {
|
|
1915
|
+
validation: [convertValidationRule(def.actionLevelValidation)]
|
|
1916
|
+
} : {},
|
|
1917
|
+
...def.defaultFormat && {
|
|
1918
|
+
defaultFormat: def.defaultFormat
|
|
1919
|
+
},
|
|
1920
|
+
...def.enableLayoutSwitch && {
|
|
1921
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
1922
|
+
},
|
|
1923
|
+
...def.displayAndFormat && {
|
|
1924
|
+
displayAndFormat: def.displayAndFormat
|
|
1925
|
+
},
|
|
1926
|
+
...def.sections && {
|
|
1927
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
1928
|
+
},
|
|
1929
|
+
...def.submissionMetadata && {
|
|
1930
|
+
submissionMetadata: def.submissionMetadata
|
|
1931
|
+
}
|
|
1799
1932
|
});
|
|
1800
1933
|
}
|
|
1801
1934
|
function defineModifyInterfaceObjectAction(interfaceType, objectType, validation) {
|
|
@@ -1841,7 +1974,7 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1841
1974
|
required: prop.sharedPropertyType.array ?? false ? {
|
|
1842
1975
|
listLength: {}
|
|
1843
1976
|
} : prop.required,
|
|
1844
|
-
allowedValues:
|
|
1977
|
+
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1845
1978
|
}
|
|
1846
1979
|
}))],
|
|
1847
1980
|
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
@@ -1866,78 +1999,89 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1866
1999
|
} : {}
|
|
1867
2000
|
});
|
|
1868
2001
|
}
|
|
1869
|
-
function defineModifyObjectAction(
|
|
1870
|
-
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1873
|
-
|
|
2002
|
+
function defineModifyObjectAction(def) {
|
|
2003
|
+
validateActionParameters(def);
|
|
2004
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2005
|
+
const parameterNames = new Set(propertyParameters);
|
|
2006
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2007
|
+
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
2008
|
+
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2009
|
+
if (def.parameterOrdering) {
|
|
2010
|
+
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
2011
|
+
def.parameterOrdering = [MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2012
|
+
}
|
|
2013
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
1874
2014
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
objectReference: {
|
|
1884
|
-
objectTypeId: objectType.apiName
|
|
2015
|
+
const parameters = createParameters(def, parameterNames, false);
|
|
2016
|
+
parameters.forEach((p) => {
|
|
2017
|
+
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2018
|
+
p.defaultValue = {
|
|
2019
|
+
type: "objectParameterPropertyValue",
|
|
2020
|
+
objectParameterPropertyValue: {
|
|
2021
|
+
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
2022
|
+
propertyTypeId: p.id
|
|
1885
2023
|
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
});
|
|
2027
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2028
|
+
return defineAction({
|
|
2029
|
+
apiName: actionApiName,
|
|
2030
|
+
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
2031
|
+
parameters,
|
|
2032
|
+
status: def.status ?? "active",
|
|
2033
|
+
rules: [{
|
|
2034
|
+
type: "modifyObjectRule",
|
|
2035
|
+
modifyObjectRule: {
|
|
2036
|
+
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
2037
|
+
propertyValues: {
|
|
2038
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2039
|
+
type: "parameterId",
|
|
2040
|
+
parameterId: p
|
|
2041
|
+
}])),
|
|
2042
|
+
...mappings
|
|
1890
2043
|
},
|
|
1891
|
-
|
|
1892
|
-
}
|
|
1893
|
-
}, ...filteredProperties.map((prop) => ({
|
|
1894
|
-
id: prop.apiName,
|
|
1895
|
-
displayName: prop.displayName,
|
|
1896
|
-
type: extractActionParameterType(prop),
|
|
1897
|
-
typeClasses: prop.typeClasses ?? [],
|
|
1898
|
-
validation: {
|
|
1899
|
-
required: prop.array ?? false ? {
|
|
1900
|
-
listLength: prop.nullability?.noEmptyCollections ? {
|
|
1901
|
-
min: 1
|
|
1902
|
-
} : {}
|
|
1903
|
-
} : prop.nullability?.noNulls ?? false,
|
|
1904
|
-
allowedValues: extractAllowedValuesFromType(prop.type)
|
|
2044
|
+
structFieldValues: {}
|
|
1905
2045
|
}
|
|
1906
|
-
}
|
|
1907
|
-
status: "active",
|
|
2046
|
+
}],
|
|
1908
2047
|
entities: {
|
|
1909
2048
|
affectedInterfaceTypes: [],
|
|
1910
|
-
affectedObjectTypes: [objectType.apiName],
|
|
2049
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
1911
2050
|
affectedLinkTypes: [],
|
|
1912
2051
|
typeGroups: []
|
|
1913
2052
|
},
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2053
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2054
|
+
...def.actionLevelValidation ? {
|
|
2055
|
+
validation: [convertValidationRule(def.actionLevelValidation)]
|
|
2056
|
+
} : {},
|
|
2057
|
+
...def.defaultFormat && {
|
|
2058
|
+
defaultFormat: def.defaultFormat
|
|
2059
|
+
},
|
|
2060
|
+
...def.enableLayoutSwitch && {
|
|
2061
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2062
|
+
},
|
|
2063
|
+
...def.displayAndFormat && {
|
|
2064
|
+
displayAndFormat: def.displayAndFormat
|
|
2065
|
+
},
|
|
2066
|
+
...def.sections && {
|
|
2067
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2068
|
+
},
|
|
2069
|
+
...def.submissionMetadata && {
|
|
2070
|
+
submissionMetadata: def.submissionMetadata
|
|
2071
|
+
}
|
|
1928
2072
|
});
|
|
1929
2073
|
}
|
|
1930
|
-
function defineDeleteObjectAction(
|
|
2074
|
+
function defineDeleteObjectAction(def) {
|
|
1931
2075
|
return defineAction({
|
|
1932
|
-
apiName: `delete-object-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`,
|
|
1933
|
-
displayName: `Delete ${objectType.displayName}`,
|
|
2076
|
+
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
2077
|
+
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
1934
2078
|
parameters: [{
|
|
1935
2079
|
id: "objectToDeleteParameter",
|
|
1936
2080
|
displayName: "Delete object",
|
|
1937
2081
|
type: {
|
|
1938
2082
|
type: "objectReference",
|
|
1939
2083
|
objectReference: {
|
|
1940
|
-
objectTypeId: objectType.apiName
|
|
2084
|
+
objectTypeId: def.objectType.apiName
|
|
1941
2085
|
}
|
|
1942
2086
|
},
|
|
1943
2087
|
validation: {
|
|
@@ -1947,22 +2091,94 @@ function defineDeleteObjectAction(objectType, validation) {
|
|
|
1947
2091
|
}
|
|
1948
2092
|
}
|
|
1949
2093
|
}],
|
|
1950
|
-
status: "active",
|
|
2094
|
+
status: def.status ?? "active",
|
|
2095
|
+
rules: [{
|
|
2096
|
+
type: "deleteObjectRule",
|
|
2097
|
+
deleteObjectRule: {
|
|
2098
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2099
|
+
}
|
|
2100
|
+
}],
|
|
1951
2101
|
entities: {
|
|
1952
2102
|
affectedInterfaceTypes: [],
|
|
1953
|
-
affectedObjectTypes: [objectType.apiName],
|
|
2103
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
1954
2104
|
affectedLinkTypes: [],
|
|
1955
2105
|
typeGroups: []
|
|
1956
2106
|
},
|
|
2107
|
+
...def.actionLevelValidation ? {
|
|
2108
|
+
validation: [convertValidationRule(def.actionLevelValidation)]
|
|
2109
|
+
} : {}
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2112
|
+
function defineCreateOrModifyObjectAction(def) {
|
|
2113
|
+
validateActionParameters(def);
|
|
2114
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2115
|
+
const parameterNames = new Set(propertyParameters);
|
|
2116
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2117
|
+
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2118
|
+
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2119
|
+
if (def.parameterOrdering) {
|
|
2120
|
+
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
2121
|
+
def.parameterOrdering = [CREATE_OR_MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2122
|
+
}
|
|
2123
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2124
|
+
}
|
|
2125
|
+
const parameters = createParameters(def, parameterNames, false);
|
|
2126
|
+
parameters.forEach((p) => {
|
|
2127
|
+
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2128
|
+
p.defaultValue = {
|
|
2129
|
+
type: "objectParameterPropertyValue",
|
|
2130
|
+
objectParameterPropertyValue: {
|
|
2131
|
+
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2132
|
+
propertyTypeId: p.id
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2138
|
+
return defineAction({
|
|
2139
|
+
apiName: actionApiName,
|
|
2140
|
+
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
2141
|
+
parameters,
|
|
2142
|
+
status: def.status ?? "active",
|
|
1957
2143
|
rules: [{
|
|
1958
|
-
type: "
|
|
1959
|
-
|
|
1960
|
-
|
|
2144
|
+
type: "addOrModifyObjectRuleV2",
|
|
2145
|
+
addOrModifyObjectRuleV2: {
|
|
2146
|
+
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2147
|
+
propertyValues: {
|
|
2148
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2149
|
+
type: "parameterId",
|
|
2150
|
+
parameterId: p
|
|
2151
|
+
}])),
|
|
2152
|
+
...mappings
|
|
2153
|
+
},
|
|
2154
|
+
structFieldValues: {}
|
|
1961
2155
|
}
|
|
1962
2156
|
}],
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
2157
|
+
entities: {
|
|
2158
|
+
affectedInterfaceTypes: [],
|
|
2159
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2160
|
+
affectedLinkTypes: [],
|
|
2161
|
+
typeGroups: []
|
|
2162
|
+
},
|
|
2163
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2164
|
+
...def.actionLevelValidation ? {
|
|
2165
|
+
validation: [convertValidationRule(def.actionLevelValidation)]
|
|
2166
|
+
} : {},
|
|
2167
|
+
...def.defaultFormat && {
|
|
2168
|
+
defaultFormat: def.defaultFormat
|
|
2169
|
+
},
|
|
2170
|
+
...def.enableLayoutSwitch && {
|
|
2171
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2172
|
+
},
|
|
2173
|
+
...def.displayAndFormat && {
|
|
2174
|
+
displayAndFormat: def.displayAndFormat
|
|
2175
|
+
},
|
|
2176
|
+
...def.sections && {
|
|
2177
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2178
|
+
},
|
|
2179
|
+
...def.submissionMetadata && {
|
|
2180
|
+
submissionMetadata: def.submissionMetadata
|
|
2181
|
+
}
|
|
1966
2182
|
});
|
|
1967
2183
|
}
|
|
1968
2184
|
function defineAction(actionDef) {
|
|
@@ -1999,13 +2215,88 @@ function defineAction(actionDef) {
|
|
|
1999
2215
|
},
|
|
2000
2216
|
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2001
2217
|
};
|
|
2002
|
-
|
|
2218
|
+
validateActionConfiguration(fullAction);
|
|
2003
2219
|
updateOntology(fullAction);
|
|
2004
2220
|
return fullAction;
|
|
2005
2221
|
}
|
|
2222
|
+
function createParameters(def, parameterSet, defaultRequired) {
|
|
2223
|
+
const targetParam = [];
|
|
2224
|
+
parameterSet.forEach((name) => {
|
|
2225
|
+
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
2226
|
+
targetParam.push({
|
|
2227
|
+
id: MODIFY_OBJECT_PARAMETER,
|
|
2228
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Modify object",
|
|
2229
|
+
type: {
|
|
2230
|
+
type: "objectReference",
|
|
2231
|
+
objectReference: {
|
|
2232
|
+
objectTypeId: def.objectType.apiName
|
|
2233
|
+
}
|
|
2234
|
+
},
|
|
2235
|
+
validation: {
|
|
2236
|
+
...def.parameterConfiguration?.[name],
|
|
2237
|
+
allowedValues: {
|
|
2238
|
+
type: "objectQuery"
|
|
2239
|
+
},
|
|
2240
|
+
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2241
|
+
},
|
|
2242
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2243
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2244
|
+
});
|
|
2245
|
+
parameterSet.delete(MODIFY_OBJECT_PARAMETER);
|
|
2246
|
+
}
|
|
2247
|
+
if (name === CREATE_OR_MODIFY_OBJECT_PARAMETER) {
|
|
2248
|
+
targetParam.push({
|
|
2249
|
+
id: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2250
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Create or modify object",
|
|
2251
|
+
type: {
|
|
2252
|
+
type: "objectReference",
|
|
2253
|
+
objectReference: {
|
|
2254
|
+
objectTypeId: def.objectType.apiName,
|
|
2255
|
+
maybeCreateObjectOption: !def.primaryKeyOption || def.primaryKeyOption === "autoGenerated" ? {
|
|
2256
|
+
type: "autoGenerated",
|
|
2257
|
+
autoGenerated: {}
|
|
2258
|
+
} : {
|
|
2259
|
+
type: "userInput",
|
|
2260
|
+
userInput: {}
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
},
|
|
2264
|
+
validation: {
|
|
2265
|
+
...def.parameterConfiguration?.[name],
|
|
2266
|
+
allowedValues: {
|
|
2267
|
+
type: "objectQuery"
|
|
2268
|
+
},
|
|
2269
|
+
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2270
|
+
},
|
|
2271
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2272
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2273
|
+
});
|
|
2274
|
+
parameterSet.delete(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
return [...targetParam, ...Array.from(parameterSet).map((id) => ({
|
|
2278
|
+
id,
|
|
2279
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ?? convertToDisplayName(id),
|
|
2280
|
+
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(def.objectType.properties?.[id]),
|
|
2281
|
+
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2282
|
+
...def.parameterConfiguration?.[id],
|
|
2283
|
+
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)),
|
|
2284
|
+
required: def.parameterConfiguration?.[id].required ?? defaultRequired
|
|
2285
|
+
} : {
|
|
2286
|
+
required: def.objectType.properties?.[id].array ?? false ? {
|
|
2287
|
+
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
2288
|
+
min: 1
|
|
2289
|
+
} : {}
|
|
2290
|
+
} : def.objectType.properties?.[id].nullability?.noNulls ?? defaultRequired,
|
|
2291
|
+
allowedValues: extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)
|
|
2292
|
+
},
|
|
2293
|
+
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2294
|
+
description: def.parameterConfiguration?.[id]?.description
|
|
2295
|
+
}))];
|
|
2296
|
+
}
|
|
2006
2297
|
function referencedParameterIds(actionDef) {
|
|
2007
2298
|
const parameterIds = /* @__PURE__ */ new Set();
|
|
2008
|
-
Object.values(actionDef.sections ?? {}).flatMap((p) => p).forEach((pId) => parameterIds.add(pId));
|
|
2299
|
+
Object.values(actionDef.sections ?? {}).flatMap((p) => p.parameters).forEach((pId) => parameterIds.add(pId));
|
|
2009
2300
|
(actionDef.formContentOrdering ?? []).forEach((item) => {
|
|
2010
2301
|
if (item.type === "parameterId") {
|
|
2011
2302
|
parameterIds.add(item.parameterId);
|
|
@@ -2059,7 +2350,80 @@ function referencedParameterIds(actionDef) {
|
|
|
2059
2350
|
});
|
|
2060
2351
|
return parameterIds;
|
|
2061
2352
|
}
|
|
2062
|
-
function
|
|
2353
|
+
function extractAllowedValuesFromActionParameterType(type) {
|
|
2354
|
+
if (typeof type === "object") {
|
|
2355
|
+
switch (type.type) {
|
|
2356
|
+
case "objectReference":
|
|
2357
|
+
case "objectReferenceList":
|
|
2358
|
+
return {
|
|
2359
|
+
type: "objectQuery"
|
|
2360
|
+
};
|
|
2361
|
+
case "struct":
|
|
2362
|
+
case "structList":
|
|
2363
|
+
throw new Error("Structs are not supported yet");
|
|
2364
|
+
default:
|
|
2365
|
+
throw new Error(`Inferred allowed values for ${type.type} not yet supported. Please explicitly provide allowed values.`);
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
switch (type) {
|
|
2369
|
+
case "boolean":
|
|
2370
|
+
case "booleanList":
|
|
2371
|
+
return {
|
|
2372
|
+
type: "boolean"
|
|
2373
|
+
};
|
|
2374
|
+
case "integer":
|
|
2375
|
+
case "integerList":
|
|
2376
|
+
case "decimal":
|
|
2377
|
+
case "decimalList":
|
|
2378
|
+
case "double":
|
|
2379
|
+
case "doubleList":
|
|
2380
|
+
case "long":
|
|
2381
|
+
case "longList":
|
|
2382
|
+
return {
|
|
2383
|
+
type: "range"
|
|
2384
|
+
};
|
|
2385
|
+
case "timestamp":
|
|
2386
|
+
case "timestampList":
|
|
2387
|
+
case "date":
|
|
2388
|
+
case "dateList":
|
|
2389
|
+
return {
|
|
2390
|
+
type: "datetime"
|
|
2391
|
+
};
|
|
2392
|
+
case "string":
|
|
2393
|
+
case "stringList":
|
|
2394
|
+
return {
|
|
2395
|
+
type: "text"
|
|
2396
|
+
};
|
|
2397
|
+
case "geohash":
|
|
2398
|
+
case "geohashList":
|
|
2399
|
+
return {
|
|
2400
|
+
type: "geohash"
|
|
2401
|
+
};
|
|
2402
|
+
case "geoshape":
|
|
2403
|
+
case "geoshapeList":
|
|
2404
|
+
return {
|
|
2405
|
+
type: "geoshape"
|
|
2406
|
+
};
|
|
2407
|
+
case "mediaReference":
|
|
2408
|
+
case "mediaReferenceList":
|
|
2409
|
+
return {
|
|
2410
|
+
type: "mediaReference"
|
|
2411
|
+
};
|
|
2412
|
+
case "geotimeSeriesReference":
|
|
2413
|
+
case "geotimeSeriesReferenceList":
|
|
2414
|
+
return {
|
|
2415
|
+
type: "geotimeSeriesReference"
|
|
2416
|
+
};
|
|
2417
|
+
case "attachment":
|
|
2418
|
+
case "attachmentList":
|
|
2419
|
+
return {
|
|
2420
|
+
type: "attachment"
|
|
2421
|
+
};
|
|
2422
|
+
default:
|
|
2423
|
+
throw new Error(`Inferred allowed values for ${type} not yet supported. Please explicitly provide allowed values.`);
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
function extractAllowedValuesFromPropertyType(type) {
|
|
2063
2427
|
switch (type) {
|
|
2064
2428
|
case "boolean":
|
|
2065
2429
|
return {
|
|
@@ -2142,6 +2506,10 @@ function extractAllowedValuesFromType(type) {
|
|
|
2142
2506
|
} : {
|
|
2143
2507
|
type: "mandatoryMarking"
|
|
2144
2508
|
};
|
|
2509
|
+
case "string":
|
|
2510
|
+
return {
|
|
2511
|
+
type: "text"
|
|
2512
|
+
};
|
|
2145
2513
|
case "struct":
|
|
2146
2514
|
throw new Error("Structs are not supported yet");
|
|
2147
2515
|
default:
|
|
@@ -2155,6 +2523,8 @@ function extractActionParameterType(pt) {
|
|
|
2155
2523
|
switch (typeType.type) {
|
|
2156
2524
|
case "marking":
|
|
2157
2525
|
return maybeAddList("marking", pt);
|
|
2526
|
+
case "string":
|
|
2527
|
+
return maybeAddList("string", pt);
|
|
2158
2528
|
case "struct":
|
|
2159
2529
|
throw new Error("Structs are not supported yet");
|
|
2160
2530
|
default:
|
|
@@ -2202,16 +2572,22 @@ function convertValidationRule(actionValidation) {
|
|
|
2202
2572
|
}
|
|
2203
2573
|
};
|
|
2204
2574
|
}
|
|
2205
|
-
function
|
|
2575
|
+
function validateActionConfiguration(action) {
|
|
2206
2576
|
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
2207
|
-
action.parameters?.
|
|
2577
|
+
const parameterMap = action.parameters?.reduce((acc, param) => {
|
|
2578
|
+
acc[param.id] = param;
|
|
2579
|
+
return acc;
|
|
2580
|
+
}, {}) ?? {};
|
|
2581
|
+
const orderedParameters = action.parameterOrdering?.map((id) => parameterMap[id]) ?? action.parameters;
|
|
2582
|
+
orderedParameters?.forEach((param) => {
|
|
2208
2583
|
param.validation.conditionalOverrides?.forEach((override) => {
|
|
2209
|
-
|
|
2584
|
+
validateParameterCondition(override.condition, param.id, seenParameterIds, action.parameters);
|
|
2210
2585
|
});
|
|
2586
|
+
validateParameterPrefill(param.id, seenParameterIds, action.parameters, param.defaultValue);
|
|
2211
2587
|
seenParameterIds.add(param.id);
|
|
2212
2588
|
});
|
|
2213
2589
|
}
|
|
2214
|
-
function
|
|
2590
|
+
function validateParameterCondition(condition, currentParameterId, seenParameterIds, parameters) {
|
|
2215
2591
|
switch (condition.type) {
|
|
2216
2592
|
case "parameter":
|
|
2217
2593
|
const overrideParamId = condition.parameterId;
|
|
@@ -2221,12 +2597,12 @@ function validateActionCondition(condition, currentParameterId, seenParameterIds
|
|
|
2221
2597
|
break;
|
|
2222
2598
|
case "and":
|
|
2223
2599
|
if ("conditions" in condition) {
|
|
2224
|
-
condition.conditions.forEach((c) =>
|
|
2600
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2225
2601
|
}
|
|
2226
2602
|
break;
|
|
2227
2603
|
case "or":
|
|
2228
2604
|
if ("conditions" in condition) {
|
|
2229
|
-
condition.conditions.forEach((c) =>
|
|
2605
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2230
2606
|
}
|
|
2231
2607
|
break;
|
|
2232
2608
|
case "comparison":
|
|
@@ -2241,6 +2617,44 @@ function validateActionCondition(condition, currentParameterId, seenParameterIds
|
|
|
2241
2617
|
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2242
2618
|
}
|
|
2243
2619
|
}
|
|
2620
|
+
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
2621
|
+
if (!defaultValue) return;
|
|
2622
|
+
switch (defaultValue.type) {
|
|
2623
|
+
case "objectParameterPropertyValue":
|
|
2624
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant5__default.default(false) : void 0;
|
|
2625
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant5__default.default(false) : void 0;
|
|
2626
|
+
break;
|
|
2627
|
+
case "staticValue":
|
|
2628
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant5__default.default(false) : void 0;
|
|
2629
|
+
break;
|
|
2630
|
+
case "staticObject":
|
|
2631
|
+
case "interfaceParameterPropertyValue":
|
|
2632
|
+
case "objectQueryPrefill":
|
|
2633
|
+
case "objectQueryPropertyValue":
|
|
2634
|
+
case "objectSetRidPrefill":
|
|
2635
|
+
case "redacted":
|
|
2636
|
+
break;
|
|
2637
|
+
default:
|
|
2638
|
+
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
function validateActionParameters(def) {
|
|
2642
|
+
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2643
|
+
!(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" ? invariant5__default.default(false, `Parameter ${id} does not exist as a property on ${def.objectType.apiName} and its type is not explicitly defined`) : invariant5__default.default(false) : void 0;
|
|
2644
|
+
});
|
|
2645
|
+
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2646
|
+
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Property ${id} does not exist as a property on ${def.objectType.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
2650
|
+
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}), ...Object.keys(def.objectType.properties ?? {}).filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
2651
|
+
}
|
|
2652
|
+
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
2653
|
+
const orderingSet = new Set(parameterOrdering);
|
|
2654
|
+
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2655
|
+
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2656
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant5__default.default(false) : void 0;
|
|
2657
|
+
}
|
|
2244
2658
|
|
|
2245
2659
|
// src/api/importOntologyEntity.ts
|
|
2246
2660
|
function importOntologyEntity(e) {
|
|
@@ -2418,10 +2832,10 @@ function getLinkMeta(meta) {
|
|
|
2418
2832
|
var typeIdPattern = /([a-z][a-z0-9\\-]*)/;
|
|
2419
2833
|
function defineLink(linkDefinition) {
|
|
2420
2834
|
if ("one" in linkDefinition) {
|
|
2421
|
-
const foreignKey = linkDefinition.toMany.object.properties?.
|
|
2835
|
+
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2422
2836
|
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`) : invariant5__default.default(false) : void 0;
|
|
2423
2837
|
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__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`) : invariant5__default.default(false) : void 0;
|
|
2424
|
-
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.
|
|
2838
|
+
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2425
2839
|
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant5__default.default(false) : void 0;
|
|
2426
2840
|
}
|
|
2427
2841
|
const fullLinkDefinition = "one" in linkDefinition ? {
|
|
@@ -2562,12 +2976,19 @@ function wrapWithProxy(entity) {
|
|
|
2562
2976
|
});
|
|
2563
2977
|
}
|
|
2564
2978
|
|
|
2979
|
+
exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;
|
|
2980
|
+
exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
2565
2981
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
2566
2982
|
exports.addDependency = addDependency;
|
|
2983
|
+
exports.addNamespaceIfNone = addNamespaceIfNone;
|
|
2984
|
+
exports.convertToDisplayName = convertToDisplayName;
|
|
2985
|
+
exports.convertToPluralDisplayName = convertToPluralDisplayName;
|
|
2986
|
+
exports.convertType = convertType;
|
|
2567
2987
|
exports.default = main;
|
|
2568
2988
|
exports.defineAction = defineAction;
|
|
2569
2989
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
2570
2990
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
2991
|
+
exports.defineCreateOrModifyObjectAction = defineCreateOrModifyObjectAction;
|
|
2571
2992
|
exports.defineDeleteObjectAction = defineDeleteObjectAction;
|
|
2572
2993
|
exports.defineInterface = defineInterface;
|
|
2573
2994
|
exports.defineInterfaceLinkConstraint = defineInterfaceLinkConstraint;
|
|
@@ -2578,6 +2999,7 @@ exports.defineObject = defineObject;
|
|
|
2578
2999
|
exports.defineOntology = defineOntology;
|
|
2579
3000
|
exports.defineSharedPropertyType = defineSharedPropertyType;
|
|
2580
3001
|
exports.defineValueType = defineValueType;
|
|
3002
|
+
exports.dumpOntologyFullMetadata = dumpOntologyFullMetadata;
|
|
2581
3003
|
exports.importOntologyEntity = importOntologyEntity;
|
|
2582
3004
|
exports.importSharedPropertyType = importSharedPropertyType;
|
|
2583
3005
|
exports.wrapWithProxy = wrapWithProxy;
|