@opencrvs/toolkit 1.8.0-rc.faacbde → 1.8.0-rc.fb0e687
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/dist/commons/api/router.d.ts +6193 -13690
- package/dist/commons/conditionals/conditionals.d.ts +18 -3
- package/dist/commons/conditionals/validate.d.ts +12 -11
- package/dist/commons/events/ActionDocument.d.ts +7168 -74
- package/dist/commons/events/ActionInput.d.ts +1109 -250
- package/dist/commons/events/ActionType.d.ts +4 -3
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +19 -6
- package/dist/commons/events/EventDocument.d.ts +420 -29
- package/dist/commons/events/EventIndex.d.ts +3 -0
- package/dist/commons/events/EventMetadata.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +161 -23
- package/dist/commons/events/PageConfig.d.ts +0 -24
- package/dist/commons/events/TemplateConfig.d.ts +2 -2
- package/dist/commons/events/test.utils.d.ts +18 -109
- package/dist/commons/events/utils.d.ts +52 -12
- package/dist/conditionals/index.js +146 -116
- package/dist/events/index.js +403 -248
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
30
30
|
// src/events/index.ts
|
31
31
|
var events_exports = {};
|
32
32
|
__export(events_exports, {
|
33
|
+
Action: () => Action,
|
33
34
|
ActionBase: () => ActionBase,
|
34
35
|
ActionConditional: () => ActionConditional,
|
35
36
|
ActionConfig: () => ActionConfig,
|
@@ -37,6 +38,7 @@ __export(events_exports, {
|
|
37
38
|
ActionDocument: () => ActionDocument,
|
38
39
|
ActionFormConfig: () => ActionFormConfig,
|
39
40
|
ActionInput: () => ActionInput,
|
41
|
+
ActionStatus: () => ActionStatus,
|
40
42
|
ActionType: () => ActionType,
|
41
43
|
ActionTypes: () => ActionTypes,
|
42
44
|
ActionUpdate: () => ActionUpdate,
|
@@ -47,6 +49,8 @@ __export(events_exports, {
|
|
47
49
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
48
50
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
49
51
|
ArchiveActionInput: () => ArchiveActionInput,
|
52
|
+
AssignActionInput: () => AssignActionInput,
|
53
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
50
54
|
BaseActionInput: () => BaseActionInput,
|
51
55
|
CertificateConfig: () => CertificateConfig,
|
52
56
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
@@ -54,6 +58,7 @@ __export(events_exports, {
|
|
54
58
|
Clause: () => Clause,
|
55
59
|
Conditional: () => Conditional,
|
56
60
|
ConditionalType: () => ConditionalType,
|
61
|
+
ConfirmableActions: () => ConfirmableActions,
|
57
62
|
DataEntry: () => DataEntry,
|
58
63
|
DataFieldValue: () => DataFieldValue,
|
59
64
|
DateValue: () => DateValue,
|
@@ -64,6 +69,7 @@ __export(events_exports, {
|
|
64
69
|
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
65
70
|
DeclareActionInput: () => DeclareActionInput,
|
66
71
|
DeduplicationConfig: () => DeduplicationConfig,
|
72
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
67
73
|
Draft: () => Draft,
|
68
74
|
DraftInput: () => DraftInput,
|
69
75
|
EmailField: () => EmailField,
|
@@ -77,6 +83,7 @@ __export(events_exports, {
|
|
77
83
|
EventSearchIndex: () => EventSearchIndex,
|
78
84
|
EventStatus: () => EventStatus,
|
79
85
|
EventStatuses: () => EventStatuses,
|
86
|
+
FieldConditional: () => FieldConditional,
|
80
87
|
FieldConfig: () => FieldConfig,
|
81
88
|
FieldType: () => FieldType,
|
82
89
|
FieldUpdateValue: () => FieldUpdateValue,
|
@@ -96,10 +103,10 @@ __export(events_exports, {
|
|
96
103
|
NotifyActionInput: () => NotifyActionInput,
|
97
104
|
NumberFieldValue: () => NumberFieldValue,
|
98
105
|
PageConfig: () => PageConfig,
|
99
|
-
PageConfigBase: () => PageConfigBase,
|
100
106
|
PageTypes: () => PageTypes,
|
101
107
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
102
108
|
ReadActionInput: () => ReadActionInput,
|
109
|
+
RegisterAction: () => RegisterAction,
|
103
110
|
RegisterActionInput: () => RegisterActionInput,
|
104
111
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
105
112
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -112,6 +119,7 @@ __export(events_exports, {
|
|
112
119
|
SummaryConfig: () => SummaryConfig,
|
113
120
|
TextValue: () => TextValue,
|
114
121
|
TranslationConfig: () => TranslationConfig,
|
122
|
+
UnassignActionInput: () => UnassignActionInput,
|
115
123
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
116
124
|
UrbanAddressValue: () => UrbanAddressValue,
|
117
125
|
ValidateActionInput: () => ValidateActionInput,
|
@@ -126,10 +134,12 @@ __export(events_exports, {
|
|
126
134
|
createEmptyDraft: () => createEmptyDraft,
|
127
135
|
createValidationSchema: () => createValidationSchema,
|
128
136
|
deepDropNulls: () => deepDropNulls,
|
137
|
+
deepMerge: () => deepMerge,
|
129
138
|
defineActionForm: () => defineActionForm,
|
130
139
|
defineConditional: () => defineConditional,
|
131
140
|
defineConfig: () => defineConfig,
|
132
141
|
defineDeclarationForm: () => defineDeclarationForm,
|
142
|
+
defineFormConditional: () => defineFormConditional,
|
133
143
|
defineFormPage: () => defineFormPage,
|
134
144
|
definePage: () => definePage,
|
135
145
|
errorMessages: () => errorMessages,
|
@@ -150,11 +160,13 @@ __export(events_exports, {
|
|
150
160
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
151
161
|
generateTransactionId: () => generateTransactionId,
|
152
162
|
generateTranslationConfig: () => generateTranslationConfig,
|
163
|
+
getAcceptedActions: () => getAcceptedActions,
|
153
164
|
getActionAnnotation: () => getActionAnnotation,
|
154
165
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
155
166
|
getActionReview: () => getActionReview,
|
156
167
|
getActionReviewFields: () => getActionReviewFields,
|
157
168
|
getAllAnnotationFields: () => getAllAnnotationFields,
|
169
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
158
170
|
getCurrentEventState: () => getCurrentEventState,
|
159
171
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
160
172
|
getDeclaration: () => getDeclaration,
|
@@ -173,6 +185,7 @@ __export(events_exports, {
|
|
173
185
|
isEmailFieldType: () => isEmailFieldType,
|
174
186
|
isFacilityFieldType: () => isFacilityFieldType,
|
175
187
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
188
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
176
189
|
isFieldEnabled: () => isFieldEnabled,
|
177
190
|
isFieldValue: () => isFieldValue,
|
178
191
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -196,6 +209,7 @@ __export(events_exports, {
|
|
196
209
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
197
210
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
198
211
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
212
|
+
never: () => never,
|
199
213
|
not: () => not,
|
200
214
|
or: () => or,
|
201
215
|
stripHiddenFields: () => stripHiddenFields,
|
@@ -211,29 +225,46 @@ var import_zod9 = require("zod");
|
|
211
225
|
|
212
226
|
// ../commons/src/events/Conditional.ts
|
213
227
|
var import_zod = require("zod");
|
214
|
-
|
215
|
-
|
216
|
-
|
228
|
+
var Conditional = import_zod.z.custom(
|
229
|
+
(val) => typeof val === "object" && val !== null
|
230
|
+
);
|
217
231
|
var ConditionalType = {
|
218
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
219
232
|
SHOW: "SHOW",
|
220
|
-
|
221
|
-
|
233
|
+
ENABLE: "ENABLE",
|
234
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
222
235
|
};
|
223
236
|
var ShowConditional = import_zod.z.object({
|
224
237
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
225
|
-
conditional: Conditional
|
226
|
-
})
|
238
|
+
conditional: Conditional
|
239
|
+
}).describe(
|
240
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
241
|
+
);
|
227
242
|
var EnableConditional = import_zod.z.object({
|
228
243
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
229
|
-
conditional: Conditional
|
230
|
-
})
|
244
|
+
conditional: Conditional
|
245
|
+
}).describe(
|
246
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
247
|
+
);
|
231
248
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
232
249
|
// Action can be shown / hidden
|
233
250
|
ShowConditional,
|
234
251
|
// Action can be shown to the user in the list but as disabled
|
235
252
|
EnableConditional
|
236
253
|
]);
|
254
|
+
var DisplayOnReviewConditional = import_zod.z.object({
|
255
|
+
type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
256
|
+
conditional: Conditional
|
257
|
+
}).describe(
|
258
|
+
"If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
|
259
|
+
);
|
260
|
+
var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
261
|
+
// Field input can be shown / hidden
|
262
|
+
ShowConditional,
|
263
|
+
// Field input can be shown to the user but as disabled
|
264
|
+
EnableConditional,
|
265
|
+
// Field output can be shown / hidden on the review page
|
266
|
+
DisplayOnReviewConditional
|
267
|
+
]);
|
237
268
|
|
238
269
|
// ../commons/src/events/PageConfig.ts
|
239
270
|
var import_zod6 = require("zod");
|
@@ -421,14 +452,14 @@ var BaseField = import_zod5.z.object({
|
|
421
452
|
]),
|
422
453
|
DependencyExpression
|
423
454
|
]).optional(),
|
424
|
-
conditionals: import_zod5.z.array(
|
455
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
425
456
|
required: import_zod5.z.boolean().default(false).optional(),
|
426
457
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
427
458
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
428
459
|
placeholder: TranslationConfig.optional(),
|
429
460
|
validation: import_zod5.z.array(
|
430
461
|
import_zod5.z.object({
|
431
|
-
validator: Conditional
|
462
|
+
validator: Conditional,
|
432
463
|
message: TranslationConfig
|
433
464
|
})
|
434
465
|
).default([]).optional(),
|
@@ -661,6 +692,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
661
692
|
EmailField,
|
662
693
|
FileUploadWithOptions,
|
663
694
|
DataField
|
695
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
664
696
|
]);
|
665
697
|
|
666
698
|
// ../commons/src/events/PageConfig.ts
|
@@ -669,7 +701,7 @@ var PageConfigBase = import_zod6.z.object({
|
|
669
701
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
670
702
|
title: TranslationConfig.describe("Header title of the page"),
|
671
703
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
672
|
-
conditional: Conditional
|
704
|
+
conditional: Conditional.optional().describe(
|
673
705
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
674
706
|
)
|
675
707
|
});
|
@@ -723,6 +755,15 @@ var ActionType = {
|
|
723
755
|
ASSIGN: "ASSIGN",
|
724
756
|
UNASSIGN: "UNASSIGN"
|
725
757
|
};
|
758
|
+
var ConfirmableActions = [
|
759
|
+
ActionType.NOTIFY,
|
760
|
+
ActionType.DECLARE,
|
761
|
+
ActionType.VALIDATE,
|
762
|
+
ActionType.REGISTER,
|
763
|
+
ActionType.REJECT,
|
764
|
+
ActionType.ARCHIVE,
|
765
|
+
ActionType.PRINT_CERTIFICATE
|
766
|
+
];
|
726
767
|
var ActionTypes = import_zod7.z.enum([
|
727
768
|
"DELETE",
|
728
769
|
"CREATE",
|
@@ -949,10 +990,12 @@ var DateDistanceMatcher = Matcher.extend({
|
|
949
990
|
});
|
950
991
|
var And = import_zod12.z.object({
|
951
992
|
type: import_zod12.z.literal("and"),
|
993
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
952
994
|
clauses: import_zod12.z.lazy(() => Clause.array())
|
953
995
|
});
|
954
996
|
var Or = import_zod12.z.object({
|
955
997
|
type: import_zod12.z.literal("or"),
|
998
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
956
999
|
clauses: import_zod12.z.lazy(() => Clause.array())
|
957
1000
|
});
|
958
1001
|
var Clause = import_zod12.z.lazy(
|
@@ -1018,7 +1061,8 @@ var EventMetadata = import_zod14.z.object({
|
|
1018
1061
|
modifiedAt: import_zod14.z.string().datetime(),
|
1019
1062
|
assignedTo: import_zod14.z.string().nullish(),
|
1020
1063
|
updatedBy: import_zod14.z.string(),
|
1021
|
-
trackingId: import_zod14.z.string()
|
1064
|
+
trackingId: import_zod14.z.string(),
|
1065
|
+
registrationNumber: import_zod14.z.string().nullish()
|
1022
1066
|
});
|
1023
1067
|
var eventMetadataLabelMap = {
|
1024
1068
|
"event.assignedTo": {
|
@@ -1070,6 +1114,11 @@ var eventMetadataLabelMap = {
|
|
1070
1114
|
id: "event.trackingId.label",
|
1071
1115
|
defaultMessage: "Tracking ID",
|
1072
1116
|
description: "Tracking ID"
|
1117
|
+
},
|
1118
|
+
"event.registrationNumber": {
|
1119
|
+
id: "event.registrationNumber.label",
|
1120
|
+
defaultMessage: "Registration Number",
|
1121
|
+
description: "Registration Number"
|
1073
1122
|
}
|
1074
1123
|
};
|
1075
1124
|
|
@@ -1452,7 +1501,8 @@ var isDataFieldType = (field2) => {
|
|
1452
1501
|
|
1453
1502
|
// ../commons/src/conditionals/validate.ts
|
1454
1503
|
var ajv = new import_ajv.default({
|
1455
|
-
$data: true
|
1504
|
+
$data: true,
|
1505
|
+
allowUnionTypes: true
|
1456
1506
|
});
|
1457
1507
|
(0, import_ajv_formats.default)(ajv);
|
1458
1508
|
function validate(schema, data) {
|
@@ -1485,6 +1535,9 @@ function isFieldVisible(field2, form) {
|
|
1485
1535
|
function isFieldEnabled(field2, form) {
|
1486
1536
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1487
1537
|
}
|
1538
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1539
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1540
|
+
}
|
1488
1541
|
var errorMessages = {
|
1489
1542
|
hiddenField: {
|
1490
1543
|
id: "v2.error.hidden",
|
@@ -1512,12 +1565,14 @@ var errorMessages = {
|
|
1512
1565
|
id: "v2.error.invalid"
|
1513
1566
|
}
|
1514
1567
|
};
|
1515
|
-
|
1516
|
-
|
1517
|
-
message
|
1518
|
-
|
1519
|
-
}
|
1520
|
-
|
1568
|
+
function createIntlError(message) {
|
1569
|
+
return {
|
1570
|
+
message: {
|
1571
|
+
message
|
1572
|
+
}
|
1573
|
+
};
|
1574
|
+
}
|
1575
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1521
1576
|
switch (issue.code) {
|
1522
1577
|
case "invalid_string": {
|
1523
1578
|
if (_ctx.data === "") {
|
@@ -1555,7 +1610,28 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1555
1610
|
}
|
1556
1611
|
}
|
1557
1612
|
return createIntlError(errorMessages.invalidInput);
|
1558
|
-
}
|
1613
|
+
}
|
1614
|
+
function runCustomFieldValidations({
|
1615
|
+
field: field2,
|
1616
|
+
conditionalParameters
|
1617
|
+
}) {
|
1618
|
+
return (field2.validation ?? []).filter((validation) => {
|
1619
|
+
return !validate(validation.validator, conditionalParameters);
|
1620
|
+
}).map((validation) => ({ message: validation.message }));
|
1621
|
+
}
|
1622
|
+
function validateFieldInput({
|
1623
|
+
field: field2,
|
1624
|
+
value
|
1625
|
+
}) {
|
1626
|
+
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1627
|
+
value,
|
1628
|
+
{
|
1629
|
+
// @ts-expect-error
|
1630
|
+
errorMap: zodToIntlErrorMap
|
1631
|
+
}
|
1632
|
+
);
|
1633
|
+
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1634
|
+
}
|
1559
1635
|
function getFieldValidationErrors({
|
1560
1636
|
field: field2,
|
1561
1637
|
values
|
@@ -1591,27 +1667,6 @@ function getFieldValidationErrors({
|
|
1591
1667
|
errors: [...fieldValidationResult, ...customValidationResults]
|
1592
1668
|
};
|
1593
1669
|
}
|
1594
|
-
function runCustomFieldValidations({
|
1595
|
-
field: field2,
|
1596
|
-
conditionalParameters
|
1597
|
-
}) {
|
1598
|
-
return (field2.validation ?? []).filter((validation) => {
|
1599
|
-
return !validate(validation.validator, conditionalParameters);
|
1600
|
-
}).map((validation) => ({ message: validation.message }));
|
1601
|
-
}
|
1602
|
-
function validateFieldInput({
|
1603
|
-
field: field2,
|
1604
|
-
value
|
1605
|
-
}) {
|
1606
|
-
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1607
|
-
value,
|
1608
|
-
{
|
1609
|
-
// @ts-expect-error
|
1610
|
-
errorMap: zodToIntlErrorMap
|
1611
|
-
}
|
1612
|
-
);
|
1613
|
-
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1614
|
-
}
|
1615
1670
|
|
1616
1671
|
// ../commons/src/uuid.ts
|
1617
1672
|
var import_uuid = require("uuid");
|
@@ -1631,15 +1686,18 @@ function getOrThrow(x, message) {
|
|
1631
1686
|
}
|
1632
1687
|
|
1633
1688
|
// ../commons/src/events/utils.ts
|
1634
|
-
|
1635
|
-
return (
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
}
|
1640
|
-
|
1641
|
-
return
|
1642
|
-
}
|
1689
|
+
function isDeclarationActionConfig(action) {
|
1690
|
+
return DeclarationActions.safeParse(action.type).success;
|
1691
|
+
}
|
1692
|
+
function getDeclarationFields(configuration) {
|
1693
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1694
|
+
}
|
1695
|
+
function getDeclarationPages(configuration) {
|
1696
|
+
return configuration.declaration.pages;
|
1697
|
+
}
|
1698
|
+
function getDeclaration(configuration) {
|
1699
|
+
return configuration.declaration;
|
1700
|
+
}
|
1643
1701
|
var getActionAnnotationFields = (actionConfig) => {
|
1644
1702
|
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1645
1703
|
return [
|
@@ -1648,13 +1706,22 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1648
1706
|
];
|
1649
1707
|
}
|
1650
1708
|
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1651
|
-
return actionConfig
|
1709
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1652
1710
|
}
|
1653
1711
|
if (isDeclarationActionConfig(actionConfig)) {
|
1654
|
-
return actionConfig
|
1712
|
+
return actionConfig.review.fields;
|
1655
1713
|
}
|
1656
1714
|
return [];
|
1657
1715
|
};
|
1716
|
+
var getAllAnnotationFields = (config) => {
|
1717
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1718
|
+
};
|
1719
|
+
var findAllFields = (config) => {
|
1720
|
+
return (0, import_lodash.flattenDeep)([
|
1721
|
+
...getDeclarationFields(config),
|
1722
|
+
...getAllAnnotationFields(config)
|
1723
|
+
]);
|
1724
|
+
};
|
1658
1725
|
var findRecordActionPages = (config, actionType) => {
|
1659
1726
|
const action = config.actions.find((a) => a.type === actionType);
|
1660
1727
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1665,30 +1732,18 @@ var findRecordActionPages = (config, actionType) => {
|
|
1665
1732
|
}
|
1666
1733
|
return [];
|
1667
1734
|
};
|
1668
|
-
function isDeclarationActionConfig(action) {
|
1669
|
-
return DeclarationActions.safeParse(action.type).success;
|
1670
|
-
}
|
1671
|
-
function getDeclarationFields(configuration) {
|
1672
|
-
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1673
|
-
}
|
1674
|
-
function getDeclarationPages(configuration) {
|
1675
|
-
return configuration.declaration.pages;
|
1676
|
-
}
|
1677
|
-
function getDeclaration(configuration) {
|
1678
|
-
return configuration.declaration;
|
1679
|
-
}
|
1680
|
-
function getActionReviewFields(configuration, actionType) {
|
1681
|
-
return getActionReview(configuration, actionType).fields;
|
1682
|
-
}
|
1683
1735
|
function getActionReview(configuration, actionType) {
|
1684
1736
|
const [actionConfig] = configuration.actions.filter(
|
1685
1737
|
(a) => a.type === actionType
|
1686
1738
|
);
|
1687
1739
|
return getOrThrow(
|
1688
|
-
actionConfig
|
1740
|
+
actionConfig.review,
|
1689
1741
|
`No review config found for ${actionType}`
|
1690
1742
|
);
|
1691
1743
|
}
|
1744
|
+
function getActionReviewFields(configuration, actionType) {
|
1745
|
+
return getActionReview(configuration, actionType).fields;
|
1746
|
+
}
|
1692
1747
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1693
1748
|
workqueueConfigs.map((workqueue) => {
|
1694
1749
|
const rootWorkqueue = Object.values(workqueues).find(
|
@@ -1720,7 +1775,7 @@ function isOptionalUncheckedCheckbox(field2, form) {
|
|
1720
1775
|
return !form[field2.id];
|
1721
1776
|
}
|
1722
1777
|
function stripHiddenFields(fields, declaration) {
|
1723
|
-
return (0, import_lodash.omitBy)(declaration, (
|
1778
|
+
return (0, import_lodash.omitBy)(declaration, (_, fieldId) => {
|
1724
1779
|
const field2 = fields.find((f) => f.id === fieldId);
|
1725
1780
|
if (!field2) {
|
1726
1781
|
return true;
|
@@ -1733,7 +1788,6 @@ function stripHiddenFields(fields, declaration) {
|
|
1733
1788
|
}
|
1734
1789
|
function findActiveDrafts(event2, drafts) {
|
1735
1790
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1736
|
-
console.log("actions", event2.actions);
|
1737
1791
|
const lastAction = actions[actions.length - 1];
|
1738
1792
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1739
1793
|
}
|
@@ -1756,6 +1810,24 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1756
1810
|
function isVerificationPage(page) {
|
1757
1811
|
return page.type === PageTypes.enum.VERIFICATION;
|
1758
1812
|
}
|
1813
|
+
function deepMerge(currentDocument, actionDocument) {
|
1814
|
+
return (0, import_lodash.mergeWith)(
|
1815
|
+
currentDocument,
|
1816
|
+
actionDocument,
|
1817
|
+
(previousValue, incomingValue) => {
|
1818
|
+
if (incomingValue === void 0) {
|
1819
|
+
return previousValue;
|
1820
|
+
}
|
1821
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1822
|
+
return incomingValue;
|
1823
|
+
}
|
1824
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1825
|
+
return void 0;
|
1826
|
+
}
|
1827
|
+
return incomingValue;
|
1828
|
+
}
|
1829
|
+
);
|
1830
|
+
}
|
1759
1831
|
|
1760
1832
|
// ../commons/src/events/EventConfig.ts
|
1761
1833
|
var EventConfig = import_zod20.z.object({
|
@@ -1808,13 +1880,25 @@ var import_zod23 = require("zod");
|
|
1808
1880
|
// ../commons/src/events/ActionDocument.ts
|
1809
1881
|
var import_zod21 = require("zod");
|
1810
1882
|
var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
|
1883
|
+
var ActionStatus = {
|
1884
|
+
Requested: "Requested",
|
1885
|
+
Accepted: "Accepted",
|
1886
|
+
Rejected: "Rejected"
|
1887
|
+
};
|
1811
1888
|
var ActionBase = import_zod21.z.object({
|
1812
1889
|
id: import_zod21.z.string(),
|
1813
1890
|
createdAt: import_zod21.z.string().datetime(),
|
1814
1891
|
createdBy: import_zod21.z.string(),
|
1815
1892
|
declaration: ActionUpdate,
|
1816
1893
|
annotation: ActionUpdate.optional(),
|
1817
|
-
createdAtLocation: import_zod21.z.string()
|
1894
|
+
createdAtLocation: import_zod21.z.string(),
|
1895
|
+
status: import_zod21.z.enum([
|
1896
|
+
ActionStatus.Requested,
|
1897
|
+
ActionStatus.Accepted,
|
1898
|
+
ActionStatus.Rejected
|
1899
|
+
]),
|
1900
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1901
|
+
originalActionId: import_zod21.z.string().optional()
|
1818
1902
|
});
|
1819
1903
|
var AssignedAction = ActionBase.merge(
|
1820
1904
|
import_zod21.z.object({
|
@@ -1830,10 +1914,7 @@ var UnassignedAction = ActionBase.merge(
|
|
1830
1914
|
var RegisterAction = ActionBase.merge(
|
1831
1915
|
import_zod21.z.object({
|
1832
1916
|
type: import_zod21.z.literal(ActionType.REGISTER),
|
1833
|
-
|
1834
|
-
trackingId: import_zod21.z.string(),
|
1835
|
-
registrationNumber: import_zod21.z.string()
|
1836
|
-
})
|
1917
|
+
registrationNumber: import_zod21.z.string().optional()
|
1837
1918
|
})
|
1838
1919
|
);
|
1839
1920
|
var DeclareAction = ActionBase.merge(
|
@@ -1915,6 +1996,18 @@ var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
|
1915
1996
|
PrintCertificateAction,
|
1916
1997
|
ReadAction
|
1917
1998
|
]);
|
1999
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
2000
|
+
declaration: true,
|
2001
|
+
annotation: true,
|
2002
|
+
createdBy: true,
|
2003
|
+
createdAtLocation: true
|
2004
|
+
}).merge(
|
2005
|
+
import_zod21.z.object({
|
2006
|
+
type: import_zod21.z.enum(ConfirmableActions),
|
2007
|
+
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2008
|
+
})
|
2009
|
+
);
|
2010
|
+
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1918
2011
|
var ResolvedUser = import_zod21.z.object({
|
1919
2012
|
id: import_zod21.z.string(),
|
1920
2013
|
role: import_zod21.z.string(),
|
@@ -1932,8 +2025,9 @@ var import_zod22 = require("zod");
|
|
1932
2025
|
var BaseActionInput = import_zod22.z.object({
|
1933
2026
|
eventId: import_zod22.z.string(),
|
1934
2027
|
transactionId: import_zod22.z.string(),
|
1935
|
-
declaration: ActionUpdate,
|
1936
|
-
annotation: ActionUpdate.optional()
|
2028
|
+
declaration: ActionUpdate.default({}),
|
2029
|
+
annotation: ActionUpdate.optional(),
|
2030
|
+
originalActionId: import_zod22.z.string().optional()
|
1937
2031
|
});
|
1938
2032
|
var CreateActionInput = BaseActionInput.merge(
|
1939
2033
|
import_zod22.z.object({
|
@@ -1944,10 +2038,7 @@ var CreateActionInput = BaseActionInput.merge(
|
|
1944
2038
|
var RegisterActionInput = BaseActionInput.merge(
|
1945
2039
|
import_zod22.z.object({
|
1946
2040
|
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1947
|
-
|
1948
|
-
trackingId: import_zod22.z.string(),
|
1949
|
-
registrationNumber: import_zod22.z.string()
|
1950
|
-
})
|
2041
|
+
registrationNumber: import_zod22.z.string().optional()
|
1951
2042
|
})
|
1952
2043
|
);
|
1953
2044
|
var ValidateActionInput = BaseActionInput.merge(
|
@@ -1994,7 +2085,8 @@ var AssignActionInput = BaseActionInput.merge(
|
|
1994
2085
|
);
|
1995
2086
|
var UnassignActionInput = BaseActionInput.merge(
|
1996
2087
|
import_zod22.z.object({
|
1997
|
-
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
|
2088
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2089
|
+
assignedTo: import_zod22.z.literal(null).default(null)
|
1998
2090
|
})
|
1999
2091
|
);
|
2000
2092
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
@@ -2065,7 +2157,7 @@ var EventDocument = import_zod25.z.object({
|
|
2065
2157
|
type: import_zod25.z.string(),
|
2066
2158
|
createdAt: import_zod25.z.string().datetime(),
|
2067
2159
|
updatedAt: import_zod25.z.string().datetime(),
|
2068
|
-
actions: import_zod25.z.array(
|
2160
|
+
actions: import_zod25.z.array(Action),
|
2069
2161
|
trackingId: import_zod25.z.string()
|
2070
2162
|
});
|
2071
2163
|
|
@@ -2082,8 +2174,13 @@ var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod
|
|
2082
2174
|
);
|
2083
2175
|
|
2084
2176
|
// ../commons/src/events/state/index.ts
|
2085
|
-
var _ = __toESM(require("lodash"));
|
2086
2177
|
function getStatusFromActions(actions) {
|
2178
|
+
const hasRejectedAction = actions.some(
|
2179
|
+
(a) => a.status === ActionStatus.Rejected
|
2180
|
+
);
|
2181
|
+
if (hasRejectedAction) {
|
2182
|
+
return EventStatus.REJECTED;
|
2183
|
+
}
|
2087
2184
|
return actions.reduce((status, action) => {
|
2088
2185
|
if (action.type === ActionType.CREATE) {
|
2089
2186
|
return EventStatus.CREATED;
|
@@ -2140,41 +2237,29 @@ function aggregateActionDeclarations(actions) {
|
|
2140
2237
|
}, {});
|
2141
2238
|
}
|
2142
2239
|
function deepDropNulls(obj) {
|
2143
|
-
if (
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
[key]
|
2152
|
-
};
|
2153
|
-
}
|
2154
|
-
return acc;
|
2155
|
-
}, {});
|
2156
|
-
}
|
2157
|
-
function deepMerge(currentDocument, actionDocument) {
|
2158
|
-
return _.mergeWith(
|
2159
|
-
currentDocument,
|
2160
|
-
actionDocument,
|
2161
|
-
(previousValue, incomingValue) => {
|
2162
|
-
if (incomingValue === void 0) {
|
2163
|
-
return previousValue;
|
2164
|
-
}
|
2165
|
-
if (_.isArray(incomingValue)) {
|
2166
|
-
return incomingValue;
|
2167
|
-
}
|
2168
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2169
|
-
return void 0;
|
2240
|
+
if (Array.isArray(obj)) {
|
2241
|
+
return obj;
|
2242
|
+
}
|
2243
|
+
if (obj !== null && typeof obj === "object") {
|
2244
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2245
|
+
const cleanedValue = deepDropNulls(value);
|
2246
|
+
if (cleanedValue !== null) {
|
2247
|
+
;
|
2248
|
+
acc[key] = cleanedValue;
|
2170
2249
|
}
|
2171
|
-
return
|
2172
|
-
}
|
2173
|
-
|
2250
|
+
return acc;
|
2251
|
+
}, {});
|
2252
|
+
}
|
2253
|
+
return obj;
|
2174
2254
|
}
|
2175
2255
|
function isUndeclaredDraft(status) {
|
2176
2256
|
return status === EventStatus.CREATED;
|
2177
2257
|
}
|
2258
|
+
function getAcceptedActions(event2) {
|
2259
|
+
return event2.actions.filter(
|
2260
|
+
(a) => a.status === ActionStatus.Accepted
|
2261
|
+
);
|
2262
|
+
}
|
2178
2263
|
function getCurrentEventState(event2) {
|
2179
2264
|
const creationAction = event2.actions.find(
|
2180
2265
|
(action) => action.type === ActionType.CREATE
|
@@ -2182,7 +2267,12 @@ function getCurrentEventState(event2) {
|
|
2182
2267
|
if (!creationAction) {
|
2183
2268
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2184
2269
|
}
|
2185
|
-
const
|
2270
|
+
const activeActions = getAcceptedActions(event2);
|
2271
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2272
|
+
const registrationAction = activeActions.find(
|
2273
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2274
|
+
);
|
2275
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2186
2276
|
return deepDropNulls({
|
2187
2277
|
id: event2.id,
|
2188
2278
|
type: event2.type,
|
@@ -2191,10 +2281,11 @@ function getCurrentEventState(event2) {
|
|
2191
2281
|
createdBy: creationAction.createdBy,
|
2192
2282
|
createdAtLocation: creationAction.createdAtLocation,
|
2193
2283
|
modifiedAt: latestAction.createdAt,
|
2194
|
-
assignedTo: getAssignedUserFromActions(
|
2284
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2195
2285
|
updatedBy: latestAction.createdBy,
|
2196
|
-
declaration: aggregateActionDeclarations(
|
2197
|
-
trackingId: event2.trackingId
|
2286
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2287
|
+
trackingId: event2.trackingId,
|
2288
|
+
registrationNumber
|
2198
2289
|
});
|
2199
2290
|
}
|
2200
2291
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2232,19 +2323,29 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2232
2323
|
}
|
2233
2324
|
};
|
2234
2325
|
}
|
2326
|
+
function getAnnotationFromDrafts(drafts) {
|
2327
|
+
const actions = drafts.map((draft) => draft.action);
|
2328
|
+
const annotation = actions.reduce((ann, action) => {
|
2329
|
+
return deepMerge(ann, action.annotation ?? {});
|
2330
|
+
}, {});
|
2331
|
+
return deepDropNulls(annotation);
|
2332
|
+
}
|
2235
2333
|
function getActionAnnotation({
|
2236
2334
|
event: event2,
|
2237
2335
|
actionType,
|
2238
2336
|
drafts
|
2239
2337
|
}) {
|
2240
|
-
const
|
2338
|
+
const activeActions = getAcceptedActions(event2);
|
2339
|
+
const action = activeActions.find(
|
2340
|
+
(activeAction) => actionType === activeAction.type
|
2341
|
+
);
|
2241
2342
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2242
2343
|
const sorted = [
|
2243
2344
|
...action ? [action] : [],
|
2244
2345
|
...eventDrafts.map((draft) => draft.action)
|
2245
2346
|
].sort();
|
2246
|
-
const annotation = sorted.reduce((
|
2247
|
-
return deepMerge(
|
2347
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2348
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2248
2349
|
}, {});
|
2249
2350
|
return deepDropNulls(annotation);
|
2250
2351
|
}
|
@@ -2268,6 +2369,16 @@ var import_lodash2 = require("lodash");
|
|
2268
2369
|
function defineConditional(schema) {
|
2269
2370
|
return schema;
|
2270
2371
|
}
|
2372
|
+
function defineFormConditional(schema) {
|
2373
|
+
const schemaWithForm = {
|
2374
|
+
type: "object",
|
2375
|
+
properties: {
|
2376
|
+
$form: schema
|
2377
|
+
},
|
2378
|
+
required: ["$form"]
|
2379
|
+
};
|
2380
|
+
return defineConditional(schemaWithForm);
|
2381
|
+
}
|
2271
2382
|
function alwaysTrue() {
|
2272
2383
|
return {};
|
2273
2384
|
}
|
@@ -2292,6 +2403,9 @@ function not(condition) {
|
|
2292
2403
|
required: []
|
2293
2404
|
});
|
2294
2405
|
}
|
2406
|
+
function never() {
|
2407
|
+
return not(alwaysTrue());
|
2408
|
+
}
|
2295
2409
|
var user = {
|
2296
2410
|
hasScope: (scope) => defineConditional({
|
2297
2411
|
type: "object",
|
@@ -2339,69 +2453,120 @@ var event = {
|
|
2339
2453
|
required: ["$event"]
|
2340
2454
|
})
|
2341
2455
|
};
|
2456
|
+
function getDateFromNow(days) {
|
2457
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2458
|
+
}
|
2459
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2460
|
+
return {
|
2461
|
+
type: "object",
|
2462
|
+
properties: {
|
2463
|
+
[fieldId]: {
|
2464
|
+
type: "string",
|
2465
|
+
format: "date",
|
2466
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2467
|
+
},
|
2468
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2469
|
+
},
|
2470
|
+
required: [fieldId]
|
2471
|
+
};
|
2472
|
+
}
|
2473
|
+
function isFieldReference(value) {
|
2474
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2475
|
+
}
|
2342
2476
|
function field(fieldId) {
|
2343
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2344
2477
|
const getDateRange = (date, clause) => ({
|
2345
2478
|
type: "object",
|
2346
2479
|
properties: {
|
2347
|
-
|
2348
|
-
type: "
|
2349
|
-
|
2350
|
-
|
2351
|
-
type: "string",
|
2352
|
-
format: "date",
|
2353
|
-
[clause]: date
|
2354
|
-
}
|
2355
|
-
},
|
2356
|
-
required: [fieldId]
|
2480
|
+
[fieldId]: {
|
2481
|
+
type: "string",
|
2482
|
+
format: "date",
|
2483
|
+
[clause]: date
|
2357
2484
|
}
|
2358
2485
|
},
|
2359
|
-
required: [
|
2486
|
+
required: [fieldId]
|
2360
2487
|
});
|
2361
2488
|
return {
|
2489
|
+
/**
|
2490
|
+
* @private Internal property used for field reference tracking.
|
2491
|
+
*/
|
2492
|
+
_fieldId: fieldId,
|
2362
2493
|
isAfter: () => ({
|
2363
2494
|
days: (days) => ({
|
2364
|
-
inPast: () =>
|
2495
|
+
inPast: () => defineFormConditional(
|
2365
2496
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2366
2497
|
),
|
2367
|
-
inFuture: () =>
|
2498
|
+
inFuture: () => defineFormConditional(
|
2368
2499
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2369
2500
|
)
|
2370
2501
|
}),
|
2371
|
-
date: (date) =>
|
2372
|
-
|
2502
|
+
date: (date) => {
|
2503
|
+
if (isFieldReference(date)) {
|
2504
|
+
const comparedFieldId = date._fieldId;
|
2505
|
+
return defineFormConditional(
|
2506
|
+
getDateRangeToFieldReference(
|
2507
|
+
fieldId,
|
2508
|
+
comparedFieldId,
|
2509
|
+
"formatMinimum"
|
2510
|
+
)
|
2511
|
+
);
|
2512
|
+
}
|
2513
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2514
|
+
},
|
2515
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2373
2516
|
}),
|
2374
2517
|
isBefore: () => ({
|
2375
2518
|
days: (days) => ({
|
2376
|
-
inPast: () =>
|
2519
|
+
inPast: () => defineFormConditional(
|
2377
2520
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2378
2521
|
),
|
2379
|
-
inFuture: () =>
|
2522
|
+
inFuture: () => defineFormConditional(
|
2380
2523
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2381
2524
|
)
|
2382
2525
|
}),
|
2383
|
-
date: (date) =>
|
2384
|
-
|
2526
|
+
date: (date) => {
|
2527
|
+
if (isFieldReference(date)) {
|
2528
|
+
const comparedFieldId = date._fieldId;
|
2529
|
+
return defineFormConditional(
|
2530
|
+
getDateRangeToFieldReference(
|
2531
|
+
fieldId,
|
2532
|
+
comparedFieldId,
|
2533
|
+
"formatMaximum"
|
2534
|
+
)
|
2535
|
+
);
|
2536
|
+
}
|
2537
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2538
|
+
},
|
2539
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2385
2540
|
}),
|
2386
|
-
isEqualTo: (value) =>
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2541
|
+
isEqualTo: (value) => {
|
2542
|
+
if (isFieldReference(value)) {
|
2543
|
+
const comparedFieldId = value._fieldId;
|
2544
|
+
return defineFormConditional({
|
2390
2545
|
type: "object",
|
2391
2546
|
properties: {
|
2392
2547
|
[fieldId]: {
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
const: value
|
2398
|
-
}
|
2548
|
+
type: ["string", "boolean"],
|
2549
|
+
const: { $data: `1/${comparedFieldId}` }
|
2550
|
+
},
|
2551
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2399
2552
|
},
|
2400
|
-
required: [fieldId]
|
2401
|
-
}
|
2402
|
-
}
|
2403
|
-
|
2404
|
-
|
2553
|
+
required: [fieldId, comparedFieldId]
|
2554
|
+
});
|
2555
|
+
}
|
2556
|
+
return defineFormConditional({
|
2557
|
+
type: "object",
|
2558
|
+
properties: {
|
2559
|
+
[fieldId]: {
|
2560
|
+
oneOf: [
|
2561
|
+
{ type: "string", const: value },
|
2562
|
+
{ type: "boolean", const: value }
|
2563
|
+
],
|
2564
|
+
const: value
|
2565
|
+
}
|
2566
|
+
},
|
2567
|
+
required: [fieldId]
|
2568
|
+
});
|
2569
|
+
},
|
2405
2570
|
/**
|
2406
2571
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2407
2572
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2410,123 +2575,87 @@ function field(fieldId) {
|
|
2410
2575
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2411
2576
|
*
|
2412
2577
|
*/
|
2413
|
-
isFalsy: () =>
|
2578
|
+
isFalsy: () => defineFormConditional({
|
2414
2579
|
type: "object",
|
2415
2580
|
properties: {
|
2416
|
-
|
2417
|
-
type: "object",
|
2418
|
-
properties: {
|
2419
|
-
[fieldId]: {
|
2420
|
-
anyOf: [
|
2421
|
-
{ const: "undefined" },
|
2422
|
-
{ const: false },
|
2423
|
-
{ const: null },
|
2424
|
-
{ const: "" }
|
2425
|
-
]
|
2426
|
-
}
|
2427
|
-
},
|
2581
|
+
[fieldId]: {
|
2428
2582
|
anyOf: [
|
2429
|
-
{
|
2430
|
-
|
2431
|
-
},
|
2432
|
-
{
|
2433
|
-
not: {
|
2434
|
-
required: [fieldId]
|
2435
|
-
}
|
2436
|
-
}
|
2583
|
+
{ const: "undefined" },
|
2584
|
+
{ const: false },
|
2585
|
+
{ const: null },
|
2586
|
+
{ const: "" }
|
2437
2587
|
]
|
2438
2588
|
}
|
2439
2589
|
},
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
$form: {
|
2446
|
-
type: "object",
|
2447
|
-
properties: {
|
2448
|
-
[fieldId]: {
|
2449
|
-
type: "string",
|
2450
|
-
enum: ["undefined"]
|
2451
|
-
}
|
2452
|
-
},
|
2590
|
+
anyOf: [
|
2591
|
+
{
|
2592
|
+
required: [fieldId]
|
2593
|
+
},
|
2594
|
+
{
|
2453
2595
|
not: {
|
2454
2596
|
required: [fieldId]
|
2455
2597
|
}
|
2456
2598
|
}
|
2599
|
+
]
|
2600
|
+
}),
|
2601
|
+
isUndefined: () => defineFormConditional({
|
2602
|
+
type: "object",
|
2603
|
+
properties: {
|
2604
|
+
[fieldId]: {
|
2605
|
+
type: "string",
|
2606
|
+
enum: ["undefined"]
|
2607
|
+
}
|
2457
2608
|
},
|
2458
|
-
|
2609
|
+
not: {
|
2610
|
+
required: [fieldId]
|
2611
|
+
}
|
2459
2612
|
}),
|
2460
|
-
inArray: (values) =>
|
2613
|
+
inArray: (values) => defineFormConditional({
|
2461
2614
|
type: "object",
|
2462
2615
|
properties: {
|
2463
|
-
|
2464
|
-
type: "
|
2465
|
-
|
2466
|
-
[fieldId]: {
|
2467
|
-
type: "string",
|
2468
|
-
enum: values
|
2469
|
-
}
|
2470
|
-
},
|
2471
|
-
required: [fieldId]
|
2616
|
+
[fieldId]: {
|
2617
|
+
type: "string",
|
2618
|
+
enum: values
|
2472
2619
|
}
|
2473
2620
|
},
|
2474
|
-
required: [
|
2621
|
+
required: [fieldId]
|
2475
2622
|
}),
|
2476
|
-
isValidEnglishName: () =>
|
2623
|
+
isValidEnglishName: () => defineFormConditional({
|
2477
2624
|
type: "object",
|
2478
2625
|
properties: {
|
2479
|
-
|
2480
|
-
type: "
|
2481
|
-
|
2482
|
-
|
2483
|
-
type: "string",
|
2484
|
-
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
2485
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2486
|
-
}
|
2487
|
-
},
|
2488
|
-
required: [fieldId]
|
2626
|
+
[fieldId]: {
|
2627
|
+
type: "string",
|
2628
|
+
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
2629
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2489
2630
|
}
|
2490
2631
|
},
|
2491
|
-
required: [
|
2632
|
+
required: [fieldId]
|
2492
2633
|
}),
|
2493
2634
|
/**
|
2494
2635
|
* Checks if the field value matches a given regular expression pattern.
|
2495
2636
|
* @param pattern - The regular expression pattern to match the field value against.
|
2496
2637
|
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2497
2638
|
*/
|
2498
|
-
matches: (pattern) =>
|
2639
|
+
matches: (pattern) => defineFormConditional({
|
2499
2640
|
type: "object",
|
2500
2641
|
properties: {
|
2501
|
-
|
2502
|
-
type: "
|
2503
|
-
|
2504
|
-
[fieldId]: {
|
2505
|
-
type: "string",
|
2506
|
-
pattern
|
2507
|
-
}
|
2508
|
-
},
|
2509
|
-
required: [fieldId]
|
2642
|
+
[fieldId]: {
|
2643
|
+
type: "string",
|
2644
|
+
pattern
|
2510
2645
|
}
|
2511
2646
|
},
|
2512
|
-
required: [
|
2647
|
+
required: [fieldId]
|
2513
2648
|
}),
|
2514
|
-
isBetween: (min, max) =>
|
2649
|
+
isBetween: (min, max) => defineFormConditional({
|
2515
2650
|
type: "object",
|
2516
2651
|
properties: {
|
2517
|
-
|
2518
|
-
type: "
|
2519
|
-
|
2520
|
-
|
2521
|
-
type: "number",
|
2522
|
-
minimum: min,
|
2523
|
-
maximum: max
|
2524
|
-
}
|
2525
|
-
},
|
2526
|
-
required: [fieldId]
|
2652
|
+
[fieldId]: {
|
2653
|
+
type: "number",
|
2654
|
+
minimum: min,
|
2655
|
+
maximum: max
|
2527
2656
|
}
|
2528
2657
|
},
|
2529
|
-
required: [
|
2658
|
+
required: [fieldId]
|
2530
2659
|
})
|
2531
2660
|
};
|
2532
2661
|
}
|
@@ -3824,11 +3953,14 @@ function generateActionInput(configuration, action) {
|
|
3824
3953
|
}
|
3825
3954
|
function generateActionMetadataInput(configuration, action) {
|
3826
3955
|
const actionConfig = configuration.actions.find(
|
3827
|
-
(
|
3956
|
+
(ac) => ac.type === action
|
3828
3957
|
);
|
3829
3958
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3830
3959
|
const annotation = fieldConfigsToActionAnnotation(annotationFields);
|
3831
|
-
const visibleVerificationPageIds =
|
3960
|
+
const visibleVerificationPageIds = findRecordActionPages(
|
3961
|
+
configuration,
|
3962
|
+
action
|
3963
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
3832
3964
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3833
3965
|
(acc, pageId) => ({
|
3834
3966
|
...acc,
|
@@ -3852,14 +3984,15 @@ var eventPayloadGenerator = {
|
|
3852
3984
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3853
3985
|
id
|
3854
3986
|
}),
|
3855
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
3987
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3856
3988
|
{
|
3857
3989
|
id: getUUID(),
|
3858
3990
|
eventId,
|
3859
3991
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3860
3992
|
transactionId: getUUID(),
|
3861
3993
|
action: {
|
3862
|
-
type:
|
3994
|
+
type: actionType,
|
3995
|
+
status: ActionStatus.Accepted,
|
3863
3996
|
declaration: {
|
3864
3997
|
"applicant.firstname": "Max",
|
3865
3998
|
"applicant.surname": "McLaren",
|
@@ -3918,6 +4051,20 @@ var eventPayloadGenerator = {
|
|
3918
4051
|
duplicates: [],
|
3919
4052
|
eventId
|
3920
4053
|
}),
|
4054
|
+
assign: (eventId, input = {}) => ({
|
4055
|
+
type: ActionType.ASSIGN,
|
4056
|
+
transactionId: input.transactionId ?? getUUID(),
|
4057
|
+
declaration: {},
|
4058
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4059
|
+
eventId
|
4060
|
+
}),
|
4061
|
+
unassign: (eventId, input = {}) => ({
|
4062
|
+
type: ActionType.UNASSIGN,
|
4063
|
+
transactionId: input.transactionId ?? getUUID(),
|
4064
|
+
declaration: {},
|
4065
|
+
assignedTo: null,
|
4066
|
+
eventId
|
4067
|
+
}),
|
3921
4068
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3922
4069
|
type: ActionType.ARCHIVE,
|
3923
4070
|
transactionId: input.transactionId ?? getUUID(),
|
@@ -4011,9 +4158,14 @@ function generateActionDocument({
|
|
4011
4158
|
createdAtLocation: "TODO",
|
4012
4159
|
declaration: generateActionInput(configuration, action),
|
4013
4160
|
annotation: {},
|
4014
|
-
...defaults
|
4161
|
+
...defaults,
|
4162
|
+
status: ActionStatus.Accepted
|
4015
4163
|
};
|
4016
4164
|
switch (action) {
|
4165
|
+
case ActionType.READ:
|
4166
|
+
return { ...actionBase, type: action };
|
4167
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4168
|
+
return { ...actionBase, type: action };
|
4017
4169
|
case ActionType.DECLARE:
|
4018
4170
|
return { ...actionBase, type: action };
|
4019
4171
|
case ActionType.UNASSIGN:
|
@@ -4041,9 +4193,10 @@ function generateActionDocument({
|
|
4041
4193
|
case ActionType.REGISTER:
|
4042
4194
|
return {
|
4043
4195
|
...actionBase,
|
4044
|
-
type: action
|
4045
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4196
|
+
type: action
|
4046
4197
|
};
|
4198
|
+
case ActionType.DELETE:
|
4199
|
+
case ActionType.DETECT_DUPLICATE:
|
4047
4200
|
default:
|
4048
4201
|
throw new Error(`Unsupported action type: ${action}`);
|
4049
4202
|
}
|
@@ -4127,7 +4280,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
4127
4280
|
return true;
|
4128
4281
|
}
|
4129
4282
|
function isFieldConfigDefaultValue(value) {
|
4130
|
-
if (!value)
|
4283
|
+
if (!value) {
|
4284
|
+
return false;
|
4285
|
+
}
|
4131
4286
|
if (isFieldValue(value)) {
|
4132
4287
|
return true;
|
4133
4288
|
}
|