@party-stack/foundry-ontology 0.13.0 → 0.14.1
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/lib/adapter/createFoundryOntologyBackendAdapter.d.ts.map +1 -1
- package/lib/adapter/createFoundryOntologyBackendAdapter.js +1 -2
- package/lib/adapter/createFoundryOntologyBackendAdapter.js.map +1 -1
- package/lib/adapter/createFoundryOntologyBackendAdapter.test.js +1 -1
- package/lib/adapter/createFoundryOntologyBackendAdapter.test.js.map +1 -1
- package/lib/config/connectionPull.test.js +7 -2
- package/lib/config/connectionPull.test.js.map +1 -1
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +29 -20
- package/lib/config/index.js.map +1 -1
- package/lib/config/index.test.js +2 -2
- package/lib/config/index.test.js.map +1 -1
- package/lib/connection.d.ts.map +1 -1
- package/lib/connection.js +2 -0
- package/lib/connection.js.map +1 -1
- package/lib/installation/createFoundryBackendInstallation.d.ts.map +1 -1
- package/lib/installation/createFoundryBackendInstallation.js +3 -3
- package/lib/installation/createFoundryBackendInstallation.js.map +1 -1
- package/lib/meta/actionTypeCollectionOptions.d.ts.map +1 -1
- package/lib/meta/actionTypeCollectionOptions.js +16 -11
- package/lib/meta/actionTypeCollectionOptions.js.map +1 -1
- package/lib/meta/actionTypeIdQuery.test.js +55 -10
- package/lib/meta/actionTypeIdQuery.test.js.map +1 -1
- package/lib/meta/convertMetaActionType.d.ts.map +1 -1
- package/lib/meta/convertMetaActionType.js +111 -37
- package/lib/meta/convertMetaActionType.js.map +1 -1
- package/lib/meta/convertMetaActionType.test.js +622 -79
- package/lib/meta/convertMetaActionType.test.js.map +1 -1
- package/lib/meta/convertOmsActionParameterMetadata.d.ts +6 -0
- package/lib/meta/convertOmsActionParameterMetadata.d.ts.map +1 -0
- package/lib/meta/convertOmsActionParameterMetadata.js +177 -0
- package/lib/meta/convertOmsActionParameterMetadata.js.map +1 -0
- package/lib/meta/entityCollectionOptions.js.map +1 -1
- package/lib/meta/loadActionTypeOmsMetadata.d.ts +6 -1
- package/lib/meta/loadActionTypeOmsMetadata.d.ts.map +1 -1
- package/lib/meta/loadActionTypeOmsMetadata.js +118 -9
- package/lib/meta/loadActionTypeOmsMetadata.js.map +1 -1
- package/lib/meta/loadActionTypeOmsMetadata.test.js +85 -5
- package/lib/meta/loadActionTypeOmsMetadata.test.js.map +1 -1
- package/lib/utils/AsyncIterable.d.ts +1 -0
- package/lib/utils/AsyncIterable.d.ts.map +1 -1
- package/lib/utils/AsyncIterable.js +11 -0
- package/lib/utils/AsyncIterable.js.map +1 -1
- package/lib/utils/AsyncIterable.test.d.ts +2 -0
- package/lib/utils/AsyncIterable.test.d.ts.map +1 -0
- package/lib/utils/AsyncIterable.test.js +17 -0
- package/lib/utils/AsyncIterable.test.js.map +1 -0
- package/package.json +8 -8
- package/lib/meta/convertOmsActionPrefills.d.ts +0 -5
- package/lib/meta/convertOmsActionPrefills.d.ts.map +0 -1
- package/lib/meta/convertOmsActionPrefills.js +0 -227
- package/lib/meta/convertOmsActionPrefills.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validate } from "@party-stack/ontology";
|
|
1
2
|
import { Temporal } from "temporal-polyfill";
|
|
2
3
|
import { describe, expect, it } from "vitest";
|
|
3
4
|
import { convertFoundryMetaActionType } from "./convertMetaActionType.js";
|
|
@@ -14,24 +15,78 @@ function actionType(parameters) {
|
|
|
14
15
|
fullLogicRules: [],
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function structListParameter() {
|
|
18
19
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
displayName: "Entries",
|
|
21
|
+
dataType: {
|
|
22
|
+
type: "array",
|
|
23
|
+
subType: {
|
|
24
|
+
type: "struct",
|
|
25
|
+
fields: [
|
|
26
|
+
{
|
|
27
|
+
name: "code",
|
|
28
|
+
fieldType: { type: "string" },
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "enabled",
|
|
33
|
+
fieldType: { type: "boolean" },
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: false,
|
|
40
|
+
typeClasses: [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function structListField(parameterId, field) {
|
|
44
|
+
return {
|
|
45
|
+
type: "structListParameterFieldValue",
|
|
46
|
+
parameterId,
|
|
47
|
+
structParameterFieldApiName: field,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function structField(parameterId, field) {
|
|
51
|
+
return {
|
|
52
|
+
type: "structParameterFieldValue",
|
|
53
|
+
parameterId,
|
|
54
|
+
structParameterFieldApiName: field,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function omsActionMetadata(parameterName, allowedValues, prefill, resolvedProperty) {
|
|
58
|
+
return {
|
|
59
|
+
actionType: {
|
|
60
|
+
actionTypeLogic: {
|
|
61
|
+
validation: {
|
|
62
|
+
parameterValidations: {
|
|
63
|
+
[parameterName]: {
|
|
64
|
+
defaultValidation: {
|
|
65
|
+
display: {
|
|
66
|
+
prefill,
|
|
67
|
+
},
|
|
68
|
+
validation: {
|
|
69
|
+
allowedValues,
|
|
70
|
+
},
|
|
29
71
|
},
|
|
30
72
|
},
|
|
31
73
|
},
|
|
32
74
|
},
|
|
33
75
|
},
|
|
34
76
|
},
|
|
77
|
+
propertyApiNamesByParameter: resolvedProperty
|
|
78
|
+
? new Map([
|
|
79
|
+
[
|
|
80
|
+
resolvedProperty.parameterId,
|
|
81
|
+
new Map([
|
|
82
|
+
[
|
|
83
|
+
resolvedProperty.propertyTypeId,
|
|
84
|
+
resolvedProperty.propertyApiName,
|
|
85
|
+
],
|
|
86
|
+
]),
|
|
87
|
+
],
|
|
88
|
+
])
|
|
89
|
+
: new Map(),
|
|
35
90
|
};
|
|
36
91
|
}
|
|
37
92
|
function omsOneOf(values, allowed = false) {
|
|
@@ -73,6 +128,24 @@ describe("convertFoundryMetaActionType parameter validation", () => {
|
|
|
73
128
|
name: "validatedAction",
|
|
74
129
|
});
|
|
75
130
|
});
|
|
131
|
+
it("preserves decimal parameters as strings", () => {
|
|
132
|
+
const result = convertFoundryMetaActionType(actionType({
|
|
133
|
+
amount: {
|
|
134
|
+
displayName: "Amount",
|
|
135
|
+
dataType: {
|
|
136
|
+
type: "decimal",
|
|
137
|
+
precision: 38,
|
|
138
|
+
scale: 18,
|
|
139
|
+
},
|
|
140
|
+
required: true,
|
|
141
|
+
typeClasses: [],
|
|
142
|
+
},
|
|
143
|
+
}));
|
|
144
|
+
expect(result.parameters[0]?.type).toEqual({
|
|
145
|
+
kind: "string",
|
|
146
|
+
value: {},
|
|
147
|
+
});
|
|
148
|
+
});
|
|
76
149
|
it("converts closed one-of string validation to an enum constraint", () => {
|
|
77
150
|
const result = convertFoundryMetaActionType(actionType({
|
|
78
151
|
status: {
|
|
@@ -216,15 +289,272 @@ describe("convertFoundryMetaActionType parameter validation", () => {
|
|
|
216
289
|
objectType: "Task",
|
|
217
290
|
values: [
|
|
218
291
|
{
|
|
219
|
-
property: [
|
|
220
|
-
"createdBy",
|
|
221
|
-
],
|
|
292
|
+
property: ["createdBy"],
|
|
222
293
|
value: {
|
|
223
294
|
kind: "contextReference",
|
|
224
295
|
value: {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
296
|
+
name: "user",
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
]);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
describe("convertFoundryMetaActionType struct assignments", () => {
|
|
307
|
+
it.each([
|
|
308
|
+
{
|
|
309
|
+
name: "create-object",
|
|
310
|
+
rule: {
|
|
311
|
+
type: "createObject",
|
|
312
|
+
objectTypeApiName: "Record",
|
|
313
|
+
propertyArguments: {},
|
|
314
|
+
structPropertyArguments: {
|
|
315
|
+
entries: {
|
|
316
|
+
code: structListField("entries", "code"),
|
|
317
|
+
enabled: structListField("entries", "enabled"),
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
expectedKind: "createObject",
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "update-object",
|
|
325
|
+
rule: {
|
|
326
|
+
type: "modifyObject",
|
|
327
|
+
objectToModify: "record",
|
|
328
|
+
propertyArguments: {},
|
|
329
|
+
structPropertyArguments: {
|
|
330
|
+
entries: {
|
|
331
|
+
code: structListField("entries", "code"),
|
|
332
|
+
enabled: structListField("entries", "enabled"),
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
expectedKind: "updateObject",
|
|
337
|
+
},
|
|
338
|
+
])("converts a complete $name list mapping to a map expression", ({ rule, expectedKind }) => {
|
|
339
|
+
const metadata = actionType({
|
|
340
|
+
entries: structListParameter(),
|
|
341
|
+
record: {
|
|
342
|
+
displayName: "Record",
|
|
343
|
+
dataType: {
|
|
344
|
+
type: "object",
|
|
345
|
+
objectTypeApiName: "Record",
|
|
346
|
+
objectApiName: "record",
|
|
347
|
+
},
|
|
348
|
+
required: true,
|
|
349
|
+
typeClasses: [],
|
|
350
|
+
},
|
|
351
|
+
});
|
|
352
|
+
metadata.fullLogicRules = [rule];
|
|
353
|
+
expect(convertFoundryMetaActionType(metadata).logic).toMatchObject([
|
|
354
|
+
{
|
|
355
|
+
kind: expectedKind,
|
|
356
|
+
value: {
|
|
357
|
+
values: [
|
|
358
|
+
{
|
|
359
|
+
property: ["entries"],
|
|
360
|
+
value: {
|
|
361
|
+
kind: "map",
|
|
362
|
+
value: {
|
|
363
|
+
source: {
|
|
364
|
+
kind: "inputReference",
|
|
365
|
+
value: {
|
|
366
|
+
name: "entries",
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
binding: "item",
|
|
370
|
+
body: {
|
|
371
|
+
kind: "struct",
|
|
372
|
+
value: {
|
|
373
|
+
fields: [
|
|
374
|
+
{
|
|
375
|
+
name: "code",
|
|
376
|
+
value: {
|
|
377
|
+
kind: "getAt",
|
|
378
|
+
value: {
|
|
379
|
+
source: {
|
|
380
|
+
kind: "localReference",
|
|
381
|
+
value: {
|
|
382
|
+
name: "item",
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
path: ["code"],
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "enabled",
|
|
391
|
+
value: {
|
|
392
|
+
kind: "getAt",
|
|
393
|
+
value: {
|
|
394
|
+
source: {
|
|
395
|
+
kind: "localReference",
|
|
396
|
+
value: {
|
|
397
|
+
name: "item",
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
path: ["enabled"],
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
],
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
]);
|
|
414
|
+
});
|
|
415
|
+
it("preserves nested assignments for an ordinary struct", () => {
|
|
416
|
+
const metadata = actionType({
|
|
417
|
+
details: {
|
|
418
|
+
displayName: "Details",
|
|
419
|
+
dataType: {
|
|
420
|
+
type: "struct",
|
|
421
|
+
fields: [
|
|
422
|
+
{
|
|
423
|
+
name: "code",
|
|
424
|
+
fieldType: { type: "string" },
|
|
425
|
+
required: true,
|
|
426
|
+
},
|
|
427
|
+
],
|
|
428
|
+
},
|
|
429
|
+
required: true,
|
|
430
|
+
typeClasses: [],
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
metadata.fullLogicRules = [
|
|
434
|
+
{
|
|
435
|
+
type: "createObject",
|
|
436
|
+
objectTypeApiName: "Record",
|
|
437
|
+
propertyArguments: {},
|
|
438
|
+
structPropertyArguments: {
|
|
439
|
+
details: {
|
|
440
|
+
code: structField("details", "code"),
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
];
|
|
445
|
+
expect(convertFoundryMetaActionType(metadata).logic).toMatchObject([
|
|
446
|
+
{
|
|
447
|
+
value: {
|
|
448
|
+
values: [
|
|
449
|
+
{
|
|
450
|
+
property: ["details", "code"],
|
|
451
|
+
value: {
|
|
452
|
+
kind: "getAt",
|
|
453
|
+
value: {
|
|
454
|
+
source: {
|
|
455
|
+
kind: "inputReference",
|
|
456
|
+
value: { name: "details" },
|
|
457
|
+
},
|
|
458
|
+
path: ["code"],
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
]);
|
|
466
|
+
});
|
|
467
|
+
it.each([
|
|
468
|
+
{
|
|
469
|
+
name: "partial",
|
|
470
|
+
fields: {
|
|
471
|
+
code: structListField("entries", "code"),
|
|
472
|
+
},
|
|
473
|
+
expectedFields: [
|
|
474
|
+
{
|
|
475
|
+
name: "code",
|
|
476
|
+
value: {
|
|
477
|
+
kind: "getAt",
|
|
478
|
+
value: {
|
|
479
|
+
source: {
|
|
480
|
+
kind: "localReference",
|
|
481
|
+
value: { name: "item" },
|
|
482
|
+
},
|
|
483
|
+
path: ["code"],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "renamed",
|
|
491
|
+
fields: {
|
|
492
|
+
renamedCode: structListField("entries", "code"),
|
|
493
|
+
enabled: structListField("entries", "enabled"),
|
|
494
|
+
},
|
|
495
|
+
expectedFields: [
|
|
496
|
+
{
|
|
497
|
+
name: "renamedCode",
|
|
498
|
+
value: {
|
|
499
|
+
kind: "getAt",
|
|
500
|
+
value: {
|
|
501
|
+
source: {
|
|
502
|
+
kind: "localReference",
|
|
503
|
+
value: { name: "item" },
|
|
504
|
+
},
|
|
505
|
+
path: ["code"],
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: "enabled",
|
|
511
|
+
value: {
|
|
512
|
+
kind: "getAt",
|
|
513
|
+
value: {
|
|
514
|
+
source: {
|
|
515
|
+
kind: "localReference",
|
|
516
|
+
value: { name: "item" },
|
|
517
|
+
},
|
|
518
|
+
path: ["enabled"],
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
],
|
|
523
|
+
},
|
|
524
|
+
])("converts a $name list mapping to a map expression", ({ fields, expectedFields }) => {
|
|
525
|
+
const metadata = actionType({
|
|
526
|
+
entries: structListParameter(),
|
|
527
|
+
});
|
|
528
|
+
metadata.fullLogicRules = [
|
|
529
|
+
{
|
|
530
|
+
type: "createObject",
|
|
531
|
+
objectTypeApiName: "Record",
|
|
532
|
+
propertyArguments: {},
|
|
533
|
+
structPropertyArguments: { entries: fields },
|
|
534
|
+
},
|
|
535
|
+
];
|
|
536
|
+
expect(convertFoundryMetaActionType(metadata).logic).toMatchObject([
|
|
537
|
+
{
|
|
538
|
+
value: {
|
|
539
|
+
values: [
|
|
540
|
+
{
|
|
541
|
+
property: ["entries"],
|
|
542
|
+
value: {
|
|
543
|
+
kind: "map",
|
|
544
|
+
value: {
|
|
545
|
+
source: {
|
|
546
|
+
kind: "inputReference",
|
|
547
|
+
value: {
|
|
548
|
+
name: "entries",
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
binding: "item",
|
|
552
|
+
body: {
|
|
553
|
+
kind: "struct",
|
|
554
|
+
value: {
|
|
555
|
+
fields: expectedFields,
|
|
556
|
+
},
|
|
557
|
+
},
|
|
228
558
|
},
|
|
229
559
|
},
|
|
230
560
|
},
|
|
@@ -233,6 +563,159 @@ describe("convertFoundryMetaActionType parameter validation", () => {
|
|
|
233
563
|
},
|
|
234
564
|
]);
|
|
235
565
|
});
|
|
566
|
+
it("rejects mappings driven by multiple list parameters", () => {
|
|
567
|
+
const metadata = actionType({
|
|
568
|
+
entries: structListParameter(),
|
|
569
|
+
otherEntries: structListParameter(),
|
|
570
|
+
});
|
|
571
|
+
metadata.fullLogicRules = [
|
|
572
|
+
{
|
|
573
|
+
type: "createObject",
|
|
574
|
+
objectTypeApiName: "Record",
|
|
575
|
+
propertyArguments: {},
|
|
576
|
+
structPropertyArguments: {
|
|
577
|
+
entries: {
|
|
578
|
+
code: structListField("entries", "code"),
|
|
579
|
+
enabled: structListField("otherEntries", "enabled"),
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
];
|
|
584
|
+
expect(() => convertFoundryMetaActionType(metadata)).toThrow('Unsupported Foundry list-of-struct assignment for property "entries": fields are mapped from multiple list parameters');
|
|
585
|
+
});
|
|
586
|
+
it("rejects mappings that mix list and non-list struct fields", () => {
|
|
587
|
+
const metadata = actionType({
|
|
588
|
+
entries: structListParameter(),
|
|
589
|
+
details: {
|
|
590
|
+
displayName: "Details",
|
|
591
|
+
dataType: {
|
|
592
|
+
type: "struct",
|
|
593
|
+
fields: [
|
|
594
|
+
{
|
|
595
|
+
name: "enabled",
|
|
596
|
+
fieldType: { type: "boolean" },
|
|
597
|
+
required: true,
|
|
598
|
+
},
|
|
599
|
+
],
|
|
600
|
+
},
|
|
601
|
+
required: true,
|
|
602
|
+
typeClasses: [],
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
metadata.fullLogicRules = [
|
|
606
|
+
{
|
|
607
|
+
type: "createObject",
|
|
608
|
+
objectTypeApiName: "Record",
|
|
609
|
+
propertyArguments: {},
|
|
610
|
+
structPropertyArguments: {
|
|
611
|
+
entries: {
|
|
612
|
+
code: structListField("entries", "code"),
|
|
613
|
+
enabled: structField("details", "enabled"),
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
];
|
|
618
|
+
expect(() => convertFoundryMetaActionType(metadata)).toThrow('Unsupported Foundry list-of-struct assignment for property "entries": list fields are mixed with non-list struct field arguments');
|
|
619
|
+
});
|
|
620
|
+
it("produces action IR that passes ontology validation", () => {
|
|
621
|
+
const metadata = actionType({
|
|
622
|
+
entries: structListParameter(),
|
|
623
|
+
record: {
|
|
624
|
+
displayName: "Record",
|
|
625
|
+
dataType: {
|
|
626
|
+
type: "object",
|
|
627
|
+
objectTypeApiName: "Record",
|
|
628
|
+
objectApiName: "record",
|
|
629
|
+
},
|
|
630
|
+
required: true,
|
|
631
|
+
typeClasses: [],
|
|
632
|
+
},
|
|
633
|
+
});
|
|
634
|
+
metadata.fullLogicRules = [
|
|
635
|
+
{
|
|
636
|
+
type: "createObject",
|
|
637
|
+
objectTypeApiName: "Record",
|
|
638
|
+
propertyArguments: {},
|
|
639
|
+
structPropertyArguments: {
|
|
640
|
+
entries: {
|
|
641
|
+
code: structListField("entries", "code"),
|
|
642
|
+
enabled: structListField("entries", "enabled"),
|
|
643
|
+
},
|
|
644
|
+
summaries: {
|
|
645
|
+
identifier: structListField("entries", "code"),
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
type: "modifyObject",
|
|
651
|
+
objectToModify: "record",
|
|
652
|
+
propertyArguments: {},
|
|
653
|
+
structPropertyArguments: {
|
|
654
|
+
entries: {
|
|
655
|
+
code: structListField("entries", "code"),
|
|
656
|
+
enabled: structListField("entries", "enabled"),
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
];
|
|
661
|
+
const converted = convertFoundryMetaActionType(metadata);
|
|
662
|
+
const ontology = {
|
|
663
|
+
types: [],
|
|
664
|
+
objectTypes: [
|
|
665
|
+
{
|
|
666
|
+
name: "Record",
|
|
667
|
+
displayName: "Record",
|
|
668
|
+
pluralDisplayName: "Records",
|
|
669
|
+
primaryKey: "id",
|
|
670
|
+
properties: [
|
|
671
|
+
{
|
|
672
|
+
name: "id",
|
|
673
|
+
displayName: "ID",
|
|
674
|
+
type: { kind: "string", value: {} },
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: "entries",
|
|
678
|
+
displayName: "Entries",
|
|
679
|
+
type: converted.parameters[0].type,
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: "summaries",
|
|
683
|
+
displayName: "Summaries",
|
|
684
|
+
type: {
|
|
685
|
+
kind: "optional",
|
|
686
|
+
value: {
|
|
687
|
+
type: {
|
|
688
|
+
kind: "list",
|
|
689
|
+
value: {
|
|
690
|
+
elementType: {
|
|
691
|
+
kind: "struct",
|
|
692
|
+
value: {
|
|
693
|
+
fields: [
|
|
694
|
+
{
|
|
695
|
+
name: "identifier",
|
|
696
|
+
displayName: "Identifier",
|
|
697
|
+
type: {
|
|
698
|
+
kind: "string",
|
|
699
|
+
value: {},
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
],
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
},
|
|
710
|
+
],
|
|
711
|
+
},
|
|
712
|
+
],
|
|
713
|
+
linkTypes: [],
|
|
714
|
+
actionTypes: [converted],
|
|
715
|
+
queryFunctionTypes: [],
|
|
716
|
+
};
|
|
717
|
+
expect(validate(ontology)).toEqual({ kind: "ok" });
|
|
718
|
+
});
|
|
236
719
|
});
|
|
237
720
|
describe("convertFoundryMetaActionType OMS string constraints", () => {
|
|
238
721
|
it("uses a closed OMS one-of and preserves its prefill", () => {
|
|
@@ -273,7 +756,7 @@ describe("convertFoundryMetaActionType OMS string constraints", () => {
|
|
|
273
756
|
});
|
|
274
757
|
});
|
|
275
758
|
it("preserves open OMS one-of values as optional string suggestions", () => {
|
|
276
|
-
const
|
|
759
|
+
const metadata = actionType({
|
|
277
760
|
country: {
|
|
278
761
|
displayName: "Country",
|
|
279
762
|
dataType: { type: "string" },
|
|
@@ -290,7 +773,21 @@ describe("convertFoundryMetaActionType OMS string constraints", () => {
|
|
|
290
773
|
required: true,
|
|
291
774
|
typeClasses: [],
|
|
292
775
|
},
|
|
293
|
-
})
|
|
776
|
+
});
|
|
777
|
+
metadata.fullLogicRules = [
|
|
778
|
+
{
|
|
779
|
+
type: "modifyObject",
|
|
780
|
+
objectToModify: "claim",
|
|
781
|
+
propertyArguments: {
|
|
782
|
+
country: {
|
|
783
|
+
type: "parameterId",
|
|
784
|
+
parameterId: "country",
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
structPropertyArguments: {},
|
|
788
|
+
},
|
|
789
|
+
];
|
|
790
|
+
const result = convertFoundryMetaActionType(metadata, omsActionMetadata("country", omsOneOf([
|
|
294
791
|
{ label: "United States", value: "US" },
|
|
295
792
|
{ label: "Mexico", value: "MX" },
|
|
296
793
|
{ label: "Canada", value: "CA" },
|
|
@@ -300,6 +797,10 @@ describe("convertFoundryMetaActionType OMS string constraints", () => {
|
|
|
300
797
|
parameterId: "claim",
|
|
301
798
|
propertyTypeId: "country",
|
|
302
799
|
},
|
|
800
|
+
}, {
|
|
801
|
+
propertyTypeId: "country",
|
|
802
|
+
parameterId: "claim",
|
|
803
|
+
propertyApiName: "country",
|
|
303
804
|
}));
|
|
304
805
|
expect(result.parameters[0]?.type).toEqual({
|
|
305
806
|
kind: "optional",
|
|
@@ -326,9 +827,18 @@ describe("convertFoundryMetaActionType OMS string constraints", () => {
|
|
|
326
827
|
},
|
|
327
828
|
});
|
|
328
829
|
expect(result.parameters[0]?.defaultValue).toEqual({
|
|
329
|
-
kind: "
|
|
830
|
+
kind: "getAt",
|
|
330
831
|
value: {
|
|
331
|
-
|
|
832
|
+
source: {
|
|
833
|
+
kind: "objectLookup",
|
|
834
|
+
value: {
|
|
835
|
+
reference: {
|
|
836
|
+
kind: "inputReference",
|
|
837
|
+
value: { name: "claim" },
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
path: ["country"],
|
|
332
842
|
},
|
|
333
843
|
});
|
|
334
844
|
});
|
|
@@ -451,7 +961,7 @@ describe("convertFoundryMetaActionType OMS string constraints", () => {
|
|
|
451
961
|
});
|
|
452
962
|
describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
453
963
|
it("converts static and object-property prefills to parameter defaults", () => {
|
|
454
|
-
const
|
|
964
|
+
const metadata = actionType({
|
|
455
965
|
assignee: {
|
|
456
966
|
displayName: "Assignee",
|
|
457
967
|
dataType: {
|
|
@@ -474,31 +984,34 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
474
984
|
required: false,
|
|
475
985
|
typeClasses: [],
|
|
476
986
|
},
|
|
477
|
-
})
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
987
|
+
});
|
|
988
|
+
const result = convertFoundryMetaActionType(metadata, {
|
|
989
|
+
actionType: {
|
|
990
|
+
actionTypeLogic: {
|
|
991
|
+
validation: {
|
|
992
|
+
parameterValidations: {
|
|
993
|
+
assigneeName: {
|
|
994
|
+
defaultValidation: {
|
|
995
|
+
display: {
|
|
996
|
+
prefill: {
|
|
997
|
+
type: "objectParameterPropertyValue",
|
|
998
|
+
objectParameterPropertyValue: {
|
|
999
|
+
parameterId: "assignee",
|
|
1000
|
+
propertyTypeId: "legacy-display-name-id",
|
|
1001
|
+
},
|
|
489
1002
|
},
|
|
490
1003
|
},
|
|
491
1004
|
},
|
|
492
1005
|
},
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
1006
|
+
notes: {
|
|
1007
|
+
defaultValidation: {
|
|
1008
|
+
display: {
|
|
1009
|
+
prefill: {
|
|
1010
|
+
type: "staticValue",
|
|
1011
|
+
staticValue: {
|
|
1012
|
+
type: "string",
|
|
1013
|
+
string: "from-foundry",
|
|
1014
|
+
},
|
|
502
1015
|
},
|
|
503
1016
|
},
|
|
504
1017
|
},
|
|
@@ -507,6 +1020,17 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
507
1020
|
},
|
|
508
1021
|
},
|
|
509
1022
|
},
|
|
1023
|
+
propertyApiNamesByParameter: new Map([
|
|
1024
|
+
[
|
|
1025
|
+
"assignee",
|
|
1026
|
+
new Map([
|
|
1027
|
+
[
|
|
1028
|
+
"legacy-display-name-id",
|
|
1029
|
+
"displayName",
|
|
1030
|
+
],
|
|
1031
|
+
]),
|
|
1032
|
+
],
|
|
1033
|
+
]),
|
|
510
1034
|
});
|
|
511
1035
|
expect(result.parameters).toMatchObject([
|
|
512
1036
|
{
|
|
@@ -515,9 +1039,18 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
515
1039
|
{
|
|
516
1040
|
name: "assigneeName",
|
|
517
1041
|
defaultValue: {
|
|
518
|
-
kind: "
|
|
1042
|
+
kind: "getAt",
|
|
519
1043
|
value: {
|
|
520
|
-
|
|
1044
|
+
source: {
|
|
1045
|
+
kind: "objectLookup",
|
|
1046
|
+
value: {
|
|
1047
|
+
reference: {
|
|
1048
|
+
kind: "inputReference",
|
|
1049
|
+
value: { name: "assignee" },
|
|
1050
|
+
},
|
|
1051
|
+
},
|
|
1052
|
+
},
|
|
1053
|
+
path: ["displayName"],
|
|
521
1054
|
},
|
|
522
1055
|
},
|
|
523
1056
|
},
|
|
@@ -598,15 +1131,19 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
598
1131
|
typeClasses: [],
|
|
599
1132
|
},
|
|
600
1133
|
}), {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
1134
|
+
actionType: {
|
|
1135
|
+
actionTypeLogic: {
|
|
1136
|
+
validation: {
|
|
1137
|
+
parameterValidations: {
|
|
1138
|
+
assignee: {
|
|
1139
|
+
defaultValidation: {
|
|
1140
|
+
display: {
|
|
1141
|
+
prefill: {
|
|
1142
|
+
type: "objectQueryPrefill",
|
|
1143
|
+
objectQueryPrefill: {
|
|
1144
|
+
objectSet,
|
|
1145
|
+
},
|
|
1146
|
+
},
|
|
610
1147
|
},
|
|
611
1148
|
},
|
|
612
1149
|
},
|
|
@@ -614,6 +1151,7 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
614
1151
|
},
|
|
615
1152
|
},
|
|
616
1153
|
},
|
|
1154
|
+
propertyApiNamesByParameter: new Map(),
|
|
617
1155
|
});
|
|
618
1156
|
expect(result.parameters[0]?.defaultValue).toBeUndefined();
|
|
619
1157
|
});
|
|
@@ -635,31 +1173,38 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
635
1173
|
typeClasses: [],
|
|
636
1174
|
},
|
|
637
1175
|
}), {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
1176
|
+
actionType: {
|
|
1177
|
+
actionTypeLogic: {
|
|
1178
|
+
validation: {
|
|
1179
|
+
parameterValidations: {
|
|
1180
|
+
dueDate: {
|
|
1181
|
+
defaultValidation: {
|
|
1182
|
+
display: {
|
|
1183
|
+
prefill: {
|
|
1184
|
+
type: "staticValue",
|
|
1185
|
+
staticValue: {
|
|
1186
|
+
type: "date",
|
|
1187
|
+
date: {
|
|
1188
|
+
dateValue: "2026-08-31",
|
|
1189
|
+
},
|
|
1190
|
+
},
|
|
649
1191
|
},
|
|
650
1192
|
},
|
|
651
1193
|
},
|
|
652
1194
|
},
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
1195
|
+
tags: {
|
|
1196
|
+
defaultValidation: {
|
|
1197
|
+
display: {
|
|
1198
|
+
prefill: {
|
|
1199
|
+
type: "staticValue",
|
|
1200
|
+
staticValue: {
|
|
1201
|
+
type: "stringList",
|
|
1202
|
+
stringList: {
|
|
1203
|
+
strings: [
|
|
1204
|
+
"priority",
|
|
1205
|
+
"customer",
|
|
1206
|
+
],
|
|
1207
|
+
},
|
|
663
1208
|
},
|
|
664
1209
|
},
|
|
665
1210
|
},
|
|
@@ -669,6 +1214,7 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
669
1214
|
},
|
|
670
1215
|
},
|
|
671
1216
|
},
|
|
1217
|
+
propertyApiNamesByParameter: new Map(),
|
|
672
1218
|
});
|
|
673
1219
|
const dueDateDefault = result.parameters[0]?.defaultValue;
|
|
674
1220
|
const tagsDefault = result.parameters[1]?.defaultValue;
|
|
@@ -680,10 +1226,7 @@ describe("convertFoundryMetaActionType OMS defaults", () => {
|
|
|
680
1226
|
const date = dueDateDefault.value.value;
|
|
681
1227
|
expect(date).toBeInstanceOf(Temporal.PlainDate);
|
|
682
1228
|
expect(date.toString()).toBe("2026-08-31");
|
|
683
|
-
expect(tagsDefault.value.value).toEqual([
|
|
684
|
-
"priority",
|
|
685
|
-
"customer",
|
|
686
|
-
]);
|
|
1229
|
+
expect(tagsDefault.value.value).toEqual(["priority", "customer"]);
|
|
687
1230
|
});
|
|
688
1231
|
});
|
|
689
1232
|
//# sourceMappingURL=convertMetaActionType.test.js.map
|