@opencrvs/toolkit 1.8.0-rc.ff62f9e → 1.8.0-rc.ffb4f66
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/README.md +1 -1
- package/dist/commons/api/router.d.ts +6496 -15505
- package/dist/commons/conditionals/conditionals.d.ts +25 -3
- package/dist/commons/conditionals/validate.d.ts +14 -17
- package/dist/commons/events/ActionConfig.d.ts +1202 -6605
- package/dist/commons/events/ActionDocument.d.ts +6956 -255
- package/dist/commons/events/ActionInput.d.ts +1316 -367
- package/dist/commons/events/ActionType.d.ts +25 -16
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +52 -37
- package/dist/commons/events/EventConfig.d.ts +648 -2983
- package/dist/commons/events/EventConfigInput.d.ts +5 -2
- package/dist/commons/events/EventDocument.d.ts +495 -662
- package/dist/commons/events/EventIndex.d.ts +6 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +245 -45
- package/dist/commons/events/FormConfig.d.ts +559 -322
- package/dist/commons/events/PageConfig.d.ts +335 -0
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/defineConfig.d.ts +28 -433
- package/dist/commons/events/index.d.ts +2 -1
- package/dist/commons/events/test.utils.d.ts +63 -284
- package/dist/commons/events/utils.d.ts +83 -178
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +161 -93
- package/dist/events/index.js +1103 -819
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -30,13 +30,17 @@ 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,
|
36
37
|
ActionConfigBase: () => ActionConfigBase,
|
37
38
|
ActionDocument: () => ActionDocument,
|
39
|
+
ActionFormConfig: () => ActionFormConfig,
|
38
40
|
ActionInput: () => ActionInput,
|
41
|
+
ActionStatus: () => ActionStatus,
|
39
42
|
ActionType: () => ActionType,
|
43
|
+
ActionTypes: () => ActionTypes,
|
40
44
|
ActionUpdate: () => ActionUpdate,
|
41
45
|
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
42
46
|
AddressFieldValue: () => AddressFieldValue,
|
@@ -45,6 +49,8 @@ __export(events_exports, {
|
|
45
49
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
46
50
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
47
51
|
ArchiveActionInput: () => ArchiveActionInput,
|
52
|
+
AssignActionInput: () => AssignActionInput,
|
53
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
48
54
|
BaseActionInput: () => BaseActionInput,
|
49
55
|
CertificateConfig: () => CertificateConfig,
|
50
56
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
@@ -52,10 +58,18 @@ __export(events_exports, {
|
|
52
58
|
Clause: () => Clause,
|
53
59
|
Conditional: () => Conditional,
|
54
60
|
ConditionalType: () => ConditionalType,
|
61
|
+
ConfirmableActions: () => ConfirmableActions,
|
62
|
+
DataEntry: () => DataEntry,
|
55
63
|
DataFieldValue: () => DataFieldValue,
|
56
64
|
DateValue: () => DateValue,
|
65
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
66
|
+
DeclarationActions: () => DeclarationActions,
|
67
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
68
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
69
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
57
70
|
DeclareActionInput: () => DeclareActionInput,
|
58
71
|
DeduplicationConfig: () => DeduplicationConfig,
|
72
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
59
73
|
Draft: () => Draft,
|
60
74
|
DraftInput: () => DraftInput,
|
61
75
|
EmailField: () => EmailField,
|
@@ -69,6 +83,7 @@ __export(events_exports, {
|
|
69
83
|
EventSearchIndex: () => EventSearchIndex,
|
70
84
|
EventStatus: () => EventStatus,
|
71
85
|
EventStatuses: () => EventStatuses,
|
86
|
+
FieldConditional: () => FieldConditional,
|
72
87
|
FieldConfig: () => FieldConfig,
|
73
88
|
FieldType: () => FieldType,
|
74
89
|
FieldUpdateValue: () => FieldUpdateValue,
|
@@ -77,21 +92,21 @@ __export(events_exports, {
|
|
77
92
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
78
93
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
79
94
|
FormConfig: () => FormConfig,
|
80
|
-
FormPage: () => FormPage,
|
81
95
|
FormPageConfig: () => FormPageConfig,
|
82
|
-
FormPageType: () => FormPageType,
|
83
96
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
84
97
|
GenericAddressValue: () => GenericAddressValue,
|
85
98
|
GeographicalArea: () => GeographicalArea,
|
86
99
|
ImageMimeType: () => ImageMimeType,
|
87
100
|
LanguageConfig: () => LanguageConfig,
|
88
|
-
LatentActions: () => LatentActions,
|
89
101
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
90
102
|
MimeType: () => MimeType,
|
91
103
|
NotifyActionInput: () => NotifyActionInput,
|
92
104
|
NumberFieldValue: () => NumberFieldValue,
|
105
|
+
PageConfig: () => PageConfig,
|
106
|
+
PageTypes: () => PageTypes,
|
93
107
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
94
108
|
ReadActionInput: () => ReadActionInput,
|
109
|
+
RegisterAction: () => RegisterAction,
|
95
110
|
RegisterActionInput: () => RegisterActionInput,
|
96
111
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
97
112
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -104,23 +119,29 @@ __export(events_exports, {
|
|
104
119
|
SummaryConfig: () => SummaryConfig,
|
105
120
|
TextValue: () => TextValue,
|
106
121
|
TranslationConfig: () => TranslationConfig,
|
122
|
+
UnassignActionInput: () => UnassignActionInput,
|
107
123
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
108
124
|
UrbanAddressValue: () => UrbanAddressValue,
|
109
125
|
ValidateActionInput: () => ValidateActionInput,
|
110
|
-
|
126
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
111
127
|
VerificationPageConfig: () => VerificationPageConfig,
|
112
128
|
WorkqueueConfig: () => WorkqueueConfig,
|
113
129
|
alwaysTrue: () => alwaysTrue,
|
114
130
|
and: () => and,
|
131
|
+
annotationActions: () => annotationActions,
|
115
132
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
116
133
|
compositeFieldTypes: () => compositeFieldTypes,
|
117
134
|
createEmptyDraft: () => createEmptyDraft,
|
118
135
|
createValidationSchema: () => createValidationSchema,
|
119
136
|
deepDropNulls: () => deepDropNulls,
|
137
|
+
deepMerge: () => deepMerge,
|
138
|
+
defineActionForm: () => defineActionForm,
|
120
139
|
defineConditional: () => defineConditional,
|
121
140
|
defineConfig: () => defineConfig,
|
122
|
-
|
141
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
142
|
+
defineFormConditional: () => defineFormConditional,
|
123
143
|
defineFormPage: () => defineFormPage,
|
144
|
+
definePage: () => definePage,
|
124
145
|
errorMessages: () => errorMessages,
|
125
146
|
event: () => event,
|
126
147
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -129,31 +150,30 @@ __export(events_exports, {
|
|
129
150
|
eventStatuses: () => eventStatuses,
|
130
151
|
field: () => field,
|
131
152
|
fieldTypes: () => fieldTypes,
|
132
|
-
findActiveActionFields: () => findActiveActionFields,
|
133
|
-
findActiveActionForm: () => findActiveActionForm,
|
134
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
135
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
136
153
|
findActiveDrafts: () => findActiveDrafts,
|
137
|
-
|
138
|
-
|
154
|
+
findAllFields: () => findAllFields,
|
155
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
156
|
+
findRecordActionPages: () => findRecordActionPages,
|
157
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
158
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
139
159
|
generateActionDocument: () => generateActionDocument,
|
140
|
-
generateActionInput: () => generateActionInput,
|
141
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
142
160
|
generateEventDocument: () => generateEventDocument,
|
143
161
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
144
162
|
generateTransactionId: () => generateTransactionId,
|
145
163
|
generateTranslationConfig: () => generateTranslationConfig,
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
164
|
+
getAcceptedActions: () => getAcceptedActions,
|
165
|
+
getActionAnnotation: () => getActionAnnotation,
|
166
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
167
|
+
getActionReview: () => getActionReview,
|
168
|
+
getActionReviewFields: () => getActionReviewFields,
|
169
|
+
getAllAnnotationFields: () => getAllAnnotationFields,
|
170
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
150
171
|
getCurrentEventState: () => getCurrentEventState,
|
151
172
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
152
|
-
|
173
|
+
getDeclaration: () => getDeclaration,
|
174
|
+
getDeclarationFields: () => getDeclarationFields,
|
175
|
+
getDeclarationPages: () => getDeclarationPages,
|
153
176
|
getFieldValidationErrors: () => getFieldValidationErrors,
|
154
|
-
getFormFields: () => getFormFields,
|
155
|
-
getMetadataForAction: () => getMetadataForAction,
|
156
|
-
getVisiblePagesFormFields: () => getVisiblePagesFormFields,
|
157
177
|
isAddressFieldType: () => isAddressFieldType,
|
158
178
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
159
179
|
isBulletListFieldType: () => isBulletListFieldType,
|
@@ -165,6 +185,7 @@ __export(events_exports, {
|
|
165
185
|
isEmailFieldType: () => isEmailFieldType,
|
166
186
|
isFacilityFieldType: () => isFacilityFieldType,
|
167
187
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
188
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
168
189
|
isFieldEnabled: () => isFieldEnabled,
|
169
190
|
isFieldValue: () => isFieldValue,
|
170
191
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -185,50 +206,70 @@ __export(events_exports, {
|
|
185
206
|
isTextFieldType: () => isTextFieldType,
|
186
207
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
187
208
|
isVerificationPage: () => isVerificationPage,
|
209
|
+
isWriteAction: () => isWriteAction,
|
188
210
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
189
211
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
190
212
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
213
|
+
never: () => never,
|
191
214
|
not: () => not,
|
215
|
+
omitHiddenFields: () => omitHiddenFields,
|
216
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
192
217
|
or: () => or,
|
193
|
-
resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
|
194
|
-
stripHiddenFields: () => stripHiddenFields,
|
195
218
|
user: () => user,
|
196
219
|
validate: () => validate,
|
197
220
|
validateFieldInput: () => validateFieldInput,
|
198
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
221
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
222
|
+
writeActions: () => writeActions
|
199
223
|
});
|
200
224
|
module.exports = __toCommonJS(events_exports);
|
201
225
|
|
202
226
|
// ../commons/src/events/ActionConfig.ts
|
203
|
-
var
|
227
|
+
var import_zod9 = require("zod");
|
204
228
|
|
205
229
|
// ../commons/src/events/Conditional.ts
|
206
230
|
var import_zod = require("zod");
|
207
|
-
|
208
|
-
|
209
|
-
|
231
|
+
var Conditional = import_zod.z.custom(
|
232
|
+
(val) => typeof val === "object" && val !== null
|
233
|
+
);
|
210
234
|
var ConditionalType = {
|
211
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
212
235
|
SHOW: "SHOW",
|
213
|
-
|
214
|
-
|
236
|
+
ENABLE: "ENABLE",
|
237
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
215
238
|
};
|
216
239
|
var ShowConditional = import_zod.z.object({
|
217
240
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
218
|
-
conditional: Conditional
|
219
|
-
})
|
241
|
+
conditional: Conditional
|
242
|
+
}).describe(
|
243
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
244
|
+
);
|
220
245
|
var EnableConditional = import_zod.z.object({
|
221
246
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
222
|
-
conditional: Conditional
|
223
|
-
})
|
247
|
+
conditional: Conditional
|
248
|
+
}).describe(
|
249
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
250
|
+
);
|
224
251
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
225
252
|
// Action can be shown / hidden
|
226
253
|
ShowConditional,
|
227
254
|
// Action can be shown to the user in the list but as disabled
|
228
255
|
EnableConditional
|
229
256
|
]);
|
257
|
+
var DisplayOnReviewConditional = import_zod.z.object({
|
258
|
+
type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
259
|
+
conditional: Conditional
|
260
|
+
}).describe(
|
261
|
+
"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."
|
262
|
+
);
|
263
|
+
var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
264
|
+
// Field input can be shown / hidden
|
265
|
+
ShowConditional,
|
266
|
+
// Field input can be shown to the user but as disabled
|
267
|
+
EnableConditional,
|
268
|
+
// Field output can be shown / hidden on the review page
|
269
|
+
DisplayOnReviewConditional
|
270
|
+
]);
|
230
271
|
|
231
|
-
// ../commons/src/events/
|
272
|
+
// ../commons/src/events/PageConfig.ts
|
232
273
|
var import_zod6 = require("zod");
|
233
274
|
|
234
275
|
// ../commons/src/events/FieldConfig.ts
|
@@ -414,14 +455,14 @@ var BaseField = import_zod5.z.object({
|
|
414
455
|
]),
|
415
456
|
DependencyExpression
|
416
457
|
]).optional(),
|
417
|
-
conditionals: import_zod5.z.array(
|
458
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
418
459
|
required: import_zod5.z.boolean().default(false).optional(),
|
419
460
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
420
461
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
421
462
|
placeholder: TranslationConfig.optional(),
|
422
463
|
validation: import_zod5.z.array(
|
423
464
|
import_zod5.z.object({
|
424
|
-
validator: Conditional
|
465
|
+
validator: Conditional,
|
425
466
|
message: TranslationConfig
|
426
467
|
})
|
427
468
|
).default([]).optional(),
|
@@ -580,7 +621,7 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
580
621
|
]);
|
581
622
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
582
623
|
partOf: import_zod5.z.object({
|
583
|
-
$
|
624
|
+
$declaration: import_zod5.z.string()
|
584
625
|
}).optional().describe("Parent location"),
|
585
626
|
type: AdministrativeAreas
|
586
627
|
}).describe("Administrative area options");
|
@@ -615,11 +656,20 @@ var Address = BaseField.extend({
|
|
615
656
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
616
657
|
defaultValue: AddressFieldValue.optional()
|
617
658
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
659
|
+
var DataEntry = import_zod5.z.union([
|
660
|
+
import_zod5.z.object({
|
661
|
+
label: TranslationConfig,
|
662
|
+
value: import_zod5.z.string()
|
663
|
+
}),
|
664
|
+
import_zod5.z.object({
|
665
|
+
fieldId: import_zod5.z.string()
|
666
|
+
})
|
667
|
+
]);
|
618
668
|
var DataField = BaseField.extend({
|
619
669
|
type: import_zod5.z.literal(FieldType.DATA),
|
620
670
|
configuration: import_zod5.z.object({
|
621
671
|
subtitle: TranslationConfig.optional(),
|
622
|
-
data: import_zod5.z.array(
|
672
|
+
data: import_zod5.z.array(DataEntry)
|
623
673
|
})
|
624
674
|
}).describe("Data field for displaying read-only data");
|
625
675
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
@@ -645,23 +695,23 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
645
695
|
EmailField,
|
646
696
|
FileUploadWithOptions,
|
647
697
|
DataField
|
698
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
648
699
|
]);
|
649
700
|
|
650
|
-
// ../commons/src/events/
|
651
|
-
var
|
652
|
-
|
653
|
-
VERIFICATION: "VERIFICATION"
|
654
|
-
};
|
655
|
-
var FormPage = import_zod6.z.object({
|
701
|
+
// ../commons/src/events/PageConfig.ts
|
702
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
703
|
+
var PageConfigBase = import_zod6.z.object({
|
656
704
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
657
|
-
type: import_zod6.z.literal(FormPageType.FORM).default(FormPageType.FORM),
|
658
705
|
title: TranslationConfig.describe("Header title of the page"),
|
659
706
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
660
|
-
conditional: Conditional
|
707
|
+
conditional: Conditional.optional().describe(
|
661
708
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
662
709
|
)
|
663
710
|
});
|
664
|
-
var
|
711
|
+
var FormPageConfig = PageConfigBase.extend({
|
712
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
713
|
+
});
|
714
|
+
var VerificationActionConfig = import_zod6.z.object({
|
665
715
|
verify: import_zod6.z.object({ label: TranslationConfig }),
|
666
716
|
cancel: import_zod6.z.object({
|
667
717
|
label: TranslationConfig,
|
@@ -671,137 +721,182 @@ var VerificationPageConfig = import_zod6.z.object({
|
|
671
721
|
})
|
672
722
|
})
|
673
723
|
}).describe("Actions available on the verification page");
|
674
|
-
var
|
675
|
-
type: import_zod6.z.literal(
|
676
|
-
actions:
|
677
|
-
});
|
678
|
-
var FormPageConfig = import_zod6.z.preprocess(
|
679
|
-
(pageConfig) => ({
|
680
|
-
...pageConfig,
|
681
|
-
type: pageConfig.type ?? FormPageType.FORM
|
682
|
-
// Default type to "FORM" if not provided
|
683
|
-
}),
|
684
|
-
import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
|
685
|
-
);
|
686
|
-
var FormConfig = import_zod6.z.object({
|
687
|
-
label: TranslationConfig.describe("Human readable description of the form"),
|
688
|
-
version: import_zod6.z.object({
|
689
|
-
id: import_zod6.z.string().describe(
|
690
|
-
"Form version. Semantic versioning recommended. Example: 0.0.1"
|
691
|
-
),
|
692
|
-
label: TranslationConfig.describe(
|
693
|
-
"Human readable description of the version"
|
694
|
-
)
|
695
|
-
}),
|
696
|
-
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
697
|
-
pages: import_zod6.z.array(FormPageConfig),
|
698
|
-
review: import_zod6.z.object({
|
699
|
-
title: TranslationConfig.describe(
|
700
|
-
"Title of the form to show in review page"
|
701
|
-
),
|
702
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
703
|
-
})
|
724
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
725
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
726
|
+
actions: VerificationActionConfig
|
704
727
|
});
|
728
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
729
|
+
FormPageConfig,
|
730
|
+
VerificationPageConfig
|
731
|
+
]);
|
705
732
|
|
706
733
|
// ../commons/src/events/ActionType.ts
|
734
|
+
var import_zod7 = require("zod");
|
707
735
|
var ActionType = {
|
736
|
+
// Pre-declaration actions
|
737
|
+
DELETE: "DELETE",
|
708
738
|
CREATE: "CREATE",
|
709
|
-
ASSIGN: "ASSIGN",
|
710
|
-
UNASSIGN: "UNASSIGN",
|
711
|
-
REGISTER: "REGISTER",
|
712
|
-
VALIDATE: "VALIDATE",
|
713
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
714
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
715
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
716
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
717
739
|
NOTIFY: "NOTIFY",
|
740
|
+
// Declaration actions
|
718
741
|
DECLARE: "DECLARE",
|
719
|
-
|
720
|
-
|
721
|
-
|
742
|
+
VALIDATE: "VALIDATE",
|
743
|
+
REGISTER: "REGISTER",
|
744
|
+
// Declaration system actions. Non-configurable.
|
745
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
722
746
|
REJECT: "REJECT",
|
747
|
+
// REJECT_DECLARATION
|
723
748
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
749
|
+
// MARK_AS_DUPLICATE
|
724
750
|
ARCHIVE: "ARCHIVE",
|
725
|
-
|
751
|
+
// Record actions
|
752
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
753
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
754
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
755
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
756
|
+
// General actions
|
757
|
+
READ: "READ",
|
758
|
+
ASSIGN: "ASSIGN",
|
759
|
+
UNASSIGN: "UNASSIGN"
|
726
760
|
};
|
727
|
-
var
|
761
|
+
var ConfirmableActions = [
|
762
|
+
ActionType.NOTIFY,
|
763
|
+
ActionType.DECLARE,
|
764
|
+
ActionType.VALIDATE,
|
765
|
+
ActionType.REGISTER,
|
766
|
+
ActionType.REJECT,
|
767
|
+
ActionType.ARCHIVE,
|
768
|
+
ActionType.PRINT_CERTIFICATE
|
769
|
+
];
|
770
|
+
var ActionTypes = import_zod7.z.enum([
|
771
|
+
"DELETE",
|
772
|
+
"CREATE",
|
773
|
+
"NOTIFY",
|
774
|
+
"DECLARE",
|
775
|
+
"VALIDATE",
|
776
|
+
"REGISTER",
|
777
|
+
"DETECT_DUPLICATE",
|
778
|
+
"REJECT",
|
779
|
+
"MARKED_AS_DUPLICATE",
|
780
|
+
"ARCHIVE",
|
781
|
+
"PRINT_CERTIFICATE",
|
782
|
+
"REQUEST_CORRECTION",
|
783
|
+
"REJECT_CORRECTION",
|
784
|
+
"APPROVE_CORRECTION",
|
785
|
+
"READ",
|
786
|
+
"ASSIGN",
|
787
|
+
"UNASSIGN"
|
788
|
+
]);
|
789
|
+
var declarationActionValues = [
|
790
|
+
ActionTypes.enum.DECLARE,
|
791
|
+
ActionTypes.enum.VALIDATE,
|
792
|
+
ActionTypes.enum.REGISTER
|
793
|
+
];
|
794
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
795
|
+
var declarationUpdateActionValues = [
|
796
|
+
...declarationActionValues,
|
797
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
798
|
+
];
|
799
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
800
|
+
declarationUpdateActionValues
|
801
|
+
);
|
802
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
803
|
+
var writeActions = ActionTypes.exclude([
|
804
|
+
ActionType.CREATE,
|
805
|
+
ActionType.READ,
|
806
|
+
ActionType.ASSIGN,
|
807
|
+
ActionType.UNASSIGN
|
808
|
+
]);
|
809
|
+
|
810
|
+
// ../commons/src/events/FormConfig.ts
|
811
|
+
var import_zod8 = require("zod");
|
812
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
813
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
814
|
+
pages: import_zod8.z.array(FormPageConfig)
|
815
|
+
}).describe("Configuration for a declaration form");
|
816
|
+
var ActionFormConfig = import_zod8.z.object({
|
817
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
818
|
+
pages: import_zod8.z.array(PageConfig)
|
819
|
+
});
|
820
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
728
821
|
|
729
822
|
// ../commons/src/events/ActionConfig.ts
|
730
|
-
var ActionConditional2 =
|
823
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
731
824
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
732
825
|
ShowConditional,
|
733
826
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
734
827
|
EnableConditional
|
735
828
|
]);
|
736
|
-
var
|
829
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
830
|
+
title: TranslationConfig.describe("Title of the review page"),
|
831
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
832
|
+
}).describe("Configuration for **declaration** review page.");
|
833
|
+
var ActionConfigBase = import_zod9.z.object({
|
737
834
|
label: TranslationConfig,
|
738
|
-
conditionals:
|
739
|
-
draft:
|
740
|
-
forms: import_zod7.z.array(FormConfig)
|
835
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
836
|
+
draft: import_zod9.z.boolean().optional()
|
741
837
|
});
|
742
838
|
var DeclareConfig = ActionConfigBase.merge(
|
743
|
-
|
744
|
-
type:
|
839
|
+
import_zod9.z.object({
|
840
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
841
|
+
review: DeclarationReviewConfig
|
745
842
|
})
|
746
843
|
);
|
747
844
|
var ValidateConfig = ActionConfigBase.merge(
|
748
|
-
|
749
|
-
type:
|
845
|
+
import_zod9.z.object({
|
846
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
847
|
+
review: DeclarationReviewConfig
|
848
|
+
})
|
849
|
+
);
|
850
|
+
var RegisterConfig = ActionConfigBase.merge(
|
851
|
+
import_zod9.z.object({
|
852
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
853
|
+
review: DeclarationReviewConfig
|
750
854
|
})
|
751
855
|
);
|
752
856
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
753
|
-
|
754
|
-
type:
|
857
|
+
import_zod9.z.object({
|
858
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
755
859
|
})
|
756
860
|
);
|
757
861
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
758
|
-
|
759
|
-
type:
|
862
|
+
import_zod9.z.object({
|
863
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
760
864
|
})
|
761
865
|
);
|
762
866
|
var ArchiveConfig = ActionConfigBase.merge(
|
763
|
-
|
764
|
-
type:
|
765
|
-
})
|
766
|
-
);
|
767
|
-
var RegisterConfig = ActionConfigBase.merge(
|
768
|
-
import_zod7.z.object({
|
769
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
867
|
+
import_zod9.z.object({
|
868
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
770
869
|
})
|
771
870
|
);
|
772
871
|
var DeleteConfig = ActionConfigBase.merge(
|
773
|
-
|
774
|
-
type:
|
872
|
+
import_zod9.z.object({
|
873
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
775
874
|
})
|
776
875
|
);
|
777
876
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
778
|
-
|
779
|
-
type:
|
877
|
+
import_zod9.z.object({
|
878
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
879
|
+
printForm: ActionFormConfig
|
780
880
|
})
|
781
881
|
);
|
782
882
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
783
|
-
|
784
|
-
type:
|
785
|
-
onboardingForm:
|
786
|
-
additionalDetailsForm:
|
883
|
+
import_zod9.z.object({
|
884
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
885
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
886
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
787
887
|
})
|
788
888
|
);
|
789
889
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
790
|
-
|
791
|
-
type:
|
890
|
+
import_zod9.z.object({
|
891
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
792
892
|
})
|
793
893
|
);
|
794
894
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
795
|
-
|
796
|
-
type:
|
797
|
-
})
|
798
|
-
);
|
799
|
-
var CustomConfig = ActionConfigBase.merge(
|
800
|
-
import_zod7.z.object({
|
801
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
895
|
+
import_zod9.z.object({
|
896
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
802
897
|
})
|
803
898
|
);
|
804
|
-
var ActionConfig =
|
899
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
805
900
|
DeclareConfig,
|
806
901
|
ValidateConfig,
|
807
902
|
RejectDeclarationConfig,
|
@@ -812,102 +907,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
812
907
|
PrintCertificateActionConfig,
|
813
908
|
RequestCorrectionConfig,
|
814
909
|
RejectCorrectionConfig,
|
815
|
-
ApproveCorrectionConfig
|
816
|
-
|
910
|
+
ApproveCorrectionConfig
|
911
|
+
]);
|
912
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
913
|
+
DeclareConfig,
|
914
|
+
ValidateConfig,
|
915
|
+
RegisterConfig
|
817
916
|
]);
|
818
917
|
|
819
918
|
// ../commons/src/events/offline/CertificateConfig.ts
|
820
|
-
var
|
821
|
-
var FontFamily =
|
822
|
-
normal:
|
823
|
-
bold:
|
824
|
-
italics:
|
825
|
-
bolditalics:
|
919
|
+
var import_zod10 = require("zod");
|
920
|
+
var FontFamily = import_zod10.z.object({
|
921
|
+
normal: import_zod10.z.string(),
|
922
|
+
bold: import_zod10.z.string(),
|
923
|
+
italics: import_zod10.z.string(),
|
924
|
+
bolditalics: import_zod10.z.string()
|
826
925
|
});
|
827
|
-
var CertificateConfig =
|
828
|
-
id:
|
829
|
-
event:
|
926
|
+
var CertificateConfig = import_zod10.z.object({
|
927
|
+
id: import_zod10.z.string(),
|
928
|
+
event: import_zod10.z.string(),
|
830
929
|
label: TranslationConfig,
|
831
|
-
isDefault:
|
832
|
-
fee:
|
833
|
-
onTime:
|
834
|
-
late:
|
835
|
-
delayed:
|
930
|
+
isDefault: import_zod10.z.boolean(),
|
931
|
+
fee: import_zod10.z.object({
|
932
|
+
onTime: import_zod10.z.number(),
|
933
|
+
late: import_zod10.z.number(),
|
934
|
+
delayed: import_zod10.z.number()
|
836
935
|
}),
|
837
|
-
svgUrl:
|
838
|
-
fonts:
|
936
|
+
svgUrl: import_zod10.z.string(),
|
937
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
839
938
|
});
|
840
939
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
841
|
-
hash:
|
842
|
-
svg:
|
940
|
+
hash: import_zod10.z.string().optional(),
|
941
|
+
svg: import_zod10.z.string()
|
843
942
|
});
|
844
943
|
|
845
944
|
// ../commons/src/events/offline/LanguageConfig.ts
|
846
|
-
var
|
847
|
-
var LanguageConfig =
|
848
|
-
lang:
|
945
|
+
var import_zod11 = require("zod");
|
946
|
+
var LanguageConfig = import_zod11.z.object({
|
947
|
+
lang: import_zod11.z.string(),
|
849
948
|
/**
|
850
949
|
* client.csv contents
|
851
950
|
*/
|
852
|
-
messages:
|
951
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
853
952
|
});
|
854
953
|
|
855
954
|
// ../commons/src/events/EventConfig.ts
|
856
|
-
var
|
955
|
+
var import_zod20 = require("zod");
|
857
956
|
|
858
957
|
// ../commons/src/events/DeduplicationConfig.ts
|
859
|
-
var
|
860
|
-
var FieldReference =
|
861
|
-
var Matcher =
|
862
|
-
fieldId:
|
863
|
-
options:
|
864
|
-
boost:
|
958
|
+
var import_zod12 = require("zod");
|
959
|
+
var FieldReference = import_zod12.z.string();
|
960
|
+
var Matcher = import_zod12.z.object({
|
961
|
+
fieldId: import_zod12.z.string(),
|
962
|
+
options: import_zod12.z.object({
|
963
|
+
boost: import_zod12.z.number().optional()
|
865
964
|
}).optional().default({})
|
866
965
|
});
|
867
966
|
var FuzzyMatcher = Matcher.extend({
|
868
|
-
type:
|
869
|
-
options:
|
967
|
+
type: import_zod12.z.literal("fuzzy"),
|
968
|
+
options: import_zod12.z.object({
|
870
969
|
/**
|
871
970
|
* Names of length 3 or less characters = 0 edits allowed
|
872
971
|
* Names of length 4 - 6 characters = 1 edit allowed
|
873
972
|
* Names of length >7 characters = 2 edits allowed
|
874
973
|
*/
|
875
|
-
fuzziness:
|
876
|
-
boost:
|
974
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
975
|
+
boost: import_zod12.z.number().optional().default(1)
|
877
976
|
}).optional().default({})
|
878
977
|
});
|
879
978
|
var StrictMatcher = Matcher.extend({
|
880
|
-
type:
|
881
|
-
options:
|
882
|
-
boost:
|
979
|
+
type: import_zod12.z.literal("strict"),
|
980
|
+
options: import_zod12.z.object({
|
981
|
+
boost: import_zod12.z.number().optional().default(1)
|
883
982
|
}).optional().default({})
|
884
983
|
});
|
885
984
|
var DateRangeMatcher = Matcher.extend({
|
886
|
-
type:
|
887
|
-
options:
|
888
|
-
days:
|
985
|
+
type: import_zod12.z.literal("dateRange"),
|
986
|
+
options: import_zod12.z.object({
|
987
|
+
days: import_zod12.z.number(),
|
889
988
|
origin: FieldReference,
|
890
|
-
boost:
|
989
|
+
boost: import_zod12.z.number().optional().default(1)
|
891
990
|
})
|
892
991
|
});
|
893
992
|
var DateDistanceMatcher = Matcher.extend({
|
894
|
-
type:
|
895
|
-
options:
|
896
|
-
days:
|
993
|
+
type: import_zod12.z.literal("dateDistance"),
|
994
|
+
options: import_zod12.z.object({
|
995
|
+
days: import_zod12.z.number(),
|
897
996
|
origin: FieldReference,
|
898
|
-
boost:
|
997
|
+
boost: import_zod12.z.number().optional().default(1)
|
899
998
|
})
|
900
999
|
});
|
901
|
-
var And =
|
902
|
-
type:
|
903
|
-
|
1000
|
+
var And = import_zod12.z.object({
|
1001
|
+
type: import_zod12.z.literal("and"),
|
1002
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1003
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
904
1004
|
});
|
905
|
-
var Or =
|
906
|
-
type:
|
907
|
-
|
1005
|
+
var Or = import_zod12.z.object({
|
1006
|
+
type: import_zod12.z.literal("or"),
|
1007
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1008
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
908
1009
|
});
|
909
|
-
var Clause =
|
910
|
-
() =>
|
1010
|
+
var Clause = import_zod12.z.lazy(
|
1011
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
911
1012
|
And,
|
912
1013
|
Or,
|
913
1014
|
FuzzyMatcher,
|
@@ -916,37 +1017,37 @@ var Clause = import_zod10.z.lazy(
|
|
916
1017
|
DateDistanceMatcher
|
917
1018
|
])
|
918
1019
|
);
|
919
|
-
var DeduplicationConfig =
|
920
|
-
id:
|
1020
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1021
|
+
id: import_zod12.z.string(),
|
921
1022
|
label: TranslationConfig,
|
922
1023
|
query: Clause
|
923
1024
|
});
|
924
1025
|
|
925
1026
|
// ../commons/src/events/SummaryConfig.ts
|
926
|
-
var
|
927
|
-
var Field =
|
928
|
-
id:
|
1027
|
+
var import_zod13 = require("zod");
|
1028
|
+
var Field = import_zod13.z.object({
|
1029
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
929
1030
|
value: TranslationConfig.describe(
|
930
1031
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
931
1032
|
),
|
932
1033
|
label: TranslationConfig,
|
933
1034
|
emptyValueMessage: TranslationConfig.optional()
|
934
1035
|
});
|
935
|
-
var Title =
|
936
|
-
id:
|
1036
|
+
var Title = import_zod13.z.object({
|
1037
|
+
id: import_zod13.z.string(),
|
937
1038
|
label: TranslationConfig.describe("Title content"),
|
938
1039
|
emptyValueMessage: TranslationConfig.optional()
|
939
1040
|
});
|
940
|
-
var SummaryConfig =
|
1041
|
+
var SummaryConfig = import_zod13.z.object({
|
941
1042
|
title: Title.describe("Title of summary view."),
|
942
|
-
fields:
|
1043
|
+
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
943
1044
|
}).describe("Configuration for summary in event.");
|
944
1045
|
|
945
1046
|
// ../commons/src/events/WorkqueueConfig.ts
|
946
|
-
var
|
1047
|
+
var import_zod15 = require("zod");
|
947
1048
|
|
948
1049
|
// ../commons/src/events/EventMetadata.ts
|
949
|
-
var
|
1050
|
+
var import_zod14 = require("zod");
|
950
1051
|
var EventStatus = {
|
951
1052
|
CREATED: "CREATED",
|
952
1053
|
NOTIFIED: "NOTIFIED",
|
@@ -958,18 +1059,19 @@ var EventStatus = {
|
|
958
1059
|
ARCHIVED: "ARCHIVED"
|
959
1060
|
};
|
960
1061
|
var eventStatuses = Object.values(EventStatus);
|
961
|
-
var EventStatuses =
|
962
|
-
var EventMetadata =
|
963
|
-
id:
|
964
|
-
type:
|
1062
|
+
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1063
|
+
var EventMetadata = import_zod14.z.object({
|
1064
|
+
id: import_zod14.z.string(),
|
1065
|
+
type: import_zod14.z.string(),
|
965
1066
|
status: EventStatuses,
|
966
|
-
createdAt:
|
967
|
-
createdBy:
|
968
|
-
createdAtLocation:
|
969
|
-
modifiedAt:
|
970
|
-
assignedTo:
|
971
|
-
updatedBy:
|
972
|
-
trackingId:
|
1067
|
+
createdAt: import_zod14.z.string().datetime(),
|
1068
|
+
createdBy: import_zod14.z.string(),
|
1069
|
+
createdAtLocation: import_zod14.z.string(),
|
1070
|
+
modifiedAt: import_zod14.z.string().datetime(),
|
1071
|
+
assignedTo: import_zod14.z.string().nullish(),
|
1072
|
+
updatedBy: import_zod14.z.string(),
|
1073
|
+
trackingId: import_zod14.z.string(),
|
1074
|
+
registrationNumber: import_zod14.z.string().nullish()
|
973
1075
|
});
|
974
1076
|
var eventMetadataLabelMap = {
|
975
1077
|
"event.assignedTo": {
|
@@ -1021,28 +1123,33 @@ var eventMetadataLabelMap = {
|
|
1021
1123
|
id: "event.trackingId.label",
|
1022
1124
|
defaultMessage: "Tracking ID",
|
1023
1125
|
description: "Tracking ID"
|
1126
|
+
},
|
1127
|
+
"event.registrationNumber": {
|
1128
|
+
id: "event.registrationNumber.label",
|
1129
|
+
defaultMessage: "Registration Number",
|
1130
|
+
description: "Registration Number"
|
1024
1131
|
}
|
1025
1132
|
};
|
1026
1133
|
|
1027
1134
|
// ../commons/src/events/WorkqueueConfig.ts
|
1028
|
-
var WorkqueueConfig =
|
1029
|
-
id:
|
1030
|
-
filters:
|
1031
|
-
|
1032
|
-
status:
|
1135
|
+
var WorkqueueConfig = import_zod15.z.object({
|
1136
|
+
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1137
|
+
filters: import_zod15.z.array(
|
1138
|
+
import_zod15.z.object({
|
1139
|
+
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1033
1140
|
})
|
1034
1141
|
).describe("Filters to be applied to workqueue.")
|
1035
1142
|
}).describe("Configuration for workqueue.");
|
1036
1143
|
|
1037
1144
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1038
|
-
var
|
1039
|
-
var AdvancedSearchConfig =
|
1145
|
+
var import_zod16 = require("zod");
|
1146
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
1040
1147
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1041
|
-
fields:
|
1042
|
-
|
1043
|
-
fieldId:
|
1044
|
-
config:
|
1045
|
-
type:
|
1148
|
+
fields: import_zod16.z.array(
|
1149
|
+
import_zod16.z.object({
|
1150
|
+
fieldId: import_zod16.z.string(),
|
1151
|
+
config: import_zod16.z.object({
|
1152
|
+
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1046
1153
|
}).optional().describe("Configuration options for the field")
|
1047
1154
|
})
|
1048
1155
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -1052,12 +1159,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1052
1159
|
var import_lodash = require("lodash");
|
1053
1160
|
|
1054
1161
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1055
|
-
var
|
1162
|
+
var import_zod18 = require("zod");
|
1056
1163
|
|
1057
1164
|
// ../commons/src/workqueues/defaultColumns.ts
|
1058
|
-
var
|
1059
|
-
var WorkQueueColumnConfig =
|
1060
|
-
id:
|
1165
|
+
var import_zod17 = require("zod");
|
1166
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1167
|
+
id: import_zod17.z.string(),
|
1061
1168
|
label: TranslationConfig
|
1062
1169
|
});
|
1063
1170
|
var defaultColumns = {
|
@@ -1094,16 +1201,16 @@ var defaultColumns = {
|
|
1094
1201
|
}
|
1095
1202
|
}
|
1096
1203
|
};
|
1097
|
-
var DefaultColumnKeys =
|
1204
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
1098
1205
|
Object.keys(defaultColumns)
|
1099
1206
|
);
|
1100
1207
|
|
1101
1208
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1102
|
-
var rootWorkqueueConfig =
|
1103
|
-
id:
|
1209
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1210
|
+
id: import_zod18.z.string(),
|
1104
1211
|
title: TranslationConfig,
|
1105
|
-
columns:
|
1106
|
-
defaultColumns:
|
1212
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1213
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1107
1214
|
});
|
1108
1215
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1109
1216
|
|
@@ -1183,7 +1290,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1183
1290
|
var import_date_fns = require("date-fns");
|
1184
1291
|
|
1185
1292
|
// ../commons/src/events/FieldTypeMapping.ts
|
1186
|
-
var
|
1293
|
+
var import_zod19 = require("zod");
|
1187
1294
|
function mapFieldTypeToZod(type, required) {
|
1188
1295
|
let schema;
|
1189
1296
|
switch (type) {
|
@@ -1236,7 +1343,7 @@ function createValidationSchema(config) {
|
|
1236
1343
|
for (const field2 of config) {
|
1237
1344
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1238
1345
|
}
|
1239
|
-
return
|
1346
|
+
return import_zod19.z.object(shape);
|
1240
1347
|
}
|
1241
1348
|
function mapFieldTypeToMockValue(field2, i) {
|
1242
1349
|
switch (field2.type) {
|
@@ -1403,7 +1510,8 @@ var isDataFieldType = (field2) => {
|
|
1403
1510
|
|
1404
1511
|
// ../commons/src/conditionals/validate.ts
|
1405
1512
|
var ajv = new import_ajv.default({
|
1406
|
-
$data: true
|
1513
|
+
$data: true,
|
1514
|
+
allowUnionTypes: true
|
1407
1515
|
});
|
1408
1516
|
(0, import_ajv_formats.default)(ajv);
|
1409
1517
|
function validate(schema, data) {
|
@@ -1436,6 +1544,9 @@ function isFieldVisible(field2, form) {
|
|
1436
1544
|
function isFieldEnabled(field2, form) {
|
1437
1545
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1438
1546
|
}
|
1547
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1548
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1549
|
+
}
|
1439
1550
|
var errorMessages = {
|
1440
1551
|
hiddenField: {
|
1441
1552
|
id: "v2.error.hidden",
|
@@ -1463,12 +1574,14 @@ var errorMessages = {
|
|
1463
1574
|
id: "v2.error.invalid"
|
1464
1575
|
}
|
1465
1576
|
};
|
1466
|
-
|
1467
|
-
|
1468
|
-
message
|
1469
|
-
|
1470
|
-
}
|
1471
|
-
|
1577
|
+
function createIntlError(message) {
|
1578
|
+
return {
|
1579
|
+
message: {
|
1580
|
+
message
|
1581
|
+
}
|
1582
|
+
};
|
1583
|
+
}
|
1584
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1472
1585
|
switch (issue.code) {
|
1473
1586
|
case "invalid_string": {
|
1474
1587
|
if (_ctx.data === "") {
|
@@ -1506,8 +1619,29 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1506
1619
|
}
|
1507
1620
|
}
|
1508
1621
|
return createIntlError(errorMessages.invalidInput);
|
1509
|
-
}
|
1510
|
-
function
|
1622
|
+
}
|
1623
|
+
function runCustomFieldValidations({
|
1624
|
+
field: field2,
|
1625
|
+
conditionalParameters
|
1626
|
+
}) {
|
1627
|
+
return (field2.validation ?? []).filter((validation) => {
|
1628
|
+
return !validate(validation.validator, conditionalParameters);
|
1629
|
+
}).map((validation) => ({ message: validation.message }));
|
1630
|
+
}
|
1631
|
+
function validateFieldInput({
|
1632
|
+
field: field2,
|
1633
|
+
value
|
1634
|
+
}) {
|
1635
|
+
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1636
|
+
value,
|
1637
|
+
{
|
1638
|
+
// @ts-expect-error
|
1639
|
+
errorMap: zodToIntlErrorMap
|
1640
|
+
}
|
1641
|
+
);
|
1642
|
+
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1643
|
+
}
|
1644
|
+
function runFieldValidations({
|
1511
1645
|
field: field2,
|
1512
1646
|
values
|
1513
1647
|
}) {
|
@@ -1515,6 +1649,23 @@ function getFieldValidationErrors({
|
|
1515
1649
|
$form: values,
|
1516
1650
|
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1517
1651
|
};
|
1652
|
+
const fieldValidationResult = validateFieldInput({
|
1653
|
+
field: field2,
|
1654
|
+
value: values[field2.id]
|
1655
|
+
});
|
1656
|
+
const customValidationResults = runCustomFieldValidations({
|
1657
|
+
field: field2,
|
1658
|
+
conditionalParameters
|
1659
|
+
});
|
1660
|
+
return {
|
1661
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1662
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1663
|
+
};
|
1664
|
+
}
|
1665
|
+
function getFieldValidationErrors({
|
1666
|
+
field: field2,
|
1667
|
+
values
|
1668
|
+
}) {
|
1518
1669
|
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1519
1670
|
if (values[field2.id]) {
|
1520
1671
|
return {
|
@@ -1529,41 +1680,21 @@ function getFieldValidationErrors({
|
|
1529
1680
|
errors: []
|
1530
1681
|
};
|
1531
1682
|
}
|
1532
|
-
|
1533
|
-
field: field2,
|
1534
|
-
value: values[field2.id]
|
1535
|
-
});
|
1536
|
-
const customValidationResults = runCustomFieldValidations({
|
1683
|
+
return runFieldValidations({
|
1537
1684
|
field: field2,
|
1538
|
-
|
1685
|
+
values
|
1539
1686
|
});
|
1540
|
-
return {
|
1541
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1542
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1543
|
-
};
|
1544
1687
|
}
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
return (
|
1550
|
-
return !validate(validation.validator, conditionalParameters);
|
1551
|
-
}).map((validation) => ({ message: validation.message }));
|
1552
|
-
}
|
1553
|
-
function validateFieldInput({
|
1554
|
-
field: field2,
|
1555
|
-
value
|
1556
|
-
}) {
|
1557
|
-
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1558
|
-
value,
|
1559
|
-
{
|
1560
|
-
// @ts-expect-error
|
1561
|
-
errorMap: zodToIntlErrorMap
|
1562
|
-
}
|
1563
|
-
);
|
1564
|
-
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1688
|
+
|
1689
|
+
// ../commons/src/uuid.ts
|
1690
|
+
var import_uuid = require("uuid");
|
1691
|
+
function getUUID() {
|
1692
|
+
return (0, import_uuid.v4)();
|
1565
1693
|
}
|
1566
1694
|
|
1695
|
+
// ../commons/src/events/utils.ts
|
1696
|
+
var import_date_fns2 = require("date-fns");
|
1697
|
+
|
1567
1698
|
// ../commons/src/utils.ts
|
1568
1699
|
function getOrThrow(x, message) {
|
1569
1700
|
if (x === void 0 || x === null) {
|
@@ -1572,74 +1703,64 @@ function getOrThrow(x, message) {
|
|
1572
1703
|
return x;
|
1573
1704
|
}
|
1574
1705
|
|
1575
|
-
// ../commons/src/uuid.ts
|
1576
|
-
var import_uuid = require("uuid");
|
1577
|
-
function getUUID() {
|
1578
|
-
return (0, import_uuid.v4)();
|
1579
|
-
}
|
1580
|
-
|
1581
1706
|
// ../commons/src/events/utils.ts
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
)
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
})
|
1609
|
-
);
|
1707
|
+
function isDeclarationActionConfig(action) {
|
1708
|
+
return DeclarationActions.safeParse(action.type).success;
|
1709
|
+
}
|
1710
|
+
function getDeclarationFields(configuration) {
|
1711
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1712
|
+
}
|
1713
|
+
function getDeclarationPages(configuration) {
|
1714
|
+
return configuration.declaration.pages;
|
1715
|
+
}
|
1716
|
+
function getDeclaration(configuration) {
|
1717
|
+
return configuration.declaration;
|
1718
|
+
}
|
1719
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1720
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1721
|
+
return [
|
1722
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1723
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1724
|
+
];
|
1725
|
+
}
|
1726
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1727
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1728
|
+
}
|
1729
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1730
|
+
return actionConfig.review.fields;
|
1731
|
+
}
|
1732
|
+
return [];
|
1610
1733
|
};
|
1611
|
-
var
|
1612
|
-
|
1613
|
-
refFields
|
1614
|
-
}) => {
|
1615
|
-
return refFields.map((field2) => {
|
1616
|
-
if (field2.label) {
|
1617
|
-
return field2;
|
1618
|
-
}
|
1619
|
-
if (isMetadataField(field2.id)) {
|
1620
|
-
return {
|
1621
|
-
...field2,
|
1622
|
-
label: eventMetadataLabelMap[field2.id]
|
1623
|
-
};
|
1624
|
-
}
|
1625
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1626
|
-
if (!pageLabel) {
|
1627
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1628
|
-
}
|
1629
|
-
return {
|
1630
|
-
...field2,
|
1631
|
-
label: pageLabel.label
|
1632
|
-
};
|
1633
|
-
});
|
1734
|
+
var getAllAnnotationFields = (config) => {
|
1735
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1634
1736
|
};
|
1635
|
-
|
1636
|
-
return
|
1637
|
-
...
|
1638
|
-
...
|
1737
|
+
var findAllFields = (config) => {
|
1738
|
+
return (0, import_lodash.flattenDeep)([
|
1739
|
+
...getDeclarationFields(config),
|
1740
|
+
...getAllAnnotationFields(config)
|
1639
1741
|
]);
|
1742
|
+
};
|
1743
|
+
var findRecordActionPages = (config, actionType) => {
|
1744
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1745
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1746
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1747
|
+
}
|
1748
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1749
|
+
return action.printForm.pages;
|
1750
|
+
}
|
1751
|
+
return [];
|
1752
|
+
};
|
1753
|
+
function getActionReview(configuration, actionType) {
|
1754
|
+
const [actionConfig] = configuration.actions.filter(
|
1755
|
+
(a) => a.type === actionType
|
1756
|
+
);
|
1757
|
+
return getOrThrow(
|
1758
|
+
actionConfig.review,
|
1759
|
+
`No review config found for ${actionType}`
|
1760
|
+
);
|
1640
1761
|
}
|
1641
|
-
function
|
1642
|
-
return configuration
|
1762
|
+
function getActionReviewFields(configuration, actionType) {
|
1763
|
+
return getActionReview(configuration, actionType).fields;
|
1643
1764
|
}
|
1644
1765
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1645
1766
|
workqueueConfigs.map((workqueue) => {
|
@@ -1653,17 +1774,6 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1653
1774
|
}
|
1654
1775
|
});
|
1655
1776
|
}
|
1656
|
-
var findActiveActionForm = (configuration, action) => {
|
1657
|
-
const actionConfig = configuration.actions.find((a) => a.type === action);
|
1658
|
-
const form = actionConfig?.forms.find((f) => f.active);
|
1659
|
-
return form;
|
1660
|
-
};
|
1661
|
-
var findActiveActionFormPages = (configuration, action) => {
|
1662
|
-
return findActiveActionForm(configuration, action)?.pages;
|
1663
|
-
};
|
1664
|
-
var getFormFields = (formConfig) => {
|
1665
|
-
return formConfig.pages.flatMap((p) => p.fields);
|
1666
|
-
};
|
1667
1777
|
function isPageVisible(page, formValues) {
|
1668
1778
|
if (!page.conditional) {
|
1669
1779
|
return true;
|
@@ -1673,64 +1783,19 @@ function isPageVisible(page, formValues) {
|
|
1673
1783
|
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1674
1784
|
});
|
1675
1785
|
}
|
1676
|
-
|
1677
|
-
return
|
1678
|
-
};
|
1679
|
-
var findActiveActionFormFields = (configuration, action) => {
|
1680
|
-
const form = findActiveActionForm(configuration, action);
|
1681
|
-
return form ? getFormFields(form) : void 0;
|
1682
|
-
};
|
1683
|
-
var findActiveActionFields = (configuration, action, formData) => {
|
1684
|
-
const form = findActiveActionForm(configuration, action);
|
1685
|
-
const reviewFields = form?.review.fields;
|
1686
|
-
let formFields = void 0;
|
1687
|
-
if (form) {
|
1688
|
-
formFields = formData ? getVisiblePagesFormFields(form, formData) : getFormFields(form);
|
1689
|
-
}
|
1690
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1691
|
-
return allFields;
|
1692
|
-
};
|
1693
|
-
var getActiveActionFormPages = (configuration, action) => {
|
1694
|
-
return getOrThrow(
|
1695
|
-
findActiveActionForm(configuration, action)?.pages,
|
1696
|
-
"Form configuration not found for type: " + configuration.id
|
1697
|
-
);
|
1698
|
-
};
|
1699
|
-
function getActiveActionFields(configuration, action) {
|
1700
|
-
if (LatentActions.some((latentAction) => latentAction === action)) {
|
1701
|
-
return getActiveActionFields(configuration, ActionType.DECLARE);
|
1702
|
-
}
|
1703
|
-
const fields = findActiveActionFields(configuration, action);
|
1704
|
-
if (!fields) {
|
1705
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1706
|
-
}
|
1707
|
-
return fields;
|
1708
|
-
}
|
1709
|
-
function getEventConfiguration(eventConfigurations, type) {
|
1710
|
-
const config = eventConfigurations.find((config2) => config2.id === type);
|
1711
|
-
if (!config) {
|
1712
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1713
|
-
}
|
1714
|
-
return config;
|
1715
|
-
}
|
1716
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1717
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1718
|
-
return false;
|
1719
|
-
}
|
1720
|
-
return !form[field2.id];
|
1721
|
-
}
|
1722
|
-
function stripHiddenFields(fields, data) {
|
1723
|
-
return (0, import_lodash.omitBy)(data, (_2, fieldId) => {
|
1786
|
+
function omitHiddenFields(fields, values) {
|
1787
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1724
1788
|
const field2 = fields.find((f) => f.id === fieldId);
|
1725
1789
|
if (!field2) {
|
1726
1790
|
return true;
|
1727
1791
|
}
|
1728
|
-
|
1729
|
-
return true;
|
1730
|
-
}
|
1731
|
-
return !isFieldVisible(field2, data);
|
1792
|
+
return !isFieldVisible(field2, values);
|
1732
1793
|
});
|
1733
1794
|
}
|
1795
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1796
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1797
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1798
|
+
}
|
1734
1799
|
function findActiveDrafts(event2, drafts) {
|
1735
1800
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1736
1801
|
const lastAction = actions[actions.length - 1];
|
@@ -1744,8 +1809,8 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1744
1809
|
transactionId: getUUID(),
|
1745
1810
|
action: {
|
1746
1811
|
type: actionType,
|
1747
|
-
|
1748
|
-
|
1812
|
+
declaration: {},
|
1813
|
+
annotation: {},
|
1749
1814
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1750
1815
|
createdBy: "@todo",
|
1751
1816
|
createdAtLocation: "@todo"
|
@@ -1753,22 +1818,49 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1753
1818
|
};
|
1754
1819
|
}
|
1755
1820
|
function isVerificationPage(page) {
|
1756
|
-
return page.type ===
|
1821
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
1822
|
+
}
|
1823
|
+
function deepMerge(currentDocument, actionDocument) {
|
1824
|
+
return (0, import_lodash.mergeWith)(
|
1825
|
+
currentDocument,
|
1826
|
+
actionDocument,
|
1827
|
+
(previousValue, incomingValue) => {
|
1828
|
+
if (incomingValue === void 0) {
|
1829
|
+
return previousValue;
|
1830
|
+
}
|
1831
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1832
|
+
return incomingValue;
|
1833
|
+
}
|
1834
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1835
|
+
return void 0;
|
1836
|
+
}
|
1837
|
+
return incomingValue;
|
1838
|
+
}
|
1839
|
+
);
|
1840
|
+
}
|
1841
|
+
function findLastAssignmentAction(actions) {
|
1842
|
+
return actions.filter(
|
1843
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1844
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1845
|
+
}
|
1846
|
+
function isWriteAction(actionType) {
|
1847
|
+
return writeActions.safeParse(actionType).success;
|
1757
1848
|
}
|
1758
1849
|
|
1759
1850
|
// ../commons/src/events/EventConfig.ts
|
1760
|
-
var EventConfig =
|
1761
|
-
id:
|
1851
|
+
var EventConfig = import_zod20.z.object({
|
1852
|
+
id: import_zod20.z.string().describe(
|
1762
1853
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1763
1854
|
),
|
1764
1855
|
summary: SummaryConfig,
|
1765
1856
|
label: TranslationConfig,
|
1766
|
-
actions:
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1857
|
+
actions: import_zod20.z.array(ActionConfig),
|
1858
|
+
declaration: DeclarationFormConfig,
|
1859
|
+
workqueues: import_zod20.z.array(WorkqueueConfig),
|
1860
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
1861
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1770
1862
|
}).superRefine((event2, ctx) => {
|
1771
|
-
const allFields =
|
1863
|
+
const allFields = findAllFields(event2);
|
1772
1864
|
const fieldIds = allFields.map((field2) => field2.id);
|
1773
1865
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1774
1866
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1795,111 +1887,118 @@ var EventConfig = import_zod18.z.object({
|
|
1795
1887
|
});
|
1796
1888
|
|
1797
1889
|
// ../commons/src/events/EventConfigInput.ts
|
1798
|
-
var
|
1890
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1891
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1892
|
+
var definePage = (page) => PageConfig.parse(page);
|
1799
1893
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1800
1894
|
|
1801
1895
|
// ../commons/src/events/Draft.ts
|
1802
|
-
var
|
1896
|
+
var import_zod23 = require("zod");
|
1803
1897
|
|
1804
1898
|
// ../commons/src/events/ActionDocument.ts
|
1805
|
-
var
|
1806
|
-
var ActionUpdate =
|
1807
|
-
var
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1899
|
+
var import_zod21 = require("zod");
|
1900
|
+
var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
|
1901
|
+
var ActionStatus = {
|
1902
|
+
Requested: "Requested",
|
1903
|
+
Accepted: "Accepted",
|
1904
|
+
Rejected: "Rejected"
|
1905
|
+
};
|
1906
|
+
var ActionBase = import_zod21.z.object({
|
1907
|
+
id: import_zod21.z.string(),
|
1908
|
+
createdAt: import_zod21.z.string().datetime(),
|
1909
|
+
createdBy: import_zod21.z.string(),
|
1910
|
+
declaration: ActionUpdate,
|
1911
|
+
annotation: ActionUpdate.optional(),
|
1912
|
+
createdAtLocation: import_zod21.z.string(),
|
1913
|
+
status: import_zod21.z.enum([
|
1914
|
+
ActionStatus.Requested,
|
1915
|
+
ActionStatus.Accepted,
|
1916
|
+
ActionStatus.Rejected
|
1917
|
+
]),
|
1918
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1919
|
+
originalActionId: import_zod21.z.string().optional()
|
1814
1920
|
});
|
1815
1921
|
var AssignedAction = ActionBase.merge(
|
1816
|
-
|
1817
|
-
type:
|
1818
|
-
assignedTo:
|
1922
|
+
import_zod21.z.object({
|
1923
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1924
|
+
assignedTo: import_zod21.z.string()
|
1819
1925
|
})
|
1820
1926
|
);
|
1821
1927
|
var UnassignedAction = ActionBase.merge(
|
1822
|
-
|
1823
|
-
type:
|
1928
|
+
import_zod21.z.object({
|
1929
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1930
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1824
1931
|
})
|
1825
1932
|
);
|
1826
1933
|
var RegisterAction = ActionBase.merge(
|
1827
|
-
|
1828
|
-
type:
|
1829
|
-
|
1830
|
-
trackingId: import_zod19.z.string(),
|
1831
|
-
registrationNumber: import_zod19.z.string()
|
1832
|
-
})
|
1934
|
+
import_zod21.z.object({
|
1935
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1936
|
+
registrationNumber: import_zod21.z.string().optional()
|
1833
1937
|
})
|
1834
1938
|
);
|
1835
1939
|
var DeclareAction = ActionBase.merge(
|
1836
|
-
|
1837
|
-
type:
|
1940
|
+
import_zod21.z.object({
|
1941
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1838
1942
|
})
|
1839
1943
|
);
|
1840
1944
|
var ValidateAction = ActionBase.merge(
|
1841
|
-
|
1842
|
-
type:
|
1945
|
+
import_zod21.z.object({
|
1946
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1843
1947
|
})
|
1844
1948
|
);
|
1845
1949
|
var RejectAction = ActionBase.merge(
|
1846
|
-
|
1847
|
-
type:
|
1950
|
+
import_zod21.z.object({
|
1951
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1848
1952
|
})
|
1849
1953
|
);
|
1850
1954
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1851
|
-
|
1852
|
-
type:
|
1955
|
+
import_zod21.z.object({
|
1956
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1853
1957
|
})
|
1854
1958
|
);
|
1855
1959
|
var ArchiveAction = ActionBase.merge(
|
1856
|
-
|
1857
|
-
type:
|
1960
|
+
import_zod21.z.object({
|
1961
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1858
1962
|
})
|
1859
1963
|
);
|
1860
1964
|
var CreatedAction = ActionBase.merge(
|
1861
|
-
|
1862
|
-
type:
|
1965
|
+
import_zod21.z.object({
|
1966
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1863
1967
|
})
|
1864
1968
|
);
|
1865
1969
|
var NotifiedAction = ActionBase.merge(
|
1866
|
-
|
1867
|
-
type:
|
1970
|
+
import_zod21.z.object({
|
1971
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1868
1972
|
})
|
1869
1973
|
);
|
1870
1974
|
var PrintCertificateAction = ActionBase.merge(
|
1871
|
-
|
1872
|
-
type:
|
1975
|
+
import_zod21.z.object({
|
1976
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1873
1977
|
})
|
1874
1978
|
);
|
1875
1979
|
var RequestedCorrectionAction = ActionBase.merge(
|
1876
|
-
|
1877
|
-
type:
|
1980
|
+
import_zod21.z.object({
|
1981
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1878
1982
|
})
|
1879
1983
|
);
|
1880
1984
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1881
|
-
|
1882
|
-
type:
|
1883
|
-
requestId:
|
1985
|
+
import_zod21.z.object({
|
1986
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1987
|
+
requestId: import_zod21.z.string()
|
1884
1988
|
})
|
1885
1989
|
);
|
1886
1990
|
var RejectedCorrectionAction = ActionBase.merge(
|
1887
|
-
|
1888
|
-
type:
|
1889
|
-
requestId:
|
1991
|
+
import_zod21.z.object({
|
1992
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1993
|
+
requestId: import_zod21.z.string()
|
1890
1994
|
})
|
1891
1995
|
);
|
1892
1996
|
var ReadAction = ActionBase.merge(
|
1893
|
-
|
1894
|
-
type:
|
1895
|
-
})
|
1896
|
-
);
|
1897
|
-
var CustomAction = ActionBase.merge(
|
1898
|
-
import_zod19.z.object({
|
1899
|
-
type: import_zod19.z.literal(ActionType.CUSTOM)
|
1997
|
+
import_zod21.z.object({
|
1998
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1900
1999
|
})
|
1901
2000
|
);
|
1902
|
-
var ActionDocument =
|
2001
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1903
2002
|
CreatedAction,
|
1904
2003
|
ValidateAction,
|
1905
2004
|
RejectAction,
|
@@ -1914,114 +2013,125 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1914
2013
|
RejectedCorrectionAction,
|
1915
2014
|
UnassignedAction,
|
1916
2015
|
PrintCertificateAction,
|
1917
|
-
ReadAction
|
1918
|
-
CustomAction
|
2016
|
+
ReadAction
|
1919
2017
|
]);
|
1920
|
-
var
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
2018
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
2019
|
+
declaration: true,
|
2020
|
+
annotation: true,
|
2021
|
+
createdBy: true,
|
2022
|
+
createdAtLocation: true
|
2023
|
+
}).merge(
|
2024
|
+
import_zod21.z.object({
|
2025
|
+
type: import_zod21.z.enum(ConfirmableActions),
|
2026
|
+
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2027
|
+
})
|
2028
|
+
);
|
2029
|
+
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2030
|
+
var ResolvedUser = import_zod21.z.object({
|
2031
|
+
id: import_zod21.z.string(),
|
2032
|
+
role: import_zod21.z.string(),
|
2033
|
+
name: import_zod21.z.array(
|
2034
|
+
import_zod21.z.object({
|
2035
|
+
use: import_zod21.z.string(),
|
2036
|
+
given: import_zod21.z.array(import_zod21.z.string()),
|
2037
|
+
family: import_zod21.z.string()
|
1928
2038
|
})
|
1929
2039
|
)
|
1930
2040
|
});
|
1931
2041
|
|
1932
2042
|
// ../commons/src/events/ActionInput.ts
|
1933
|
-
var
|
1934
|
-
var BaseActionInput =
|
1935
|
-
eventId:
|
1936
|
-
transactionId:
|
1937
|
-
|
1938
|
-
|
2043
|
+
var import_zod22 = require("zod");
|
2044
|
+
var BaseActionInput = import_zod22.z.object({
|
2045
|
+
eventId: import_zod22.z.string(),
|
2046
|
+
transactionId: import_zod22.z.string(),
|
2047
|
+
declaration: ActionUpdate.default({}),
|
2048
|
+
annotation: ActionUpdate.optional(),
|
2049
|
+
originalActionId: import_zod22.z.string().optional(),
|
2050
|
+
keepAssignment: import_zod22.z.boolean().optional()
|
1939
2051
|
});
|
1940
2052
|
var CreateActionInput = BaseActionInput.merge(
|
1941
|
-
|
1942
|
-
type:
|
1943
|
-
createdAtLocation:
|
2053
|
+
import_zod22.z.object({
|
2054
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2055
|
+
createdAtLocation: import_zod22.z.string()
|
1944
2056
|
})
|
1945
2057
|
);
|
1946
2058
|
var RegisterActionInput = BaseActionInput.merge(
|
1947
|
-
|
1948
|
-
type:
|
1949
|
-
|
1950
|
-
trackingId: import_zod20.z.string(),
|
1951
|
-
registrationNumber: import_zod20.z.string()
|
1952
|
-
})
|
2059
|
+
import_zod22.z.object({
|
2060
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2061
|
+
registrationNumber: import_zod22.z.string().optional()
|
1953
2062
|
})
|
1954
2063
|
);
|
1955
2064
|
var ValidateActionInput = BaseActionInput.merge(
|
1956
|
-
|
1957
|
-
type:
|
1958
|
-
duplicates:
|
2065
|
+
import_zod22.z.object({
|
2066
|
+
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2067
|
+
duplicates: import_zod22.z.array(import_zod22.z.string())
|
1959
2068
|
})
|
1960
2069
|
);
|
1961
2070
|
var NotifyActionInput = BaseActionInput.merge(
|
1962
|
-
|
1963
|
-
type:
|
2071
|
+
import_zod22.z.object({
|
2072
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1964
2073
|
})
|
1965
2074
|
);
|
1966
2075
|
var DeclareActionInput = BaseActionInput.merge(
|
1967
|
-
|
1968
|
-
type:
|
2076
|
+
import_zod22.z.object({
|
2077
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1969
2078
|
})
|
1970
2079
|
);
|
1971
2080
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1972
|
-
|
1973
|
-
type:
|
2081
|
+
import_zod22.z.object({
|
2082
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1974
2083
|
})
|
1975
2084
|
);
|
1976
2085
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1977
|
-
|
1978
|
-
type:
|
2086
|
+
import_zod22.z.object({
|
2087
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1979
2088
|
})
|
1980
2089
|
);
|
1981
2090
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1982
|
-
|
1983
|
-
type:
|
2091
|
+
import_zod22.z.object({
|
2092
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1984
2093
|
})
|
1985
2094
|
);
|
1986
2095
|
var ArchiveActionInput = BaseActionInput.merge(
|
1987
|
-
|
1988
|
-
type:
|
2096
|
+
import_zod22.z.object({
|
2097
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1989
2098
|
})
|
1990
2099
|
);
|
1991
2100
|
var AssignActionInput = BaseActionInput.merge(
|
1992
|
-
|
1993
|
-
type:
|
1994
|
-
assignedTo:
|
2101
|
+
import_zod22.z.object({
|
2102
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2103
|
+
assignedTo: import_zod22.z.string()
|
1995
2104
|
})
|
1996
2105
|
);
|
1997
2106
|
var UnassignActionInput = BaseActionInput.merge(
|
1998
|
-
|
1999
|
-
type:
|
2107
|
+
import_zod22.z.object({
|
2108
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2109
|
+
assignedTo: import_zod22.z.literal(null).default(null)
|
2000
2110
|
})
|
2001
2111
|
);
|
2002
2112
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2003
|
-
|
2004
|
-
type:
|
2113
|
+
import_zod22.z.object({
|
2114
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2005
2115
|
})
|
2006
2116
|
);
|
2007
2117
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2008
|
-
|
2009
|
-
requestId:
|
2010
|
-
type:
|
2118
|
+
import_zod22.z.object({
|
2119
|
+
requestId: import_zod22.z.string(),
|
2120
|
+
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2011
2121
|
})
|
2012
2122
|
);
|
2013
2123
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2014
|
-
|
2015
|
-
requestId:
|
2016
|
-
type:
|
2124
|
+
import_zod22.z.object({
|
2125
|
+
requestId: import_zod22.z.string(),
|
2126
|
+
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2017
2127
|
})
|
2018
2128
|
);
|
2019
2129
|
var ReadActionInput = BaseActionInput.merge(
|
2020
|
-
|
2021
|
-
type:
|
2130
|
+
import_zod22.z.object({
|
2131
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2022
2132
|
})
|
2023
2133
|
);
|
2024
|
-
var ActionInput =
|
2134
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2025
2135
|
CreateActionInput,
|
2026
2136
|
ValidateActionInput,
|
2027
2137
|
RegisterActionInput,
|
@@ -2040,52 +2150,57 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
2040
2150
|
]);
|
2041
2151
|
|
2042
2152
|
// ../commons/src/events/Draft.ts
|
2043
|
-
var Draft =
|
2044
|
-
id:
|
2045
|
-
eventId:
|
2046
|
-
transactionId:
|
2047
|
-
createdAt:
|
2153
|
+
var Draft = import_zod23.z.object({
|
2154
|
+
id: import_zod23.z.string(),
|
2155
|
+
eventId: import_zod23.z.string(),
|
2156
|
+
transactionId: import_zod23.z.string(),
|
2157
|
+
createdAt: import_zod23.z.string().datetime(),
|
2048
2158
|
action: ActionBase.extend({
|
2049
|
-
type:
|
2159
|
+
type: ActionTypes
|
2050
2160
|
}).omit({ id: true })
|
2051
2161
|
});
|
2052
2162
|
var DraftInput = BaseActionInput.extend({
|
2053
|
-
type:
|
2163
|
+
type: ActionTypes
|
2054
2164
|
});
|
2055
2165
|
|
2056
|
-
// ../commons/src/events/EventInput.ts
|
2057
|
-
var
|
2058
|
-
var EventInput =
|
2059
|
-
transactionId:
|
2060
|
-
type:
|
2166
|
+
// ../commons/src/events/EventInput.ts
|
2167
|
+
var import_zod24 = require("zod");
|
2168
|
+
var EventInput = import_zod24.z.object({
|
2169
|
+
transactionId: import_zod24.z.string(),
|
2170
|
+
type: import_zod24.z.string()
|
2061
2171
|
});
|
2062
2172
|
|
2063
2173
|
// ../commons/src/events/EventDocument.ts
|
2064
|
-
var
|
2065
|
-
var EventDocument =
|
2066
|
-
id:
|
2067
|
-
type:
|
2068
|
-
createdAt:
|
2069
|
-
updatedAt:
|
2070
|
-
actions:
|
2071
|
-
trackingId:
|
2174
|
+
var import_zod25 = require("zod");
|
2175
|
+
var EventDocument = import_zod25.z.object({
|
2176
|
+
id: import_zod25.z.string(),
|
2177
|
+
type: import_zod25.z.string(),
|
2178
|
+
createdAt: import_zod25.z.string().datetime(),
|
2179
|
+
updatedAt: import_zod25.z.string().datetime(),
|
2180
|
+
actions: import_zod25.z.array(Action),
|
2181
|
+
trackingId: import_zod25.z.string()
|
2072
2182
|
});
|
2073
2183
|
|
2074
2184
|
// ../commons/src/events/EventIndex.ts
|
2075
|
-
var
|
2185
|
+
var import_zod26 = require("zod");
|
2076
2186
|
var EventIndex = EventMetadata.extend({
|
2077
|
-
|
2187
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2078
2188
|
});
|
2079
|
-
var EventSearchIndex =
|
2080
|
-
|
2081
|
-
type:
|
2189
|
+
var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
|
2190
|
+
import_zod26.z.object({
|
2191
|
+
type: import_zod26.z.string()
|
2082
2192
|
// Ensures "type" (event-id) exists and is a string
|
2083
2193
|
})
|
2084
2194
|
);
|
2085
2195
|
|
2086
2196
|
// ../commons/src/events/state/index.ts
|
2087
|
-
var _ = __toESM(require("lodash"));
|
2088
2197
|
function getStatusFromActions(actions) {
|
2198
|
+
const hasRejectedAction = actions.some(
|
2199
|
+
(a) => a.status === ActionStatus.Rejected
|
2200
|
+
);
|
2201
|
+
if (hasRejectedAction) {
|
2202
|
+
return EventStatus.REJECTED;
|
2203
|
+
}
|
2089
2204
|
return actions.reduce((status, action) => {
|
2090
2205
|
if (action.type === ActionType.CREATE) {
|
2091
2206
|
return EventStatus.CREATED;
|
@@ -2122,7 +2237,7 @@ function getAssignedUserFromActions(actions) {
|
|
2122
2237
|
return user2;
|
2123
2238
|
}, null);
|
2124
2239
|
}
|
2125
|
-
function
|
2240
|
+
function aggregateActionDeclarations(actions) {
|
2126
2241
|
const excludedActions = [
|
2127
2242
|
ActionType.REQUEST_CORRECTION,
|
2128
2243
|
ActionType.PRINT_CERTIFICATE
|
@@ -2136,47 +2251,35 @@ function getData(actions) {
|
|
2136
2251
|
if (!requestAction) {
|
2137
2252
|
return status;
|
2138
2253
|
}
|
2139
|
-
return deepMerge(status, requestAction.
|
2254
|
+
return deepMerge(status, requestAction.declaration);
|
2140
2255
|
}
|
2141
|
-
return deepMerge(status, action.
|
2256
|
+
return deepMerge(status, action.declaration);
|
2142
2257
|
}, {});
|
2143
2258
|
}
|
2144
2259
|
function deepDropNulls(obj) {
|
2145
|
-
if (
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
[key]
|
2154
|
-
};
|
2155
|
-
}
|
2156
|
-
return acc;
|
2157
|
-
}, {});
|
2158
|
-
}
|
2159
|
-
function deepMerge(currentDocument, actionDocument) {
|
2160
|
-
return _.mergeWith(
|
2161
|
-
currentDocument,
|
2162
|
-
actionDocument,
|
2163
|
-
(previousValue, incomingValue) => {
|
2164
|
-
if (incomingValue === void 0) {
|
2165
|
-
return previousValue;
|
2166
|
-
}
|
2167
|
-
if (_.isArray(incomingValue)) {
|
2168
|
-
return incomingValue;
|
2169
|
-
}
|
2170
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2171
|
-
return void 0;
|
2260
|
+
if (Array.isArray(obj)) {
|
2261
|
+
return obj.map(deepDropNulls);
|
2262
|
+
}
|
2263
|
+
if (obj !== null && typeof obj === "object") {
|
2264
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2265
|
+
const cleanedValue = deepDropNulls(value);
|
2266
|
+
if (cleanedValue !== null) {
|
2267
|
+
;
|
2268
|
+
acc[key] = cleanedValue;
|
2172
2269
|
}
|
2173
|
-
return
|
2174
|
-
}
|
2175
|
-
|
2270
|
+
return acc;
|
2271
|
+
}, {});
|
2272
|
+
}
|
2273
|
+
return obj;
|
2176
2274
|
}
|
2177
2275
|
function isUndeclaredDraft(status) {
|
2178
2276
|
return status === EventStatus.CREATED;
|
2179
2277
|
}
|
2278
|
+
function getAcceptedActions(event2) {
|
2279
|
+
return event2.actions.filter(
|
2280
|
+
(a) => a.status === ActionStatus.Accepted
|
2281
|
+
);
|
2282
|
+
}
|
2180
2283
|
function getCurrentEventState(event2) {
|
2181
2284
|
const creationAction = event2.actions.find(
|
2182
2285
|
(action) => action.type === ActionType.CREATE
|
@@ -2184,7 +2287,12 @@ function getCurrentEventState(event2) {
|
|
2184
2287
|
if (!creationAction) {
|
2185
2288
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2186
2289
|
}
|
2187
|
-
const
|
2290
|
+
const activeActions = getAcceptedActions(event2);
|
2291
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2292
|
+
const registrationAction = activeActions.find(
|
2293
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2294
|
+
);
|
2295
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2188
2296
|
return deepDropNulls({
|
2189
2297
|
id: event2.id,
|
2190
2298
|
type: event2.type,
|
@@ -2193,10 +2301,11 @@ function getCurrentEventState(event2) {
|
|
2193
2301
|
createdBy: creationAction.createdBy,
|
2194
2302
|
createdAtLocation: creationAction.createdAtLocation,
|
2195
2303
|
modifiedAt: latestAction.createdAt,
|
2196
|
-
assignedTo: getAssignedUserFromActions(
|
2304
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2197
2305
|
updatedBy: latestAction.createdBy,
|
2198
|
-
|
2199
|
-
trackingId: event2.trackingId
|
2306
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2307
|
+
trackingId: event2.trackingId,
|
2308
|
+
registrationNumber
|
2200
2309
|
});
|
2201
2310
|
}
|
2202
2311
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2228,38 +2337,44 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2228
2337
|
}
|
2229
2338
|
return {
|
2230
2339
|
...eventIndex,
|
2231
|
-
|
2232
|
-
...eventIndex.
|
2233
|
-
...activeDrafts[activeDrafts.length - 1].
|
2340
|
+
declaration: {
|
2341
|
+
...eventIndex.declaration,
|
2342
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2234
2343
|
}
|
2235
2344
|
};
|
2236
2345
|
}
|
2237
|
-
function
|
2346
|
+
function getAnnotationFromDrafts(drafts) {
|
2347
|
+
const actions = drafts.map((draft) => draft.action);
|
2348
|
+
const annotation = actions.reduce((ann, action) => {
|
2349
|
+
return deepMerge(ann, action.annotation ?? {});
|
2350
|
+
}, {});
|
2351
|
+
return deepDropNulls(annotation);
|
2352
|
+
}
|
2353
|
+
function getActionAnnotation({
|
2238
2354
|
event: event2,
|
2239
2355
|
actionType,
|
2240
2356
|
drafts
|
2241
2357
|
}) {
|
2242
|
-
const
|
2358
|
+
const activeActions = getAcceptedActions(event2);
|
2359
|
+
const action = activeActions.find(
|
2360
|
+
(activeAction) => actionType === activeAction.type
|
2361
|
+
);
|
2243
2362
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2244
2363
|
const sorted = [
|
2245
2364
|
...action ? [action] : [],
|
2246
2365
|
...eventDrafts.map((draft) => draft.action)
|
2247
2366
|
].sort();
|
2248
|
-
const
|
2249
|
-
return deepMerge(
|
2367
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2368
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2250
2369
|
}, {});
|
2251
|
-
return deepDropNulls(
|
2370
|
+
return deepDropNulls(annotation);
|
2252
2371
|
}
|
2253
2372
|
|
2254
2373
|
// ../commons/src/events/defineConfig.ts
|
2255
2374
|
var defineConfig = (config) => {
|
2256
2375
|
validateWorkqueueConfig(config.workqueues);
|
2257
2376
|
const input = EventConfig.parse(config);
|
2258
|
-
|
2259
|
-
return EventConfig.parse({
|
2260
|
-
...input,
|
2261
|
-
pageFields
|
2262
|
-
});
|
2377
|
+
return input;
|
2263
2378
|
};
|
2264
2379
|
|
2265
2380
|
// ../commons/src/events/transactions.ts
|
@@ -2274,6 +2389,16 @@ var import_lodash2 = require("lodash");
|
|
2274
2389
|
function defineConditional(schema) {
|
2275
2390
|
return schema;
|
2276
2391
|
}
|
2392
|
+
function defineFormConditional(schema) {
|
2393
|
+
const schemaWithForm = {
|
2394
|
+
type: "object",
|
2395
|
+
properties: {
|
2396
|
+
$form: schema
|
2397
|
+
},
|
2398
|
+
required: ["$form"]
|
2399
|
+
};
|
2400
|
+
return defineConditional(schemaWithForm);
|
2401
|
+
}
|
2277
2402
|
function alwaysTrue() {
|
2278
2403
|
return {};
|
2279
2404
|
}
|
@@ -2298,6 +2423,9 @@ function not(condition) {
|
|
2298
2423
|
required: []
|
2299
2424
|
});
|
2300
2425
|
}
|
2426
|
+
function never() {
|
2427
|
+
return not(alwaysTrue());
|
2428
|
+
}
|
2301
2429
|
var user = {
|
2302
2430
|
hasScope: (scope) => defineConditional({
|
2303
2431
|
type: "object",
|
@@ -2345,69 +2473,120 @@ var event = {
|
|
2345
2473
|
required: ["$event"]
|
2346
2474
|
})
|
2347
2475
|
};
|
2476
|
+
function getDateFromNow(days) {
|
2477
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2478
|
+
}
|
2479
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2480
|
+
return {
|
2481
|
+
type: "object",
|
2482
|
+
properties: {
|
2483
|
+
[fieldId]: {
|
2484
|
+
type: "string",
|
2485
|
+
format: "date",
|
2486
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2487
|
+
},
|
2488
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2489
|
+
},
|
2490
|
+
required: [fieldId]
|
2491
|
+
};
|
2492
|
+
}
|
2493
|
+
function isFieldReference(value) {
|
2494
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2495
|
+
}
|
2348
2496
|
function field(fieldId) {
|
2349
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2350
2497
|
const getDateRange = (date, clause) => ({
|
2351
2498
|
type: "object",
|
2352
2499
|
properties: {
|
2353
|
-
|
2354
|
-
type: "
|
2355
|
-
|
2356
|
-
|
2357
|
-
type: "string",
|
2358
|
-
format: "date",
|
2359
|
-
[clause]: date
|
2360
|
-
}
|
2361
|
-
},
|
2362
|
-
required: [fieldId]
|
2500
|
+
[fieldId]: {
|
2501
|
+
type: "string",
|
2502
|
+
format: "date",
|
2503
|
+
[clause]: date
|
2363
2504
|
}
|
2364
2505
|
},
|
2365
|
-
required: [
|
2506
|
+
required: [fieldId]
|
2366
2507
|
});
|
2367
2508
|
return {
|
2509
|
+
/**
|
2510
|
+
* @private Internal property used for field reference tracking.
|
2511
|
+
*/
|
2512
|
+
_fieldId: fieldId,
|
2368
2513
|
isAfter: () => ({
|
2369
2514
|
days: (days) => ({
|
2370
|
-
inPast: () =>
|
2515
|
+
inPast: () => defineFormConditional(
|
2371
2516
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2372
2517
|
),
|
2373
|
-
inFuture: () =>
|
2518
|
+
inFuture: () => defineFormConditional(
|
2374
2519
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2375
2520
|
)
|
2376
2521
|
}),
|
2377
|
-
date: (date) =>
|
2378
|
-
|
2522
|
+
date: (date) => {
|
2523
|
+
if (isFieldReference(date)) {
|
2524
|
+
const comparedFieldId = date._fieldId;
|
2525
|
+
return defineFormConditional(
|
2526
|
+
getDateRangeToFieldReference(
|
2527
|
+
fieldId,
|
2528
|
+
comparedFieldId,
|
2529
|
+
"formatMinimum"
|
2530
|
+
)
|
2531
|
+
);
|
2532
|
+
}
|
2533
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2534
|
+
},
|
2535
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2379
2536
|
}),
|
2380
2537
|
isBefore: () => ({
|
2381
2538
|
days: (days) => ({
|
2382
|
-
inPast: () =>
|
2539
|
+
inPast: () => defineFormConditional(
|
2383
2540
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2384
2541
|
),
|
2385
|
-
inFuture: () =>
|
2542
|
+
inFuture: () => defineFormConditional(
|
2386
2543
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2387
2544
|
)
|
2388
2545
|
}),
|
2389
|
-
date: (date) =>
|
2390
|
-
|
2546
|
+
date: (date) => {
|
2547
|
+
if (isFieldReference(date)) {
|
2548
|
+
const comparedFieldId = date._fieldId;
|
2549
|
+
return defineFormConditional(
|
2550
|
+
getDateRangeToFieldReference(
|
2551
|
+
fieldId,
|
2552
|
+
comparedFieldId,
|
2553
|
+
"formatMaximum"
|
2554
|
+
)
|
2555
|
+
);
|
2556
|
+
}
|
2557
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2558
|
+
},
|
2559
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2391
2560
|
}),
|
2392
|
-
isEqualTo: (value) =>
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2561
|
+
isEqualTo: (value) => {
|
2562
|
+
if (isFieldReference(value)) {
|
2563
|
+
const comparedFieldId = value._fieldId;
|
2564
|
+
return defineFormConditional({
|
2396
2565
|
type: "object",
|
2397
2566
|
properties: {
|
2398
2567
|
[fieldId]: {
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
const: value
|
2404
|
-
}
|
2568
|
+
type: ["string", "boolean"],
|
2569
|
+
const: { $data: `1/${comparedFieldId}` }
|
2570
|
+
},
|
2571
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2405
2572
|
},
|
2406
|
-
required: [fieldId]
|
2407
|
-
}
|
2408
|
-
}
|
2409
|
-
|
2410
|
-
|
2573
|
+
required: [fieldId, comparedFieldId]
|
2574
|
+
});
|
2575
|
+
}
|
2576
|
+
return defineFormConditional({
|
2577
|
+
type: "object",
|
2578
|
+
properties: {
|
2579
|
+
[fieldId]: {
|
2580
|
+
oneOf: [
|
2581
|
+
{ type: "string", const: value },
|
2582
|
+
{ type: "boolean", const: value }
|
2583
|
+
],
|
2584
|
+
const: value
|
2585
|
+
}
|
2586
|
+
},
|
2587
|
+
required: [fieldId]
|
2588
|
+
});
|
2589
|
+
},
|
2411
2590
|
/**
|
2412
2591
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2413
2592
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2416,108 +2595,102 @@ function field(fieldId) {
|
|
2416
2595
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2417
2596
|
*
|
2418
2597
|
*/
|
2419
|
-
isFalsy: () =>
|
2598
|
+
isFalsy: () => defineFormConditional({
|
2420
2599
|
type: "object",
|
2421
2600
|
properties: {
|
2422
|
-
|
2423
|
-
type: "object",
|
2424
|
-
properties: {
|
2425
|
-
[fieldId]: {
|
2426
|
-
anyOf: [
|
2427
|
-
{ const: "undefined" },
|
2428
|
-
{ const: false },
|
2429
|
-
{ const: null },
|
2430
|
-
{ const: "" }
|
2431
|
-
]
|
2432
|
-
}
|
2433
|
-
},
|
2601
|
+
[fieldId]: {
|
2434
2602
|
anyOf: [
|
2435
|
-
{
|
2436
|
-
|
2437
|
-
},
|
2438
|
-
{
|
2439
|
-
not: {
|
2440
|
-
required: [fieldId]
|
2441
|
-
}
|
2442
|
-
}
|
2603
|
+
{ const: "undefined" },
|
2604
|
+
{ const: false },
|
2605
|
+
{ const: null },
|
2606
|
+
{ const: "" }
|
2443
2607
|
]
|
2444
2608
|
}
|
2445
2609
|
},
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
$form: {
|
2452
|
-
type: "object",
|
2453
|
-
properties: {
|
2454
|
-
[fieldId]: {
|
2455
|
-
type: "string",
|
2456
|
-
enum: ["undefined"]
|
2457
|
-
}
|
2458
|
-
},
|
2610
|
+
anyOf: [
|
2611
|
+
{
|
2612
|
+
required: [fieldId]
|
2613
|
+
},
|
2614
|
+
{
|
2459
2615
|
not: {
|
2460
2616
|
required: [fieldId]
|
2461
2617
|
}
|
2462
2618
|
}
|
2619
|
+
]
|
2620
|
+
}),
|
2621
|
+
isUndefined: () => defineFormConditional({
|
2622
|
+
type: "object",
|
2623
|
+
properties: {
|
2624
|
+
[fieldId]: {
|
2625
|
+
type: "string",
|
2626
|
+
enum: ["undefined"]
|
2627
|
+
}
|
2463
2628
|
},
|
2464
|
-
|
2629
|
+
not: {
|
2630
|
+
required: [fieldId]
|
2631
|
+
}
|
2465
2632
|
}),
|
2466
|
-
inArray: (values) =>
|
2633
|
+
inArray: (values) => defineFormConditional({
|
2467
2634
|
type: "object",
|
2468
2635
|
properties: {
|
2469
|
-
|
2470
|
-
type: "
|
2471
|
-
|
2472
|
-
[fieldId]: {
|
2473
|
-
type: "string",
|
2474
|
-
enum: values
|
2475
|
-
}
|
2476
|
-
},
|
2477
|
-
required: [fieldId]
|
2636
|
+
[fieldId]: {
|
2637
|
+
type: "string",
|
2638
|
+
enum: values
|
2478
2639
|
}
|
2479
2640
|
},
|
2480
|
-
required: [
|
2641
|
+
required: [fieldId]
|
2481
2642
|
}),
|
2482
|
-
isValidEnglishName: () =>
|
2643
|
+
isValidEnglishName: () => defineFormConditional({
|
2483
2644
|
type: "object",
|
2484
2645
|
properties: {
|
2485
|
-
|
2486
|
-
type: "
|
2487
|
-
|
2488
|
-
|
2489
|
-
|
2490
|
-
|
2491
|
-
|
2492
|
-
|
2493
|
-
|
2494
|
-
|
2646
|
+
[fieldId]: {
|
2647
|
+
type: "string",
|
2648
|
+
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'._-]*)*$",
|
2649
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2650
|
+
}
|
2651
|
+
},
|
2652
|
+
required: [fieldId]
|
2653
|
+
}),
|
2654
|
+
/**
|
2655
|
+
* Checks if the field value matches a given regular expression pattern.
|
2656
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2657
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2658
|
+
*/
|
2659
|
+
matches: (pattern) => defineFormConditional({
|
2660
|
+
type: "object",
|
2661
|
+
properties: {
|
2662
|
+
[fieldId]: {
|
2663
|
+
type: "string",
|
2664
|
+
pattern
|
2665
|
+
}
|
2666
|
+
},
|
2667
|
+
required: [fieldId]
|
2668
|
+
}),
|
2669
|
+
isBetween: (min, max) => defineFormConditional({
|
2670
|
+
type: "object",
|
2671
|
+
properties: {
|
2672
|
+
[fieldId]: {
|
2673
|
+
type: "number",
|
2674
|
+
minimum: min,
|
2675
|
+
maximum: max
|
2495
2676
|
}
|
2496
2677
|
},
|
2497
|
-
required: [
|
2678
|
+
required: [fieldId]
|
2498
2679
|
})
|
2499
2680
|
};
|
2500
2681
|
}
|
2501
2682
|
|
2502
2683
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2503
|
-
var PRINT_CERTIFICATE_FORM =
|
2684
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2504
2685
|
label: {
|
2505
2686
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2506
2687
|
defaultMessage: "Tennis club membership certificate collector",
|
2507
2688
|
description: "This is what this form is referred as in the system"
|
2508
2689
|
},
|
2509
|
-
version: {
|
2510
|
-
id: "1.0.0",
|
2511
|
-
label: {
|
2512
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2513
|
-
defaultMessage: "Version 1",
|
2514
|
-
description: "This is the first version of the form"
|
2515
|
-
}
|
2516
|
-
},
|
2517
|
-
active: true,
|
2518
2690
|
pages: [
|
2519
2691
|
{
|
2520
2692
|
id: "collector",
|
2693
|
+
type: PageTypes.enum.FORM,
|
2521
2694
|
title: {
|
2522
2695
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2523
2696
|
defaultMessage: "Print certified copy",
|
@@ -2532,7 +2705,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2532
2705
|
defaultMessage: "Requester",
|
2533
2706
|
description: "This is the label for the field"
|
2534
2707
|
},
|
2535
|
-
type:
|
2708
|
+
type: FieldType.SELECT,
|
2536
2709
|
options: [
|
2537
2710
|
{
|
2538
2711
|
value: "INFORMANT",
|
@@ -2609,7 +2782,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2609
2782
|
defaultMessage: "Select Type of ID",
|
2610
2783
|
description: "This is the label for selecting the type of ID"
|
2611
2784
|
},
|
2612
|
-
type:
|
2785
|
+
type: FieldType.SELECT,
|
2613
2786
|
options: [
|
2614
2787
|
{
|
2615
2788
|
value: "PASSPORT",
|
@@ -2710,7 +2883,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2710
2883
|
defaultMessage: "Passport Details",
|
2711
2884
|
description: "Field for entering Passport details"
|
2712
2885
|
},
|
2713
|
-
type:
|
2886
|
+
type: FieldType.TEXT
|
2714
2887
|
},
|
2715
2888
|
{
|
2716
2889
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2761,7 +2934,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2761
2934
|
defaultMessage: "Driving License Details",
|
2762
2935
|
description: "Field for entering Driving License details"
|
2763
2936
|
},
|
2764
|
-
type:
|
2937
|
+
type: FieldType.TEXT
|
2765
2938
|
},
|
2766
2939
|
{
|
2767
2940
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2812,7 +2985,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2812
2985
|
defaultMessage: "Refugee Number Details",
|
2813
2986
|
description: "Field for entering Refugee Number details"
|
2814
2987
|
},
|
2815
|
-
type:
|
2988
|
+
type: FieldType.TEXT
|
2816
2989
|
},
|
2817
2990
|
{
|
2818
2991
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2863,7 +3036,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2863
3036
|
defaultMessage: "Alien Number Details",
|
2864
3037
|
description: "Field for entering Alien Number details"
|
2865
3038
|
},
|
2866
|
-
type:
|
3039
|
+
type: FieldType.TEXT
|
2867
3040
|
},
|
2868
3041
|
{
|
2869
3042
|
id: "collector.OTHER.idTypeOther",
|
@@ -2914,7 +3087,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2914
3087
|
defaultMessage: "Other ID Type (if applicable)",
|
2915
3088
|
description: 'Field for entering ID type if "Other" is selected'
|
2916
3089
|
},
|
2917
|
-
type:
|
3090
|
+
type: FieldType.TEXT
|
2918
3091
|
},
|
2919
3092
|
{
|
2920
3093
|
id: "collector.OTHER.firstName",
|
@@ -2965,7 +3138,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2965
3138
|
defaultMessage: "First Name",
|
2966
3139
|
description: "This is the label for the first name field"
|
2967
3140
|
},
|
2968
|
-
type:
|
3141
|
+
type: FieldType.TEXT
|
2969
3142
|
},
|
2970
3143
|
{
|
2971
3144
|
id: "collector.OTHER.lastName",
|
@@ -3016,7 +3189,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3016
3189
|
defaultMessage: "Last Name",
|
3017
3190
|
description: "This is the label for the last name field"
|
3018
3191
|
},
|
3019
|
-
type:
|
3192
|
+
type: FieldType.TEXT
|
3020
3193
|
},
|
3021
3194
|
{
|
3022
3195
|
id: "collector.OTHER.relationshipToMember",
|
@@ -3067,7 +3240,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3067
3240
|
defaultMessage: "Relationship to Member",
|
3068
3241
|
description: "This is the label for the relationship to member field"
|
3069
3242
|
},
|
3070
|
-
type:
|
3243
|
+
type: FieldType.TEXT
|
3071
3244
|
},
|
3072
3245
|
{
|
3073
3246
|
id: "collector.OTHER.signedAffidavit",
|
@@ -3118,13 +3291,13 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3118
3291
|
defaultMessage: "Signed Affidavit (Optional)",
|
3119
3292
|
description: "This is the label for uploading a signed affidavit"
|
3120
3293
|
},
|
3121
|
-
type:
|
3294
|
+
type: FieldType.FILE
|
3122
3295
|
}
|
3123
3296
|
]
|
3124
3297
|
},
|
3125
3298
|
{
|
3126
3299
|
id: "collector.identity.verify",
|
3127
|
-
type:
|
3300
|
+
type: PageTypes.enum.VERIFICATION,
|
3128
3301
|
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3129
3302
|
title: {
|
3130
3303
|
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
@@ -3161,62 +3334,45 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3161
3334
|
}
|
3162
3335
|
}
|
3163
3336
|
}
|
3164
|
-
]
|
3165
|
-
review: {
|
3166
|
-
title: {
|
3167
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
3168
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
3169
|
-
description: "Title of the form to show in review page"
|
3170
|
-
},
|
3171
|
-
fields: []
|
3172
|
-
}
|
3337
|
+
]
|
3173
3338
|
});
|
3174
|
-
var
|
3175
|
-
|
3176
|
-
id: "v2.event.tennis-club-membership.action.declare.form.
|
3177
|
-
defaultMessage: "
|
3178
|
-
description: "
|
3179
|
-
},
|
3180
|
-
active: true,
|
3181
|
-
version: {
|
3182
|
-
id: "1.0.0",
|
3183
|
-
label: {
|
3184
|
-
id: "v2.event.tennis-club-membership.action.declare.form.version.1",
|
3185
|
-
defaultMessage: "Version 1",
|
3186
|
-
description: "This is the first version of the form"
|
3187
|
-
}
|
3339
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3340
|
+
title: {
|
3341
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3342
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3343
|
+
description: "Title of the review page"
|
3188
3344
|
},
|
3189
|
-
|
3190
|
-
|
3191
|
-
id: "
|
3192
|
-
|
3193
|
-
|
3345
|
+
fields: [
|
3346
|
+
{
|
3347
|
+
id: "review.comment",
|
3348
|
+
type: FieldType.TEXTAREA,
|
3349
|
+
label: {
|
3350
|
+
defaultMessage: "Comment",
|
3351
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3352
|
+
description: "Label for the comment field in the review section"
|
3353
|
+
}
|
3194
3354
|
},
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
description: "Label for the comment field in the review section"
|
3203
|
-
}
|
3355
|
+
{
|
3356
|
+
type: FieldType.SIGNATURE,
|
3357
|
+
id: "review.signature",
|
3358
|
+
label: {
|
3359
|
+
defaultMessage: "Signature of informant",
|
3360
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3361
|
+
description: "Label for the signature field in the review section"
|
3204
3362
|
},
|
3205
|
-
{
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
defaultMessage: "Signature of informant",
|
3210
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3211
|
-
description: "Label for the signature field in the review section"
|
3212
|
-
},
|
3213
|
-
signaturePromptLabel: {
|
3214
|
-
id: "v2.signature.upload.modal.title",
|
3215
|
-
defaultMessage: "Draw signature",
|
3216
|
-
description: "Title for the modal to draw signature"
|
3217
|
-
}
|
3363
|
+
signaturePromptLabel: {
|
3364
|
+
id: "v2.signature.upload.modal.title",
|
3365
|
+
defaultMessage: "Draw signature",
|
3366
|
+
description: "Title for the modal to draw signature"
|
3218
3367
|
}
|
3219
|
-
|
3368
|
+
}
|
3369
|
+
]
|
3370
|
+
};
|
3371
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3372
|
+
label: {
|
3373
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3374
|
+
defaultMessage: "Tennis club membership application",
|
3375
|
+
description: "This is what this form is referred as in the system"
|
3220
3376
|
},
|
3221
3377
|
pages: [
|
3222
3378
|
{
|
@@ -3229,7 +3385,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3229
3385
|
fields: [
|
3230
3386
|
{
|
3231
3387
|
id: "applicant.firstname",
|
3232
|
-
type:
|
3388
|
+
type: FieldType.TEXT,
|
3233
3389
|
required: true,
|
3234
3390
|
conditionals: [],
|
3235
3391
|
label: {
|
@@ -3240,7 +3396,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3240
3396
|
},
|
3241
3397
|
{
|
3242
3398
|
id: "applicant.surname",
|
3243
|
-
type:
|
3399
|
+
type: FieldType.TEXT,
|
3244
3400
|
required: true,
|
3245
3401
|
conditionals: [],
|
3246
3402
|
label: {
|
@@ -3262,9 +3418,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3262
3418
|
},
|
3263
3419
|
{
|
3264
3420
|
id: "applicant.dob",
|
3265
|
-
type:
|
3421
|
+
type: FieldType.DATE,
|
3266
3422
|
required: true,
|
3267
|
-
conditionals: [],
|
3268
3423
|
validation: [
|
3269
3424
|
{
|
3270
3425
|
message: {
|
@@ -3275,15 +3430,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3275
3430
|
validator: field("applicant.dob").isBefore().now()
|
3276
3431
|
}
|
3277
3432
|
],
|
3433
|
+
conditionals: [
|
3434
|
+
{
|
3435
|
+
type: ConditionalType.SHOW,
|
3436
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3437
|
+
}
|
3438
|
+
],
|
3278
3439
|
label: {
|
3279
3440
|
defaultMessage: "Applicant's date of birth",
|
3280
3441
|
description: "This is the label for the field",
|
3281
3442
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3282
3443
|
}
|
3283
3444
|
},
|
3445
|
+
{
|
3446
|
+
id: "applicant.dobUnknown",
|
3447
|
+
type: FieldType.CHECKBOX,
|
3448
|
+
required: false,
|
3449
|
+
label: {
|
3450
|
+
defaultMessage: "Exact date of birth unknown",
|
3451
|
+
description: "This is the label for the field",
|
3452
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3453
|
+
},
|
3454
|
+
conditionals: [
|
3455
|
+
{
|
3456
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3457
|
+
conditional: never()
|
3458
|
+
}
|
3459
|
+
]
|
3460
|
+
},
|
3461
|
+
{
|
3462
|
+
id: "applicant.age",
|
3463
|
+
type: FieldType.NUMBER,
|
3464
|
+
required: true,
|
3465
|
+
label: {
|
3466
|
+
defaultMessage: "Age of tennis-member",
|
3467
|
+
description: "This is the label for the field",
|
3468
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3469
|
+
},
|
3470
|
+
conditionals: [
|
3471
|
+
{
|
3472
|
+
type: ConditionalType.SHOW,
|
3473
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3474
|
+
}
|
3475
|
+
]
|
3476
|
+
},
|
3284
3477
|
{
|
3285
3478
|
id: "applicant.image",
|
3286
|
-
type:
|
3479
|
+
type: FieldType.FILE,
|
3287
3480
|
required: false,
|
3288
3481
|
label: {
|
3289
3482
|
defaultMessage: "Applicant's profile picture",
|
@@ -3315,7 +3508,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3315
3508
|
fields: [
|
3316
3509
|
{
|
3317
3510
|
id: "senior-pass.id",
|
3318
|
-
type:
|
3511
|
+
type: FieldType.TEXT,
|
3319
3512
|
required: true,
|
3320
3513
|
label: {
|
3321
3514
|
defaultMessage: "Senior pass ID",
|
@@ -3346,7 +3539,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3346
3539
|
},
|
3347
3540
|
{
|
3348
3541
|
id: "recommender.firstname",
|
3349
|
-
type:
|
3542
|
+
type: FieldType.TEXT,
|
3350
3543
|
required: true,
|
3351
3544
|
conditionals: [
|
3352
3545
|
{
|
@@ -3362,7 +3555,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3362
3555
|
},
|
3363
3556
|
{
|
3364
3557
|
id: "recommender.surname",
|
3365
|
-
type:
|
3558
|
+
type: FieldType.TEXT,
|
3366
3559
|
required: true,
|
3367
3560
|
conditionals: [
|
3368
3561
|
{
|
@@ -3378,7 +3571,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3378
3571
|
},
|
3379
3572
|
{
|
3380
3573
|
id: "recommender.id",
|
3381
|
-
type:
|
3574
|
+
type: FieldType.TEXT,
|
3382
3575
|
required: true,
|
3383
3576
|
conditionals: [
|
3384
3577
|
{
|
@@ -3486,7 +3679,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3486
3679
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3487
3680
|
id: "event.tennis-club-membership.action.declare.label"
|
3488
3681
|
},
|
3489
|
-
|
3682
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3490
3683
|
},
|
3491
3684
|
{
|
3492
3685
|
type: ActionType.VALIDATE,
|
@@ -3495,7 +3688,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3495
3688
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3496
3689
|
id: "event.tennis-club-membership.action.validate.label"
|
3497
3690
|
},
|
3498
|
-
|
3691
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3499
3692
|
},
|
3500
3693
|
{
|
3501
3694
|
type: ActionType.REGISTER,
|
@@ -3504,7 +3697,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3504
3697
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3505
3698
|
id: "event.tennis-club-membership.action.register.label"
|
3506
3699
|
},
|
3507
|
-
|
3700
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3508
3701
|
},
|
3509
3702
|
{
|
3510
3703
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3513,10 +3706,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3513
3706
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3514
3707
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3515
3708
|
},
|
3516
|
-
forms: [TENNIS_CLUB_FORM],
|
3517
3709
|
onboardingForm: [
|
3518
3710
|
{
|
3519
3711
|
id: "correction-requester",
|
3712
|
+
type: PageTypes.enum.FORM,
|
3520
3713
|
title: {
|
3521
3714
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3522
3715
|
defaultMessage: "Correction requester",
|
@@ -3580,6 +3773,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3580
3773
|
},
|
3581
3774
|
{
|
3582
3775
|
id: "identity-check",
|
3776
|
+
type: PageTypes.enum.FORM,
|
3583
3777
|
title: {
|
3584
3778
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3585
3779
|
defaultMessage: "Verify their identity",
|
@@ -3622,6 +3816,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3622
3816
|
additionalDetailsForm: [
|
3623
3817
|
{
|
3624
3818
|
id: "correction-request.supporting-documents",
|
3819
|
+
type: PageTypes.enum.FORM,
|
3625
3820
|
title: {
|
3626
3821
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3627
3822
|
defaultMessage: "Upload supporting documents",
|
@@ -3639,7 +3834,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3639
3834
|
},
|
3640
3835
|
{
|
3641
3836
|
id: "correction.supportingDocs",
|
3642
|
-
type:
|
3837
|
+
type: FieldType.FILE,
|
3643
3838
|
label: {
|
3644
3839
|
id: "correction.corrector.title",
|
3645
3840
|
defaultMessage: "Upload supporting documents",
|
@@ -3683,6 +3878,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3683
3878
|
},
|
3684
3879
|
{
|
3685
3880
|
id: "correction-request.additional-details",
|
3881
|
+
type: PageTypes.enum.FORM,
|
3686
3882
|
title: {
|
3687
3883
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3688
3884
|
defaultMessage: "Reason for correction",
|
@@ -3691,7 +3887,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3691
3887
|
fields: [
|
3692
3888
|
{
|
3693
3889
|
id: "correction.request.reason",
|
3694
|
-
type:
|
3890
|
+
type: FieldType.TEXT,
|
3695
3891
|
label: {
|
3696
3892
|
id: "correction.reason.title",
|
3697
3893
|
defaultMessage: "Reason for correction?",
|
@@ -3704,7 +3900,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3704
3900
|
},
|
3705
3901
|
{
|
3706
3902
|
type: ActionType.APPROVE_CORRECTION,
|
3707
|
-
forms: [TENNIS_CLUB_FORM],
|
3708
3903
|
label: {
|
3709
3904
|
defaultMessage: "Approve correction",
|
3710
3905
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3718,7 +3913,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3718
3913
|
defaultMessage: "Print certificate",
|
3719
3914
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3720
3915
|
},
|
3721
|
-
|
3916
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3722
3917
|
conditionals: [
|
3723
3918
|
{
|
3724
3919
|
type: "SHOW",
|
@@ -3765,8 +3960,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3765
3960
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3766
3961
|
defaultMessage: "Archive",
|
3767
3962
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3768
|
-
}
|
3769
|
-
forms: [TENNIS_CLUB_FORM]
|
3963
|
+
}
|
3770
3964
|
},
|
3771
3965
|
{
|
3772
3966
|
type: ActionType.REJECT,
|
@@ -3774,8 +3968,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3774
3968
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3775
3969
|
defaultMessage: "Reject",
|
3776
3970
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3777
|
-
}
|
3778
|
-
forms: [TENNIS_CLUB_FORM]
|
3971
|
+
}
|
3779
3972
|
}
|
3780
3973
|
],
|
3781
3974
|
advancedSearch: [
|
@@ -3791,33 +3984,53 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3791
3984
|
}
|
3792
3985
|
]
|
3793
3986
|
}
|
3794
|
-
]
|
3987
|
+
],
|
3988
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3795
3989
|
});
|
3796
3990
|
|
3797
3991
|
// ../commons/src/events/test.utils.ts
|
3798
|
-
function
|
3799
|
-
|
3800
|
-
const data = fields.reduce(
|
3992
|
+
function fieldConfigsToActionPayload(fields) {
|
3993
|
+
return fields.reduce(
|
3801
3994
|
(acc, field2, i) => ({
|
3802
3995
|
...acc,
|
3803
3996
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3804
3997
|
}),
|
3805
3998
|
{}
|
3806
3999
|
);
|
3807
|
-
return stripHiddenFields(fields, data);
|
3808
4000
|
}
|
3809
|
-
function
|
3810
|
-
const
|
4001
|
+
function generateActionDeclarationInput(configuration, action) {
|
4002
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
4003
|
+
if (parsed.success) {
|
4004
|
+
const fields = getDeclarationFields(configuration);
|
4005
|
+
const declarationConfig = getDeclaration(configuration);
|
4006
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4007
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
4008
|
+
}
|
4009
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
4010
|
+
return {};
|
4011
|
+
}
|
4012
|
+
function generateActionAnnotationInput(configuration, action) {
|
4013
|
+
const actionConfig = configuration.actions.find(
|
4014
|
+
(ac) => ac.type === action
|
4015
|
+
);
|
4016
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4017
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4018
|
+
const visibleVerificationPageIds = findRecordActionPages(
|
3811
4019
|
configuration,
|
3812
4020
|
action
|
3813
|
-
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page,
|
3814
|
-
|
4021
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
4022
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3815
4023
|
(acc, pageId) => ({
|
3816
4024
|
...acc,
|
3817
4025
|
[pageId]: true
|
3818
4026
|
}),
|
3819
4027
|
{}
|
3820
4028
|
);
|
4029
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4030
|
+
return {
|
4031
|
+
...fieldBasedPayload,
|
4032
|
+
...visiblePageVerificationMap
|
4033
|
+
};
|
3821
4034
|
}
|
3822
4035
|
var eventPayloadGenerator = {
|
3823
4036
|
create: (input = {}) => ({
|
@@ -3829,21 +4042,22 @@ var eventPayloadGenerator = {
|
|
3829
4042
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3830
4043
|
id
|
3831
4044
|
}),
|
3832
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4045
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3833
4046
|
{
|
3834
4047
|
id: getUUID(),
|
3835
4048
|
eventId,
|
3836
4049
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3837
4050
|
transactionId: getUUID(),
|
3838
4051
|
action: {
|
3839
|
-
type:
|
3840
|
-
|
4052
|
+
type: actionType,
|
4053
|
+
status: ActionStatus.Accepted,
|
4054
|
+
declaration: {
|
3841
4055
|
"applicant.firstname": "Max",
|
3842
4056
|
"applicant.surname": "McLaren",
|
3843
4057
|
"applicant.dob": "2020-01-02",
|
3844
4058
|
"recommender.none": true
|
3845
4059
|
},
|
3846
|
-
|
4060
|
+
annotation: {
|
3847
4061
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3848
4062
|
"correction.request.reason": "Child's name was incorrect"
|
3849
4063
|
},
|
@@ -3858,45 +4072,104 @@ var eventPayloadGenerator = {
|
|
3858
4072
|
declare: (eventId, input = {}) => ({
|
3859
4073
|
type: ActionType.DECLARE,
|
3860
4074
|
transactionId: input.transactionId ?? getUUID(),
|
3861
|
-
|
4075
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4076
|
+
tennisClubMembershipEvent,
|
4077
|
+
ActionType.DECLARE
|
4078
|
+
),
|
4079
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4080
|
+
tennisClubMembershipEvent,
|
4081
|
+
ActionType.DECLARE
|
4082
|
+
),
|
3862
4083
|
eventId
|
3863
4084
|
}),
|
4085
|
+
/**
|
4086
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4087
|
+
*/
|
4088
|
+
notify: (eventId, input = {}) => {
|
4089
|
+
let declaration = input.declaration;
|
4090
|
+
if (!declaration) {
|
4091
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4092
|
+
generateActionDeclarationInput(
|
4093
|
+
tennisClubMembershipEvent,
|
4094
|
+
ActionType.DECLARE
|
4095
|
+
),
|
4096
|
+
import_lodash2.isString
|
4097
|
+
);
|
4098
|
+
declaration = partialDeclaration;
|
4099
|
+
}
|
4100
|
+
return {
|
4101
|
+
type: ActionType.NOTIFY,
|
4102
|
+
transactionId: input.transactionId ?? getUUID(),
|
4103
|
+
declaration,
|
4104
|
+
eventId
|
4105
|
+
};
|
4106
|
+
},
|
3864
4107
|
validate: (eventId, input = {}) => ({
|
3865
4108
|
type: ActionType.VALIDATE,
|
3866
4109
|
transactionId: input.transactionId ?? getUUID(),
|
3867
|
-
|
4110
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4111
|
+
tennisClubMembershipEvent,
|
4112
|
+
ActionType.VALIDATE
|
4113
|
+
),
|
4114
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4115
|
+
tennisClubMembershipEvent,
|
4116
|
+
ActionType.VALIDATE
|
4117
|
+
),
|
3868
4118
|
duplicates: [],
|
3869
4119
|
eventId
|
3870
4120
|
}),
|
4121
|
+
assign: (eventId, input = {}) => ({
|
4122
|
+
type: ActionType.ASSIGN,
|
4123
|
+
transactionId: input.transactionId ?? getUUID(),
|
4124
|
+
declaration: {},
|
4125
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4126
|
+
eventId
|
4127
|
+
}),
|
4128
|
+
unassign: (eventId, input = {}) => ({
|
4129
|
+
type: ActionType.UNASSIGN,
|
4130
|
+
transactionId: input.transactionId ?? getUUID(),
|
4131
|
+
declaration: {},
|
4132
|
+
assignedTo: null,
|
4133
|
+
eventId
|
4134
|
+
}),
|
3871
4135
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3872
4136
|
type: ActionType.ARCHIVE,
|
3873
4137
|
transactionId: input.transactionId ?? getUUID(),
|
3874
|
-
|
3875
|
-
|
4138
|
+
declaration: {},
|
4139
|
+
// @TODO: Check whether generator is needed?
|
4140
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3876
4141
|
duplicates: [],
|
3877
4142
|
eventId
|
3878
4143
|
}),
|
3879
4144
|
reject: (eventId, input = {}) => ({
|
3880
4145
|
type: ActionType.REJECT,
|
3881
4146
|
transactionId: input.transactionId ?? getUUID(),
|
3882
|
-
|
4147
|
+
declaration: {},
|
4148
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4149
|
+
tennisClubMembershipEvent,
|
4150
|
+
ActionType.REJECT
|
4151
|
+
),
|
3883
4152
|
duplicates: [],
|
3884
4153
|
eventId
|
3885
4154
|
}),
|
3886
4155
|
register: (eventId, input = {}) => ({
|
3887
4156
|
type: ActionType.REGISTER,
|
3888
4157
|
transactionId: input.transactionId ?? getUUID(),
|
3889
|
-
|
4158
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4159
|
+
tennisClubMembershipEvent,
|
4160
|
+
ActionType.REGISTER
|
4161
|
+
),
|
4162
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4163
|
+
tennisClubMembershipEvent,
|
4164
|
+
ActionType.REGISTER
|
4165
|
+
),
|
3890
4166
|
eventId
|
3891
4167
|
}),
|
3892
4168
|
printCertificate: (eventId, input = {}) => ({
|
3893
4169
|
type: ActionType.PRINT_CERTIFICATE,
|
3894
4170
|
transactionId: input.transactionId ?? getUUID(),
|
3895
|
-
|
3896
|
-
|
3897
|
-
ActionType.PRINT_CERTIFICATE
|
3898
|
-
),
|
3899
|
-
metadata: input.metadata ?? generateActionMetadataInput(
|
4171
|
+
declaration: {},
|
4172
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3900
4173
|
tennisClubMembershipEvent,
|
3901
4174
|
ActionType.PRINT_CERTIFICATE
|
3902
4175
|
),
|
@@ -3906,17 +4179,21 @@ var eventPayloadGenerator = {
|
|
3906
4179
|
request: (eventId, input = {}) => ({
|
3907
4180
|
type: ActionType.REQUEST_CORRECTION,
|
3908
4181
|
transactionId: input.transactionId ?? getUUID(),
|
3909
|
-
|
4182
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4183
|
+
tennisClubMembershipEvent,
|
4184
|
+
ActionType.REQUEST_CORRECTION
|
4185
|
+
),
|
4186
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3910
4187
|
tennisClubMembershipEvent,
|
3911
4188
|
ActionType.REQUEST_CORRECTION
|
3912
4189
|
),
|
3913
|
-
metadata: {},
|
3914
4190
|
eventId
|
3915
4191
|
}),
|
3916
4192
|
approve: (eventId, requestId, input = {}) => ({
|
3917
4193
|
type: ActionType.APPROVE_CORRECTION,
|
3918
4194
|
transactionId: input.transactionId ?? getUUID(),
|
3919
|
-
|
4195
|
+
declaration: {},
|
4196
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3920
4197
|
tennisClubMembershipEvent,
|
3921
4198
|
ActionType.APPROVE_CORRECTION
|
3922
4199
|
),
|
@@ -3926,7 +4203,8 @@ var eventPayloadGenerator = {
|
|
3926
4203
|
reject: (eventId, requestId, input = {}) => ({
|
3927
4204
|
type: ActionType.REJECT_CORRECTION,
|
3928
4205
|
transactionId: input.transactionId ?? getUUID(),
|
3929
|
-
|
4206
|
+
declaration: {},
|
4207
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3930
4208
|
tennisClubMembershipEvent,
|
3931
4209
|
ActionType.REJECT_CORRECTION
|
3932
4210
|
),
|
@@ -3948,15 +4226,20 @@ function generateActionDocument({
|
|
3948
4226
|
createdBy: getUUID(),
|
3949
4227
|
id: getUUID(),
|
3950
4228
|
createdAtLocation: "TODO",
|
3951
|
-
|
3952
|
-
|
3953
|
-
...defaults
|
4229
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4230
|
+
annotation: {},
|
4231
|
+
...defaults,
|
4232
|
+
status: ActionStatus.Accepted
|
3954
4233
|
};
|
3955
4234
|
switch (action) {
|
4235
|
+
case ActionType.READ:
|
4236
|
+
return { ...actionBase, type: action };
|
4237
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4238
|
+
return { ...actionBase, type: action };
|
3956
4239
|
case ActionType.DECLARE:
|
3957
4240
|
return { ...actionBase, type: action };
|
3958
4241
|
case ActionType.UNASSIGN:
|
3959
|
-
return { ...actionBase, type: action };
|
4242
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3960
4243
|
case ActionType.ASSIGN:
|
3961
4244
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3962
4245
|
case ActionType.VALIDATE:
|
@@ -3977,14 +4260,13 @@ function generateActionDocument({
|
|
3977
4260
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3978
4261
|
case ActionType.REJECT_CORRECTION:
|
3979
4262
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3980
|
-
case ActionType.CUSTOM:
|
3981
|
-
return { ...actionBase, type: action };
|
3982
4263
|
case ActionType.REGISTER:
|
3983
4264
|
return {
|
3984
4265
|
...actionBase,
|
3985
|
-
type: action
|
3986
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4266
|
+
type: action
|
3987
4267
|
};
|
4268
|
+
case ActionType.DELETE:
|
4269
|
+
case ActionType.DETECT_DUPLICATE:
|
3988
4270
|
default:
|
3989
4271
|
throw new Error(`Unsupported action type: ${action}`);
|
3990
4272
|
}
|
@@ -4008,7 +4290,7 @@ function generateEventDocument({
|
|
4008
4290
|
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4009
4291
|
};
|
4010
4292
|
}
|
4011
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4293
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
4012
4294
|
const action = generateActionDocument({
|
4013
4295
|
configuration: tennisClubMembershipEvent,
|
4014
4296
|
action: actionType
|
@@ -4018,9 +4300,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
4018
4300
|
transactionId: getUUID(),
|
4019
4301
|
action: {
|
4020
4302
|
...action,
|
4021
|
-
|
4022
|
-
...action.
|
4023
|
-
...
|
4303
|
+
declaration: {
|
4304
|
+
...action.declaration,
|
4305
|
+
...declaration
|
4024
4306
|
}
|
4025
4307
|
},
|
4026
4308
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -4037,7 +4319,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4037
4319
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4038
4320
|
assignedTo: overrides.assignedTo ?? null,
|
4039
4321
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4040
|
-
|
4322
|
+
declaration: overrides.declaration ?? {
|
4041
4323
|
"recommender.none": true,
|
4042
4324
|
"applicant.firstname": "Danny",
|
4043
4325
|
"applicant.surname": "Doe",
|
@@ -4068,7 +4350,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
4068
4350
|
return true;
|
4069
4351
|
}
|
4070
4352
|
function isFieldConfigDefaultValue(value) {
|
4071
|
-
if (!value)
|
4353
|
+
if (!value) {
|
4354
|
+
return false;
|
4355
|
+
}
|
4072
4356
|
if (isFieldValue(value)) {
|
4073
4357
|
return true;
|
4074
4358
|
}
|