@opencrvs/toolkit 1.8.0-rc.f7910f3 → 1.8.0-rc.f872339
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 +5825 -13746
- package/dist/commons/conditionals/conditionals.d.ts +25 -3
- package/dist/commons/conditionals/validate.d.ts +12 -17
- package/dist/commons/events/ActionConfig.d.ts +1202 -6605
- 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/CompositeFieldValue.d.ts +3 -0
- 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 +846 -3043
- package/dist/commons/events/EventConfigInput.d.ts +5 -2
- package/dist/commons/events/EventDocument.d.ts +703 -304
- package/dist/commons/events/EventIndex.d.ts +9 -3
- package/dist/commons/events/EventMetadata.d.ts +6 -0
- package/dist/commons/events/FieldConfig.d.ts +286 -45
- package/dist/commons/events/FormConfig.d.ts +559 -322
- package/dist/commons/events/PageConfig.d.ts +335 -0
- package/dist/commons/events/SummaryConfig.d.ts +93 -7
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/User.d.ts +5 -0
- package/dist/commons/events/defineConfig.d.ts +41 -435
- package/dist/commons/events/index.d.ts +3 -1
- package/dist/commons/events/scopes.d.ts +25 -0
- package/dist/commons/events/test.utils.d.ts +63 -284
- package/dist/commons/events/utils.d.ts +83 -178
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +161 -93
- package/dist/events/index.js +1348 -849
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -30,13 +30,18 @@ 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_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
|
34
|
+
Action: () => Action,
|
33
35
|
ActionBase: () => ActionBase,
|
34
36
|
ActionConditional: () => ActionConditional,
|
35
37
|
ActionConfig: () => ActionConfig,
|
36
38
|
ActionConfigBase: () => ActionConfigBase,
|
37
39
|
ActionDocument: () => ActionDocument,
|
40
|
+
ActionFormConfig: () => ActionFormConfig,
|
38
41
|
ActionInput: () => ActionInput,
|
42
|
+
ActionStatus: () => ActionStatus,
|
39
43
|
ActionType: () => ActionType,
|
44
|
+
ActionTypes: () => ActionTypes,
|
40
45
|
ActionUpdate: () => ActionUpdate,
|
41
46
|
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
42
47
|
AddressFieldValue: () => AddressFieldValue,
|
@@ -45,17 +50,28 @@ __export(events_exports, {
|
|
45
50
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
46
51
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
47
52
|
ArchiveActionInput: () => ArchiveActionInput,
|
53
|
+
AssignActionInput: () => AssignActionInput,
|
54
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
48
55
|
BaseActionInput: () => BaseActionInput,
|
56
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
49
57
|
CertificateConfig: () => CertificateConfig,
|
50
58
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
51
59
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
52
60
|
Clause: () => Clause,
|
53
61
|
Conditional: () => Conditional,
|
54
62
|
ConditionalType: () => ConditionalType,
|
63
|
+
ConfirmableActions: () => ConfirmableActions,
|
64
|
+
DataEntry: () => DataEntry,
|
55
65
|
DataFieldValue: () => DataFieldValue,
|
56
66
|
DateValue: () => DateValue,
|
67
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
68
|
+
DeclarationActions: () => DeclarationActions,
|
69
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
70
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
71
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
57
72
|
DeclareActionInput: () => DeclareActionInput,
|
58
73
|
DeduplicationConfig: () => DeduplicationConfig,
|
74
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
59
75
|
Draft: () => Draft,
|
60
76
|
DraftInput: () => DraftInput,
|
61
77
|
EmailField: () => EmailField,
|
@@ -69,6 +85,7 @@ __export(events_exports, {
|
|
69
85
|
EventSearchIndex: () => EventSearchIndex,
|
70
86
|
EventStatus: () => EventStatus,
|
71
87
|
EventStatuses: () => EventStatuses,
|
88
|
+
FieldConditional: () => FieldConditional,
|
72
89
|
FieldConfig: () => FieldConfig,
|
73
90
|
FieldType: () => FieldType,
|
74
91
|
FieldUpdateValue: () => FieldUpdateValue,
|
@@ -77,20 +94,21 @@ __export(events_exports, {
|
|
77
94
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
78
95
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
79
96
|
FormConfig: () => FormConfig,
|
80
|
-
FormPage: () => FormPage,
|
81
97
|
FormPageConfig: () => FormPageConfig,
|
82
|
-
FormPageType: () => FormPageType,
|
83
98
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
84
99
|
GenericAddressValue: () => GenericAddressValue,
|
85
100
|
GeographicalArea: () => GeographicalArea,
|
86
101
|
ImageMimeType: () => ImageMimeType,
|
87
102
|
LanguageConfig: () => LanguageConfig,
|
88
|
-
LatentActions: () => LatentActions,
|
89
103
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
90
104
|
MimeType: () => MimeType,
|
91
105
|
NotifyActionInput: () => NotifyActionInput,
|
92
106
|
NumberFieldValue: () => NumberFieldValue,
|
107
|
+
PageConfig: () => PageConfig,
|
108
|
+
PageTypes: () => PageTypes,
|
93
109
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
110
|
+
ReadActionInput: () => ReadActionInput,
|
111
|
+
RegisterAction: () => RegisterAction,
|
94
112
|
RegisterActionInput: () => RegisterActionInput,
|
95
113
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
96
114
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -103,23 +121,30 @@ __export(events_exports, {
|
|
103
121
|
SummaryConfig: () => SummaryConfig,
|
104
122
|
TextValue: () => TextValue,
|
105
123
|
TranslationConfig: () => TranslationConfig,
|
124
|
+
UnassignActionInput: () => UnassignActionInput,
|
106
125
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
107
126
|
UrbanAddressValue: () => UrbanAddressValue,
|
108
127
|
ValidateActionInput: () => ValidateActionInput,
|
109
|
-
|
128
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
110
129
|
VerificationPageConfig: () => VerificationPageConfig,
|
111
130
|
WorkqueueConfig: () => WorkqueueConfig,
|
112
131
|
alwaysTrue: () => alwaysTrue,
|
113
132
|
and: () => and,
|
133
|
+
annotationActions: () => annotationActions,
|
114
134
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
135
|
+
areConditionsMet: () => areConditionsMet,
|
115
136
|
compositeFieldTypes: () => compositeFieldTypes,
|
116
137
|
createEmptyDraft: () => createEmptyDraft,
|
117
138
|
createValidationSchema: () => createValidationSchema,
|
118
139
|
deepDropNulls: () => deepDropNulls,
|
140
|
+
deepMerge: () => deepMerge,
|
141
|
+
defineActionForm: () => defineActionForm,
|
119
142
|
defineConditional: () => defineConditional,
|
120
143
|
defineConfig: () => defineConfig,
|
121
|
-
|
144
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
145
|
+
defineFormConditional: () => defineFormConditional,
|
122
146
|
defineFormPage: () => defineFormPage,
|
147
|
+
definePage: () => definePage,
|
123
148
|
errorMessages: () => errorMessages,
|
124
149
|
event: () => event,
|
125
150
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -128,35 +153,36 @@ __export(events_exports, {
|
|
128
153
|
eventStatuses: () => eventStatuses,
|
129
154
|
field: () => field,
|
130
155
|
fieldTypes: () => fieldTypes,
|
131
|
-
|
132
|
-
findActiveActionForm: () => findActiveActionForm,
|
133
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
134
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
156
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
135
157
|
findActiveDrafts: () => findActiveDrafts,
|
136
|
-
|
137
|
-
|
158
|
+
findAllFields: () => findAllFields,
|
159
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
160
|
+
findRecordActionPages: () => findRecordActionPages,
|
161
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
162
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
138
163
|
generateActionDocument: () => generateActionDocument,
|
139
|
-
generateActionInput: () => generateActionInput,
|
140
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
141
164
|
generateEventDocument: () => generateEventDocument,
|
142
165
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
143
166
|
generateTransactionId: () => generateTransactionId,
|
144
167
|
generateTranslationConfig: () => generateTranslationConfig,
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
168
|
+
getAcceptedActions: () => getAcceptedActions,
|
169
|
+
getActionAnnotation: () => getActionAnnotation,
|
170
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
171
|
+
getActionReview: () => getActionReview,
|
172
|
+
getActionReviewFields: () => getActionReviewFields,
|
173
|
+
getAllAnnotationFields: () => getAllAnnotationFields,
|
174
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
149
175
|
getCurrentEventState: () => getCurrentEventState,
|
150
176
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
getVisiblePagesFormFields: () => getVisiblePagesFormFields,
|
177
|
+
getDeclaration: () => getDeclaration,
|
178
|
+
getDeclarationFields: () => getDeclarationFields,
|
179
|
+
getDeclarationPages: () => getDeclarationPages,
|
180
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
156
181
|
isAddressFieldType: () => isAddressFieldType,
|
157
182
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
158
183
|
isBulletListFieldType: () => isBulletListFieldType,
|
159
184
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
185
|
+
isConditionMet: () => isConditionMet,
|
160
186
|
isCountryFieldType: () => isCountryFieldType,
|
161
187
|
isDataFieldType: () => isDataFieldType,
|
162
188
|
isDateFieldType: () => isDateFieldType,
|
@@ -164,6 +190,7 @@ __export(events_exports, {
|
|
164
190
|
isEmailFieldType: () => isEmailFieldType,
|
165
191
|
isFacilityFieldType: () => isFacilityFieldType,
|
166
192
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
193
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
167
194
|
isFieldEnabled: () => isFieldEnabled,
|
168
195
|
isFieldValue: () => isFieldValue,
|
169
196
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -184,50 +211,71 @@ __export(events_exports, {
|
|
184
211
|
isTextFieldType: () => isTextFieldType,
|
185
212
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
186
213
|
isVerificationPage: () => isVerificationPage,
|
214
|
+
isWriteAction: () => isWriteAction,
|
187
215
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
188
216
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
189
217
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
218
|
+
never: () => never,
|
190
219
|
not: () => not,
|
220
|
+
omitHiddenFields: () => omitHiddenFields,
|
221
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
191
222
|
or: () => or,
|
192
|
-
|
193
|
-
stripHiddenFields: () => stripHiddenFields,
|
223
|
+
runFieldValidations: () => runFieldValidations,
|
194
224
|
user: () => user,
|
195
225
|
validate: () => validate,
|
196
226
|
validateFieldInput: () => validateFieldInput,
|
197
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
227
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
228
|
+
writeActions: () => writeActions
|
198
229
|
});
|
199
230
|
module.exports = __toCommonJS(events_exports);
|
200
231
|
|
201
232
|
// ../commons/src/events/ActionConfig.ts
|
202
|
-
var
|
233
|
+
var import_zod9 = require("zod");
|
203
234
|
|
204
235
|
// ../commons/src/events/Conditional.ts
|
205
236
|
var import_zod = require("zod");
|
206
|
-
|
207
|
-
|
208
|
-
|
237
|
+
var Conditional = import_zod.z.custom(
|
238
|
+
(val) => typeof val === "object" && val !== null
|
239
|
+
);
|
209
240
|
var ConditionalType = {
|
210
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
211
241
|
SHOW: "SHOW",
|
212
|
-
|
213
|
-
|
242
|
+
ENABLE: "ENABLE",
|
243
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
214
244
|
};
|
215
245
|
var ShowConditional = import_zod.z.object({
|
216
246
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
217
|
-
conditional: Conditional
|
218
|
-
})
|
247
|
+
conditional: Conditional
|
248
|
+
}).describe(
|
249
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
250
|
+
);
|
219
251
|
var EnableConditional = import_zod.z.object({
|
220
252
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
221
|
-
conditional: Conditional
|
222
|
-
})
|
253
|
+
conditional: Conditional
|
254
|
+
}).describe(
|
255
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
256
|
+
);
|
223
257
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
224
258
|
// Action can be shown / hidden
|
225
259
|
ShowConditional,
|
226
260
|
// Action can be shown to the user in the list but as disabled
|
227
261
|
EnableConditional
|
228
262
|
]);
|
263
|
+
var DisplayOnReviewConditional = import_zod.z.object({
|
264
|
+
type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
265
|
+
conditional: Conditional
|
266
|
+
}).describe(
|
267
|
+
"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."
|
268
|
+
);
|
269
|
+
var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
270
|
+
// Field input can be shown / hidden
|
271
|
+
ShowConditional,
|
272
|
+
// Field input can be shown to the user but as disabled
|
273
|
+
EnableConditional,
|
274
|
+
// Field output can be shown / hidden on the review page
|
275
|
+
DisplayOnReviewConditional
|
276
|
+
]);
|
229
277
|
|
230
|
-
// ../commons/src/events/
|
278
|
+
// ../commons/src/events/PageConfig.ts
|
231
279
|
var import_zod6 = require("zod");
|
232
280
|
|
233
281
|
// ../commons/src/events/FieldConfig.ts
|
@@ -413,14 +461,14 @@ var BaseField = import_zod5.z.object({
|
|
413
461
|
]),
|
414
462
|
DependencyExpression
|
415
463
|
]).optional(),
|
416
|
-
conditionals: import_zod5.z.array(
|
464
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
417
465
|
required: import_zod5.z.boolean().default(false).optional(),
|
418
466
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
419
467
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
420
468
|
placeholder: TranslationConfig.optional(),
|
421
469
|
validation: import_zod5.z.array(
|
422
470
|
import_zod5.z.object({
|
423
|
-
validator: Conditional
|
471
|
+
validator: Conditional,
|
424
472
|
message: TranslationConfig
|
425
473
|
})
|
426
474
|
).default([]).optional(),
|
@@ -530,7 +578,8 @@ var File = BaseField.extend({
|
|
530
578
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
531
579
|
"Whether the file upload button should take the full width of the container or not"
|
532
580
|
)
|
533
|
-
}).optional()
|
581
|
+
}).optional(),
|
582
|
+
fileName: TranslationConfig.optional()
|
534
583
|
}).default({
|
535
584
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
536
585
|
})
|
@@ -579,7 +628,7 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
579
628
|
]);
|
580
629
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
581
630
|
partOf: import_zod5.z.object({
|
582
|
-
$
|
631
|
+
$declaration: import_zod5.z.string()
|
583
632
|
}).optional().describe("Parent location"),
|
584
633
|
type: AdministrativeAreas
|
585
634
|
}).describe("Administrative area options");
|
@@ -614,11 +663,20 @@ var Address = BaseField.extend({
|
|
614
663
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
615
664
|
defaultValue: AddressFieldValue.optional()
|
616
665
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
666
|
+
var DataEntry = import_zod5.z.union([
|
667
|
+
import_zod5.z.object({
|
668
|
+
label: TranslationConfig,
|
669
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
670
|
+
}),
|
671
|
+
import_zod5.z.object({
|
672
|
+
fieldId: import_zod5.z.string()
|
673
|
+
})
|
674
|
+
]);
|
617
675
|
var DataField = BaseField.extend({
|
618
676
|
type: import_zod5.z.literal(FieldType.DATA),
|
619
677
|
configuration: import_zod5.z.object({
|
620
678
|
subtitle: TranslationConfig.optional(),
|
621
|
-
data: import_zod5.z.array(
|
679
|
+
data: import_zod5.z.array(DataEntry)
|
622
680
|
})
|
623
681
|
}).describe("Data field for displaying read-only data");
|
624
682
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
@@ -644,23 +702,23 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
644
702
|
EmailField,
|
645
703
|
FileUploadWithOptions,
|
646
704
|
DataField
|
705
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
647
706
|
]);
|
648
707
|
|
649
|
-
// ../commons/src/events/
|
650
|
-
var
|
651
|
-
|
652
|
-
VERIFICATION: "VERIFICATION"
|
653
|
-
};
|
654
|
-
var FormPage = import_zod6.z.object({
|
708
|
+
// ../commons/src/events/PageConfig.ts
|
709
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
710
|
+
var PageConfigBase = import_zod6.z.object({
|
655
711
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
656
|
-
type: import_zod6.z.literal(FormPageType.FORM).default(FormPageType.FORM),
|
657
712
|
title: TranslationConfig.describe("Header title of the page"),
|
658
713
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
659
|
-
conditional: Conditional
|
714
|
+
conditional: Conditional.optional().describe(
|
660
715
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
661
716
|
)
|
662
717
|
});
|
663
|
-
var
|
718
|
+
var FormPageConfig = PageConfigBase.extend({
|
719
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
720
|
+
});
|
721
|
+
var VerificationActionConfig = import_zod6.z.object({
|
664
722
|
verify: import_zod6.z.object({ label: TranslationConfig }),
|
665
723
|
cancel: import_zod6.z.object({
|
666
724
|
label: TranslationConfig,
|
@@ -670,136 +728,182 @@ var VerificationPageConfig = import_zod6.z.object({
|
|
670
728
|
})
|
671
729
|
})
|
672
730
|
}).describe("Actions available on the verification page");
|
673
|
-
var
|
674
|
-
type: import_zod6.z.literal(
|
675
|
-
actions:
|
676
|
-
});
|
677
|
-
var FormPageConfig = import_zod6.z.preprocess(
|
678
|
-
(pageConfig) => ({
|
679
|
-
...pageConfig,
|
680
|
-
type: pageConfig.type ?? FormPageType.FORM
|
681
|
-
// Default type to "FORM" if not provided
|
682
|
-
}),
|
683
|
-
import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
|
684
|
-
);
|
685
|
-
var FormConfig = import_zod6.z.object({
|
686
|
-
label: TranslationConfig.describe("Human readable description of the form"),
|
687
|
-
version: import_zod6.z.object({
|
688
|
-
id: import_zod6.z.string().describe(
|
689
|
-
"Form version. Semantic versioning recommended. Example: 0.0.1"
|
690
|
-
),
|
691
|
-
label: TranslationConfig.describe(
|
692
|
-
"Human readable description of the version"
|
693
|
-
)
|
694
|
-
}),
|
695
|
-
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
696
|
-
pages: import_zod6.z.array(FormPageConfig),
|
697
|
-
review: import_zod6.z.object({
|
698
|
-
title: TranslationConfig.describe(
|
699
|
-
"Title of the form to show in review page"
|
700
|
-
),
|
701
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
702
|
-
})
|
731
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
732
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
733
|
+
actions: VerificationActionConfig
|
703
734
|
});
|
735
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
736
|
+
FormPageConfig,
|
737
|
+
VerificationPageConfig
|
738
|
+
]);
|
704
739
|
|
705
740
|
// ../commons/src/events/ActionType.ts
|
741
|
+
var import_zod7 = require("zod");
|
706
742
|
var ActionType = {
|
743
|
+
// Pre-declaration actions
|
744
|
+
DELETE: "DELETE",
|
707
745
|
CREATE: "CREATE",
|
708
|
-
ASSIGN: "ASSIGN",
|
709
|
-
UNASSIGN: "UNASSIGN",
|
710
|
-
REGISTER: "REGISTER",
|
711
|
-
VALIDATE: "VALIDATE",
|
712
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
713
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
714
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
715
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
716
746
|
NOTIFY: "NOTIFY",
|
747
|
+
// Declaration actions
|
717
748
|
DECLARE: "DECLARE",
|
718
|
-
|
719
|
-
|
720
|
-
|
749
|
+
VALIDATE: "VALIDATE",
|
750
|
+
REGISTER: "REGISTER",
|
751
|
+
// Declaration system actions. Non-configurable.
|
752
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
721
753
|
REJECT: "REJECT",
|
754
|
+
// REJECT_DECLARATION
|
722
755
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
723
|
-
|
756
|
+
// MARK_AS_DUPLICATE
|
757
|
+
ARCHIVE: "ARCHIVE",
|
758
|
+
// Record actions
|
759
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
760
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
761
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
762
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
763
|
+
// General actions
|
764
|
+
READ: "READ",
|
765
|
+
ASSIGN: "ASSIGN",
|
766
|
+
UNASSIGN: "UNASSIGN"
|
724
767
|
};
|
725
|
-
var
|
768
|
+
var ConfirmableActions = [
|
769
|
+
ActionType.NOTIFY,
|
770
|
+
ActionType.DECLARE,
|
771
|
+
ActionType.VALIDATE,
|
772
|
+
ActionType.REGISTER,
|
773
|
+
ActionType.REJECT,
|
774
|
+
ActionType.ARCHIVE,
|
775
|
+
ActionType.PRINT_CERTIFICATE
|
776
|
+
];
|
777
|
+
var ActionTypes = import_zod7.z.enum([
|
778
|
+
"DELETE",
|
779
|
+
"CREATE",
|
780
|
+
"NOTIFY",
|
781
|
+
"DECLARE",
|
782
|
+
"VALIDATE",
|
783
|
+
"REGISTER",
|
784
|
+
"DETECT_DUPLICATE",
|
785
|
+
"REJECT",
|
786
|
+
"MARKED_AS_DUPLICATE",
|
787
|
+
"ARCHIVE",
|
788
|
+
"PRINT_CERTIFICATE",
|
789
|
+
"REQUEST_CORRECTION",
|
790
|
+
"REJECT_CORRECTION",
|
791
|
+
"APPROVE_CORRECTION",
|
792
|
+
"READ",
|
793
|
+
"ASSIGN",
|
794
|
+
"UNASSIGN"
|
795
|
+
]);
|
796
|
+
var declarationActionValues = [
|
797
|
+
ActionTypes.enum.DECLARE,
|
798
|
+
ActionTypes.enum.VALIDATE,
|
799
|
+
ActionTypes.enum.REGISTER
|
800
|
+
];
|
801
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
802
|
+
var declarationUpdateActionValues = [
|
803
|
+
...declarationActionValues,
|
804
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
805
|
+
];
|
806
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
807
|
+
declarationUpdateActionValues
|
808
|
+
);
|
809
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
810
|
+
var writeActions = ActionTypes.exclude([
|
811
|
+
ActionType.CREATE,
|
812
|
+
ActionType.READ,
|
813
|
+
ActionType.ASSIGN,
|
814
|
+
ActionType.UNASSIGN
|
815
|
+
]);
|
816
|
+
|
817
|
+
// ../commons/src/events/FormConfig.ts
|
818
|
+
var import_zod8 = require("zod");
|
819
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
820
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
821
|
+
pages: import_zod8.z.array(FormPageConfig)
|
822
|
+
}).describe("Configuration for a declaration form");
|
823
|
+
var ActionFormConfig = import_zod8.z.object({
|
824
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
825
|
+
pages: import_zod8.z.array(PageConfig)
|
826
|
+
});
|
827
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
726
828
|
|
727
829
|
// ../commons/src/events/ActionConfig.ts
|
728
|
-
var ActionConditional2 =
|
830
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
729
831
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
730
832
|
ShowConditional,
|
731
833
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
732
834
|
EnableConditional
|
733
835
|
]);
|
734
|
-
var
|
836
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
837
|
+
title: TranslationConfig.describe("Title of the review page"),
|
838
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
839
|
+
}).describe("Configuration for **declaration** review page.");
|
840
|
+
var ActionConfigBase = import_zod9.z.object({
|
735
841
|
label: TranslationConfig,
|
736
|
-
conditionals:
|
737
|
-
draft:
|
738
|
-
forms: import_zod7.z.array(FormConfig)
|
842
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
843
|
+
draft: import_zod9.z.boolean().optional()
|
739
844
|
});
|
740
845
|
var DeclareConfig = ActionConfigBase.merge(
|
741
|
-
|
742
|
-
type:
|
846
|
+
import_zod9.z.object({
|
847
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
848
|
+
review: DeclarationReviewConfig
|
743
849
|
})
|
744
850
|
);
|
745
851
|
var ValidateConfig = ActionConfigBase.merge(
|
746
|
-
|
747
|
-
type:
|
852
|
+
import_zod9.z.object({
|
853
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
854
|
+
review: DeclarationReviewConfig
|
855
|
+
})
|
856
|
+
);
|
857
|
+
var RegisterConfig = ActionConfigBase.merge(
|
858
|
+
import_zod9.z.object({
|
859
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
860
|
+
review: DeclarationReviewConfig
|
748
861
|
})
|
749
862
|
);
|
750
863
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
751
|
-
|
752
|
-
type:
|
864
|
+
import_zod9.z.object({
|
865
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
753
866
|
})
|
754
867
|
);
|
755
868
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
756
|
-
|
757
|
-
type:
|
869
|
+
import_zod9.z.object({
|
870
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
758
871
|
})
|
759
872
|
);
|
760
873
|
var ArchiveConfig = ActionConfigBase.merge(
|
761
|
-
|
762
|
-
type:
|
763
|
-
})
|
764
|
-
);
|
765
|
-
var RegisterConfig = ActionConfigBase.merge(
|
766
|
-
import_zod7.z.object({
|
767
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
874
|
+
import_zod9.z.object({
|
875
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
768
876
|
})
|
769
877
|
);
|
770
878
|
var DeleteConfig = ActionConfigBase.merge(
|
771
|
-
|
772
|
-
type:
|
879
|
+
import_zod9.z.object({
|
880
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
773
881
|
})
|
774
882
|
);
|
775
883
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
776
|
-
|
777
|
-
type:
|
884
|
+
import_zod9.z.object({
|
885
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
886
|
+
printForm: ActionFormConfig
|
778
887
|
})
|
779
888
|
);
|
780
889
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
781
|
-
|
782
|
-
type:
|
783
|
-
onboardingForm:
|
784
|
-
additionalDetailsForm:
|
890
|
+
import_zod9.z.object({
|
891
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
892
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
893
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
785
894
|
})
|
786
895
|
);
|
787
896
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
788
|
-
|
789
|
-
type:
|
897
|
+
import_zod9.z.object({
|
898
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
790
899
|
})
|
791
900
|
);
|
792
901
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
793
|
-
|
794
|
-
type:
|
795
|
-
})
|
796
|
-
);
|
797
|
-
var CustomConfig = ActionConfigBase.merge(
|
798
|
-
import_zod7.z.object({
|
799
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
902
|
+
import_zod9.z.object({
|
903
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
800
904
|
})
|
801
905
|
);
|
802
|
-
var ActionConfig =
|
906
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
803
907
|
DeclareConfig,
|
804
908
|
ValidateConfig,
|
805
909
|
RejectDeclarationConfig,
|
@@ -810,102 +914,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
810
914
|
PrintCertificateActionConfig,
|
811
915
|
RequestCorrectionConfig,
|
812
916
|
RejectCorrectionConfig,
|
813
|
-
ApproveCorrectionConfig
|
814
|
-
|
917
|
+
ApproveCorrectionConfig
|
918
|
+
]);
|
919
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
920
|
+
DeclareConfig,
|
921
|
+
ValidateConfig,
|
922
|
+
RegisterConfig
|
815
923
|
]);
|
816
924
|
|
817
925
|
// ../commons/src/events/offline/CertificateConfig.ts
|
818
|
-
var
|
819
|
-
var FontFamily =
|
820
|
-
normal:
|
821
|
-
bold:
|
822
|
-
italics:
|
823
|
-
bolditalics:
|
926
|
+
var import_zod10 = require("zod");
|
927
|
+
var FontFamily = import_zod10.z.object({
|
928
|
+
normal: import_zod10.z.string(),
|
929
|
+
bold: import_zod10.z.string(),
|
930
|
+
italics: import_zod10.z.string(),
|
931
|
+
bolditalics: import_zod10.z.string()
|
824
932
|
});
|
825
|
-
var CertificateConfig =
|
826
|
-
id:
|
827
|
-
event:
|
933
|
+
var CertificateConfig = import_zod10.z.object({
|
934
|
+
id: import_zod10.z.string(),
|
935
|
+
event: import_zod10.z.string(),
|
828
936
|
label: TranslationConfig,
|
829
|
-
isDefault:
|
830
|
-
fee:
|
831
|
-
onTime:
|
832
|
-
late:
|
833
|
-
delayed:
|
937
|
+
isDefault: import_zod10.z.boolean(),
|
938
|
+
fee: import_zod10.z.object({
|
939
|
+
onTime: import_zod10.z.number(),
|
940
|
+
late: import_zod10.z.number(),
|
941
|
+
delayed: import_zod10.z.number()
|
834
942
|
}),
|
835
|
-
svgUrl:
|
836
|
-
fonts:
|
943
|
+
svgUrl: import_zod10.z.string(),
|
944
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
837
945
|
});
|
838
946
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
839
|
-
hash:
|
840
|
-
svg:
|
947
|
+
hash: import_zod10.z.string().optional(),
|
948
|
+
svg: import_zod10.z.string()
|
841
949
|
});
|
842
950
|
|
843
951
|
// ../commons/src/events/offline/LanguageConfig.ts
|
844
|
-
var
|
845
|
-
var LanguageConfig =
|
846
|
-
lang:
|
952
|
+
var import_zod11 = require("zod");
|
953
|
+
var LanguageConfig = import_zod11.z.object({
|
954
|
+
lang: import_zod11.z.string(),
|
847
955
|
/**
|
848
956
|
* client.csv contents
|
849
957
|
*/
|
850
|
-
messages:
|
958
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
851
959
|
});
|
852
960
|
|
853
961
|
// ../commons/src/events/EventConfig.ts
|
854
|
-
var
|
962
|
+
var import_zod20 = require("zod");
|
855
963
|
|
856
964
|
// ../commons/src/events/DeduplicationConfig.ts
|
857
|
-
var
|
858
|
-
var FieldReference =
|
859
|
-
var Matcher =
|
860
|
-
fieldId:
|
861
|
-
options:
|
862
|
-
boost:
|
965
|
+
var import_zod12 = require("zod");
|
966
|
+
var FieldReference = import_zod12.z.string();
|
967
|
+
var Matcher = import_zod12.z.object({
|
968
|
+
fieldId: import_zod12.z.string(),
|
969
|
+
options: import_zod12.z.object({
|
970
|
+
boost: import_zod12.z.number().optional()
|
863
971
|
}).optional().default({})
|
864
972
|
});
|
865
973
|
var FuzzyMatcher = Matcher.extend({
|
866
|
-
type:
|
867
|
-
options:
|
974
|
+
type: import_zod12.z.literal("fuzzy"),
|
975
|
+
options: import_zod12.z.object({
|
868
976
|
/**
|
869
977
|
* Names of length 3 or less characters = 0 edits allowed
|
870
978
|
* Names of length 4 - 6 characters = 1 edit allowed
|
871
979
|
* Names of length >7 characters = 2 edits allowed
|
872
980
|
*/
|
873
|
-
fuzziness:
|
874
|
-
boost:
|
981
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
982
|
+
boost: import_zod12.z.number().optional().default(1)
|
875
983
|
}).optional().default({})
|
876
984
|
});
|
877
985
|
var StrictMatcher = Matcher.extend({
|
878
|
-
type:
|
879
|
-
options:
|
880
|
-
boost:
|
986
|
+
type: import_zod12.z.literal("strict"),
|
987
|
+
options: import_zod12.z.object({
|
988
|
+
boost: import_zod12.z.number().optional().default(1)
|
881
989
|
}).optional().default({})
|
882
990
|
});
|
883
991
|
var DateRangeMatcher = Matcher.extend({
|
884
|
-
type:
|
885
|
-
options:
|
886
|
-
days:
|
992
|
+
type: import_zod12.z.literal("dateRange"),
|
993
|
+
options: import_zod12.z.object({
|
994
|
+
days: import_zod12.z.number(),
|
887
995
|
origin: FieldReference,
|
888
|
-
boost:
|
996
|
+
boost: import_zod12.z.number().optional().default(1)
|
889
997
|
})
|
890
998
|
});
|
891
999
|
var DateDistanceMatcher = Matcher.extend({
|
892
|
-
type:
|
893
|
-
options:
|
894
|
-
days:
|
1000
|
+
type: import_zod12.z.literal("dateDistance"),
|
1001
|
+
options: import_zod12.z.object({
|
1002
|
+
days: import_zod12.z.number(),
|
895
1003
|
origin: FieldReference,
|
896
|
-
boost:
|
1004
|
+
boost: import_zod12.z.number().optional().default(1)
|
897
1005
|
})
|
898
1006
|
});
|
899
|
-
var And =
|
900
|
-
type:
|
901
|
-
|
1007
|
+
var And = import_zod12.z.object({
|
1008
|
+
type: import_zod12.z.literal("and"),
|
1009
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1010
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
902
1011
|
});
|
903
|
-
var Or =
|
904
|
-
type:
|
905
|
-
|
1012
|
+
var Or = import_zod12.z.object({
|
1013
|
+
type: import_zod12.z.literal("or"),
|
1014
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1015
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
906
1016
|
});
|
907
|
-
var Clause =
|
908
|
-
() =>
|
1017
|
+
var Clause = import_zod12.z.lazy(
|
1018
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
909
1019
|
And,
|
910
1020
|
Or,
|
911
1021
|
FuzzyMatcher,
|
@@ -914,37 +1024,44 @@ var Clause = import_zod10.z.lazy(
|
|
914
1024
|
DateDistanceMatcher
|
915
1025
|
])
|
916
1026
|
);
|
917
|
-
var DeduplicationConfig =
|
918
|
-
id:
|
1027
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1028
|
+
id: import_zod12.z.string(),
|
919
1029
|
label: TranslationConfig,
|
920
1030
|
query: Clause
|
921
1031
|
});
|
922
1032
|
|
923
1033
|
// ../commons/src/events/SummaryConfig.ts
|
924
|
-
var
|
925
|
-
var
|
926
|
-
|
1034
|
+
var import_zod13 = require("zod");
|
1035
|
+
var BaseField2 = import_zod13.z.object({
|
1036
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1037
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1038
|
+
});
|
1039
|
+
var ReferenceField = BaseField2.extend({
|
1040
|
+
fieldId: import_zod13.z.string()
|
1041
|
+
}).describe("Field directly referencing event data with field id");
|
1042
|
+
var Field = BaseField2.extend({
|
1043
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
927
1044
|
value: TranslationConfig.describe(
|
928
1045
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
929
1046
|
),
|
930
1047
|
label: TranslationConfig,
|
931
1048
|
emptyValueMessage: TranslationConfig.optional()
|
932
|
-
});
|
933
|
-
var Title =
|
934
|
-
id:
|
1049
|
+
}).describe("Custom configured field");
|
1050
|
+
var Title = import_zod13.z.object({
|
1051
|
+
id: import_zod13.z.string(),
|
935
1052
|
label: TranslationConfig.describe("Title content"),
|
936
1053
|
emptyValueMessage: TranslationConfig.optional()
|
937
1054
|
});
|
938
|
-
var SummaryConfig =
|
1055
|
+
var SummaryConfig = import_zod13.z.object({
|
939
1056
|
title: Title.describe("Title of summary view."),
|
940
|
-
fields:
|
1057
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
941
1058
|
}).describe("Configuration for summary in event.");
|
942
1059
|
|
943
1060
|
// ../commons/src/events/WorkqueueConfig.ts
|
944
|
-
var
|
1061
|
+
var import_zod15 = require("zod");
|
945
1062
|
|
946
1063
|
// ../commons/src/events/EventMetadata.ts
|
947
|
-
var
|
1064
|
+
var import_zod14 = require("zod");
|
948
1065
|
var EventStatus = {
|
949
1066
|
CREATED: "CREATED",
|
950
1067
|
NOTIFIED: "NOTIFIED",
|
@@ -956,18 +1073,20 @@ var EventStatus = {
|
|
956
1073
|
ARCHIVED: "ARCHIVED"
|
957
1074
|
};
|
958
1075
|
var eventStatuses = Object.values(EventStatus);
|
959
|
-
var EventStatuses =
|
960
|
-
var EventMetadata =
|
961
|
-
id:
|
962
|
-
type:
|
1076
|
+
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1077
|
+
var EventMetadata = import_zod14.z.object({
|
1078
|
+
id: import_zod14.z.string(),
|
1079
|
+
type: import_zod14.z.string(),
|
963
1080
|
status: EventStatuses,
|
964
|
-
createdAt:
|
965
|
-
createdBy:
|
966
|
-
createdAtLocation:
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
1081
|
+
createdAt: import_zod14.z.string().datetime(),
|
1082
|
+
createdBy: import_zod14.z.string(),
|
1083
|
+
createdAtLocation: import_zod14.z.string(),
|
1084
|
+
updatedAtLocation: import_zod14.z.string(),
|
1085
|
+
modifiedAt: import_zod14.z.string().datetime(),
|
1086
|
+
assignedTo: import_zod14.z.string().nullish(),
|
1087
|
+
updatedBy: import_zod14.z.string(),
|
1088
|
+
trackingId: import_zod14.z.string(),
|
1089
|
+
registrationNumber: import_zod14.z.string().nullish()
|
971
1090
|
});
|
972
1091
|
var eventMetadataLabelMap = {
|
973
1092
|
"event.assignedTo": {
|
@@ -985,6 +1104,11 @@ var eventMetadataLabelMap = {
|
|
985
1104
|
defaultMessage: "Location",
|
986
1105
|
description: "Created At Location"
|
987
1106
|
},
|
1107
|
+
"event.updatedAtLocation": {
|
1108
|
+
id: "event.updatedAtLocation.label",
|
1109
|
+
defaultMessage: "Location",
|
1110
|
+
description: "Updated At Location"
|
1111
|
+
},
|
988
1112
|
"event.createdBy": {
|
989
1113
|
id: "event.createdBy.label",
|
990
1114
|
defaultMessage: "Created By",
|
@@ -1019,28 +1143,33 @@ var eventMetadataLabelMap = {
|
|
1019
1143
|
id: "event.trackingId.label",
|
1020
1144
|
defaultMessage: "Tracking ID",
|
1021
1145
|
description: "Tracking ID"
|
1146
|
+
},
|
1147
|
+
"event.registrationNumber": {
|
1148
|
+
id: "event.registrationNumber.label",
|
1149
|
+
defaultMessage: "Registration Number",
|
1150
|
+
description: "Registration Number"
|
1022
1151
|
}
|
1023
1152
|
};
|
1024
1153
|
|
1025
1154
|
// ../commons/src/events/WorkqueueConfig.ts
|
1026
|
-
var WorkqueueConfig =
|
1027
|
-
id:
|
1028
|
-
filters:
|
1029
|
-
|
1030
|
-
status:
|
1155
|
+
var WorkqueueConfig = import_zod15.z.object({
|
1156
|
+
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1157
|
+
filters: import_zod15.z.array(
|
1158
|
+
import_zod15.z.object({
|
1159
|
+
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1031
1160
|
})
|
1032
1161
|
).describe("Filters to be applied to workqueue.")
|
1033
1162
|
}).describe("Configuration for workqueue.");
|
1034
1163
|
|
1035
1164
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1036
|
-
var
|
1037
|
-
var AdvancedSearchConfig =
|
1165
|
+
var import_zod16 = require("zod");
|
1166
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
1038
1167
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1039
|
-
fields:
|
1040
|
-
|
1041
|
-
fieldId:
|
1042
|
-
config:
|
1043
|
-
type:
|
1168
|
+
fields: import_zod16.z.array(
|
1169
|
+
import_zod16.z.object({
|
1170
|
+
fieldId: import_zod16.z.string(),
|
1171
|
+
config: import_zod16.z.object({
|
1172
|
+
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1044
1173
|
}).optional().describe("Configuration options for the field")
|
1045
1174
|
})
|
1046
1175
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -1050,12 +1179,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1050
1179
|
var import_lodash = require("lodash");
|
1051
1180
|
|
1052
1181
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1053
|
-
var
|
1182
|
+
var import_zod18 = require("zod");
|
1054
1183
|
|
1055
1184
|
// ../commons/src/workqueues/defaultColumns.ts
|
1056
|
-
var
|
1057
|
-
var WorkQueueColumnConfig =
|
1058
|
-
id:
|
1185
|
+
var import_zod17 = require("zod");
|
1186
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1187
|
+
id: import_zod17.z.string(),
|
1059
1188
|
label: TranslationConfig
|
1060
1189
|
});
|
1061
1190
|
var defaultColumns = {
|
@@ -1092,16 +1221,16 @@ var defaultColumns = {
|
|
1092
1221
|
}
|
1093
1222
|
}
|
1094
1223
|
};
|
1095
|
-
var DefaultColumnKeys =
|
1224
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
1096
1225
|
Object.keys(defaultColumns)
|
1097
1226
|
);
|
1098
1227
|
|
1099
1228
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1100
|
-
var rootWorkqueueConfig =
|
1101
|
-
id:
|
1229
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1230
|
+
id: import_zod18.z.string(),
|
1102
1231
|
title: TranslationConfig,
|
1103
|
-
columns:
|
1104
|
-
defaultColumns:
|
1232
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1233
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1105
1234
|
});
|
1106
1235
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1107
1236
|
|
@@ -1181,7 +1310,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1181
1310
|
var import_date_fns = require("date-fns");
|
1182
1311
|
|
1183
1312
|
// ../commons/src/events/FieldTypeMapping.ts
|
1184
|
-
var
|
1313
|
+
var import_zod19 = require("zod");
|
1185
1314
|
function mapFieldTypeToZod(type, required) {
|
1186
1315
|
let schema;
|
1187
1316
|
switch (type) {
|
@@ -1234,7 +1363,7 @@ function createValidationSchema(config) {
|
|
1234
1363
|
for (const field2 of config) {
|
1235
1364
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1236
1365
|
}
|
1237
|
-
return
|
1366
|
+
return import_zod19.z.object(shape);
|
1238
1367
|
}
|
1239
1368
|
function mapFieldTypeToMockValue(field2, i) {
|
1240
1369
|
switch (field2.type) {
|
@@ -1401,18 +1530,30 @@ var isDataFieldType = (field2) => {
|
|
1401
1530
|
|
1402
1531
|
// ../commons/src/conditionals/validate.ts
|
1403
1532
|
var ajv = new import_ajv.default({
|
1404
|
-
$data: true
|
1533
|
+
$data: true,
|
1534
|
+
allowUnionTypes: true
|
1405
1535
|
});
|
1406
1536
|
(0, import_ajv_formats.default)(ajv);
|
1407
1537
|
function validate(schema, data) {
|
1408
1538
|
return ajv.validate(schema, data);
|
1409
1539
|
}
|
1540
|
+
function isConditionMet(conditional, values) {
|
1541
|
+
return validate(conditional, {
|
1542
|
+
$form: values,
|
1543
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1544
|
+
});
|
1545
|
+
}
|
1410
1546
|
function getConditionalActionsForField(field2, values) {
|
1411
1547
|
if (!field2.conditionals) {
|
1412
1548
|
return [];
|
1413
1549
|
}
|
1414
1550
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1415
1551
|
}
|
1552
|
+
function areConditionsMet(conditions, values) {
|
1553
|
+
return conditions.every(
|
1554
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1555
|
+
);
|
1556
|
+
}
|
1416
1557
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1417
1558
|
const hasRule = (field2.conditionals ?? []).some(
|
1418
1559
|
(conditional) => conditional.type === conditionalType
|
@@ -1434,6 +1575,9 @@ function isFieldVisible(field2, form) {
|
|
1434
1575
|
function isFieldEnabled(field2, form) {
|
1435
1576
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1436
1577
|
}
|
1578
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1579
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1580
|
+
}
|
1437
1581
|
var errorMessages = {
|
1438
1582
|
hiddenField: {
|
1439
1583
|
id: "v2.error.hidden",
|
@@ -1461,12 +1605,14 @@ var errorMessages = {
|
|
1461
1605
|
id: "v2.error.invalid"
|
1462
1606
|
}
|
1463
1607
|
};
|
1464
|
-
|
1465
|
-
|
1466
|
-
message
|
1467
|
-
|
1468
|
-
}
|
1469
|
-
|
1608
|
+
function createIntlError(message) {
|
1609
|
+
return {
|
1610
|
+
message: {
|
1611
|
+
message
|
1612
|
+
}
|
1613
|
+
};
|
1614
|
+
}
|
1615
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1470
1616
|
switch (issue.code) {
|
1471
1617
|
case "invalid_string": {
|
1472
1618
|
if (_ctx.data === "") {
|
@@ -1504,41 +1650,6 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1504
1650
|
}
|
1505
1651
|
}
|
1506
1652
|
return createIntlError(errorMessages.invalidInput);
|
1507
|
-
};
|
1508
|
-
function getFieldValidationErrors({
|
1509
|
-
field: field2,
|
1510
|
-
values
|
1511
|
-
}) {
|
1512
|
-
const conditionalParameters = {
|
1513
|
-
$form: values,
|
1514
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1515
|
-
};
|
1516
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1517
|
-
if (values[field2.id]) {
|
1518
|
-
return {
|
1519
|
-
errors: [
|
1520
|
-
{
|
1521
|
-
message: errorMessages.hiddenField
|
1522
|
-
}
|
1523
|
-
]
|
1524
|
-
};
|
1525
|
-
}
|
1526
|
-
return {
|
1527
|
-
errors: []
|
1528
|
-
};
|
1529
|
-
}
|
1530
|
-
const fieldValidationResult = validateFieldInput({
|
1531
|
-
field: field2,
|
1532
|
-
value: values[field2.id]
|
1533
|
-
});
|
1534
|
-
const customValidationResults = runCustomFieldValidations({
|
1535
|
-
field: field2,
|
1536
|
-
conditionalParameters
|
1537
|
-
});
|
1538
|
-
return {
|
1539
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1540
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1541
|
-
};
|
1542
1653
|
}
|
1543
1654
|
function runCustomFieldValidations({
|
1544
1655
|
field: field2,
|
@@ -1561,13 +1672,31 @@ function validateFieldInput({
|
|
1561
1672
|
);
|
1562
1673
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1563
1674
|
}
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1675
|
+
function runFieldValidations({
|
1676
|
+
field: field2,
|
1677
|
+
values
|
1678
|
+
}) {
|
1679
|
+
if (!isFieldVisible(field2, values)) {
|
1680
|
+
return {
|
1681
|
+
errors: []
|
1682
|
+
};
|
1569
1683
|
}
|
1570
|
-
|
1684
|
+
const conditionalParameters = {
|
1685
|
+
$form: values,
|
1686
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1687
|
+
};
|
1688
|
+
const fieldValidationResult = validateFieldInput({
|
1689
|
+
field: field2,
|
1690
|
+
value: values[field2.id]
|
1691
|
+
});
|
1692
|
+
const customValidationResults = runCustomFieldValidations({
|
1693
|
+
field: field2,
|
1694
|
+
conditionalParameters
|
1695
|
+
});
|
1696
|
+
return {
|
1697
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1698
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1699
|
+
};
|
1571
1700
|
}
|
1572
1701
|
|
1573
1702
|
// ../commons/src/uuid.ts
|
@@ -1576,68 +1705,72 @@ function getUUID() {
|
|
1576
1705
|
return (0, import_uuid.v4)();
|
1577
1706
|
}
|
1578
1707
|
|
1708
|
+
// ../commons/src/utils.ts
|
1709
|
+
function getOrThrow(x, message) {
|
1710
|
+
if (x === void 0 || x === null) {
|
1711
|
+
throw new Error(message);
|
1712
|
+
}
|
1713
|
+
return x;
|
1714
|
+
}
|
1715
|
+
|
1579
1716
|
// ../commons/src/events/utils.ts
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
)
|
1717
|
+
function isDeclarationActionConfig(action) {
|
1718
|
+
return DeclarationActions.safeParse(action.type).success;
|
1719
|
+
}
|
1720
|
+
function getDeclarationFields(configuration) {
|
1721
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1722
|
+
}
|
1723
|
+
function getDeclarationPages(configuration) {
|
1724
|
+
return configuration.declaration.pages;
|
1725
|
+
}
|
1726
|
+
function getDeclaration(configuration) {
|
1727
|
+
return configuration.declaration;
|
1728
|
+
}
|
1729
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1730
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1731
|
+
return [
|
1732
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1733
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1734
|
+
];
|
1735
|
+
}
|
1736
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1737
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1738
|
+
}
|
1739
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1740
|
+
return actionConfig.review.fields;
|
1741
|
+
}
|
1742
|
+
return [];
|
1594
1743
|
};
|
1595
|
-
var
|
1596
|
-
return (0, import_lodash.flattenDeep)(
|
1597
|
-
config.actions.map((action) => {
|
1598
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1599
|
-
return [
|
1600
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1601
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1602
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1603
|
-
];
|
1604
|
-
}
|
1605
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1606
|
-
})
|
1607
|
-
);
|
1744
|
+
var getAllAnnotationFields = (config) => {
|
1745
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1608
1746
|
};
|
1609
|
-
var
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
return refFields.map((field2) => {
|
1614
|
-
if (field2.label) {
|
1615
|
-
return field2;
|
1616
|
-
}
|
1617
|
-
if (isMetadataField(field2.id)) {
|
1618
|
-
return {
|
1619
|
-
...field2,
|
1620
|
-
label: eventMetadataLabelMap[field2.id]
|
1621
|
-
};
|
1622
|
-
}
|
1623
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1624
|
-
if (!pageLabel) {
|
1625
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1626
|
-
}
|
1627
|
-
return {
|
1628
|
-
...field2,
|
1629
|
-
label: pageLabel.label
|
1630
|
-
};
|
1631
|
-
});
|
1632
|
-
};
|
1633
|
-
function getAllFields(configuration) {
|
1634
|
-
return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
|
1635
|
-
...form.review.fields,
|
1636
|
-
...form.pages.flatMap((page) => page.fields)
|
1747
|
+
var findAllFields = (config) => {
|
1748
|
+
return (0, import_lodash.flattenDeep)([
|
1749
|
+
...getDeclarationFields(config),
|
1750
|
+
...getAllAnnotationFields(config)
|
1637
1751
|
]);
|
1752
|
+
};
|
1753
|
+
var findRecordActionPages = (config, actionType) => {
|
1754
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1755
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1756
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1757
|
+
}
|
1758
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1759
|
+
return action.printForm.pages;
|
1760
|
+
}
|
1761
|
+
return [];
|
1762
|
+
};
|
1763
|
+
function getActionReview(configuration, actionType) {
|
1764
|
+
const [actionConfig] = configuration.actions.filter(
|
1765
|
+
(a) => a.type === actionType
|
1766
|
+
);
|
1767
|
+
return getOrThrow(
|
1768
|
+
actionConfig.review,
|
1769
|
+
`No review config found for ${actionType}`
|
1770
|
+
);
|
1638
1771
|
}
|
1639
|
-
function
|
1640
|
-
return configuration
|
1772
|
+
function getActionReviewFields(configuration, actionType) {
|
1773
|
+
return getActionReview(configuration, actionType).fields;
|
1641
1774
|
}
|
1642
1775
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1643
1776
|
workqueueConfigs.map((workqueue) => {
|
@@ -1651,86 +1784,27 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1651
1784
|
}
|
1652
1785
|
});
|
1653
1786
|
}
|
1654
|
-
var findActiveActionForm = (configuration, action) => {
|
1655
|
-
const actionConfig = configuration.actions.find((a) => a.type === action);
|
1656
|
-
const form = actionConfig?.forms.find((f) => f.active);
|
1657
|
-
return form;
|
1658
|
-
};
|
1659
|
-
var findActiveActionFormPages = (configuration, action) => {
|
1660
|
-
return findActiveActionForm(configuration, action)?.pages;
|
1661
|
-
};
|
1662
|
-
var getFormFields = (formConfig) => {
|
1663
|
-
return formConfig.pages.flatMap((p) => p.fields);
|
1664
|
-
};
|
1665
1787
|
function isPageVisible(page, formValues) {
|
1666
1788
|
if (!page.conditional) {
|
1667
1789
|
return true;
|
1668
1790
|
}
|
1669
|
-
return
|
1670
|
-
$form: formValues,
|
1671
|
-
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1672
|
-
});
|
1673
|
-
}
|
1674
|
-
var getVisiblePagesFormFields = (formConfig, formData) => {
|
1675
|
-
return formConfig.pages.filter((p) => isPageVisible(p, formData)).flatMap((p) => p.fields);
|
1676
|
-
};
|
1677
|
-
var findActiveActionFormFields = (configuration, action) => {
|
1678
|
-
const form = findActiveActionForm(configuration, action);
|
1679
|
-
return form ? getFormFields(form) : void 0;
|
1680
|
-
};
|
1681
|
-
var findActiveActionFields = (configuration, action, formData) => {
|
1682
|
-
const form = findActiveActionForm(configuration, action);
|
1683
|
-
const reviewFields = form?.review.fields;
|
1684
|
-
let formFields = void 0;
|
1685
|
-
if (form) {
|
1686
|
-
formFields = formData ? getVisiblePagesFormFields(form, formData) : getFormFields(form);
|
1687
|
-
}
|
1688
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1689
|
-
return allFields;
|
1690
|
-
};
|
1691
|
-
var getActiveActionFormPages = (configuration, action) => {
|
1692
|
-
return getOrThrow(
|
1693
|
-
findActiveActionForm(configuration, action)?.pages,
|
1694
|
-
"Form configuration not found for type: " + configuration.id
|
1695
|
-
);
|
1696
|
-
};
|
1697
|
-
function getActiveActionFields(configuration, action) {
|
1698
|
-
if (LatentActions.some((latentAction) => latentAction === action)) {
|
1699
|
-
return getActiveActionFields(configuration, ActionType.DECLARE);
|
1700
|
-
}
|
1701
|
-
const fields = findActiveActionFields(configuration, action);
|
1702
|
-
if (!fields) {
|
1703
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1704
|
-
}
|
1705
|
-
return fields;
|
1791
|
+
return isConditionMet(page.conditional, formValues);
|
1706
1792
|
}
|
1707
|
-
function
|
1708
|
-
|
1709
|
-
if (!config) {
|
1710
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1711
|
-
}
|
1712
|
-
return config;
|
1713
|
-
}
|
1714
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1715
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1716
|
-
return false;
|
1717
|
-
}
|
1718
|
-
return !form[field2.id];
|
1719
|
-
}
|
1720
|
-
function stripHiddenFields(fields, data) {
|
1721
|
-
return (0, import_lodash.omitBy)(data, (_2, fieldId) => {
|
1793
|
+
function omitHiddenFields(fields, values) {
|
1794
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1722
1795
|
const field2 = fields.find((f) => f.id === fieldId);
|
1723
1796
|
if (!field2) {
|
1724
1797
|
return true;
|
1725
1798
|
}
|
1726
|
-
|
1727
|
-
return true;
|
1728
|
-
}
|
1729
|
-
return !isFieldVisible(field2, data);
|
1799
|
+
return !isFieldVisible(field2, values);
|
1730
1800
|
});
|
1731
1801
|
}
|
1802
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1803
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1804
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1805
|
+
}
|
1732
1806
|
function findActiveDrafts(event2, drafts) {
|
1733
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1807
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1734
1808
|
const lastAction = actions[actions.length - 1];
|
1735
1809
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1736
1810
|
}
|
@@ -1742,8 +1816,8 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1742
1816
|
transactionId: getUUID(),
|
1743
1817
|
action: {
|
1744
1818
|
type: actionType,
|
1745
|
-
|
1746
|
-
|
1819
|
+
declaration: {},
|
1820
|
+
annotation: {},
|
1747
1821
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1748
1822
|
createdBy: "@todo",
|
1749
1823
|
createdAtLocation: "@todo"
|
@@ -1751,22 +1825,49 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1751
1825
|
};
|
1752
1826
|
}
|
1753
1827
|
function isVerificationPage(page) {
|
1754
|
-
return page.type ===
|
1828
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
1829
|
+
}
|
1830
|
+
function deepMerge(currentDocument, actionDocument) {
|
1831
|
+
return (0, import_lodash.mergeWith)(
|
1832
|
+
currentDocument,
|
1833
|
+
actionDocument,
|
1834
|
+
(previousValue, incomingValue) => {
|
1835
|
+
if (incomingValue === void 0) {
|
1836
|
+
return previousValue;
|
1837
|
+
}
|
1838
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1839
|
+
return incomingValue;
|
1840
|
+
}
|
1841
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1842
|
+
return void 0;
|
1843
|
+
}
|
1844
|
+
return incomingValue;
|
1845
|
+
}
|
1846
|
+
);
|
1847
|
+
}
|
1848
|
+
function findLastAssignmentAction(actions) {
|
1849
|
+
return actions.filter(
|
1850
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1851
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1852
|
+
}
|
1853
|
+
function isWriteAction(actionType) {
|
1854
|
+
return writeActions.safeParse(actionType).success;
|
1755
1855
|
}
|
1756
1856
|
|
1757
1857
|
// ../commons/src/events/EventConfig.ts
|
1758
|
-
var EventConfig =
|
1759
|
-
id:
|
1858
|
+
var EventConfig = import_zod20.z.object({
|
1859
|
+
id: import_zod20.z.string().describe(
|
1760
1860
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1761
1861
|
),
|
1762
1862
|
summary: SummaryConfig,
|
1763
1863
|
label: TranslationConfig,
|
1764
|
-
actions:
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1864
|
+
actions: import_zod20.z.array(ActionConfig),
|
1865
|
+
declaration: DeclarationFormConfig,
|
1866
|
+
workqueues: import_zod20.z.array(WorkqueueConfig),
|
1867
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
1868
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1768
1869
|
}).superRefine((event2, ctx) => {
|
1769
|
-
const allFields =
|
1870
|
+
const allFields = findAllFields(event2);
|
1770
1871
|
const fieldIds = allFields.map((field2) => field2.id);
|
1771
1872
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1772
1873
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1793,106 +1894,118 @@ var EventConfig = import_zod18.z.object({
|
|
1793
1894
|
});
|
1794
1895
|
|
1795
1896
|
// ../commons/src/events/EventConfigInput.ts
|
1796
|
-
var
|
1897
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1898
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1899
|
+
var definePage = (page) => PageConfig.parse(page);
|
1797
1900
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1798
1901
|
|
1799
1902
|
// ../commons/src/events/Draft.ts
|
1800
|
-
var
|
1903
|
+
var import_zod23 = require("zod");
|
1801
1904
|
|
1802
1905
|
// ../commons/src/events/ActionDocument.ts
|
1803
|
-
var
|
1804
|
-
var ActionUpdate =
|
1805
|
-
var
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1906
|
+
var import_zod21 = require("zod");
|
1907
|
+
var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
|
1908
|
+
var ActionStatus = {
|
1909
|
+
Requested: "Requested",
|
1910
|
+
Accepted: "Accepted",
|
1911
|
+
Rejected: "Rejected"
|
1912
|
+
};
|
1913
|
+
var ActionBase = import_zod21.z.object({
|
1914
|
+
id: import_zod21.z.string(),
|
1915
|
+
createdAt: import_zod21.z.string().datetime(),
|
1916
|
+
createdBy: import_zod21.z.string(),
|
1917
|
+
declaration: ActionUpdate,
|
1918
|
+
annotation: ActionUpdate.optional(),
|
1919
|
+
createdAtLocation: import_zod21.z.string(),
|
1920
|
+
status: import_zod21.z.enum([
|
1921
|
+
ActionStatus.Requested,
|
1922
|
+
ActionStatus.Accepted,
|
1923
|
+
ActionStatus.Rejected
|
1924
|
+
]),
|
1925
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1926
|
+
originalActionId: import_zod21.z.string().optional()
|
1812
1927
|
});
|
1813
1928
|
var AssignedAction = ActionBase.merge(
|
1814
|
-
|
1815
|
-
type:
|
1816
|
-
assignedTo:
|
1929
|
+
import_zod21.z.object({
|
1930
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1931
|
+
assignedTo: import_zod21.z.string()
|
1817
1932
|
})
|
1818
1933
|
);
|
1819
1934
|
var UnassignedAction = ActionBase.merge(
|
1820
|
-
|
1821
|
-
type:
|
1935
|
+
import_zod21.z.object({
|
1936
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1937
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1822
1938
|
})
|
1823
1939
|
);
|
1824
1940
|
var RegisterAction = ActionBase.merge(
|
1825
|
-
|
1826
|
-
type:
|
1827
|
-
|
1828
|
-
trackingId: import_zod19.z.string(),
|
1829
|
-
registrationNumber: import_zod19.z.string()
|
1830
|
-
})
|
1941
|
+
import_zod21.z.object({
|
1942
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1943
|
+
registrationNumber: import_zod21.z.string().optional()
|
1831
1944
|
})
|
1832
1945
|
);
|
1833
1946
|
var DeclareAction = ActionBase.merge(
|
1834
|
-
|
1835
|
-
type:
|
1947
|
+
import_zod21.z.object({
|
1948
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1836
1949
|
})
|
1837
1950
|
);
|
1838
1951
|
var ValidateAction = ActionBase.merge(
|
1839
|
-
|
1840
|
-
type:
|
1952
|
+
import_zod21.z.object({
|
1953
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1841
1954
|
})
|
1842
1955
|
);
|
1843
1956
|
var RejectAction = ActionBase.merge(
|
1844
|
-
|
1845
|
-
type:
|
1957
|
+
import_zod21.z.object({
|
1958
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1846
1959
|
})
|
1847
1960
|
);
|
1848
1961
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1849
|
-
|
1850
|
-
type:
|
1962
|
+
import_zod21.z.object({
|
1963
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1851
1964
|
})
|
1852
1965
|
);
|
1853
1966
|
var ArchiveAction = ActionBase.merge(
|
1854
|
-
|
1855
|
-
type:
|
1967
|
+
import_zod21.z.object({
|
1968
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1856
1969
|
})
|
1857
1970
|
);
|
1858
1971
|
var CreatedAction = ActionBase.merge(
|
1859
|
-
|
1860
|
-
type:
|
1972
|
+
import_zod21.z.object({
|
1973
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1861
1974
|
})
|
1862
1975
|
);
|
1863
1976
|
var NotifiedAction = ActionBase.merge(
|
1864
|
-
|
1865
|
-
type:
|
1977
|
+
import_zod21.z.object({
|
1978
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1866
1979
|
})
|
1867
1980
|
);
|
1868
1981
|
var PrintCertificateAction = ActionBase.merge(
|
1869
|
-
|
1870
|
-
type:
|
1982
|
+
import_zod21.z.object({
|
1983
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1871
1984
|
})
|
1872
1985
|
);
|
1873
1986
|
var RequestedCorrectionAction = ActionBase.merge(
|
1874
|
-
|
1875
|
-
type:
|
1987
|
+
import_zod21.z.object({
|
1988
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1876
1989
|
})
|
1877
1990
|
);
|
1878
1991
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1879
|
-
|
1880
|
-
type:
|
1881
|
-
requestId:
|
1992
|
+
import_zod21.z.object({
|
1993
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1994
|
+
requestId: import_zod21.z.string()
|
1882
1995
|
})
|
1883
1996
|
);
|
1884
1997
|
var RejectedCorrectionAction = ActionBase.merge(
|
1885
|
-
|
1886
|
-
type:
|
1887
|
-
requestId:
|
1998
|
+
import_zod21.z.object({
|
1999
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
2000
|
+
requestId: import_zod21.z.string()
|
1888
2001
|
})
|
1889
2002
|
);
|
1890
|
-
var
|
1891
|
-
|
1892
|
-
type:
|
2003
|
+
var ReadAction = ActionBase.merge(
|
2004
|
+
import_zod21.z.object({
|
2005
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1893
2006
|
})
|
1894
2007
|
);
|
1895
|
-
var ActionDocument =
|
2008
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1896
2009
|
CreatedAction,
|
1897
2010
|
ValidateAction,
|
1898
2011
|
RejectAction,
|
@@ -1907,108 +2020,125 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1907
2020
|
RejectedCorrectionAction,
|
1908
2021
|
UnassignedAction,
|
1909
2022
|
PrintCertificateAction,
|
1910
|
-
|
2023
|
+
ReadAction
|
1911
2024
|
]);
|
1912
|
-
var
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
2025
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
2026
|
+
declaration: true,
|
2027
|
+
annotation: true,
|
2028
|
+
createdBy: true,
|
2029
|
+
createdAtLocation: true
|
2030
|
+
}).merge(
|
2031
|
+
import_zod21.z.object({
|
2032
|
+
type: import_zod21.z.enum(ConfirmableActions),
|
2033
|
+
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2034
|
+
})
|
2035
|
+
);
|
2036
|
+
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2037
|
+
var ResolvedUser = import_zod21.z.object({
|
2038
|
+
id: import_zod21.z.string(),
|
2039
|
+
role: import_zod21.z.string(),
|
2040
|
+
name: import_zod21.z.array(
|
2041
|
+
import_zod21.z.object({
|
2042
|
+
use: import_zod21.z.string(),
|
2043
|
+
given: import_zod21.z.array(import_zod21.z.string()),
|
2044
|
+
family: import_zod21.z.string()
|
1920
2045
|
})
|
1921
2046
|
)
|
1922
2047
|
});
|
1923
2048
|
|
1924
2049
|
// ../commons/src/events/ActionInput.ts
|
1925
|
-
var
|
1926
|
-
var BaseActionInput =
|
1927
|
-
eventId:
|
1928
|
-
transactionId:
|
1929
|
-
|
1930
|
-
|
2050
|
+
var import_zod22 = require("zod");
|
2051
|
+
var BaseActionInput = import_zod22.z.object({
|
2052
|
+
eventId: import_zod22.z.string(),
|
2053
|
+
transactionId: import_zod22.z.string(),
|
2054
|
+
declaration: ActionUpdate.default({}),
|
2055
|
+
annotation: ActionUpdate.optional(),
|
2056
|
+
originalActionId: import_zod22.z.string().optional(),
|
2057
|
+
keepAssignment: import_zod22.z.boolean().optional()
|
1931
2058
|
});
|
1932
2059
|
var CreateActionInput = BaseActionInput.merge(
|
1933
|
-
|
1934
|
-
type:
|
1935
|
-
createdAtLocation:
|
2060
|
+
import_zod22.z.object({
|
2061
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2062
|
+
createdAtLocation: import_zod22.z.string()
|
1936
2063
|
})
|
1937
2064
|
);
|
1938
2065
|
var RegisterActionInput = BaseActionInput.merge(
|
1939
|
-
|
1940
|
-
type:
|
1941
|
-
|
1942
|
-
trackingId: import_zod20.z.string(),
|
1943
|
-
registrationNumber: import_zod20.z.string()
|
1944
|
-
})
|
2066
|
+
import_zod22.z.object({
|
2067
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2068
|
+
registrationNumber: import_zod22.z.string().optional()
|
1945
2069
|
})
|
1946
2070
|
);
|
1947
2071
|
var ValidateActionInput = BaseActionInput.merge(
|
1948
|
-
|
1949
|
-
type:
|
1950
|
-
duplicates:
|
2072
|
+
import_zod22.z.object({
|
2073
|
+
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2074
|
+
duplicates: import_zod22.z.array(import_zod22.z.string())
|
1951
2075
|
})
|
1952
2076
|
);
|
1953
2077
|
var NotifyActionInput = BaseActionInput.merge(
|
1954
|
-
|
1955
|
-
type:
|
2078
|
+
import_zod22.z.object({
|
2079
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1956
2080
|
})
|
1957
2081
|
);
|
1958
2082
|
var DeclareActionInput = BaseActionInput.merge(
|
1959
|
-
|
1960
|
-
type:
|
2083
|
+
import_zod22.z.object({
|
2084
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1961
2085
|
})
|
1962
2086
|
);
|
1963
2087
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1964
|
-
|
1965
|
-
type:
|
2088
|
+
import_zod22.z.object({
|
2089
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1966
2090
|
})
|
1967
2091
|
);
|
1968
2092
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1969
|
-
|
1970
|
-
type:
|
2093
|
+
import_zod22.z.object({
|
2094
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1971
2095
|
})
|
1972
2096
|
);
|
1973
2097
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1974
|
-
|
1975
|
-
type:
|
2098
|
+
import_zod22.z.object({
|
2099
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1976
2100
|
})
|
1977
2101
|
);
|
1978
2102
|
var ArchiveActionInput = BaseActionInput.merge(
|
1979
|
-
|
1980
|
-
type:
|
2103
|
+
import_zod22.z.object({
|
2104
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1981
2105
|
})
|
1982
2106
|
);
|
1983
2107
|
var AssignActionInput = BaseActionInput.merge(
|
1984
|
-
|
1985
|
-
type:
|
1986
|
-
assignedTo:
|
2108
|
+
import_zod22.z.object({
|
2109
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2110
|
+
assignedTo: import_zod22.z.string()
|
1987
2111
|
})
|
1988
2112
|
);
|
1989
2113
|
var UnassignActionInput = BaseActionInput.merge(
|
1990
|
-
|
1991
|
-
type:
|
2114
|
+
import_zod22.z.object({
|
2115
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2116
|
+
assignedTo: import_zod22.z.literal(null).default(null)
|
1992
2117
|
})
|
1993
2118
|
);
|
1994
2119
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1995
|
-
|
1996
|
-
type:
|
2120
|
+
import_zod22.z.object({
|
2121
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1997
2122
|
})
|
1998
2123
|
);
|
1999
2124
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2000
|
-
|
2001
|
-
requestId:
|
2002
|
-
type:
|
2125
|
+
import_zod22.z.object({
|
2126
|
+
requestId: import_zod22.z.string(),
|
2127
|
+
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2003
2128
|
})
|
2004
2129
|
);
|
2005
2130
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2006
|
-
|
2007
|
-
requestId:
|
2008
|
-
type:
|
2131
|
+
import_zod22.z.object({
|
2132
|
+
requestId: import_zod22.z.string(),
|
2133
|
+
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2134
|
+
})
|
2135
|
+
);
|
2136
|
+
var ReadActionInput = BaseActionInput.merge(
|
2137
|
+
import_zod22.z.object({
|
2138
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2009
2139
|
})
|
2010
2140
|
);
|
2011
|
-
var ActionInput =
|
2141
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2012
2142
|
CreateActionInput,
|
2013
2143
|
ValidateActionInput,
|
2014
2144
|
RegisterActionInput,
|
@@ -2022,79 +2152,90 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
2022
2152
|
PrintCertificateActionInput,
|
2023
2153
|
RequestCorrectionActionInput,
|
2024
2154
|
RejectCorrectionActionInput,
|
2025
|
-
ApproveCorrectionActionInput
|
2155
|
+
ApproveCorrectionActionInput,
|
2156
|
+
ReadActionInput
|
2026
2157
|
]);
|
2027
2158
|
|
2028
2159
|
// ../commons/src/events/Draft.ts
|
2029
|
-
var Draft =
|
2030
|
-
id:
|
2031
|
-
eventId:
|
2032
|
-
transactionId:
|
2033
|
-
createdAt:
|
2160
|
+
var Draft = import_zod23.z.object({
|
2161
|
+
id: import_zod23.z.string(),
|
2162
|
+
eventId: import_zod23.z.string(),
|
2163
|
+
transactionId: import_zod23.z.string(),
|
2164
|
+
createdAt: import_zod23.z.string().datetime(),
|
2034
2165
|
action: ActionBase.extend({
|
2035
|
-
type:
|
2166
|
+
type: ActionTypes
|
2036
2167
|
}).omit({ id: true })
|
2037
2168
|
});
|
2038
2169
|
var DraftInput = BaseActionInput.extend({
|
2039
|
-
type:
|
2170
|
+
type: ActionTypes
|
2040
2171
|
});
|
2041
2172
|
|
2042
2173
|
// ../commons/src/events/EventInput.ts
|
2043
|
-
var
|
2044
|
-
var EventInput =
|
2045
|
-
transactionId:
|
2046
|
-
type:
|
2174
|
+
var import_zod24 = require("zod");
|
2175
|
+
var EventInput = import_zod24.z.object({
|
2176
|
+
transactionId: import_zod24.z.string(),
|
2177
|
+
type: import_zod24.z.string()
|
2047
2178
|
});
|
2048
2179
|
|
2049
2180
|
// ../commons/src/events/EventDocument.ts
|
2050
|
-
var
|
2051
|
-
var EventDocument =
|
2052
|
-
id:
|
2053
|
-
type:
|
2054
|
-
createdAt:
|
2055
|
-
updatedAt:
|
2056
|
-
|
2057
|
-
|
2181
|
+
var import_zod25 = require("zod");
|
2182
|
+
var EventDocument = import_zod25.z.object({
|
2183
|
+
id: import_zod25.z.string(),
|
2184
|
+
type: import_zod25.z.string(),
|
2185
|
+
createdAt: import_zod25.z.string().datetime(),
|
2186
|
+
updatedAt: import_zod25.z.string().datetime(),
|
2187
|
+
updatedAtLocation: import_zod25.z.string(),
|
2188
|
+
actions: import_zod25.z.array(Action),
|
2189
|
+
trackingId: import_zod25.z.string()
|
2058
2190
|
});
|
2059
2191
|
|
2060
2192
|
// ../commons/src/events/EventIndex.ts
|
2061
|
-
var
|
2193
|
+
var import_zod26 = require("zod");
|
2062
2194
|
var EventIndex = EventMetadata.extend({
|
2063
|
-
|
2195
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2064
2196
|
});
|
2065
|
-
var EventSearchIndex =
|
2066
|
-
|
2067
|
-
type:
|
2197
|
+
var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
|
2198
|
+
import_zod26.z.object({
|
2199
|
+
type: import_zod26.z.string()
|
2068
2200
|
// Ensures "type" (event-id) exists and is a string
|
2069
2201
|
})
|
2070
2202
|
);
|
2071
2203
|
|
2072
2204
|
// ../commons/src/events/state/index.ts
|
2073
|
-
var _ = __toESM(require("lodash"));
|
2074
2205
|
function getStatusFromActions(actions) {
|
2206
|
+
const hasRejectedAction = actions.some(
|
2207
|
+
(a) => a.status === ActionStatus.Rejected
|
2208
|
+
);
|
2209
|
+
if (hasRejectedAction) {
|
2210
|
+
return EventStatus.REJECTED;
|
2211
|
+
}
|
2075
2212
|
return actions.reduce((status, action) => {
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2213
|
+
switch (action.type) {
|
2214
|
+
case ActionType.CREATE:
|
2215
|
+
return EventStatus.CREATED;
|
2216
|
+
case ActionType.DECLARE:
|
2217
|
+
return EventStatus.DECLARED;
|
2218
|
+
case ActionType.VALIDATE:
|
2219
|
+
return EventStatus.VALIDATED;
|
2220
|
+
case ActionType.REGISTER:
|
2221
|
+
return EventStatus.REGISTERED;
|
2222
|
+
case ActionType.REJECT:
|
2223
|
+
return EventStatus.REJECTED;
|
2224
|
+
case ActionType.ARCHIVE:
|
2225
|
+
return EventStatus.ARCHIVED;
|
2226
|
+
case ActionType.NOTIFY:
|
2227
|
+
return EventStatus.NOTIFIED;
|
2228
|
+
case ActionType.PRINT_CERTIFICATE:
|
2229
|
+
case ActionType.ASSIGN:
|
2230
|
+
case ActionType.UNASSIGN:
|
2231
|
+
case ActionType.REQUEST_CORRECTION:
|
2232
|
+
case ActionType.APPROVE_CORRECTION:
|
2233
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2234
|
+
case ActionType.REJECT_CORRECTION:
|
2235
|
+
case ActionType.READ:
|
2236
|
+
default:
|
2237
|
+
return status;
|
2096
2238
|
}
|
2097
|
-
return status;
|
2098
2239
|
}, EventStatus.CREATED);
|
2099
2240
|
}
|
2100
2241
|
function getAssignedUserFromActions(actions) {
|
@@ -2108,7 +2249,7 @@ function getAssignedUserFromActions(actions) {
|
|
2108
2249
|
return user2;
|
2109
2250
|
}, null);
|
2110
2251
|
}
|
2111
|
-
function
|
2252
|
+
function aggregateActionDeclarations(actions) {
|
2112
2253
|
const excludedActions = [
|
2113
2254
|
ActionType.REQUEST_CORRECTION,
|
2114
2255
|
ActionType.PRINT_CERTIFICATE
|
@@ -2122,47 +2263,35 @@ function getData(actions) {
|
|
2122
2263
|
if (!requestAction) {
|
2123
2264
|
return status;
|
2124
2265
|
}
|
2125
|
-
return deepMerge(status, requestAction.
|
2126
|
-
}
|
2127
|
-
return deepMerge(status, action.data);
|
2128
|
-
}, {});
|
2129
|
-
}
|
2130
|
-
function deepDropNulls(obj) {
|
2131
|
-
if (!_.isObject(obj)) return obj;
|
2132
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2133
|
-
if (_.isObject(value)) {
|
2134
|
-
value = deepDropNulls(value);
|
2135
|
-
}
|
2136
|
-
if (value !== null) {
|
2137
|
-
return {
|
2138
|
-
...acc,
|
2139
|
-
[key]: value
|
2140
|
-
};
|
2141
|
-
}
|
2142
|
-
return acc;
|
2143
|
-
}, {});
|
2144
|
-
}
|
2145
|
-
function deepMerge(currentDocument, actionDocument) {
|
2146
|
-
return _.mergeWith(
|
2147
|
-
currentDocument,
|
2148
|
-
actionDocument,
|
2149
|
-
(previousValue, incomingValue) => {
|
2150
|
-
if (incomingValue === void 0) {
|
2151
|
-
return previousValue;
|
2152
|
-
}
|
2153
|
-
if (_.isArray(incomingValue)) {
|
2154
|
-
return incomingValue;
|
2155
|
-
}
|
2156
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2157
|
-
return void 0;
|
2158
|
-
}
|
2159
|
-
return incomingValue;
|
2266
|
+
return deepMerge(status, requestAction.declaration);
|
2160
2267
|
}
|
2161
|
-
|
2268
|
+
return deepMerge(status, action.declaration);
|
2269
|
+
}, {});
|
2270
|
+
}
|
2271
|
+
function deepDropNulls(obj) {
|
2272
|
+
if (Array.isArray(obj)) {
|
2273
|
+
return obj.map(deepDropNulls);
|
2274
|
+
}
|
2275
|
+
if (obj !== null && typeof obj === "object") {
|
2276
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2277
|
+
const cleanedValue = deepDropNulls(value);
|
2278
|
+
if (cleanedValue !== null) {
|
2279
|
+
;
|
2280
|
+
acc[key] = cleanedValue;
|
2281
|
+
}
|
2282
|
+
return acc;
|
2283
|
+
}, {});
|
2284
|
+
}
|
2285
|
+
return obj;
|
2162
2286
|
}
|
2163
2287
|
function isUndeclaredDraft(status) {
|
2164
2288
|
return status === EventStatus.CREATED;
|
2165
2289
|
}
|
2290
|
+
function getAcceptedActions(event2) {
|
2291
|
+
return event2.actions.filter(
|
2292
|
+
(a) => a.status === ActionStatus.Accepted
|
2293
|
+
);
|
2294
|
+
}
|
2166
2295
|
function getCurrentEventState(event2) {
|
2167
2296
|
const creationAction = event2.actions.find(
|
2168
2297
|
(action) => action.type === ActionType.CREATE
|
@@ -2170,7 +2299,12 @@ function getCurrentEventState(event2) {
|
|
2170
2299
|
if (!creationAction) {
|
2171
2300
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2172
2301
|
}
|
2173
|
-
const
|
2302
|
+
const activeActions = getAcceptedActions(event2);
|
2303
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2304
|
+
const registrationAction = activeActions.find(
|
2305
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2306
|
+
);
|
2307
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2174
2308
|
return deepDropNulls({
|
2175
2309
|
id: event2.id,
|
2176
2310
|
type: event2.type,
|
@@ -2179,10 +2313,12 @@ function getCurrentEventState(event2) {
|
|
2179
2313
|
createdBy: creationAction.createdBy,
|
2180
2314
|
createdAtLocation: creationAction.createdAtLocation,
|
2181
2315
|
modifiedAt: latestAction.createdAt,
|
2182
|
-
assignedTo: getAssignedUserFromActions(
|
2316
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2183
2317
|
updatedBy: latestAction.createdBy,
|
2184
|
-
|
2185
|
-
|
2318
|
+
updatedAtLocation: event2.updatedAtLocation,
|
2319
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2320
|
+
trackingId: event2.trackingId,
|
2321
|
+
registrationNumber
|
2186
2322
|
});
|
2187
2323
|
}
|
2188
2324
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2214,38 +2350,44 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2214
2350
|
}
|
2215
2351
|
return {
|
2216
2352
|
...eventIndex,
|
2217
|
-
|
2218
|
-
...eventIndex.
|
2219
|
-
...activeDrafts[activeDrafts.length - 1].
|
2353
|
+
declaration: {
|
2354
|
+
...eventIndex.declaration,
|
2355
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2220
2356
|
}
|
2221
2357
|
};
|
2222
2358
|
}
|
2223
|
-
function
|
2359
|
+
function getAnnotationFromDrafts(drafts) {
|
2360
|
+
const actions = drafts.map((draft) => draft.action);
|
2361
|
+
const annotation = actions.reduce((ann, action) => {
|
2362
|
+
return deepMerge(ann, action.annotation ?? {});
|
2363
|
+
}, {});
|
2364
|
+
return deepDropNulls(annotation);
|
2365
|
+
}
|
2366
|
+
function getActionAnnotation({
|
2224
2367
|
event: event2,
|
2225
2368
|
actionType,
|
2226
2369
|
drafts
|
2227
2370
|
}) {
|
2228
|
-
const
|
2371
|
+
const activeActions = getAcceptedActions(event2);
|
2372
|
+
const action = activeActions.find(
|
2373
|
+
(activeAction) => actionType === activeAction.type
|
2374
|
+
);
|
2229
2375
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2230
2376
|
const sorted = [
|
2231
2377
|
...action ? [action] : [],
|
2232
2378
|
...eventDrafts.map((draft) => draft.action)
|
2233
2379
|
].sort();
|
2234
|
-
const
|
2235
|
-
return deepMerge(
|
2380
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2381
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2236
2382
|
}, {});
|
2237
|
-
return deepDropNulls(
|
2383
|
+
return deepDropNulls(annotation);
|
2238
2384
|
}
|
2239
2385
|
|
2240
2386
|
// ../commons/src/events/defineConfig.ts
|
2241
2387
|
var defineConfig = (config) => {
|
2242
2388
|
validateWorkqueueConfig(config.workqueues);
|
2243
2389
|
const input = EventConfig.parse(config);
|
2244
|
-
|
2245
|
-
return EventConfig.parse({
|
2246
|
-
...input,
|
2247
|
-
pageFields
|
2248
|
-
});
|
2390
|
+
return input;
|
2249
2391
|
};
|
2250
2392
|
|
2251
2393
|
// ../commons/src/events/transactions.ts
|
@@ -2260,6 +2402,16 @@ var import_lodash2 = require("lodash");
|
|
2260
2402
|
function defineConditional(schema) {
|
2261
2403
|
return schema;
|
2262
2404
|
}
|
2405
|
+
function defineFormConditional(schema) {
|
2406
|
+
const schemaWithForm = {
|
2407
|
+
type: "object",
|
2408
|
+
properties: {
|
2409
|
+
$form: schema
|
2410
|
+
},
|
2411
|
+
required: ["$form"]
|
2412
|
+
};
|
2413
|
+
return defineConditional(schemaWithForm);
|
2414
|
+
}
|
2263
2415
|
function alwaysTrue() {
|
2264
2416
|
return {};
|
2265
2417
|
}
|
@@ -2284,6 +2436,9 @@ function not(condition) {
|
|
2284
2436
|
required: []
|
2285
2437
|
});
|
2286
2438
|
}
|
2439
|
+
function never() {
|
2440
|
+
return not(alwaysTrue());
|
2441
|
+
}
|
2287
2442
|
var user = {
|
2288
2443
|
hasScope: (scope) => defineConditional({
|
2289
2444
|
type: "object",
|
@@ -2331,69 +2486,120 @@ var event = {
|
|
2331
2486
|
required: ["$event"]
|
2332
2487
|
})
|
2333
2488
|
};
|
2489
|
+
function getDateFromNow(days) {
|
2490
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2491
|
+
}
|
2492
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2493
|
+
return {
|
2494
|
+
type: "object",
|
2495
|
+
properties: {
|
2496
|
+
[fieldId]: {
|
2497
|
+
type: "string",
|
2498
|
+
format: "date",
|
2499
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2500
|
+
},
|
2501
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2502
|
+
},
|
2503
|
+
required: [fieldId]
|
2504
|
+
};
|
2505
|
+
}
|
2506
|
+
function isFieldReference(value) {
|
2507
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2508
|
+
}
|
2334
2509
|
function field(fieldId) {
|
2335
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2336
2510
|
const getDateRange = (date, clause) => ({
|
2337
2511
|
type: "object",
|
2338
2512
|
properties: {
|
2339
|
-
|
2340
|
-
type: "
|
2341
|
-
|
2342
|
-
|
2343
|
-
type: "string",
|
2344
|
-
format: "date",
|
2345
|
-
[clause]: date
|
2346
|
-
}
|
2347
|
-
},
|
2348
|
-
required: [fieldId]
|
2513
|
+
[fieldId]: {
|
2514
|
+
type: "string",
|
2515
|
+
format: "date",
|
2516
|
+
[clause]: date
|
2349
2517
|
}
|
2350
2518
|
},
|
2351
|
-
required: [
|
2519
|
+
required: [fieldId]
|
2352
2520
|
});
|
2353
2521
|
return {
|
2522
|
+
/**
|
2523
|
+
* @private Internal property used for field reference tracking.
|
2524
|
+
*/
|
2525
|
+
_fieldId: fieldId,
|
2354
2526
|
isAfter: () => ({
|
2355
2527
|
days: (days) => ({
|
2356
|
-
inPast: () =>
|
2528
|
+
inPast: () => defineFormConditional(
|
2357
2529
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2358
2530
|
),
|
2359
|
-
inFuture: () =>
|
2531
|
+
inFuture: () => defineFormConditional(
|
2360
2532
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2361
2533
|
)
|
2362
2534
|
}),
|
2363
|
-
date: (date) =>
|
2364
|
-
|
2535
|
+
date: (date) => {
|
2536
|
+
if (isFieldReference(date)) {
|
2537
|
+
const comparedFieldId = date._fieldId;
|
2538
|
+
return defineFormConditional(
|
2539
|
+
getDateRangeToFieldReference(
|
2540
|
+
fieldId,
|
2541
|
+
comparedFieldId,
|
2542
|
+
"formatMinimum"
|
2543
|
+
)
|
2544
|
+
);
|
2545
|
+
}
|
2546
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2547
|
+
},
|
2548
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2365
2549
|
}),
|
2366
2550
|
isBefore: () => ({
|
2367
2551
|
days: (days) => ({
|
2368
|
-
inPast: () =>
|
2552
|
+
inPast: () => defineFormConditional(
|
2369
2553
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2370
2554
|
),
|
2371
|
-
inFuture: () =>
|
2555
|
+
inFuture: () => defineFormConditional(
|
2372
2556
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2373
2557
|
)
|
2374
2558
|
}),
|
2375
|
-
date: (date) =>
|
2376
|
-
|
2559
|
+
date: (date) => {
|
2560
|
+
if (isFieldReference(date)) {
|
2561
|
+
const comparedFieldId = date._fieldId;
|
2562
|
+
return defineFormConditional(
|
2563
|
+
getDateRangeToFieldReference(
|
2564
|
+
fieldId,
|
2565
|
+
comparedFieldId,
|
2566
|
+
"formatMaximum"
|
2567
|
+
)
|
2568
|
+
);
|
2569
|
+
}
|
2570
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2571
|
+
},
|
2572
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2377
2573
|
}),
|
2378
|
-
isEqualTo: (value) =>
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2574
|
+
isEqualTo: (value) => {
|
2575
|
+
if (isFieldReference(value)) {
|
2576
|
+
const comparedFieldId = value._fieldId;
|
2577
|
+
return defineFormConditional({
|
2382
2578
|
type: "object",
|
2383
2579
|
properties: {
|
2384
2580
|
[fieldId]: {
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
const: value
|
2390
|
-
}
|
2581
|
+
type: ["string", "boolean"],
|
2582
|
+
const: { $data: `1/${comparedFieldId}` }
|
2583
|
+
},
|
2584
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2391
2585
|
},
|
2392
|
-
required: [fieldId]
|
2393
|
-
}
|
2394
|
-
}
|
2395
|
-
|
2396
|
-
|
2586
|
+
required: [fieldId, comparedFieldId]
|
2587
|
+
});
|
2588
|
+
}
|
2589
|
+
return defineFormConditional({
|
2590
|
+
type: "object",
|
2591
|
+
properties: {
|
2592
|
+
[fieldId]: {
|
2593
|
+
oneOf: [
|
2594
|
+
{ type: "string", const: value },
|
2595
|
+
{ type: "boolean", const: value }
|
2596
|
+
],
|
2597
|
+
const: value
|
2598
|
+
}
|
2599
|
+
},
|
2600
|
+
required: [fieldId]
|
2601
|
+
});
|
2602
|
+
},
|
2397
2603
|
/**
|
2398
2604
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2399
2605
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2402,108 +2608,102 @@ function field(fieldId) {
|
|
2402
2608
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2403
2609
|
*
|
2404
2610
|
*/
|
2405
|
-
isFalsy: () =>
|
2611
|
+
isFalsy: () => defineFormConditional({
|
2406
2612
|
type: "object",
|
2407
2613
|
properties: {
|
2408
|
-
|
2409
|
-
type: "object",
|
2410
|
-
properties: {
|
2411
|
-
[fieldId]: {
|
2412
|
-
anyOf: [
|
2413
|
-
{ const: "undefined" },
|
2414
|
-
{ const: false },
|
2415
|
-
{ const: null },
|
2416
|
-
{ const: "" }
|
2417
|
-
]
|
2418
|
-
}
|
2419
|
-
},
|
2614
|
+
[fieldId]: {
|
2420
2615
|
anyOf: [
|
2421
|
-
{
|
2422
|
-
|
2423
|
-
},
|
2424
|
-
{
|
2425
|
-
not: {
|
2426
|
-
required: [fieldId]
|
2427
|
-
}
|
2428
|
-
}
|
2616
|
+
{ const: "undefined" },
|
2617
|
+
{ const: false },
|
2618
|
+
{ const: null },
|
2619
|
+
{ const: "" }
|
2429
2620
|
]
|
2430
2621
|
}
|
2431
2622
|
},
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
$form: {
|
2438
|
-
type: "object",
|
2439
|
-
properties: {
|
2440
|
-
[fieldId]: {
|
2441
|
-
type: "string",
|
2442
|
-
enum: ["undefined"]
|
2443
|
-
}
|
2444
|
-
},
|
2623
|
+
anyOf: [
|
2624
|
+
{
|
2625
|
+
required: [fieldId]
|
2626
|
+
},
|
2627
|
+
{
|
2445
2628
|
not: {
|
2446
2629
|
required: [fieldId]
|
2447
2630
|
}
|
2448
2631
|
}
|
2632
|
+
]
|
2633
|
+
}),
|
2634
|
+
isUndefined: () => defineFormConditional({
|
2635
|
+
type: "object",
|
2636
|
+
properties: {
|
2637
|
+
[fieldId]: {
|
2638
|
+
type: "string",
|
2639
|
+
enum: ["undefined"]
|
2640
|
+
}
|
2449
2641
|
},
|
2450
|
-
|
2642
|
+
not: {
|
2643
|
+
required: [fieldId]
|
2644
|
+
}
|
2451
2645
|
}),
|
2452
|
-
inArray: (values) =>
|
2646
|
+
inArray: (values) => defineFormConditional({
|
2453
2647
|
type: "object",
|
2454
2648
|
properties: {
|
2455
|
-
|
2456
|
-
type: "
|
2457
|
-
|
2458
|
-
[fieldId]: {
|
2459
|
-
type: "string",
|
2460
|
-
enum: values
|
2461
|
-
}
|
2462
|
-
},
|
2463
|
-
required: [fieldId]
|
2649
|
+
[fieldId]: {
|
2650
|
+
type: "string",
|
2651
|
+
enum: values
|
2464
2652
|
}
|
2465
2653
|
},
|
2466
|
-
required: [
|
2654
|
+
required: [fieldId]
|
2467
2655
|
}),
|
2468
|
-
isValidEnglishName: () =>
|
2656
|
+
isValidEnglishName: () => defineFormConditional({
|
2469
2657
|
type: "object",
|
2470
2658
|
properties: {
|
2471
|
-
|
2472
|
-
type: "
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2659
|
+
[fieldId]: {
|
2660
|
+
type: "string",
|
2661
|
+
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'._-]*)*$",
|
2662
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2663
|
+
}
|
2664
|
+
},
|
2665
|
+
required: [fieldId]
|
2666
|
+
}),
|
2667
|
+
/**
|
2668
|
+
* Checks if the field value matches a given regular expression pattern.
|
2669
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2670
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2671
|
+
*/
|
2672
|
+
matches: (pattern) => defineFormConditional({
|
2673
|
+
type: "object",
|
2674
|
+
properties: {
|
2675
|
+
[fieldId]: {
|
2676
|
+
type: "string",
|
2677
|
+
pattern
|
2678
|
+
}
|
2679
|
+
},
|
2680
|
+
required: [fieldId]
|
2681
|
+
}),
|
2682
|
+
isBetween: (min, max) => defineFormConditional({
|
2683
|
+
type: "object",
|
2684
|
+
properties: {
|
2685
|
+
[fieldId]: {
|
2686
|
+
type: "number",
|
2687
|
+
minimum: min,
|
2688
|
+
maximum: max
|
2481
2689
|
}
|
2482
2690
|
},
|
2483
|
-
required: [
|
2691
|
+
required: [fieldId]
|
2484
2692
|
})
|
2485
2693
|
};
|
2486
2694
|
}
|
2487
2695
|
|
2488
2696
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2489
|
-
var PRINT_CERTIFICATE_FORM =
|
2697
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2490
2698
|
label: {
|
2491
2699
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2492
2700
|
defaultMessage: "Tennis club membership certificate collector",
|
2493
2701
|
description: "This is what this form is referred as in the system"
|
2494
2702
|
},
|
2495
|
-
version: {
|
2496
|
-
id: "1.0.0",
|
2497
|
-
label: {
|
2498
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2499
|
-
defaultMessage: "Version 1",
|
2500
|
-
description: "This is the first version of the form"
|
2501
|
-
}
|
2502
|
-
},
|
2503
|
-
active: true,
|
2504
2703
|
pages: [
|
2505
2704
|
{
|
2506
2705
|
id: "collector",
|
2706
|
+
type: PageTypes.enum.FORM,
|
2507
2707
|
title: {
|
2508
2708
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2509
2709
|
defaultMessage: "Print certified copy",
|
@@ -2518,7 +2718,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2518
2718
|
defaultMessage: "Requester",
|
2519
2719
|
description: "This is the label for the field"
|
2520
2720
|
},
|
2521
|
-
type:
|
2721
|
+
type: FieldType.SELECT,
|
2522
2722
|
options: [
|
2523
2723
|
{
|
2524
2724
|
value: "INFORMANT",
|
@@ -2595,7 +2795,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2595
2795
|
defaultMessage: "Select Type of ID",
|
2596
2796
|
description: "This is the label for selecting the type of ID"
|
2597
2797
|
},
|
2598
|
-
type:
|
2798
|
+
type: FieldType.SELECT,
|
2599
2799
|
options: [
|
2600
2800
|
{
|
2601
2801
|
value: "PASSPORT",
|
@@ -2696,7 +2896,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2696
2896
|
defaultMessage: "Passport Details",
|
2697
2897
|
description: "Field for entering Passport details"
|
2698
2898
|
},
|
2699
|
-
type:
|
2899
|
+
type: FieldType.TEXT
|
2700
2900
|
},
|
2701
2901
|
{
|
2702
2902
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2747,7 +2947,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2747
2947
|
defaultMessage: "Driving License Details",
|
2748
2948
|
description: "Field for entering Driving License details"
|
2749
2949
|
},
|
2750
|
-
type:
|
2950
|
+
type: FieldType.TEXT
|
2751
2951
|
},
|
2752
2952
|
{
|
2753
2953
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2798,7 +2998,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2798
2998
|
defaultMessage: "Refugee Number Details",
|
2799
2999
|
description: "Field for entering Refugee Number details"
|
2800
3000
|
},
|
2801
|
-
type:
|
3001
|
+
type: FieldType.TEXT
|
2802
3002
|
},
|
2803
3003
|
{
|
2804
3004
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2849,7 +3049,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2849
3049
|
defaultMessage: "Alien Number Details",
|
2850
3050
|
description: "Field for entering Alien Number details"
|
2851
3051
|
},
|
2852
|
-
type:
|
3052
|
+
type: FieldType.TEXT
|
2853
3053
|
},
|
2854
3054
|
{
|
2855
3055
|
id: "collector.OTHER.idTypeOther",
|
@@ -2900,7 +3100,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2900
3100
|
defaultMessage: "Other ID Type (if applicable)",
|
2901
3101
|
description: 'Field for entering ID type if "Other" is selected'
|
2902
3102
|
},
|
2903
|
-
type:
|
3103
|
+
type: FieldType.TEXT
|
2904
3104
|
},
|
2905
3105
|
{
|
2906
3106
|
id: "collector.OTHER.firstName",
|
@@ -2951,7 +3151,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2951
3151
|
defaultMessage: "First Name",
|
2952
3152
|
description: "This is the label for the first name field"
|
2953
3153
|
},
|
2954
|
-
type:
|
3154
|
+
type: FieldType.TEXT
|
2955
3155
|
},
|
2956
3156
|
{
|
2957
3157
|
id: "collector.OTHER.lastName",
|
@@ -3002,7 +3202,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3002
3202
|
defaultMessage: "Last Name",
|
3003
3203
|
description: "This is the label for the last name field"
|
3004
3204
|
},
|
3005
|
-
type:
|
3205
|
+
type: FieldType.TEXT
|
3006
3206
|
},
|
3007
3207
|
{
|
3008
3208
|
id: "collector.OTHER.relationshipToMember",
|
@@ -3053,7 +3253,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3053
3253
|
defaultMessage: "Relationship to Member",
|
3054
3254
|
description: "This is the label for the relationship to member field"
|
3055
3255
|
},
|
3056
|
-
type:
|
3256
|
+
type: FieldType.TEXT
|
3057
3257
|
},
|
3058
3258
|
{
|
3059
3259
|
id: "collector.OTHER.signedAffidavit",
|
@@ -3104,13 +3304,13 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3104
3304
|
defaultMessage: "Signed Affidavit (Optional)",
|
3105
3305
|
description: "This is the label for uploading a signed affidavit"
|
3106
3306
|
},
|
3107
|
-
type:
|
3307
|
+
type: FieldType.FILE
|
3108
3308
|
}
|
3109
3309
|
]
|
3110
3310
|
},
|
3111
3311
|
{
|
3112
3312
|
id: "collector.identity.verify",
|
3113
|
-
type:
|
3313
|
+
type: PageTypes.enum.VERIFICATION,
|
3114
3314
|
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3115
3315
|
title: {
|
3116
3316
|
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
@@ -3147,62 +3347,45 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3147
3347
|
}
|
3148
3348
|
}
|
3149
3349
|
}
|
3150
|
-
]
|
3151
|
-
review: {
|
3152
|
-
title: {
|
3153
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
3154
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
3155
|
-
description: "Title of the form to show in review page"
|
3156
|
-
},
|
3157
|
-
fields: []
|
3158
|
-
}
|
3350
|
+
]
|
3159
3351
|
});
|
3160
|
-
var
|
3161
|
-
|
3162
|
-
id: "v2.event.tennis-club-membership.action.declare.form.
|
3163
|
-
defaultMessage: "
|
3164
|
-
description: "
|
3165
|
-
},
|
3166
|
-
active: true,
|
3167
|
-
version: {
|
3168
|
-
id: "1.0.0",
|
3169
|
-
label: {
|
3170
|
-
id: "v2.event.tennis-club-membership.action.declare.form.version.1",
|
3171
|
-
defaultMessage: "Version 1",
|
3172
|
-
description: "This is the first version of the form"
|
3173
|
-
}
|
3352
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3353
|
+
title: {
|
3354
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3355
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3356
|
+
description: "Title of the review page"
|
3174
3357
|
},
|
3175
|
-
|
3176
|
-
|
3177
|
-
id: "
|
3178
|
-
|
3179
|
-
|
3358
|
+
fields: [
|
3359
|
+
{
|
3360
|
+
id: "review.comment",
|
3361
|
+
type: FieldType.TEXTAREA,
|
3362
|
+
label: {
|
3363
|
+
defaultMessage: "Comment",
|
3364
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3365
|
+
description: "Label for the comment field in the review section"
|
3366
|
+
}
|
3180
3367
|
},
|
3181
|
-
|
3182
|
-
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
description: "Label for the comment field in the review section"
|
3189
|
-
}
|
3368
|
+
{
|
3369
|
+
type: FieldType.SIGNATURE,
|
3370
|
+
id: "review.signature",
|
3371
|
+
label: {
|
3372
|
+
defaultMessage: "Signature of informant",
|
3373
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3374
|
+
description: "Label for the signature field in the review section"
|
3190
3375
|
},
|
3191
|
-
{
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
defaultMessage: "Signature of informant",
|
3196
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3197
|
-
description: "Label for the signature field in the review section"
|
3198
|
-
},
|
3199
|
-
signaturePromptLabel: {
|
3200
|
-
id: "v2.signature.upload.modal.title",
|
3201
|
-
defaultMessage: "Draw signature",
|
3202
|
-
description: "Title for the modal to draw signature"
|
3203
|
-
}
|
3376
|
+
signaturePromptLabel: {
|
3377
|
+
id: "v2.signature.upload.modal.title",
|
3378
|
+
defaultMessage: "Draw signature",
|
3379
|
+
description: "Title for the modal to draw signature"
|
3204
3380
|
}
|
3205
|
-
|
3381
|
+
}
|
3382
|
+
]
|
3383
|
+
};
|
3384
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3385
|
+
label: {
|
3386
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3387
|
+
defaultMessage: "Tennis club membership application",
|
3388
|
+
description: "This is what this form is referred as in the system"
|
3206
3389
|
},
|
3207
3390
|
pages: [
|
3208
3391
|
{
|
@@ -3215,7 +3398,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3215
3398
|
fields: [
|
3216
3399
|
{
|
3217
3400
|
id: "applicant.firstname",
|
3218
|
-
type:
|
3401
|
+
type: FieldType.TEXT,
|
3219
3402
|
required: true,
|
3220
3403
|
conditionals: [],
|
3221
3404
|
label: {
|
@@ -3226,7 +3409,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3226
3409
|
},
|
3227
3410
|
{
|
3228
3411
|
id: "applicant.surname",
|
3229
|
-
type:
|
3412
|
+
type: FieldType.TEXT,
|
3230
3413
|
required: true,
|
3231
3414
|
conditionals: [],
|
3232
3415
|
label: {
|
@@ -3248,9 +3431,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3248
3431
|
},
|
3249
3432
|
{
|
3250
3433
|
id: "applicant.dob",
|
3251
|
-
type:
|
3434
|
+
type: FieldType.DATE,
|
3252
3435
|
required: true,
|
3253
|
-
conditionals: [],
|
3254
3436
|
validation: [
|
3255
3437
|
{
|
3256
3438
|
message: {
|
@@ -3261,15 +3443,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3261
3443
|
validator: field("applicant.dob").isBefore().now()
|
3262
3444
|
}
|
3263
3445
|
],
|
3446
|
+
conditionals: [
|
3447
|
+
{
|
3448
|
+
type: ConditionalType.SHOW,
|
3449
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3450
|
+
}
|
3451
|
+
],
|
3264
3452
|
label: {
|
3265
3453
|
defaultMessage: "Applicant's date of birth",
|
3266
3454
|
description: "This is the label for the field",
|
3267
3455
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3268
3456
|
}
|
3269
3457
|
},
|
3458
|
+
{
|
3459
|
+
id: "applicant.dobUnknown",
|
3460
|
+
type: FieldType.CHECKBOX,
|
3461
|
+
required: false,
|
3462
|
+
label: {
|
3463
|
+
defaultMessage: "Exact date of birth unknown",
|
3464
|
+
description: "This is the label for the field",
|
3465
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3466
|
+
},
|
3467
|
+
conditionals: [
|
3468
|
+
{
|
3469
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3470
|
+
conditional: never()
|
3471
|
+
}
|
3472
|
+
]
|
3473
|
+
},
|
3474
|
+
{
|
3475
|
+
id: "applicant.age",
|
3476
|
+
type: FieldType.NUMBER,
|
3477
|
+
required: true,
|
3478
|
+
label: {
|
3479
|
+
defaultMessage: "Age of tennis-member",
|
3480
|
+
description: "This is the label for the field",
|
3481
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3482
|
+
},
|
3483
|
+
conditionals: [
|
3484
|
+
{
|
3485
|
+
type: ConditionalType.SHOW,
|
3486
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3487
|
+
}
|
3488
|
+
]
|
3489
|
+
},
|
3270
3490
|
{
|
3271
3491
|
id: "applicant.image",
|
3272
|
-
type:
|
3492
|
+
type: FieldType.FILE,
|
3273
3493
|
required: false,
|
3274
3494
|
label: {
|
3275
3495
|
defaultMessage: "Applicant's profile picture",
|
@@ -3301,7 +3521,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3301
3521
|
fields: [
|
3302
3522
|
{
|
3303
3523
|
id: "senior-pass.id",
|
3304
|
-
type:
|
3524
|
+
type: FieldType.TEXT,
|
3305
3525
|
required: true,
|
3306
3526
|
label: {
|
3307
3527
|
defaultMessage: "Senior pass ID",
|
@@ -3332,7 +3552,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3332
3552
|
},
|
3333
3553
|
{
|
3334
3554
|
id: "recommender.firstname",
|
3335
|
-
type:
|
3555
|
+
type: FieldType.TEXT,
|
3336
3556
|
required: true,
|
3337
3557
|
conditionals: [
|
3338
3558
|
{
|
@@ -3348,7 +3568,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3348
3568
|
},
|
3349
3569
|
{
|
3350
3570
|
id: "recommender.surname",
|
3351
|
-
type:
|
3571
|
+
type: FieldType.TEXT,
|
3352
3572
|
required: true,
|
3353
3573
|
conditionals: [
|
3354
3574
|
{
|
@@ -3364,7 +3584,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3364
3584
|
},
|
3365
3585
|
{
|
3366
3586
|
id: "recommender.id",
|
3367
|
-
type:
|
3587
|
+
type: FieldType.TEXT,
|
3368
3588
|
required: true,
|
3369
3589
|
conditionals: [
|
3370
3590
|
{
|
@@ -3472,7 +3692,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3472
3692
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3473
3693
|
id: "event.tennis-club-membership.action.declare.label"
|
3474
3694
|
},
|
3475
|
-
|
3695
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3476
3696
|
},
|
3477
3697
|
{
|
3478
3698
|
type: ActionType.VALIDATE,
|
@@ -3481,7 +3701,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3481
3701
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3482
3702
|
id: "event.tennis-club-membership.action.validate.label"
|
3483
3703
|
},
|
3484
|
-
|
3704
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3485
3705
|
},
|
3486
3706
|
{
|
3487
3707
|
type: ActionType.REGISTER,
|
@@ -3490,7 +3710,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3490
3710
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3491
3711
|
id: "event.tennis-club-membership.action.register.label"
|
3492
3712
|
},
|
3493
|
-
|
3713
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3494
3714
|
},
|
3495
3715
|
{
|
3496
3716
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3499,10 +3719,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3499
3719
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3500
3720
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3501
3721
|
},
|
3502
|
-
forms: [TENNIS_CLUB_FORM],
|
3503
3722
|
onboardingForm: [
|
3504
3723
|
{
|
3505
3724
|
id: "correction-requester",
|
3725
|
+
type: PageTypes.enum.FORM,
|
3506
3726
|
title: {
|
3507
3727
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3508
3728
|
defaultMessage: "Correction requester",
|
@@ -3566,6 +3786,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3566
3786
|
},
|
3567
3787
|
{
|
3568
3788
|
id: "identity-check",
|
3789
|
+
type: PageTypes.enum.FORM,
|
3569
3790
|
title: {
|
3570
3791
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3571
3792
|
defaultMessage: "Verify their identity",
|
@@ -3608,6 +3829,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3608
3829
|
additionalDetailsForm: [
|
3609
3830
|
{
|
3610
3831
|
id: "correction-request.supporting-documents",
|
3832
|
+
type: PageTypes.enum.FORM,
|
3611
3833
|
title: {
|
3612
3834
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3613
3835
|
defaultMessage: "Upload supporting documents",
|
@@ -3625,7 +3847,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3625
3847
|
},
|
3626
3848
|
{
|
3627
3849
|
id: "correction.supportingDocs",
|
3628
|
-
type:
|
3850
|
+
type: FieldType.FILE,
|
3629
3851
|
label: {
|
3630
3852
|
id: "correction.corrector.title",
|
3631
3853
|
defaultMessage: "Upload supporting documents",
|
@@ -3669,6 +3891,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3669
3891
|
},
|
3670
3892
|
{
|
3671
3893
|
id: "correction-request.additional-details",
|
3894
|
+
type: PageTypes.enum.FORM,
|
3672
3895
|
title: {
|
3673
3896
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3674
3897
|
defaultMessage: "Reason for correction",
|
@@ -3677,7 +3900,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3677
3900
|
fields: [
|
3678
3901
|
{
|
3679
3902
|
id: "correction.request.reason",
|
3680
|
-
type:
|
3903
|
+
type: FieldType.TEXT,
|
3681
3904
|
label: {
|
3682
3905
|
id: "correction.reason.title",
|
3683
3906
|
defaultMessage: "Reason for correction?",
|
@@ -3690,7 +3913,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3690
3913
|
},
|
3691
3914
|
{
|
3692
3915
|
type: ActionType.APPROVE_CORRECTION,
|
3693
|
-
forms: [TENNIS_CLUB_FORM],
|
3694
3916
|
label: {
|
3695
3917
|
defaultMessage: "Approve correction",
|
3696
3918
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3704,7 +3926,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3704
3926
|
defaultMessage: "Print certificate",
|
3705
3927
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3706
3928
|
},
|
3707
|
-
|
3929
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3708
3930
|
conditionals: [
|
3709
3931
|
{
|
3710
3932
|
type: "SHOW",
|
@@ -3751,8 +3973,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3751
3973
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3752
3974
|
defaultMessage: "Archive",
|
3753
3975
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3754
|
-
}
|
3755
|
-
forms: [TENNIS_CLUB_FORM]
|
3976
|
+
}
|
3756
3977
|
},
|
3757
3978
|
{
|
3758
3979
|
type: ActionType.REJECT,
|
@@ -3760,8 +3981,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3760
3981
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3761
3982
|
defaultMessage: "Reject",
|
3762
3983
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3763
|
-
}
|
3764
|
-
forms: [TENNIS_CLUB_FORM]
|
3984
|
+
}
|
3765
3985
|
}
|
3766
3986
|
],
|
3767
3987
|
advancedSearch: [
|
@@ -3777,33 +3997,53 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3777
3997
|
}
|
3778
3998
|
]
|
3779
3999
|
}
|
3780
|
-
]
|
4000
|
+
],
|
4001
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3781
4002
|
});
|
3782
4003
|
|
3783
4004
|
// ../commons/src/events/test.utils.ts
|
3784
|
-
function
|
3785
|
-
|
3786
|
-
const data = fields.reduce(
|
4005
|
+
function fieldConfigsToActionPayload(fields) {
|
4006
|
+
return fields.reduce(
|
3787
4007
|
(acc, field2, i) => ({
|
3788
4008
|
...acc,
|
3789
4009
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3790
4010
|
}),
|
3791
4011
|
{}
|
3792
4012
|
);
|
3793
|
-
return stripHiddenFields(fields, data);
|
3794
4013
|
}
|
3795
|
-
function
|
3796
|
-
const
|
4014
|
+
function generateActionDeclarationInput(configuration, action) {
|
4015
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
4016
|
+
if (parsed.success) {
|
4017
|
+
const fields = getDeclarationFields(configuration);
|
4018
|
+
const declarationConfig = getDeclaration(configuration);
|
4019
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4020
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
4021
|
+
}
|
4022
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
4023
|
+
return {};
|
4024
|
+
}
|
4025
|
+
function generateActionAnnotationInput(configuration, action) {
|
4026
|
+
const actionConfig = configuration.actions.find(
|
4027
|
+
(ac) => ac.type === action
|
4028
|
+
);
|
4029
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4030
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4031
|
+
const visibleVerificationPageIds = findRecordActionPages(
|
3797
4032
|
configuration,
|
3798
4033
|
action
|
3799
|
-
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page,
|
3800
|
-
|
4034
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
4035
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3801
4036
|
(acc, pageId) => ({
|
3802
4037
|
...acc,
|
3803
4038
|
[pageId]: true
|
3804
4039
|
}),
|
3805
4040
|
{}
|
3806
4041
|
);
|
4042
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4043
|
+
return {
|
4044
|
+
...fieldBasedPayload,
|
4045
|
+
...visiblePageVerificationMap
|
4046
|
+
};
|
3807
4047
|
}
|
3808
4048
|
var eventPayloadGenerator = {
|
3809
4049
|
create: (input = {}) => ({
|
@@ -3815,21 +4055,22 @@ var eventPayloadGenerator = {
|
|
3815
4055
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3816
4056
|
id
|
3817
4057
|
}),
|
3818
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4058
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3819
4059
|
{
|
3820
4060
|
id: getUUID(),
|
3821
4061
|
eventId,
|
3822
4062
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3823
4063
|
transactionId: getUUID(),
|
3824
4064
|
action: {
|
3825
|
-
type:
|
3826
|
-
|
4065
|
+
type: actionType,
|
4066
|
+
status: ActionStatus.Accepted,
|
4067
|
+
declaration: {
|
3827
4068
|
"applicant.firstname": "Max",
|
3828
4069
|
"applicant.surname": "McLaren",
|
3829
4070
|
"applicant.dob": "2020-01-02",
|
3830
4071
|
"recommender.none": true
|
3831
4072
|
},
|
3832
|
-
|
4073
|
+
annotation: {
|
3833
4074
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3834
4075
|
"correction.request.reason": "Child's name was incorrect"
|
3835
4076
|
},
|
@@ -3844,45 +4085,104 @@ var eventPayloadGenerator = {
|
|
3844
4085
|
declare: (eventId, input = {}) => ({
|
3845
4086
|
type: ActionType.DECLARE,
|
3846
4087
|
transactionId: input.transactionId ?? getUUID(),
|
3847
|
-
|
4088
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4089
|
+
tennisClubMembershipEvent,
|
4090
|
+
ActionType.DECLARE
|
4091
|
+
),
|
4092
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4093
|
+
tennisClubMembershipEvent,
|
4094
|
+
ActionType.DECLARE
|
4095
|
+
),
|
3848
4096
|
eventId
|
3849
4097
|
}),
|
4098
|
+
/**
|
4099
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4100
|
+
*/
|
4101
|
+
notify: (eventId, input = {}) => {
|
4102
|
+
let declaration = input.declaration;
|
4103
|
+
if (!declaration) {
|
4104
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4105
|
+
generateActionDeclarationInput(
|
4106
|
+
tennisClubMembershipEvent,
|
4107
|
+
ActionType.DECLARE
|
4108
|
+
),
|
4109
|
+
import_lodash2.isString
|
4110
|
+
);
|
4111
|
+
declaration = partialDeclaration;
|
4112
|
+
}
|
4113
|
+
return {
|
4114
|
+
type: ActionType.NOTIFY,
|
4115
|
+
transactionId: input.transactionId ?? getUUID(),
|
4116
|
+
declaration,
|
4117
|
+
eventId
|
4118
|
+
};
|
4119
|
+
},
|
3850
4120
|
validate: (eventId, input = {}) => ({
|
3851
4121
|
type: ActionType.VALIDATE,
|
3852
4122
|
transactionId: input.transactionId ?? getUUID(),
|
3853
|
-
|
4123
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4124
|
+
tennisClubMembershipEvent,
|
4125
|
+
ActionType.VALIDATE
|
4126
|
+
),
|
4127
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4128
|
+
tennisClubMembershipEvent,
|
4129
|
+
ActionType.VALIDATE
|
4130
|
+
),
|
3854
4131
|
duplicates: [],
|
3855
4132
|
eventId
|
3856
4133
|
}),
|
4134
|
+
assign: (eventId, input = {}) => ({
|
4135
|
+
type: ActionType.ASSIGN,
|
4136
|
+
transactionId: input.transactionId ?? getUUID(),
|
4137
|
+
declaration: {},
|
4138
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4139
|
+
eventId
|
4140
|
+
}),
|
4141
|
+
unassign: (eventId, input = {}) => ({
|
4142
|
+
type: ActionType.UNASSIGN,
|
4143
|
+
transactionId: input.transactionId ?? getUUID(),
|
4144
|
+
declaration: {},
|
4145
|
+
assignedTo: null,
|
4146
|
+
eventId
|
4147
|
+
}),
|
3857
4148
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3858
4149
|
type: ActionType.ARCHIVE,
|
3859
4150
|
transactionId: input.transactionId ?? getUUID(),
|
3860
|
-
|
3861
|
-
|
4151
|
+
declaration: {},
|
4152
|
+
// @TODO: Check whether generator is needed?
|
4153
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3862
4154
|
duplicates: [],
|
3863
4155
|
eventId
|
3864
4156
|
}),
|
3865
4157
|
reject: (eventId, input = {}) => ({
|
3866
4158
|
type: ActionType.REJECT,
|
3867
4159
|
transactionId: input.transactionId ?? getUUID(),
|
3868
|
-
|
4160
|
+
declaration: {},
|
4161
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4162
|
+
tennisClubMembershipEvent,
|
4163
|
+
ActionType.REJECT
|
4164
|
+
),
|
3869
4165
|
duplicates: [],
|
3870
4166
|
eventId
|
3871
4167
|
}),
|
3872
4168
|
register: (eventId, input = {}) => ({
|
3873
4169
|
type: ActionType.REGISTER,
|
3874
4170
|
transactionId: input.transactionId ?? getUUID(),
|
3875
|
-
|
4171
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4172
|
+
tennisClubMembershipEvent,
|
4173
|
+
ActionType.REGISTER
|
4174
|
+
),
|
4175
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4176
|
+
tennisClubMembershipEvent,
|
4177
|
+
ActionType.REGISTER
|
4178
|
+
),
|
3876
4179
|
eventId
|
3877
4180
|
}),
|
3878
4181
|
printCertificate: (eventId, input = {}) => ({
|
3879
4182
|
type: ActionType.PRINT_CERTIFICATE,
|
3880
4183
|
transactionId: input.transactionId ?? getUUID(),
|
3881
|
-
|
3882
|
-
|
3883
|
-
ActionType.PRINT_CERTIFICATE
|
3884
|
-
),
|
3885
|
-
metadata: input.metadata ?? generateActionMetadataInput(
|
4184
|
+
declaration: {},
|
4185
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3886
4186
|
tennisClubMembershipEvent,
|
3887
4187
|
ActionType.PRINT_CERTIFICATE
|
3888
4188
|
),
|
@@ -3892,17 +4192,21 @@ var eventPayloadGenerator = {
|
|
3892
4192
|
request: (eventId, input = {}) => ({
|
3893
4193
|
type: ActionType.REQUEST_CORRECTION,
|
3894
4194
|
transactionId: input.transactionId ?? getUUID(),
|
3895
|
-
|
4195
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4196
|
+
tennisClubMembershipEvent,
|
4197
|
+
ActionType.REQUEST_CORRECTION
|
4198
|
+
),
|
4199
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3896
4200
|
tennisClubMembershipEvent,
|
3897
4201
|
ActionType.REQUEST_CORRECTION
|
3898
4202
|
),
|
3899
|
-
metadata: {},
|
3900
4203
|
eventId
|
3901
4204
|
}),
|
3902
4205
|
approve: (eventId, requestId, input = {}) => ({
|
3903
4206
|
type: ActionType.APPROVE_CORRECTION,
|
3904
4207
|
transactionId: input.transactionId ?? getUUID(),
|
3905
|
-
|
4208
|
+
declaration: {},
|
4209
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3906
4210
|
tennisClubMembershipEvent,
|
3907
4211
|
ActionType.APPROVE_CORRECTION
|
3908
4212
|
),
|
@@ -3912,7 +4216,8 @@ var eventPayloadGenerator = {
|
|
3912
4216
|
reject: (eventId, requestId, input = {}) => ({
|
3913
4217
|
type: ActionType.REJECT_CORRECTION,
|
3914
4218
|
transactionId: input.transactionId ?? getUUID(),
|
3915
|
-
|
4219
|
+
declaration: {},
|
4220
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3916
4221
|
tennisClubMembershipEvent,
|
3917
4222
|
ActionType.REJECT_CORRECTION
|
3918
4223
|
),
|
@@ -3934,15 +4239,20 @@ function generateActionDocument({
|
|
3934
4239
|
createdBy: getUUID(),
|
3935
4240
|
id: getUUID(),
|
3936
4241
|
createdAtLocation: "TODO",
|
3937
|
-
|
3938
|
-
|
3939
|
-
...defaults
|
4242
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4243
|
+
annotation: {},
|
4244
|
+
...defaults,
|
4245
|
+
status: ActionStatus.Accepted
|
3940
4246
|
};
|
3941
4247
|
switch (action) {
|
4248
|
+
case ActionType.READ:
|
4249
|
+
return { ...actionBase, type: action };
|
4250
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4251
|
+
return { ...actionBase, type: action };
|
3942
4252
|
case ActionType.DECLARE:
|
3943
4253
|
return { ...actionBase, type: action };
|
3944
4254
|
case ActionType.UNASSIGN:
|
3945
|
-
return { ...actionBase, type: action };
|
4255
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3946
4256
|
case ActionType.ASSIGN:
|
3947
4257
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3948
4258
|
case ActionType.VALIDATE:
|
@@ -3963,14 +4273,13 @@ function generateActionDocument({
|
|
3963
4273
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3964
4274
|
case ActionType.REJECT_CORRECTION:
|
3965
4275
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3966
|
-
case ActionType.CUSTOM:
|
3967
|
-
return { ...actionBase, type: action };
|
3968
4276
|
case ActionType.REGISTER:
|
3969
4277
|
return {
|
3970
4278
|
...actionBase,
|
3971
|
-
type: action
|
3972
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4279
|
+
type: action
|
3973
4280
|
};
|
4281
|
+
case ActionType.DELETE:
|
4282
|
+
case ActionType.DETECT_DUPLICATE:
|
3974
4283
|
default:
|
3975
4284
|
throw new Error(`Unsupported action type: ${action}`);
|
3976
4285
|
}
|
@@ -3991,10 +4300,11 @@ function generateEventDocument({
|
|
3991
4300
|
id: getUUID(),
|
3992
4301
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3993
4302
|
// @TODO: This should be fixed in the future.
|
3994
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4303
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4304
|
+
updatedAtLocation: "TODO"
|
3995
4305
|
};
|
3996
4306
|
}
|
3997
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4307
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3998
4308
|
const action = generateActionDocument({
|
3999
4309
|
configuration: tennisClubMembershipEvent,
|
4000
4310
|
action: actionType
|
@@ -4004,9 +4314,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
4004
4314
|
transactionId: getUUID(),
|
4005
4315
|
action: {
|
4006
4316
|
...action,
|
4007
|
-
|
4008
|
-
...action.
|
4009
|
-
...
|
4317
|
+
declaration: {
|
4318
|
+
...action.declaration,
|
4319
|
+
...declaration
|
4010
4320
|
}
|
4011
4321
|
},
|
4012
4322
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -4020,10 +4330,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4020
4330
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4021
4331
|
createdBy: overrides.createdBy ?? getUUID(),
|
4022
4332
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
4333
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4023
4334
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4024
4335
|
assignedTo: overrides.assignedTo ?? null,
|
4025
4336
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4026
|
-
|
4337
|
+
declaration: overrides.declaration ?? {
|
4027
4338
|
"recommender.none": true,
|
4028
4339
|
"applicant.firstname": "Danny",
|
4029
4340
|
"applicant.surname": "Doe",
|
@@ -4054,7 +4365,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
4054
4365
|
return true;
|
4055
4366
|
}
|
4056
4367
|
function isFieldConfigDefaultValue(value) {
|
4057
|
-
if (!value)
|
4368
|
+
if (!value) {
|
4369
|
+
return false;
|
4370
|
+
}
|
4058
4371
|
if (isFieldValue(value)) {
|
4059
4372
|
return true;
|
4060
4373
|
}
|
@@ -4066,3 +4379,189 @@ function isFieldConfigDefaultValue(value) {
|
|
4066
4379
|
}
|
4067
4380
|
return false;
|
4068
4381
|
}
|
4382
|
+
|
4383
|
+
// ../commons/src/events/scopes.ts
|
4384
|
+
var import_lodash3 = require("lodash");
|
4385
|
+
|
4386
|
+
// ../commons/src/scopes.ts
|
4387
|
+
var SCOPES = {
|
4388
|
+
// TODO v1.8 legacy scopes
|
4389
|
+
NATLSYSADMIN: "natlsysadmin",
|
4390
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
4391
|
+
DECLARE: "declare",
|
4392
|
+
REGISTER: "register",
|
4393
|
+
VALIDATE: "validate",
|
4394
|
+
DEMO: "demo",
|
4395
|
+
CERTIFY: "certify",
|
4396
|
+
PERFORMANCE: "performance",
|
4397
|
+
SYSADMIN: "sysadmin",
|
4398
|
+
TEAMS: "teams",
|
4399
|
+
CONFIG: "config",
|
4400
|
+
// systems / integrations
|
4401
|
+
WEBHOOK: "webhook",
|
4402
|
+
NATIONALID: "nationalId",
|
4403
|
+
NOTIFICATION_API: "notification-api",
|
4404
|
+
RECORDSEARCH: "recordsearch",
|
4405
|
+
/**
|
4406
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4407
|
+
*/
|
4408
|
+
RECORD_DECLARE: "record.declare-birth",
|
4409
|
+
// declare
|
4410
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4411
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4412
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
4413
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4414
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4415
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4416
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4417
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4418
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4419
|
+
// validate
|
4420
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4421
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4422
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4423
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4424
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4425
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4426
|
+
// register
|
4427
|
+
RECORD_REGISTER: "record.register",
|
4428
|
+
// certify
|
4429
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
4430
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4431
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4432
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4433
|
+
// v1.8
|
4434
|
+
/**
|
4435
|
+
* This scope is used to **print and **issue certified copies of a record
|
4436
|
+
* after it has been registered. Previously Registrars had this permission.
|
4437
|
+
*/
|
4438
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4439
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4440
|
+
// v1.8
|
4441
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4442
|
+
// v1.8
|
4443
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4444
|
+
// v1.8
|
4445
|
+
// correct
|
4446
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4447
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4448
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4449
|
+
// v1.8
|
4450
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4451
|
+
// v1.8
|
4452
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4453
|
+
// v1.8
|
4454
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4455
|
+
// v1.8
|
4456
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4457
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4458
|
+
// search
|
4459
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4460
|
+
SEARCH_BIRTH: "search.birth",
|
4461
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4462
|
+
SEARCH_DEATH: "search.death",
|
4463
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4464
|
+
SEARCH_MARRIAGE: "search.marriage",
|
4465
|
+
// audit v1.8
|
4466
|
+
RECORD_READ: "record.read",
|
4467
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
4468
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
4469
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4470
|
+
// profile
|
4471
|
+
PROFILE_UPDATE: "profile.update",
|
4472
|
+
//v1.8
|
4473
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4474
|
+
// performance
|
4475
|
+
PERFORMANCE_READ: "performance.read",
|
4476
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4477
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4478
|
+
// organisation
|
4479
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4480
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4481
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4482
|
+
// user
|
4483
|
+
USER_READ: "user.read:all",
|
4484
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
4485
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4486
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4487
|
+
//v1.8
|
4488
|
+
USER_CREATE: "user.create:all",
|
4489
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4490
|
+
USER_UPDATE: "user.update:all",
|
4491
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4492
|
+
// config
|
4493
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
4494
|
+
// data seeding
|
4495
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
4496
|
+
};
|
4497
|
+
var scopes = Object.values(SCOPES);
|
4498
|
+
|
4499
|
+
// ../commons/src/events/scopes.ts
|
4500
|
+
function hasAnyOfScopes(a, b) {
|
4501
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4502
|
+
}
|
4503
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
4504
|
+
SCOPES.RECORD_DECLARE,
|
4505
|
+
SCOPES.RECORD_READ,
|
4506
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4507
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4508
|
+
SCOPES.RECORD_REGISTER,
|
4509
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
4510
|
+
SCOPES.CONFIG,
|
4511
|
+
SCOPES.CONFIG_UPDATE_ALL
|
4512
|
+
];
|
4513
|
+
var ACTION_ALLOWED_SCOPES = {
|
4514
|
+
[ActionType.READ]: [
|
4515
|
+
SCOPES.RECORD_DECLARE,
|
4516
|
+
SCOPES.RECORD_READ,
|
4517
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4518
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4519
|
+
SCOPES.RECORD_REGISTER,
|
4520
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
4521
|
+
],
|
4522
|
+
[ActionType.CREATE]: [
|
4523
|
+
SCOPES.RECORD_DECLARE,
|
4524
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4525
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
4526
|
+
],
|
4527
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
4528
|
+
[ActionType.DECLARE]: [
|
4529
|
+
SCOPES.RECORD_DECLARE,
|
4530
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4531
|
+
SCOPES.RECORD_REGISTER
|
4532
|
+
],
|
4533
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
4534
|
+
[ActionType.VALIDATE]: [
|
4535
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4536
|
+
SCOPES.RECORD_REGISTER
|
4537
|
+
],
|
4538
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
4539
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
4540
|
+
[ActionType.REQUEST_CORRECTION]: [
|
4541
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
4542
|
+
],
|
4543
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4544
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4545
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4546
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4547
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
4548
|
+
[ActionType.ASSIGN]: null,
|
4549
|
+
[ActionType.UNASSIGN]: null,
|
4550
|
+
[ActionType.DETECT_DUPLICATE]: []
|
4551
|
+
};
|
4552
|
+
function filterUnallowedActions(actions, userScopes) {
|
4553
|
+
const allowedActions = actions.filter((action) => {
|
4554
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
4555
|
+
if (requiredScopes === null) {
|
4556
|
+
return true;
|
4557
|
+
}
|
4558
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
4559
|
+
});
|
4560
|
+
const hasOtherAllowedActions = allowedActions.some(
|
4561
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
4562
|
+
);
|
4563
|
+
if (hasOtherAllowedActions) {
|
4564
|
+
return allowedActions;
|
4565
|
+
}
|
4566
|
+
return [ActionType.READ];
|
4567
|
+
}
|