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