@opencrvs/toolkit 1.8.0-rc.f9911ed → 1.8.0-rc.f9b51fa
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 +6105 -14020
- 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 +1255 -6456
- package/dist/commons/events/ActionDocument.d.ts +7344 -244
- package/dist/commons/events/ActionInput.d.ts +2129 -392
- package/dist/commons/events/ActionType.d.ts +26 -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 +614 -2837
- package/dist/commons/events/EventConfigInput.d.ts +5 -2
- package/dist/commons/events/EventDocument.d.ts +700 -304
- 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 +520 -273
- 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 +34 -411
- 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 +86 -153
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +161 -93
- package/dist/events/index.js +1155 -818
- package/dist/scopes/index.d.ts +70 -1
- package/dist/scopes/index.js +130 -0
- 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,20 +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,
|
108
|
+
ReadActionInput: () => ReadActionInput,
|
109
|
+
RegisterAction: () => RegisterAction,
|
94
110
|
RegisterActionInput: () => RegisterActionInput,
|
95
111
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
96
112
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -103,23 +119,29 @@ __export(events_exports, {
|
|
103
119
|
SummaryConfig: () => SummaryConfig,
|
104
120
|
TextValue: () => TextValue,
|
105
121
|
TranslationConfig: () => TranslationConfig,
|
122
|
+
UnassignActionInput: () => UnassignActionInput,
|
106
123
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
107
124
|
UrbanAddressValue: () => UrbanAddressValue,
|
108
125
|
ValidateActionInput: () => ValidateActionInput,
|
109
|
-
|
126
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
110
127
|
VerificationPageConfig: () => VerificationPageConfig,
|
111
128
|
WorkqueueConfig: () => WorkqueueConfig,
|
112
129
|
alwaysTrue: () => alwaysTrue,
|
113
130
|
and: () => and,
|
131
|
+
annotationActions: () => annotationActions,
|
114
132
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
115
133
|
compositeFieldTypes: () => compositeFieldTypes,
|
116
134
|
createEmptyDraft: () => createEmptyDraft,
|
117
135
|
createValidationSchema: () => createValidationSchema,
|
118
136
|
deepDropNulls: () => deepDropNulls,
|
137
|
+
deepMerge: () => deepMerge,
|
138
|
+
defineActionForm: () => defineActionForm,
|
119
139
|
defineConditional: () => defineConditional,
|
120
140
|
defineConfig: () => defineConfig,
|
121
|
-
|
141
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
142
|
+
defineFormConditional: () => defineFormConditional,
|
122
143
|
defineFormPage: () => defineFormPage,
|
144
|
+
definePage: () => definePage,
|
123
145
|
errorMessages: () => errorMessages,
|
124
146
|
event: () => event,
|
125
147
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -128,31 +150,30 @@ __export(events_exports, {
|
|
128
150
|
eventStatuses: () => eventStatuses,
|
129
151
|
field: () => field,
|
130
152
|
fieldTypes: () => fieldTypes,
|
131
|
-
findActiveActionFields: () => findActiveActionFields,
|
132
|
-
findActiveActionForm: () => findActiveActionForm,
|
133
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
134
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
135
|
-
findActiveActionVerificationPageIds: () => findActiveActionVerificationPageIds,
|
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
177
|
isAddressFieldType: () => isAddressFieldType,
|
157
178
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
158
179
|
isBulletListFieldType: () => isBulletListFieldType,
|
@@ -164,6 +185,7 @@ __export(events_exports, {
|
|
164
185
|
isEmailFieldType: () => isEmailFieldType,
|
165
186
|
isFacilityFieldType: () => isFacilityFieldType,
|
166
187
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
188
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
167
189
|
isFieldEnabled: () => isFieldEnabled,
|
168
190
|
isFieldValue: () => isFieldValue,
|
169
191
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -174,6 +196,7 @@ __export(events_exports, {
|
|
174
196
|
isNumberFieldType: () => isNumberFieldType,
|
175
197
|
isOfficeFieldType: () => isOfficeFieldType,
|
176
198
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
199
|
+
isPageVisible: () => isPageVisible,
|
177
200
|
isParagraphFieldType: () => isParagraphFieldType,
|
178
201
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
179
202
|
isSelectFieldType: () => isSelectFieldType,
|
@@ -182,50 +205,71 @@ __export(events_exports, {
|
|
182
205
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
183
206
|
isTextFieldType: () => isTextFieldType,
|
184
207
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
208
|
+
isVerificationPage: () => isVerificationPage,
|
209
|
+
isWriteAction: () => isWriteAction,
|
185
210
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
186
211
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
187
212
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
213
|
+
never: () => never,
|
188
214
|
not: () => not,
|
215
|
+
omitHiddenFields: () => omitHiddenFields,
|
216
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
189
217
|
or: () => or,
|
190
|
-
resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
|
191
|
-
stripHiddenFields: () => stripHiddenFields,
|
192
218
|
user: () => user,
|
193
219
|
validate: () => validate,
|
194
220
|
validateFieldInput: () => validateFieldInput,
|
195
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
221
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
222
|
+
writeActions: () => writeActions
|
196
223
|
});
|
197
224
|
module.exports = __toCommonJS(events_exports);
|
198
225
|
|
199
226
|
// ../commons/src/events/ActionConfig.ts
|
200
|
-
var
|
227
|
+
var import_zod9 = require("zod");
|
201
228
|
|
202
229
|
// ../commons/src/events/Conditional.ts
|
203
230
|
var import_zod = require("zod");
|
204
|
-
|
205
|
-
|
206
|
-
|
231
|
+
var Conditional = import_zod.z.custom(
|
232
|
+
(val) => typeof val === "object" && val !== null
|
233
|
+
);
|
207
234
|
var ConditionalType = {
|
208
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
209
235
|
SHOW: "SHOW",
|
210
|
-
|
211
|
-
|
236
|
+
ENABLE: "ENABLE",
|
237
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
212
238
|
};
|
213
239
|
var ShowConditional = import_zod.z.object({
|
214
240
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
215
|
-
conditional: Conditional
|
216
|
-
})
|
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
|
+
);
|
217
245
|
var EnableConditional = import_zod.z.object({
|
218
246
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
219
|
-
conditional: Conditional
|
220
|
-
})
|
247
|
+
conditional: Conditional
|
248
|
+
}).describe(
|
249
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
250
|
+
);
|
221
251
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
222
252
|
// Action can be shown / hidden
|
223
253
|
ShowConditional,
|
224
254
|
// Action can be shown to the user in the list but as disabled
|
225
255
|
EnableConditional
|
226
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
|
+
]);
|
227
271
|
|
228
|
-
// ../commons/src/events/
|
272
|
+
// ../commons/src/events/PageConfig.ts
|
229
273
|
var import_zod6 = require("zod");
|
230
274
|
|
231
275
|
// ../commons/src/events/FieldConfig.ts
|
@@ -411,14 +455,14 @@ var BaseField = import_zod5.z.object({
|
|
411
455
|
]),
|
412
456
|
DependencyExpression
|
413
457
|
]).optional(),
|
414
|
-
conditionals: import_zod5.z.array(
|
458
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
415
459
|
required: import_zod5.z.boolean().default(false).optional(),
|
416
460
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
417
461
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
418
462
|
placeholder: TranslationConfig.optional(),
|
419
463
|
validation: import_zod5.z.array(
|
420
464
|
import_zod5.z.object({
|
421
|
-
validator: Conditional
|
465
|
+
validator: Conditional,
|
422
466
|
message: TranslationConfig
|
423
467
|
})
|
424
468
|
).default([]).optional(),
|
@@ -577,7 +621,7 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
577
621
|
]);
|
578
622
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
579
623
|
partOf: import_zod5.z.object({
|
580
|
-
$
|
624
|
+
$declaration: import_zod5.z.string()
|
581
625
|
}).optional().describe("Parent location"),
|
582
626
|
type: AdministrativeAreas
|
583
627
|
}).describe("Administrative area options");
|
@@ -612,11 +656,20 @@ var Address = BaseField.extend({
|
|
612
656
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
613
657
|
defaultValue: AddressFieldValue.optional()
|
614
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
|
+
]);
|
615
668
|
var DataField = BaseField.extend({
|
616
669
|
type: import_zod5.z.literal(FieldType.DATA),
|
617
670
|
configuration: import_zod5.z.object({
|
618
671
|
subtitle: TranslationConfig.optional(),
|
619
|
-
data: import_zod5.z.array(
|
672
|
+
data: import_zod5.z.array(DataEntry)
|
620
673
|
})
|
621
674
|
}).describe("Data field for displaying read-only data");
|
622
675
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
@@ -642,20 +695,23 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
642
695
|
EmailField,
|
643
696
|
FileUploadWithOptions,
|
644
697
|
DataField
|
698
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
645
699
|
]);
|
646
700
|
|
647
|
-
// ../commons/src/events/
|
648
|
-
var
|
649
|
-
|
650
|
-
VERIFICATION: "VERIFICATION"
|
651
|
-
};
|
652
|
-
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({
|
653
704
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
654
705
|
title: TranslationConfig.describe("Header title of the page"),
|
655
706
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
656
|
-
|
707
|
+
conditional: Conditional.optional().describe(
|
708
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
709
|
+
)
|
710
|
+
});
|
711
|
+
var FormPageConfig = PageConfigBase.extend({
|
712
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
657
713
|
});
|
658
|
-
var
|
714
|
+
var VerificationActionConfig = import_zod6.z.object({
|
659
715
|
verify: import_zod6.z.object({ label: TranslationConfig }),
|
660
716
|
cancel: import_zod6.z.object({
|
661
717
|
label: TranslationConfig,
|
@@ -665,136 +721,182 @@ var VerificationPageConfig = import_zod6.z.object({
|
|
665
721
|
})
|
666
722
|
})
|
667
723
|
}).describe("Actions available on the verification page");
|
668
|
-
var
|
669
|
-
type: import_zod6.z.literal(
|
670
|
-
actions:
|
671
|
-
});
|
672
|
-
var FormPageConfig = import_zod6.z.preprocess(
|
673
|
-
(pageConfig) => ({
|
674
|
-
...pageConfig,
|
675
|
-
type: pageConfig.type ?? FormPageType.FORM
|
676
|
-
// Default type to "FORM" if not provided
|
677
|
-
}),
|
678
|
-
import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
|
679
|
-
);
|
680
|
-
var FormConfig = import_zod6.z.object({
|
681
|
-
label: TranslationConfig.describe("Human readable description of the form"),
|
682
|
-
version: import_zod6.z.object({
|
683
|
-
id: import_zod6.z.string().describe(
|
684
|
-
"Form version. Semantic versioning recommended. Example: 0.0.1"
|
685
|
-
),
|
686
|
-
label: TranslationConfig.describe(
|
687
|
-
"Human readable description of the version"
|
688
|
-
)
|
689
|
-
}),
|
690
|
-
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
691
|
-
pages: import_zod6.z.array(FormPageConfig),
|
692
|
-
review: import_zod6.z.object({
|
693
|
-
title: TranslationConfig.describe(
|
694
|
-
"Title of the form to show in review page"
|
695
|
-
),
|
696
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
697
|
-
})
|
724
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
725
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
726
|
+
actions: VerificationActionConfig
|
698
727
|
});
|
728
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
729
|
+
FormPageConfig,
|
730
|
+
VerificationPageConfig
|
731
|
+
]);
|
699
732
|
|
700
733
|
// ../commons/src/events/ActionType.ts
|
734
|
+
var import_zod7 = require("zod");
|
701
735
|
var ActionType = {
|
736
|
+
// Pre-declaration actions
|
737
|
+
DELETE: "DELETE",
|
702
738
|
CREATE: "CREATE",
|
703
|
-
ASSIGN: "ASSIGN",
|
704
|
-
UNASSIGN: "UNASSIGN",
|
705
|
-
REGISTER: "REGISTER",
|
706
|
-
VALIDATE: "VALIDATE",
|
707
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
708
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
709
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
710
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
711
739
|
NOTIFY: "NOTIFY",
|
740
|
+
// Declaration actions
|
712
741
|
DECLARE: "DECLARE",
|
713
|
-
|
714
|
-
|
715
|
-
|
742
|
+
VALIDATE: "VALIDATE",
|
743
|
+
REGISTER: "REGISTER",
|
744
|
+
// Declaration system actions. Non-configurable.
|
745
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
716
746
|
REJECT: "REJECT",
|
747
|
+
// REJECT_DECLARATION
|
717
748
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
718
|
-
|
749
|
+
// MARK_AS_DUPLICATE
|
750
|
+
ARCHIVE: "ARCHIVE",
|
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"
|
719
760
|
};
|
720
|
-
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]);
|
721
821
|
|
722
822
|
// ../commons/src/events/ActionConfig.ts
|
723
|
-
var ActionConditional2 =
|
823
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
724
824
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
725
825
|
ShowConditional,
|
726
826
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
727
827
|
EnableConditional
|
728
828
|
]);
|
729
|
-
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({
|
730
834
|
label: TranslationConfig,
|
731
|
-
conditionals:
|
732
|
-
draft:
|
733
|
-
forms: import_zod7.z.array(FormConfig)
|
835
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
836
|
+
draft: import_zod9.z.boolean().optional()
|
734
837
|
});
|
735
838
|
var DeclareConfig = ActionConfigBase.merge(
|
736
|
-
|
737
|
-
type:
|
839
|
+
import_zod9.z.object({
|
840
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
841
|
+
review: DeclarationReviewConfig
|
738
842
|
})
|
739
843
|
);
|
740
844
|
var ValidateConfig = ActionConfigBase.merge(
|
741
|
-
|
742
|
-
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
|
743
854
|
})
|
744
855
|
);
|
745
856
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
746
|
-
|
747
|
-
type:
|
857
|
+
import_zod9.z.object({
|
858
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
748
859
|
})
|
749
860
|
);
|
750
861
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
751
|
-
|
752
|
-
type:
|
862
|
+
import_zod9.z.object({
|
863
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
753
864
|
})
|
754
865
|
);
|
755
866
|
var ArchiveConfig = ActionConfigBase.merge(
|
756
|
-
|
757
|
-
type:
|
758
|
-
})
|
759
|
-
);
|
760
|
-
var RegisterConfig = ActionConfigBase.merge(
|
761
|
-
import_zod7.z.object({
|
762
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
867
|
+
import_zod9.z.object({
|
868
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
763
869
|
})
|
764
870
|
);
|
765
871
|
var DeleteConfig = ActionConfigBase.merge(
|
766
|
-
|
767
|
-
type:
|
872
|
+
import_zod9.z.object({
|
873
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
768
874
|
})
|
769
875
|
);
|
770
876
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
771
|
-
|
772
|
-
type:
|
877
|
+
import_zod9.z.object({
|
878
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
879
|
+
printForm: ActionFormConfig
|
773
880
|
})
|
774
881
|
);
|
775
882
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
776
|
-
|
777
|
-
type:
|
778
|
-
onboardingForm:
|
779
|
-
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)
|
780
887
|
})
|
781
888
|
);
|
782
889
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
783
|
-
|
784
|
-
type:
|
890
|
+
import_zod9.z.object({
|
891
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
785
892
|
})
|
786
893
|
);
|
787
894
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
788
|
-
|
789
|
-
type:
|
790
|
-
})
|
791
|
-
);
|
792
|
-
var CustomConfig = ActionConfigBase.merge(
|
793
|
-
import_zod7.z.object({
|
794
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
895
|
+
import_zod9.z.object({
|
896
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
795
897
|
})
|
796
898
|
);
|
797
|
-
var ActionConfig =
|
899
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
798
900
|
DeclareConfig,
|
799
901
|
ValidateConfig,
|
800
902
|
RejectDeclarationConfig,
|
@@ -805,102 +907,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
805
907
|
PrintCertificateActionConfig,
|
806
908
|
RequestCorrectionConfig,
|
807
909
|
RejectCorrectionConfig,
|
808
|
-
ApproveCorrectionConfig
|
809
|
-
|
910
|
+
ApproveCorrectionConfig
|
911
|
+
]);
|
912
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
913
|
+
DeclareConfig,
|
914
|
+
ValidateConfig,
|
915
|
+
RegisterConfig
|
810
916
|
]);
|
811
917
|
|
812
918
|
// ../commons/src/events/offline/CertificateConfig.ts
|
813
|
-
var
|
814
|
-
var FontFamily =
|
815
|
-
normal:
|
816
|
-
bold:
|
817
|
-
italics:
|
818
|
-
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()
|
819
925
|
});
|
820
|
-
var CertificateConfig =
|
821
|
-
id:
|
822
|
-
event:
|
926
|
+
var CertificateConfig = import_zod10.z.object({
|
927
|
+
id: import_zod10.z.string(),
|
928
|
+
event: import_zod10.z.string(),
|
823
929
|
label: TranslationConfig,
|
824
|
-
isDefault:
|
825
|
-
fee:
|
826
|
-
onTime:
|
827
|
-
late:
|
828
|
-
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()
|
829
935
|
}),
|
830
|
-
svgUrl:
|
831
|
-
fonts:
|
936
|
+
svgUrl: import_zod10.z.string(),
|
937
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
832
938
|
});
|
833
939
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
834
|
-
hash:
|
835
|
-
svg:
|
940
|
+
hash: import_zod10.z.string().optional(),
|
941
|
+
svg: import_zod10.z.string()
|
836
942
|
});
|
837
943
|
|
838
944
|
// ../commons/src/events/offline/LanguageConfig.ts
|
839
|
-
var
|
840
|
-
var LanguageConfig =
|
841
|
-
lang:
|
945
|
+
var import_zod11 = require("zod");
|
946
|
+
var LanguageConfig = import_zod11.z.object({
|
947
|
+
lang: import_zod11.z.string(),
|
842
948
|
/**
|
843
949
|
* client.csv contents
|
844
950
|
*/
|
845
|
-
messages:
|
951
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
846
952
|
});
|
847
953
|
|
848
954
|
// ../commons/src/events/EventConfig.ts
|
849
|
-
var
|
955
|
+
var import_zod20 = require("zod");
|
850
956
|
|
851
957
|
// ../commons/src/events/DeduplicationConfig.ts
|
852
|
-
var
|
853
|
-
var FieldReference =
|
854
|
-
var Matcher =
|
855
|
-
fieldId:
|
856
|
-
options:
|
857
|
-
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()
|
858
964
|
}).optional().default({})
|
859
965
|
});
|
860
966
|
var FuzzyMatcher = Matcher.extend({
|
861
|
-
type:
|
862
|
-
options:
|
967
|
+
type: import_zod12.z.literal("fuzzy"),
|
968
|
+
options: import_zod12.z.object({
|
863
969
|
/**
|
864
970
|
* Names of length 3 or less characters = 0 edits allowed
|
865
971
|
* Names of length 4 - 6 characters = 1 edit allowed
|
866
972
|
* Names of length >7 characters = 2 edits allowed
|
867
973
|
*/
|
868
|
-
fuzziness:
|
869
|
-
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)
|
870
976
|
}).optional().default({})
|
871
977
|
});
|
872
978
|
var StrictMatcher = Matcher.extend({
|
873
|
-
type:
|
874
|
-
options:
|
875
|
-
boost:
|
979
|
+
type: import_zod12.z.literal("strict"),
|
980
|
+
options: import_zod12.z.object({
|
981
|
+
boost: import_zod12.z.number().optional().default(1)
|
876
982
|
}).optional().default({})
|
877
983
|
});
|
878
984
|
var DateRangeMatcher = Matcher.extend({
|
879
|
-
type:
|
880
|
-
options:
|
881
|
-
days:
|
985
|
+
type: import_zod12.z.literal("dateRange"),
|
986
|
+
options: import_zod12.z.object({
|
987
|
+
days: import_zod12.z.number(),
|
882
988
|
origin: FieldReference,
|
883
|
-
boost:
|
989
|
+
boost: import_zod12.z.number().optional().default(1)
|
884
990
|
})
|
885
991
|
});
|
886
992
|
var DateDistanceMatcher = Matcher.extend({
|
887
|
-
type:
|
888
|
-
options:
|
889
|
-
days:
|
993
|
+
type: import_zod12.z.literal("dateDistance"),
|
994
|
+
options: import_zod12.z.object({
|
995
|
+
days: import_zod12.z.number(),
|
890
996
|
origin: FieldReference,
|
891
|
-
boost:
|
997
|
+
boost: import_zod12.z.number().optional().default(1)
|
892
998
|
})
|
893
999
|
});
|
894
|
-
var And =
|
895
|
-
type:
|
896
|
-
|
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())
|
897
1004
|
});
|
898
|
-
var Or =
|
899
|
-
type:
|
900
|
-
|
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())
|
901
1009
|
});
|
902
|
-
var Clause =
|
903
|
-
() =>
|
1010
|
+
var Clause = import_zod12.z.lazy(
|
1011
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
904
1012
|
And,
|
905
1013
|
Or,
|
906
1014
|
FuzzyMatcher,
|
@@ -909,37 +1017,37 @@ var Clause = import_zod10.z.lazy(
|
|
909
1017
|
DateDistanceMatcher
|
910
1018
|
])
|
911
1019
|
);
|
912
|
-
var DeduplicationConfig =
|
913
|
-
id:
|
1020
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1021
|
+
id: import_zod12.z.string(),
|
914
1022
|
label: TranslationConfig,
|
915
1023
|
query: Clause
|
916
1024
|
});
|
917
1025
|
|
918
1026
|
// ../commons/src/events/SummaryConfig.ts
|
919
|
-
var
|
920
|
-
var Field =
|
921
|
-
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"),
|
922
1030
|
value: TranslationConfig.describe(
|
923
1031
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
924
1032
|
),
|
925
1033
|
label: TranslationConfig,
|
926
1034
|
emptyValueMessage: TranslationConfig.optional()
|
927
1035
|
});
|
928
|
-
var Title =
|
929
|
-
id:
|
1036
|
+
var Title = import_zod13.z.object({
|
1037
|
+
id: import_zod13.z.string(),
|
930
1038
|
label: TranslationConfig.describe("Title content"),
|
931
1039
|
emptyValueMessage: TranslationConfig.optional()
|
932
1040
|
});
|
933
|
-
var SummaryConfig =
|
1041
|
+
var SummaryConfig = import_zod13.z.object({
|
934
1042
|
title: Title.describe("Title of summary view."),
|
935
|
-
fields:
|
1043
|
+
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
936
1044
|
}).describe("Configuration for summary in event.");
|
937
1045
|
|
938
1046
|
// ../commons/src/events/WorkqueueConfig.ts
|
939
|
-
var
|
1047
|
+
var import_zod15 = require("zod");
|
940
1048
|
|
941
1049
|
// ../commons/src/events/EventMetadata.ts
|
942
|
-
var
|
1050
|
+
var import_zod14 = require("zod");
|
943
1051
|
var EventStatus = {
|
944
1052
|
CREATED: "CREATED",
|
945
1053
|
NOTIFIED: "NOTIFIED",
|
@@ -951,18 +1059,19 @@ var EventStatus = {
|
|
951
1059
|
ARCHIVED: "ARCHIVED"
|
952
1060
|
};
|
953
1061
|
var eventStatuses = Object.values(EventStatus);
|
954
|
-
var EventStatuses =
|
955
|
-
var EventMetadata =
|
956
|
-
id:
|
957
|
-
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(),
|
958
1066
|
status: EventStatuses,
|
959
|
-
createdAt:
|
960
|
-
createdBy:
|
961
|
-
createdAtLocation:
|
962
|
-
modifiedAt:
|
963
|
-
assignedTo:
|
964
|
-
updatedBy:
|
965
|
-
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()
|
966
1075
|
});
|
967
1076
|
var eventMetadataLabelMap = {
|
968
1077
|
"event.assignedTo": {
|
@@ -1014,28 +1123,33 @@ var eventMetadataLabelMap = {
|
|
1014
1123
|
id: "event.trackingId.label",
|
1015
1124
|
defaultMessage: "Tracking ID",
|
1016
1125
|
description: "Tracking ID"
|
1126
|
+
},
|
1127
|
+
"event.registrationNumber": {
|
1128
|
+
id: "event.registrationNumber.label",
|
1129
|
+
defaultMessage: "Registration Number",
|
1130
|
+
description: "Registration Number"
|
1017
1131
|
}
|
1018
1132
|
};
|
1019
1133
|
|
1020
1134
|
// ../commons/src/events/WorkqueueConfig.ts
|
1021
|
-
var WorkqueueConfig =
|
1022
|
-
id:
|
1023
|
-
filters:
|
1024
|
-
|
1025
|
-
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.")
|
1026
1140
|
})
|
1027
1141
|
).describe("Filters to be applied to workqueue.")
|
1028
1142
|
}).describe("Configuration for workqueue.");
|
1029
1143
|
|
1030
1144
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1031
|
-
var
|
1032
|
-
var AdvancedSearchConfig =
|
1145
|
+
var import_zod16 = require("zod");
|
1146
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
1033
1147
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1034
|
-
fields:
|
1035
|
-
|
1036
|
-
fieldId:
|
1037
|
-
config:
|
1038
|
-
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")
|
1039
1153
|
}).optional().describe("Configuration options for the field")
|
1040
1154
|
})
|
1041
1155
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -1045,12 +1159,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1045
1159
|
var import_lodash = require("lodash");
|
1046
1160
|
|
1047
1161
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1048
|
-
var
|
1162
|
+
var import_zod18 = require("zod");
|
1049
1163
|
|
1050
1164
|
// ../commons/src/workqueues/defaultColumns.ts
|
1051
|
-
var
|
1052
|
-
var WorkQueueColumnConfig =
|
1053
|
-
id:
|
1165
|
+
var import_zod17 = require("zod");
|
1166
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1167
|
+
id: import_zod17.z.string(),
|
1054
1168
|
label: TranslationConfig
|
1055
1169
|
});
|
1056
1170
|
var defaultColumns = {
|
@@ -1087,16 +1201,16 @@ var defaultColumns = {
|
|
1087
1201
|
}
|
1088
1202
|
}
|
1089
1203
|
};
|
1090
|
-
var DefaultColumnKeys =
|
1204
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
1091
1205
|
Object.keys(defaultColumns)
|
1092
1206
|
);
|
1093
1207
|
|
1094
1208
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1095
|
-
var rootWorkqueueConfig =
|
1096
|
-
id:
|
1209
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1210
|
+
id: import_zod18.z.string(),
|
1097
1211
|
title: TranslationConfig,
|
1098
|
-
columns:
|
1099
|
-
defaultColumns:
|
1212
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1213
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1100
1214
|
});
|
1101
1215
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1102
1216
|
|
@@ -1176,7 +1290,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1176
1290
|
var import_date_fns = require("date-fns");
|
1177
1291
|
|
1178
1292
|
// ../commons/src/events/FieldTypeMapping.ts
|
1179
|
-
var
|
1293
|
+
var import_zod19 = require("zod");
|
1180
1294
|
function mapFieldTypeToZod(type, required) {
|
1181
1295
|
let schema;
|
1182
1296
|
switch (type) {
|
@@ -1229,7 +1343,7 @@ function createValidationSchema(config) {
|
|
1229
1343
|
for (const field2 of config) {
|
1230
1344
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1231
1345
|
}
|
1232
|
-
return
|
1346
|
+
return import_zod19.z.object(shape);
|
1233
1347
|
}
|
1234
1348
|
function mapFieldTypeToMockValue(field2, i) {
|
1235
1349
|
switch (field2.type) {
|
@@ -1396,7 +1510,8 @@ var isDataFieldType = (field2) => {
|
|
1396
1510
|
|
1397
1511
|
// ../commons/src/conditionals/validate.ts
|
1398
1512
|
var ajv = new import_ajv.default({
|
1399
|
-
$data: true
|
1513
|
+
$data: true,
|
1514
|
+
allowUnionTypes: true
|
1400
1515
|
});
|
1401
1516
|
(0, import_ajv_formats.default)(ajv);
|
1402
1517
|
function validate(schema, data) {
|
@@ -1429,6 +1544,9 @@ function isFieldVisible(field2, form) {
|
|
1429
1544
|
function isFieldEnabled(field2, form) {
|
1430
1545
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1431
1546
|
}
|
1547
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1548
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1549
|
+
}
|
1432
1550
|
var errorMessages = {
|
1433
1551
|
hiddenField: {
|
1434
1552
|
id: "v2.error.hidden",
|
@@ -1456,12 +1574,14 @@ var errorMessages = {
|
|
1456
1574
|
id: "v2.error.invalid"
|
1457
1575
|
}
|
1458
1576
|
};
|
1459
|
-
|
1460
|
-
|
1461
|
-
message
|
1462
|
-
|
1463
|
-
}
|
1464
|
-
|
1577
|
+
function createIntlError(message) {
|
1578
|
+
return {
|
1579
|
+
message: {
|
1580
|
+
message
|
1581
|
+
}
|
1582
|
+
};
|
1583
|
+
}
|
1584
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1465
1585
|
switch (issue.code) {
|
1466
1586
|
case "invalid_string": {
|
1467
1587
|
if (_ctx.data === "") {
|
@@ -1499,8 +1619,29 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1499
1619
|
}
|
1500
1620
|
}
|
1501
1621
|
return createIntlError(errorMessages.invalidInput);
|
1502
|
-
}
|
1503
|
-
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({
|
1504
1645
|
field: field2,
|
1505
1646
|
values
|
1506
1647
|
}) {
|
@@ -1508,6 +1649,23 @@ function getFieldValidationErrors({
|
|
1508
1649
|
$form: values,
|
1509
1650
|
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1510
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
|
+
}) {
|
1511
1669
|
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1512
1670
|
if (values[field2.id]) {
|
1513
1671
|
return {
|
@@ -1522,41 +1680,21 @@ function getFieldValidationErrors({
|
|
1522
1680
|
errors: []
|
1523
1681
|
};
|
1524
1682
|
}
|
1525
|
-
|
1683
|
+
return runFieldValidations({
|
1526
1684
|
field: field2,
|
1527
|
-
|
1685
|
+
values
|
1528
1686
|
});
|
1529
|
-
const customValidationResults = runCustomFieldValidations({
|
1530
|
-
field: field2,
|
1531
|
-
conditionalParameters
|
1532
|
-
});
|
1533
|
-
return {
|
1534
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1535
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1536
|
-
};
|
1537
1687
|
}
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
return (
|
1543
|
-
return !validate(validation.validator, conditionalParameters);
|
1544
|
-
}).map((validation) => ({ message: validation.message }));
|
1545
|
-
}
|
1546
|
-
function validateFieldInput({
|
1547
|
-
field: field2,
|
1548
|
-
value
|
1549
|
-
}) {
|
1550
|
-
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1551
|
-
value,
|
1552
|
-
{
|
1553
|
-
// @ts-expect-error
|
1554
|
-
errorMap: zodToIntlErrorMap
|
1555
|
-
}
|
1556
|
-
);
|
1557
|
-
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)();
|
1558
1693
|
}
|
1559
1694
|
|
1695
|
+
// ../commons/src/events/utils.ts
|
1696
|
+
var import_date_fns2 = require("date-fns");
|
1697
|
+
|
1560
1698
|
// ../commons/src/utils.ts
|
1561
1699
|
function getOrThrow(x, message) {
|
1562
1700
|
if (x === void 0 || x === null) {
|
@@ -1565,73 +1703,64 @@ function getOrThrow(x, message) {
|
|
1565
1703
|
return x;
|
1566
1704
|
}
|
1567
1705
|
|
1568
|
-
// ../commons/src/uuid.ts
|
1569
|
-
var import_uuid = require("uuid");
|
1570
|
-
function getUUID() {
|
1571
|
-
return (0, import_uuid.v4)();
|
1572
|
-
}
|
1573
|
-
|
1574
1706
|
// ../commons/src/events/utils.ts
|
1575
|
-
function
|
1576
|
-
return
|
1577
|
-
}
|
1578
|
-
|
1579
|
-
return (
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
);
|
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 [];
|
1602
1733
|
};
|
1603
|
-
var
|
1604
|
-
|
1605
|
-
refFields
|
1606
|
-
}) => {
|
1607
|
-
return refFields.map((field2) => {
|
1608
|
-
if (field2.label) {
|
1609
|
-
return field2;
|
1610
|
-
}
|
1611
|
-
if (isMetadataField(field2.id)) {
|
1612
|
-
return {
|
1613
|
-
...field2,
|
1614
|
-
label: eventMetadataLabelMap[field2.id]
|
1615
|
-
};
|
1616
|
-
}
|
1617
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1618
|
-
if (!pageLabel) {
|
1619
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1620
|
-
}
|
1621
|
-
return {
|
1622
|
-
...field2,
|
1623
|
-
label: pageLabel.label
|
1624
|
-
};
|
1625
|
-
});
|
1734
|
+
var getAllAnnotationFields = (config) => {
|
1735
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1626
1736
|
};
|
1627
|
-
|
1628
|
-
return
|
1629
|
-
...
|
1630
|
-
...
|
1737
|
+
var findAllFields = (config) => {
|
1738
|
+
return (0, import_lodash.flattenDeep)([
|
1739
|
+
...getDeclarationFields(config),
|
1740
|
+
...getAllAnnotationFields(config)
|
1631
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
|
+
);
|
1632
1761
|
}
|
1633
|
-
function
|
1634
|
-
return configuration
|
1762
|
+
function getActionReviewFields(configuration, actionType) {
|
1763
|
+
return getActionReview(configuration, actionType).fields;
|
1635
1764
|
}
|
1636
1765
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1637
1766
|
workqueueConfigs.map((workqueue) => {
|
@@ -1645,71 +1774,30 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1645
1774
|
}
|
1646
1775
|
});
|
1647
1776
|
}
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
return form;
|
1652
|
-
};
|
1653
|
-
var findActiveActionFormPages = (configuration, action) => {
|
1654
|
-
return findActiveActionForm(configuration, action)?.pages;
|
1655
|
-
};
|
1656
|
-
var getFormFields = (formConfig) => {
|
1657
|
-
return formConfig.pages.flatMap((p) => p.fields);
|
1658
|
-
};
|
1659
|
-
var findActiveActionFormFields = (configuration, action) => {
|
1660
|
-
const form = findActiveActionForm(configuration, action);
|
1661
|
-
return form ? getFormFields(form) : void 0;
|
1662
|
-
};
|
1663
|
-
var findActiveActionFields = (configuration, action) => {
|
1664
|
-
const form = findActiveActionForm(configuration, action);
|
1665
|
-
const reviewFields = form?.review.fields;
|
1666
|
-
const formFields = form ? getFormFields(form) : void 0;
|
1667
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1668
|
-
return allFields;
|
1669
|
-
};
|
1670
|
-
var getActiveActionFormPages = (configuration, action) => {
|
1671
|
-
return getOrThrow(
|
1672
|
-
findActiveActionForm(configuration, action)?.pages,
|
1673
|
-
"Form configuration not found for type: " + configuration.id
|
1674
|
-
);
|
1675
|
-
};
|
1676
|
-
function getActiveActionFields(configuration, action) {
|
1677
|
-
if (LatentActions.some((latentAction) => latentAction === action)) {
|
1678
|
-
return getActiveActionFields(configuration, ActionType.DECLARE);
|
1679
|
-
}
|
1680
|
-
const fields = findActiveActionFields(configuration, action);
|
1681
|
-
if (!fields) {
|
1682
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1683
|
-
}
|
1684
|
-
return fields;
|
1685
|
-
}
|
1686
|
-
function getEventConfiguration(eventConfigurations, type) {
|
1687
|
-
const config = eventConfigurations.find((config2) => config2.id === type);
|
1688
|
-
if (!config) {
|
1689
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1690
|
-
}
|
1691
|
-
return config;
|
1692
|
-
}
|
1693
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1694
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1695
|
-
return false;
|
1777
|
+
function isPageVisible(page, formValues) {
|
1778
|
+
if (!page.conditional) {
|
1779
|
+
return true;
|
1696
1780
|
}
|
1697
|
-
return
|
1781
|
+
return validate(page.conditional, {
|
1782
|
+
$form: formValues,
|
1783
|
+
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1784
|
+
});
|
1698
1785
|
}
|
1699
|
-
function
|
1700
|
-
return (0, import_lodash.omitBy)(
|
1786
|
+
function omitHiddenFields(fields, values) {
|
1787
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1701
1788
|
const field2 = fields.find((f) => f.id === fieldId);
|
1702
1789
|
if (!field2) {
|
1703
1790
|
return true;
|
1704
1791
|
}
|
1705
|
-
|
1706
|
-
return true;
|
1707
|
-
}
|
1708
|
-
return !isFieldVisible(field2, data);
|
1792
|
+
return !isFieldVisible(field2, values);
|
1709
1793
|
});
|
1710
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
|
+
}
|
1711
1799
|
function findActiveDrafts(event2, drafts) {
|
1712
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1800
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1713
1801
|
const lastAction = actions[actions.length - 1];
|
1714
1802
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1715
1803
|
}
|
@@ -1721,35 +1809,58 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1721
1809
|
transactionId: getUUID(),
|
1722
1810
|
action: {
|
1723
1811
|
type: actionType,
|
1724
|
-
|
1725
|
-
|
1812
|
+
declaration: {},
|
1813
|
+
annotation: {},
|
1726
1814
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1727
1815
|
createdBy: "@todo",
|
1728
1816
|
createdAtLocation: "@todo"
|
1729
1817
|
}
|
1730
1818
|
};
|
1731
1819
|
}
|
1732
|
-
function
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1820
|
+
function isVerificationPage(page) {
|
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;
|
1738
1848
|
}
|
1739
1849
|
|
1740
1850
|
// ../commons/src/events/EventConfig.ts
|
1741
|
-
var EventConfig =
|
1742
|
-
id:
|
1851
|
+
var EventConfig = import_zod20.z.object({
|
1852
|
+
id: import_zod20.z.string().describe(
|
1743
1853
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1744
1854
|
),
|
1745
1855
|
summary: SummaryConfig,
|
1746
1856
|
label: TranslationConfig,
|
1747
|
-
actions:
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
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([])
|
1751
1862
|
}).superRefine((event2, ctx) => {
|
1752
|
-
const allFields =
|
1863
|
+
const allFields = findAllFields(event2);
|
1753
1864
|
const fieldIds = allFields.map((field2) => field2.id);
|
1754
1865
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1755
1866
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1776,106 +1887,118 @@ var EventConfig = import_zod18.z.object({
|
|
1776
1887
|
});
|
1777
1888
|
|
1778
1889
|
// ../commons/src/events/EventConfigInput.ts
|
1779
|
-
var
|
1890
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1891
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1892
|
+
var definePage = (page) => PageConfig.parse(page);
|
1780
1893
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1781
1894
|
|
1782
1895
|
// ../commons/src/events/Draft.ts
|
1783
|
-
var
|
1896
|
+
var import_zod23 = require("zod");
|
1784
1897
|
|
1785
1898
|
// ../commons/src/events/ActionDocument.ts
|
1786
|
-
var
|
1787
|
-
var ActionUpdate =
|
1788
|
-
var
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
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()
|
1795
1920
|
});
|
1796
1921
|
var AssignedAction = ActionBase.merge(
|
1797
|
-
|
1798
|
-
type:
|
1799
|
-
assignedTo:
|
1922
|
+
import_zod21.z.object({
|
1923
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1924
|
+
assignedTo: import_zod21.z.string()
|
1800
1925
|
})
|
1801
1926
|
);
|
1802
1927
|
var UnassignedAction = ActionBase.merge(
|
1803
|
-
|
1804
|
-
type:
|
1928
|
+
import_zod21.z.object({
|
1929
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1930
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1805
1931
|
})
|
1806
1932
|
);
|
1807
1933
|
var RegisterAction = ActionBase.merge(
|
1808
|
-
|
1809
|
-
type:
|
1810
|
-
|
1811
|
-
trackingId: import_zod19.z.string(),
|
1812
|
-
registrationNumber: import_zod19.z.string()
|
1813
|
-
})
|
1934
|
+
import_zod21.z.object({
|
1935
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1936
|
+
registrationNumber: import_zod21.z.string().optional()
|
1814
1937
|
})
|
1815
1938
|
);
|
1816
1939
|
var DeclareAction = ActionBase.merge(
|
1817
|
-
|
1818
|
-
type:
|
1940
|
+
import_zod21.z.object({
|
1941
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1819
1942
|
})
|
1820
1943
|
);
|
1821
1944
|
var ValidateAction = ActionBase.merge(
|
1822
|
-
|
1823
|
-
type:
|
1945
|
+
import_zod21.z.object({
|
1946
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1824
1947
|
})
|
1825
1948
|
);
|
1826
1949
|
var RejectAction = ActionBase.merge(
|
1827
|
-
|
1828
|
-
type:
|
1950
|
+
import_zod21.z.object({
|
1951
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1829
1952
|
})
|
1830
1953
|
);
|
1831
1954
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1832
|
-
|
1833
|
-
type:
|
1955
|
+
import_zod21.z.object({
|
1956
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1834
1957
|
})
|
1835
1958
|
);
|
1836
1959
|
var ArchiveAction = ActionBase.merge(
|
1837
|
-
|
1838
|
-
type:
|
1960
|
+
import_zod21.z.object({
|
1961
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1839
1962
|
})
|
1840
1963
|
);
|
1841
1964
|
var CreatedAction = ActionBase.merge(
|
1842
|
-
|
1843
|
-
type:
|
1965
|
+
import_zod21.z.object({
|
1966
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1844
1967
|
})
|
1845
1968
|
);
|
1846
1969
|
var NotifiedAction = ActionBase.merge(
|
1847
|
-
|
1848
|
-
type:
|
1970
|
+
import_zod21.z.object({
|
1971
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1849
1972
|
})
|
1850
1973
|
);
|
1851
1974
|
var PrintCertificateAction = ActionBase.merge(
|
1852
|
-
|
1853
|
-
type:
|
1975
|
+
import_zod21.z.object({
|
1976
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1854
1977
|
})
|
1855
1978
|
);
|
1856
1979
|
var RequestedCorrectionAction = ActionBase.merge(
|
1857
|
-
|
1858
|
-
type:
|
1980
|
+
import_zod21.z.object({
|
1981
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1859
1982
|
})
|
1860
1983
|
);
|
1861
1984
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1862
|
-
|
1863
|
-
type:
|
1864
|
-
requestId:
|
1985
|
+
import_zod21.z.object({
|
1986
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1987
|
+
requestId: import_zod21.z.string()
|
1865
1988
|
})
|
1866
1989
|
);
|
1867
1990
|
var RejectedCorrectionAction = ActionBase.merge(
|
1868
|
-
|
1869
|
-
type:
|
1870
|
-
requestId:
|
1991
|
+
import_zod21.z.object({
|
1992
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1993
|
+
requestId: import_zod21.z.string()
|
1871
1994
|
})
|
1872
1995
|
);
|
1873
|
-
var
|
1874
|
-
|
1875
|
-
type:
|
1996
|
+
var ReadAction = ActionBase.merge(
|
1997
|
+
import_zod21.z.object({
|
1998
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1876
1999
|
})
|
1877
2000
|
);
|
1878
|
-
var ActionDocument =
|
2001
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1879
2002
|
CreatedAction,
|
1880
2003
|
ValidateAction,
|
1881
2004
|
RejectAction,
|
@@ -1890,108 +2013,125 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1890
2013
|
RejectedCorrectionAction,
|
1891
2014
|
UnassignedAction,
|
1892
2015
|
PrintCertificateAction,
|
1893
|
-
|
2016
|
+
ReadAction
|
1894
2017
|
]);
|
1895
|
-
var
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
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()
|
1903
2038
|
})
|
1904
2039
|
)
|
1905
2040
|
});
|
1906
2041
|
|
1907
2042
|
// ../commons/src/events/ActionInput.ts
|
1908
|
-
var
|
1909
|
-
var BaseActionInput =
|
1910
|
-
eventId:
|
1911
|
-
transactionId:
|
1912
|
-
|
1913
|
-
|
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()
|
1914
2051
|
});
|
1915
2052
|
var CreateActionInput = BaseActionInput.merge(
|
1916
|
-
|
1917
|
-
type:
|
1918
|
-
createdAtLocation:
|
2053
|
+
import_zod22.z.object({
|
2054
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2055
|
+
createdAtLocation: import_zod22.z.string()
|
1919
2056
|
})
|
1920
2057
|
);
|
1921
2058
|
var RegisterActionInput = BaseActionInput.merge(
|
1922
|
-
|
1923
|
-
type:
|
1924
|
-
|
1925
|
-
trackingId: import_zod20.z.string(),
|
1926
|
-
registrationNumber: import_zod20.z.string()
|
1927
|
-
})
|
2059
|
+
import_zod22.z.object({
|
2060
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2061
|
+
registrationNumber: import_zod22.z.string().optional()
|
1928
2062
|
})
|
1929
2063
|
);
|
1930
2064
|
var ValidateActionInput = BaseActionInput.merge(
|
1931
|
-
|
1932
|
-
type:
|
1933
|
-
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())
|
1934
2068
|
})
|
1935
2069
|
);
|
1936
2070
|
var NotifyActionInput = BaseActionInput.merge(
|
1937
|
-
|
1938
|
-
type:
|
2071
|
+
import_zod22.z.object({
|
2072
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1939
2073
|
})
|
1940
2074
|
);
|
1941
2075
|
var DeclareActionInput = BaseActionInput.merge(
|
1942
|
-
|
1943
|
-
type:
|
2076
|
+
import_zod22.z.object({
|
2077
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1944
2078
|
})
|
1945
2079
|
);
|
1946
2080
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1947
|
-
|
1948
|
-
type:
|
2081
|
+
import_zod22.z.object({
|
2082
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1949
2083
|
})
|
1950
2084
|
);
|
1951
2085
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1952
|
-
|
1953
|
-
type:
|
2086
|
+
import_zod22.z.object({
|
2087
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1954
2088
|
})
|
1955
2089
|
);
|
1956
2090
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1957
|
-
|
1958
|
-
type:
|
2091
|
+
import_zod22.z.object({
|
2092
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1959
2093
|
})
|
1960
2094
|
);
|
1961
2095
|
var ArchiveActionInput = BaseActionInput.merge(
|
1962
|
-
|
1963
|
-
type:
|
2096
|
+
import_zod22.z.object({
|
2097
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1964
2098
|
})
|
1965
2099
|
);
|
1966
2100
|
var AssignActionInput = BaseActionInput.merge(
|
1967
|
-
|
1968
|
-
type:
|
1969
|
-
assignedTo:
|
2101
|
+
import_zod22.z.object({
|
2102
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2103
|
+
assignedTo: import_zod22.z.string()
|
1970
2104
|
})
|
1971
2105
|
);
|
1972
2106
|
var UnassignActionInput = BaseActionInput.merge(
|
1973
|
-
|
1974
|
-
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)
|
1975
2110
|
})
|
1976
2111
|
);
|
1977
2112
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1978
|
-
|
1979
|
-
type:
|
2113
|
+
import_zod22.z.object({
|
2114
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1980
2115
|
})
|
1981
2116
|
);
|
1982
2117
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1983
|
-
|
1984
|
-
requestId:
|
1985
|
-
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)
|
1986
2121
|
})
|
1987
2122
|
);
|
1988
2123
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1989
|
-
|
1990
|
-
requestId:
|
1991
|
-
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)
|
1992
2127
|
})
|
1993
2128
|
);
|
1994
|
-
var
|
2129
|
+
var ReadActionInput = BaseActionInput.merge(
|
2130
|
+
import_zod22.z.object({
|
2131
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2132
|
+
})
|
2133
|
+
);
|
2134
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
1995
2135
|
CreateActionInput,
|
1996
2136
|
ValidateActionInput,
|
1997
2137
|
RegisterActionInput,
|
@@ -2005,56 +2145,62 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
2005
2145
|
PrintCertificateActionInput,
|
2006
2146
|
RequestCorrectionActionInput,
|
2007
2147
|
RejectCorrectionActionInput,
|
2008
|
-
ApproveCorrectionActionInput
|
2148
|
+
ApproveCorrectionActionInput,
|
2149
|
+
ReadActionInput
|
2009
2150
|
]);
|
2010
2151
|
|
2011
2152
|
// ../commons/src/events/Draft.ts
|
2012
|
-
var Draft =
|
2013
|
-
id:
|
2014
|
-
eventId:
|
2015
|
-
transactionId:
|
2016
|
-
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(),
|
2017
2158
|
action: ActionBase.extend({
|
2018
|
-
type:
|
2159
|
+
type: ActionTypes
|
2019
2160
|
}).omit({ id: true })
|
2020
2161
|
});
|
2021
2162
|
var DraftInput = BaseActionInput.extend({
|
2022
|
-
type:
|
2163
|
+
type: ActionTypes
|
2023
2164
|
});
|
2024
2165
|
|
2025
2166
|
// ../commons/src/events/EventInput.ts
|
2026
|
-
var
|
2027
|
-
var EventInput =
|
2028
|
-
transactionId:
|
2029
|
-
type:
|
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()
|
2030
2171
|
});
|
2031
2172
|
|
2032
2173
|
// ../commons/src/events/EventDocument.ts
|
2033
|
-
var
|
2034
|
-
var EventDocument =
|
2035
|
-
id:
|
2036
|
-
type:
|
2037
|
-
createdAt:
|
2038
|
-
updatedAt:
|
2039
|
-
actions:
|
2040
|
-
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()
|
2041
2182
|
});
|
2042
2183
|
|
2043
2184
|
// ../commons/src/events/EventIndex.ts
|
2044
|
-
var
|
2185
|
+
var import_zod26 = require("zod");
|
2045
2186
|
var EventIndex = EventMetadata.extend({
|
2046
|
-
|
2187
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2047
2188
|
});
|
2048
|
-
var EventSearchIndex =
|
2049
|
-
|
2050
|
-
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()
|
2051
2192
|
// Ensures "type" (event-id) exists and is a string
|
2052
2193
|
})
|
2053
2194
|
);
|
2054
2195
|
|
2055
2196
|
// ../commons/src/events/state/index.ts
|
2056
|
-
var _ = __toESM(require("lodash"));
|
2057
2197
|
function getStatusFromActions(actions) {
|
2198
|
+
const hasRejectedAction = actions.some(
|
2199
|
+
(a) => a.status === ActionStatus.Rejected
|
2200
|
+
);
|
2201
|
+
if (hasRejectedAction) {
|
2202
|
+
return EventStatus.REJECTED;
|
2203
|
+
}
|
2058
2204
|
return actions.reduce((status, action) => {
|
2059
2205
|
if (action.type === ActionType.CREATE) {
|
2060
2206
|
return EventStatus.CREATED;
|
@@ -2091,61 +2237,49 @@ function getAssignedUserFromActions(actions) {
|
|
2091
2237
|
return user2;
|
2092
2238
|
}, null);
|
2093
2239
|
}
|
2094
|
-
function
|
2240
|
+
function aggregateActionDeclarations(actions) {
|
2095
2241
|
const excludedActions = [
|
2096
2242
|
ActionType.REQUEST_CORRECTION,
|
2097
2243
|
ActionType.PRINT_CERTIFICATE
|
2098
2244
|
];
|
2099
2245
|
return actions.reduce((status, action) => {
|
2100
|
-
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2101
|
-
return status;
|
2102
|
-
}
|
2103
|
-
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2104
|
-
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2105
|
-
if (!requestAction) {
|
2106
|
-
return status;
|
2107
|
-
}
|
2108
|
-
return deepMerge(status, requestAction.data);
|
2109
|
-
}
|
2110
|
-
return deepMerge(status, action.data);
|
2111
|
-
}, {});
|
2112
|
-
}
|
2113
|
-
function deepDropNulls(obj) {
|
2114
|
-
if (!_.isObject(obj)) return obj;
|
2115
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2116
|
-
if (_.isObject(value)) {
|
2117
|
-
value = deepDropNulls(value);
|
2118
|
-
}
|
2119
|
-
if (value !== null) {
|
2120
|
-
return {
|
2121
|
-
...acc,
|
2122
|
-
[key]: value
|
2123
|
-
};
|
2124
|
-
}
|
2125
|
-
return acc;
|
2126
|
-
}, {});
|
2127
|
-
}
|
2128
|
-
function deepMerge(currentDocument, actionDocument) {
|
2129
|
-
return _.mergeWith(
|
2130
|
-
currentDocument,
|
2131
|
-
actionDocument,
|
2132
|
-
(previousValue, incomingValue) => {
|
2133
|
-
if (incomingValue === void 0) {
|
2134
|
-
return previousValue;
|
2135
|
-
}
|
2136
|
-
if (_.isArray(incomingValue)) {
|
2137
|
-
return incomingValue;
|
2138
|
-
}
|
2139
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2140
|
-
return void 0;
|
2246
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2247
|
+
return status;
|
2248
|
+
}
|
2249
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2250
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2251
|
+
if (!requestAction) {
|
2252
|
+
return status;
|
2141
2253
|
}
|
2142
|
-
return
|
2254
|
+
return deepMerge(status, requestAction.declaration);
|
2143
2255
|
}
|
2144
|
-
|
2256
|
+
return deepMerge(status, action.declaration);
|
2257
|
+
}, {});
|
2258
|
+
}
|
2259
|
+
function deepDropNulls(obj) {
|
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;
|
2269
|
+
}
|
2270
|
+
return acc;
|
2271
|
+
}, {});
|
2272
|
+
}
|
2273
|
+
return obj;
|
2145
2274
|
}
|
2146
2275
|
function isUndeclaredDraft(status) {
|
2147
2276
|
return status === EventStatus.CREATED;
|
2148
2277
|
}
|
2278
|
+
function getAcceptedActions(event2) {
|
2279
|
+
return event2.actions.filter(
|
2280
|
+
(a) => a.status === ActionStatus.Accepted
|
2281
|
+
);
|
2282
|
+
}
|
2149
2283
|
function getCurrentEventState(event2) {
|
2150
2284
|
const creationAction = event2.actions.find(
|
2151
2285
|
(action) => action.type === ActionType.CREATE
|
@@ -2153,7 +2287,12 @@ function getCurrentEventState(event2) {
|
|
2153
2287
|
if (!creationAction) {
|
2154
2288
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2155
2289
|
}
|
2156
|
-
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;
|
2157
2296
|
return deepDropNulls({
|
2158
2297
|
id: event2.id,
|
2159
2298
|
type: event2.type,
|
@@ -2162,10 +2301,11 @@ function getCurrentEventState(event2) {
|
|
2162
2301
|
createdBy: creationAction.createdBy,
|
2163
2302
|
createdAtLocation: creationAction.createdAtLocation,
|
2164
2303
|
modifiedAt: latestAction.createdAt,
|
2165
|
-
assignedTo: getAssignedUserFromActions(
|
2304
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2166
2305
|
updatedBy: latestAction.createdBy,
|
2167
|
-
|
2168
|
-
trackingId: event2.trackingId
|
2306
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2307
|
+
trackingId: event2.trackingId,
|
2308
|
+
registrationNumber
|
2169
2309
|
});
|
2170
2310
|
}
|
2171
2311
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2197,38 +2337,44 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2197
2337
|
}
|
2198
2338
|
return {
|
2199
2339
|
...eventIndex,
|
2200
|
-
|
2201
|
-
...eventIndex.
|
2202
|
-
...activeDrafts[activeDrafts.length - 1].
|
2340
|
+
declaration: {
|
2341
|
+
...eventIndex.declaration,
|
2342
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2203
2343
|
}
|
2204
2344
|
};
|
2205
2345
|
}
|
2206
|
-
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({
|
2207
2354
|
event: event2,
|
2208
2355
|
actionType,
|
2209
2356
|
drafts
|
2210
2357
|
}) {
|
2211
|
-
const
|
2358
|
+
const activeActions = getAcceptedActions(event2);
|
2359
|
+
const action = activeActions.find(
|
2360
|
+
(activeAction) => actionType === activeAction.type
|
2361
|
+
);
|
2212
2362
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2213
2363
|
const sorted = [
|
2214
2364
|
...action ? [action] : [],
|
2215
2365
|
...eventDrafts.map((draft) => draft.action)
|
2216
2366
|
].sort();
|
2217
|
-
const
|
2218
|
-
return deepMerge(
|
2367
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2368
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2219
2369
|
}, {});
|
2220
|
-
return deepDropNulls(
|
2370
|
+
return deepDropNulls(annotation);
|
2221
2371
|
}
|
2222
2372
|
|
2223
2373
|
// ../commons/src/events/defineConfig.ts
|
2224
2374
|
var defineConfig = (config) => {
|
2225
2375
|
validateWorkqueueConfig(config.workqueues);
|
2226
2376
|
const input = EventConfig.parse(config);
|
2227
|
-
|
2228
|
-
return EventConfig.parse({
|
2229
|
-
...input,
|
2230
|
-
pageFields
|
2231
|
-
});
|
2377
|
+
return input;
|
2232
2378
|
};
|
2233
2379
|
|
2234
2380
|
// ../commons/src/events/transactions.ts
|
@@ -2243,6 +2389,16 @@ var import_lodash2 = require("lodash");
|
|
2243
2389
|
function defineConditional(schema) {
|
2244
2390
|
return schema;
|
2245
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
|
+
}
|
2246
2402
|
function alwaysTrue() {
|
2247
2403
|
return {};
|
2248
2404
|
}
|
@@ -2267,6 +2423,9 @@ function not(condition) {
|
|
2267
2423
|
required: []
|
2268
2424
|
});
|
2269
2425
|
}
|
2426
|
+
function never() {
|
2427
|
+
return not(alwaysTrue());
|
2428
|
+
}
|
2270
2429
|
var user = {
|
2271
2430
|
hasScope: (scope) => defineConditional({
|
2272
2431
|
type: "object",
|
@@ -2314,69 +2473,120 @@ var event = {
|
|
2314
2473
|
required: ["$event"]
|
2315
2474
|
})
|
2316
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
|
+
}
|
2317
2496
|
function field(fieldId) {
|
2318
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2319
2497
|
const getDateRange = (date, clause) => ({
|
2320
2498
|
type: "object",
|
2321
2499
|
properties: {
|
2322
|
-
|
2323
|
-
type: "
|
2324
|
-
|
2325
|
-
|
2326
|
-
type: "string",
|
2327
|
-
format: "date",
|
2328
|
-
[clause]: date
|
2329
|
-
}
|
2330
|
-
},
|
2331
|
-
required: [fieldId]
|
2500
|
+
[fieldId]: {
|
2501
|
+
type: "string",
|
2502
|
+
format: "date",
|
2503
|
+
[clause]: date
|
2332
2504
|
}
|
2333
2505
|
},
|
2334
|
-
required: [
|
2506
|
+
required: [fieldId]
|
2335
2507
|
});
|
2336
2508
|
return {
|
2509
|
+
/**
|
2510
|
+
* @private Internal property used for field reference tracking.
|
2511
|
+
*/
|
2512
|
+
_fieldId: fieldId,
|
2337
2513
|
isAfter: () => ({
|
2338
2514
|
days: (days) => ({
|
2339
|
-
inPast: () =>
|
2515
|
+
inPast: () => defineFormConditional(
|
2340
2516
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2341
2517
|
),
|
2342
|
-
inFuture: () =>
|
2518
|
+
inFuture: () => defineFormConditional(
|
2343
2519
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2344
2520
|
)
|
2345
2521
|
}),
|
2346
|
-
date: (date) =>
|
2347
|
-
|
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"))
|
2348
2536
|
}),
|
2349
2537
|
isBefore: () => ({
|
2350
2538
|
days: (days) => ({
|
2351
|
-
inPast: () =>
|
2539
|
+
inPast: () => defineFormConditional(
|
2352
2540
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2353
2541
|
),
|
2354
|
-
inFuture: () =>
|
2542
|
+
inFuture: () => defineFormConditional(
|
2355
2543
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2356
2544
|
)
|
2357
2545
|
}),
|
2358
|
-
date: (date) =>
|
2359
|
-
|
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"))
|
2360
2560
|
}),
|
2361
|
-
isEqualTo: (value) =>
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2561
|
+
isEqualTo: (value) => {
|
2562
|
+
if (isFieldReference(value)) {
|
2563
|
+
const comparedFieldId = value._fieldId;
|
2564
|
+
return defineFormConditional({
|
2365
2565
|
type: "object",
|
2366
2566
|
properties: {
|
2367
2567
|
[fieldId]: {
|
2368
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
const: value
|
2373
|
-
}
|
2568
|
+
type: ["string", "boolean"],
|
2569
|
+
const: { $data: `1/${comparedFieldId}` }
|
2570
|
+
},
|
2571
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2374
2572
|
},
|
2375
|
-
required: [fieldId]
|
2376
|
-
}
|
2377
|
-
}
|
2378
|
-
|
2379
|
-
|
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
|
+
},
|
2380
2590
|
/**
|
2381
2591
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2382
2592
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2385,108 +2595,102 @@ function field(fieldId) {
|
|
2385
2595
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2386
2596
|
*
|
2387
2597
|
*/
|
2388
|
-
isFalsy: () =>
|
2598
|
+
isFalsy: () => defineFormConditional({
|
2389
2599
|
type: "object",
|
2390
2600
|
properties: {
|
2391
|
-
|
2392
|
-
type: "object",
|
2393
|
-
properties: {
|
2394
|
-
[fieldId]: {
|
2395
|
-
anyOf: [
|
2396
|
-
{ const: "undefined" },
|
2397
|
-
{ const: false },
|
2398
|
-
{ const: null },
|
2399
|
-
{ const: "" }
|
2400
|
-
]
|
2401
|
-
}
|
2402
|
-
},
|
2601
|
+
[fieldId]: {
|
2403
2602
|
anyOf: [
|
2404
|
-
{
|
2405
|
-
|
2406
|
-
},
|
2407
|
-
{
|
2408
|
-
not: {
|
2409
|
-
required: [fieldId]
|
2410
|
-
}
|
2411
|
-
}
|
2603
|
+
{ const: "undefined" },
|
2604
|
+
{ const: false },
|
2605
|
+
{ const: null },
|
2606
|
+
{ const: "" }
|
2412
2607
|
]
|
2413
2608
|
}
|
2414
2609
|
},
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
$form: {
|
2421
|
-
type: "object",
|
2422
|
-
properties: {
|
2423
|
-
[fieldId]: {
|
2424
|
-
type: "string",
|
2425
|
-
enum: ["undefined"]
|
2426
|
-
}
|
2427
|
-
},
|
2610
|
+
anyOf: [
|
2611
|
+
{
|
2612
|
+
required: [fieldId]
|
2613
|
+
},
|
2614
|
+
{
|
2428
2615
|
not: {
|
2429
2616
|
required: [fieldId]
|
2430
2617
|
}
|
2431
2618
|
}
|
2619
|
+
]
|
2620
|
+
}),
|
2621
|
+
isUndefined: () => defineFormConditional({
|
2622
|
+
type: "object",
|
2623
|
+
properties: {
|
2624
|
+
[fieldId]: {
|
2625
|
+
type: "string",
|
2626
|
+
enum: ["undefined"]
|
2627
|
+
}
|
2432
2628
|
},
|
2433
|
-
|
2629
|
+
not: {
|
2630
|
+
required: [fieldId]
|
2631
|
+
}
|
2434
2632
|
}),
|
2435
|
-
inArray: (values) =>
|
2633
|
+
inArray: (values) => defineFormConditional({
|
2436
2634
|
type: "object",
|
2437
2635
|
properties: {
|
2438
|
-
|
2439
|
-
type: "
|
2440
|
-
|
2441
|
-
[fieldId]: {
|
2442
|
-
type: "string",
|
2443
|
-
enum: values
|
2444
|
-
}
|
2445
|
-
},
|
2446
|
-
required: [fieldId]
|
2636
|
+
[fieldId]: {
|
2637
|
+
type: "string",
|
2638
|
+
enum: values
|
2447
2639
|
}
|
2448
2640
|
},
|
2449
|
-
required: [
|
2641
|
+
required: [fieldId]
|
2450
2642
|
}),
|
2451
|
-
isValidEnglishName: () =>
|
2643
|
+
isValidEnglishName: () => defineFormConditional({
|
2452
2644
|
type: "object",
|
2453
2645
|
properties: {
|
2454
|
-
|
2455
|
-
type: "
|
2456
|
-
|
2457
|
-
|
2458
|
-
type: "string",
|
2459
|
-
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'._-]*)*$",
|
2460
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2461
|
-
}
|
2462
|
-
},
|
2463
|
-
required: [fieldId]
|
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."
|
2464
2650
|
}
|
2465
2651
|
},
|
2466
|
-
required: [
|
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
|
2676
|
+
}
|
2677
|
+
},
|
2678
|
+
required: [fieldId]
|
2467
2679
|
})
|
2468
2680
|
};
|
2469
2681
|
}
|
2470
2682
|
|
2471
2683
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2472
|
-
var PRINT_CERTIFICATE_FORM =
|
2684
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2473
2685
|
label: {
|
2474
2686
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2475
2687
|
defaultMessage: "Tennis club membership certificate collector",
|
2476
2688
|
description: "This is what this form is referred as in the system"
|
2477
2689
|
},
|
2478
|
-
version: {
|
2479
|
-
id: "1.0.0",
|
2480
|
-
label: {
|
2481
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2482
|
-
defaultMessage: "Version 1",
|
2483
|
-
description: "This is the first version of the form"
|
2484
|
-
}
|
2485
|
-
},
|
2486
|
-
active: true,
|
2487
2690
|
pages: [
|
2488
2691
|
{
|
2489
2692
|
id: "collector",
|
2693
|
+
type: PageTypes.enum.FORM,
|
2490
2694
|
title: {
|
2491
2695
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2492
2696
|
defaultMessage: "Print certified copy",
|
@@ -2501,7 +2705,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2501
2705
|
defaultMessage: "Requester",
|
2502
2706
|
description: "This is the label for the field"
|
2503
2707
|
},
|
2504
|
-
type:
|
2708
|
+
type: FieldType.SELECT,
|
2505
2709
|
options: [
|
2506
2710
|
{
|
2507
2711
|
value: "INFORMANT",
|
@@ -2578,7 +2782,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2578
2782
|
defaultMessage: "Select Type of ID",
|
2579
2783
|
description: "This is the label for selecting the type of ID"
|
2580
2784
|
},
|
2581
|
-
type:
|
2785
|
+
type: FieldType.SELECT,
|
2582
2786
|
options: [
|
2583
2787
|
{
|
2584
2788
|
value: "PASSPORT",
|
@@ -2679,7 +2883,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2679
2883
|
defaultMessage: "Passport Details",
|
2680
2884
|
description: "Field for entering Passport details"
|
2681
2885
|
},
|
2682
|
-
type:
|
2886
|
+
type: FieldType.TEXT
|
2683
2887
|
},
|
2684
2888
|
{
|
2685
2889
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2730,7 +2934,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2730
2934
|
defaultMessage: "Driving License Details",
|
2731
2935
|
description: "Field for entering Driving License details"
|
2732
2936
|
},
|
2733
|
-
type:
|
2937
|
+
type: FieldType.TEXT
|
2734
2938
|
},
|
2735
2939
|
{
|
2736
2940
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2781,7 +2985,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2781
2985
|
defaultMessage: "Refugee Number Details",
|
2782
2986
|
description: "Field for entering Refugee Number details"
|
2783
2987
|
},
|
2784
|
-
type:
|
2988
|
+
type: FieldType.TEXT
|
2785
2989
|
},
|
2786
2990
|
{
|
2787
2991
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2832,7 +3036,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2832
3036
|
defaultMessage: "Alien Number Details",
|
2833
3037
|
description: "Field for entering Alien Number details"
|
2834
3038
|
},
|
2835
|
-
type:
|
3039
|
+
type: FieldType.TEXT
|
2836
3040
|
},
|
2837
3041
|
{
|
2838
3042
|
id: "collector.OTHER.idTypeOther",
|
@@ -2883,7 +3087,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2883
3087
|
defaultMessage: "Other ID Type (if applicable)",
|
2884
3088
|
description: 'Field for entering ID type if "Other" is selected'
|
2885
3089
|
},
|
2886
|
-
type:
|
3090
|
+
type: FieldType.TEXT
|
2887
3091
|
},
|
2888
3092
|
{
|
2889
3093
|
id: "collector.OTHER.firstName",
|
@@ -2934,7 +3138,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2934
3138
|
defaultMessage: "First Name",
|
2935
3139
|
description: "This is the label for the first name field"
|
2936
3140
|
},
|
2937
|
-
type:
|
3141
|
+
type: FieldType.TEXT
|
2938
3142
|
},
|
2939
3143
|
{
|
2940
3144
|
id: "collector.OTHER.lastName",
|
@@ -2985,7 +3189,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2985
3189
|
defaultMessage: "Last Name",
|
2986
3190
|
description: "This is the label for the last name field"
|
2987
3191
|
},
|
2988
|
-
type:
|
3192
|
+
type: FieldType.TEXT
|
2989
3193
|
},
|
2990
3194
|
{
|
2991
3195
|
id: "collector.OTHER.relationshipToMember",
|
@@ -3036,7 +3240,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3036
3240
|
defaultMessage: "Relationship to Member",
|
3037
3241
|
description: "This is the label for the relationship to member field"
|
3038
3242
|
},
|
3039
|
-
type:
|
3243
|
+
type: FieldType.TEXT
|
3040
3244
|
},
|
3041
3245
|
{
|
3042
3246
|
id: "collector.OTHER.signedAffidavit",
|
@@ -3087,13 +3291,14 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3087
3291
|
defaultMessage: "Signed Affidavit (Optional)",
|
3088
3292
|
description: "This is the label for uploading a signed affidavit"
|
3089
3293
|
},
|
3090
|
-
type:
|
3294
|
+
type: FieldType.FILE
|
3091
3295
|
}
|
3092
3296
|
]
|
3093
3297
|
},
|
3094
3298
|
{
|
3095
3299
|
id: "collector.identity.verify",
|
3096
|
-
type:
|
3300
|
+
type: PageTypes.enum.VERIFICATION,
|
3301
|
+
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3097
3302
|
title: {
|
3098
3303
|
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
3099
3304
|
defaultMessage: "Verify their identity",
|
@@ -3129,62 +3334,45 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3129
3334
|
}
|
3130
3335
|
}
|
3131
3336
|
}
|
3132
|
-
]
|
3133
|
-
review: {
|
3134
|
-
title: {
|
3135
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
3136
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
3137
|
-
description: "Title of the form to show in review page"
|
3138
|
-
},
|
3139
|
-
fields: []
|
3140
|
-
}
|
3337
|
+
]
|
3141
3338
|
});
|
3142
|
-
var
|
3143
|
-
|
3144
|
-
id: "v2.event.tennis-club-membership.action.declare.form.
|
3145
|
-
defaultMessage: "
|
3146
|
-
description: "
|
3147
|
-
},
|
3148
|
-
active: true,
|
3149
|
-
version: {
|
3150
|
-
id: "1.0.0",
|
3151
|
-
label: {
|
3152
|
-
id: "v2.event.tennis-club-membership.action.declare.form.version.1",
|
3153
|
-
defaultMessage: "Version 1",
|
3154
|
-
description: "This is the first version of the form"
|
3155
|
-
}
|
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"
|
3156
3344
|
},
|
3157
|
-
|
3158
|
-
|
3159
|
-
id: "
|
3160
|
-
|
3161
|
-
|
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
|
+
}
|
3162
3354
|
},
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
description: "Label for the comment field in the review section"
|
3171
|
-
}
|
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"
|
3172
3362
|
},
|
3173
|
-
{
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
defaultMessage: "Signature of informant",
|
3178
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3179
|
-
description: "Label for the signature field in the review section"
|
3180
|
-
},
|
3181
|
-
signaturePromptLabel: {
|
3182
|
-
id: "v2.signature.upload.modal.title",
|
3183
|
-
defaultMessage: "Draw signature",
|
3184
|
-
description: "Title for the modal to draw signature"
|
3185
|
-
}
|
3363
|
+
signaturePromptLabel: {
|
3364
|
+
id: "v2.signature.upload.modal.title",
|
3365
|
+
defaultMessage: "Draw signature",
|
3366
|
+
description: "Title for the modal to draw signature"
|
3186
3367
|
}
|
3187
|
-
|
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"
|
3188
3376
|
},
|
3189
3377
|
pages: [
|
3190
3378
|
{
|
@@ -3197,7 +3385,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3197
3385
|
fields: [
|
3198
3386
|
{
|
3199
3387
|
id: "applicant.firstname",
|
3200
|
-
type:
|
3388
|
+
type: FieldType.TEXT,
|
3201
3389
|
required: true,
|
3202
3390
|
conditionals: [],
|
3203
3391
|
label: {
|
@@ -3208,7 +3396,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3208
3396
|
},
|
3209
3397
|
{
|
3210
3398
|
id: "applicant.surname",
|
3211
|
-
type:
|
3399
|
+
type: FieldType.TEXT,
|
3212
3400
|
required: true,
|
3213
3401
|
conditionals: [],
|
3214
3402
|
label: {
|
@@ -3230,9 +3418,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3230
3418
|
},
|
3231
3419
|
{
|
3232
3420
|
id: "applicant.dob",
|
3233
|
-
type:
|
3421
|
+
type: FieldType.DATE,
|
3234
3422
|
required: true,
|
3235
|
-
conditionals: [],
|
3236
3423
|
validation: [
|
3237
3424
|
{
|
3238
3425
|
message: {
|
@@ -3243,15 +3430,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3243
3430
|
validator: field("applicant.dob").isBefore().now()
|
3244
3431
|
}
|
3245
3432
|
],
|
3433
|
+
conditionals: [
|
3434
|
+
{
|
3435
|
+
type: ConditionalType.SHOW,
|
3436
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3437
|
+
}
|
3438
|
+
],
|
3246
3439
|
label: {
|
3247
3440
|
defaultMessage: "Applicant's date of birth",
|
3248
3441
|
description: "This is the label for the field",
|
3249
3442
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3250
3443
|
}
|
3251
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
|
+
},
|
3252
3477
|
{
|
3253
3478
|
id: "applicant.image",
|
3254
|
-
type:
|
3479
|
+
type: FieldType.FILE,
|
3255
3480
|
required: false,
|
3256
3481
|
label: {
|
3257
3482
|
defaultMessage: "Applicant's profile picture",
|
@@ -3272,6 +3497,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3272
3497
|
}
|
3273
3498
|
]
|
3274
3499
|
},
|
3500
|
+
{
|
3501
|
+
id: "senior-pass",
|
3502
|
+
conditional: field("applicant.dob").isBefore().date("1950-01-01"),
|
3503
|
+
title: {
|
3504
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
|
3505
|
+
defaultMessage: "Assign senior pass for applicant",
|
3506
|
+
description: "This is the title of the section"
|
3507
|
+
},
|
3508
|
+
fields: [
|
3509
|
+
{
|
3510
|
+
id: "senior-pass.id",
|
3511
|
+
type: FieldType.TEXT,
|
3512
|
+
required: true,
|
3513
|
+
label: {
|
3514
|
+
defaultMessage: "Senior pass ID",
|
3515
|
+
description: "This is the label for the field",
|
3516
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
|
3517
|
+
}
|
3518
|
+
}
|
3519
|
+
]
|
3520
|
+
},
|
3275
3521
|
{
|
3276
3522
|
id: "recommender",
|
3277
3523
|
title: {
|
@@ -3293,7 +3539,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3293
3539
|
},
|
3294
3540
|
{
|
3295
3541
|
id: "recommender.firstname",
|
3296
|
-
type:
|
3542
|
+
type: FieldType.TEXT,
|
3297
3543
|
required: true,
|
3298
3544
|
conditionals: [
|
3299
3545
|
{
|
@@ -3309,7 +3555,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3309
3555
|
},
|
3310
3556
|
{
|
3311
3557
|
id: "recommender.surname",
|
3312
|
-
type:
|
3558
|
+
type: FieldType.TEXT,
|
3313
3559
|
required: true,
|
3314
3560
|
conditionals: [
|
3315
3561
|
{
|
@@ -3325,7 +3571,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3325
3571
|
},
|
3326
3572
|
{
|
3327
3573
|
id: "recommender.id",
|
3328
|
-
type:
|
3574
|
+
type: FieldType.TEXT,
|
3329
3575
|
required: true,
|
3330
3576
|
conditionals: [
|
3331
3577
|
{
|
@@ -3433,7 +3679,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3433
3679
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3434
3680
|
id: "event.tennis-club-membership.action.declare.label"
|
3435
3681
|
},
|
3436
|
-
|
3682
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3437
3683
|
},
|
3438
3684
|
{
|
3439
3685
|
type: ActionType.VALIDATE,
|
@@ -3442,7 +3688,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3442
3688
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3443
3689
|
id: "event.tennis-club-membership.action.validate.label"
|
3444
3690
|
},
|
3445
|
-
|
3691
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3446
3692
|
},
|
3447
3693
|
{
|
3448
3694
|
type: ActionType.REGISTER,
|
@@ -3451,7 +3697,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3451
3697
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3452
3698
|
id: "event.tennis-club-membership.action.register.label"
|
3453
3699
|
},
|
3454
|
-
|
3700
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3455
3701
|
},
|
3456
3702
|
{
|
3457
3703
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3460,10 +3706,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3460
3706
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3461
3707
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3462
3708
|
},
|
3463
|
-
forms: [TENNIS_CLUB_FORM],
|
3464
3709
|
onboardingForm: [
|
3465
3710
|
{
|
3466
3711
|
id: "correction-requester",
|
3712
|
+
type: PageTypes.enum.FORM,
|
3467
3713
|
title: {
|
3468
3714
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3469
3715
|
defaultMessage: "Correction requester",
|
@@ -3527,6 +3773,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3527
3773
|
},
|
3528
3774
|
{
|
3529
3775
|
id: "identity-check",
|
3776
|
+
type: PageTypes.enum.FORM,
|
3530
3777
|
title: {
|
3531
3778
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3532
3779
|
defaultMessage: "Verify their identity",
|
@@ -3569,6 +3816,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3569
3816
|
additionalDetailsForm: [
|
3570
3817
|
{
|
3571
3818
|
id: "correction-request.supporting-documents",
|
3819
|
+
type: PageTypes.enum.FORM,
|
3572
3820
|
title: {
|
3573
3821
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3574
3822
|
defaultMessage: "Upload supporting documents",
|
@@ -3586,7 +3834,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3586
3834
|
},
|
3587
3835
|
{
|
3588
3836
|
id: "correction.supportingDocs",
|
3589
|
-
type:
|
3837
|
+
type: FieldType.FILE,
|
3590
3838
|
label: {
|
3591
3839
|
id: "correction.corrector.title",
|
3592
3840
|
defaultMessage: "Upload supporting documents",
|
@@ -3630,6 +3878,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3630
3878
|
},
|
3631
3879
|
{
|
3632
3880
|
id: "correction-request.additional-details",
|
3881
|
+
type: PageTypes.enum.FORM,
|
3633
3882
|
title: {
|
3634
3883
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3635
3884
|
defaultMessage: "Reason for correction",
|
@@ -3638,7 +3887,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3638
3887
|
fields: [
|
3639
3888
|
{
|
3640
3889
|
id: "correction.request.reason",
|
3641
|
-
type:
|
3890
|
+
type: FieldType.TEXT,
|
3642
3891
|
label: {
|
3643
3892
|
id: "correction.reason.title",
|
3644
3893
|
defaultMessage: "Reason for correction?",
|
@@ -3651,7 +3900,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3651
3900
|
},
|
3652
3901
|
{
|
3653
3902
|
type: ActionType.APPROVE_CORRECTION,
|
3654
|
-
forms: [TENNIS_CLUB_FORM],
|
3655
3903
|
label: {
|
3656
3904
|
defaultMessage: "Approve correction",
|
3657
3905
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3665,7 +3913,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3665
3913
|
defaultMessage: "Print certificate",
|
3666
3914
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3667
3915
|
},
|
3668
|
-
|
3916
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3669
3917
|
conditionals: [
|
3670
3918
|
{
|
3671
3919
|
type: "SHOW",
|
@@ -3712,8 +3960,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3712
3960
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3713
3961
|
defaultMessage: "Archive",
|
3714
3962
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3715
|
-
}
|
3716
|
-
forms: [TENNIS_CLUB_FORM]
|
3963
|
+
}
|
3717
3964
|
},
|
3718
3965
|
{
|
3719
3966
|
type: ActionType.REJECT,
|
@@ -3721,8 +3968,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3721
3968
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3722
3969
|
defaultMessage: "Reject",
|
3723
3970
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3724
|
-
}
|
3725
|
-
forms: [TENNIS_CLUB_FORM]
|
3971
|
+
}
|
3726
3972
|
}
|
3727
3973
|
],
|
3728
3974
|
advancedSearch: [
|
@@ -3738,33 +3984,53 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3738
3984
|
}
|
3739
3985
|
]
|
3740
3986
|
}
|
3741
|
-
]
|
3987
|
+
],
|
3988
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3742
3989
|
});
|
3743
3990
|
|
3744
3991
|
// ../commons/src/events/test.utils.ts
|
3745
|
-
function
|
3746
|
-
|
3747
|
-
const data = fields.reduce(
|
3992
|
+
function fieldConfigsToActionPayload(fields) {
|
3993
|
+
return fields.reduce(
|
3748
3994
|
(acc, field2, i) => ({
|
3749
3995
|
...acc,
|
3750
3996
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3751
3997
|
}),
|
3752
3998
|
{}
|
3753
3999
|
);
|
3754
|
-
return stripHiddenFields(fields, data);
|
3755
4000
|
}
|
3756
|
-
function
|
3757
|
-
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(
|
3758
4019
|
configuration,
|
3759
4020
|
action
|
3760
|
-
);
|
3761
|
-
|
4021
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
4022
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3762
4023
|
(acc, pageId) => ({
|
3763
4024
|
...acc,
|
3764
4025
|
[pageId]: true
|
3765
4026
|
}),
|
3766
4027
|
{}
|
3767
4028
|
);
|
4029
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4030
|
+
return {
|
4031
|
+
...fieldBasedPayload,
|
4032
|
+
...visiblePageVerificationMap
|
4033
|
+
};
|
3768
4034
|
}
|
3769
4035
|
var eventPayloadGenerator = {
|
3770
4036
|
create: (input = {}) => ({
|
@@ -3776,21 +4042,22 @@ var eventPayloadGenerator = {
|
|
3776
4042
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3777
4043
|
id
|
3778
4044
|
}),
|
3779
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4045
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3780
4046
|
{
|
3781
4047
|
id: getUUID(),
|
3782
4048
|
eventId,
|
3783
4049
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3784
4050
|
transactionId: getUUID(),
|
3785
4051
|
action: {
|
3786
|
-
type:
|
3787
|
-
|
4052
|
+
type: actionType,
|
4053
|
+
status: ActionStatus.Accepted,
|
4054
|
+
declaration: {
|
3788
4055
|
"applicant.firstname": "Max",
|
3789
4056
|
"applicant.surname": "McLaren",
|
3790
4057
|
"applicant.dob": "2020-01-02",
|
3791
4058
|
"recommender.none": true
|
3792
4059
|
},
|
3793
|
-
|
4060
|
+
annotation: {
|
3794
4061
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3795
4062
|
"correction.request.reason": "Child's name was incorrect"
|
3796
4063
|
},
|
@@ -3805,45 +4072,104 @@ var eventPayloadGenerator = {
|
|
3805
4072
|
declare: (eventId, input = {}) => ({
|
3806
4073
|
type: ActionType.DECLARE,
|
3807
4074
|
transactionId: input.transactionId ?? getUUID(),
|
3808
|
-
|
4075
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4076
|
+
tennisClubMembershipEvent,
|
4077
|
+
ActionType.DECLARE
|
4078
|
+
),
|
4079
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4080
|
+
tennisClubMembershipEvent,
|
4081
|
+
ActionType.DECLARE
|
4082
|
+
),
|
3809
4083
|
eventId
|
3810
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
|
+
},
|
3811
4107
|
validate: (eventId, input = {}) => ({
|
3812
4108
|
type: ActionType.VALIDATE,
|
3813
4109
|
transactionId: input.transactionId ?? getUUID(),
|
3814
|
-
|
4110
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4111
|
+
tennisClubMembershipEvent,
|
4112
|
+
ActionType.VALIDATE
|
4113
|
+
),
|
4114
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4115
|
+
tennisClubMembershipEvent,
|
4116
|
+
ActionType.VALIDATE
|
4117
|
+
),
|
3815
4118
|
duplicates: [],
|
3816
4119
|
eventId
|
3817
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
|
+
}),
|
3818
4135
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3819
4136
|
type: ActionType.ARCHIVE,
|
3820
4137
|
transactionId: input.transactionId ?? getUUID(),
|
3821
|
-
|
3822
|
-
|
4138
|
+
declaration: {},
|
4139
|
+
// @TODO: Check whether generator is needed?
|
4140
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3823
4141
|
duplicates: [],
|
3824
4142
|
eventId
|
3825
4143
|
}),
|
3826
4144
|
reject: (eventId, input = {}) => ({
|
3827
4145
|
type: ActionType.REJECT,
|
3828
4146
|
transactionId: input.transactionId ?? getUUID(),
|
3829
|
-
|
4147
|
+
declaration: {},
|
4148
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4149
|
+
tennisClubMembershipEvent,
|
4150
|
+
ActionType.REJECT
|
4151
|
+
),
|
3830
4152
|
duplicates: [],
|
3831
4153
|
eventId
|
3832
4154
|
}),
|
3833
4155
|
register: (eventId, input = {}) => ({
|
3834
4156
|
type: ActionType.REGISTER,
|
3835
4157
|
transactionId: input.transactionId ?? getUUID(),
|
3836
|
-
|
4158
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4159
|
+
tennisClubMembershipEvent,
|
4160
|
+
ActionType.REGISTER
|
4161
|
+
),
|
4162
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4163
|
+
tennisClubMembershipEvent,
|
4164
|
+
ActionType.REGISTER
|
4165
|
+
),
|
3837
4166
|
eventId
|
3838
4167
|
}),
|
3839
4168
|
printCertificate: (eventId, input = {}) => ({
|
3840
4169
|
type: ActionType.PRINT_CERTIFICATE,
|
3841
4170
|
transactionId: input.transactionId ?? getUUID(),
|
3842
|
-
|
3843
|
-
|
3844
|
-
ActionType.PRINT_CERTIFICATE
|
3845
|
-
),
|
3846
|
-
metadata: input.metadata ?? generateActionMetadataInput(
|
4171
|
+
declaration: {},
|
4172
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3847
4173
|
tennisClubMembershipEvent,
|
3848
4174
|
ActionType.PRINT_CERTIFICATE
|
3849
4175
|
),
|
@@ -3853,17 +4179,21 @@ var eventPayloadGenerator = {
|
|
3853
4179
|
request: (eventId, input = {}) => ({
|
3854
4180
|
type: ActionType.REQUEST_CORRECTION,
|
3855
4181
|
transactionId: input.transactionId ?? getUUID(),
|
3856
|
-
|
4182
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4183
|
+
tennisClubMembershipEvent,
|
4184
|
+
ActionType.REQUEST_CORRECTION
|
4185
|
+
),
|
4186
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3857
4187
|
tennisClubMembershipEvent,
|
3858
4188
|
ActionType.REQUEST_CORRECTION
|
3859
4189
|
),
|
3860
|
-
metadata: {},
|
3861
4190
|
eventId
|
3862
4191
|
}),
|
3863
4192
|
approve: (eventId, requestId, input = {}) => ({
|
3864
4193
|
type: ActionType.APPROVE_CORRECTION,
|
3865
4194
|
transactionId: input.transactionId ?? getUUID(),
|
3866
|
-
|
4195
|
+
declaration: {},
|
4196
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3867
4197
|
tennisClubMembershipEvent,
|
3868
4198
|
ActionType.APPROVE_CORRECTION
|
3869
4199
|
),
|
@@ -3873,7 +4203,8 @@ var eventPayloadGenerator = {
|
|
3873
4203
|
reject: (eventId, requestId, input = {}) => ({
|
3874
4204
|
type: ActionType.REJECT_CORRECTION,
|
3875
4205
|
transactionId: input.transactionId ?? getUUID(),
|
3876
|
-
|
4206
|
+
declaration: {},
|
4207
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3877
4208
|
tennisClubMembershipEvent,
|
3878
4209
|
ActionType.REJECT_CORRECTION
|
3879
4210
|
),
|
@@ -3895,15 +4226,20 @@ function generateActionDocument({
|
|
3895
4226
|
createdBy: getUUID(),
|
3896
4227
|
id: getUUID(),
|
3897
4228
|
createdAtLocation: "TODO",
|
3898
|
-
|
3899
|
-
|
3900
|
-
...defaults
|
4229
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4230
|
+
annotation: {},
|
4231
|
+
...defaults,
|
4232
|
+
status: ActionStatus.Accepted
|
3901
4233
|
};
|
3902
4234
|
switch (action) {
|
4235
|
+
case ActionType.READ:
|
4236
|
+
return { ...actionBase, type: action };
|
4237
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4238
|
+
return { ...actionBase, type: action };
|
3903
4239
|
case ActionType.DECLARE:
|
3904
4240
|
return { ...actionBase, type: action };
|
3905
4241
|
case ActionType.UNASSIGN:
|
3906
|
-
return { ...actionBase, type: action };
|
4242
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3907
4243
|
case ActionType.ASSIGN:
|
3908
4244
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3909
4245
|
case ActionType.VALIDATE:
|
@@ -3924,14 +4260,13 @@ function generateActionDocument({
|
|
3924
4260
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3925
4261
|
case ActionType.REJECT_CORRECTION:
|
3926
4262
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3927
|
-
case ActionType.CUSTOM:
|
3928
|
-
return { ...actionBase, type: action };
|
3929
4263
|
case ActionType.REGISTER:
|
3930
4264
|
return {
|
3931
4265
|
...actionBase,
|
3932
|
-
type: action
|
3933
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4266
|
+
type: action
|
3934
4267
|
};
|
4268
|
+
case ActionType.DELETE:
|
4269
|
+
case ActionType.DETECT_DUPLICATE:
|
3935
4270
|
default:
|
3936
4271
|
throw new Error(`Unsupported action type: ${action}`);
|
3937
4272
|
}
|
@@ -3955,7 +4290,7 @@ function generateEventDocument({
|
|
3955
4290
|
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
3956
4291
|
};
|
3957
4292
|
}
|
3958
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4293
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3959
4294
|
const action = generateActionDocument({
|
3960
4295
|
configuration: tennisClubMembershipEvent,
|
3961
4296
|
action: actionType
|
@@ -3965,9 +4300,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3965
4300
|
transactionId: getUUID(),
|
3966
4301
|
action: {
|
3967
4302
|
...action,
|
3968
|
-
|
3969
|
-
...action.
|
3970
|
-
...
|
4303
|
+
declaration: {
|
4304
|
+
...action.declaration,
|
4305
|
+
...declaration
|
3971
4306
|
}
|
3972
4307
|
},
|
3973
4308
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3984,7 +4319,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3984
4319
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3985
4320
|
assignedTo: overrides.assignedTo ?? null,
|
3986
4321
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3987
|
-
|
4322
|
+
declaration: overrides.declaration ?? {
|
3988
4323
|
"recommender.none": true,
|
3989
4324
|
"applicant.firstname": "Danny",
|
3990
4325
|
"applicant.surname": "Doe",
|
@@ -4015,7 +4350,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
4015
4350
|
return true;
|
4016
4351
|
}
|
4017
4352
|
function isFieldConfigDefaultValue(value) {
|
4018
|
-
if (!value)
|
4353
|
+
if (!value) {
|
4354
|
+
return false;
|
4355
|
+
}
|
4019
4356
|
if (isFieldValue(value)) {
|
4020
4357
|
return true;
|
4021
4358
|
}
|