@opencrvs/toolkit 1.8.0-rc.fe799b0 → 1.8.0-rc.fef85f2
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 +6711 -9366
- package/dist/commons/conditionals/conditionals.d.ts +26 -3
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +39 -17
- package/dist/commons/conditionals/validate.test.d.ts +2 -0
- package/dist/commons/events/ActionConfig.d.ts +1116 -2067
- package/dist/commons/events/ActionDocument.d.ts +9488 -312
- package/dist/commons/events/ActionInput.d.ts +5331 -558
- package/dist/commons/events/ActionType.d.ts +27 -12
- package/dist/commons/events/CompositeFieldValue.d.ts +155 -2
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +351 -51
- package/dist/commons/events/EventConfig.d.ts +704 -1245
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +3348 -429
- 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 +568 -74
- package/dist/commons/events/FieldType.d.ts +6 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +154 -3
- package/dist/commons/events/FieldValue.d.ts +76 -2
- package/dist/commons/events/FormConfig.d.ts +633 -48
- 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 +38 -0
- package/dist/commons/events/User.d.ts +5 -0
- package/dist/commons/events/defineConfig.d.ts +104 -224
- package/dist/commons/events/index.d.ts +4 -1
- package/dist/commons/events/scopes.d.ts +25 -0
- package/dist/commons/events/test.utils.d.ts +141 -214
- package/dist/commons/events/utils.d.ts +196 -69
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +166 -81
- package/dist/events/index.js +1747 -839
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -30,29 +30,48 @@ 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,
|
48
|
+
AddressType: () => AddressType,
|
49
|
+
AdministrativeAreas: () => AdministrativeAreas,
|
43
50
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
44
51
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
45
|
-
|
52
|
+
ArchiveActionInput: () => ArchiveActionInput,
|
53
|
+
AssignActionInput: () => AssignActionInput,
|
54
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
46
55
|
BaseActionInput: () => BaseActionInput,
|
56
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
47
57
|
CertificateConfig: () => CertificateConfig,
|
48
58
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
49
59
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
50
60
|
Clause: () => Clause,
|
51
61
|
Conditional: () => Conditional,
|
52
62
|
ConditionalType: () => ConditionalType,
|
63
|
+
ConfirmableActions: () => ConfirmableActions,
|
64
|
+
DataEntry: () => DataEntry,
|
65
|
+
DataFieldValue: () => DataFieldValue,
|
53
66
|
DateValue: () => DateValue,
|
67
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
68
|
+
DeclarationActions: () => DeclarationActions,
|
69
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
70
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
71
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
54
72
|
DeclareActionInput: () => DeclareActionInput,
|
55
73
|
DeduplicationConfig: () => DeduplicationConfig,
|
74
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
56
75
|
Draft: () => Draft,
|
57
76
|
DraftInput: () => DraftInput,
|
58
77
|
EmailField: () => EmailField,
|
@@ -66,6 +85,7 @@ __export(events_exports, {
|
|
66
85
|
EventSearchIndex: () => EventSearchIndex,
|
67
86
|
EventStatus: () => EventStatus,
|
68
87
|
EventStatuses: () => EventStatuses,
|
88
|
+
FieldConditional: () => FieldConditional,
|
69
89
|
FieldConfig: () => FieldConfig,
|
70
90
|
FieldType: () => FieldType,
|
71
91
|
FieldUpdateValue: () => FieldUpdateValue,
|
@@ -74,13 +94,21 @@ __export(events_exports, {
|
|
74
94
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
75
95
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
76
96
|
FormConfig: () => FormConfig,
|
77
|
-
|
97
|
+
FormPageConfig: () => FormPageConfig,
|
98
|
+
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
99
|
+
GenericAddressValue: () => GenericAddressValue,
|
78
100
|
GeographicalArea: () => GeographicalArea,
|
101
|
+
ImageMimeType: () => ImageMimeType,
|
79
102
|
LanguageConfig: () => LanguageConfig,
|
80
103
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
104
|
+
MimeType: () => MimeType,
|
81
105
|
NotifyActionInput: () => NotifyActionInput,
|
82
106
|
NumberFieldValue: () => NumberFieldValue,
|
107
|
+
PageConfig: () => PageConfig,
|
108
|
+
PageTypes: () => PageTypes,
|
83
109
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
110
|
+
ReadActionInput: () => ReadActionInput,
|
111
|
+
RegisterAction: () => RegisterAction,
|
84
112
|
RegisterActionInput: () => RegisterActionInput,
|
85
113
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
86
114
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -93,19 +121,31 @@ __export(events_exports, {
|
|
93
121
|
SummaryConfig: () => SummaryConfig,
|
94
122
|
TextValue: () => TextValue,
|
95
123
|
TranslationConfig: () => TranslationConfig,
|
124
|
+
UnassignActionInput: () => UnassignActionInput,
|
96
125
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
97
126
|
UrbanAddressValue: () => UrbanAddressValue,
|
98
127
|
ValidateActionInput: () => ValidateActionInput,
|
128
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
129
|
+
VerificationPageConfig: () => VerificationPageConfig,
|
99
130
|
WorkqueueConfig: () => WorkqueueConfig,
|
100
131
|
alwaysTrue: () => alwaysTrue,
|
101
132
|
and: () => and,
|
133
|
+
annotationActions: () => annotationActions,
|
102
134
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
135
|
+
areConditionsMet: () => areConditionsMet,
|
136
|
+
compositeFieldTypes: () => compositeFieldTypes,
|
137
|
+
createEmptyDraft: () => createEmptyDraft,
|
103
138
|
createValidationSchema: () => createValidationSchema,
|
104
139
|
deepDropNulls: () => deepDropNulls,
|
140
|
+
deepMerge: () => deepMerge,
|
141
|
+
defineActionForm: () => defineActionForm,
|
105
142
|
defineConditional: () => defineConditional,
|
106
143
|
defineConfig: () => defineConfig,
|
107
|
-
|
144
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
145
|
+
defineFormConditional: () => defineFormConditional,
|
108
146
|
defineFormPage: () => defineFormPage,
|
147
|
+
definePage: () => definePage,
|
148
|
+
errorMessages: () => errorMessages,
|
109
149
|
event: () => event,
|
110
150
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
111
151
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
@@ -113,36 +153,47 @@ __export(events_exports, {
|
|
113
153
|
eventStatuses: () => eventStatuses,
|
114
154
|
field: () => field,
|
115
155
|
fieldTypes: () => fieldTypes,
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
156
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
157
|
+
findActiveDrafts: () => findActiveDrafts,
|
158
|
+
findAllFields: () => findAllFields,
|
159
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
160
|
+
findRecordActionPages: () => findRecordActionPages,
|
161
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
162
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
122
163
|
generateActionDocument: () => generateActionDocument,
|
123
|
-
generateActionInput: () => generateActionInput,
|
124
164
|
generateEventDocument: () => generateEventDocument,
|
125
165
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
126
166
|
generateTransactionId: () => generateTransactionId,
|
127
|
-
|
128
|
-
|
129
|
-
|
167
|
+
generateTranslationConfig: () => generateTranslationConfig,
|
168
|
+
getAcceptedActions: () => getAcceptedActions,
|
169
|
+
getActionAnnotation: () => getActionAnnotation,
|
170
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
171
|
+
getActionReview: () => getActionReview,
|
172
|
+
getActionReviewFields: () => getActionReviewFields,
|
173
|
+
getAllAnnotationFields: () => getAllAnnotationFields,
|
174
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
130
175
|
getCurrentEventState: () => getCurrentEventState,
|
131
176
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
177
|
+
getDeclaration: () => getDeclaration,
|
178
|
+
getDeclarationFields: () => getDeclarationFields,
|
179
|
+
getDeclarationPages: () => getDeclarationPages,
|
180
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
136
181
|
isAddressFieldType: () => isAddressFieldType,
|
137
182
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
138
183
|
isBulletListFieldType: () => isBulletListFieldType,
|
139
184
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
185
|
+
isConditionMet: () => isConditionMet,
|
140
186
|
isCountryFieldType: () => isCountryFieldType,
|
187
|
+
isDataFieldType: () => isDataFieldType,
|
141
188
|
isDateFieldType: () => isDateFieldType,
|
142
189
|
isDividerFieldType: () => isDividerFieldType,
|
143
190
|
isEmailFieldType: () => isEmailFieldType,
|
144
191
|
isFacilityFieldType: () => isFacilityFieldType,
|
192
|
+
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
193
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
145
194
|
isFieldEnabled: () => isFieldEnabled,
|
195
|
+
isFieldValue: () => isFieldValue,
|
196
|
+
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
146
197
|
isFieldVisible: () => isFieldVisible,
|
147
198
|
isFileFieldType: () => isFileFieldType,
|
148
199
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
@@ -150,56 +201,81 @@ __export(events_exports, {
|
|
150
201
|
isNumberFieldType: () => isNumberFieldType,
|
151
202
|
isOfficeFieldType: () => isOfficeFieldType,
|
152
203
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
204
|
+
isPageVisible: () => isPageVisible,
|
153
205
|
isParagraphFieldType: () => isParagraphFieldType,
|
154
206
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
155
207
|
isSelectFieldType: () => isSelectFieldType,
|
156
208
|
isSignatureFieldType: () => isSignatureFieldType,
|
209
|
+
isTemplateVariable: () => isTemplateVariable,
|
157
210
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
158
211
|
isTextFieldType: () => isTextFieldType,
|
159
212
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
213
|
+
isVerificationPage: () => isVerificationPage,
|
214
|
+
isWriteAction: () => isWriteAction,
|
215
|
+
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
160
216
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
161
217
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
218
|
+
never: () => never,
|
162
219
|
not: () => not,
|
220
|
+
omitHiddenFields: () => omitHiddenFields,
|
221
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
163
222
|
or: () => or,
|
164
|
-
|
165
|
-
stripHiddenFields: () => stripHiddenFields,
|
223
|
+
runFieldValidations: () => runFieldValidations,
|
166
224
|
user: () => user,
|
167
225
|
validate: () => validate,
|
168
226
|
validateFieldInput: () => validateFieldInput,
|
169
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
227
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
228
|
+
writeActions: () => writeActions
|
170
229
|
});
|
171
230
|
module.exports = __toCommonJS(events_exports);
|
172
231
|
|
173
232
|
// ../commons/src/events/ActionConfig.ts
|
174
|
-
var
|
233
|
+
var import_zod9 = require("zod");
|
175
234
|
|
176
235
|
// ../commons/src/events/Conditional.ts
|
177
236
|
var import_zod = require("zod");
|
178
|
-
|
179
|
-
|
180
|
-
|
237
|
+
var Conditional = import_zod.z.custom(
|
238
|
+
(val) => typeof val === "object" && val !== null
|
239
|
+
);
|
181
240
|
var ConditionalType = {
|
182
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
183
241
|
SHOW: "SHOW",
|
184
|
-
|
185
|
-
|
242
|
+
ENABLE: "ENABLE",
|
243
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
186
244
|
};
|
187
245
|
var ShowConditional = import_zod.z.object({
|
188
246
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
189
|
-
conditional: Conditional
|
190
|
-
})
|
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
|
+
);
|
191
251
|
var EnableConditional = import_zod.z.object({
|
192
252
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
193
|
-
conditional: Conditional
|
194
|
-
})
|
253
|
+
conditional: Conditional
|
254
|
+
}).describe(
|
255
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
256
|
+
);
|
195
257
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
196
258
|
// Action can be shown / hidden
|
197
259
|
ShowConditional,
|
198
260
|
// Action can be shown to the user in the list but as disabled
|
199
261
|
EnableConditional
|
200
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
|
+
]);
|
201
277
|
|
202
|
-
// ../commons/src/events/
|
278
|
+
// ../commons/src/events/PageConfig.ts
|
203
279
|
var import_zod6 = require("zod");
|
204
280
|
|
205
281
|
// ../commons/src/events/FieldConfig.ts
|
@@ -240,9 +316,15 @@ var FieldType = {
|
|
240
316
|
ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
|
241
317
|
FACILITY: "FACILITY",
|
242
318
|
OFFICE: "OFFICE",
|
243
|
-
SIGNATURE: "SIGNATURE"
|
319
|
+
SIGNATURE: "SIGNATURE",
|
320
|
+
DATA: "DATA"
|
244
321
|
};
|
245
322
|
var fieldTypes = Object.values(FieldType);
|
323
|
+
var compositeFieldTypes = [
|
324
|
+
FieldType.ADDRESS,
|
325
|
+
FieldType.FILE_WITH_OPTIONS,
|
326
|
+
FieldType.FILE
|
327
|
+
];
|
246
328
|
|
247
329
|
// ../commons/src/events/FieldValue.ts
|
248
330
|
var import_zod4 = require("zod");
|
@@ -253,6 +335,10 @@ var GeographicalArea = {
|
|
253
335
|
URBAN: "URBAN",
|
254
336
|
RURAL: "RURAL"
|
255
337
|
};
|
338
|
+
var AddressType = {
|
339
|
+
DOMESTIC: "DOMESTIC",
|
340
|
+
INTERNATIONAL: "INTERNATIONAL"
|
341
|
+
};
|
256
342
|
var FileFieldValue = import_zod3.z.object({
|
257
343
|
filename: import_zod3.z.string(),
|
258
344
|
originalFilename: import_zod3.z.string(),
|
@@ -260,6 +346,7 @@ var FileFieldValue = import_zod3.z.object({
|
|
260
346
|
});
|
261
347
|
var AdminStructure = import_zod3.z.object({
|
262
348
|
country: import_zod3.z.string(),
|
349
|
+
addressType: import_zod3.z.literal(AddressType.DOMESTIC),
|
263
350
|
province: import_zod3.z.string(),
|
264
351
|
district: import_zod3.z.string()
|
265
352
|
});
|
@@ -287,14 +374,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
|
|
287
374
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
288
375
|
village: import_zod3.z.string().nullish()
|
289
376
|
});
|
290
|
-
var
|
291
|
-
|
292
|
-
|
293
|
-
|
377
|
+
var GenericAddressValue = import_zod3.z.object({
|
378
|
+
country: import_zod3.z.string(),
|
379
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
380
|
+
state: import_zod3.z.string(),
|
381
|
+
district2: import_zod3.z.string(),
|
382
|
+
cityOrTown: import_zod3.z.string().optional(),
|
383
|
+
addressLine1: import_zod3.z.string().optional(),
|
384
|
+
addressLine2: import_zod3.z.string().optional(),
|
385
|
+
addressLine3: import_zod3.z.string().optional(),
|
386
|
+
postcodeOrZip: import_zod3.z.string().optional()
|
387
|
+
});
|
388
|
+
var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
|
389
|
+
var GenericAddressUpdateValue = import_zod3.z.object({
|
390
|
+
country: import_zod3.z.string(),
|
391
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
392
|
+
state: import_zod3.z.string(),
|
393
|
+
district2: import_zod3.z.string(),
|
394
|
+
cityOrTown: import_zod3.z.string().nullish(),
|
395
|
+
addressLine1: import_zod3.z.string().nullish(),
|
396
|
+
addressLine2: import_zod3.z.string().nullish(),
|
397
|
+
addressLine3: import_zod3.z.string().nullish(),
|
398
|
+
postcodeOrZip: import_zod3.z.string().nullish()
|
399
|
+
});
|
294
400
|
var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
|
295
401
|
UrbanAddressUpdateValue,
|
296
402
|
RuralAddressUpdateValue
|
297
|
-
]);
|
403
|
+
]).or(GenericAddressUpdateValue);
|
298
404
|
var FileFieldValueWithOption = import_zod3.z.object({
|
299
405
|
filename: import_zod3.z.string(),
|
300
406
|
originalFilename: import_zod3.z.string(),
|
@@ -310,6 +416,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
|
|
310
416
|
var EmailValue = import_zod4.z.string().email();
|
311
417
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
312
418
|
var NumberFieldValue = import_zod4.z.number();
|
419
|
+
var DataFieldValue = import_zod4.z.undefined();
|
313
420
|
var FieldValue = import_zod4.z.union([
|
314
421
|
TextValue,
|
315
422
|
DateValue,
|
@@ -318,7 +425,9 @@ var FieldValue = import_zod4.z.union([
|
|
318
425
|
FileFieldValue,
|
319
426
|
FileFieldWithOptionValue,
|
320
427
|
UrbanAddressValue,
|
321
|
-
RuralAddressValue
|
428
|
+
RuralAddressValue,
|
429
|
+
DataFieldValue,
|
430
|
+
GenericAddressValue
|
322
431
|
]);
|
323
432
|
var FieldUpdateValue = import_zod4.z.union([
|
324
433
|
TextValue,
|
@@ -328,7 +437,9 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
328
437
|
FileFieldValue,
|
329
438
|
FileFieldWithOptionValue,
|
330
439
|
UrbanAddressUpdateValue,
|
331
|
-
RuralAddressUpdateValue
|
440
|
+
RuralAddressUpdateValue,
|
441
|
+
DataFieldValue,
|
442
|
+
GenericAddressUpdateValue
|
332
443
|
]);
|
333
444
|
|
334
445
|
// ../commons/src/events/FieldConfig.ts
|
@@ -350,14 +461,14 @@ var BaseField = import_zod5.z.object({
|
|
350
461
|
]),
|
351
462
|
DependencyExpression
|
352
463
|
]).optional(),
|
353
|
-
conditionals: import_zod5.z.array(
|
464
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
354
465
|
required: import_zod5.z.boolean().default(false).optional(),
|
355
466
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
356
467
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
357
468
|
placeholder: TranslationConfig.optional(),
|
358
469
|
validation: import_zod5.z.array(
|
359
470
|
import_zod5.z.object({
|
360
|
-
validator: Conditional
|
471
|
+
validator: Conditional,
|
361
472
|
message: TranslationConfig
|
362
473
|
})
|
363
474
|
).default([]).optional(),
|
@@ -399,15 +510,25 @@ var TextAreaField = BaseField.extend({
|
|
399
510
|
postfix: TranslationConfig.optional()
|
400
511
|
}).default({ rows: 4 }).optional()
|
401
512
|
}).describe("Multiline text input");
|
513
|
+
var ImageMimeType = import_zod5.z.enum([
|
514
|
+
"image/png",
|
515
|
+
"image/jpg",
|
516
|
+
"image/jpeg",
|
517
|
+
"image/svg+xml"
|
518
|
+
]);
|
519
|
+
var MimeType = ImageMimeType;
|
520
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
402
521
|
var SignatureField = BaseField.extend({
|
403
522
|
type: import_zod5.z.literal(FieldType.SIGNATURE),
|
404
523
|
signaturePromptLabel: TranslationConfig.describe(
|
405
524
|
"Title of the signature modal"
|
406
525
|
),
|
407
526
|
configuration: import_zod5.z.object({
|
408
|
-
|
409
|
-
|
410
|
-
}).default({
|
527
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
528
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
529
|
+
}).default({
|
530
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
531
|
+
})
|
411
532
|
}).describe("Signature input field");
|
412
533
|
var EmailField = BaseField.extend({
|
413
534
|
type: import_zod5.z.literal(FieldType.EMAIL),
|
@@ -450,13 +571,18 @@ var PageHeader = BaseField.extend({
|
|
450
571
|
}).describe("A read-only header component for form pages");
|
451
572
|
var File = BaseField.extend({
|
452
573
|
type: import_zod5.z.literal(FieldType.FILE),
|
453
|
-
|
574
|
+
configuration: import_zod5.z.object({
|
575
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
576
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
454
577
|
style: import_zod5.z.object({
|
455
|
-
|
578
|
+
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
456
579
|
"Whether the file upload button should take the full width of the container or not"
|
457
580
|
)
|
458
|
-
})
|
459
|
-
|
581
|
+
}).optional(),
|
582
|
+
fileName: TranslationConfig.optional()
|
583
|
+
}).default({
|
584
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
585
|
+
})
|
460
586
|
}).describe("File upload");
|
461
587
|
var SelectOption = import_zod5.z.object({
|
462
588
|
value: import_zod5.z.string().describe("The value of the option"),
|
@@ -495,11 +621,16 @@ var Country = BaseField.extend({
|
|
495
621
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
496
622
|
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
497
623
|
}).describe("Country select field");
|
624
|
+
var AdministrativeAreas = import_zod5.z.enum([
|
625
|
+
"ADMIN_STRUCTURE",
|
626
|
+
"HEALTH_FACILITY",
|
627
|
+
"CRVS_OFFICE"
|
628
|
+
]);
|
498
629
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
499
630
|
partOf: import_zod5.z.object({
|
500
|
-
$
|
631
|
+
$declaration: import_zod5.z.string()
|
501
632
|
}).optional().describe("Parent location"),
|
502
|
-
type:
|
633
|
+
type: AdministrativeAreas
|
503
634
|
}).describe("Administrative area options");
|
504
635
|
var AdministrativeArea = BaseField.extend({
|
505
636
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
@@ -512,8 +643,14 @@ var Location = BaseField.extend({
|
|
512
643
|
}).describe("Input field for a location");
|
513
644
|
var FileUploadWithOptions = BaseField.extend({
|
514
645
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
515
|
-
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
516
|
-
|
646
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
647
|
+
configuration: import_zod5.z.object({
|
648
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
649
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
650
|
+
}).default({
|
651
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
652
|
+
})
|
653
|
+
});
|
517
654
|
var Facility = BaseField.extend({
|
518
655
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
519
656
|
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
@@ -526,6 +663,22 @@ var Address = BaseField.extend({
|
|
526
663
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
527
664
|
defaultValue: AddressFieldValue.optional()
|
528
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
|
+
]);
|
675
|
+
var DataField = BaseField.extend({
|
676
|
+
type: import_zod5.z.literal(FieldType.DATA),
|
677
|
+
configuration: import_zod5.z.object({
|
678
|
+
subtitle: TranslationConfig.optional(),
|
679
|
+
data: import_zod5.z.array(DataEntry)
|
680
|
+
})
|
681
|
+
}).describe("Data field for displaying read-only data");
|
529
682
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
530
683
|
Address,
|
531
684
|
TextField,
|
@@ -547,244 +700,322 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
547
700
|
Office,
|
548
701
|
SignatureField,
|
549
702
|
EmailField,
|
550
|
-
FileUploadWithOptions
|
703
|
+
FileUploadWithOptions,
|
704
|
+
DataField
|
705
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
551
706
|
]);
|
552
707
|
|
553
|
-
// ../commons/src/events/
|
554
|
-
var
|
708
|
+
// ../commons/src/events/PageConfig.ts
|
709
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
710
|
+
var PageConfigBase = import_zod6.z.object({
|
555
711
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
556
712
|
title: TranslationConfig.describe("Header title of the page"),
|
557
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
713
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
714
|
+
conditional: Conditional.optional().describe(
|
715
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
716
|
+
)
|
558
717
|
});
|
559
|
-
var
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
label: TranslationConfig
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
pages: import_zod6.z.array(FormPage),
|
571
|
-
review: import_zod6.z.object({
|
572
|
-
title: TranslationConfig.describe(
|
573
|
-
"Title of the form to show in review page"
|
574
|
-
),
|
575
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
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({
|
722
|
+
verify: import_zod6.z.object({ label: TranslationConfig }),
|
723
|
+
cancel: import_zod6.z.object({
|
724
|
+
label: TranslationConfig,
|
725
|
+
confirmation: import_zod6.z.object({
|
726
|
+
title: TranslationConfig,
|
727
|
+
body: TranslationConfig
|
728
|
+
})
|
576
729
|
})
|
730
|
+
}).describe("Actions available on the verification page");
|
731
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
732
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
733
|
+
actions: VerificationActionConfig
|
577
734
|
});
|
735
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
736
|
+
FormPageConfig,
|
737
|
+
VerificationPageConfig
|
738
|
+
]);
|
578
739
|
|
579
740
|
// ../commons/src/events/ActionType.ts
|
741
|
+
var import_zod7 = require("zod");
|
580
742
|
var ActionType = {
|
743
|
+
// Pre-declaration actions
|
744
|
+
DELETE: "DELETE",
|
581
745
|
CREATE: "CREATE",
|
582
|
-
ASSIGN: "ASSIGN",
|
583
|
-
UNASSIGN: "UNASSIGN",
|
584
|
-
REGISTER: "REGISTER",
|
585
|
-
VALIDATE: "VALIDATE",
|
586
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
587
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
588
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
589
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
590
746
|
NOTIFY: "NOTIFY",
|
747
|
+
// Declaration actions
|
591
748
|
DECLARE: "DECLARE",
|
592
|
-
|
593
|
-
|
594
|
-
|
749
|
+
VALIDATE: "VALIDATE",
|
750
|
+
REGISTER: "REGISTER",
|
751
|
+
// Declaration system actions. Non-configurable.
|
752
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
595
753
|
REJECT: "REJECT",
|
754
|
+
// REJECT_DECLARATION
|
596
755
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
597
|
-
|
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"
|
598
767
|
};
|
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]);
|
599
828
|
|
600
829
|
// ../commons/src/events/ActionConfig.ts
|
601
|
-
var ActionConditional2 =
|
830
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
602
831
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
603
832
|
ShowConditional,
|
604
833
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
605
834
|
EnableConditional
|
606
835
|
]);
|
607
|
-
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({
|
608
841
|
label: TranslationConfig,
|
609
|
-
conditionals:
|
610
|
-
draft:
|
611
|
-
forms: import_zod7.z.array(FormConfig)
|
842
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
843
|
+
draft: import_zod9.z.boolean().optional()
|
612
844
|
});
|
613
845
|
var DeclareConfig = ActionConfigBase.merge(
|
614
|
-
|
615
|
-
type:
|
846
|
+
import_zod9.z.object({
|
847
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
848
|
+
review: DeclarationReviewConfig
|
616
849
|
})
|
617
850
|
);
|
618
851
|
var ValidateConfig = ActionConfigBase.merge(
|
619
|
-
|
620
|
-
type:
|
852
|
+
import_zod9.z.object({
|
853
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
854
|
+
review: DeclarationReviewConfig
|
621
855
|
})
|
622
856
|
);
|
623
|
-
var
|
624
|
-
|
625
|
-
type:
|
626
|
-
|
627
|
-
isDuplicate: import_zod7.z.boolean()
|
857
|
+
var RegisterConfig = ActionConfigBase.merge(
|
858
|
+
import_zod9.z.object({
|
859
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
860
|
+
review: DeclarationReviewConfig
|
628
861
|
})
|
629
862
|
);
|
630
|
-
var
|
631
|
-
|
632
|
-
type:
|
633
|
-
comment: import_zod7.z.string(),
|
634
|
-
duplicates: import_zod7.z.array(import_zod7.z.string()).describe("UUIDs of duplicate records")
|
863
|
+
var RejectDeclarationConfig = ActionConfigBase.merge(
|
864
|
+
import_zod9.z.object({
|
865
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
635
866
|
})
|
636
867
|
);
|
637
|
-
var
|
638
|
-
|
639
|
-
type:
|
640
|
-
comment: import_zod7.z.string(),
|
641
|
-
isDuplicate: import_zod7.z.boolean()
|
868
|
+
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
869
|
+
import_zod9.z.object({
|
870
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
642
871
|
})
|
643
872
|
);
|
644
|
-
var
|
645
|
-
|
646
|
-
type:
|
873
|
+
var ArchiveConfig = ActionConfigBase.merge(
|
874
|
+
import_zod9.z.object({
|
875
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
647
876
|
})
|
648
877
|
);
|
649
878
|
var DeleteConfig = ActionConfigBase.merge(
|
650
|
-
|
651
|
-
type:
|
879
|
+
import_zod9.z.object({
|
880
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
652
881
|
})
|
653
882
|
);
|
654
883
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
655
|
-
|
656
|
-
type:
|
884
|
+
import_zod9.z.object({
|
885
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
886
|
+
printForm: ActionFormConfig
|
657
887
|
})
|
658
888
|
);
|
659
889
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
660
|
-
|
661
|
-
type:
|
662
|
-
onboardingForm:
|
663
|
-
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)
|
664
894
|
})
|
665
895
|
);
|
666
896
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
667
|
-
|
668
|
-
type:
|
897
|
+
import_zod9.z.object({
|
898
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
669
899
|
})
|
670
900
|
);
|
671
901
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
672
|
-
|
673
|
-
type:
|
674
|
-
})
|
675
|
-
);
|
676
|
-
var CustomConfig = ActionConfigBase.merge(
|
677
|
-
import_zod7.z.object({
|
678
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
902
|
+
import_zod9.z.object({
|
903
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
679
904
|
})
|
680
905
|
);
|
681
|
-
var ActionConfig =
|
906
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
682
907
|
DeclareConfig,
|
683
908
|
ValidateConfig,
|
684
909
|
RejectDeclarationConfig,
|
685
910
|
MarkedAsDuplicateConfig,
|
686
|
-
|
911
|
+
ArchiveConfig,
|
687
912
|
RegisterConfig,
|
688
913
|
DeleteConfig,
|
689
914
|
PrintCertificateActionConfig,
|
690
915
|
RequestCorrectionConfig,
|
691
916
|
RejectCorrectionConfig,
|
692
|
-
ApproveCorrectionConfig
|
693
|
-
|
917
|
+
ApproveCorrectionConfig
|
918
|
+
]);
|
919
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
920
|
+
DeclareConfig,
|
921
|
+
ValidateConfig,
|
922
|
+
RegisterConfig
|
694
923
|
]);
|
695
924
|
|
696
925
|
// ../commons/src/events/offline/CertificateConfig.ts
|
697
|
-
var
|
698
|
-
var FontFamily =
|
699
|
-
normal:
|
700
|
-
bold:
|
701
|
-
italics:
|
702
|
-
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()
|
703
932
|
});
|
704
|
-
var CertificateConfig =
|
705
|
-
id:
|
706
|
-
event:
|
933
|
+
var CertificateConfig = import_zod10.z.object({
|
934
|
+
id: import_zod10.z.string(),
|
935
|
+
event: import_zod10.z.string(),
|
707
936
|
label: TranslationConfig,
|
708
|
-
isDefault:
|
709
|
-
fee:
|
710
|
-
onTime:
|
711
|
-
late:
|
712
|
-
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()
|
713
942
|
}),
|
714
|
-
svgUrl:
|
715
|
-
fonts:
|
943
|
+
svgUrl: import_zod10.z.string(),
|
944
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
716
945
|
});
|
717
946
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
718
|
-
hash:
|
719
|
-
svg:
|
947
|
+
hash: import_zod10.z.string().optional(),
|
948
|
+
svg: import_zod10.z.string()
|
720
949
|
});
|
721
950
|
|
722
951
|
// ../commons/src/events/offline/LanguageConfig.ts
|
723
|
-
var
|
724
|
-
var LanguageConfig =
|
725
|
-
lang:
|
952
|
+
var import_zod11 = require("zod");
|
953
|
+
var LanguageConfig = import_zod11.z.object({
|
954
|
+
lang: import_zod11.z.string(),
|
726
955
|
/**
|
727
956
|
* client.csv contents
|
728
957
|
*/
|
729
|
-
messages:
|
958
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
730
959
|
});
|
731
960
|
|
732
961
|
// ../commons/src/events/EventConfig.ts
|
733
|
-
var
|
962
|
+
var import_zod20 = require("zod");
|
734
963
|
|
735
964
|
// ../commons/src/events/DeduplicationConfig.ts
|
736
|
-
var
|
737
|
-
var FieldReference =
|
738
|
-
var Matcher =
|
739
|
-
fieldId:
|
740
|
-
options:
|
741
|
-
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()
|
742
971
|
}).optional().default({})
|
743
972
|
});
|
744
973
|
var FuzzyMatcher = Matcher.extend({
|
745
|
-
type:
|
746
|
-
options:
|
974
|
+
type: import_zod12.z.literal("fuzzy"),
|
975
|
+
options: import_zod12.z.object({
|
747
976
|
/**
|
748
977
|
* Names of length 3 or less characters = 0 edits allowed
|
749
978
|
* Names of length 4 - 6 characters = 1 edit allowed
|
750
979
|
* Names of length >7 characters = 2 edits allowed
|
751
980
|
*/
|
752
|
-
fuzziness:
|
753
|
-
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)
|
754
983
|
}).optional().default({})
|
755
984
|
});
|
756
985
|
var StrictMatcher = Matcher.extend({
|
757
|
-
type:
|
758
|
-
options:
|
759
|
-
boost:
|
986
|
+
type: import_zod12.z.literal("strict"),
|
987
|
+
options: import_zod12.z.object({
|
988
|
+
boost: import_zod12.z.number().optional().default(1)
|
760
989
|
}).optional().default({})
|
761
990
|
});
|
762
991
|
var DateRangeMatcher = Matcher.extend({
|
763
|
-
type:
|
764
|
-
options:
|
765
|
-
days:
|
992
|
+
type: import_zod12.z.literal("dateRange"),
|
993
|
+
options: import_zod12.z.object({
|
994
|
+
days: import_zod12.z.number(),
|
766
995
|
origin: FieldReference,
|
767
|
-
boost:
|
996
|
+
boost: import_zod12.z.number().optional().default(1)
|
768
997
|
})
|
769
998
|
});
|
770
999
|
var DateDistanceMatcher = Matcher.extend({
|
771
|
-
type:
|
772
|
-
options:
|
773
|
-
days:
|
1000
|
+
type: import_zod12.z.literal("dateDistance"),
|
1001
|
+
options: import_zod12.z.object({
|
1002
|
+
days: import_zod12.z.number(),
|
774
1003
|
origin: FieldReference,
|
775
|
-
boost:
|
1004
|
+
boost: import_zod12.z.number().optional().default(1)
|
776
1005
|
})
|
777
1006
|
});
|
778
|
-
var And =
|
779
|
-
type:
|
780
|
-
|
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())
|
781
1011
|
});
|
782
|
-
var Or =
|
783
|
-
type:
|
784
|
-
|
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())
|
785
1016
|
});
|
786
|
-
var Clause =
|
787
|
-
() =>
|
1017
|
+
var Clause = import_zod12.z.lazy(
|
1018
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
788
1019
|
And,
|
789
1020
|
Or,
|
790
1021
|
FuzzyMatcher,
|
@@ -793,37 +1024,44 @@ var Clause = import_zod10.z.lazy(
|
|
793
1024
|
DateDistanceMatcher
|
794
1025
|
])
|
795
1026
|
);
|
796
|
-
var DeduplicationConfig =
|
797
|
-
id:
|
1027
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1028
|
+
id: import_zod12.z.string(),
|
798
1029
|
label: TranslationConfig,
|
799
1030
|
query: Clause
|
800
1031
|
});
|
801
1032
|
|
802
1033
|
// ../commons/src/events/SummaryConfig.ts
|
803
|
-
var
|
804
|
-
var
|
805
|
-
|
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"),
|
806
1044
|
value: TranslationConfig.describe(
|
807
1045
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
808
1046
|
),
|
809
1047
|
label: TranslationConfig,
|
810
1048
|
emptyValueMessage: TranslationConfig.optional()
|
811
|
-
});
|
812
|
-
var Title =
|
813
|
-
id:
|
1049
|
+
}).describe("Custom configured field");
|
1050
|
+
var Title = import_zod13.z.object({
|
1051
|
+
id: import_zod13.z.string(),
|
814
1052
|
label: TranslationConfig.describe("Title content"),
|
815
1053
|
emptyValueMessage: TranslationConfig.optional()
|
816
1054
|
});
|
817
|
-
var SummaryConfig =
|
1055
|
+
var SummaryConfig = import_zod13.z.object({
|
818
1056
|
title: Title.describe("Title of summary view."),
|
819
|
-
fields:
|
1057
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
820
1058
|
}).describe("Configuration for summary in event.");
|
821
1059
|
|
822
1060
|
// ../commons/src/events/WorkqueueConfig.ts
|
823
|
-
var
|
1061
|
+
var import_zod15 = require("zod");
|
824
1062
|
|
825
1063
|
// ../commons/src/events/EventMetadata.ts
|
826
|
-
var
|
1064
|
+
var import_zod14 = require("zod");
|
827
1065
|
var EventStatus = {
|
828
1066
|
CREATED: "CREATED",
|
829
1067
|
NOTIFIED: "NOTIFIED",
|
@@ -835,18 +1073,20 @@ var EventStatus = {
|
|
835
1073
|
ARCHIVED: "ARCHIVED"
|
836
1074
|
};
|
837
1075
|
var eventStatuses = Object.values(EventStatus);
|
838
|
-
var EventStatuses =
|
839
|
-
var EventMetadata =
|
840
|
-
id:
|
841
|
-
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(),
|
842
1080
|
status: EventStatuses,
|
843
|
-
createdAt:
|
844
|
-
createdBy:
|
845
|
-
createdAtLocation:
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
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()
|
850
1090
|
});
|
851
1091
|
var eventMetadataLabelMap = {
|
852
1092
|
"event.assignedTo": {
|
@@ -864,6 +1104,11 @@ var eventMetadataLabelMap = {
|
|
864
1104
|
defaultMessage: "Location",
|
865
1105
|
description: "Created At Location"
|
866
1106
|
},
|
1107
|
+
"event.updatedAtLocation": {
|
1108
|
+
id: "event.updatedAtLocation.label",
|
1109
|
+
defaultMessage: "Location",
|
1110
|
+
description: "Updated At Location"
|
1111
|
+
},
|
867
1112
|
"event.createdBy": {
|
868
1113
|
id: "event.createdBy.label",
|
869
1114
|
defaultMessage: "Created By",
|
@@ -898,28 +1143,33 @@ var eventMetadataLabelMap = {
|
|
898
1143
|
id: "event.trackingId.label",
|
899
1144
|
defaultMessage: "Tracking ID",
|
900
1145
|
description: "Tracking ID"
|
1146
|
+
},
|
1147
|
+
"event.registrationNumber": {
|
1148
|
+
id: "event.registrationNumber.label",
|
1149
|
+
defaultMessage: "Registration Number",
|
1150
|
+
description: "Registration Number"
|
901
1151
|
}
|
902
1152
|
};
|
903
1153
|
|
904
1154
|
// ../commons/src/events/WorkqueueConfig.ts
|
905
|
-
var WorkqueueConfig =
|
906
|
-
id:
|
907
|
-
filters:
|
908
|
-
|
909
|
-
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.")
|
910
1160
|
})
|
911
1161
|
).describe("Filters to be applied to workqueue.")
|
912
1162
|
}).describe("Configuration for workqueue.");
|
913
1163
|
|
914
1164
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
915
|
-
var
|
916
|
-
var AdvancedSearchConfig =
|
1165
|
+
var import_zod16 = require("zod");
|
1166
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
917
1167
|
title: TranslationConfig.describe("Advanced search tab title"),
|
918
|
-
fields:
|
919
|
-
|
920
|
-
fieldId:
|
921
|
-
config:
|
922
|
-
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")
|
923
1173
|
}).optional().describe("Configuration options for the field")
|
924
1174
|
})
|
925
1175
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -929,12 +1179,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
929
1179
|
var import_lodash = require("lodash");
|
930
1180
|
|
931
1181
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
932
|
-
var
|
1182
|
+
var import_zod18 = require("zod");
|
933
1183
|
|
934
1184
|
// ../commons/src/workqueues/defaultColumns.ts
|
935
|
-
var
|
936
|
-
var WorkQueueColumnConfig =
|
937
|
-
id:
|
1185
|
+
var import_zod17 = require("zod");
|
1186
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1187
|
+
id: import_zod17.z.string(),
|
938
1188
|
label: TranslationConfig
|
939
1189
|
});
|
940
1190
|
var defaultColumns = {
|
@@ -971,16 +1221,16 @@ var defaultColumns = {
|
|
971
1221
|
}
|
972
1222
|
}
|
973
1223
|
};
|
974
|
-
var DefaultColumnKeys =
|
1224
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
975
1225
|
Object.keys(defaultColumns)
|
976
1226
|
);
|
977
1227
|
|
978
1228
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
979
|
-
var rootWorkqueueConfig =
|
980
|
-
id:
|
1229
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1230
|
+
id: import_zod18.z.string(),
|
981
1231
|
title: TranslationConfig,
|
982
|
-
columns:
|
983
|
-
defaultColumns:
|
1232
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1233
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
984
1234
|
});
|
985
1235
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
986
1236
|
|
@@ -1060,7 +1310,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1060
1310
|
var import_date_fns = require("date-fns");
|
1061
1311
|
|
1062
1312
|
// ../commons/src/events/FieldTypeMapping.ts
|
1063
|
-
var
|
1313
|
+
var import_zod19 = require("zod");
|
1064
1314
|
function mapFieldTypeToZod(type, required) {
|
1065
1315
|
let schema;
|
1066
1316
|
switch (type) {
|
@@ -1102,6 +1352,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1102
1352
|
case FieldType.ADDRESS:
|
1103
1353
|
schema = AddressFieldUpdateValue;
|
1104
1354
|
break;
|
1355
|
+
case FieldType.DATA:
|
1356
|
+
schema = DataFieldValue;
|
1357
|
+
break;
|
1105
1358
|
}
|
1106
1359
|
return required ? schema : schema.nullish();
|
1107
1360
|
}
|
@@ -1110,7 +1363,7 @@ function createValidationSchema(config) {
|
|
1110
1363
|
for (const field2 of config) {
|
1111
1364
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1112
1365
|
}
|
1113
|
-
return
|
1366
|
+
return import_zod19.z.object(shape);
|
1114
1367
|
}
|
1115
1368
|
function mapFieldTypeToMockValue(field2, i) {
|
1116
1369
|
switch (field2.type) {
|
@@ -1136,6 +1389,7 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1136
1389
|
case FieldType.ADDRESS:
|
1137
1390
|
return {
|
1138
1391
|
country: "FAR",
|
1392
|
+
addressType: AddressType.DOMESTIC,
|
1139
1393
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1140
1394
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1141
1395
|
urbanOrRural: "URBAN",
|
@@ -1157,6 +1411,54 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1157
1411
|
};
|
1158
1412
|
case FieldType.FILE_WITH_OPTIONS:
|
1159
1413
|
return null;
|
1414
|
+
case FieldType.DATA:
|
1415
|
+
return {};
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
function mapFieldTypeToEmptyValue(field2) {
|
1419
|
+
switch (field2.type) {
|
1420
|
+
case FieldType.DIVIDER:
|
1421
|
+
case FieldType.TEXT:
|
1422
|
+
case FieldType.TEXTAREA:
|
1423
|
+
case FieldType.BULLET_LIST:
|
1424
|
+
case FieldType.PAGE_HEADER:
|
1425
|
+
case FieldType.LOCATION:
|
1426
|
+
case FieldType.SELECT:
|
1427
|
+
case FieldType.COUNTRY:
|
1428
|
+
case FieldType.RADIO_GROUP:
|
1429
|
+
case FieldType.SIGNATURE:
|
1430
|
+
case FieldType.PARAGRAPH:
|
1431
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
1432
|
+
case FieldType.FACILITY:
|
1433
|
+
case FieldType.OFFICE:
|
1434
|
+
case FieldType.NUMBER:
|
1435
|
+
case FieldType.EMAIL:
|
1436
|
+
case FieldType.DATE:
|
1437
|
+
case FieldType.CHECKBOX:
|
1438
|
+
case FieldType.DATA:
|
1439
|
+
return null;
|
1440
|
+
case FieldType.ADDRESS:
|
1441
|
+
return {
|
1442
|
+
country: null,
|
1443
|
+
addressType: AddressType.DOMESTIC,
|
1444
|
+
province: null,
|
1445
|
+
district: null,
|
1446
|
+
urbanOrRural: "URBAN",
|
1447
|
+
// Default to urban needed for validation
|
1448
|
+
town: null,
|
1449
|
+
residentialArea: null,
|
1450
|
+
street: null,
|
1451
|
+
number: null,
|
1452
|
+
zipCode: null
|
1453
|
+
};
|
1454
|
+
case FieldType.FILE:
|
1455
|
+
return {
|
1456
|
+
filename: "",
|
1457
|
+
originalFilename: "",
|
1458
|
+
type: ""
|
1459
|
+
};
|
1460
|
+
case FieldType.FILE_WITH_OPTIONS:
|
1461
|
+
return [];
|
1160
1462
|
}
|
1161
1463
|
}
|
1162
1464
|
var isParagraphFieldType = (field2) => {
|
@@ -1222,21 +1524,36 @@ var isFacilityFieldType = (field2) => {
|
|
1222
1524
|
var isOfficeFieldType = (field2) => {
|
1223
1525
|
return field2.config.type === FieldType.OFFICE;
|
1224
1526
|
};
|
1527
|
+
var isDataFieldType = (field2) => {
|
1528
|
+
return field2.config.type === FieldType.DATA;
|
1529
|
+
};
|
1225
1530
|
|
1226
1531
|
// ../commons/src/conditionals/validate.ts
|
1227
1532
|
var ajv = new import_ajv.default({
|
1228
|
-
$data: true
|
1533
|
+
$data: true,
|
1534
|
+
allowUnionTypes: true
|
1229
1535
|
});
|
1230
1536
|
(0, import_ajv_formats.default)(ajv);
|
1231
1537
|
function validate(schema, data) {
|
1232
1538
|
return ajv.validate(schema, data);
|
1233
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
|
+
}
|
1234
1546
|
function getConditionalActionsForField(field2, values) {
|
1235
1547
|
if (!field2.conditionals) {
|
1236
1548
|
return [];
|
1237
1549
|
}
|
1238
1550
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1239
1551
|
}
|
1552
|
+
function areConditionsMet(conditions, values) {
|
1553
|
+
return conditions.every(
|
1554
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1555
|
+
);
|
1556
|
+
}
|
1240
1557
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1241
1558
|
const hasRule = (field2.conditionals ?? []).some(
|
1242
1559
|
(conditional) => conditional.type === conditionalType
|
@@ -1258,88 +1575,81 @@ function isFieldVisible(field2, form) {
|
|
1258
1575
|
function isFieldEnabled(field2, form) {
|
1259
1576
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1260
1577
|
}
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
description: "This is the error message for required fields",
|
1290
|
-
id: "v2.error.required"
|
1291
|
-
}
|
1292
|
-
}
|
1293
|
-
};
|
1578
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1579
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1580
|
+
}
|
1581
|
+
var errorMessages = {
|
1582
|
+
hiddenField: {
|
1583
|
+
id: "v2.error.hidden",
|
1584
|
+
defaultMessage: "Hidden or disabled field should not receive a value",
|
1585
|
+
description: "Error message when field is hidden or disabled, but a value was received"
|
1586
|
+
},
|
1587
|
+
invalidDate: {
|
1588
|
+
defaultMessage: "Invalid date field",
|
1589
|
+
description: "Error message when date field is invalid",
|
1590
|
+
id: "v2.error.invalidDate"
|
1591
|
+
},
|
1592
|
+
invalidEmail: {
|
1593
|
+
defaultMessage: "Invalid email address",
|
1594
|
+
description: "Error message when email address is invalid",
|
1595
|
+
id: "v2.error.invalidEmail"
|
1596
|
+
},
|
1597
|
+
requiredField: {
|
1598
|
+
defaultMessage: "Required for registration",
|
1599
|
+
description: "Error message when required field is missing",
|
1600
|
+
id: "v2.error.required"
|
1601
|
+
},
|
1602
|
+
invalidInput: {
|
1603
|
+
defaultMessage: "Invalid input",
|
1604
|
+
description: "Error message when generic field is invalid",
|
1605
|
+
id: "v2.error.invalid"
|
1294
1606
|
}
|
1607
|
+
};
|
1608
|
+
function createIntlError(message) {
|
1295
1609
|
return {
|
1296
1610
|
message: {
|
1297
|
-
message
|
1298
|
-
defaultMessage: "Invalid input",
|
1299
|
-
description: "This is the error message for invalid field value",
|
1300
|
-
id: "v2.error.invalid"
|
1301
|
-
}
|
1611
|
+
message
|
1302
1612
|
}
|
1303
1613
|
};
|
1304
|
-
}
|
1305
|
-
function
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1614
|
+
}
|
1615
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1616
|
+
switch (issue.code) {
|
1617
|
+
case "invalid_string": {
|
1618
|
+
if (_ctx.data === "") {
|
1619
|
+
return createIntlError(errorMessages.requiredField);
|
1620
|
+
}
|
1621
|
+
if (issue.validation === "date") {
|
1622
|
+
return createIntlError(errorMessages.invalidDate);
|
1623
|
+
}
|
1624
|
+
if (issue.validation === "email") {
|
1625
|
+
return createIntlError(errorMessages.invalidEmail);
|
1626
|
+
}
|
1627
|
+
break;
|
1628
|
+
}
|
1629
|
+
case "invalid_type": {
|
1630
|
+
if (issue.expected !== issue.received && issue.received === "undefined") {
|
1631
|
+
return createIntlError(errorMessages.requiredField);
|
1632
|
+
}
|
1633
|
+
break;
|
1634
|
+
}
|
1635
|
+
case "too_small": {
|
1636
|
+
if (issue.message === void 0) {
|
1637
|
+
return createIntlError(errorMessages.requiredField);
|
1638
|
+
}
|
1639
|
+
break;
|
1640
|
+
}
|
1641
|
+
case "invalid_union": {
|
1642
|
+
for (const { issues } of issue.unionErrors) {
|
1643
|
+
for (const e of issues) {
|
1644
|
+
if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
|
1645
|
+
return createIntlError(errorMessages.invalidInput);
|
1323
1646
|
}
|
1324
|
-
|
1325
|
-
}
|
1647
|
+
}
|
1648
|
+
}
|
1649
|
+
return createIntlError(errorMessages.requiredField);
|
1326
1650
|
}
|
1327
|
-
return {
|
1328
|
-
errors: []
|
1329
|
-
};
|
1330
1651
|
}
|
1331
|
-
|
1332
|
-
field: field2,
|
1333
|
-
value: values[field2.id]
|
1334
|
-
});
|
1335
|
-
const customValidationResults = runCustomFieldValidations({
|
1336
|
-
field: field2,
|
1337
|
-
conditionalParameters
|
1338
|
-
});
|
1339
|
-
return {
|
1340
|
-
// Assumes that custom validation errors are more important than field validation errors
|
1341
|
-
errors: [...customValidationResults, ...fieldValidationResult]
|
1342
|
-
};
|
1652
|
+
return createIntlError(errorMessages.invalidInput);
|
1343
1653
|
}
|
1344
1654
|
function runCustomFieldValidations({
|
1345
1655
|
field: field2,
|
@@ -1362,68 +1672,105 @@ function validateFieldInput({
|
|
1362
1672
|
);
|
1363
1673
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1364
1674
|
}
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
var findInputPageFields = (config) => {
|
1371
|
-
return (0, import_lodash.flattenDeep)(
|
1372
|
-
config.actions.map(
|
1373
|
-
({ forms }) => forms.map(
|
1374
|
-
({ pages }) => pages.map(
|
1375
|
-
({ fields }) => fields.map(({ id, label }) => ({ id, label }))
|
1376
|
-
)
|
1377
|
-
)
|
1378
|
-
)
|
1379
|
-
);
|
1380
|
-
};
|
1381
|
-
var findPageFields = (config) => {
|
1382
|
-
return (0, import_lodash.flattenDeep)(
|
1383
|
-
config.actions.map((action) => {
|
1384
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1385
|
-
return [
|
1386
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1387
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1388
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1389
|
-
];
|
1390
|
-
}
|
1391
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1392
|
-
})
|
1393
|
-
);
|
1394
|
-
};
|
1395
|
-
var resolveLabelsFromKnownFields = ({
|
1396
|
-
pageFields,
|
1397
|
-
refFields
|
1398
|
-
}) => {
|
1399
|
-
return refFields.map((field2) => {
|
1400
|
-
if (field2.label) {
|
1401
|
-
return field2;
|
1402
|
-
}
|
1403
|
-
if (isMetadataField(field2.id)) {
|
1404
|
-
return {
|
1405
|
-
...field2,
|
1406
|
-
label: eventMetadataLabelMap[field2.id]
|
1407
|
-
};
|
1408
|
-
}
|
1409
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1410
|
-
if (!pageLabel) {
|
1411
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1412
|
-
}
|
1675
|
+
function runFieldValidations({
|
1676
|
+
field: field2,
|
1677
|
+
values
|
1678
|
+
}) {
|
1679
|
+
if (!isFieldVisible(field2, values)) {
|
1413
1680
|
return {
|
1414
|
-
|
1415
|
-
label: pageLabel.label
|
1681
|
+
errors: []
|
1416
1682
|
};
|
1683
|
+
}
|
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
|
1417
1695
|
});
|
1696
|
+
return {
|
1697
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1698
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1699
|
+
};
|
1700
|
+
}
|
1701
|
+
|
1702
|
+
// ../commons/src/uuid.ts
|
1703
|
+
var import_uuid = require("uuid");
|
1704
|
+
function getUUID() {
|
1705
|
+
return (0, import_uuid.v4)();
|
1706
|
+
}
|
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
|
+
|
1716
|
+
// ../commons/src/events/utils.ts
|
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 [];
|
1418
1743
|
};
|
1419
|
-
|
1420
|
-
return
|
1421
|
-
|
1422
|
-
|
1744
|
+
var getAllAnnotationFields = (config) => {
|
1745
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1746
|
+
};
|
1747
|
+
var findAllFields = (config) => {
|
1748
|
+
return (0, import_lodash.flattenDeep)([
|
1749
|
+
...getDeclarationFields(config),
|
1750
|
+
...getAllAnnotationFields(config)
|
1423
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
|
+
);
|
1424
1771
|
}
|
1425
|
-
function
|
1426
|
-
return configuration
|
1772
|
+
function getActionReviewFields(configuration, actionType) {
|
1773
|
+
return getActionReview(configuration, actionType).fields;
|
1427
1774
|
}
|
1428
1775
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1429
1776
|
workqueueConfigs.map((workqueue) => {
|
@@ -1432,79 +1779,95 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1432
1779
|
);
|
1433
1780
|
if (!rootWorkqueue) {
|
1434
1781
|
throw new Error(
|
1435
|
-
`Invalid workqueue configuration: workqueue not found with id:
|
1782
|
+
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1436
1783
|
);
|
1437
1784
|
}
|
1438
1785
|
});
|
1439
1786
|
}
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
return form;
|
1444
|
-
};
|
1445
|
-
var findActiveActionFormPages = (configuration, action) => {
|
1446
|
-
return findActiveActionForm(configuration, action)?.pages;
|
1447
|
-
};
|
1448
|
-
var getFormFields = (formConfig) => {
|
1449
|
-
return formConfig.pages.flatMap((p) => p.fields);
|
1450
|
-
};
|
1451
|
-
var findActiveActionFormFields = (configuration, action) => {
|
1452
|
-
const form = findActiveActionForm(configuration, action);
|
1453
|
-
return form ? getFormFields(form) : void 0;
|
1454
|
-
};
|
1455
|
-
var findActiveActionFields = (configuration, action) => {
|
1456
|
-
const form = findActiveActionForm(configuration, action);
|
1457
|
-
const reviewFields = form?.review.fields;
|
1458
|
-
const formFields = form ? getFormFields(form) : void 0;
|
1459
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1460
|
-
return allFields;
|
1461
|
-
};
|
1462
|
-
function getActiveActionFields(configuration, action) {
|
1463
|
-
const fields = findActiveActionFields(configuration, action);
|
1464
|
-
if (!fields) {
|
1465
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1466
|
-
}
|
1467
|
-
return fields;
|
1468
|
-
}
|
1469
|
-
function getEventConfiguration(eventConfigurations, type) {
|
1470
|
-
const config = eventConfigurations.find((config2) => config2.id === type);
|
1471
|
-
if (!config) {
|
1472
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1473
|
-
}
|
1474
|
-
return config;
|
1475
|
-
}
|
1476
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1477
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1478
|
-
return false;
|
1787
|
+
function isPageVisible(page, formValues) {
|
1788
|
+
if (!page.conditional) {
|
1789
|
+
return true;
|
1479
1790
|
}
|
1480
|
-
return
|
1791
|
+
return isConditionMet(page.conditional, formValues);
|
1481
1792
|
}
|
1482
|
-
function
|
1483
|
-
return (0, import_lodash.omitBy)(
|
1793
|
+
function omitHiddenFields(fields, values) {
|
1794
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1484
1795
|
const field2 = fields.find((f) => f.id === fieldId);
|
1485
1796
|
if (!field2) {
|
1486
1797
|
return true;
|
1487
1798
|
}
|
1488
|
-
|
1489
|
-
return true;
|
1490
|
-
}
|
1491
|
-
return !isFieldVisible(field2, data);
|
1799
|
+
return !isFieldVisible(field2, values);
|
1492
1800
|
});
|
1493
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
|
+
}
|
1806
|
+
function findActiveDrafts(event2, drafts) {
|
1807
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1808
|
+
const lastAction = actions[actions.length - 1];
|
1809
|
+
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1810
|
+
}
|
1811
|
+
function createEmptyDraft(eventId, draftId, actionType) {
|
1812
|
+
return {
|
1813
|
+
id: draftId,
|
1814
|
+
eventId,
|
1815
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1816
|
+
transactionId: getUUID(),
|
1817
|
+
action: {
|
1818
|
+
type: actionType,
|
1819
|
+
declaration: {},
|
1820
|
+
annotation: {},
|
1821
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1822
|
+
createdBy: "@todo",
|
1823
|
+
createdAtLocation: "@todo"
|
1824
|
+
}
|
1825
|
+
};
|
1826
|
+
}
|
1827
|
+
function isVerificationPage(page) {
|
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;
|
1855
|
+
}
|
1494
1856
|
|
1495
1857
|
// ../commons/src/events/EventConfig.ts
|
1496
|
-
var EventConfig =
|
1497
|
-
id:
|
1858
|
+
var EventConfig = import_zod20.z.object({
|
1859
|
+
id: import_zod20.z.string().describe(
|
1498
1860
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1499
1861
|
),
|
1500
1862
|
summary: SummaryConfig,
|
1501
1863
|
label: TranslationConfig,
|
1502
|
-
actions:
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
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([])
|
1506
1869
|
}).superRefine((event2, ctx) => {
|
1507
|
-
const allFields =
|
1870
|
+
const allFields = findAllFields(event2);
|
1508
1871
|
const fieldIds = allFields.map((field2) => field2.id);
|
1509
1872
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1510
1873
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1531,111 +1894,123 @@ var EventConfig = import_zod18.z.object({
|
|
1531
1894
|
});
|
1532
1895
|
|
1533
1896
|
// ../commons/src/events/EventConfigInput.ts
|
1534
|
-
var
|
1535
|
-
var
|
1897
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1898
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1899
|
+
var definePage = (page) => PageConfig.parse(page);
|
1900
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1536
1901
|
|
1537
1902
|
// ../commons/src/events/Draft.ts
|
1538
|
-
var
|
1903
|
+
var import_zod23 = require("zod");
|
1539
1904
|
|
1540
1905
|
// ../commons/src/events/ActionDocument.ts
|
1541
|
-
var
|
1542
|
-
var ActionUpdate =
|
1543
|
-
var
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
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()
|
1550
1927
|
});
|
1551
1928
|
var AssignedAction = ActionBase.merge(
|
1552
|
-
|
1553
|
-
type:
|
1554
|
-
assignedTo:
|
1929
|
+
import_zod21.z.object({
|
1930
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1931
|
+
assignedTo: import_zod21.z.string()
|
1555
1932
|
})
|
1556
1933
|
);
|
1557
1934
|
var UnassignedAction = ActionBase.merge(
|
1558
|
-
|
1559
|
-
type:
|
1935
|
+
import_zod21.z.object({
|
1936
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1937
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1560
1938
|
})
|
1561
1939
|
);
|
1562
1940
|
var RegisterAction = ActionBase.merge(
|
1563
|
-
|
1564
|
-
type:
|
1565
|
-
|
1566
|
-
trackingId: import_zod19.z.string(),
|
1567
|
-
registrationNumber: import_zod19.z.string()
|
1568
|
-
})
|
1941
|
+
import_zod21.z.object({
|
1942
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1943
|
+
registrationNumber: import_zod21.z.string().optional()
|
1569
1944
|
})
|
1570
1945
|
);
|
1571
1946
|
var DeclareAction = ActionBase.merge(
|
1572
|
-
|
1573
|
-
type:
|
1947
|
+
import_zod21.z.object({
|
1948
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1574
1949
|
})
|
1575
1950
|
);
|
1576
1951
|
var ValidateAction = ActionBase.merge(
|
1577
|
-
|
1578
|
-
type:
|
1952
|
+
import_zod21.z.object({
|
1953
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1579
1954
|
})
|
1580
1955
|
);
|
1581
1956
|
var RejectAction = ActionBase.merge(
|
1582
|
-
|
1583
|
-
type:
|
1957
|
+
import_zod21.z.object({
|
1958
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1584
1959
|
})
|
1585
1960
|
);
|
1586
1961
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1587
|
-
|
1588
|
-
type:
|
1962
|
+
import_zod21.z.object({
|
1963
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1589
1964
|
})
|
1590
1965
|
);
|
1591
|
-
var
|
1592
|
-
|
1593
|
-
type:
|
1966
|
+
var ArchiveAction = ActionBase.merge(
|
1967
|
+
import_zod21.z.object({
|
1968
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1594
1969
|
})
|
1595
1970
|
);
|
1596
1971
|
var CreatedAction = ActionBase.merge(
|
1597
|
-
|
1598
|
-
type:
|
1972
|
+
import_zod21.z.object({
|
1973
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1599
1974
|
})
|
1600
1975
|
);
|
1601
1976
|
var NotifiedAction = ActionBase.merge(
|
1602
|
-
|
1603
|
-
type:
|
1977
|
+
import_zod21.z.object({
|
1978
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1604
1979
|
})
|
1605
1980
|
);
|
1606
1981
|
var PrintCertificateAction = ActionBase.merge(
|
1607
|
-
|
1608
|
-
type:
|
1982
|
+
import_zod21.z.object({
|
1983
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1609
1984
|
})
|
1610
1985
|
);
|
1611
1986
|
var RequestedCorrectionAction = ActionBase.merge(
|
1612
|
-
|
1613
|
-
type:
|
1987
|
+
import_zod21.z.object({
|
1988
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1614
1989
|
})
|
1615
1990
|
);
|
1616
1991
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1617
|
-
|
1618
|
-
type:
|
1619
|
-
requestId:
|
1992
|
+
import_zod21.z.object({
|
1993
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1994
|
+
requestId: import_zod21.z.string()
|
1620
1995
|
})
|
1621
1996
|
);
|
1622
1997
|
var RejectedCorrectionAction = ActionBase.merge(
|
1623
|
-
|
1624
|
-
type:
|
1625
|
-
requestId:
|
1998
|
+
import_zod21.z.object({
|
1999
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
2000
|
+
requestId: import_zod21.z.string()
|
1626
2001
|
})
|
1627
2002
|
);
|
1628
|
-
var
|
1629
|
-
|
1630
|
-
type:
|
2003
|
+
var ReadAction = ActionBase.merge(
|
2004
|
+
import_zod21.z.object({
|
2005
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1631
2006
|
})
|
1632
2007
|
);
|
1633
|
-
var ActionDocument =
|
2008
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1634
2009
|
CreatedAction,
|
1635
2010
|
ValidateAction,
|
1636
2011
|
RejectAction,
|
1637
2012
|
MarkAsDuplicateAction,
|
1638
|
-
|
2013
|
+
ArchiveAction,
|
1639
2014
|
NotifiedAction,
|
1640
2015
|
RegisterAction,
|
1641
2016
|
DeclareAction,
|
@@ -1645,110 +2020,125 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1645
2020
|
RejectedCorrectionAction,
|
1646
2021
|
UnassignedAction,
|
1647
2022
|
PrintCertificateAction,
|
1648
|
-
|
2023
|
+
ReadAction
|
1649
2024
|
]);
|
1650
|
-
var
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
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()
|
1658
2045
|
})
|
1659
2046
|
)
|
1660
2047
|
});
|
1661
2048
|
|
1662
2049
|
// ../commons/src/events/ActionInput.ts
|
1663
|
-
var
|
1664
|
-
var BaseActionInput =
|
1665
|
-
eventId:
|
1666
|
-
transactionId:
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
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()
|
1670
2058
|
});
|
1671
2059
|
var CreateActionInput = BaseActionInput.merge(
|
1672
|
-
|
1673
|
-
type:
|
1674
|
-
createdAtLocation:
|
2060
|
+
import_zod22.z.object({
|
2061
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2062
|
+
createdAtLocation: import_zod22.z.string()
|
1675
2063
|
})
|
1676
2064
|
);
|
1677
2065
|
var RegisterActionInput = BaseActionInput.merge(
|
1678
|
-
|
1679
|
-
type:
|
1680
|
-
|
1681
|
-
trackingId: import_zod20.z.string(),
|
1682
|
-
registrationNumber: import_zod20.z.string()
|
1683
|
-
})
|
2066
|
+
import_zod22.z.object({
|
2067
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2068
|
+
registrationNumber: import_zod22.z.string().optional()
|
1684
2069
|
})
|
1685
2070
|
);
|
1686
2071
|
var ValidateActionInput = BaseActionInput.merge(
|
1687
|
-
|
1688
|
-
type:
|
1689
|
-
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())
|
1690
2075
|
})
|
1691
2076
|
);
|
1692
2077
|
var NotifyActionInput = BaseActionInput.merge(
|
1693
|
-
|
1694
|
-
type:
|
1695
|
-
createdAtLocation: import_zod20.z.string()
|
2078
|
+
import_zod22.z.object({
|
2079
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1696
2080
|
})
|
1697
2081
|
);
|
1698
2082
|
var DeclareActionInput = BaseActionInput.merge(
|
1699
|
-
|
1700
|
-
type:
|
2083
|
+
import_zod22.z.object({
|
2084
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1701
2085
|
})
|
1702
2086
|
);
|
1703
2087
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1704
|
-
|
1705
|
-
type:
|
2088
|
+
import_zod22.z.object({
|
2089
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1706
2090
|
})
|
1707
2091
|
);
|
1708
2092
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1709
|
-
|
1710
|
-
type:
|
2093
|
+
import_zod22.z.object({
|
2094
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1711
2095
|
})
|
1712
2096
|
);
|
1713
2097
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1714
|
-
|
1715
|
-
type:
|
2098
|
+
import_zod22.z.object({
|
2099
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1716
2100
|
})
|
1717
2101
|
);
|
1718
|
-
var
|
1719
|
-
|
1720
|
-
type:
|
2102
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2103
|
+
import_zod22.z.object({
|
2104
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1721
2105
|
})
|
1722
2106
|
);
|
1723
2107
|
var AssignActionInput = BaseActionInput.merge(
|
1724
|
-
|
1725
|
-
type:
|
1726
|
-
assignedTo:
|
2108
|
+
import_zod22.z.object({
|
2109
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2110
|
+
assignedTo: import_zod22.z.string()
|
1727
2111
|
})
|
1728
2112
|
);
|
1729
2113
|
var UnassignActionInput = BaseActionInput.merge(
|
1730
|
-
|
1731
|
-
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)
|
1732
2117
|
})
|
1733
2118
|
);
|
1734
2119
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1735
|
-
|
1736
|
-
type:
|
2120
|
+
import_zod22.z.object({
|
2121
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1737
2122
|
})
|
1738
2123
|
);
|
1739
2124
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1740
|
-
|
1741
|
-
requestId:
|
1742
|
-
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)
|
1743
2128
|
})
|
1744
2129
|
);
|
1745
2130
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1746
|
-
|
1747
|
-
requestId:
|
1748
|
-
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)
|
1749
2134
|
})
|
1750
2135
|
);
|
1751
|
-
var
|
2136
|
+
var ReadActionInput = BaseActionInput.merge(
|
2137
|
+
import_zod22.z.object({
|
2138
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2139
|
+
})
|
2140
|
+
);
|
2141
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
1752
2142
|
CreateActionInput,
|
1753
2143
|
ValidateActionInput,
|
1754
2144
|
RegisterActionInput,
|
@@ -1756,82 +2146,96 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
1756
2146
|
DeclareActionInput,
|
1757
2147
|
RejectDeclarationActionInput,
|
1758
2148
|
MarkedAsDuplicateActionInput,
|
1759
|
-
|
2149
|
+
ArchiveActionInput,
|
1760
2150
|
AssignActionInput,
|
1761
2151
|
UnassignActionInput,
|
1762
2152
|
PrintCertificateActionInput,
|
1763
2153
|
RequestCorrectionActionInput,
|
1764
2154
|
RejectCorrectionActionInput,
|
1765
|
-
ApproveCorrectionActionInput
|
2155
|
+
ApproveCorrectionActionInput,
|
2156
|
+
ReadActionInput
|
1766
2157
|
]);
|
1767
2158
|
|
1768
2159
|
// ../commons/src/events/Draft.ts
|
1769
|
-
var Draft =
|
1770
|
-
id:
|
1771
|
-
eventId:
|
1772
|
-
transactionId:
|
1773
|
-
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(),
|
1774
2165
|
action: ActionBase.extend({
|
1775
|
-
type:
|
2166
|
+
type: ActionTypes
|
1776
2167
|
}).omit({ id: true })
|
1777
2168
|
});
|
1778
2169
|
var DraftInput = BaseActionInput.extend({
|
1779
|
-
type:
|
2170
|
+
type: ActionTypes
|
1780
2171
|
});
|
1781
2172
|
|
1782
2173
|
// ../commons/src/events/EventInput.ts
|
1783
|
-
var
|
1784
|
-
var EventInput =
|
1785
|
-
transactionId:
|
1786
|
-
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()
|
1787
2178
|
});
|
1788
2179
|
|
1789
2180
|
// ../commons/src/events/EventDocument.ts
|
1790
|
-
var
|
1791
|
-
var EventDocument =
|
1792
|
-
id:
|
1793
|
-
type:
|
1794
|
-
createdAt:
|
1795
|
-
updatedAt:
|
1796
|
-
|
1797
|
-
|
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()
|
1798
2190
|
});
|
1799
2191
|
|
1800
2192
|
// ../commons/src/events/EventIndex.ts
|
1801
|
-
var
|
2193
|
+
var import_zod26 = require("zod");
|
1802
2194
|
var EventIndex = EventMetadata.extend({
|
1803
|
-
|
2195
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
1804
2196
|
});
|
1805
|
-
var EventSearchIndex =
|
1806
|
-
|
1807
|
-
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()
|
1808
2200
|
// Ensures "type" (event-id) exists and is a string
|
1809
2201
|
})
|
1810
2202
|
);
|
1811
2203
|
|
1812
2204
|
// ../commons/src/events/state/index.ts
|
1813
|
-
var _ = __toESM(require("lodash"));
|
1814
2205
|
function getStatusFromActions(actions) {
|
2206
|
+
const hasRejectedAction = actions.some(
|
2207
|
+
(a) => a.status === ActionStatus.Rejected
|
2208
|
+
);
|
2209
|
+
if (hasRejectedAction) {
|
2210
|
+
return EventStatus.REJECTED;
|
2211
|
+
}
|
1815
2212
|
return actions.reduce((status, action) => {
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
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;
|
1833
2238
|
}
|
1834
|
-
return status;
|
1835
2239
|
}, EventStatus.CREATED);
|
1836
2240
|
}
|
1837
2241
|
function getAssignedUserFromActions(actions) {
|
@@ -1845,7 +2249,7 @@ function getAssignedUserFromActions(actions) {
|
|
1845
2249
|
return user2;
|
1846
2250
|
}, null);
|
1847
2251
|
}
|
1848
|
-
function
|
2252
|
+
function aggregateActionDeclarations(actions) {
|
1849
2253
|
const excludedActions = [
|
1850
2254
|
ActionType.REQUEST_CORRECTION,
|
1851
2255
|
ActionType.PRINT_CERTIFICATE
|
@@ -1859,46 +2263,34 @@ function getData(actions) {
|
|
1859
2263
|
if (!requestAction) {
|
1860
2264
|
return status;
|
1861
2265
|
}
|
1862
|
-
return deepMerge(status, requestAction.
|
2266
|
+
return deepMerge(status, requestAction.declaration);
|
1863
2267
|
}
|
1864
|
-
return deepMerge(status, action.
|
2268
|
+
return deepMerge(status, action.declaration);
|
1865
2269
|
}, {});
|
1866
2270
|
}
|
1867
2271
|
function deepDropNulls(obj) {
|
1868
|
-
if (
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
[key]
|
1877
|
-
};
|
1878
|
-
}
|
1879
|
-
return acc;
|
1880
|
-
}, {});
|
1881
|
-
}
|
1882
|
-
function deepMerge(currentDocument, actionDocument) {
|
1883
|
-
return _.mergeWith(
|
1884
|
-
currentDocument,
|
1885
|
-
actionDocument,
|
1886
|
-
(previousValue, incomingValue) => {
|
1887
|
-
if (incomingValue === void 0) {
|
1888
|
-
return previousValue;
|
1889
|
-
}
|
1890
|
-
if (_.isArray(incomingValue)) {
|
1891
|
-
return incomingValue;
|
1892
|
-
}
|
1893
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
1894
|
-
return void 0;
|
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;
|
1895
2281
|
}
|
1896
|
-
return
|
1897
|
-
}
|
1898
|
-
|
2282
|
+
return acc;
|
2283
|
+
}, {});
|
2284
|
+
}
|
2285
|
+
return obj;
|
1899
2286
|
}
|
1900
|
-
function isUndeclaredDraft(
|
1901
|
-
return
|
2287
|
+
function isUndeclaredDraft(status) {
|
2288
|
+
return status === EventStatus.CREATED;
|
2289
|
+
}
|
2290
|
+
function getAcceptedActions(event2) {
|
2291
|
+
return event2.actions.filter(
|
2292
|
+
(a) => a.status === ActionStatus.Accepted
|
2293
|
+
);
|
1902
2294
|
}
|
1903
2295
|
function getCurrentEventState(event2) {
|
1904
2296
|
const creationAction = event2.actions.find(
|
@@ -1907,7 +2299,12 @@ function getCurrentEventState(event2) {
|
|
1907
2299
|
if (!creationAction) {
|
1908
2300
|
throw new Error(`Event ${event2.id} has no creation action`);
|
1909
2301
|
}
|
1910
|
-
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;
|
1911
2308
|
return deepDropNulls({
|
1912
2309
|
id: event2.id,
|
1913
2310
|
type: event2.type,
|
@@ -1916,16 +2313,17 @@ function getCurrentEventState(event2) {
|
|
1916
2313
|
createdBy: creationAction.createdBy,
|
1917
2314
|
createdAtLocation: creationAction.createdAtLocation,
|
1918
2315
|
modifiedAt: latestAction.createdAt,
|
1919
|
-
assignedTo: getAssignedUserFromActions(
|
2316
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
1920
2317
|
updatedBy: latestAction.createdBy,
|
1921
|
-
|
1922
|
-
|
2318
|
+
updatedAtLocation: event2.updatedAtLocation,
|
2319
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2320
|
+
trackingId: event2.trackingId,
|
2321
|
+
registrationNumber
|
1923
2322
|
});
|
1924
2323
|
}
|
1925
2324
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
1926
|
-
const actions = event2.actions.slice().sort();
|
1927
|
-
const
|
1928
|
-
const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(({ createdAt }) => createdAt > lastAction.createdAt).map((draft) => draft.action).flatMap((action) => {
|
2325
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2326
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
1929
2327
|
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1930
2328
|
return [
|
1931
2329
|
action,
|
@@ -1952,46 +2350,46 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
1952
2350
|
}
|
1953
2351
|
return {
|
1954
2352
|
...eventIndex,
|
1955
|
-
|
1956
|
-
...eventIndex.
|
1957
|
-
...activeDrafts[activeDrafts.length - 1].
|
2353
|
+
declaration: {
|
2354
|
+
...eventIndex.declaration,
|
2355
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
1958
2356
|
}
|
1959
2357
|
};
|
1960
2358
|
}
|
1961
|
-
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({
|
1962
2367
|
event: event2,
|
1963
2368
|
actionType,
|
1964
2369
|
drafts
|
1965
2370
|
}) {
|
1966
|
-
const
|
2371
|
+
const activeActions = getAcceptedActions(event2);
|
2372
|
+
const action = activeActions.find(
|
2373
|
+
(activeAction) => actionType === activeAction.type
|
2374
|
+
);
|
1967
2375
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
1968
2376
|
const sorted = [
|
1969
2377
|
...action ? [action] : [],
|
1970
2378
|
...eventDrafts.map((draft) => draft.action)
|
1971
2379
|
].sort();
|
1972
|
-
const
|
1973
|
-
return deepMerge(
|
2380
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2381
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
1974
2382
|
}, {});
|
1975
|
-
return deepDropNulls(
|
2383
|
+
return deepDropNulls(annotation);
|
1976
2384
|
}
|
1977
2385
|
|
1978
2386
|
// ../commons/src/events/defineConfig.ts
|
1979
2387
|
var defineConfig = (config) => {
|
1980
2388
|
validateWorkqueueConfig(config.workqueues);
|
1981
2389
|
const input = EventConfig.parse(config);
|
1982
|
-
|
1983
|
-
return EventConfig.parse({
|
1984
|
-
...input,
|
1985
|
-
pageFields
|
1986
|
-
});
|
2390
|
+
return input;
|
1987
2391
|
};
|
1988
2392
|
|
1989
|
-
// ../commons/src/uuid.ts
|
1990
|
-
var import_uuid = require("uuid");
|
1991
|
-
function getUUID() {
|
1992
|
-
return (0, import_uuid.v4)();
|
1993
|
-
}
|
1994
|
-
|
1995
2393
|
// ../commons/src/events/transactions.ts
|
1996
2394
|
function generateTransactionId() {
|
1997
2395
|
return getUUID();
|
@@ -2004,6 +2402,16 @@ var import_lodash2 = require("lodash");
|
|
2004
2402
|
function defineConditional(schema) {
|
2005
2403
|
return schema;
|
2006
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
|
+
}
|
2007
2415
|
function alwaysTrue() {
|
2008
2416
|
return {};
|
2009
2417
|
}
|
@@ -2028,6 +2436,9 @@ function not(condition) {
|
|
2028
2436
|
required: []
|
2029
2437
|
});
|
2030
2438
|
}
|
2439
|
+
function never() {
|
2440
|
+
return not(alwaysTrue());
|
2441
|
+
}
|
2031
2442
|
var user = {
|
2032
2443
|
hasScope: (scope) => defineConditional({
|
2033
2444
|
type: "object",
|
@@ -2075,69 +2486,120 @@ var event = {
|
|
2075
2486
|
required: ["$event"]
|
2076
2487
|
})
|
2077
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
|
+
}
|
2078
2509
|
function field(fieldId) {
|
2079
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2080
2510
|
const getDateRange = (date, clause) => ({
|
2081
2511
|
type: "object",
|
2082
2512
|
properties: {
|
2083
|
-
|
2084
|
-
type: "
|
2085
|
-
|
2086
|
-
|
2087
|
-
type: "string",
|
2088
|
-
format: "date",
|
2089
|
-
[clause]: date
|
2090
|
-
}
|
2091
|
-
},
|
2092
|
-
required: [fieldId]
|
2513
|
+
[fieldId]: {
|
2514
|
+
type: "string",
|
2515
|
+
format: "date",
|
2516
|
+
[clause]: date
|
2093
2517
|
}
|
2094
2518
|
},
|
2095
|
-
required: [
|
2519
|
+
required: [fieldId]
|
2096
2520
|
});
|
2097
2521
|
return {
|
2522
|
+
/**
|
2523
|
+
* @private Internal property used for field reference tracking.
|
2524
|
+
*/
|
2525
|
+
_fieldId: fieldId,
|
2098
2526
|
isAfter: () => ({
|
2099
2527
|
days: (days) => ({
|
2100
|
-
inPast: () =>
|
2528
|
+
inPast: () => defineFormConditional(
|
2101
2529
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2102
2530
|
),
|
2103
|
-
inFuture: () =>
|
2531
|
+
inFuture: () => defineFormConditional(
|
2104
2532
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2105
2533
|
)
|
2106
2534
|
}),
|
2107
|
-
date: (date) =>
|
2108
|
-
|
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"))
|
2109
2549
|
}),
|
2110
2550
|
isBefore: () => ({
|
2111
2551
|
days: (days) => ({
|
2112
|
-
inPast: () =>
|
2552
|
+
inPast: () => defineFormConditional(
|
2113
2553
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2114
2554
|
),
|
2115
|
-
inFuture: () =>
|
2555
|
+
inFuture: () => defineFormConditional(
|
2116
2556
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2117
2557
|
)
|
2118
2558
|
}),
|
2119
|
-
date: (date) =>
|
2120
|
-
|
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"))
|
2121
2573
|
}),
|
2122
|
-
isEqualTo: (value) =>
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2574
|
+
isEqualTo: (value) => {
|
2575
|
+
if (isFieldReference(value)) {
|
2576
|
+
const comparedFieldId = value._fieldId;
|
2577
|
+
return defineFormConditional({
|
2126
2578
|
type: "object",
|
2127
2579
|
properties: {
|
2128
2580
|
[fieldId]: {
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
const: value
|
2134
|
-
}
|
2581
|
+
type: ["string", "boolean"],
|
2582
|
+
const: { $data: `1/${comparedFieldId}` }
|
2583
|
+
},
|
2584
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2135
2585
|
},
|
2136
|
-
required: [fieldId]
|
2137
|
-
}
|
2138
|
-
}
|
2139
|
-
|
2140
|
-
|
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
|
+
},
|
2141
2603
|
/**
|
2142
2604
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2143
2605
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2146,91 +2608,102 @@ function field(fieldId) {
|
|
2146
2608
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2147
2609
|
*
|
2148
2610
|
*/
|
2149
|
-
isFalsy: () =>
|
2611
|
+
isFalsy: () => defineFormConditional({
|
2150
2612
|
type: "object",
|
2151
2613
|
properties: {
|
2152
|
-
|
2153
|
-
type: "object",
|
2154
|
-
properties: {
|
2155
|
-
[fieldId]: {
|
2156
|
-
anyOf: [
|
2157
|
-
{ const: "undefined" },
|
2158
|
-
{ const: false },
|
2159
|
-
{ const: null },
|
2160
|
-
{ const: "" }
|
2161
|
-
]
|
2162
|
-
}
|
2163
|
-
},
|
2614
|
+
[fieldId]: {
|
2164
2615
|
anyOf: [
|
2165
|
-
{
|
2166
|
-
|
2167
|
-
},
|
2168
|
-
{
|
2169
|
-
not: {
|
2170
|
-
required: [fieldId]
|
2171
|
-
}
|
2172
|
-
}
|
2616
|
+
{ const: "undefined" },
|
2617
|
+
{ const: false },
|
2618
|
+
{ const: null },
|
2619
|
+
{ const: "" }
|
2173
2620
|
]
|
2174
2621
|
}
|
2175
2622
|
},
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
$form: {
|
2182
|
-
type: "object",
|
2183
|
-
properties: {
|
2184
|
-
[fieldId]: {
|
2185
|
-
type: "string",
|
2186
|
-
enum: ["undefined"]
|
2187
|
-
}
|
2188
|
-
},
|
2623
|
+
anyOf: [
|
2624
|
+
{
|
2625
|
+
required: [fieldId]
|
2626
|
+
},
|
2627
|
+
{
|
2189
2628
|
not: {
|
2190
2629
|
required: [fieldId]
|
2191
2630
|
}
|
2192
2631
|
}
|
2632
|
+
]
|
2633
|
+
}),
|
2634
|
+
isUndefined: () => defineFormConditional({
|
2635
|
+
type: "object",
|
2636
|
+
properties: {
|
2637
|
+
[fieldId]: {
|
2638
|
+
type: "string",
|
2639
|
+
enum: ["undefined"]
|
2640
|
+
}
|
2193
2641
|
},
|
2194
|
-
|
2642
|
+
not: {
|
2643
|
+
required: [fieldId]
|
2644
|
+
}
|
2195
2645
|
}),
|
2196
|
-
inArray: (values) =>
|
2646
|
+
inArray: (values) => defineFormConditional({
|
2197
2647
|
type: "object",
|
2198
2648
|
properties: {
|
2199
|
-
|
2200
|
-
type: "
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2649
|
+
[fieldId]: {
|
2650
|
+
type: "string",
|
2651
|
+
enum: values
|
2652
|
+
}
|
2653
|
+
},
|
2654
|
+
required: [fieldId]
|
2655
|
+
}),
|
2656
|
+
isValidEnglishName: () => defineFormConditional({
|
2657
|
+
type: "object",
|
2658
|
+
properties: {
|
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
|
2208
2689
|
}
|
2209
2690
|
},
|
2210
|
-
required: [
|
2691
|
+
required: [fieldId]
|
2211
2692
|
})
|
2212
2693
|
};
|
2213
2694
|
}
|
2214
2695
|
|
2215
2696
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2216
|
-
var PRINT_CERTIFICATE_FORM =
|
2697
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2217
2698
|
label: {
|
2218
2699
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2219
2700
|
defaultMessage: "Tennis club membership certificate collector",
|
2220
2701
|
description: "This is what this form is referred as in the system"
|
2221
2702
|
},
|
2222
|
-
version: {
|
2223
|
-
id: "1.0.0",
|
2224
|
-
label: {
|
2225
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2226
|
-
defaultMessage: "Version 1",
|
2227
|
-
description: "This is the first version of the form"
|
2228
|
-
}
|
2229
|
-
},
|
2230
|
-
active: true,
|
2231
2703
|
pages: [
|
2232
2704
|
{
|
2233
2705
|
id: "collector",
|
2706
|
+
type: PageTypes.enum.FORM,
|
2234
2707
|
title: {
|
2235
2708
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2236
2709
|
defaultMessage: "Print certified copy",
|
@@ -2245,7 +2718,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2245
2718
|
defaultMessage: "Requester",
|
2246
2719
|
description: "This is the label for the field"
|
2247
2720
|
},
|
2248
|
-
type:
|
2721
|
+
type: FieldType.SELECT,
|
2249
2722
|
options: [
|
2250
2723
|
{
|
2251
2724
|
value: "INFORMANT",
|
@@ -2322,7 +2795,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2322
2795
|
defaultMessage: "Select Type of ID",
|
2323
2796
|
description: "This is the label for selecting the type of ID"
|
2324
2797
|
},
|
2325
|
-
type:
|
2798
|
+
type: FieldType.SELECT,
|
2326
2799
|
options: [
|
2327
2800
|
{
|
2328
2801
|
value: "PASSPORT",
|
@@ -2423,7 +2896,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2423
2896
|
defaultMessage: "Passport Details",
|
2424
2897
|
description: "Field for entering Passport details"
|
2425
2898
|
},
|
2426
|
-
type:
|
2899
|
+
type: FieldType.TEXT
|
2427
2900
|
},
|
2428
2901
|
{
|
2429
2902
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2474,7 +2947,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2474
2947
|
defaultMessage: "Driving License Details",
|
2475
2948
|
description: "Field for entering Driving License details"
|
2476
2949
|
},
|
2477
|
-
type:
|
2950
|
+
type: FieldType.TEXT
|
2478
2951
|
},
|
2479
2952
|
{
|
2480
2953
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2525,7 +2998,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2525
2998
|
defaultMessage: "Refugee Number Details",
|
2526
2999
|
description: "Field for entering Refugee Number details"
|
2527
3000
|
},
|
2528
|
-
type:
|
3001
|
+
type: FieldType.TEXT
|
2529
3002
|
},
|
2530
3003
|
{
|
2531
3004
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2576,7 +3049,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2576
3049
|
defaultMessage: "Alien Number Details",
|
2577
3050
|
description: "Field for entering Alien Number details"
|
2578
3051
|
},
|
2579
|
-
type:
|
3052
|
+
type: FieldType.TEXT
|
2580
3053
|
},
|
2581
3054
|
{
|
2582
3055
|
id: "collector.OTHER.idTypeOther",
|
@@ -2627,7 +3100,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2627
3100
|
defaultMessage: "Other ID Type (if applicable)",
|
2628
3101
|
description: 'Field for entering ID type if "Other" is selected'
|
2629
3102
|
},
|
2630
|
-
type:
|
3103
|
+
type: FieldType.TEXT
|
2631
3104
|
},
|
2632
3105
|
{
|
2633
3106
|
id: "collector.OTHER.firstName",
|
@@ -2678,7 +3151,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2678
3151
|
defaultMessage: "First Name",
|
2679
3152
|
description: "This is the label for the first name field"
|
2680
3153
|
},
|
2681
|
-
type:
|
3154
|
+
type: FieldType.TEXT
|
2682
3155
|
},
|
2683
3156
|
{
|
2684
3157
|
id: "collector.OTHER.lastName",
|
@@ -2729,7 +3202,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2729
3202
|
defaultMessage: "Last Name",
|
2730
3203
|
description: "This is the label for the last name field"
|
2731
3204
|
},
|
2732
|
-
type:
|
3205
|
+
type: FieldType.TEXT
|
2733
3206
|
},
|
2734
3207
|
{
|
2735
3208
|
id: "collector.OTHER.relationshipToMember",
|
@@ -2780,7 +3253,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2780
3253
|
defaultMessage: "Relationship to Member",
|
2781
3254
|
description: "This is the label for the relationship to member field"
|
2782
3255
|
},
|
2783
|
-
type:
|
3256
|
+
type: FieldType.TEXT
|
2784
3257
|
},
|
2785
3258
|
{
|
2786
3259
|
id: "collector.OTHER.signedAffidavit",
|
@@ -2831,66 +3304,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2831
3304
|
defaultMessage: "Signed Affidavit (Optional)",
|
2832
3305
|
description: "This is the label for uploading a signed affidavit"
|
2833
3306
|
},
|
2834
|
-
type:
|
3307
|
+
type: FieldType.FILE
|
2835
3308
|
}
|
2836
3309
|
]
|
2837
|
-
}
|
2838
|
-
],
|
2839
|
-
review: {
|
2840
|
-
title: {
|
2841
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
2842
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
2843
|
-
description: "Title of the form to show in review page"
|
2844
3310
|
},
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2860
|
-
|
3311
|
+
{
|
3312
|
+
id: "collector.identity.verify",
|
3313
|
+
type: PageTypes.enum.VERIFICATION,
|
3314
|
+
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3315
|
+
title: {
|
3316
|
+
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
3317
|
+
defaultMessage: "Verify their identity",
|
3318
|
+
description: "This is the title of the section"
|
3319
|
+
},
|
3320
|
+
fields: [],
|
3321
|
+
actions: {
|
3322
|
+
verify: {
|
3323
|
+
label: {
|
3324
|
+
defaultMessage: "Verified",
|
3325
|
+
description: "This is the label for the verification button",
|
3326
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.verify"
|
3327
|
+
}
|
3328
|
+
},
|
3329
|
+
cancel: {
|
3330
|
+
label: {
|
3331
|
+
defaultMessage: "Identity does not match",
|
3332
|
+
description: "This is the label for the verification cancellation button",
|
3333
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
|
3334
|
+
},
|
3335
|
+
confirmation: {
|
3336
|
+
title: {
|
3337
|
+
defaultMessage: "Print without proof of ID?",
|
3338
|
+
description: "This is the title for the verification cancellation modal",
|
3339
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
|
3340
|
+
},
|
3341
|
+
body: {
|
3342
|
+
defaultMessage: "Please be aware that if you proceed, you will be responsible for issuing a certificate without the necessary proof of ID from the collector",
|
3343
|
+
description: "This is the body for the verification cancellation modal",
|
3344
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
|
3345
|
+
}
|
3346
|
+
}
|
3347
|
+
}
|
3348
|
+
}
|
2861
3349
|
}
|
3350
|
+
]
|
3351
|
+
});
|
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"
|
2862
3357
|
},
|
2863
|
-
|
2864
|
-
|
2865
|
-
id: "
|
2866
|
-
|
2867
|
-
|
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
|
+
}
|
2868
3367
|
},
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
description: "Label for the comment field in the review section"
|
2877
|
-
}
|
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"
|
2878
3375
|
},
|
2879
|
-
{
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
defaultMessage: "Signature of informant",
|
2884
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
2885
|
-
description: "Label for the signature field in the review section"
|
2886
|
-
},
|
2887
|
-
signaturePromptLabel: {
|
2888
|
-
id: "v2.signature.upload.modal.title",
|
2889
|
-
defaultMessage: "Draw signature",
|
2890
|
-
description: "Title for the modal to draw signature"
|
2891
|
-
}
|
3376
|
+
signaturePromptLabel: {
|
3377
|
+
id: "v2.signature.upload.modal.title",
|
3378
|
+
defaultMessage: "Draw signature",
|
3379
|
+
description: "Title for the modal to draw signature"
|
2892
3380
|
}
|
2893
|
-
|
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"
|
2894
3389
|
},
|
2895
3390
|
pages: [
|
2896
3391
|
{
|
@@ -2903,7 +3398,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2903
3398
|
fields: [
|
2904
3399
|
{
|
2905
3400
|
id: "applicant.firstname",
|
2906
|
-
type:
|
3401
|
+
type: FieldType.TEXT,
|
2907
3402
|
required: true,
|
2908
3403
|
conditionals: [],
|
2909
3404
|
label: {
|
@@ -2914,7 +3409,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2914
3409
|
},
|
2915
3410
|
{
|
2916
3411
|
id: "applicant.surname",
|
2917
|
-
type:
|
3412
|
+
type: FieldType.TEXT,
|
2918
3413
|
required: true,
|
2919
3414
|
conditionals: [],
|
2920
3415
|
label: {
|
@@ -2936,9 +3431,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2936
3431
|
},
|
2937
3432
|
{
|
2938
3433
|
id: "applicant.dob",
|
2939
|
-
type:
|
3434
|
+
type: FieldType.DATE,
|
2940
3435
|
required: true,
|
2941
|
-
conditionals: [],
|
2942
3436
|
validation: [
|
2943
3437
|
{
|
2944
3438
|
message: {
|
@@ -2949,15 +3443,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2949
3443
|
validator: field("applicant.dob").isBefore().now()
|
2950
3444
|
}
|
2951
3445
|
],
|
3446
|
+
conditionals: [
|
3447
|
+
{
|
3448
|
+
type: ConditionalType.SHOW,
|
3449
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3450
|
+
}
|
3451
|
+
],
|
2952
3452
|
label: {
|
2953
3453
|
defaultMessage: "Applicant's date of birth",
|
2954
3454
|
description: "This is the label for the field",
|
2955
3455
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
2956
3456
|
}
|
2957
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
|
+
},
|
2958
3490
|
{
|
2959
3491
|
id: "applicant.image",
|
2960
|
-
type:
|
3492
|
+
type: FieldType.FILE,
|
2961
3493
|
required: false,
|
2962
3494
|
label: {
|
2963
3495
|
defaultMessage: "Applicant's profile picture",
|
@@ -2978,6 +3510,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2978
3510
|
}
|
2979
3511
|
]
|
2980
3512
|
},
|
3513
|
+
{
|
3514
|
+
id: "senior-pass",
|
3515
|
+
conditional: field("applicant.dob").isBefore().date("1950-01-01"),
|
3516
|
+
title: {
|
3517
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
|
3518
|
+
defaultMessage: "Assign senior pass for applicant",
|
3519
|
+
description: "This is the title of the section"
|
3520
|
+
},
|
3521
|
+
fields: [
|
3522
|
+
{
|
3523
|
+
id: "senior-pass.id",
|
3524
|
+
type: FieldType.TEXT,
|
3525
|
+
required: true,
|
3526
|
+
label: {
|
3527
|
+
defaultMessage: "Senior pass ID",
|
3528
|
+
description: "This is the label for the field",
|
3529
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
|
3530
|
+
}
|
3531
|
+
}
|
3532
|
+
]
|
3533
|
+
},
|
2981
3534
|
{
|
2982
3535
|
id: "recommender",
|
2983
3536
|
title: {
|
@@ -2999,7 +3552,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2999
3552
|
},
|
3000
3553
|
{
|
3001
3554
|
id: "recommender.firstname",
|
3002
|
-
type:
|
3555
|
+
type: FieldType.TEXT,
|
3003
3556
|
required: true,
|
3004
3557
|
conditionals: [
|
3005
3558
|
{
|
@@ -3015,7 +3568,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3015
3568
|
},
|
3016
3569
|
{
|
3017
3570
|
id: "recommender.surname",
|
3018
|
-
type:
|
3571
|
+
type: FieldType.TEXT,
|
3019
3572
|
required: true,
|
3020
3573
|
conditionals: [
|
3021
3574
|
{
|
@@ -3031,7 +3584,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3031
3584
|
},
|
3032
3585
|
{
|
3033
3586
|
id: "recommender.id",
|
3034
|
-
type:
|
3587
|
+
type: FieldType.TEXT,
|
3035
3588
|
required: true,
|
3036
3589
|
conditionals: [
|
3037
3590
|
{
|
@@ -3139,7 +3692,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3139
3692
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3140
3693
|
id: "event.tennis-club-membership.action.declare.label"
|
3141
3694
|
},
|
3142
|
-
|
3695
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3143
3696
|
},
|
3144
3697
|
{
|
3145
3698
|
type: ActionType.VALIDATE,
|
@@ -3148,7 +3701,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3148
3701
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3149
3702
|
id: "event.tennis-club-membership.action.validate.label"
|
3150
3703
|
},
|
3151
|
-
|
3704
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3152
3705
|
},
|
3153
3706
|
{
|
3154
3707
|
type: ActionType.REGISTER,
|
@@ -3157,7 +3710,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3157
3710
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3158
3711
|
id: "event.tennis-club-membership.action.register.label"
|
3159
3712
|
},
|
3160
|
-
|
3713
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3161
3714
|
},
|
3162
3715
|
{
|
3163
3716
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3166,10 +3719,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3166
3719
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3167
3720
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3168
3721
|
},
|
3169
|
-
forms: [TENNIS_CLUB_FORM],
|
3170
3722
|
onboardingForm: [
|
3171
3723
|
{
|
3172
3724
|
id: "correction-requester",
|
3725
|
+
type: PageTypes.enum.FORM,
|
3173
3726
|
title: {
|
3174
3727
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3175
3728
|
defaultMessage: "Correction requester",
|
@@ -3233,6 +3786,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3233
3786
|
},
|
3234
3787
|
{
|
3235
3788
|
id: "identity-check",
|
3789
|
+
type: PageTypes.enum.FORM,
|
3236
3790
|
title: {
|
3237
3791
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3238
3792
|
defaultMessage: "Verify their identity",
|
@@ -3275,6 +3829,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3275
3829
|
additionalDetailsForm: [
|
3276
3830
|
{
|
3277
3831
|
id: "correction-request.supporting-documents",
|
3832
|
+
type: PageTypes.enum.FORM,
|
3278
3833
|
title: {
|
3279
3834
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3280
3835
|
defaultMessage: "Upload supporting documents",
|
@@ -3292,7 +3847,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3292
3847
|
},
|
3293
3848
|
{
|
3294
3849
|
id: "correction.supportingDocs",
|
3295
|
-
type:
|
3850
|
+
type: FieldType.FILE,
|
3296
3851
|
label: {
|
3297
3852
|
id: "correction.corrector.title",
|
3298
3853
|
defaultMessage: "Upload supporting documents",
|
@@ -3336,6 +3891,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3336
3891
|
},
|
3337
3892
|
{
|
3338
3893
|
id: "correction-request.additional-details",
|
3894
|
+
type: PageTypes.enum.FORM,
|
3339
3895
|
title: {
|
3340
3896
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3341
3897
|
defaultMessage: "Reason for correction",
|
@@ -3344,7 +3900,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3344
3900
|
fields: [
|
3345
3901
|
{
|
3346
3902
|
id: "correction.request.reason",
|
3347
|
-
type:
|
3903
|
+
type: FieldType.TEXT,
|
3348
3904
|
label: {
|
3349
3905
|
id: "correction.reason.title",
|
3350
3906
|
defaultMessage: "Reason for correction?",
|
@@ -3357,7 +3913,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3357
3913
|
},
|
3358
3914
|
{
|
3359
3915
|
type: ActionType.APPROVE_CORRECTION,
|
3360
|
-
forms: [TENNIS_CLUB_FORM],
|
3361
3916
|
label: {
|
3362
3917
|
defaultMessage: "Approve correction",
|
3363
3918
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3371,7 +3926,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3371
3926
|
defaultMessage: "Print certificate",
|
3372
3927
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3373
3928
|
},
|
3374
|
-
|
3929
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3375
3930
|
conditionals: [
|
3376
3931
|
{
|
3377
3932
|
type: "SHOW",
|
@@ -3411,6 +3966,22 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3411
3966
|
})
|
3412
3967
|
}
|
3413
3968
|
]
|
3969
|
+
},
|
3970
|
+
{
|
3971
|
+
type: ActionType.ARCHIVE,
|
3972
|
+
label: {
|
3973
|
+
id: "v2.event.tennis-club-membership.action.archive.label",
|
3974
|
+
defaultMessage: "Archive",
|
3975
|
+
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3976
|
+
}
|
3977
|
+
},
|
3978
|
+
{
|
3979
|
+
type: ActionType.REJECT,
|
3980
|
+
label: {
|
3981
|
+
id: "v2.event.tennis-club-membership.action.reject.label",
|
3982
|
+
defaultMessage: "Reject",
|
3983
|
+
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3984
|
+
}
|
3414
3985
|
}
|
3415
3986
|
],
|
3416
3987
|
advancedSearch: [
|
@@ -3426,20 +3997,53 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3426
3997
|
}
|
3427
3998
|
]
|
3428
3999
|
}
|
3429
|
-
]
|
4000
|
+
],
|
4001
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3430
4002
|
});
|
3431
4003
|
|
3432
4004
|
// ../commons/src/events/test.utils.ts
|
3433
|
-
function
|
3434
|
-
|
3435
|
-
const data = fields.reduce(
|
4005
|
+
function fieldConfigsToActionPayload(fields) {
|
4006
|
+
return fields.reduce(
|
3436
4007
|
(acc, field2, i) => ({
|
3437
4008
|
...acc,
|
3438
4009
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3439
4010
|
}),
|
3440
4011
|
{}
|
3441
4012
|
);
|
3442
|
-
|
4013
|
+
}
|
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(
|
4032
|
+
configuration,
|
4033
|
+
action
|
4034
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
4035
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
4036
|
+
(acc, pageId) => ({
|
4037
|
+
...acc,
|
4038
|
+
[pageId]: true
|
4039
|
+
}),
|
4040
|
+
{}
|
4041
|
+
);
|
4042
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4043
|
+
return {
|
4044
|
+
...fieldBasedPayload,
|
4045
|
+
...visiblePageVerificationMap
|
4046
|
+
};
|
3443
4047
|
}
|
3444
4048
|
var eventPayloadGenerator = {
|
3445
4049
|
create: (input = {}) => ({
|
@@ -3451,21 +4055,22 @@ var eventPayloadGenerator = {
|
|
3451
4055
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3452
4056
|
id
|
3453
4057
|
}),
|
3454
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4058
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3455
4059
|
{
|
3456
4060
|
id: getUUID(),
|
3457
4061
|
eventId,
|
3458
4062
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3459
4063
|
transactionId: getUUID(),
|
3460
4064
|
action: {
|
3461
|
-
type:
|
3462
|
-
|
4065
|
+
type: actionType,
|
4066
|
+
status: ActionStatus.Accepted,
|
4067
|
+
declaration: {
|
3463
4068
|
"applicant.firstname": "Max",
|
3464
4069
|
"applicant.surname": "McLaren",
|
3465
4070
|
"applicant.dob": "2020-01-02",
|
3466
4071
|
"recommender.none": true
|
3467
4072
|
},
|
3468
|
-
|
4073
|
+
annotation: {
|
3469
4074
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3470
4075
|
"correction.request.reason": "Child's name was incorrect"
|
3471
4076
|
},
|
@@ -3480,41 +4085,104 @@ var eventPayloadGenerator = {
|
|
3480
4085
|
declare: (eventId, input = {}) => ({
|
3481
4086
|
type: ActionType.DECLARE,
|
3482
4087
|
transactionId: input.transactionId ?? getUUID(),
|
3483
|
-
|
4088
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4089
|
+
tennisClubMembershipEvent,
|
4090
|
+
ActionType.DECLARE
|
4091
|
+
),
|
4092
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4093
|
+
tennisClubMembershipEvent,
|
4094
|
+
ActionType.DECLARE
|
4095
|
+
),
|
3484
4096
|
eventId
|
3485
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
|
+
},
|
3486
4120
|
validate: (eventId, input = {}) => ({
|
3487
4121
|
type: ActionType.VALIDATE,
|
3488
4122
|
transactionId: input.transactionId ?? getUUID(),
|
3489
|
-
|
4123
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4124
|
+
tennisClubMembershipEvent,
|
4125
|
+
ActionType.VALIDATE
|
4126
|
+
),
|
4127
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4128
|
+
tennisClubMembershipEvent,
|
4129
|
+
ActionType.VALIDATE
|
4130
|
+
),
|
3490
4131
|
duplicates: [],
|
3491
4132
|
eventId
|
3492
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
|
+
}),
|
3493
4148
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3494
|
-
type: ActionType.
|
4149
|
+
type: ActionType.ARCHIVE,
|
3495
4150
|
transactionId: input.transactionId ?? getUUID(),
|
3496
|
-
|
3497
|
-
|
4151
|
+
declaration: {},
|
4152
|
+
// @TODO: Check whether generator is needed?
|
4153
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3498
4154
|
duplicates: [],
|
3499
4155
|
eventId
|
3500
4156
|
}),
|
3501
4157
|
reject: (eventId, input = {}) => ({
|
3502
4158
|
type: ActionType.REJECT,
|
3503
4159
|
transactionId: input.transactionId ?? getUUID(),
|
3504
|
-
|
4160
|
+
declaration: {},
|
4161
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4162
|
+
tennisClubMembershipEvent,
|
4163
|
+
ActionType.REJECT
|
4164
|
+
),
|
3505
4165
|
duplicates: [],
|
3506
4166
|
eventId
|
3507
4167
|
}),
|
3508
4168
|
register: (eventId, input = {}) => ({
|
3509
4169
|
type: ActionType.REGISTER,
|
3510
4170
|
transactionId: input.transactionId ?? getUUID(),
|
3511
|
-
|
4171
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4172
|
+
tennisClubMembershipEvent,
|
4173
|
+
ActionType.REGISTER
|
4174
|
+
),
|
4175
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4176
|
+
tennisClubMembershipEvent,
|
4177
|
+
ActionType.REGISTER
|
4178
|
+
),
|
3512
4179
|
eventId
|
3513
4180
|
}),
|
3514
4181
|
printCertificate: (eventId, input = {}) => ({
|
3515
4182
|
type: ActionType.PRINT_CERTIFICATE,
|
3516
4183
|
transactionId: input.transactionId ?? getUUID(),
|
3517
|
-
|
4184
|
+
declaration: {},
|
4185
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3518
4186
|
tennisClubMembershipEvent,
|
3519
4187
|
ActionType.PRINT_CERTIFICATE
|
3520
4188
|
),
|
@@ -3524,17 +4192,21 @@ var eventPayloadGenerator = {
|
|
3524
4192
|
request: (eventId, input = {}) => ({
|
3525
4193
|
type: ActionType.REQUEST_CORRECTION,
|
3526
4194
|
transactionId: input.transactionId ?? getUUID(),
|
3527
|
-
|
4195
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4196
|
+
tennisClubMembershipEvent,
|
4197
|
+
ActionType.REQUEST_CORRECTION
|
4198
|
+
),
|
4199
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3528
4200
|
tennisClubMembershipEvent,
|
3529
4201
|
ActionType.REQUEST_CORRECTION
|
3530
4202
|
),
|
3531
|
-
metadata: {},
|
3532
4203
|
eventId
|
3533
4204
|
}),
|
3534
4205
|
approve: (eventId, requestId, input = {}) => ({
|
3535
4206
|
type: ActionType.APPROVE_CORRECTION,
|
3536
4207
|
transactionId: input.transactionId ?? getUUID(),
|
3537
|
-
|
4208
|
+
declaration: {},
|
4209
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3538
4210
|
tennisClubMembershipEvent,
|
3539
4211
|
ActionType.APPROVE_CORRECTION
|
3540
4212
|
),
|
@@ -3544,7 +4216,8 @@ var eventPayloadGenerator = {
|
|
3544
4216
|
reject: (eventId, requestId, input = {}) => ({
|
3545
4217
|
type: ActionType.REJECT_CORRECTION,
|
3546
4218
|
transactionId: input.transactionId ?? getUUID(),
|
3547
|
-
|
4219
|
+
declaration: {},
|
4220
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3548
4221
|
tennisClubMembershipEvent,
|
3549
4222
|
ActionType.REJECT_CORRECTION
|
3550
4223
|
),
|
@@ -3560,24 +4233,31 @@ function generateActionDocument({
|
|
3560
4233
|
defaults = {}
|
3561
4234
|
}) {
|
3562
4235
|
const actionBase = {
|
3563
|
-
createdAt
|
4236
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4237
|
+
// @TODO: This should be fixed in the future.
|
4238
|
+
createdAt: new Date(Date.now() - 500).toISOString(),
|
3564
4239
|
createdBy: getUUID(),
|
3565
4240
|
id: getUUID(),
|
3566
4241
|
createdAtLocation: "TODO",
|
3567
|
-
|
3568
|
-
|
3569
|
-
...defaults
|
4242
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4243
|
+
annotation: {},
|
4244
|
+
...defaults,
|
4245
|
+
status: ActionStatus.Accepted
|
3570
4246
|
};
|
3571
4247
|
switch (action) {
|
4248
|
+
case ActionType.READ:
|
4249
|
+
return { ...actionBase, type: action };
|
4250
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4251
|
+
return { ...actionBase, type: action };
|
3572
4252
|
case ActionType.DECLARE:
|
3573
4253
|
return { ...actionBase, type: action };
|
3574
4254
|
case ActionType.UNASSIGN:
|
3575
|
-
return { ...actionBase, type: action };
|
4255
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3576
4256
|
case ActionType.ASSIGN:
|
3577
4257
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3578
4258
|
case ActionType.VALIDATE:
|
3579
4259
|
return { ...actionBase, type: action };
|
3580
|
-
case ActionType.
|
4260
|
+
case ActionType.ARCHIVE:
|
3581
4261
|
return { ...actionBase, type: action };
|
3582
4262
|
case ActionType.REJECT:
|
3583
4263
|
return { ...actionBase, type: action };
|
@@ -3593,14 +4273,13 @@ function generateActionDocument({
|
|
3593
4273
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3594
4274
|
case ActionType.REJECT_CORRECTION:
|
3595
4275
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3596
|
-
case ActionType.CUSTOM:
|
3597
|
-
return { ...actionBase, type: action };
|
3598
4276
|
case ActionType.REGISTER:
|
3599
4277
|
return {
|
3600
4278
|
...actionBase,
|
3601
|
-
type: action
|
3602
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4279
|
+
type: action
|
3603
4280
|
};
|
4281
|
+
case ActionType.DELETE:
|
4282
|
+
case ActionType.DETECT_DUPLICATE:
|
3604
4283
|
default:
|
3605
4284
|
throw new Error(`Unsupported action type: ${action}`);
|
3606
4285
|
}
|
@@ -3615,12 +4294,17 @@ function generateEventDocument({
|
|
3615
4294
|
actions: actions.map(
|
3616
4295
|
(action) => generateActionDocument({ configuration, action })
|
3617
4296
|
),
|
3618
|
-
createdAt
|
4297
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4298
|
+
// @TODO: This should be fixed in the future.
|
4299
|
+
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
3619
4300
|
id: getUUID(),
|
3620
|
-
|
4301
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4302
|
+
// @TODO: This should be fixed in the future.
|
4303
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4304
|
+
updatedAtLocation: "TODO"
|
3621
4305
|
};
|
3622
4306
|
}
|
3623
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4307
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3624
4308
|
const action = generateActionDocument({
|
3625
4309
|
configuration: tennisClubMembershipEvent,
|
3626
4310
|
action: actionType
|
@@ -3630,9 +4314,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3630
4314
|
transactionId: getUUID(),
|
3631
4315
|
action: {
|
3632
4316
|
...action,
|
3633
|
-
|
3634
|
-
...action.
|
3635
|
-
...
|
4317
|
+
declaration: {
|
4318
|
+
...action.declaration,
|
4319
|
+
...declaration
|
3636
4320
|
}
|
3637
4321
|
},
|
3638
4322
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3646,10 +4330,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3646
4330
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3647
4331
|
createdBy: overrides.createdBy ?? getUUID(),
|
3648
4332
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
4333
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
3649
4334
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3650
4335
|
assignedTo: overrides.assignedTo ?? null,
|
3651
4336
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3652
|
-
|
4337
|
+
declaration: overrides.declaration ?? {
|
3653
4338
|
"recommender.none": true,
|
3654
4339
|
"applicant.firstname": "Danny",
|
3655
4340
|
"applicant.surname": "Doe",
|
@@ -3657,3 +4342,226 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3657
4342
|
},
|
3658
4343
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3659
4344
|
});
|
4345
|
+
var generateTranslationConfig = (message) => ({
|
4346
|
+
defaultMessage: message,
|
4347
|
+
description: "Description for ${message}",
|
4348
|
+
id: message
|
4349
|
+
});
|
4350
|
+
|
4351
|
+
// ../commons/src/events/TemplateConfig.ts
|
4352
|
+
function isTemplateVariable(value) {
|
4353
|
+
return typeof value === "string" && value.startsWith("$");
|
4354
|
+
}
|
4355
|
+
function isFieldValue(value) {
|
4356
|
+
return FieldValue.safeParse(value).success;
|
4357
|
+
}
|
4358
|
+
function isFieldValueWithoutTemplates(value) {
|
4359
|
+
if (isTemplateVariable(value)) {
|
4360
|
+
return false;
|
4361
|
+
}
|
4362
|
+
if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
|
4363
|
+
return false;
|
4364
|
+
}
|
4365
|
+
return true;
|
4366
|
+
}
|
4367
|
+
function isFieldConfigDefaultValue(value) {
|
4368
|
+
if (!value) {
|
4369
|
+
return false;
|
4370
|
+
}
|
4371
|
+
if (isFieldValue(value)) {
|
4372
|
+
return true;
|
4373
|
+
}
|
4374
|
+
if (isTemplateVariable(value)) {
|
4375
|
+
return true;
|
4376
|
+
}
|
4377
|
+
if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
|
4378
|
+
return Object.values(value).every((v) => isFieldConfigDefaultValue(v));
|
4379
|
+
}
|
4380
|
+
return false;
|
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
|
+
}
|