@osdk/maker 0.12.0-beta.9 → 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 +128 -0
- package/README.md +1 -1
- package/build/browser/api/defineAction.js +373 -89
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineOntology.js +78 -33
- 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 +4289 -2577
- 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 +537 -131
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +78 -9
- package/build/esm/api/defineAction.js +373 -89
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineOntology.js +78 -33
- 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 +4289 -2577
- 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 +1 -0
- package/build/types/api/defineAction.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 +69 -7
- 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 +5 -5
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))$/;
|
|
@@ -170,8 +171,6 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
170
171
|
type: property.type
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
-
// src/api/ontologyUtils.ts
|
|
175
174
|
function convertActionVisibility(visibility) {
|
|
176
175
|
switch (visibility) {
|
|
177
176
|
case "editable":
|
|
@@ -241,6 +240,22 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
241
240
|
}
|
|
242
241
|
};
|
|
243
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;
|
|
244
259
|
default:
|
|
245
260
|
throw new Error(`Unknown parameter override type`);
|
|
246
261
|
}
|
|
@@ -249,6 +264,23 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
249
264
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
250
265
|
};
|
|
251
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
|
+
}
|
|
252
284
|
function convertConditionDefinition(condition) {
|
|
253
285
|
switch (condition.type) {
|
|
254
286
|
case "and":
|
|
@@ -318,6 +350,51 @@ function convertConditionDefinition(condition) {
|
|
|
318
350
|
return condition;
|
|
319
351
|
}
|
|
320
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
|
+
}
|
|
321
398
|
var defaultTypeClasses = [{
|
|
322
399
|
kind: "render_hint",
|
|
323
400
|
name: "SELECTABLE"
|
|
@@ -704,7 +781,11 @@ function convertToWireImportedTypes(importedTypes2) {
|
|
|
704
781
|
apiName: spt.sharedPropertyType.apiName,
|
|
705
782
|
displayName: spt.sharedPropertyType.displayMetadata.displayName,
|
|
706
783
|
description: spt.sharedPropertyType.displayMetadata.description,
|
|
707
|
-
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
|
+
}
|
|
708
789
|
})),
|
|
709
790
|
objectTypes: Object.values(asBlockData.objectTypes).map((ot) => ({
|
|
710
791
|
apiName: ot.objectType.apiName,
|
|
@@ -1090,7 +1171,7 @@ function convertLink(linkType) {
|
|
|
1090
1171
|
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1091
1172
|
object: linkType.toMany.object.apiName
|
|
1092
1173
|
},
|
|
1093
|
-
column: linkType.
|
|
1174
|
+
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
1094
1175
|
}]
|
|
1095
1176
|
}
|
|
1096
1177
|
},
|
|
@@ -1143,6 +1224,9 @@ function convertInterface(interfaceType) {
|
|
|
1143
1224
|
properties: []
|
|
1144
1225
|
};
|
|
1145
1226
|
}
|
|
1227
|
+
function dumpOntologyFullMetadata() {
|
|
1228
|
+
return convertToWireOntologyIr(ontologyDefinition);
|
|
1229
|
+
}
|
|
1146
1230
|
function convertSpt({
|
|
1147
1231
|
type,
|
|
1148
1232
|
array,
|
|
@@ -1178,7 +1262,10 @@ function convertSpt({
|
|
|
1178
1262
|
gothamMapping,
|
|
1179
1263
|
indexedForSearch: true,
|
|
1180
1264
|
typeClasses: typeClasses ?? [],
|
|
1181
|
-
valueType
|
|
1265
|
+
valueType: valueType === void 0 ? void 0 : {
|
|
1266
|
+
apiName: valueType.apiName,
|
|
1267
|
+
version: valueType.version
|
|
1268
|
+
}
|
|
1182
1269
|
};
|
|
1183
1270
|
}
|
|
1184
1271
|
function convertObjectStatus(status) {
|
|
@@ -1216,6 +1303,7 @@ function convertAction(action) {
|
|
|
1216
1303
|
const actionValidation = convertActionValidation(action);
|
|
1217
1304
|
const actionParameters = convertActionParameters(action);
|
|
1218
1305
|
const actionSections = convertActionSections(action);
|
|
1306
|
+
const parameterOrdering = action.parameterOrdering ?? (action.parameters ?? []).map((p) => p.id);
|
|
1219
1307
|
return {
|
|
1220
1308
|
actionType: {
|
|
1221
1309
|
actionTypeLogic: {
|
|
@@ -1228,8 +1316,8 @@ function convertAction(action) {
|
|
|
1228
1316
|
apiName: action.apiName,
|
|
1229
1317
|
displayMetadata: {
|
|
1230
1318
|
configuration: {
|
|
1231
|
-
defaultLayout: "FORM",
|
|
1232
|
-
displayAndFormat: {
|
|
1319
|
+
defaultLayout: action.defaultFormat ?? "FORM",
|
|
1320
|
+
displayAndFormat: action.displayAndFormat ?? {
|
|
1233
1321
|
table: {
|
|
1234
1322
|
columnWidthByParameterRid: {},
|
|
1235
1323
|
enableFileImport: true,
|
|
@@ -1238,7 +1326,7 @@ function convertAction(action) {
|
|
|
1238
1326
|
rowHeightInLines: 1
|
|
1239
1327
|
}
|
|
1240
1328
|
},
|
|
1241
|
-
enableLayoutUserSwitch: false
|
|
1329
|
+
enableLayoutUserSwitch: action.enableLayoutSwitch ?? false
|
|
1242
1330
|
},
|
|
1243
1331
|
description: action.description ?? "",
|
|
1244
1332
|
displayName: action.displayName,
|
|
@@ -1249,11 +1337,20 @@ function convertAction(action) {
|
|
|
1249
1337
|
color: "#000000"
|
|
1250
1338
|
}
|
|
1251
1339
|
},
|
|
1252
|
-
successMessage: [
|
|
1253
|
-
|
|
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
|
+
}
|
|
1254
1351
|
},
|
|
1255
|
-
|
|
1256
|
-
|
|
1352
|
+
parameterOrdering,
|
|
1353
|
+
formContentOrdering: getFormContentOrdering(action, parameterOrdering),
|
|
1257
1354
|
parameters: actionParameters,
|
|
1258
1355
|
sections: actionSections,
|
|
1259
1356
|
status: typeof action.status === "string" ? {
|
|
@@ -1284,16 +1381,35 @@ function convertActionValidation(action) {
|
|
|
1284
1381
|
defaultValidation: {
|
|
1285
1382
|
display: {
|
|
1286
1383
|
renderHint: renderHintFromBaseType(p),
|
|
1287
|
-
visibility: convertActionVisibility(p.validation.defaultVisibility)
|
|
1384
|
+
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
1385
|
+
...p.defaultValue && {
|
|
1386
|
+
prefill: p.defaultValue
|
|
1387
|
+
}
|
|
1288
1388
|
},
|
|
1289
1389
|
validation: {
|
|
1290
|
-
allowedValues: extractAllowedValues(p),
|
|
1390
|
+
allowedValues: extractAllowedValues(p.validation.allowedValues),
|
|
1291
1391
|
required: convertParameterRequirementConstraint(p.validation.required)
|
|
1292
1392
|
}
|
|
1293
1393
|
},
|
|
1294
1394
|
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation)) ?? []
|
|
1295
1395
|
}];
|
|
1296
|
-
}))
|
|
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
|
+
}
|
|
1297
1413
|
};
|
|
1298
1414
|
}
|
|
1299
1415
|
function convertActionParameters(action) {
|
|
@@ -1311,32 +1427,41 @@ function convertActionParameters(action) {
|
|
|
1311
1427
|
}]));
|
|
1312
1428
|
}
|
|
1313
1429
|
function convertActionSections(action) {
|
|
1314
|
-
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId,
|
|
1430
|
+
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [sectionId, {
|
|
1315
1431
|
id: sectionId,
|
|
1316
|
-
content:
|
|
1432
|
+
content: section.parameters.map((p) => ({
|
|
1317
1433
|
type: "parameterId",
|
|
1318
1434
|
parameterId: p
|
|
1319
1435
|
})),
|
|
1320
1436
|
displayMetadata: {
|
|
1321
|
-
collapsedByDefault: false,
|
|
1322
|
-
columnCount: 1,
|
|
1323
|
-
description: "",
|
|
1324
|
-
displayName: sectionId,
|
|
1325
|
-
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
|
+
}
|
|
1326
1451
|
}
|
|
1327
1452
|
}]));
|
|
1328
1453
|
}
|
|
1329
|
-
function extractAllowedValues(
|
|
1330
|
-
switch (
|
|
1454
|
+
function extractAllowedValues(allowedValues) {
|
|
1455
|
+
switch (allowedValues.type) {
|
|
1331
1456
|
case "oneOf":
|
|
1332
1457
|
return {
|
|
1333
1458
|
type: "oneOf",
|
|
1334
1459
|
oneOf: {
|
|
1335
1460
|
type: "oneOf",
|
|
1336
1461
|
oneOf: {
|
|
1337
|
-
labelledValues:
|
|
1462
|
+
labelledValues: allowedValues.oneOf,
|
|
1338
1463
|
otherValueAllowed: {
|
|
1339
|
-
allowed: false
|
|
1464
|
+
allowed: allowedValues.otherValueAllowed ?? false
|
|
1340
1465
|
}
|
|
1341
1466
|
}
|
|
1342
1467
|
}
|
|
@@ -1345,7 +1470,7 @@ function extractAllowedValues(parameter) {
|
|
|
1345
1470
|
const {
|
|
1346
1471
|
min,
|
|
1347
1472
|
max
|
|
1348
|
-
} =
|
|
1473
|
+
} = allowedValues;
|
|
1349
1474
|
return {
|
|
1350
1475
|
type: "range",
|
|
1351
1476
|
range: {
|
|
@@ -1371,17 +1496,17 @@ function extractAllowedValues(parameter) {
|
|
|
1371
1496
|
minLength,
|
|
1372
1497
|
maxLength,
|
|
1373
1498
|
regex
|
|
1374
|
-
} =
|
|
1499
|
+
} = allowedValues;
|
|
1375
1500
|
return {
|
|
1376
1501
|
type: "text",
|
|
1377
1502
|
text: {
|
|
1378
1503
|
type: "text",
|
|
1379
1504
|
text: {
|
|
1380
1505
|
...minLength === void 0 ? {} : {
|
|
1381
|
-
|
|
1506
|
+
minLength
|
|
1382
1507
|
},
|
|
1383
1508
|
...maxLength === void 0 ? {} : {
|
|
1384
|
-
|
|
1509
|
+
maxLength
|
|
1385
1510
|
},
|
|
1386
1511
|
...regex === void 0 ? {} : {
|
|
1387
1512
|
regex: {
|
|
@@ -1396,7 +1521,7 @@ function extractAllowedValues(parameter) {
|
|
|
1396
1521
|
const {
|
|
1397
1522
|
minimum,
|
|
1398
1523
|
maximum
|
|
1399
|
-
} =
|
|
1524
|
+
} = allowedValues;
|
|
1400
1525
|
return {
|
|
1401
1526
|
type: "datetime",
|
|
1402
1527
|
datetime: {
|
|
@@ -1413,7 +1538,7 @@ function extractAllowedValues(parameter) {
|
|
|
1413
1538
|
objectTypeReference: {
|
|
1414
1539
|
type: "objectTypeReference",
|
|
1415
1540
|
objectTypeReference: {
|
|
1416
|
-
interfaceTypeRids:
|
|
1541
|
+
interfaceTypeRids: allowedValues.interfaceTypes
|
|
1417
1542
|
}
|
|
1418
1543
|
}
|
|
1419
1544
|
};
|
|
@@ -1431,7 +1556,7 @@ function extractAllowedValues(parameter) {
|
|
|
1431
1556
|
}
|
|
1432
1557
|
};
|
|
1433
1558
|
default:
|
|
1434
|
-
const k =
|
|
1559
|
+
const k = allowedValues.type;
|
|
1435
1560
|
return {
|
|
1436
1561
|
type: k,
|
|
1437
1562
|
[k]: {
|
|
@@ -1596,7 +1721,7 @@ function convertCardinality(cardinality) {
|
|
|
1596
1721
|
// src/cli/main.ts
|
|
1597
1722
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1598
1723
|
async function main(args = process.argv) {
|
|
1599
|
-
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({
|
|
1600
1725
|
input: {
|
|
1601
1726
|
alias: "i",
|
|
1602
1727
|
describe: "Input file",
|
|
@@ -1656,14 +1781,7 @@ async function main(args = process.argv) {
|
|
|
1656
1781
|
}
|
|
1657
1782
|
}
|
|
1658
1783
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
1659
|
-
const q = await defineOntology(apiNamespace, async () =>
|
|
1660
|
-
const jiti$1 = jiti.createJiti(undefined, {
|
|
1661
|
-
moduleCache: true,
|
|
1662
|
-
debug: false,
|
|
1663
|
-
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)) })
|
|
1664
|
-
});
|
|
1665
|
-
const module = await jiti$1.import(input);
|
|
1666
|
-
}, outputDir, dependencyFile);
|
|
1784
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile);
|
|
1667
1785
|
return q;
|
|
1668
1786
|
}
|
|
1669
1787
|
var MAX_SEARCH_DEPTH = 5;
|
|
@@ -1730,7 +1848,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1730
1848
|
required: prop.sharedPropertyType.array ?? false ? {
|
|
1731
1849
|
listLength: {}
|
|
1732
1850
|
} : prop.required,
|
|
1733
|
-
allowedValues:
|
|
1851
|
+
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1734
1852
|
}
|
|
1735
1853
|
}))],
|
|
1736
1854
|
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
@@ -1757,32 +1875,18 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1757
1875
|
});
|
|
1758
1876
|
}
|
|
1759
1877
|
function defineCreateObjectAction(def) {
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
(def.
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
type: extractActionParameterType(def.objectType.properties?.[id]),
|
|
1771
|
-
validation: def.parameterLevelValidations?.[id] !== void 0 ? {
|
|
1772
|
-
...def.parameterLevelValidations?.[id],
|
|
1773
|
-
allowedValues: def.parameterLevelValidations?.[id].allowedValues ?? extractAllowedValuesFromType(def.objectType.properties?.[id].type),
|
|
1774
|
-
required: def.parameterLevelValidations?.[id].required ?? true
|
|
1775
|
-
} : {
|
|
1776
|
-
required: def.objectType.properties?.[id].array ?? false ? {
|
|
1777
|
-
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
1778
|
-
min: 1
|
|
1779
|
-
} : {}
|
|
1780
|
-
} : def.objectType.properties?.[id].nullability?.noNulls ?? true,
|
|
1781
|
-
allowedValues: extractAllowedValuesFromType(def.objectType.properties?.[id].type)
|
|
1782
|
-
}
|
|
1783
|
-
}));
|
|
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);
|
|
1885
|
+
}
|
|
1886
|
+
const parameters = createParameters(def, parameterNames, true);
|
|
1887
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
1784
1888
|
return defineAction({
|
|
1785
|
-
apiName:
|
|
1889
|
+
apiName: actionApiName,
|
|
1786
1890
|
displayName: def.displayName ?? `Create ${def.objectType.displayName}`,
|
|
1787
1891
|
parameters,
|
|
1788
1892
|
status: def.status ?? "active",
|
|
@@ -1796,16 +1900,35 @@ function defineCreateObjectAction(def) {
|
|
|
1796
1900
|
type: "addObjectRule",
|
|
1797
1901
|
addObjectRule: {
|
|
1798
1902
|
objectTypeId: def.objectType.apiName,
|
|
1799
|
-
propertyValues:
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1903
|
+
propertyValues: {
|
|
1904
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
1905
|
+
type: "parameterId",
|
|
1906
|
+
parameterId: p
|
|
1907
|
+
}])),
|
|
1908
|
+
...mappings
|
|
1909
|
+
},
|
|
1803
1910
|
structFieldValues: {}
|
|
1804
1911
|
}
|
|
1805
1912
|
}],
|
|
1913
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1806
1914
|
...def.actionLevelValidation ? {
|
|
1807
1915
|
validation: [convertValidationRule(def.actionLevelValidation)]
|
|
1808
|
-
} : {}
|
|
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
|
+
}
|
|
1809
1932
|
});
|
|
1810
1933
|
}
|
|
1811
1934
|
function defineModifyInterfaceObjectAction(interfaceType, objectType, validation) {
|
|
@@ -1851,7 +1974,7 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1851
1974
|
required: prop.sharedPropertyType.array ?? false ? {
|
|
1852
1975
|
listLength: {}
|
|
1853
1976
|
} : prop.required,
|
|
1854
|
-
allowedValues:
|
|
1977
|
+
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1855
1978
|
}
|
|
1856
1979
|
}))],
|
|
1857
1980
|
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
@@ -1877,58 +2000,47 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1877
2000
|
});
|
|
1878
2001
|
}
|
|
1879
2002
|
function defineModifyObjectAction(def) {
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
(def.
|
|
1884
|
-
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
displayName: def.objectType.properties?.[id].displayName ?? convertToDisplayName(id),
|
|
1890
|
-
type: extractActionParameterType(def.objectType.properties?.[id]),
|
|
1891
|
-
validation: def.parameterLevelValidations?.[id] !== void 0 ? {
|
|
1892
|
-
...def.parameterLevelValidations?.[id],
|
|
1893
|
-
allowedValues: def.parameterLevelValidations?.[id].allowedValues ?? extractAllowedValuesFromType(def.objectType.properties?.[id].type),
|
|
1894
|
-
required: def.parameterLevelValidations?.[id].required ?? false
|
|
1895
|
-
} : {
|
|
1896
|
-
required: def.objectType.properties?.[id].array ?? false ? {
|
|
1897
|
-
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
1898
|
-
min: 1
|
|
1899
|
-
} : {}
|
|
1900
|
-
} : def.objectType.properties?.[id].nullability?.noNulls ?? false,
|
|
1901
|
-
allowedValues: extractAllowedValuesFromType(def.objectType.properties?.[id].type)
|
|
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];
|
|
1902
2012
|
}
|
|
1903
|
-
|
|
2013
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2014
|
+
}
|
|
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
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
});
|
|
2027
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
1904
2028
|
return defineAction({
|
|
1905
|
-
apiName:
|
|
2029
|
+
apiName: actionApiName,
|
|
1906
2030
|
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
1907
|
-
parameters
|
|
1908
|
-
id: "objectToModifyParameter",
|
|
1909
|
-
displayName: "Modify object",
|
|
1910
|
-
type: {
|
|
1911
|
-
type: "objectReference",
|
|
1912
|
-
objectReference: {
|
|
1913
|
-
objectTypeId: def.objectType.apiName
|
|
1914
|
-
}
|
|
1915
|
-
},
|
|
1916
|
-
validation: {
|
|
1917
|
-
allowedValues: {
|
|
1918
|
-
type: "objectQuery"
|
|
1919
|
-
},
|
|
1920
|
-
required: true
|
|
1921
|
-
}
|
|
1922
|
-
}, ...parameters],
|
|
2031
|
+
parameters,
|
|
1923
2032
|
status: def.status ?? "active",
|
|
1924
2033
|
rules: [{
|
|
1925
2034
|
type: "modifyObjectRule",
|
|
1926
2035
|
modifyObjectRule: {
|
|
1927
|
-
objectToModify:
|
|
1928
|
-
propertyValues:
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2036
|
+
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
2037
|
+
propertyValues: {
|
|
2038
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2039
|
+
type: "parameterId",
|
|
2040
|
+
parameterId: p
|
|
2041
|
+
}])),
|
|
2042
|
+
...mappings
|
|
2043
|
+
},
|
|
1932
2044
|
structFieldValues: {}
|
|
1933
2045
|
}
|
|
1934
2046
|
}],
|
|
@@ -1938,9 +2050,25 @@ function defineModifyObjectAction(def) {
|
|
|
1938
2050
|
affectedLinkTypes: [],
|
|
1939
2051
|
typeGroups: []
|
|
1940
2052
|
},
|
|
2053
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
1941
2054
|
...def.actionLevelValidation ? {
|
|
1942
2055
|
validation: [convertValidationRule(def.actionLevelValidation)]
|
|
1943
|
-
} : {}
|
|
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
|
+
}
|
|
1944
2072
|
});
|
|
1945
2073
|
}
|
|
1946
2074
|
function defineDeleteObjectAction(def) {
|
|
@@ -1981,6 +2109,78 @@ function defineDeleteObjectAction(def) {
|
|
|
1981
2109
|
} : {}
|
|
1982
2110
|
});
|
|
1983
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",
|
|
2143
|
+
rules: [{
|
|
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: {}
|
|
2155
|
+
}
|
|
2156
|
+
}],
|
|
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
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
1984
2184
|
function defineAction(actionDef) {
|
|
1985
2185
|
const apiName = namespace + actionDef.apiName;
|
|
1986
2186
|
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
@@ -2015,13 +2215,88 @@ function defineAction(actionDef) {
|
|
|
2015
2215
|
},
|
|
2016
2216
|
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2017
2217
|
};
|
|
2018
|
-
|
|
2218
|
+
validateActionConfiguration(fullAction);
|
|
2019
2219
|
updateOntology(fullAction);
|
|
2020
2220
|
return fullAction;
|
|
2021
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
|
+
}
|
|
2022
2297
|
function referencedParameterIds(actionDef) {
|
|
2023
2298
|
const parameterIds = /* @__PURE__ */ new Set();
|
|
2024
|
-
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));
|
|
2025
2300
|
(actionDef.formContentOrdering ?? []).forEach((item) => {
|
|
2026
2301
|
if (item.type === "parameterId") {
|
|
2027
2302
|
parameterIds.add(item.parameterId);
|
|
@@ -2075,7 +2350,80 @@ function referencedParameterIds(actionDef) {
|
|
|
2075
2350
|
});
|
|
2076
2351
|
return parameterIds;
|
|
2077
2352
|
}
|
|
2078
|
-
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) {
|
|
2079
2427
|
switch (type) {
|
|
2080
2428
|
case "boolean":
|
|
2081
2429
|
return {
|
|
@@ -2158,6 +2506,10 @@ function extractAllowedValuesFromType(type) {
|
|
|
2158
2506
|
} : {
|
|
2159
2507
|
type: "mandatoryMarking"
|
|
2160
2508
|
};
|
|
2509
|
+
case "string":
|
|
2510
|
+
return {
|
|
2511
|
+
type: "text"
|
|
2512
|
+
};
|
|
2161
2513
|
case "struct":
|
|
2162
2514
|
throw new Error("Structs are not supported yet");
|
|
2163
2515
|
default:
|
|
@@ -2171,6 +2523,8 @@ function extractActionParameterType(pt) {
|
|
|
2171
2523
|
switch (typeType.type) {
|
|
2172
2524
|
case "marking":
|
|
2173
2525
|
return maybeAddList("marking", pt);
|
|
2526
|
+
case "string":
|
|
2527
|
+
return maybeAddList("string", pt);
|
|
2174
2528
|
case "struct":
|
|
2175
2529
|
throw new Error("Structs are not supported yet");
|
|
2176
2530
|
default:
|
|
@@ -2218,16 +2572,22 @@ function convertValidationRule(actionValidation) {
|
|
|
2218
2572
|
}
|
|
2219
2573
|
};
|
|
2220
2574
|
}
|
|
2221
|
-
function
|
|
2575
|
+
function validateActionConfiguration(action) {
|
|
2222
2576
|
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
2223
|
-
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) => {
|
|
2224
2583
|
param.validation.conditionalOverrides?.forEach((override) => {
|
|
2225
|
-
|
|
2584
|
+
validateParameterCondition(override.condition, param.id, seenParameterIds, action.parameters);
|
|
2226
2585
|
});
|
|
2586
|
+
validateParameterPrefill(param.id, seenParameterIds, action.parameters, param.defaultValue);
|
|
2227
2587
|
seenParameterIds.add(param.id);
|
|
2228
2588
|
});
|
|
2229
2589
|
}
|
|
2230
|
-
function
|
|
2590
|
+
function validateParameterCondition(condition, currentParameterId, seenParameterIds, parameters) {
|
|
2231
2591
|
switch (condition.type) {
|
|
2232
2592
|
case "parameter":
|
|
2233
2593
|
const overrideParamId = condition.parameterId;
|
|
@@ -2237,12 +2597,12 @@ function validateActionCondition(condition, currentParameterId, seenParameterIds
|
|
|
2237
2597
|
break;
|
|
2238
2598
|
case "and":
|
|
2239
2599
|
if ("conditions" in condition) {
|
|
2240
|
-
condition.conditions.forEach((c) =>
|
|
2600
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2241
2601
|
}
|
|
2242
2602
|
break;
|
|
2243
2603
|
case "or":
|
|
2244
2604
|
if ("conditions" in condition) {
|
|
2245
|
-
condition.conditions.forEach((c) =>
|
|
2605
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2246
2606
|
}
|
|
2247
2607
|
break;
|
|
2248
2608
|
case "comparison":
|
|
@@ -2257,6 +2617,44 @@ function validateActionCondition(condition, currentParameterId, seenParameterIds
|
|
|
2257
2617
|
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2258
2618
|
}
|
|
2259
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
|
+
}
|
|
2260
2658
|
|
|
2261
2659
|
// src/api/importOntologyEntity.ts
|
|
2262
2660
|
function importOntologyEntity(e) {
|
|
@@ -2578,12 +2976,19 @@ function wrapWithProxy(entity) {
|
|
|
2578
2976
|
});
|
|
2579
2977
|
}
|
|
2580
2978
|
|
|
2979
|
+
exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;
|
|
2980
|
+
exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
2581
2981
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
2582
2982
|
exports.addDependency = addDependency;
|
|
2983
|
+
exports.addNamespaceIfNone = addNamespaceIfNone;
|
|
2984
|
+
exports.convertToDisplayName = convertToDisplayName;
|
|
2985
|
+
exports.convertToPluralDisplayName = convertToPluralDisplayName;
|
|
2986
|
+
exports.convertType = convertType;
|
|
2583
2987
|
exports.default = main;
|
|
2584
2988
|
exports.defineAction = defineAction;
|
|
2585
2989
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
2586
2990
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
2991
|
+
exports.defineCreateOrModifyObjectAction = defineCreateOrModifyObjectAction;
|
|
2587
2992
|
exports.defineDeleteObjectAction = defineDeleteObjectAction;
|
|
2588
2993
|
exports.defineInterface = defineInterface;
|
|
2589
2994
|
exports.defineInterfaceLinkConstraint = defineInterfaceLinkConstraint;
|
|
@@ -2594,6 +2999,7 @@ exports.defineObject = defineObject;
|
|
|
2594
2999
|
exports.defineOntology = defineOntology;
|
|
2595
3000
|
exports.defineSharedPropertyType = defineSharedPropertyType;
|
|
2596
3001
|
exports.defineValueType = defineValueType;
|
|
3002
|
+
exports.dumpOntologyFullMetadata = dumpOntologyFullMetadata;
|
|
2597
3003
|
exports.importOntologyEntity = importOntologyEntity;
|
|
2598
3004
|
exports.importSharedPropertyType = importSharedPropertyType;
|
|
2599
3005
|
exports.wrapWithProxy = wrapWithProxy;
|