@opencrvs/toolkit 1.8.0-rc.f7e8fb5 → 1.8.0-rc.f8e4107
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 +6649 -9067
- package/dist/commons/conditionals/conditionals.d.ts +91 -3
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +41 -17
- package/dist/commons/conditionals/validate.test.d.ts +2 -0
- package/dist/commons/events/ActionConfig.d.ts +1123 -2056
- package/dist/commons/events/ActionDocument.d.ts +9644 -363
- package/dist/commons/events/ActionInput.d.ts +5329 -472
- package/dist/commons/events/ActionType.d.ts +26 -11
- package/dist/commons/events/AdvancedSearchConfig.d.ts +107 -14
- package/dist/commons/events/CompositeFieldValue.d.ts +152 -2
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +361 -53
- package/dist/commons/events/EventConfig.d.ts +634 -1223
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +3495 -499
- package/dist/commons/events/EventIndex.d.ts +752 -7
- package/dist/commons/events/EventMetadata.d.ts +9 -3
- package/dist/commons/events/FieldConfig.d.ts +571 -119
- package/dist/commons/events/FieldType.d.ts +2 -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/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/defineConfig.d.ts +94 -215
- package/dist/commons/events/index.d.ts +2 -1
- package/dist/commons/events/test.utils.d.ts +140 -213
- package/dist/commons/events/utils.d.ts +125 -86
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +215 -81
- package/dist/events/index.js +1949 -1232
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -30,20 +30,27 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
30
30
|
// src/events/index.ts
|
31
31
|
var events_exports = {};
|
32
32
|
__export(events_exports, {
|
33
|
+
Action: () => Action,
|
33
34
|
ActionBase: () => ActionBase,
|
34
35
|
ActionConditional: () => ActionConditional,
|
35
36
|
ActionConfig: () => ActionConfig,
|
36
37
|
ActionConfigBase: () => ActionConfigBase,
|
37
38
|
ActionDocument: () => ActionDocument,
|
39
|
+
ActionFormConfig: () => ActionFormConfig,
|
38
40
|
ActionInput: () => ActionInput,
|
41
|
+
ActionStatus: () => ActionStatus,
|
39
42
|
ActionType: () => ActionType,
|
43
|
+
ActionTypes: () => ActionTypes,
|
40
44
|
ActionUpdate: () => ActionUpdate,
|
41
45
|
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
42
46
|
AddressFieldValue: () => AddressFieldValue,
|
47
|
+
AddressType: () => AddressType,
|
43
48
|
AdministrativeAreas: () => AdministrativeAreas,
|
44
49
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
45
50
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
46
51
|
ArchiveActionInput: () => ArchiveActionInput,
|
52
|
+
AssignActionInput: () => AssignActionInput,
|
53
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
47
54
|
BaseActionInput: () => BaseActionInput,
|
48
55
|
CertificateConfig: () => CertificateConfig,
|
49
56
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
@@ -51,15 +58,24 @@ __export(events_exports, {
|
|
51
58
|
Clause: () => Clause,
|
52
59
|
Conditional: () => Conditional,
|
53
60
|
ConditionalType: () => ConditionalType,
|
61
|
+
ConfirmableActions: () => ConfirmableActions,
|
62
|
+
DataEntry: () => DataEntry,
|
63
|
+
DataFieldValue: () => DataFieldValue,
|
54
64
|
DateValue: () => DateValue,
|
65
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
66
|
+
DeclarationActions: () => DeclarationActions,
|
67
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
68
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
69
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
55
70
|
DeclareActionInput: () => DeclareActionInput,
|
56
71
|
DeduplicationConfig: () => DeduplicationConfig,
|
72
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
57
73
|
Draft: () => Draft,
|
58
74
|
DraftInput: () => DraftInput,
|
59
75
|
EmailField: () => EmailField,
|
60
76
|
EmailValue: () => EmailValue,
|
61
77
|
EnableConditional: () => EnableConditional,
|
62
|
-
EventConfig: () =>
|
78
|
+
EventConfig: () => EventConfig2,
|
63
79
|
EventDocument: () => EventDocument,
|
64
80
|
EventIndex: () => EventIndex,
|
65
81
|
EventInput: () => EventInput,
|
@@ -67,7 +83,9 @@ __export(events_exports, {
|
|
67
83
|
EventSearchIndex: () => EventSearchIndex,
|
68
84
|
EventStatus: () => EventStatus,
|
69
85
|
EventStatuses: () => EventStatuses,
|
86
|
+
FieldConditional: () => FieldConditional,
|
70
87
|
FieldConfig: () => FieldConfig,
|
88
|
+
FieldConfigSchema: () => FieldConfigSchema,
|
71
89
|
FieldType: () => FieldType,
|
72
90
|
FieldUpdateValue: () => FieldUpdateValue,
|
73
91
|
FieldValue: () => FieldValue,
|
@@ -75,13 +93,23 @@ __export(events_exports, {
|
|
75
93
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
76
94
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
77
95
|
FormConfig: () => FormConfig,
|
78
|
-
|
96
|
+
FormPageConfig: () => FormPageConfig,
|
97
|
+
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
98
|
+
GenericAddressValue: () => GenericAddressValue,
|
79
99
|
GeographicalArea: () => GeographicalArea,
|
100
|
+
ImageMimeType: () => ImageMimeType,
|
80
101
|
LanguageConfig: () => LanguageConfig,
|
81
102
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
103
|
+
MimeType: () => MimeType,
|
82
104
|
NotifyActionInput: () => NotifyActionInput,
|
83
105
|
NumberFieldValue: () => NumberFieldValue,
|
106
|
+
PageConfig: () => PageConfig,
|
107
|
+
PageTypes: () => PageTypes,
|
84
108
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
109
|
+
QueryInput: () => QueryInput,
|
110
|
+
QueryType: () => QueryType,
|
111
|
+
ReadActionInput: () => ReadActionInput,
|
112
|
+
RegisterAction: () => RegisterAction,
|
85
113
|
RegisterActionInput: () => RegisterActionInput,
|
86
114
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
87
115
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -90,64 +118,78 @@ __export(events_exports, {
|
|
90
118
|
ResolvedUser: () => ResolvedUser,
|
91
119
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
92
120
|
RuralAddressValue: () => RuralAddressValue,
|
121
|
+
SelectOption: () => SelectOption,
|
93
122
|
ShowConditional: () => ShowConditional,
|
94
123
|
SummaryConfig: () => SummaryConfig,
|
95
124
|
TextValue: () => TextValue,
|
96
125
|
TranslationConfig: () => TranslationConfig,
|
126
|
+
UnassignActionInput: () => UnassignActionInput,
|
97
127
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
98
128
|
UrbanAddressValue: () => UrbanAddressValue,
|
99
129
|
ValidateActionInput: () => ValidateActionInput,
|
130
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
131
|
+
VerificationPageConfig: () => VerificationPageConfig,
|
100
132
|
WorkqueueConfig: () => WorkqueueConfig,
|
101
133
|
alwaysTrue: () => alwaysTrue,
|
102
134
|
and: () => and,
|
135
|
+
annotationActions: () => annotationActions,
|
103
136
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
104
137
|
compositeFieldTypes: () => compositeFieldTypes,
|
105
138
|
createEmptyDraft: () => createEmptyDraft,
|
106
139
|
createValidationSchema: () => createValidationSchema,
|
107
140
|
deepDropNulls: () => deepDropNulls,
|
141
|
+
deepMerge: () => deepMerge,
|
142
|
+
defineActionForm: () => defineActionForm,
|
108
143
|
defineConditional: () => defineConditional,
|
109
144
|
defineConfig: () => defineConfig,
|
110
|
-
|
145
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
146
|
+
defineFormConditional: () => defineFormConditional,
|
111
147
|
defineFormPage: () => defineFormPage,
|
148
|
+
definePage: () => definePage,
|
149
|
+
errorMessages: () => errorMessages,
|
112
150
|
event: () => event,
|
151
|
+
eventField: () => eventField,
|
113
152
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
114
153
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
115
154
|
eventQueryDataGenerator: () => eventQueryDataGenerator,
|
116
155
|
eventStatuses: () => eventStatuses,
|
117
156
|
field: () => field,
|
118
157
|
fieldTypes: () => fieldTypes,
|
119
|
-
findActiveActionFields: () => findActiveActionFields,
|
120
|
-
findActiveActionForm: () => findActiveActionForm,
|
121
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
122
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
123
158
|
findActiveDrafts: () => findActiveDrafts,
|
124
|
-
|
125
|
-
|
159
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
160
|
+
findRecordActionPages: () => findRecordActionPages,
|
161
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
162
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
126
163
|
generateActionDocument: () => generateActionDocument,
|
127
|
-
generateActionInput: () => generateActionInput,
|
128
164
|
generateEventDocument: () => generateEventDocument,
|
129
165
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
130
166
|
generateTransactionId: () => generateTransactionId,
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
167
|
+
generateTranslationConfig: () => generateTranslationConfig,
|
168
|
+
getAcceptedActions: () => getAcceptedActions,
|
169
|
+
getActionAnnotation: () => getActionAnnotation,
|
170
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
171
|
+
getActionReview: () => getActionReview,
|
172
|
+
getActionReviewFields: () => getActionReviewFields,
|
173
|
+
getAllAnnotationFields: () => getAllAnnotationFields,
|
174
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
135
175
|
getCurrentEventState: () => getCurrentEventState,
|
136
176
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
137
|
-
|
177
|
+
getDeclaration: () => getDeclaration,
|
178
|
+
getDeclarationFields: () => getDeclarationFields,
|
179
|
+
getDeclarationPages: () => getDeclarationPages,
|
138
180
|
getFieldValidationErrors: () => getFieldValidationErrors,
|
139
|
-
getFormFields: () => getFormFields,
|
140
|
-
getMetadataForAction: () => getMetadataForAction,
|
141
181
|
isAddressFieldType: () => isAddressFieldType,
|
142
182
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
143
183
|
isBulletListFieldType: () => isBulletListFieldType,
|
144
184
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
145
185
|
isCountryFieldType: () => isCountryFieldType,
|
186
|
+
isDataFieldType: () => isDataFieldType,
|
146
187
|
isDateFieldType: () => isDateFieldType,
|
147
188
|
isDividerFieldType: () => isDividerFieldType,
|
148
189
|
isEmailFieldType: () => isEmailFieldType,
|
149
190
|
isFacilityFieldType: () => isFacilityFieldType,
|
150
191
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
192
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
151
193
|
isFieldEnabled: () => isFieldEnabled,
|
152
194
|
isFieldValue: () => isFieldValue,
|
153
195
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -158,6 +200,7 @@ __export(events_exports, {
|
|
158
200
|
isNumberFieldType: () => isNumberFieldType,
|
159
201
|
isOfficeFieldType: () => isOfficeFieldType,
|
160
202
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
203
|
+
isPageVisible: () => isPageVisible,
|
161
204
|
isParagraphFieldType: () => isParagraphFieldType,
|
162
205
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
163
206
|
isSelectFieldType: () => isSelectFieldType,
|
@@ -166,49 +209,71 @@ __export(events_exports, {
|
|
166
209
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
167
210
|
isTextFieldType: () => isTextFieldType,
|
168
211
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
212
|
+
isVerificationPage: () => isVerificationPage,
|
213
|
+
isWriteAction: () => isWriteAction,
|
214
|
+
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
169
215
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
170
216
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
217
|
+
never: () => never,
|
171
218
|
not: () => not,
|
219
|
+
omitHiddenFields: () => omitHiddenFields,
|
220
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
172
221
|
or: () => or,
|
173
|
-
resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
|
174
|
-
stripHiddenFields: () => stripHiddenFields,
|
175
222
|
user: () => user,
|
176
223
|
validate: () => validate,
|
177
224
|
validateFieldInput: () => validateFieldInput,
|
178
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
225
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
226
|
+
writeActions: () => writeActions
|
179
227
|
});
|
180
228
|
module.exports = __toCommonJS(events_exports);
|
181
229
|
|
182
230
|
// ../commons/src/events/ActionConfig.ts
|
183
|
-
var
|
231
|
+
var import_zod9 = require("zod");
|
184
232
|
|
185
233
|
// ../commons/src/events/Conditional.ts
|
186
234
|
var import_zod = require("zod");
|
187
|
-
|
188
|
-
|
189
|
-
|
235
|
+
var Conditional = import_zod.z.custom(
|
236
|
+
(val) => typeof val === "object" && val !== null
|
237
|
+
);
|
190
238
|
var ConditionalType = {
|
191
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
192
239
|
SHOW: "SHOW",
|
193
|
-
|
194
|
-
|
240
|
+
ENABLE: "ENABLE",
|
241
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
195
242
|
};
|
196
243
|
var ShowConditional = import_zod.z.object({
|
197
244
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
198
|
-
conditional: Conditional
|
199
|
-
})
|
245
|
+
conditional: Conditional
|
246
|
+
}).describe(
|
247
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
248
|
+
);
|
200
249
|
var EnableConditional = import_zod.z.object({
|
201
250
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
202
|
-
conditional: Conditional
|
203
|
-
})
|
251
|
+
conditional: Conditional
|
252
|
+
}).describe(
|
253
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
254
|
+
);
|
204
255
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
205
256
|
// Action can be shown / hidden
|
206
257
|
ShowConditional,
|
207
258
|
// Action can be shown to the user in the list but as disabled
|
208
259
|
EnableConditional
|
209
260
|
]);
|
261
|
+
var DisplayOnReviewConditional = import_zod.z.object({
|
262
|
+
type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
263
|
+
conditional: Conditional
|
264
|
+
}).describe(
|
265
|
+
"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."
|
266
|
+
);
|
267
|
+
var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
268
|
+
// Field input can be shown / hidden
|
269
|
+
ShowConditional,
|
270
|
+
// Field input can be shown to the user but as disabled
|
271
|
+
EnableConditional,
|
272
|
+
// Field output can be shown / hidden on the review page
|
273
|
+
DisplayOnReviewConditional
|
274
|
+
]);
|
210
275
|
|
211
|
-
// ../commons/src/events/
|
276
|
+
// ../commons/src/events/PageConfig.ts
|
212
277
|
var import_zod6 = require("zod");
|
213
278
|
|
214
279
|
// ../commons/src/events/FieldConfig.ts
|
@@ -249,7 +314,8 @@ var FieldType = {
|
|
249
314
|
ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
|
250
315
|
FACILITY: "FACILITY",
|
251
316
|
OFFICE: "OFFICE",
|
252
|
-
SIGNATURE: "SIGNATURE"
|
317
|
+
SIGNATURE: "SIGNATURE",
|
318
|
+
DATA: "DATA"
|
253
319
|
};
|
254
320
|
var fieldTypes = Object.values(FieldType);
|
255
321
|
var compositeFieldTypes = [
|
@@ -267,6 +333,10 @@ var GeographicalArea = {
|
|
267
333
|
URBAN: "URBAN",
|
268
334
|
RURAL: "RURAL"
|
269
335
|
};
|
336
|
+
var AddressType = {
|
337
|
+
DOMESTIC: "DOMESTIC",
|
338
|
+
INTERNATIONAL: "INTERNATIONAL"
|
339
|
+
};
|
270
340
|
var FileFieldValue = import_zod3.z.object({
|
271
341
|
filename: import_zod3.z.string(),
|
272
342
|
originalFilename: import_zod3.z.string(),
|
@@ -274,6 +344,7 @@ var FileFieldValue = import_zod3.z.object({
|
|
274
344
|
});
|
275
345
|
var AdminStructure = import_zod3.z.object({
|
276
346
|
country: import_zod3.z.string(),
|
347
|
+
addressType: import_zod3.z.literal(AddressType.DOMESTIC),
|
277
348
|
province: import_zod3.z.string(),
|
278
349
|
district: import_zod3.z.string()
|
279
350
|
});
|
@@ -301,14 +372,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
|
|
301
372
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
302
373
|
village: import_zod3.z.string().nullish()
|
303
374
|
});
|
304
|
-
var
|
305
|
-
|
306
|
-
|
307
|
-
|
375
|
+
var GenericAddressValue = import_zod3.z.object({
|
376
|
+
country: import_zod3.z.string(),
|
377
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
378
|
+
state: import_zod3.z.string(),
|
379
|
+
district2: import_zod3.z.string(),
|
380
|
+
cityOrTown: import_zod3.z.string().optional(),
|
381
|
+
addressLine1: import_zod3.z.string().optional(),
|
382
|
+
addressLine2: import_zod3.z.string().optional(),
|
383
|
+
addressLine3: import_zod3.z.string().optional(),
|
384
|
+
postcodeOrZip: import_zod3.z.string().optional()
|
385
|
+
});
|
386
|
+
var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
|
387
|
+
var GenericAddressUpdateValue = import_zod3.z.object({
|
388
|
+
country: import_zod3.z.string(),
|
389
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
390
|
+
state: import_zod3.z.string(),
|
391
|
+
district2: import_zod3.z.string(),
|
392
|
+
cityOrTown: import_zod3.z.string().nullish(),
|
393
|
+
addressLine1: import_zod3.z.string().nullish(),
|
394
|
+
addressLine2: import_zod3.z.string().nullish(),
|
395
|
+
addressLine3: import_zod3.z.string().nullish(),
|
396
|
+
postcodeOrZip: import_zod3.z.string().nullish()
|
397
|
+
});
|
308
398
|
var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
|
309
399
|
UrbanAddressUpdateValue,
|
310
400
|
RuralAddressUpdateValue
|
311
|
-
]);
|
401
|
+
]).or(GenericAddressUpdateValue);
|
312
402
|
var FileFieldValueWithOption = import_zod3.z.object({
|
313
403
|
filename: import_zod3.z.string(),
|
314
404
|
originalFilename: import_zod3.z.string(),
|
@@ -324,6 +414,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
|
|
324
414
|
var EmailValue = import_zod4.z.string().email();
|
325
415
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
326
416
|
var NumberFieldValue = import_zod4.z.number();
|
417
|
+
var DataFieldValue = import_zod4.z.undefined();
|
327
418
|
var FieldValue = import_zod4.z.union([
|
328
419
|
TextValue,
|
329
420
|
DateValue,
|
@@ -332,7 +423,9 @@ var FieldValue = import_zod4.z.union([
|
|
332
423
|
FileFieldValue,
|
333
424
|
FileFieldWithOptionValue,
|
334
425
|
UrbanAddressValue,
|
335
|
-
RuralAddressValue
|
426
|
+
RuralAddressValue,
|
427
|
+
DataFieldValue,
|
428
|
+
GenericAddressValue
|
336
429
|
]);
|
337
430
|
var FieldUpdateValue = import_zod4.z.union([
|
338
431
|
TextValue,
|
@@ -342,7 +435,9 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
342
435
|
FileFieldValue,
|
343
436
|
FileFieldWithOptionValue,
|
344
437
|
UrbanAddressUpdateValue,
|
345
|
-
RuralAddressUpdateValue
|
438
|
+
RuralAddressUpdateValue,
|
439
|
+
DataFieldValue,
|
440
|
+
GenericAddressUpdateValue
|
346
441
|
]);
|
347
442
|
|
348
443
|
// ../commons/src/events/FieldConfig.ts
|
@@ -364,14 +459,14 @@ var BaseField = import_zod5.z.object({
|
|
364
459
|
]),
|
365
460
|
DependencyExpression
|
366
461
|
]).optional(),
|
367
|
-
conditionals: import_zod5.z.array(
|
462
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
368
463
|
required: import_zod5.z.boolean().default(false).optional(),
|
369
464
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
370
465
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
371
466
|
placeholder: TranslationConfig.optional(),
|
372
467
|
validation: import_zod5.z.array(
|
373
468
|
import_zod5.z.object({
|
374
|
-
validator: Conditional
|
469
|
+
validator: Conditional,
|
375
470
|
message: TranslationConfig
|
376
471
|
})
|
377
472
|
).default([]).optional(),
|
@@ -413,15 +508,25 @@ var TextAreaField = BaseField.extend({
|
|
413
508
|
postfix: TranslationConfig.optional()
|
414
509
|
}).default({ rows: 4 }).optional()
|
415
510
|
}).describe("Multiline text input");
|
511
|
+
var ImageMimeType = import_zod5.z.enum([
|
512
|
+
"image/png",
|
513
|
+
"image/jpg",
|
514
|
+
"image/jpeg",
|
515
|
+
"image/svg+xml"
|
516
|
+
]);
|
517
|
+
var MimeType = ImageMimeType;
|
518
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
416
519
|
var SignatureField = BaseField.extend({
|
417
520
|
type: import_zod5.z.literal(FieldType.SIGNATURE),
|
418
521
|
signaturePromptLabel: TranslationConfig.describe(
|
419
522
|
"Title of the signature modal"
|
420
523
|
),
|
421
524
|
configuration: import_zod5.z.object({
|
422
|
-
|
423
|
-
|
424
|
-
}).default({
|
525
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
526
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
527
|
+
}).default({
|
528
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
529
|
+
})
|
425
530
|
}).describe("Signature input field");
|
426
531
|
var EmailField = BaseField.extend({
|
427
532
|
type: import_zod5.z.literal(FieldType.EMAIL),
|
@@ -464,13 +569,17 @@ var PageHeader = BaseField.extend({
|
|
464
569
|
}).describe("A read-only header component for form pages");
|
465
570
|
var File = BaseField.extend({
|
466
571
|
type: import_zod5.z.literal(FieldType.FILE),
|
467
|
-
|
572
|
+
configuration: import_zod5.z.object({
|
573
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
574
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
468
575
|
style: import_zod5.z.object({
|
469
|
-
|
576
|
+
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
470
577
|
"Whether the file upload button should take the full width of the container or not"
|
471
578
|
)
|
472
|
-
})
|
473
|
-
}).
|
579
|
+
}).optional()
|
580
|
+
}).default({
|
581
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
582
|
+
})
|
474
583
|
}).describe("File upload");
|
475
584
|
var SelectOption = import_zod5.z.object({
|
476
585
|
value: import_zod5.z.string().describe("The value of the option"),
|
@@ -516,7 +625,7 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
516
625
|
]);
|
517
626
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
518
627
|
partOf: import_zod5.z.object({
|
519
|
-
$
|
628
|
+
$declaration: import_zod5.z.string()
|
520
629
|
}).optional().describe("Parent location"),
|
521
630
|
type: AdministrativeAreas
|
522
631
|
}).describe("Administrative area options");
|
@@ -531,8 +640,14 @@ var Location = BaseField.extend({
|
|
531
640
|
}).describe("Input field for a location");
|
532
641
|
var FileUploadWithOptions = BaseField.extend({
|
533
642
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
534
|
-
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
535
|
-
|
643
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
644
|
+
configuration: import_zod5.z.object({
|
645
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
646
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
647
|
+
}).default({
|
648
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
649
|
+
})
|
650
|
+
});
|
536
651
|
var Facility = BaseField.extend({
|
537
652
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
538
653
|
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
@@ -545,6 +660,22 @@ var Address = BaseField.extend({
|
|
545
660
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
546
661
|
defaultValue: AddressFieldValue.optional()
|
547
662
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
663
|
+
var DataEntry = import_zod5.z.union([
|
664
|
+
import_zod5.z.object({
|
665
|
+
label: TranslationConfig,
|
666
|
+
value: import_zod5.z.string()
|
667
|
+
}),
|
668
|
+
import_zod5.z.object({
|
669
|
+
fieldId: import_zod5.z.string()
|
670
|
+
})
|
671
|
+
]);
|
672
|
+
var DataField = BaseField.extend({
|
673
|
+
type: import_zod5.z.literal(FieldType.DATA),
|
674
|
+
configuration: import_zod5.z.object({
|
675
|
+
subtitle: TranslationConfig.optional(),
|
676
|
+
data: import_zod5.z.array(DataEntry)
|
677
|
+
})
|
678
|
+
}).describe("Data field for displaying read-only data");
|
548
679
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
549
680
|
Address,
|
550
681
|
TextField,
|
@@ -566,132 +697,210 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
566
697
|
Office,
|
567
698
|
SignatureField,
|
568
699
|
EmailField,
|
569
|
-
FileUploadWithOptions
|
700
|
+
FileUploadWithOptions,
|
701
|
+
DataField
|
702
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
570
703
|
]);
|
571
704
|
|
572
|
-
// ../commons/src/events/
|
573
|
-
var
|
705
|
+
// ../commons/src/events/PageConfig.ts
|
706
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
707
|
+
var PageConfigBase = import_zod6.z.object({
|
574
708
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
575
709
|
title: TranslationConfig.describe("Header title of the page"),
|
576
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
710
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
711
|
+
conditional: Conditional.optional().describe(
|
712
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
713
|
+
)
|
577
714
|
});
|
578
|
-
var
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
label: TranslationConfig
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
pages: import_zod6.z.array(FormPage),
|
590
|
-
review: import_zod6.z.object({
|
591
|
-
title: TranslationConfig.describe(
|
592
|
-
"Title of the form to show in review page"
|
593
|
-
),
|
594
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
715
|
+
var FormPageConfig = PageConfigBase.extend({
|
716
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
717
|
+
});
|
718
|
+
var VerificationActionConfig = import_zod6.z.object({
|
719
|
+
verify: import_zod6.z.object({ label: TranslationConfig }),
|
720
|
+
cancel: import_zod6.z.object({
|
721
|
+
label: TranslationConfig,
|
722
|
+
confirmation: import_zod6.z.object({
|
723
|
+
title: TranslationConfig,
|
724
|
+
body: TranslationConfig
|
725
|
+
})
|
595
726
|
})
|
727
|
+
}).describe("Actions available on the verification page");
|
728
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
729
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
730
|
+
actions: VerificationActionConfig
|
596
731
|
});
|
732
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
733
|
+
FormPageConfig,
|
734
|
+
VerificationPageConfig
|
735
|
+
]);
|
597
736
|
|
598
737
|
// ../commons/src/events/ActionType.ts
|
738
|
+
var import_zod7 = require("zod");
|
599
739
|
var ActionType = {
|
740
|
+
// Pre-declaration actions
|
741
|
+
DELETE: "DELETE",
|
600
742
|
CREATE: "CREATE",
|
601
|
-
ASSIGN: "ASSIGN",
|
602
|
-
UNASSIGN: "UNASSIGN",
|
603
|
-
REGISTER: "REGISTER",
|
604
|
-
VALIDATE: "VALIDATE",
|
605
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
606
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
607
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
608
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
609
743
|
NOTIFY: "NOTIFY",
|
744
|
+
// Declaration actions
|
610
745
|
DECLARE: "DECLARE",
|
611
|
-
|
612
|
-
|
613
|
-
|
746
|
+
VALIDATE: "VALIDATE",
|
747
|
+
REGISTER: "REGISTER",
|
748
|
+
// Declaration system actions. Non-configurable.
|
749
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
614
750
|
REJECT: "REJECT",
|
751
|
+
// REJECT_DECLARATION
|
615
752
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
616
|
-
|
753
|
+
// MARK_AS_DUPLICATE
|
754
|
+
ARCHIVE: "ARCHIVE",
|
755
|
+
// Record actions
|
756
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
757
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
758
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
759
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
760
|
+
// General actions
|
761
|
+
READ: "READ",
|
762
|
+
ASSIGN: "ASSIGN",
|
763
|
+
UNASSIGN: "UNASSIGN"
|
617
764
|
};
|
765
|
+
var ConfirmableActions = [
|
766
|
+
ActionType.NOTIFY,
|
767
|
+
ActionType.DECLARE,
|
768
|
+
ActionType.VALIDATE,
|
769
|
+
ActionType.REGISTER,
|
770
|
+
ActionType.REJECT,
|
771
|
+
ActionType.ARCHIVE,
|
772
|
+
ActionType.PRINT_CERTIFICATE
|
773
|
+
];
|
774
|
+
var ActionTypes = import_zod7.z.enum([
|
775
|
+
"DELETE",
|
776
|
+
"CREATE",
|
777
|
+
"NOTIFY",
|
778
|
+
"DECLARE",
|
779
|
+
"VALIDATE",
|
780
|
+
"REGISTER",
|
781
|
+
"DETECT_DUPLICATE",
|
782
|
+
"REJECT",
|
783
|
+
"MARKED_AS_DUPLICATE",
|
784
|
+
"ARCHIVE",
|
785
|
+
"PRINT_CERTIFICATE",
|
786
|
+
"REQUEST_CORRECTION",
|
787
|
+
"REJECT_CORRECTION",
|
788
|
+
"APPROVE_CORRECTION",
|
789
|
+
"READ",
|
790
|
+
"ASSIGN",
|
791
|
+
"UNASSIGN"
|
792
|
+
]);
|
793
|
+
var declarationActionValues = [
|
794
|
+
ActionTypes.enum.DECLARE,
|
795
|
+
ActionTypes.enum.VALIDATE,
|
796
|
+
ActionTypes.enum.REGISTER
|
797
|
+
];
|
798
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
799
|
+
var declarationUpdateActionValues = [
|
800
|
+
...declarationActionValues,
|
801
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
802
|
+
];
|
803
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
804
|
+
declarationUpdateActionValues
|
805
|
+
);
|
806
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
807
|
+
var writeActions = ActionTypes.exclude([
|
808
|
+
ActionType.CREATE,
|
809
|
+
ActionType.READ,
|
810
|
+
ActionType.ASSIGN,
|
811
|
+
ActionType.UNASSIGN
|
812
|
+
]);
|
813
|
+
|
814
|
+
// ../commons/src/events/FormConfig.ts
|
815
|
+
var import_zod8 = require("zod");
|
816
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
817
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
818
|
+
pages: import_zod8.z.array(FormPageConfig)
|
819
|
+
}).describe("Configuration for a declaration form");
|
820
|
+
var ActionFormConfig = import_zod8.z.object({
|
821
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
822
|
+
pages: import_zod8.z.array(PageConfig)
|
823
|
+
});
|
824
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
618
825
|
|
619
826
|
// ../commons/src/events/ActionConfig.ts
|
620
|
-
var ActionConditional2 =
|
827
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
621
828
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
622
829
|
ShowConditional,
|
623
830
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
624
831
|
EnableConditional
|
625
832
|
]);
|
626
|
-
var
|
833
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
834
|
+
title: TranslationConfig.describe("Title of the review page"),
|
835
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
836
|
+
}).describe("Configuration for **declaration** review page.");
|
837
|
+
var ActionConfigBase = import_zod9.z.object({
|
627
838
|
label: TranslationConfig,
|
628
|
-
conditionals:
|
629
|
-
draft:
|
630
|
-
forms: import_zod7.z.array(FormConfig)
|
839
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
840
|
+
draft: import_zod9.z.boolean().optional()
|
631
841
|
});
|
632
842
|
var DeclareConfig = ActionConfigBase.merge(
|
633
|
-
|
634
|
-
type:
|
843
|
+
import_zod9.z.object({
|
844
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
845
|
+
review: DeclarationReviewConfig
|
635
846
|
})
|
636
847
|
);
|
637
848
|
var ValidateConfig = ActionConfigBase.merge(
|
638
|
-
|
639
|
-
type:
|
849
|
+
import_zod9.z.object({
|
850
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
851
|
+
review: DeclarationReviewConfig
|
852
|
+
})
|
853
|
+
);
|
854
|
+
var RegisterConfig = ActionConfigBase.merge(
|
855
|
+
import_zod9.z.object({
|
856
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
857
|
+
review: DeclarationReviewConfig
|
640
858
|
})
|
641
859
|
);
|
642
860
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
643
|
-
|
644
|
-
type:
|
861
|
+
import_zod9.z.object({
|
862
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
645
863
|
})
|
646
864
|
);
|
647
865
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
648
|
-
|
649
|
-
type:
|
866
|
+
import_zod9.z.object({
|
867
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
650
868
|
})
|
651
869
|
);
|
652
870
|
var ArchiveConfig = ActionConfigBase.merge(
|
653
|
-
|
654
|
-
type:
|
655
|
-
})
|
656
|
-
);
|
657
|
-
var RegisterConfig = ActionConfigBase.merge(
|
658
|
-
import_zod7.z.object({
|
659
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
871
|
+
import_zod9.z.object({
|
872
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
660
873
|
})
|
661
874
|
);
|
662
875
|
var DeleteConfig = ActionConfigBase.merge(
|
663
|
-
|
664
|
-
type:
|
876
|
+
import_zod9.z.object({
|
877
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
665
878
|
})
|
666
879
|
);
|
667
880
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
668
|
-
|
669
|
-
type:
|
881
|
+
import_zod9.z.object({
|
882
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
883
|
+
printForm: ActionFormConfig
|
670
884
|
})
|
671
885
|
);
|
672
886
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
673
|
-
|
674
|
-
type:
|
675
|
-
onboardingForm:
|
676
|
-
additionalDetailsForm:
|
887
|
+
import_zod9.z.object({
|
888
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
889
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
890
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
677
891
|
})
|
678
892
|
);
|
679
893
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
680
|
-
|
681
|
-
type:
|
894
|
+
import_zod9.z.object({
|
895
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
682
896
|
})
|
683
897
|
);
|
684
898
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
685
|
-
|
686
|
-
type:
|
687
|
-
})
|
688
|
-
);
|
689
|
-
var CustomConfig = ActionConfigBase.merge(
|
690
|
-
import_zod7.z.object({
|
691
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
899
|
+
import_zod9.z.object({
|
900
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
692
901
|
})
|
693
902
|
);
|
694
|
-
var ActionConfig =
|
903
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
695
904
|
DeclareConfig,
|
696
905
|
ValidateConfig,
|
697
906
|
RejectDeclarationConfig,
|
@@ -702,102 +911,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
702
911
|
PrintCertificateActionConfig,
|
703
912
|
RequestCorrectionConfig,
|
704
913
|
RejectCorrectionConfig,
|
705
|
-
ApproveCorrectionConfig
|
706
|
-
|
914
|
+
ApproveCorrectionConfig
|
915
|
+
]);
|
916
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
917
|
+
DeclareConfig,
|
918
|
+
ValidateConfig,
|
919
|
+
RegisterConfig
|
707
920
|
]);
|
708
921
|
|
709
922
|
// ../commons/src/events/offline/CertificateConfig.ts
|
710
|
-
var
|
711
|
-
var FontFamily =
|
712
|
-
normal:
|
713
|
-
bold:
|
714
|
-
italics:
|
715
|
-
bolditalics:
|
923
|
+
var import_zod10 = require("zod");
|
924
|
+
var FontFamily = import_zod10.z.object({
|
925
|
+
normal: import_zod10.z.string(),
|
926
|
+
bold: import_zod10.z.string(),
|
927
|
+
italics: import_zod10.z.string(),
|
928
|
+
bolditalics: import_zod10.z.string()
|
716
929
|
});
|
717
|
-
var CertificateConfig =
|
718
|
-
id:
|
719
|
-
event:
|
930
|
+
var CertificateConfig = import_zod10.z.object({
|
931
|
+
id: import_zod10.z.string(),
|
932
|
+
event: import_zod10.z.string(),
|
720
933
|
label: TranslationConfig,
|
721
|
-
isDefault:
|
722
|
-
fee:
|
723
|
-
onTime:
|
724
|
-
late:
|
725
|
-
delayed:
|
934
|
+
isDefault: import_zod10.z.boolean(),
|
935
|
+
fee: import_zod10.z.object({
|
936
|
+
onTime: import_zod10.z.number(),
|
937
|
+
late: import_zod10.z.number(),
|
938
|
+
delayed: import_zod10.z.number()
|
726
939
|
}),
|
727
|
-
svgUrl:
|
728
|
-
fonts:
|
940
|
+
svgUrl: import_zod10.z.string(),
|
941
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
729
942
|
});
|
730
943
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
731
|
-
hash:
|
732
|
-
svg:
|
944
|
+
hash: import_zod10.z.string().optional(),
|
945
|
+
svg: import_zod10.z.string()
|
733
946
|
});
|
734
947
|
|
735
948
|
// ../commons/src/events/offline/LanguageConfig.ts
|
736
|
-
var
|
737
|
-
var LanguageConfig =
|
738
|
-
lang:
|
949
|
+
var import_zod11 = require("zod");
|
950
|
+
var LanguageConfig = import_zod11.z.object({
|
951
|
+
lang: import_zod11.z.string(),
|
739
952
|
/**
|
740
953
|
* client.csv contents
|
741
954
|
*/
|
742
|
-
messages:
|
955
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
743
956
|
});
|
744
957
|
|
745
958
|
// ../commons/src/events/EventConfig.ts
|
746
|
-
var
|
959
|
+
var import_zod17 = require("zod");
|
747
960
|
|
748
961
|
// ../commons/src/events/DeduplicationConfig.ts
|
749
|
-
var
|
750
|
-
var FieldReference =
|
751
|
-
var Matcher =
|
752
|
-
fieldId:
|
753
|
-
options:
|
754
|
-
boost:
|
962
|
+
var import_zod12 = require("zod");
|
963
|
+
var FieldReference = import_zod12.z.string();
|
964
|
+
var Matcher = import_zod12.z.object({
|
965
|
+
fieldId: import_zod12.z.string(),
|
966
|
+
options: import_zod12.z.object({
|
967
|
+
boost: import_zod12.z.number().optional()
|
755
968
|
}).optional().default({})
|
756
969
|
});
|
757
970
|
var FuzzyMatcher = Matcher.extend({
|
758
|
-
type:
|
759
|
-
options:
|
971
|
+
type: import_zod12.z.literal("fuzzy"),
|
972
|
+
options: import_zod12.z.object({
|
760
973
|
/**
|
761
974
|
* Names of length 3 or less characters = 0 edits allowed
|
762
975
|
* Names of length 4 - 6 characters = 1 edit allowed
|
763
976
|
* Names of length >7 characters = 2 edits allowed
|
764
977
|
*/
|
765
|
-
fuzziness:
|
766
|
-
boost:
|
978
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
979
|
+
boost: import_zod12.z.number().optional().default(1)
|
767
980
|
}).optional().default({})
|
768
981
|
});
|
769
982
|
var StrictMatcher = Matcher.extend({
|
770
|
-
type:
|
771
|
-
options:
|
772
|
-
boost:
|
983
|
+
type: import_zod12.z.literal("strict"),
|
984
|
+
options: import_zod12.z.object({
|
985
|
+
boost: import_zod12.z.number().optional().default(1)
|
773
986
|
}).optional().default({})
|
774
987
|
});
|
775
988
|
var DateRangeMatcher = Matcher.extend({
|
776
|
-
type:
|
777
|
-
options:
|
778
|
-
days:
|
989
|
+
type: import_zod12.z.literal("dateRange"),
|
990
|
+
options: import_zod12.z.object({
|
991
|
+
days: import_zod12.z.number(),
|
779
992
|
origin: FieldReference,
|
780
|
-
boost:
|
993
|
+
boost: import_zod12.z.number().optional().default(1)
|
781
994
|
})
|
782
995
|
});
|
783
996
|
var DateDistanceMatcher = Matcher.extend({
|
784
|
-
type:
|
785
|
-
options:
|
786
|
-
days:
|
997
|
+
type: import_zod12.z.literal("dateDistance"),
|
998
|
+
options: import_zod12.z.object({
|
999
|
+
days: import_zod12.z.number(),
|
787
1000
|
origin: FieldReference,
|
788
|
-
boost:
|
1001
|
+
boost: import_zod12.z.number().optional().default(1)
|
789
1002
|
})
|
790
1003
|
});
|
791
|
-
var And =
|
792
|
-
type:
|
793
|
-
|
1004
|
+
var And = import_zod12.z.object({
|
1005
|
+
type: import_zod12.z.literal("and"),
|
1006
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1007
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
794
1008
|
});
|
795
|
-
var Or =
|
796
|
-
type:
|
797
|
-
|
1009
|
+
var Or = import_zod12.z.object({
|
1010
|
+
type: import_zod12.z.literal("or"),
|
1011
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1012
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
798
1013
|
});
|
799
|
-
var Clause =
|
800
|
-
() =>
|
1014
|
+
var Clause = import_zod12.z.lazy(
|
1015
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
801
1016
|
And,
|
802
1017
|
Or,
|
803
1018
|
FuzzyMatcher,
|
@@ -806,37 +1021,37 @@ var Clause = import_zod10.z.lazy(
|
|
806
1021
|
DateDistanceMatcher
|
807
1022
|
])
|
808
1023
|
);
|
809
|
-
var DeduplicationConfig =
|
810
|
-
id:
|
1024
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1025
|
+
id: import_zod12.z.string(),
|
811
1026
|
label: TranslationConfig,
|
812
1027
|
query: Clause
|
813
1028
|
});
|
814
1029
|
|
815
1030
|
// ../commons/src/events/SummaryConfig.ts
|
816
|
-
var
|
817
|
-
var Field =
|
818
|
-
id:
|
1031
|
+
var import_zod13 = require("zod");
|
1032
|
+
var Field = import_zod13.z.object({
|
1033
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
819
1034
|
value: TranslationConfig.describe(
|
820
1035
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
821
1036
|
),
|
822
1037
|
label: TranslationConfig,
|
823
1038
|
emptyValueMessage: TranslationConfig.optional()
|
824
1039
|
});
|
825
|
-
var Title =
|
826
|
-
id:
|
1040
|
+
var Title = import_zod13.z.object({
|
1041
|
+
id: import_zod13.z.string(),
|
827
1042
|
label: TranslationConfig.describe("Title content"),
|
828
1043
|
emptyValueMessage: TranslationConfig.optional()
|
829
1044
|
});
|
830
|
-
var SummaryConfig =
|
1045
|
+
var SummaryConfig = import_zod13.z.object({
|
831
1046
|
title: Title.describe("Title of summary view."),
|
832
|
-
fields:
|
1047
|
+
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
833
1048
|
}).describe("Configuration for summary in event.");
|
834
1049
|
|
835
1050
|
// ../commons/src/events/WorkqueueConfig.ts
|
836
|
-
var
|
1051
|
+
var import_zod15 = require("zod");
|
837
1052
|
|
838
1053
|
// ../commons/src/events/EventMetadata.ts
|
839
|
-
var
|
1054
|
+
var import_zod14 = require("zod");
|
840
1055
|
var EventStatus = {
|
841
1056
|
CREATED: "CREATED",
|
842
1057
|
NOTIFIED: "NOTIFIED",
|
@@ -848,18 +1063,20 @@ var EventStatus = {
|
|
848
1063
|
ARCHIVED: "ARCHIVED"
|
849
1064
|
};
|
850
1065
|
var eventStatuses = Object.values(EventStatus);
|
851
|
-
var EventStatuses =
|
852
|
-
var EventMetadata =
|
853
|
-
id:
|
854
|
-
type:
|
1066
|
+
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1067
|
+
var EventMetadata = import_zod14.z.object({
|
1068
|
+
id: import_zod14.z.string(),
|
1069
|
+
type: import_zod14.z.string(),
|
855
1070
|
status: EventStatuses,
|
856
|
-
createdAt:
|
857
|
-
createdBy:
|
858
|
-
createdAtLocation:
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
1071
|
+
createdAt: import_zod14.z.string().datetime(),
|
1072
|
+
createdBy: import_zod14.z.string(),
|
1073
|
+
createdAtLocation: import_zod14.z.string(),
|
1074
|
+
updatedAtLocation: import_zod14.z.string(),
|
1075
|
+
updatedAt: import_zod14.z.string().datetime(),
|
1076
|
+
assignedTo: import_zod14.z.string().nullish(),
|
1077
|
+
updatedBy: import_zod14.z.string(),
|
1078
|
+
trackingId: import_zod14.z.string(),
|
1079
|
+
registrationNumber: import_zod14.z.string().nullish()
|
863
1080
|
});
|
864
1081
|
var eventMetadataLabelMap = {
|
865
1082
|
"event.assignedTo": {
|
@@ -877,6 +1094,11 @@ var eventMetadataLabelMap = {
|
|
877
1094
|
defaultMessage: "Location",
|
878
1095
|
description: "Created At Location"
|
879
1096
|
},
|
1097
|
+
"event.updatedAtLocation": {
|
1098
|
+
id: "event.updatedAtLocation.label",
|
1099
|
+
defaultMessage: "Location",
|
1100
|
+
description: "Updated At"
|
1101
|
+
},
|
880
1102
|
"event.createdBy": {
|
881
1103
|
id: "event.createdBy.label",
|
882
1104
|
defaultMessage: "Created By",
|
@@ -887,7 +1109,7 @@ var eventMetadataLabelMap = {
|
|
887
1109
|
defaultMessage: "ID",
|
888
1110
|
description: "ID"
|
889
1111
|
},
|
890
|
-
"event.
|
1112
|
+
"event.updatedAt": {
|
891
1113
|
id: "event.modifiedAt.label",
|
892
1114
|
defaultMessage: "Updated",
|
893
1115
|
description: "Modified At"
|
@@ -911,148 +1133,561 @@ var eventMetadataLabelMap = {
|
|
911
1133
|
id: "event.trackingId.label",
|
912
1134
|
defaultMessage: "Tracking ID",
|
913
1135
|
description: "Tracking ID"
|
1136
|
+
},
|
1137
|
+
"event.registrationNumber": {
|
1138
|
+
id: "event.registrationNumber.label",
|
1139
|
+
defaultMessage: "Registration Number",
|
1140
|
+
description: "Registration Number"
|
914
1141
|
}
|
915
1142
|
};
|
916
1143
|
|
917
1144
|
// ../commons/src/events/WorkqueueConfig.ts
|
918
|
-
var WorkqueueConfig =
|
919
|
-
id:
|
920
|
-
filters:
|
921
|
-
|
922
|
-
status:
|
1145
|
+
var WorkqueueConfig = import_zod15.z.object({
|
1146
|
+
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1147
|
+
filters: import_zod15.z.array(
|
1148
|
+
import_zod15.z.object({
|
1149
|
+
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
923
1150
|
})
|
924
1151
|
).describe("Filters to be applied to workqueue.")
|
925
1152
|
}).describe("Configuration for workqueue.");
|
926
1153
|
|
927
1154
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
928
|
-
var
|
929
|
-
var
|
1155
|
+
var import_zod16 = require("zod");
|
1156
|
+
var FieldType2 = import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]);
|
1157
|
+
var FieldConfigSchema = import_zod16.z.object({
|
1158
|
+
fieldId: import_zod16.z.string(),
|
1159
|
+
config: import_zod16.z.object({
|
1160
|
+
type: FieldType2.describe("Determines the type of field")
|
1161
|
+
}),
|
1162
|
+
options: import_zod16.z.array(SelectOption).optional()
|
1163
|
+
});
|
1164
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
930
1165
|
title: TranslationConfig.describe("Advanced search tab title"),
|
931
|
-
fields:
|
932
|
-
import_zod14.z.object({
|
933
|
-
fieldId: import_zod14.z.string(),
|
934
|
-
config: import_zod14.z.object({
|
935
|
-
type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
936
|
-
}).optional().describe("Configuration options for the field")
|
937
|
-
})
|
938
|
-
).optional().default([]).describe("Advanced search fields.")
|
1166
|
+
fields: import_zod16.z.array(FieldConfigSchema).optional().default([]).describe("Advanced search fields.")
|
939
1167
|
});
|
940
1168
|
|
941
|
-
// ../commons/src/
|
1169
|
+
// ../commons/src/utils.ts
|
942
1170
|
var import_lodash = require("lodash");
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
// ../commons/src/workqueues/defaultColumns.ts
|
948
|
-
var import_zod15 = require("zod");
|
949
|
-
var WorkQueueColumnConfig = import_zod15.z.object({
|
950
|
-
id: import_zod15.z.string(),
|
951
|
-
label: TranslationConfig
|
952
|
-
});
|
953
|
-
var defaultColumns = {
|
954
|
-
event: {
|
955
|
-
id: "event",
|
956
|
-
label: {
|
957
|
-
defaultMessage: "Event",
|
958
|
-
description: "This is the label for the workqueue column",
|
959
|
-
id: "workqueue.default.column.event"
|
960
|
-
}
|
961
|
-
},
|
962
|
-
status: {
|
963
|
-
id: "status",
|
964
|
-
label: {
|
965
|
-
defaultMessage: "Status",
|
966
|
-
description: "This is the label for the workqueue column",
|
967
|
-
id: "workqueue.default.column.status"
|
968
|
-
}
|
969
|
-
},
|
970
|
-
createdAt: {
|
971
|
-
id: "createdAt",
|
972
|
-
label: {
|
973
|
-
defaultMessage: "Created",
|
974
|
-
description: "This is the label for the workqueue column",
|
975
|
-
id: "workqueue.default.column.createdAt"
|
976
|
-
}
|
977
|
-
},
|
978
|
-
modifiedAt: {
|
979
|
-
id: "modifiedAt",
|
980
|
-
label: {
|
981
|
-
defaultMessage: "Modified",
|
982
|
-
description: "This is the label for the workqueue column",
|
983
|
-
id: "workqueue.default.column.modifiedAt"
|
984
|
-
}
|
1171
|
+
function getOrThrow(x, message) {
|
1172
|
+
if (x === void 0 || x === null) {
|
1173
|
+
throw new Error(message);
|
985
1174
|
}
|
1175
|
+
return x;
|
1176
|
+
}
|
1177
|
+
var findAllFields = (config) => {
|
1178
|
+
return (0, import_lodash.flattenDeep)([
|
1179
|
+
...getDeclarationFields(config),
|
1180
|
+
...getAllAnnotationFields(config)
|
1181
|
+
]);
|
986
1182
|
};
|
987
|
-
var
|
988
|
-
Object.keys(defaultColumns)
|
989
|
-
);
|
1183
|
+
var metadataFields = ["trackingId", "status"];
|
990
1184
|
|
991
|
-
// ../commons/src/
|
992
|
-
var
|
993
|
-
id:
|
994
|
-
|
995
|
-
|
996
|
-
|
1185
|
+
// ../commons/src/events/EventConfig.ts
|
1186
|
+
var EventConfig2 = import_zod17.z.object({
|
1187
|
+
id: import_zod17.z.string().describe(
|
1188
|
+
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1189
|
+
),
|
1190
|
+
summary: SummaryConfig,
|
1191
|
+
label: TranslationConfig,
|
1192
|
+
actions: import_zod17.z.array(ActionConfig),
|
1193
|
+
declaration: DeclarationFormConfig,
|
1194
|
+
workqueues: import_zod17.z.array(WorkqueueConfig),
|
1195
|
+
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1196
|
+
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1197
|
+
}).superRefine((event2, ctx) => {
|
1198
|
+
const allFields = findAllFields(event2);
|
1199
|
+
const fieldIds = allFields.map((field2) => field2.id);
|
1200
|
+
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1201
|
+
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
1202
|
+
);
|
1203
|
+
const advancedSearchFieldsSet = new Set(advancedSearchFields);
|
1204
|
+
if (advancedSearchFieldsSet.size !== advancedSearchFields.length) {
|
1205
|
+
ctx.addIssue({
|
1206
|
+
code: "custom",
|
1207
|
+
message: "Advanced search field ids must be unique",
|
1208
|
+
path: ["advancedSearch"]
|
1209
|
+
});
|
1210
|
+
}
|
1211
|
+
const invalidFields = event2.advancedSearch.flatMap(
|
1212
|
+
(section) => (
|
1213
|
+
// Check if the fieldId is not in the fieldIds array
|
1214
|
+
// and also not in the metadataFields array
|
1215
|
+
section.fields.filter(
|
1216
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || Boolean(metadataFields.find((f) => f === field2.fieldId)))
|
1217
|
+
)
|
1218
|
+
)
|
1219
|
+
);
|
1220
|
+
if (invalidFields.length > 0) {
|
1221
|
+
ctx.addIssue({
|
1222
|
+
code: "custom",
|
1223
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1224
|
+
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1225
|
+
path: ["advancedSearch"]
|
1226
|
+
});
|
1227
|
+
}
|
997
1228
|
});
|
998
|
-
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
999
1229
|
|
1000
|
-
// ../commons/src/
|
1001
|
-
var
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
description: "This is the label for the workqueue",
|
1006
|
-
id: "workqueue.all.label"
|
1007
|
-
},
|
1008
|
-
columns: [
|
1009
|
-
{
|
1010
|
-
id: "title",
|
1011
|
-
label: {
|
1012
|
-
defaultMessage: "Title",
|
1013
|
-
description: "This is the label for the workqueue column",
|
1014
|
-
id: "workqueue.all.column.title"
|
1015
|
-
}
|
1016
|
-
}
|
1017
|
-
],
|
1018
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1019
|
-
});
|
1230
|
+
// ../commons/src/events/EventConfigInput.ts
|
1231
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1232
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1233
|
+
var definePage = (page) => PageConfig.parse(page);
|
1234
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1020
1235
|
|
1021
|
-
// ../commons/src/
|
1022
|
-
var
|
1023
|
-
id: "ready-for-review",
|
1024
|
-
title: {
|
1025
|
-
defaultMessage: "Ready for review",
|
1026
|
-
description: "Label for in review workqueue",
|
1027
|
-
id: "event.workqueue.in-review.label"
|
1028
|
-
},
|
1029
|
-
columns: [
|
1030
|
-
{
|
1031
|
-
id: "title",
|
1032
|
-
label: {
|
1033
|
-
defaultMessage: "Title",
|
1034
|
-
description: "This is the label for the workqueue column",
|
1035
|
-
id: "workqueue.in-reveiw.column.title"
|
1036
|
-
}
|
1037
|
-
}
|
1038
|
-
],
|
1039
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1040
|
-
});
|
1236
|
+
// ../commons/src/events/Draft.ts
|
1237
|
+
var import_zod20 = require("zod");
|
1041
1238
|
|
1042
|
-
// ../commons/src/
|
1043
|
-
var
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1239
|
+
// ../commons/src/events/ActionDocument.ts
|
1240
|
+
var import_zod18 = require("zod");
|
1241
|
+
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1242
|
+
var ActionStatus = {
|
1243
|
+
Requested: "Requested",
|
1244
|
+
Accepted: "Accepted",
|
1245
|
+
Rejected: "Rejected"
|
1246
|
+
};
|
1247
|
+
var ActionBase = import_zod18.z.object({
|
1248
|
+
id: import_zod18.z.string(),
|
1249
|
+
createdAt: import_zod18.z.string().datetime(),
|
1250
|
+
createdBy: import_zod18.z.string(),
|
1251
|
+
declaration: ActionUpdate,
|
1252
|
+
annotation: ActionUpdate.optional(),
|
1253
|
+
createdAtLocation: import_zod18.z.string().optional(),
|
1254
|
+
updatedAtLocation: import_zod18.z.string().optional(),
|
1255
|
+
status: import_zod18.z.enum([
|
1256
|
+
ActionStatus.Requested,
|
1257
|
+
ActionStatus.Accepted,
|
1258
|
+
ActionStatus.Rejected
|
1259
|
+
]),
|
1260
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1261
|
+
originalActionId: import_zod18.z.string().optional()
|
1262
|
+
});
|
1263
|
+
var AssignedAction = ActionBase.merge(
|
1264
|
+
import_zod18.z.object({
|
1265
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1266
|
+
assignedTo: import_zod18.z.string()
|
1267
|
+
})
|
1268
|
+
);
|
1269
|
+
var UnassignedAction = ActionBase.merge(
|
1270
|
+
import_zod18.z.object({
|
1271
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1272
|
+
assignedTo: import_zod18.z.literal(null).default(null)
|
1273
|
+
})
|
1274
|
+
);
|
1275
|
+
var RegisterAction = ActionBase.merge(
|
1276
|
+
import_zod18.z.object({
|
1277
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1278
|
+
registrationNumber: import_zod18.z.string().optional()
|
1279
|
+
})
|
1280
|
+
);
|
1281
|
+
var DeclareAction = ActionBase.merge(
|
1282
|
+
import_zod18.z.object({
|
1283
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1284
|
+
})
|
1285
|
+
);
|
1286
|
+
var ValidateAction = ActionBase.merge(
|
1287
|
+
import_zod18.z.object({
|
1288
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1289
|
+
})
|
1290
|
+
);
|
1291
|
+
var RejectAction = ActionBase.merge(
|
1292
|
+
import_zod18.z.object({
|
1293
|
+
type: import_zod18.z.literal(ActionType.REJECT)
|
1294
|
+
})
|
1295
|
+
);
|
1296
|
+
var MarkAsDuplicateAction = ActionBase.merge(
|
1297
|
+
import_zod18.z.object({
|
1298
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1299
|
+
})
|
1300
|
+
);
|
1301
|
+
var ArchiveAction = ActionBase.merge(
|
1302
|
+
import_zod18.z.object({
|
1303
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE)
|
1304
|
+
})
|
1305
|
+
);
|
1306
|
+
var CreatedAction = ActionBase.merge(
|
1307
|
+
import_zod18.z.object({
|
1308
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1309
|
+
})
|
1310
|
+
);
|
1311
|
+
var NotifiedAction = ActionBase.merge(
|
1312
|
+
import_zod18.z.object({
|
1313
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1314
|
+
})
|
1315
|
+
);
|
1316
|
+
var PrintCertificateAction = ActionBase.merge(
|
1317
|
+
import_zod18.z.object({
|
1318
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1319
|
+
})
|
1320
|
+
);
|
1321
|
+
var RequestedCorrectionAction = ActionBase.merge(
|
1322
|
+
import_zod18.z.object({
|
1323
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1324
|
+
})
|
1325
|
+
);
|
1326
|
+
var ApprovedCorrectionAction = ActionBase.merge(
|
1327
|
+
import_zod18.z.object({
|
1328
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1329
|
+
requestId: import_zod18.z.string()
|
1330
|
+
})
|
1331
|
+
);
|
1332
|
+
var RejectedCorrectionAction = ActionBase.merge(
|
1333
|
+
import_zod18.z.object({
|
1334
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1335
|
+
requestId: import_zod18.z.string()
|
1336
|
+
})
|
1337
|
+
);
|
1338
|
+
var ReadAction = ActionBase.merge(
|
1339
|
+
import_zod18.z.object({
|
1340
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1341
|
+
})
|
1342
|
+
);
|
1343
|
+
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1344
|
+
CreatedAction,
|
1345
|
+
ValidateAction,
|
1346
|
+
RejectAction,
|
1347
|
+
MarkAsDuplicateAction,
|
1348
|
+
ArchiveAction,
|
1349
|
+
NotifiedAction,
|
1350
|
+
RegisterAction,
|
1351
|
+
DeclareAction,
|
1352
|
+
AssignedAction,
|
1353
|
+
RequestedCorrectionAction,
|
1354
|
+
ApprovedCorrectionAction,
|
1355
|
+
RejectedCorrectionAction,
|
1356
|
+
UnassignedAction,
|
1357
|
+
PrintCertificateAction,
|
1358
|
+
ReadAction
|
1359
|
+
]);
|
1360
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1361
|
+
declaration: true,
|
1362
|
+
annotation: true,
|
1363
|
+
createdBy: true,
|
1364
|
+
createdAtLocation: true
|
1365
|
+
}).merge(
|
1366
|
+
import_zod18.z.object({
|
1367
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1368
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1369
|
+
})
|
1370
|
+
);
|
1371
|
+
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1372
|
+
var ResolvedUser = import_zod18.z.object({
|
1373
|
+
id: import_zod18.z.string(),
|
1374
|
+
role: import_zod18.z.string(),
|
1375
|
+
name: import_zod18.z.array(
|
1376
|
+
import_zod18.z.object({
|
1377
|
+
use: import_zod18.z.string(),
|
1378
|
+
given: import_zod18.z.array(import_zod18.z.string()),
|
1379
|
+
family: import_zod18.z.string()
|
1380
|
+
})
|
1381
|
+
)
|
1382
|
+
});
|
1383
|
+
|
1384
|
+
// ../commons/src/events/ActionInput.ts
|
1385
|
+
var import_zod19 = require("zod");
|
1386
|
+
var BaseActionInput = import_zod19.z.object({
|
1387
|
+
eventId: import_zod19.z.string(),
|
1388
|
+
transactionId: import_zod19.z.string(),
|
1389
|
+
declaration: ActionUpdate.default({}),
|
1390
|
+
annotation: ActionUpdate.optional(),
|
1391
|
+
originalActionId: import_zod19.z.string().optional(),
|
1392
|
+
keepAssignment: import_zod19.z.boolean().optional()
|
1393
|
+
});
|
1394
|
+
var CreateActionInput = BaseActionInput.merge(
|
1395
|
+
import_zod19.z.object({
|
1396
|
+
type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1397
|
+
createdAtLocation: import_zod19.z.string()
|
1398
|
+
})
|
1399
|
+
);
|
1400
|
+
var RegisterActionInput = BaseActionInput.merge(
|
1401
|
+
import_zod19.z.object({
|
1402
|
+
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1403
|
+
registrationNumber: import_zod19.z.string().optional()
|
1404
|
+
})
|
1405
|
+
);
|
1406
|
+
var ValidateActionInput = BaseActionInput.merge(
|
1407
|
+
import_zod19.z.object({
|
1408
|
+
type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1409
|
+
duplicates: import_zod19.z.array(import_zod19.z.string())
|
1410
|
+
})
|
1411
|
+
);
|
1412
|
+
var NotifyActionInput = BaseActionInput.merge(
|
1413
|
+
import_zod19.z.object({
|
1414
|
+
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1415
|
+
})
|
1416
|
+
);
|
1417
|
+
var DeclareActionInput = BaseActionInput.merge(
|
1418
|
+
import_zod19.z.object({
|
1419
|
+
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1420
|
+
})
|
1421
|
+
);
|
1422
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
1423
|
+
import_zod19.z.object({
|
1424
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1425
|
+
})
|
1426
|
+
);
|
1427
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1428
|
+
import_zod19.z.object({
|
1429
|
+
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1430
|
+
})
|
1431
|
+
);
|
1432
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1433
|
+
import_zod19.z.object({
|
1434
|
+
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1435
|
+
})
|
1436
|
+
);
|
1437
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
1438
|
+
import_zod19.z.object({
|
1439
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1440
|
+
})
|
1441
|
+
);
|
1442
|
+
var AssignActionInput = BaseActionInput.merge(
|
1443
|
+
import_zod19.z.object({
|
1444
|
+
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1445
|
+
assignedTo: import_zod19.z.string()
|
1446
|
+
})
|
1447
|
+
);
|
1448
|
+
var UnassignActionInput = BaseActionInput.merge(
|
1449
|
+
import_zod19.z.object({
|
1450
|
+
type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
1451
|
+
assignedTo: import_zod19.z.literal(null).default(null)
|
1452
|
+
})
|
1453
|
+
);
|
1454
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1455
|
+
import_zod19.z.object({
|
1456
|
+
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1457
|
+
})
|
1458
|
+
);
|
1459
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1460
|
+
import_zod19.z.object({
|
1461
|
+
requestId: import_zod19.z.string(),
|
1462
|
+
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1463
|
+
})
|
1464
|
+
);
|
1465
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1466
|
+
import_zod19.z.object({
|
1467
|
+
requestId: import_zod19.z.string(),
|
1468
|
+
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1469
|
+
})
|
1470
|
+
);
|
1471
|
+
var ReadActionInput = BaseActionInput.merge(
|
1472
|
+
import_zod19.z.object({
|
1473
|
+
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
1474
|
+
})
|
1475
|
+
);
|
1476
|
+
var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
1477
|
+
CreateActionInput,
|
1478
|
+
ValidateActionInput,
|
1479
|
+
RegisterActionInput,
|
1480
|
+
NotifyActionInput,
|
1481
|
+
DeclareActionInput,
|
1482
|
+
RejectDeclarationActionInput,
|
1483
|
+
MarkedAsDuplicateActionInput,
|
1484
|
+
ArchiveActionInput,
|
1485
|
+
AssignActionInput,
|
1486
|
+
UnassignActionInput,
|
1487
|
+
PrintCertificateActionInput,
|
1488
|
+
RequestCorrectionActionInput,
|
1489
|
+
RejectCorrectionActionInput,
|
1490
|
+
ApproveCorrectionActionInput,
|
1491
|
+
ReadActionInput
|
1492
|
+
]);
|
1493
|
+
|
1494
|
+
// ../commons/src/events/Draft.ts
|
1495
|
+
var Draft = import_zod20.z.object({
|
1496
|
+
id: import_zod20.z.string(),
|
1497
|
+
eventId: import_zod20.z.string(),
|
1498
|
+
transactionId: import_zod20.z.string(),
|
1499
|
+
createdAt: import_zod20.z.string().datetime(),
|
1500
|
+
action: ActionBase.extend({
|
1501
|
+
type: ActionTypes
|
1502
|
+
}).omit({ id: true })
|
1503
|
+
});
|
1504
|
+
var DraftInput = BaseActionInput.extend({
|
1505
|
+
type: ActionTypes
|
1506
|
+
});
|
1507
|
+
|
1508
|
+
// ../commons/src/events/EventInput.ts
|
1509
|
+
var import_zod21 = require("zod");
|
1510
|
+
var EventInput = import_zod21.z.object({
|
1511
|
+
transactionId: import_zod21.z.string(),
|
1512
|
+
type: import_zod21.z.string()
|
1513
|
+
});
|
1514
|
+
|
1515
|
+
// ../commons/src/events/EventDocument.ts
|
1516
|
+
var import_zod22 = require("zod");
|
1517
|
+
var EventDocument = import_zod22.z.object({
|
1518
|
+
id: import_zod22.z.string(),
|
1519
|
+
type: import_zod22.z.string(),
|
1520
|
+
createdAt: import_zod22.z.string().datetime(),
|
1521
|
+
updatedAt: import_zod22.z.string().datetime(),
|
1522
|
+
actions: import_zod22.z.array(Action),
|
1523
|
+
trackingId: import_zod22.z.string()
|
1524
|
+
});
|
1525
|
+
|
1526
|
+
// ../commons/src/events/EventIndex.ts
|
1527
|
+
var import_zod23 = require("zod");
|
1528
|
+
var EventIndex = EventMetadata.extend({
|
1529
|
+
declaration: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any())
|
1530
|
+
});
|
1531
|
+
var EventSearchIndex = import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any()).and(
|
1532
|
+
import_zod23.z.object({
|
1533
|
+
type: import_zod23.z.string()
|
1534
|
+
// Ensures "type" (event-id) exists and is a string
|
1535
|
+
})
|
1536
|
+
);
|
1537
|
+
var Fuzzy = import_zod23.z.object({ type: import_zod23.z.literal("fuzzy"), term: import_zod23.z.string() });
|
1538
|
+
var Exact = import_zod23.z.object({ type: import_zod23.z.literal("exact"), term: import_zod23.z.string() });
|
1539
|
+
var AnyOf = import_zod23.z.object({
|
1540
|
+
type: import_zod23.z.literal("anyOf"),
|
1541
|
+
terms: import_zod23.z.array(import_zod23.z.string())
|
1542
|
+
});
|
1543
|
+
var Range = import_zod23.z.object({
|
1544
|
+
type: import_zod23.z.literal("range"),
|
1545
|
+
gte: import_zod23.z.string(),
|
1546
|
+
lte: import_zod23.z.string()
|
1547
|
+
});
|
1548
|
+
var Within = import_zod23.z.object({ type: import_zod23.z.literal("within"), location: import_zod23.z.string() });
|
1549
|
+
var DateCondition = import_zod23.z.union([Exact, Range]);
|
1550
|
+
var QueryInput = import_zod23.z.lazy(
|
1551
|
+
() => import_zod23.z.union([
|
1552
|
+
import_zod23.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
1553
|
+
import_zod23.z.record(import_zod23.z.string(), QueryInput)
|
1554
|
+
])
|
1555
|
+
);
|
1556
|
+
var QueryExpression = import_zod23.z.object({
|
1557
|
+
type: import_zod23.z.literal("and"),
|
1558
|
+
eventType: import_zod23.z.string(),
|
1559
|
+
searchType: import_zod23.z.optional(import_zod23.z.union([AnyOf, Exact])),
|
1560
|
+
status: import_zod23.z.optional(import_zod23.z.union([AnyOf, Exact])),
|
1561
|
+
createdAt: import_zod23.z.optional(DateCondition),
|
1562
|
+
updatedAt: import_zod23.z.optional(DateCondition),
|
1563
|
+
createAtLocation: import_zod23.z.optional(import_zod23.z.union([Within, Exact])),
|
1564
|
+
updatedAtLocation: import_zod23.z.optional(import_zod23.z.union([Within, Exact])),
|
1565
|
+
createdBy: import_zod23.z.optional(Exact),
|
1566
|
+
updatedBy: import_zod23.z.optional(Exact),
|
1567
|
+
trackingId: import_zod23.z.optional(Exact),
|
1568
|
+
data: QueryInput
|
1569
|
+
}).partial();
|
1570
|
+
var Or2 = import_zod23.z.object({
|
1571
|
+
type: import_zod23.z.literal("or"),
|
1572
|
+
clauses: import_zod23.z.array(QueryExpression)
|
1573
|
+
});
|
1574
|
+
var QueryType = import_zod23.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
1575
|
+
|
1576
|
+
// ../commons/src/events/utils.ts
|
1577
|
+
var import_lodash2 = require("lodash");
|
1578
|
+
|
1579
|
+
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1580
|
+
var import_zod25 = require("zod");
|
1581
|
+
|
1582
|
+
// ../commons/src/workqueues/defaultColumns.ts
|
1583
|
+
var import_zod24 = require("zod");
|
1584
|
+
var WorkQueueColumnConfig = import_zod24.z.object({
|
1585
|
+
id: import_zod24.z.string(),
|
1586
|
+
label: TranslationConfig
|
1587
|
+
});
|
1588
|
+
var defaultColumns = {
|
1589
|
+
event: {
|
1590
|
+
id: "event",
|
1591
|
+
label: {
|
1592
|
+
defaultMessage: "Event",
|
1593
|
+
description: "This is the label for the workqueue column",
|
1594
|
+
id: "workqueue.default.column.event"
|
1595
|
+
}
|
1596
|
+
},
|
1597
|
+
status: {
|
1598
|
+
id: "status",
|
1599
|
+
label: {
|
1600
|
+
defaultMessage: "Status",
|
1601
|
+
description: "This is the label for the workqueue column",
|
1602
|
+
id: "workqueue.default.column.status"
|
1603
|
+
}
|
1604
|
+
},
|
1605
|
+
createdAt: {
|
1606
|
+
id: "createdAt",
|
1607
|
+
label: {
|
1608
|
+
defaultMessage: "Created",
|
1609
|
+
description: "This is the label for the workqueue column",
|
1610
|
+
id: "workqueue.default.column.createdAt"
|
1611
|
+
}
|
1612
|
+
},
|
1613
|
+
modifiedAt: {
|
1614
|
+
id: "modifiedAt",
|
1615
|
+
label: {
|
1616
|
+
defaultMessage: "Modified",
|
1617
|
+
description: "This is the label for the workqueue column",
|
1618
|
+
id: "workqueue.default.column.modifiedAt"
|
1619
|
+
}
|
1620
|
+
}
|
1621
|
+
};
|
1622
|
+
var DefaultColumnKeys = import_zod24.z.enum(
|
1623
|
+
Object.keys(defaultColumns)
|
1624
|
+
);
|
1625
|
+
|
1626
|
+
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1627
|
+
var rootWorkqueueConfig = import_zod25.z.object({
|
1628
|
+
id: import_zod25.z.string(),
|
1629
|
+
title: TranslationConfig,
|
1630
|
+
columns: import_zod25.z.array(WorkQueueColumnConfig),
|
1631
|
+
defaultColumns: import_zod25.z.array(DefaultColumnKeys)
|
1632
|
+
});
|
1633
|
+
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1634
|
+
|
1635
|
+
// ../commons/src/workqueues/all.ts
|
1636
|
+
var allWorkqueue = defineWorkqueue({
|
1637
|
+
id: "all",
|
1638
|
+
title: {
|
1639
|
+
defaultMessage: "All events",
|
1640
|
+
description: "This is the label for the workqueue",
|
1641
|
+
id: "workqueue.all.label"
|
1642
|
+
},
|
1643
|
+
columns: [
|
1644
|
+
{
|
1645
|
+
id: "title",
|
1646
|
+
label: {
|
1647
|
+
defaultMessage: "Title",
|
1648
|
+
description: "This is the label for the workqueue column",
|
1649
|
+
id: "workqueue.all.column.title"
|
1650
|
+
}
|
1651
|
+
}
|
1652
|
+
],
|
1653
|
+
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1654
|
+
});
|
1655
|
+
|
1656
|
+
// ../commons/src/workqueues/readyForReview.ts
|
1657
|
+
var inReviewWorkqueue = defineWorkqueue({
|
1658
|
+
id: "ready-for-review",
|
1659
|
+
title: {
|
1660
|
+
defaultMessage: "Ready for review",
|
1661
|
+
description: "Label for in review workqueue",
|
1662
|
+
id: "event.workqueue.in-review.label"
|
1663
|
+
},
|
1664
|
+
columns: [
|
1665
|
+
{
|
1666
|
+
id: "title",
|
1667
|
+
label: {
|
1668
|
+
defaultMessage: "Title",
|
1669
|
+
description: "This is the label for the workqueue column",
|
1670
|
+
id: "workqueue.in-reveiw.column.title"
|
1671
|
+
}
|
1672
|
+
}
|
1673
|
+
],
|
1674
|
+
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1675
|
+
});
|
1676
|
+
|
1677
|
+
// ../commons/src/workqueues/readyToPrint.ts
|
1678
|
+
var registeredWorkqueue = defineWorkqueue({
|
1679
|
+
id: "registered",
|
1680
|
+
title: {
|
1681
|
+
defaultMessage: "Ready to print",
|
1682
|
+
description: "Label for registered workqueue",
|
1683
|
+
id: "event.workqueue.registered.label"
|
1684
|
+
},
|
1685
|
+
columns: [
|
1686
|
+
{
|
1687
|
+
id: "title",
|
1688
|
+
label: {
|
1689
|
+
defaultMessage: "Title",
|
1690
|
+
description: "This is the label for the workqueue column",
|
1056
1691
|
id: "workqueue.registered.column.title"
|
1057
1692
|
}
|
1058
1693
|
}
|
@@ -1073,7 +1708,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1073
1708
|
var import_date_fns = require("date-fns");
|
1074
1709
|
|
1075
1710
|
// ../commons/src/events/FieldTypeMapping.ts
|
1076
|
-
var
|
1711
|
+
var import_zod26 = require("zod");
|
1077
1712
|
function mapFieldTypeToZod(type, required) {
|
1078
1713
|
let schema;
|
1079
1714
|
switch (type) {
|
@@ -1115,6 +1750,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1115
1750
|
case FieldType.ADDRESS:
|
1116
1751
|
schema = AddressFieldUpdateValue;
|
1117
1752
|
break;
|
1753
|
+
case FieldType.DATA:
|
1754
|
+
schema = DataFieldValue;
|
1755
|
+
break;
|
1118
1756
|
}
|
1119
1757
|
return required ? schema : schema.nullish();
|
1120
1758
|
}
|
@@ -1123,7 +1761,7 @@ function createValidationSchema(config) {
|
|
1123
1761
|
for (const field2 of config) {
|
1124
1762
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1125
1763
|
}
|
1126
|
-
return
|
1764
|
+
return import_zod26.z.object(shape);
|
1127
1765
|
}
|
1128
1766
|
function mapFieldTypeToMockValue(field2, i) {
|
1129
1767
|
switch (field2.type) {
|
@@ -1149,6 +1787,7 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1149
1787
|
case FieldType.ADDRESS:
|
1150
1788
|
return {
|
1151
1789
|
country: "FAR",
|
1790
|
+
addressType: AddressType.DOMESTIC,
|
1152
1791
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1153
1792
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1154
1793
|
urbanOrRural: "URBAN",
|
@@ -1170,6 +1809,54 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1170
1809
|
};
|
1171
1810
|
case FieldType.FILE_WITH_OPTIONS:
|
1172
1811
|
return null;
|
1812
|
+
case FieldType.DATA:
|
1813
|
+
return {};
|
1814
|
+
}
|
1815
|
+
}
|
1816
|
+
function mapFieldTypeToEmptyValue(field2) {
|
1817
|
+
switch (field2.type) {
|
1818
|
+
case FieldType.DIVIDER:
|
1819
|
+
case FieldType.TEXT:
|
1820
|
+
case FieldType.TEXTAREA:
|
1821
|
+
case FieldType.BULLET_LIST:
|
1822
|
+
case FieldType.PAGE_HEADER:
|
1823
|
+
case FieldType.LOCATION:
|
1824
|
+
case FieldType.SELECT:
|
1825
|
+
case FieldType.COUNTRY:
|
1826
|
+
case FieldType.RADIO_GROUP:
|
1827
|
+
case FieldType.SIGNATURE:
|
1828
|
+
case FieldType.PARAGRAPH:
|
1829
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
1830
|
+
case FieldType.FACILITY:
|
1831
|
+
case FieldType.OFFICE:
|
1832
|
+
case FieldType.NUMBER:
|
1833
|
+
case FieldType.EMAIL:
|
1834
|
+
case FieldType.DATE:
|
1835
|
+
case FieldType.CHECKBOX:
|
1836
|
+
case FieldType.DATA:
|
1837
|
+
return null;
|
1838
|
+
case FieldType.ADDRESS:
|
1839
|
+
return {
|
1840
|
+
country: null,
|
1841
|
+
addressType: AddressType.DOMESTIC,
|
1842
|
+
province: null,
|
1843
|
+
district: null,
|
1844
|
+
urbanOrRural: "URBAN",
|
1845
|
+
// Default to urban needed for validation
|
1846
|
+
town: null,
|
1847
|
+
residentialArea: null,
|
1848
|
+
street: null,
|
1849
|
+
number: null,
|
1850
|
+
zipCode: null
|
1851
|
+
};
|
1852
|
+
case FieldType.FILE:
|
1853
|
+
return {
|
1854
|
+
filename: "",
|
1855
|
+
originalFilename: "",
|
1856
|
+
type: ""
|
1857
|
+
};
|
1858
|
+
case FieldType.FILE_WITH_OPTIONS:
|
1859
|
+
return [];
|
1173
1860
|
}
|
1174
1861
|
}
|
1175
1862
|
var isParagraphFieldType = (field2) => {
|
@@ -1211,659 +1898,365 @@ var isSelectFieldType = (field2) => {
|
|
1211
1898
|
var isAddressFieldType = (field2) => {
|
1212
1899
|
return field2.config.type === FieldType.ADDRESS;
|
1213
1900
|
};
|
1214
|
-
var isCountryFieldType = (field2) => {
|
1215
|
-
return field2.config.type === FieldType.COUNTRY;
|
1216
|
-
};
|
1217
|
-
var isCheckboxFieldType = (field2) => {
|
1218
|
-
return field2.config.type === FieldType.CHECKBOX;
|
1219
|
-
};
|
1220
|
-
var isRadioGroupFieldType = (field2) => {
|
1221
|
-
return field2.config.type === FieldType.RADIO_GROUP;
|
1222
|
-
};
|
1223
|
-
var isLocationFieldType = (field2) => {
|
1224
|
-
return field2.config.type === FieldType.LOCATION;
|
1225
|
-
};
|
1226
|
-
var isDividerFieldType = (field2) => {
|
1227
|
-
return field2.config.type === FieldType.DIVIDER;
|
1228
|
-
};
|
1229
|
-
var isAdministrativeAreaFieldType = (field2) => {
|
1230
|
-
return field2.config.type === FieldType.ADMINISTRATIVE_AREA;
|
1231
|
-
};
|
1232
|
-
var isFacilityFieldType = (field2) => {
|
1233
|
-
return field2.config.type === FieldType.FACILITY;
|
1234
|
-
};
|
1235
|
-
var isOfficeFieldType = (field2) => {
|
1236
|
-
return field2.config.type === FieldType.OFFICE;
|
1237
|
-
};
|
1238
|
-
|
1239
|
-
// ../commons/src/conditionals/validate.ts
|
1240
|
-
var ajv = new import_ajv.default({
|
1241
|
-
$data: true
|
1242
|
-
});
|
1243
|
-
(0, import_ajv_formats.default)(ajv);
|
1244
|
-
function validate(schema, data) {
|
1245
|
-
return ajv.validate(schema, data);
|
1246
|
-
}
|
1247
|
-
function getConditionalActionsForField(field2, values) {
|
1248
|
-
if (!field2.conditionals) {
|
1249
|
-
return [];
|
1250
|
-
}
|
1251
|
-
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1252
|
-
}
|
1253
|
-
function isFieldConditionMet(field2, form, conditionalType) {
|
1254
|
-
const hasRule = (field2.conditionals ?? []).some(
|
1255
|
-
(conditional) => conditional.type === conditionalType
|
1256
|
-
);
|
1257
|
-
if (!hasRule) {
|
1258
|
-
return true;
|
1259
|
-
}
|
1260
|
-
const validConditionals = getConditionalActionsForField(field2, {
|
1261
|
-
$form: form,
|
1262
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), {
|
1263
|
-
representation: "date"
|
1264
|
-
})
|
1265
|
-
});
|
1266
|
-
return validConditionals.includes(conditionalType);
|
1267
|
-
}
|
1268
|
-
function isFieldVisible(field2, form) {
|
1269
|
-
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1270
|
-
}
|
1271
|
-
function isFieldEnabled(field2, form) {
|
1272
|
-
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1273
|
-
}
|
1274
|
-
var zodToIntlErrorMap = (issue, _ctx) => {
|
1275
|
-
if (issue.code === "invalid_string" && issue.validation === "date") {
|
1276
|
-
return {
|
1277
|
-
message: {
|
1278
|
-
message: {
|
1279
|
-
defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
|
1280
|
-
description: "This is the error message for invalid date fields",
|
1281
|
-
id: "v2.error.invalidDate"
|
1282
|
-
}
|
1283
|
-
}
|
1284
|
-
};
|
1285
|
-
}
|
1286
|
-
if (issue.code === "invalid_string" && issue.validation === "email") {
|
1287
|
-
return {
|
1288
|
-
message: {
|
1289
|
-
message: {
|
1290
|
-
defaultMessage: "Invalid email address",
|
1291
|
-
description: "This is the error message for invalid email fields",
|
1292
|
-
id: "v2.error.invalidEmail"
|
1293
|
-
}
|
1294
|
-
}
|
1295
|
-
};
|
1296
|
-
}
|
1297
|
-
if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
|
1298
|
-
return {
|
1299
|
-
message: {
|
1300
|
-
message: {
|
1301
|
-
defaultMessage: "Required for registration",
|
1302
|
-
description: "This is the error message for required fields",
|
1303
|
-
id: "v2.error.required"
|
1304
|
-
}
|
1305
|
-
}
|
1306
|
-
};
|
1307
|
-
}
|
1308
|
-
return {
|
1309
|
-
message: {
|
1310
|
-
message: {
|
1311
|
-
defaultMessage: "Invalid input",
|
1312
|
-
description: "This is the error message for invalid field value",
|
1313
|
-
id: "v2.error.invalid"
|
1314
|
-
}
|
1315
|
-
}
|
1316
|
-
};
|
1317
|
-
};
|
1318
|
-
function getFieldValidationErrors({
|
1319
|
-
field: field2,
|
1320
|
-
values
|
1321
|
-
}) {
|
1322
|
-
const conditionalParameters = {
|
1323
|
-
$form: values,
|
1324
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1325
|
-
};
|
1326
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1327
|
-
if (values[field2.id]) {
|
1328
|
-
return {
|
1329
|
-
errors: [
|
1330
|
-
{
|
1331
|
-
message: {
|
1332
|
-
id: "v2.error.hidden",
|
1333
|
-
defaultMessage: "Hidden or disabled field should not receive a value",
|
1334
|
-
description: "Error message when field is hidden or disabled, but a value was received"
|
1335
|
-
}
|
1336
|
-
}
|
1337
|
-
]
|
1338
|
-
};
|
1339
|
-
}
|
1340
|
-
return {
|
1341
|
-
errors: []
|
1342
|
-
};
|
1343
|
-
}
|
1344
|
-
const fieldValidationResult = validateFieldInput({
|
1345
|
-
field: field2,
|
1346
|
-
value: values[field2.id]
|
1347
|
-
});
|
1348
|
-
const customValidationResults = runCustomFieldValidations({
|
1349
|
-
field: field2,
|
1350
|
-
conditionalParameters
|
1351
|
-
});
|
1352
|
-
return {
|
1353
|
-
// Assumes that custom validation errors are more important than field validation errors
|
1354
|
-
errors: [...customValidationResults, ...fieldValidationResult]
|
1355
|
-
};
|
1356
|
-
}
|
1357
|
-
function runCustomFieldValidations({
|
1358
|
-
field: field2,
|
1359
|
-
conditionalParameters
|
1360
|
-
}) {
|
1361
|
-
return (field2.validation ?? []).filter((validation) => {
|
1362
|
-
return !validate(validation.validator, conditionalParameters);
|
1363
|
-
}).map((validation) => ({ message: validation.message }));
|
1364
|
-
}
|
1365
|
-
function validateFieldInput({
|
1366
|
-
field: field2,
|
1367
|
-
value
|
1368
|
-
}) {
|
1369
|
-
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1370
|
-
value,
|
1371
|
-
{
|
1372
|
-
// @ts-expect-error
|
1373
|
-
errorMap: zodToIntlErrorMap
|
1374
|
-
}
|
1375
|
-
);
|
1376
|
-
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1377
|
-
}
|
1378
|
-
|
1379
|
-
// ../commons/src/utils.ts
|
1380
|
-
function getOrThrow(x, message) {
|
1381
|
-
if (x === void 0 || x === null) {
|
1382
|
-
throw new Error(message);
|
1383
|
-
}
|
1384
|
-
return x;
|
1385
|
-
}
|
1386
|
-
|
1387
|
-
// ../commons/src/uuid.ts
|
1388
|
-
var import_uuid = require("uuid");
|
1389
|
-
function getUUID() {
|
1390
|
-
return (0, import_uuid.v4)();
|
1391
|
-
}
|
1392
|
-
|
1393
|
-
// ../commons/src/events/utils.ts
|
1394
|
-
function isMetadataField(field2) {
|
1395
|
-
return field2 in eventMetadataLabelMap;
|
1396
|
-
}
|
1397
|
-
var findInputPageFields = (config) => {
|
1398
|
-
return (0, import_lodash.flattenDeep)(
|
1399
|
-
config.actions.map(
|
1400
|
-
({ forms }) => forms.map(
|
1401
|
-
({ pages }) => pages.map(
|
1402
|
-
({ fields }) => fields.map(({ id, label }) => ({ id, label }))
|
1403
|
-
)
|
1404
|
-
)
|
1405
|
-
)
|
1406
|
-
);
|
1407
|
-
};
|
1408
|
-
var findPageFields = (config) => {
|
1409
|
-
return (0, import_lodash.flattenDeep)(
|
1410
|
-
config.actions.map((action) => {
|
1411
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1412
|
-
return [
|
1413
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1414
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1415
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1416
|
-
];
|
1417
|
-
}
|
1418
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1419
|
-
})
|
1420
|
-
);
|
1421
|
-
};
|
1422
|
-
var resolveLabelsFromKnownFields = ({
|
1423
|
-
pageFields,
|
1424
|
-
refFields
|
1425
|
-
}) => {
|
1426
|
-
return refFields.map((field2) => {
|
1427
|
-
if (field2.label) {
|
1428
|
-
return field2;
|
1429
|
-
}
|
1430
|
-
if (isMetadataField(field2.id)) {
|
1431
|
-
return {
|
1432
|
-
...field2,
|
1433
|
-
label: eventMetadataLabelMap[field2.id]
|
1434
|
-
};
|
1435
|
-
}
|
1436
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1437
|
-
if (!pageLabel) {
|
1438
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1439
|
-
}
|
1440
|
-
return {
|
1441
|
-
...field2,
|
1442
|
-
label: pageLabel.label
|
1443
|
-
};
|
1444
|
-
});
|
1901
|
+
var isCountryFieldType = (field2) => {
|
1902
|
+
return field2.config.type === FieldType.COUNTRY;
|
1445
1903
|
};
|
1446
|
-
|
1447
|
-
return
|
1448
|
-
...form.review.fields,
|
1449
|
-
...form.pages.flatMap((page) => page.fields)
|
1450
|
-
]);
|
1451
|
-
}
|
1452
|
-
function getAllPages(configuration) {
|
1453
|
-
return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => form.pages);
|
1454
|
-
}
|
1455
|
-
function validateWorkqueueConfig(workqueueConfigs) {
|
1456
|
-
workqueueConfigs.map((workqueue) => {
|
1457
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1458
|
-
(wq) => wq.id === workqueue.id
|
1459
|
-
);
|
1460
|
-
if (!rootWorkqueue) {
|
1461
|
-
throw new Error(
|
1462
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1463
|
-
);
|
1464
|
-
}
|
1465
|
-
});
|
1466
|
-
}
|
1467
|
-
var findActiveActionForm = (configuration, action) => {
|
1468
|
-
const actionConfig = configuration.actions.find((a) => a.type === action);
|
1469
|
-
const form = actionConfig?.forms.find((f) => f.active);
|
1470
|
-
return form;
|
1904
|
+
var isCheckboxFieldType = (field2) => {
|
1905
|
+
return field2.config.type === FieldType.CHECKBOX;
|
1471
1906
|
};
|
1472
|
-
var
|
1473
|
-
return
|
1907
|
+
var isRadioGroupFieldType = (field2) => {
|
1908
|
+
return field2.config.type === FieldType.RADIO_GROUP;
|
1474
1909
|
};
|
1475
|
-
var
|
1476
|
-
return
|
1910
|
+
var isLocationFieldType = (field2) => {
|
1911
|
+
return field2.config.type === FieldType.LOCATION;
|
1477
1912
|
};
|
1478
|
-
var
|
1479
|
-
|
1480
|
-
return form ? getFormFields(form) : void 0;
|
1913
|
+
var isDividerFieldType = (field2) => {
|
1914
|
+
return field2.config.type === FieldType.DIVIDER;
|
1481
1915
|
};
|
1482
|
-
var
|
1483
|
-
|
1484
|
-
const reviewFields = form?.review.fields;
|
1485
|
-
const formFields = form ? getFormFields(form) : void 0;
|
1486
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1487
|
-
return allFields;
|
1916
|
+
var isAdministrativeAreaFieldType = (field2) => {
|
1917
|
+
return field2.config.type === FieldType.ADMINISTRATIVE_AREA;
|
1488
1918
|
};
|
1489
|
-
var
|
1490
|
-
return
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1919
|
+
var isFacilityFieldType = (field2) => {
|
1920
|
+
return field2.config.type === FieldType.FACILITY;
|
1921
|
+
};
|
1922
|
+
var isOfficeFieldType = (field2) => {
|
1923
|
+
return field2.config.type === FieldType.OFFICE;
|
1924
|
+
};
|
1925
|
+
var isDataFieldType = (field2) => {
|
1926
|
+
return field2.config.type === FieldType.DATA;
|
1494
1927
|
};
|
1495
|
-
function getActiveActionFields(configuration, action) {
|
1496
|
-
const fields = findActiveActionFields(configuration, action);
|
1497
|
-
if (!fields) {
|
1498
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1499
|
-
}
|
1500
|
-
return fields;
|
1501
|
-
}
|
1502
|
-
function getEventConfiguration(eventConfigurations, type) {
|
1503
|
-
const config = eventConfigurations.find((config2) => config2.id === type);
|
1504
|
-
if (!config) {
|
1505
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1506
|
-
}
|
1507
|
-
return config;
|
1508
|
-
}
|
1509
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1510
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1511
|
-
return false;
|
1512
|
-
}
|
1513
|
-
return !form[field2.id];
|
1514
|
-
}
|
1515
|
-
function stripHiddenFields(fields, data) {
|
1516
|
-
return (0, import_lodash.omitBy)(data, (_2, fieldId) => {
|
1517
|
-
const field2 = fields.find((f) => f.id === fieldId);
|
1518
|
-
if (!field2) {
|
1519
|
-
return true;
|
1520
|
-
}
|
1521
|
-
if (isOptionalUncheckedCheckbox(field2, data)) {
|
1522
|
-
return true;
|
1523
|
-
}
|
1524
|
-
return !isFieldVisible(field2, data);
|
1525
|
-
});
|
1526
|
-
}
|
1527
|
-
function findActiveDrafts(event2, drafts) {
|
1528
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1529
|
-
const lastAction = actions[actions.length - 1];
|
1530
|
-
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1531
|
-
}
|
1532
|
-
function createEmptyDraft(eventId, draftId, actionType) {
|
1533
|
-
return {
|
1534
|
-
id: draftId,
|
1535
|
-
eventId,
|
1536
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1537
|
-
transactionId: getUUID(),
|
1538
|
-
action: {
|
1539
|
-
type: actionType,
|
1540
|
-
data: {},
|
1541
|
-
metadata: {},
|
1542
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1543
|
-
createdBy: "@todo",
|
1544
|
-
createdAtLocation: "@todo"
|
1545
|
-
}
|
1546
|
-
};
|
1547
|
-
}
|
1548
|
-
|
1549
|
-
// ../commons/src/events/EventConfig.ts
|
1550
|
-
var EventConfig = import_zod18.z.object({
|
1551
|
-
id: import_zod18.z.string().describe(
|
1552
|
-
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1553
|
-
),
|
1554
|
-
summary: SummaryConfig,
|
1555
|
-
label: TranslationConfig,
|
1556
|
-
actions: import_zod18.z.array(ActionConfig),
|
1557
|
-
workqueues: import_zod18.z.array(WorkqueueConfig),
|
1558
|
-
deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
|
1559
|
-
advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
|
1560
|
-
}).superRefine((event2, ctx) => {
|
1561
|
-
const allFields = findPageFields(event2);
|
1562
|
-
const fieldIds = allFields.map((field2) => field2.id);
|
1563
|
-
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1564
|
-
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
1565
|
-
);
|
1566
|
-
const advancedSearchFieldsSet = new Set(advancedSearchFields);
|
1567
|
-
if (advancedSearchFieldsSet.size !== advancedSearchFields.length) {
|
1568
|
-
ctx.addIssue({
|
1569
|
-
code: "custom",
|
1570
|
-
message: "Advanced search field ids must be unique",
|
1571
|
-
path: ["advancedSearch"]
|
1572
|
-
});
|
1573
|
-
}
|
1574
|
-
const invalidFields = event2.advancedSearch.flatMap(
|
1575
|
-
(section) => section.fields.filter((field2) => !fieldIds.includes(field2.fieldId))
|
1576
|
-
);
|
1577
|
-
if (invalidFields.length > 0) {
|
1578
|
-
ctx.addIssue({
|
1579
|
-
code: "custom",
|
1580
|
-
message: `Advanced search id must match a field id in fields array.
|
1581
|
-
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1582
|
-
path: ["advancedSearch"]
|
1583
|
-
});
|
1584
|
-
}
|
1585
|
-
});
|
1586
|
-
|
1587
|
-
// ../commons/src/events/EventConfigInput.ts
|
1588
|
-
var defineForm = (form) => FormConfig.parse(form);
|
1589
|
-
var defineFormPage = (formPage) => FormPage.parse(formPage);
|
1590
|
-
|
1591
|
-
// ../commons/src/events/Draft.ts
|
1592
|
-
var import_zod21 = require("zod");
|
1593
|
-
|
1594
|
-
// ../commons/src/events/ActionDocument.ts
|
1595
|
-
var import_zod19 = require("zod");
|
1596
|
-
var ActionUpdate = import_zod19.z.record(import_zod19.z.string(), FieldUpdateValue);
|
1597
|
-
var ActionBase = import_zod19.z.object({
|
1598
|
-
id: import_zod19.z.string(),
|
1599
|
-
createdAt: import_zod19.z.string().datetime(),
|
1600
|
-
createdBy: import_zod19.z.string(),
|
1601
|
-
data: ActionUpdate,
|
1602
|
-
metadata: ActionUpdate.optional(),
|
1603
|
-
createdAtLocation: import_zod19.z.string()
|
1604
|
-
});
|
1605
|
-
var AssignedAction = ActionBase.merge(
|
1606
|
-
import_zod19.z.object({
|
1607
|
-
type: import_zod19.z.literal(ActionType.ASSIGN),
|
1608
|
-
assignedTo: import_zod19.z.string()
|
1609
|
-
})
|
1610
|
-
);
|
1611
|
-
var UnassignedAction = ActionBase.merge(
|
1612
|
-
import_zod19.z.object({
|
1613
|
-
type: import_zod19.z.literal(ActionType.UNASSIGN)
|
1614
|
-
})
|
1615
|
-
);
|
1616
|
-
var RegisterAction = ActionBase.merge(
|
1617
|
-
import_zod19.z.object({
|
1618
|
-
type: import_zod19.z.literal(ActionType.REGISTER),
|
1619
|
-
identifiers: import_zod19.z.object({
|
1620
|
-
trackingId: import_zod19.z.string(),
|
1621
|
-
registrationNumber: import_zod19.z.string()
|
1622
|
-
})
|
1623
|
-
})
|
1624
|
-
);
|
1625
|
-
var DeclareAction = ActionBase.merge(
|
1626
|
-
import_zod19.z.object({
|
1627
|
-
type: import_zod19.z.literal(ActionType.DECLARE)
|
1628
|
-
})
|
1629
|
-
);
|
1630
|
-
var ValidateAction = ActionBase.merge(
|
1631
|
-
import_zod19.z.object({
|
1632
|
-
type: import_zod19.z.literal(ActionType.VALIDATE)
|
1633
|
-
})
|
1634
|
-
);
|
1635
|
-
var RejectAction = ActionBase.merge(
|
1636
|
-
import_zod19.z.object({
|
1637
|
-
type: import_zod19.z.literal(ActionType.REJECT)
|
1638
|
-
})
|
1639
|
-
);
|
1640
|
-
var MarkAsDuplicateAction = ActionBase.merge(
|
1641
|
-
import_zod19.z.object({
|
1642
|
-
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1643
|
-
})
|
1644
|
-
);
|
1645
|
-
var ArchiveAction = ActionBase.merge(
|
1646
|
-
import_zod19.z.object({
|
1647
|
-
type: import_zod19.z.literal(ActionType.ARCHIVE)
|
1648
|
-
})
|
1649
|
-
);
|
1650
|
-
var CreatedAction = ActionBase.merge(
|
1651
|
-
import_zod19.z.object({
|
1652
|
-
type: import_zod19.z.literal(ActionType.CREATE)
|
1653
|
-
})
|
1654
|
-
);
|
1655
|
-
var NotifiedAction = ActionBase.merge(
|
1656
|
-
import_zod19.z.object({
|
1657
|
-
type: import_zod19.z.literal(ActionType.NOTIFY)
|
1658
|
-
})
|
1659
|
-
);
|
1660
|
-
var PrintCertificateAction = ActionBase.merge(
|
1661
|
-
import_zod19.z.object({
|
1662
|
-
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
|
1663
|
-
})
|
1664
|
-
);
|
1665
|
-
var RequestedCorrectionAction = ActionBase.merge(
|
1666
|
-
import_zod19.z.object({
|
1667
|
-
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION)
|
1668
|
-
})
|
1669
|
-
);
|
1670
|
-
var ApprovedCorrectionAction = ActionBase.merge(
|
1671
|
-
import_zod19.z.object({
|
1672
|
-
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
|
1673
|
-
requestId: import_zod19.z.string()
|
1674
|
-
})
|
1675
|
-
);
|
1676
|
-
var RejectedCorrectionAction = ActionBase.merge(
|
1677
|
-
import_zod19.z.object({
|
1678
|
-
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
|
1679
|
-
requestId: import_zod19.z.string()
|
1680
|
-
})
|
1681
|
-
);
|
1682
|
-
var CustomAction = ActionBase.merge(
|
1683
|
-
import_zod19.z.object({
|
1684
|
-
type: import_zod19.z.literal(ActionType.CUSTOM)
|
1685
|
-
})
|
1686
|
-
);
|
1687
|
-
var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
1688
|
-
CreatedAction,
|
1689
|
-
ValidateAction,
|
1690
|
-
RejectAction,
|
1691
|
-
MarkAsDuplicateAction,
|
1692
|
-
ArchiveAction,
|
1693
|
-
NotifiedAction,
|
1694
|
-
RegisterAction,
|
1695
|
-
DeclareAction,
|
1696
|
-
AssignedAction,
|
1697
|
-
RequestedCorrectionAction,
|
1698
|
-
ApprovedCorrectionAction,
|
1699
|
-
RejectedCorrectionAction,
|
1700
|
-
UnassignedAction,
|
1701
|
-
PrintCertificateAction,
|
1702
|
-
CustomAction
|
1703
|
-
]);
|
1704
|
-
var ResolvedUser = import_zod19.z.object({
|
1705
|
-
id: import_zod19.z.string(),
|
1706
|
-
role: import_zod19.z.string(),
|
1707
|
-
name: import_zod19.z.array(
|
1708
|
-
import_zod19.z.object({
|
1709
|
-
use: import_zod19.z.string(),
|
1710
|
-
given: import_zod19.z.array(import_zod19.z.string()),
|
1711
|
-
family: import_zod19.z.string()
|
1712
|
-
})
|
1713
|
-
)
|
1714
|
-
});
|
1715
|
-
|
1716
|
-
// ../commons/src/events/ActionInput.ts
|
1717
|
-
var import_zod20 = require("zod");
|
1718
|
-
var BaseActionInput = import_zod20.z.object({
|
1719
|
-
eventId: import_zod20.z.string(),
|
1720
|
-
transactionId: import_zod20.z.string(),
|
1721
|
-
data: ActionUpdate,
|
1722
|
-
metadata: ActionUpdate.optional()
|
1723
|
-
});
|
1724
|
-
var CreateActionInput = BaseActionInput.merge(
|
1725
|
-
import_zod20.z.object({
|
1726
|
-
type: import_zod20.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1727
|
-
createdAtLocation: import_zod20.z.string()
|
1728
|
-
})
|
1729
|
-
);
|
1730
|
-
var RegisterActionInput = BaseActionInput.merge(
|
1731
|
-
import_zod20.z.object({
|
1732
|
-
type: import_zod20.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1733
|
-
identifiers: import_zod20.z.object({
|
1734
|
-
trackingId: import_zod20.z.string(),
|
1735
|
-
registrationNumber: import_zod20.z.string()
|
1736
|
-
})
|
1737
|
-
})
|
1738
|
-
);
|
1739
|
-
var ValidateActionInput = BaseActionInput.merge(
|
1740
|
-
import_zod20.z.object({
|
1741
|
-
type: import_zod20.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1742
|
-
duplicates: import_zod20.z.array(import_zod20.z.string())
|
1743
|
-
})
|
1744
|
-
);
|
1745
|
-
var NotifyActionInput = BaseActionInput.merge(
|
1746
|
-
import_zod20.z.object({
|
1747
|
-
type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1748
|
-
})
|
1749
|
-
);
|
1750
|
-
var DeclareActionInput = BaseActionInput.merge(
|
1751
|
-
import_zod20.z.object({
|
1752
|
-
type: import_zod20.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1753
|
-
})
|
1754
|
-
);
|
1755
|
-
var PrintCertificateActionInput = BaseActionInput.merge(
|
1756
|
-
import_zod20.z.object({
|
1757
|
-
type: import_zod20.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1758
|
-
})
|
1759
|
-
);
|
1760
|
-
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1761
|
-
import_zod20.z.object({
|
1762
|
-
type: import_zod20.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1763
|
-
})
|
1764
|
-
);
|
1765
|
-
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1766
|
-
import_zod20.z.object({
|
1767
|
-
type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1768
|
-
})
|
1769
|
-
);
|
1770
|
-
var ArchiveActionInput = BaseActionInput.merge(
|
1771
|
-
import_zod20.z.object({
|
1772
|
-
type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1773
|
-
})
|
1774
|
-
);
|
1775
|
-
var AssignActionInput = BaseActionInput.merge(
|
1776
|
-
import_zod20.z.object({
|
1777
|
-
type: import_zod20.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1778
|
-
assignedTo: import_zod20.z.string()
|
1779
|
-
})
|
1780
|
-
);
|
1781
|
-
var UnassignActionInput = BaseActionInput.merge(
|
1782
|
-
import_zod20.z.object({
|
1783
|
-
type: import_zod20.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
|
1784
|
-
})
|
1785
|
-
);
|
1786
|
-
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1787
|
-
import_zod20.z.object({
|
1788
|
-
type: import_zod20.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1789
|
-
})
|
1790
|
-
);
|
1791
|
-
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1792
|
-
import_zod20.z.object({
|
1793
|
-
requestId: import_zod20.z.string(),
|
1794
|
-
type: import_zod20.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1795
|
-
})
|
1796
|
-
);
|
1797
|
-
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1798
|
-
import_zod20.z.object({
|
1799
|
-
requestId: import_zod20.z.string(),
|
1800
|
-
type: import_zod20.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1801
|
-
})
|
1802
|
-
);
|
1803
|
-
var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
1804
|
-
CreateActionInput,
|
1805
|
-
ValidateActionInput,
|
1806
|
-
RegisterActionInput,
|
1807
|
-
NotifyActionInput,
|
1808
|
-
DeclareActionInput,
|
1809
|
-
RejectDeclarationActionInput,
|
1810
|
-
MarkedAsDuplicateActionInput,
|
1811
|
-
ArchiveActionInput,
|
1812
|
-
AssignActionInput,
|
1813
|
-
UnassignActionInput,
|
1814
|
-
PrintCertificateActionInput,
|
1815
|
-
RequestCorrectionActionInput,
|
1816
|
-
RejectCorrectionActionInput,
|
1817
|
-
ApproveCorrectionActionInput
|
1818
|
-
]);
|
1819
|
-
|
1820
|
-
// ../commons/src/events/Draft.ts
|
1821
|
-
var Draft = import_zod21.z.object({
|
1822
|
-
id: import_zod21.z.string(),
|
1823
|
-
eventId: import_zod21.z.string(),
|
1824
|
-
transactionId: import_zod21.z.string(),
|
1825
|
-
createdAt: import_zod21.z.string().datetime(),
|
1826
|
-
action: ActionBase.extend({
|
1827
|
-
type: import_zod21.z.enum(Object.values(ActionType))
|
1828
|
-
}).omit({ id: true })
|
1829
|
-
});
|
1830
|
-
var DraftInput = BaseActionInput.extend({
|
1831
|
-
type: import_zod21.z.enum(Object.values(ActionType))
|
1832
|
-
});
|
1833
1928
|
|
1834
|
-
// ../commons/src/
|
1835
|
-
var
|
1836
|
-
|
1837
|
-
|
1838
|
-
type: import_zod22.z.string()
|
1929
|
+
// ../commons/src/conditionals/validate.ts
|
1930
|
+
var ajv = new import_ajv.default({
|
1931
|
+
$data: true,
|
1932
|
+
allowUnionTypes: true
|
1839
1933
|
});
|
1934
|
+
(0, import_ajv_formats.default)(ajv);
|
1935
|
+
function validate(schema, data) {
|
1936
|
+
return ajv.validate(schema, data);
|
1937
|
+
}
|
1938
|
+
function getConditionalActionsForField(field2, values) {
|
1939
|
+
if (!field2.conditionals) {
|
1940
|
+
return [];
|
1941
|
+
}
|
1942
|
+
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1943
|
+
}
|
1944
|
+
function isFieldConditionMet(field2, form, conditionalType) {
|
1945
|
+
const hasRule = (field2.conditionals ?? []).some(
|
1946
|
+
(conditional) => conditional.type === conditionalType
|
1947
|
+
);
|
1948
|
+
if (!hasRule) {
|
1949
|
+
return true;
|
1950
|
+
}
|
1951
|
+
const validConditionals = getConditionalActionsForField(field2, {
|
1952
|
+
$form: form,
|
1953
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), {
|
1954
|
+
representation: "date"
|
1955
|
+
})
|
1956
|
+
});
|
1957
|
+
return validConditionals.includes(conditionalType);
|
1958
|
+
}
|
1959
|
+
function isFieldVisible(field2, form) {
|
1960
|
+
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1961
|
+
}
|
1962
|
+
function isFieldEnabled(field2, form) {
|
1963
|
+
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1964
|
+
}
|
1965
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1966
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1967
|
+
}
|
1968
|
+
var errorMessages = {
|
1969
|
+
hiddenField: {
|
1970
|
+
id: "v2.error.hidden",
|
1971
|
+
defaultMessage: "Hidden or disabled field should not receive a value",
|
1972
|
+
description: "Error message when field is hidden or disabled, but a value was received"
|
1973
|
+
},
|
1974
|
+
invalidDate: {
|
1975
|
+
defaultMessage: "Invalid date field",
|
1976
|
+
description: "Error message when date field is invalid",
|
1977
|
+
id: "v2.error.invalidDate"
|
1978
|
+
},
|
1979
|
+
invalidEmail: {
|
1980
|
+
defaultMessage: "Invalid email address",
|
1981
|
+
description: "Error message when email address is invalid",
|
1982
|
+
id: "v2.error.invalidEmail"
|
1983
|
+
},
|
1984
|
+
requiredField: {
|
1985
|
+
defaultMessage: "Required for registration",
|
1986
|
+
description: "Error message when required field is missing",
|
1987
|
+
id: "v2.error.required"
|
1988
|
+
},
|
1989
|
+
invalidInput: {
|
1990
|
+
defaultMessage: "Invalid input",
|
1991
|
+
description: "Error message when generic field is invalid",
|
1992
|
+
id: "v2.error.invalid"
|
1993
|
+
}
|
1994
|
+
};
|
1995
|
+
function createIntlError(message) {
|
1996
|
+
return {
|
1997
|
+
message: {
|
1998
|
+
message
|
1999
|
+
}
|
2000
|
+
};
|
2001
|
+
}
|
2002
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
2003
|
+
switch (issue.code) {
|
2004
|
+
case "invalid_string": {
|
2005
|
+
if (_ctx.data === "") {
|
2006
|
+
return createIntlError(errorMessages.requiredField);
|
2007
|
+
}
|
2008
|
+
if (issue.validation === "date") {
|
2009
|
+
return createIntlError(errorMessages.invalidDate);
|
2010
|
+
}
|
2011
|
+
if (issue.validation === "email") {
|
2012
|
+
return createIntlError(errorMessages.invalidEmail);
|
2013
|
+
}
|
2014
|
+
break;
|
2015
|
+
}
|
2016
|
+
case "invalid_type": {
|
2017
|
+
if (issue.expected !== issue.received && issue.received === "undefined") {
|
2018
|
+
return createIntlError(errorMessages.requiredField);
|
2019
|
+
}
|
2020
|
+
break;
|
2021
|
+
}
|
2022
|
+
case "too_small": {
|
2023
|
+
if (issue.message === void 0) {
|
2024
|
+
return createIntlError(errorMessages.requiredField);
|
2025
|
+
}
|
2026
|
+
break;
|
2027
|
+
}
|
2028
|
+
case "invalid_union": {
|
2029
|
+
for (const { issues } of issue.unionErrors) {
|
2030
|
+
for (const e of issues) {
|
2031
|
+
if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
|
2032
|
+
return createIntlError(errorMessages.invalidInput);
|
2033
|
+
}
|
2034
|
+
}
|
2035
|
+
}
|
2036
|
+
return createIntlError(errorMessages.requiredField);
|
2037
|
+
}
|
2038
|
+
}
|
2039
|
+
return createIntlError(errorMessages.invalidInput);
|
2040
|
+
}
|
2041
|
+
function runCustomFieldValidations({
|
2042
|
+
field: field2,
|
2043
|
+
conditionalParameters
|
2044
|
+
}) {
|
2045
|
+
return (field2.validation ?? []).filter((validation) => {
|
2046
|
+
return !validate(validation.validator, conditionalParameters);
|
2047
|
+
}).map((validation) => ({ message: validation.message }));
|
2048
|
+
}
|
2049
|
+
function validateFieldInput({
|
2050
|
+
field: field2,
|
2051
|
+
value
|
2052
|
+
}) {
|
2053
|
+
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
2054
|
+
value,
|
2055
|
+
{
|
2056
|
+
// @ts-expect-error
|
2057
|
+
errorMap: zodToIntlErrorMap
|
2058
|
+
}
|
2059
|
+
);
|
2060
|
+
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
2061
|
+
}
|
2062
|
+
function runFieldValidations({
|
2063
|
+
field: field2,
|
2064
|
+
values
|
2065
|
+
}) {
|
2066
|
+
const conditionalParameters = {
|
2067
|
+
$form: values,
|
2068
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
2069
|
+
};
|
2070
|
+
const fieldValidationResult = validateFieldInput({
|
2071
|
+
field: field2,
|
2072
|
+
value: values[field2.id]
|
2073
|
+
});
|
2074
|
+
const customValidationResults = runCustomFieldValidations({
|
2075
|
+
field: field2,
|
2076
|
+
conditionalParameters
|
2077
|
+
});
|
2078
|
+
return {
|
2079
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
2080
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
2081
|
+
};
|
2082
|
+
}
|
2083
|
+
function getFieldValidationErrors({
|
2084
|
+
field: field2,
|
2085
|
+
values
|
2086
|
+
}) {
|
2087
|
+
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
2088
|
+
if (values[field2.id]) {
|
2089
|
+
return {
|
2090
|
+
errors: [
|
2091
|
+
{
|
2092
|
+
message: errorMessages.hiddenField
|
2093
|
+
}
|
2094
|
+
]
|
2095
|
+
};
|
2096
|
+
}
|
2097
|
+
return {
|
2098
|
+
errors: []
|
2099
|
+
};
|
2100
|
+
}
|
2101
|
+
return runFieldValidations({
|
2102
|
+
field: field2,
|
2103
|
+
values
|
2104
|
+
});
|
2105
|
+
}
|
1840
2106
|
|
1841
|
-
// ../commons/src/
|
1842
|
-
var
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
createdAt: import_zod23.z.string().datetime(),
|
1847
|
-
updatedAt: import_zod23.z.string().datetime(),
|
1848
|
-
actions: import_zod23.z.array(ActionDocument),
|
1849
|
-
trackingId: import_zod23.z.string()
|
1850
|
-
});
|
2107
|
+
// ../commons/src/uuid.ts
|
2108
|
+
var import_uuid = require("uuid");
|
2109
|
+
function getUUID() {
|
2110
|
+
return (0, import_uuid.v4)();
|
2111
|
+
}
|
1851
2112
|
|
1852
|
-
// ../commons/src/events/
|
1853
|
-
var
|
1854
|
-
|
1855
|
-
|
1856
|
-
}
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
2113
|
+
// ../commons/src/events/utils.ts
|
2114
|
+
var import_date_fns2 = require("date-fns");
|
2115
|
+
function isDeclarationActionConfig(action) {
|
2116
|
+
return DeclarationActions.safeParse(action.type).success;
|
2117
|
+
}
|
2118
|
+
function getDeclarationFields(configuration) {
|
2119
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
2120
|
+
}
|
2121
|
+
function getDeclarationPages(configuration) {
|
2122
|
+
return configuration.declaration.pages;
|
2123
|
+
}
|
2124
|
+
function getDeclaration(configuration) {
|
2125
|
+
return configuration.declaration;
|
2126
|
+
}
|
2127
|
+
var getActionAnnotationFields = (actionConfig) => {
|
2128
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
2129
|
+
return [
|
2130
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
2131
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
2132
|
+
];
|
2133
|
+
}
|
2134
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
2135
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
2136
|
+
}
|
2137
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
2138
|
+
return actionConfig.review.fields;
|
2139
|
+
}
|
2140
|
+
return [];
|
2141
|
+
};
|
2142
|
+
var getAllAnnotationFields = (config) => {
|
2143
|
+
return (0, import_lodash2.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
2144
|
+
};
|
2145
|
+
var findRecordActionPages = (config, actionType) => {
|
2146
|
+
const action = config.actions.find((a) => a.type === actionType);
|
2147
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
2148
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
2149
|
+
}
|
2150
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
2151
|
+
return action.printForm.pages;
|
2152
|
+
}
|
2153
|
+
return [];
|
2154
|
+
};
|
2155
|
+
function getActionReview(configuration, actionType) {
|
2156
|
+
const [actionConfig] = configuration.actions.filter(
|
2157
|
+
(a) => a.type === actionType
|
2158
|
+
);
|
2159
|
+
return getOrThrow(
|
2160
|
+
actionConfig.review,
|
2161
|
+
`No review config found for ${actionType}`
|
2162
|
+
);
|
2163
|
+
}
|
2164
|
+
function getActionReviewFields(configuration, actionType) {
|
2165
|
+
return getActionReview(configuration, actionType).fields;
|
2166
|
+
}
|
2167
|
+
function validateWorkqueueConfig(workqueueConfigs) {
|
2168
|
+
workqueueConfigs.map((workqueue) => {
|
2169
|
+
const rootWorkqueue = Object.values(workqueues).find(
|
2170
|
+
(wq) => wq.id === workqueue.id
|
2171
|
+
);
|
2172
|
+
if (!rootWorkqueue) {
|
2173
|
+
throw new Error(
|
2174
|
+
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
2175
|
+
);
|
2176
|
+
}
|
2177
|
+
});
|
2178
|
+
}
|
2179
|
+
function isPageVisible(page, formValues) {
|
2180
|
+
if (!page.conditional) {
|
2181
|
+
return true;
|
2182
|
+
}
|
2183
|
+
return validate(page.conditional, {
|
2184
|
+
$form: formValues,
|
2185
|
+
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
2186
|
+
});
|
2187
|
+
}
|
2188
|
+
function omitHiddenFields(fields, values) {
|
2189
|
+
return (0, import_lodash2.omitBy)(values, (_, fieldId) => {
|
2190
|
+
const field2 = fields.find((f) => f.id === fieldId);
|
2191
|
+
if (!field2) {
|
2192
|
+
return true;
|
2193
|
+
}
|
2194
|
+
return !isFieldVisible(field2, values);
|
2195
|
+
});
|
2196
|
+
}
|
2197
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
2198
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
2199
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
2200
|
+
}
|
2201
|
+
function findActiveDrafts(event2, drafts) {
|
2202
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2203
|
+
const lastAction = actions[actions.length - 1];
|
2204
|
+
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
2205
|
+
}
|
2206
|
+
function createEmptyDraft(eventId, draftId, actionType) {
|
2207
|
+
return {
|
2208
|
+
id: draftId,
|
2209
|
+
eventId,
|
2210
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2211
|
+
transactionId: getUUID(),
|
2212
|
+
action: {
|
2213
|
+
type: actionType,
|
2214
|
+
declaration: {},
|
2215
|
+
annotation: {},
|
2216
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2217
|
+
createdBy: "@todo",
|
2218
|
+
createdAtLocation: "@todo"
|
2219
|
+
}
|
2220
|
+
};
|
2221
|
+
}
|
2222
|
+
function isVerificationPage(page) {
|
2223
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
2224
|
+
}
|
2225
|
+
function deepMerge(currentDocument, actionDocument) {
|
2226
|
+
return (0, import_lodash2.mergeWith)(
|
2227
|
+
currentDocument,
|
2228
|
+
actionDocument,
|
2229
|
+
(previousValue, incomingValue) => {
|
2230
|
+
if (incomingValue === void 0) {
|
2231
|
+
return previousValue;
|
2232
|
+
}
|
2233
|
+
if ((0, import_lodash2.isArray)(incomingValue)) {
|
2234
|
+
return incomingValue;
|
2235
|
+
}
|
2236
|
+
if ((0, import_lodash2.isObject)(previousValue) && (0, import_lodash2.isObject)(incomingValue)) {
|
2237
|
+
return void 0;
|
2238
|
+
}
|
2239
|
+
return incomingValue;
|
2240
|
+
}
|
2241
|
+
);
|
2242
|
+
}
|
2243
|
+
function findLastAssignmentAction(actions) {
|
2244
|
+
return actions.filter(
|
2245
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
2246
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
2247
|
+
}
|
2248
|
+
function isWriteAction(actionType) {
|
2249
|
+
return writeActions.safeParse(actionType).success;
|
2250
|
+
}
|
1863
2251
|
|
1864
2252
|
// ../commons/src/events/state/index.ts
|
1865
|
-
var _ = __toESM(require("lodash"));
|
1866
2253
|
function getStatusFromActions(actions) {
|
2254
|
+
const hasRejectedAction = actions.some(
|
2255
|
+
(a) => a.status === ActionStatus.Rejected
|
2256
|
+
);
|
2257
|
+
if (hasRejectedAction) {
|
2258
|
+
return EventStatus.REJECTED;
|
2259
|
+
}
|
1867
2260
|
return actions.reduce((status, action) => {
|
1868
2261
|
if (action.type === ActionType.CREATE) {
|
1869
2262
|
return EventStatus.CREATED;
|
@@ -1900,7 +2293,7 @@ function getAssignedUserFromActions(actions) {
|
|
1900
2293
|
return user2;
|
1901
2294
|
}, null);
|
1902
2295
|
}
|
1903
|
-
function
|
2296
|
+
function aggregateActionDeclarations(actions) {
|
1904
2297
|
const excludedActions = [
|
1905
2298
|
ActionType.REQUEST_CORRECTION,
|
1906
2299
|
ActionType.PRINT_CERTIFICATE
|
@@ -1914,47 +2307,35 @@ function getData(actions) {
|
|
1914
2307
|
if (!requestAction) {
|
1915
2308
|
return status;
|
1916
2309
|
}
|
1917
|
-
return deepMerge(status, requestAction.
|
2310
|
+
return deepMerge(status, requestAction.declaration);
|
1918
2311
|
}
|
1919
|
-
return deepMerge(status, action.
|
2312
|
+
return deepMerge(status, action.declaration);
|
1920
2313
|
}, {});
|
1921
2314
|
}
|
1922
2315
|
function deepDropNulls(obj) {
|
1923
|
-
if (
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
[key]
|
1932
|
-
};
|
1933
|
-
}
|
1934
|
-
return acc;
|
1935
|
-
}, {});
|
1936
|
-
}
|
1937
|
-
function deepMerge(currentDocument, actionDocument) {
|
1938
|
-
return _.mergeWith(
|
1939
|
-
currentDocument,
|
1940
|
-
actionDocument,
|
1941
|
-
(previousValue, incomingValue) => {
|
1942
|
-
if (incomingValue === void 0) {
|
1943
|
-
return previousValue;
|
1944
|
-
}
|
1945
|
-
if (_.isArray(incomingValue)) {
|
1946
|
-
return incomingValue;
|
1947
|
-
}
|
1948
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
1949
|
-
return void 0;
|
2316
|
+
if (Array.isArray(obj)) {
|
2317
|
+
return obj.map(deepDropNulls);
|
2318
|
+
}
|
2319
|
+
if (obj !== null && typeof obj === "object") {
|
2320
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2321
|
+
const cleanedValue = deepDropNulls(value);
|
2322
|
+
if (cleanedValue !== null) {
|
2323
|
+
;
|
2324
|
+
acc[key] = cleanedValue;
|
1950
2325
|
}
|
1951
|
-
return
|
1952
|
-
}
|
1953
|
-
|
2326
|
+
return acc;
|
2327
|
+
}, {});
|
2328
|
+
}
|
2329
|
+
return obj;
|
1954
2330
|
}
|
1955
2331
|
function isUndeclaredDraft(status) {
|
1956
2332
|
return status === EventStatus.CREATED;
|
1957
2333
|
}
|
2334
|
+
function getAcceptedActions(event2) {
|
2335
|
+
return event2.actions.filter(
|
2336
|
+
(a) => a.status === ActionStatus.Accepted
|
2337
|
+
);
|
2338
|
+
}
|
1958
2339
|
function getCurrentEventState(event2) {
|
1959
2340
|
const creationAction = event2.actions.find(
|
1960
2341
|
(action) => action.type === ActionType.CREATE
|
@@ -1962,19 +2343,28 @@ function getCurrentEventState(event2) {
|
|
1962
2343
|
if (!creationAction) {
|
1963
2344
|
throw new Error(`Event ${event2.id} has no creation action`);
|
1964
2345
|
}
|
1965
|
-
const
|
2346
|
+
const activeActions = getAcceptedActions(event2);
|
2347
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2348
|
+
const registrationAction = activeActions.find(
|
2349
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2350
|
+
);
|
2351
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
1966
2352
|
return deepDropNulls({
|
1967
2353
|
id: event2.id,
|
1968
2354
|
type: event2.type,
|
1969
2355
|
status: getStatusFromActions(event2.actions),
|
1970
2356
|
createdAt: event2.createdAt,
|
1971
2357
|
createdBy: creationAction.createdBy,
|
1972
|
-
createdAtLocation: creationAction.createdAtLocation,
|
1973
|
-
|
1974
|
-
|
2358
|
+
createdAtLocation: creationAction.createdAtLocation ?? "",
|
2359
|
+
// @todo remove using empty string
|
2360
|
+
updatedAtLocation: creationAction.updatedAtLocation ?? "",
|
2361
|
+
// @todo remove using empty string
|
2362
|
+
updatedAt: latestAction.createdAt,
|
2363
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
1975
2364
|
updatedBy: latestAction.createdBy,
|
1976
|
-
|
1977
|
-
trackingId: event2.trackingId
|
2365
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2366
|
+
trackingId: event2.trackingId,
|
2367
|
+
registrationNumber
|
1978
2368
|
});
|
1979
2369
|
}
|
1980
2370
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -1999,45 +2389,51 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
|
|
1999
2389
|
return getCurrentEventState(withDrafts);
|
2000
2390
|
}
|
2001
2391
|
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2002
|
-
const indexedAt = eventIndex.
|
2392
|
+
const indexedAt = eventIndex.updatedAt;
|
2003
2393
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2004
2394
|
if (activeDrafts.length === 0) {
|
2005
2395
|
return eventIndex;
|
2006
2396
|
}
|
2007
2397
|
return {
|
2008
2398
|
...eventIndex,
|
2009
|
-
|
2010
|
-
...eventIndex.
|
2011
|
-
...activeDrafts[activeDrafts.length - 1].
|
2399
|
+
declaration: {
|
2400
|
+
...eventIndex.declaration,
|
2401
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2012
2402
|
}
|
2013
2403
|
};
|
2014
2404
|
}
|
2015
|
-
function
|
2405
|
+
function getAnnotationFromDrafts(drafts) {
|
2406
|
+
const actions = drafts.map((draft) => draft.action);
|
2407
|
+
const annotation = actions.reduce((ann, action) => {
|
2408
|
+
return deepMerge(ann, action.annotation ?? {});
|
2409
|
+
}, {});
|
2410
|
+
return deepDropNulls(annotation);
|
2411
|
+
}
|
2412
|
+
function getActionAnnotation({
|
2016
2413
|
event: event2,
|
2017
2414
|
actionType,
|
2018
2415
|
drafts
|
2019
2416
|
}) {
|
2020
|
-
const
|
2417
|
+
const activeActions = getAcceptedActions(event2);
|
2418
|
+
const action = activeActions.find(
|
2419
|
+
(activeAction) => actionType === activeAction.type
|
2420
|
+
);
|
2021
2421
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2022
2422
|
const sorted = [
|
2023
2423
|
...action ? [action] : [],
|
2024
2424
|
...eventDrafts.map((draft) => draft.action)
|
2025
2425
|
].sort();
|
2026
|
-
const
|
2027
|
-
return deepMerge(
|
2426
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2427
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2028
2428
|
}, {});
|
2029
|
-
return deepDropNulls(
|
2429
|
+
return deepDropNulls(annotation);
|
2030
2430
|
}
|
2031
2431
|
|
2032
2432
|
// ../commons/src/events/defineConfig.ts
|
2033
2433
|
var defineConfig = (config) => {
|
2034
2434
|
validateWorkqueueConfig(config.workqueues);
|
2035
|
-
const input =
|
2036
|
-
|
2037
|
-
return EventConfig.parse({
|
2038
|
-
...input,
|
2039
|
-
pageFields
|
2040
|
-
});
|
2435
|
+
const input = EventConfig2.parse(config);
|
2436
|
+
return input;
|
2041
2437
|
};
|
2042
2438
|
|
2043
2439
|
// ../commons/src/events/transactions.ts
|
@@ -2046,12 +2442,22 @@ function generateTransactionId() {
|
|
2046
2442
|
}
|
2047
2443
|
|
2048
2444
|
// ../commons/src/events/test.utils.ts
|
2049
|
-
var
|
2445
|
+
var import_lodash3 = require("lodash");
|
2050
2446
|
|
2051
2447
|
// ../commons/src/conditionals/conditionals.ts
|
2052
2448
|
function defineConditional(schema) {
|
2053
2449
|
return schema;
|
2054
2450
|
}
|
2451
|
+
function defineFormConditional(schema) {
|
2452
|
+
const schemaWithForm = {
|
2453
|
+
type: "object",
|
2454
|
+
properties: {
|
2455
|
+
$form: schema
|
2456
|
+
},
|
2457
|
+
required: ["$form"]
|
2458
|
+
};
|
2459
|
+
return defineConditional(schemaWithForm);
|
2460
|
+
}
|
2055
2461
|
function alwaysTrue() {
|
2056
2462
|
return {};
|
2057
2463
|
}
|
@@ -2076,6 +2482,9 @@ function not(condition) {
|
|
2076
2482
|
required: []
|
2077
2483
|
});
|
2078
2484
|
}
|
2485
|
+
function never() {
|
2486
|
+
return not(alwaysTrue());
|
2487
|
+
}
|
2079
2488
|
var user = {
|
2080
2489
|
hasScope: (scope) => defineConditional({
|
2081
2490
|
type: "object",
|
@@ -2123,69 +2532,120 @@ var event = {
|
|
2123
2532
|
required: ["$event"]
|
2124
2533
|
})
|
2125
2534
|
};
|
2535
|
+
function getDateFromNow(days) {
|
2536
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2537
|
+
}
|
2538
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2539
|
+
return {
|
2540
|
+
type: "object",
|
2541
|
+
properties: {
|
2542
|
+
[fieldId]: {
|
2543
|
+
type: "string",
|
2544
|
+
format: "date",
|
2545
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2546
|
+
},
|
2547
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2548
|
+
},
|
2549
|
+
required: [fieldId]
|
2550
|
+
};
|
2551
|
+
}
|
2552
|
+
function isFieldReference(value) {
|
2553
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2554
|
+
}
|
2126
2555
|
function field(fieldId) {
|
2127
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2128
2556
|
const getDateRange = (date, clause) => ({
|
2129
2557
|
type: "object",
|
2130
2558
|
properties: {
|
2131
|
-
|
2132
|
-
type: "
|
2133
|
-
|
2134
|
-
|
2135
|
-
type: "string",
|
2136
|
-
format: "date",
|
2137
|
-
[clause]: date
|
2138
|
-
}
|
2139
|
-
},
|
2140
|
-
required: [fieldId]
|
2559
|
+
[fieldId]: {
|
2560
|
+
type: "string",
|
2561
|
+
format: "date",
|
2562
|
+
[clause]: date
|
2141
2563
|
}
|
2142
2564
|
},
|
2143
|
-
required: [
|
2565
|
+
required: [fieldId]
|
2144
2566
|
});
|
2145
2567
|
return {
|
2568
|
+
/**
|
2569
|
+
* @private Internal property used for field reference tracking.
|
2570
|
+
*/
|
2571
|
+
_fieldId: fieldId,
|
2146
2572
|
isAfter: () => ({
|
2147
2573
|
days: (days) => ({
|
2148
|
-
inPast: () =>
|
2574
|
+
inPast: () => defineFormConditional(
|
2149
2575
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2150
2576
|
),
|
2151
|
-
inFuture: () =>
|
2577
|
+
inFuture: () => defineFormConditional(
|
2152
2578
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2153
2579
|
)
|
2154
2580
|
}),
|
2155
|
-
date: (date) =>
|
2156
|
-
|
2581
|
+
date: (date) => {
|
2582
|
+
if (isFieldReference(date)) {
|
2583
|
+
const comparedFieldId = date._fieldId;
|
2584
|
+
return defineFormConditional(
|
2585
|
+
getDateRangeToFieldReference(
|
2586
|
+
fieldId,
|
2587
|
+
comparedFieldId,
|
2588
|
+
"formatMinimum"
|
2589
|
+
)
|
2590
|
+
);
|
2591
|
+
}
|
2592
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2593
|
+
},
|
2594
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2157
2595
|
}),
|
2158
2596
|
isBefore: () => ({
|
2159
2597
|
days: (days) => ({
|
2160
|
-
inPast: () =>
|
2598
|
+
inPast: () => defineFormConditional(
|
2161
2599
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2162
2600
|
),
|
2163
|
-
inFuture: () =>
|
2601
|
+
inFuture: () => defineFormConditional(
|
2164
2602
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2165
2603
|
)
|
2166
2604
|
}),
|
2167
|
-
date: (date) =>
|
2168
|
-
|
2605
|
+
date: (date) => {
|
2606
|
+
if (isFieldReference(date)) {
|
2607
|
+
const comparedFieldId = date._fieldId;
|
2608
|
+
return defineFormConditional(
|
2609
|
+
getDateRangeToFieldReference(
|
2610
|
+
fieldId,
|
2611
|
+
comparedFieldId,
|
2612
|
+
"formatMaximum"
|
2613
|
+
)
|
2614
|
+
);
|
2615
|
+
}
|
2616
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2617
|
+
},
|
2618
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2169
2619
|
}),
|
2170
|
-
isEqualTo: (value) =>
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2620
|
+
isEqualTo: (value) => {
|
2621
|
+
if (isFieldReference(value)) {
|
2622
|
+
const comparedFieldId = value._fieldId;
|
2623
|
+
return defineFormConditional({
|
2174
2624
|
type: "object",
|
2175
2625
|
properties: {
|
2176
2626
|
[fieldId]: {
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
const: value
|
2182
|
-
}
|
2627
|
+
type: ["string", "boolean"],
|
2628
|
+
const: { $data: `1/${comparedFieldId}` }
|
2629
|
+
},
|
2630
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2183
2631
|
},
|
2184
|
-
required: [fieldId]
|
2185
|
-
}
|
2186
|
-
}
|
2187
|
-
|
2188
|
-
|
2632
|
+
required: [fieldId, comparedFieldId]
|
2633
|
+
});
|
2634
|
+
}
|
2635
|
+
return defineFormConditional({
|
2636
|
+
type: "object",
|
2637
|
+
properties: {
|
2638
|
+
[fieldId]: {
|
2639
|
+
oneOf: [
|
2640
|
+
{ type: "string", const: value },
|
2641
|
+
{ type: "boolean", const: value }
|
2642
|
+
],
|
2643
|
+
const: value
|
2644
|
+
}
|
2645
|
+
},
|
2646
|
+
required: [fieldId]
|
2647
|
+
});
|
2648
|
+
},
|
2189
2649
|
/**
|
2190
2650
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2191
2651
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2194,91 +2654,150 @@ function field(fieldId) {
|
|
2194
2654
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2195
2655
|
*
|
2196
2656
|
*/
|
2197
|
-
isFalsy: () =>
|
2657
|
+
isFalsy: () => defineFormConditional({
|
2198
2658
|
type: "object",
|
2199
2659
|
properties: {
|
2200
|
-
|
2201
|
-
type: "object",
|
2202
|
-
properties: {
|
2203
|
-
[fieldId]: {
|
2204
|
-
anyOf: [
|
2205
|
-
{ const: "undefined" },
|
2206
|
-
{ const: false },
|
2207
|
-
{ const: null },
|
2208
|
-
{ const: "" }
|
2209
|
-
]
|
2210
|
-
}
|
2211
|
-
},
|
2660
|
+
[fieldId]: {
|
2212
2661
|
anyOf: [
|
2213
|
-
{
|
2214
|
-
|
2215
|
-
},
|
2216
|
-
{
|
2217
|
-
not: {
|
2218
|
-
required: [fieldId]
|
2219
|
-
}
|
2220
|
-
}
|
2662
|
+
{ const: "undefined" },
|
2663
|
+
{ const: false },
|
2664
|
+
{ const: null },
|
2665
|
+
{ const: "" }
|
2221
2666
|
]
|
2222
2667
|
}
|
2223
2668
|
},
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
$form: {
|
2230
|
-
type: "object",
|
2231
|
-
properties: {
|
2232
|
-
[fieldId]: {
|
2233
|
-
type: "string",
|
2234
|
-
enum: ["undefined"]
|
2235
|
-
}
|
2236
|
-
},
|
2669
|
+
anyOf: [
|
2670
|
+
{
|
2671
|
+
required: [fieldId]
|
2672
|
+
},
|
2673
|
+
{
|
2237
2674
|
not: {
|
2238
2675
|
required: [fieldId]
|
2239
2676
|
}
|
2240
2677
|
}
|
2678
|
+
]
|
2679
|
+
}),
|
2680
|
+
isUndefined: () => defineFormConditional({
|
2681
|
+
type: "object",
|
2682
|
+
properties: {
|
2683
|
+
[fieldId]: {
|
2684
|
+
type: "string",
|
2685
|
+
enum: ["undefined"]
|
2686
|
+
}
|
2687
|
+
},
|
2688
|
+
not: {
|
2689
|
+
required: [fieldId]
|
2690
|
+
}
|
2691
|
+
}),
|
2692
|
+
inArray: (values) => defineFormConditional({
|
2693
|
+
type: "object",
|
2694
|
+
properties: {
|
2695
|
+
[fieldId]: {
|
2696
|
+
type: "string",
|
2697
|
+
enum: values
|
2698
|
+
}
|
2241
2699
|
},
|
2242
|
-
required: [
|
2700
|
+
required: [fieldId]
|
2243
2701
|
}),
|
2244
|
-
|
2702
|
+
isValidEnglishName: () => defineFormConditional({
|
2245
2703
|
type: "object",
|
2246
2704
|
properties: {
|
2247
|
-
|
2248
|
-
type: "
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2705
|
+
[fieldId]: {
|
2706
|
+
type: "string",
|
2707
|
+
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'._-]*)*$",
|
2708
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2709
|
+
}
|
2710
|
+
},
|
2711
|
+
required: [fieldId]
|
2712
|
+
}),
|
2713
|
+
/**
|
2714
|
+
* Checks if the field value matches a given regular expression pattern.
|
2715
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2716
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2717
|
+
*/
|
2718
|
+
matches: (pattern) => defineFormConditional({
|
2719
|
+
type: "object",
|
2720
|
+
properties: {
|
2721
|
+
[fieldId]: {
|
2722
|
+
type: "string",
|
2723
|
+
pattern
|
2724
|
+
}
|
2725
|
+
},
|
2726
|
+
required: [fieldId]
|
2727
|
+
}),
|
2728
|
+
isBetween: (min, max) => defineFormConditional({
|
2729
|
+
type: "object",
|
2730
|
+
properties: {
|
2731
|
+
[fieldId]: {
|
2732
|
+
type: "number",
|
2733
|
+
minimum: min,
|
2734
|
+
maximum: max
|
2256
2735
|
}
|
2257
2736
|
},
|
2258
|
-
required: [
|
2737
|
+
required: [fieldId]
|
2738
|
+
}),
|
2739
|
+
/**
|
2740
|
+
* Creates a range configuration for the specified field.
|
2741
|
+
*
|
2742
|
+
* @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
|
2743
|
+
*
|
2744
|
+
* @example field('age').range()
|
2745
|
+
* // {
|
2746
|
+
* // fieldId: 'age',
|
2747
|
+
* // config: { type: 'RANGE' }
|
2748
|
+
* // }
|
2749
|
+
*/
|
2750
|
+
range: () => ({
|
2751
|
+
fieldId,
|
2752
|
+
config: { type: "RANGE" }
|
2753
|
+
}),
|
2754
|
+
/**
|
2755
|
+
* Creates a configuration for exact matching of the specified field.
|
2756
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2757
|
+
* @example field('dob').exact()
|
2758
|
+
* // {
|
2759
|
+
* // fieldId: 'dob',
|
2760
|
+
* // config: { type: 'EXACT' }
|
2761
|
+
* // }
|
2762
|
+
*/
|
2763
|
+
exact: () => ({
|
2764
|
+
fieldId,
|
2765
|
+
config: { type: "EXACT" }
|
2766
|
+
}),
|
2767
|
+
/**
|
2768
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
2769
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2770
|
+
* @example field('name').fuzzy()
|
2771
|
+
* // {
|
2772
|
+
* // fieldId: 'name',
|
2773
|
+
* // config: { type: 'FUZZY' }
|
2774
|
+
* // }
|
2775
|
+
*/
|
2776
|
+
fuzzy: () => ({
|
2777
|
+
fieldId,
|
2778
|
+
config: { type: "FUZZY" }
|
2259
2779
|
})
|
2260
2780
|
};
|
2261
2781
|
}
|
2782
|
+
function eventField(fieldId, options) {
|
2783
|
+
return {
|
2784
|
+
fieldId,
|
2785
|
+
options,
|
2786
|
+
config: { type: "EXACT" }
|
2787
|
+
};
|
2788
|
+
}
|
2262
2789
|
|
2263
2790
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2264
|
-
var PRINT_CERTIFICATE_FORM =
|
2791
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2265
2792
|
label: {
|
2266
2793
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2267
2794
|
defaultMessage: "Tennis club membership certificate collector",
|
2268
2795
|
description: "This is what this form is referred as in the system"
|
2269
2796
|
},
|
2270
|
-
version: {
|
2271
|
-
id: "1.0.0",
|
2272
|
-
label: {
|
2273
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2274
|
-
defaultMessage: "Version 1",
|
2275
|
-
description: "This is the first version of the form"
|
2276
|
-
}
|
2277
|
-
},
|
2278
|
-
active: true,
|
2279
2797
|
pages: [
|
2280
2798
|
{
|
2281
2799
|
id: "collector",
|
2800
|
+
type: PageTypes.enum.FORM,
|
2282
2801
|
title: {
|
2283
2802
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2284
2803
|
defaultMessage: "Print certified copy",
|
@@ -2293,7 +2812,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2293
2812
|
defaultMessage: "Requester",
|
2294
2813
|
description: "This is the label for the field"
|
2295
2814
|
},
|
2296
|
-
type:
|
2815
|
+
type: FieldType.SELECT,
|
2297
2816
|
options: [
|
2298
2817
|
{
|
2299
2818
|
value: "INFORMANT",
|
@@ -2370,7 +2889,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2370
2889
|
defaultMessage: "Select Type of ID",
|
2371
2890
|
description: "This is the label for selecting the type of ID"
|
2372
2891
|
},
|
2373
|
-
type:
|
2892
|
+
type: FieldType.SELECT,
|
2374
2893
|
options: [
|
2375
2894
|
{
|
2376
2895
|
value: "PASSPORT",
|
@@ -2471,7 +2990,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2471
2990
|
defaultMessage: "Passport Details",
|
2472
2991
|
description: "Field for entering Passport details"
|
2473
2992
|
},
|
2474
|
-
type:
|
2993
|
+
type: FieldType.TEXT
|
2475
2994
|
},
|
2476
2995
|
{
|
2477
2996
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2522,7 +3041,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2522
3041
|
defaultMessage: "Driving License Details",
|
2523
3042
|
description: "Field for entering Driving License details"
|
2524
3043
|
},
|
2525
|
-
type:
|
3044
|
+
type: FieldType.TEXT
|
2526
3045
|
},
|
2527
3046
|
{
|
2528
3047
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2573,7 +3092,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2573
3092
|
defaultMessage: "Refugee Number Details",
|
2574
3093
|
description: "Field for entering Refugee Number details"
|
2575
3094
|
},
|
2576
|
-
type:
|
3095
|
+
type: FieldType.TEXT
|
2577
3096
|
},
|
2578
3097
|
{
|
2579
3098
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2624,7 +3143,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2624
3143
|
defaultMessage: "Alien Number Details",
|
2625
3144
|
description: "Field for entering Alien Number details"
|
2626
3145
|
},
|
2627
|
-
type:
|
3146
|
+
type: FieldType.TEXT
|
2628
3147
|
},
|
2629
3148
|
{
|
2630
3149
|
id: "collector.OTHER.idTypeOther",
|
@@ -2675,7 +3194,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2675
3194
|
defaultMessage: "Other ID Type (if applicable)",
|
2676
3195
|
description: 'Field for entering ID type if "Other" is selected'
|
2677
3196
|
},
|
2678
|
-
type:
|
3197
|
+
type: FieldType.TEXT
|
2679
3198
|
},
|
2680
3199
|
{
|
2681
3200
|
id: "collector.OTHER.firstName",
|
@@ -2726,7 +3245,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2726
3245
|
defaultMessage: "First Name",
|
2727
3246
|
description: "This is the label for the first name field"
|
2728
3247
|
},
|
2729
|
-
type:
|
3248
|
+
type: FieldType.TEXT
|
2730
3249
|
},
|
2731
3250
|
{
|
2732
3251
|
id: "collector.OTHER.lastName",
|
@@ -2777,7 +3296,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2777
3296
|
defaultMessage: "Last Name",
|
2778
3297
|
description: "This is the label for the last name field"
|
2779
3298
|
},
|
2780
|
-
type:
|
3299
|
+
type: FieldType.TEXT
|
2781
3300
|
},
|
2782
3301
|
{
|
2783
3302
|
id: "collector.OTHER.relationshipToMember",
|
@@ -2828,7 +3347,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2828
3347
|
defaultMessage: "Relationship to Member",
|
2829
3348
|
description: "This is the label for the relationship to member field"
|
2830
3349
|
},
|
2831
|
-
type:
|
3350
|
+
type: FieldType.TEXT
|
2832
3351
|
},
|
2833
3352
|
{
|
2834
3353
|
id: "collector.OTHER.signedAffidavit",
|
@@ -2879,66 +3398,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2879
3398
|
defaultMessage: "Signed Affidavit (Optional)",
|
2880
3399
|
description: "This is the label for uploading a signed affidavit"
|
2881
3400
|
},
|
2882
|
-
type:
|
3401
|
+
type: FieldType.FILE
|
2883
3402
|
}
|
2884
3403
|
]
|
2885
|
-
}
|
2886
|
-
],
|
2887
|
-
review: {
|
2888
|
-
title: {
|
2889
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
2890
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
2891
|
-
description: "Title of the form to show in review page"
|
2892
3404
|
},
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
3405
|
+
{
|
3406
|
+
id: "collector.identity.verify",
|
3407
|
+
type: PageTypes.enum.VERIFICATION,
|
3408
|
+
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3409
|
+
title: {
|
3410
|
+
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
3411
|
+
defaultMessage: "Verify their identity",
|
3412
|
+
description: "This is the title of the section"
|
3413
|
+
},
|
3414
|
+
fields: [],
|
3415
|
+
actions: {
|
3416
|
+
verify: {
|
3417
|
+
label: {
|
3418
|
+
defaultMessage: "Verified",
|
3419
|
+
description: "This is the label for the verification button",
|
3420
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.verify"
|
3421
|
+
}
|
3422
|
+
},
|
3423
|
+
cancel: {
|
3424
|
+
label: {
|
3425
|
+
defaultMessage: "Identity does not match",
|
3426
|
+
description: "This is the label for the verification cancellation button",
|
3427
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
|
3428
|
+
},
|
3429
|
+
confirmation: {
|
3430
|
+
title: {
|
3431
|
+
defaultMessage: "Print without proof of ID?",
|
3432
|
+
description: "This is the title for the verification cancellation modal",
|
3433
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
|
3434
|
+
},
|
3435
|
+
body: {
|
3436
|
+
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",
|
3437
|
+
description: "This is the body for the verification cancellation modal",
|
3438
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
|
3439
|
+
}
|
3440
|
+
}
|
3441
|
+
}
|
3442
|
+
}
|
2909
3443
|
}
|
3444
|
+
]
|
3445
|
+
});
|
3446
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3447
|
+
title: {
|
3448
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3449
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3450
|
+
description: "Title of the review page"
|
2910
3451
|
},
|
2911
|
-
|
2912
|
-
|
2913
|
-
id: "
|
2914
|
-
|
2915
|
-
|
3452
|
+
fields: [
|
3453
|
+
{
|
3454
|
+
id: "review.comment",
|
3455
|
+
type: FieldType.TEXTAREA,
|
3456
|
+
label: {
|
3457
|
+
defaultMessage: "Comment",
|
3458
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3459
|
+
description: "Label for the comment field in the review section"
|
3460
|
+
}
|
2916
3461
|
},
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
description: "Label for the comment field in the review section"
|
2925
|
-
}
|
3462
|
+
{
|
3463
|
+
type: FieldType.SIGNATURE,
|
3464
|
+
id: "review.signature",
|
3465
|
+
label: {
|
3466
|
+
defaultMessage: "Signature of informant",
|
3467
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3468
|
+
description: "Label for the signature field in the review section"
|
2926
3469
|
},
|
2927
|
-
{
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
defaultMessage: "Signature of informant",
|
2932
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
2933
|
-
description: "Label for the signature field in the review section"
|
2934
|
-
},
|
2935
|
-
signaturePromptLabel: {
|
2936
|
-
id: "v2.signature.upload.modal.title",
|
2937
|
-
defaultMessage: "Draw signature",
|
2938
|
-
description: "Title for the modal to draw signature"
|
2939
|
-
}
|
3470
|
+
signaturePromptLabel: {
|
3471
|
+
id: "v2.signature.upload.modal.title",
|
3472
|
+
defaultMessage: "Draw signature",
|
3473
|
+
description: "Title for the modal to draw signature"
|
2940
3474
|
}
|
2941
|
-
|
3475
|
+
}
|
3476
|
+
]
|
3477
|
+
};
|
3478
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3479
|
+
label: {
|
3480
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3481
|
+
defaultMessage: "Tennis club membership application",
|
3482
|
+
description: "This is what this form is referred as in the system"
|
2942
3483
|
},
|
2943
3484
|
pages: [
|
2944
3485
|
{
|
@@ -2951,7 +3492,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2951
3492
|
fields: [
|
2952
3493
|
{
|
2953
3494
|
id: "applicant.firstname",
|
2954
|
-
type:
|
3495
|
+
type: FieldType.TEXT,
|
2955
3496
|
required: true,
|
2956
3497
|
conditionals: [],
|
2957
3498
|
label: {
|
@@ -2962,7 +3503,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2962
3503
|
},
|
2963
3504
|
{
|
2964
3505
|
id: "applicant.surname",
|
2965
|
-
type:
|
3506
|
+
type: FieldType.TEXT,
|
2966
3507
|
required: true,
|
2967
3508
|
conditionals: [],
|
2968
3509
|
label: {
|
@@ -2984,9 +3525,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2984
3525
|
},
|
2985
3526
|
{
|
2986
3527
|
id: "applicant.dob",
|
2987
|
-
type:
|
3528
|
+
type: FieldType.DATE,
|
2988
3529
|
required: true,
|
2989
|
-
conditionals: [],
|
2990
3530
|
validation: [
|
2991
3531
|
{
|
2992
3532
|
message: {
|
@@ -2997,15 +3537,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2997
3537
|
validator: field("applicant.dob").isBefore().now()
|
2998
3538
|
}
|
2999
3539
|
],
|
3540
|
+
conditionals: [
|
3541
|
+
{
|
3542
|
+
type: ConditionalType.SHOW,
|
3543
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3544
|
+
}
|
3545
|
+
],
|
3000
3546
|
label: {
|
3001
3547
|
defaultMessage: "Applicant's date of birth",
|
3002
3548
|
description: "This is the label for the field",
|
3003
3549
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3004
3550
|
}
|
3005
3551
|
},
|
3552
|
+
{
|
3553
|
+
id: "applicant.dobUnknown",
|
3554
|
+
type: FieldType.CHECKBOX,
|
3555
|
+
required: false,
|
3556
|
+
label: {
|
3557
|
+
defaultMessage: "Exact date of birth unknown",
|
3558
|
+
description: "This is the label for the field",
|
3559
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3560
|
+
},
|
3561
|
+
conditionals: [
|
3562
|
+
{
|
3563
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3564
|
+
conditional: never()
|
3565
|
+
}
|
3566
|
+
]
|
3567
|
+
},
|
3568
|
+
{
|
3569
|
+
id: "applicant.age",
|
3570
|
+
type: FieldType.NUMBER,
|
3571
|
+
required: true,
|
3572
|
+
label: {
|
3573
|
+
defaultMessage: "Age of tennis-member",
|
3574
|
+
description: "This is the label for the field",
|
3575
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3576
|
+
},
|
3577
|
+
conditionals: [
|
3578
|
+
{
|
3579
|
+
type: ConditionalType.SHOW,
|
3580
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3581
|
+
}
|
3582
|
+
]
|
3583
|
+
},
|
3006
3584
|
{
|
3007
3585
|
id: "applicant.image",
|
3008
|
-
type:
|
3586
|
+
type: FieldType.FILE,
|
3009
3587
|
required: false,
|
3010
3588
|
label: {
|
3011
3589
|
defaultMessage: "Applicant's profile picture",
|
@@ -3026,6 +3604,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3026
3604
|
}
|
3027
3605
|
]
|
3028
3606
|
},
|
3607
|
+
{
|
3608
|
+
id: "senior-pass",
|
3609
|
+
conditional: field("applicant.dob").isBefore().date("1950-01-01"),
|
3610
|
+
title: {
|
3611
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
|
3612
|
+
defaultMessage: "Assign senior pass for applicant",
|
3613
|
+
description: "This is the title of the section"
|
3614
|
+
},
|
3615
|
+
fields: [
|
3616
|
+
{
|
3617
|
+
id: "senior-pass.id",
|
3618
|
+
type: FieldType.TEXT,
|
3619
|
+
required: true,
|
3620
|
+
label: {
|
3621
|
+
defaultMessage: "Senior pass ID",
|
3622
|
+
description: "This is the label for the field",
|
3623
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
|
3624
|
+
}
|
3625
|
+
}
|
3626
|
+
]
|
3627
|
+
},
|
3029
3628
|
{
|
3030
3629
|
id: "recommender",
|
3031
3630
|
title: {
|
@@ -3047,7 +3646,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3047
3646
|
},
|
3048
3647
|
{
|
3049
3648
|
id: "recommender.firstname",
|
3050
|
-
type:
|
3649
|
+
type: FieldType.TEXT,
|
3051
3650
|
required: true,
|
3052
3651
|
conditionals: [
|
3053
3652
|
{
|
@@ -3063,7 +3662,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3063
3662
|
},
|
3064
3663
|
{
|
3065
3664
|
id: "recommender.surname",
|
3066
|
-
type:
|
3665
|
+
type: FieldType.TEXT,
|
3067
3666
|
required: true,
|
3068
3667
|
conditionals: [
|
3069
3668
|
{
|
@@ -3079,7 +3678,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3079
3678
|
},
|
3080
3679
|
{
|
3081
3680
|
id: "recommender.id",
|
3082
|
-
type:
|
3681
|
+
type: FieldType.TEXT,
|
3083
3682
|
required: true,
|
3084
3683
|
conditionals: [
|
3085
3684
|
{
|
@@ -3187,7 +3786,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3187
3786
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3188
3787
|
id: "event.tennis-club-membership.action.declare.label"
|
3189
3788
|
},
|
3190
|
-
|
3789
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3191
3790
|
},
|
3192
3791
|
{
|
3193
3792
|
type: ActionType.VALIDATE,
|
@@ -3196,7 +3795,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3196
3795
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3197
3796
|
id: "event.tennis-club-membership.action.validate.label"
|
3198
3797
|
},
|
3199
|
-
|
3798
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3200
3799
|
},
|
3201
3800
|
{
|
3202
3801
|
type: ActionType.REGISTER,
|
@@ -3205,7 +3804,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3205
3804
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3206
3805
|
id: "event.tennis-club-membership.action.register.label"
|
3207
3806
|
},
|
3208
|
-
|
3807
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3209
3808
|
},
|
3210
3809
|
{
|
3211
3810
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3214,10 +3813,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3214
3813
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3215
3814
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3216
3815
|
},
|
3217
|
-
forms: [TENNIS_CLUB_FORM],
|
3218
3816
|
onboardingForm: [
|
3219
3817
|
{
|
3220
3818
|
id: "correction-requester",
|
3819
|
+
type: PageTypes.enum.FORM,
|
3221
3820
|
title: {
|
3222
3821
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3223
3822
|
defaultMessage: "Correction requester",
|
@@ -3281,6 +3880,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3281
3880
|
},
|
3282
3881
|
{
|
3283
3882
|
id: "identity-check",
|
3883
|
+
type: PageTypes.enum.FORM,
|
3284
3884
|
title: {
|
3285
3885
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3286
3886
|
defaultMessage: "Verify their identity",
|
@@ -3323,6 +3923,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3323
3923
|
additionalDetailsForm: [
|
3324
3924
|
{
|
3325
3925
|
id: "correction-request.supporting-documents",
|
3926
|
+
type: PageTypes.enum.FORM,
|
3326
3927
|
title: {
|
3327
3928
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3328
3929
|
defaultMessage: "Upload supporting documents",
|
@@ -3340,7 +3941,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3340
3941
|
},
|
3341
3942
|
{
|
3342
3943
|
id: "correction.supportingDocs",
|
3343
|
-
type:
|
3944
|
+
type: FieldType.FILE,
|
3344
3945
|
label: {
|
3345
3946
|
id: "correction.corrector.title",
|
3346
3947
|
defaultMessage: "Upload supporting documents",
|
@@ -3384,6 +3985,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3384
3985
|
},
|
3385
3986
|
{
|
3386
3987
|
id: "correction-request.additional-details",
|
3988
|
+
type: PageTypes.enum.FORM,
|
3387
3989
|
title: {
|
3388
3990
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3389
3991
|
defaultMessage: "Reason for correction",
|
@@ -3392,7 +3994,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3392
3994
|
fields: [
|
3393
3995
|
{
|
3394
3996
|
id: "correction.request.reason",
|
3395
|
-
type:
|
3997
|
+
type: FieldType.TEXT,
|
3396
3998
|
label: {
|
3397
3999
|
id: "correction.reason.title",
|
3398
4000
|
defaultMessage: "Reason for correction?",
|
@@ -3405,7 +4007,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3405
4007
|
},
|
3406
4008
|
{
|
3407
4009
|
type: ActionType.APPROVE_CORRECTION,
|
3408
|
-
forms: [TENNIS_CLUB_FORM],
|
3409
4010
|
label: {
|
3410
4011
|
defaultMessage: "Approve correction",
|
3411
4012
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3419,7 +4020,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3419
4020
|
defaultMessage: "Print certificate",
|
3420
4021
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3421
4022
|
},
|
3422
|
-
|
4023
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3423
4024
|
conditionals: [
|
3424
4025
|
{
|
3425
4026
|
type: "SHOW",
|
@@ -3466,8 +4067,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3466
4067
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3467
4068
|
defaultMessage: "Archive",
|
3468
4069
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3469
|
-
}
|
3470
|
-
forms: [TENNIS_CLUB_FORM]
|
4070
|
+
}
|
3471
4071
|
},
|
3472
4072
|
{
|
3473
4073
|
type: ActionType.REJECT,
|
@@ -3475,8 +4075,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3475
4075
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3476
4076
|
defaultMessage: "Reject",
|
3477
4077
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3478
|
-
}
|
3479
|
-
forms: [TENNIS_CLUB_FORM]
|
4078
|
+
}
|
3480
4079
|
}
|
3481
4080
|
],
|
3482
4081
|
advancedSearch: [
|
@@ -3486,26 +4085,55 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3486
4085
|
description: "This is what this event is referred as in the system",
|
3487
4086
|
id: "v2.event.tennis-club-membership.search"
|
3488
4087
|
},
|
3489
|
-
fields: [
|
3490
|
-
{
|
3491
|
-
fieldId: "applicant.dob"
|
3492
|
-
}
|
3493
|
-
]
|
4088
|
+
fields: [field("applicant.dob").exact()]
|
3494
4089
|
}
|
3495
|
-
]
|
4090
|
+
],
|
4091
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3496
4092
|
});
|
3497
4093
|
|
3498
4094
|
// ../commons/src/events/test.utils.ts
|
3499
|
-
function
|
3500
|
-
|
3501
|
-
const data = fields.reduce(
|
4095
|
+
function fieldConfigsToActionPayload(fields) {
|
4096
|
+
return fields.reduce(
|
3502
4097
|
(acc, field2, i) => ({
|
3503
4098
|
...acc,
|
3504
4099
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3505
4100
|
}),
|
3506
4101
|
{}
|
3507
4102
|
);
|
3508
|
-
|
4103
|
+
}
|
4104
|
+
function generateActionDeclarationInput(configuration, action) {
|
4105
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
4106
|
+
if (parsed.success) {
|
4107
|
+
const fields = getDeclarationFields(configuration);
|
4108
|
+
const declarationConfig = getDeclaration(configuration);
|
4109
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4110
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
4111
|
+
}
|
4112
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
4113
|
+
return {};
|
4114
|
+
}
|
4115
|
+
function generateActionAnnotationInput(configuration, action) {
|
4116
|
+
const actionConfig = configuration.actions.find(
|
4117
|
+
(ac) => ac.type === action
|
4118
|
+
);
|
4119
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4120
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4121
|
+
const visibleVerificationPageIds = findRecordActionPages(
|
4122
|
+
configuration,
|
4123
|
+
action
|
4124
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
4125
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
4126
|
+
(acc, pageId) => ({
|
4127
|
+
...acc,
|
4128
|
+
[pageId]: true
|
4129
|
+
}),
|
4130
|
+
{}
|
4131
|
+
);
|
4132
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4133
|
+
return {
|
4134
|
+
...fieldBasedPayload,
|
4135
|
+
...visiblePageVerificationMap
|
4136
|
+
};
|
3509
4137
|
}
|
3510
4138
|
var eventPayloadGenerator = {
|
3511
4139
|
create: (input = {}) => ({
|
@@ -3517,27 +4145,29 @@ var eventPayloadGenerator = {
|
|
3517
4145
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3518
4146
|
id
|
3519
4147
|
}),
|
3520
|
-
draft: (eventId, input = {}) => (0,
|
4148
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash3.merge)(
|
3521
4149
|
{
|
3522
4150
|
id: getUUID(),
|
3523
4151
|
eventId,
|
3524
4152
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3525
4153
|
transactionId: getUUID(),
|
3526
4154
|
action: {
|
3527
|
-
type:
|
3528
|
-
|
4155
|
+
type: actionType,
|
4156
|
+
status: ActionStatus.Accepted,
|
4157
|
+
declaration: {
|
3529
4158
|
"applicant.firstname": "Max",
|
3530
4159
|
"applicant.surname": "McLaren",
|
3531
4160
|
"applicant.dob": "2020-01-02",
|
3532
4161
|
"recommender.none": true
|
3533
4162
|
},
|
3534
|
-
|
4163
|
+
annotation: {
|
3535
4164
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3536
4165
|
"correction.request.reason": "Child's name was incorrect"
|
3537
4166
|
},
|
3538
4167
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3539
4168
|
createdBy: "@todo",
|
3540
|
-
createdAtLocation: "@todo"
|
4169
|
+
createdAtLocation: "@todo",
|
4170
|
+
updatedAtLocation: "@todo"
|
3541
4171
|
}
|
3542
4172
|
},
|
3543
4173
|
input
|
@@ -3546,41 +4176,104 @@ var eventPayloadGenerator = {
|
|
3546
4176
|
declare: (eventId, input = {}) => ({
|
3547
4177
|
type: ActionType.DECLARE,
|
3548
4178
|
transactionId: input.transactionId ?? getUUID(),
|
3549
|
-
|
4179
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4180
|
+
tennisClubMembershipEvent,
|
4181
|
+
ActionType.DECLARE
|
4182
|
+
),
|
4183
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4184
|
+
tennisClubMembershipEvent,
|
4185
|
+
ActionType.DECLARE
|
4186
|
+
),
|
3550
4187
|
eventId
|
3551
4188
|
}),
|
4189
|
+
/**
|
4190
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4191
|
+
*/
|
4192
|
+
notify: (eventId, input = {}) => {
|
4193
|
+
let declaration = input.declaration;
|
4194
|
+
if (!declaration) {
|
4195
|
+
const partialDeclaration = (0, import_lodash3.omitBy)(
|
4196
|
+
generateActionDeclarationInput(
|
4197
|
+
tennisClubMembershipEvent,
|
4198
|
+
ActionType.DECLARE
|
4199
|
+
),
|
4200
|
+
import_lodash3.isString
|
4201
|
+
);
|
4202
|
+
declaration = partialDeclaration;
|
4203
|
+
}
|
4204
|
+
return {
|
4205
|
+
type: ActionType.NOTIFY,
|
4206
|
+
transactionId: input.transactionId ?? getUUID(),
|
4207
|
+
declaration,
|
4208
|
+
eventId
|
4209
|
+
};
|
4210
|
+
},
|
3552
4211
|
validate: (eventId, input = {}) => ({
|
3553
4212
|
type: ActionType.VALIDATE,
|
3554
4213
|
transactionId: input.transactionId ?? getUUID(),
|
3555
|
-
|
4214
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4215
|
+
tennisClubMembershipEvent,
|
4216
|
+
ActionType.VALIDATE
|
4217
|
+
),
|
4218
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4219
|
+
tennisClubMembershipEvent,
|
4220
|
+
ActionType.VALIDATE
|
4221
|
+
),
|
3556
4222
|
duplicates: [],
|
3557
4223
|
eventId
|
3558
4224
|
}),
|
4225
|
+
assign: (eventId, input = {}) => ({
|
4226
|
+
type: ActionType.ASSIGN,
|
4227
|
+
transactionId: input.transactionId ?? getUUID(),
|
4228
|
+
declaration: {},
|
4229
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4230
|
+
eventId
|
4231
|
+
}),
|
4232
|
+
unassign: (eventId, input = {}) => ({
|
4233
|
+
type: ActionType.UNASSIGN,
|
4234
|
+
transactionId: input.transactionId ?? getUUID(),
|
4235
|
+
declaration: {},
|
4236
|
+
assignedTo: null,
|
4237
|
+
eventId
|
4238
|
+
}),
|
3559
4239
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3560
4240
|
type: ActionType.ARCHIVE,
|
3561
4241
|
transactionId: input.transactionId ?? getUUID(),
|
3562
|
-
|
3563
|
-
|
4242
|
+
declaration: {},
|
4243
|
+
// @TODO: Check whether generator is needed?
|
4244
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3564
4245
|
duplicates: [],
|
3565
4246
|
eventId
|
3566
4247
|
}),
|
3567
4248
|
reject: (eventId, input = {}) => ({
|
3568
4249
|
type: ActionType.REJECT,
|
3569
4250
|
transactionId: input.transactionId ?? getUUID(),
|
3570
|
-
|
4251
|
+
declaration: {},
|
4252
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4253
|
+
tennisClubMembershipEvent,
|
4254
|
+
ActionType.REJECT
|
4255
|
+
),
|
3571
4256
|
duplicates: [],
|
3572
4257
|
eventId
|
3573
4258
|
}),
|
3574
4259
|
register: (eventId, input = {}) => ({
|
3575
4260
|
type: ActionType.REGISTER,
|
3576
4261
|
transactionId: input.transactionId ?? getUUID(),
|
3577
|
-
|
4262
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4263
|
+
tennisClubMembershipEvent,
|
4264
|
+
ActionType.REGISTER
|
4265
|
+
),
|
4266
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4267
|
+
tennisClubMembershipEvent,
|
4268
|
+
ActionType.REGISTER
|
4269
|
+
),
|
3578
4270
|
eventId
|
3579
4271
|
}),
|
3580
4272
|
printCertificate: (eventId, input = {}) => ({
|
3581
4273
|
type: ActionType.PRINT_CERTIFICATE,
|
3582
4274
|
transactionId: input.transactionId ?? getUUID(),
|
3583
|
-
|
4275
|
+
declaration: {},
|
4276
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3584
4277
|
tennisClubMembershipEvent,
|
3585
4278
|
ActionType.PRINT_CERTIFICATE
|
3586
4279
|
),
|
@@ -3590,17 +4283,21 @@ var eventPayloadGenerator = {
|
|
3590
4283
|
request: (eventId, input = {}) => ({
|
3591
4284
|
type: ActionType.REQUEST_CORRECTION,
|
3592
4285
|
transactionId: input.transactionId ?? getUUID(),
|
3593
|
-
|
4286
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4287
|
+
tennisClubMembershipEvent,
|
4288
|
+
ActionType.REQUEST_CORRECTION
|
4289
|
+
),
|
4290
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3594
4291
|
tennisClubMembershipEvent,
|
3595
4292
|
ActionType.REQUEST_CORRECTION
|
3596
4293
|
),
|
3597
|
-
metadata: {},
|
3598
4294
|
eventId
|
3599
4295
|
}),
|
3600
4296
|
approve: (eventId, requestId, input = {}) => ({
|
3601
4297
|
type: ActionType.APPROVE_CORRECTION,
|
3602
4298
|
transactionId: input.transactionId ?? getUUID(),
|
3603
|
-
|
4299
|
+
declaration: {},
|
4300
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3604
4301
|
tennisClubMembershipEvent,
|
3605
4302
|
ActionType.APPROVE_CORRECTION
|
3606
4303
|
),
|
@@ -3610,7 +4307,8 @@ var eventPayloadGenerator = {
|
|
3610
4307
|
reject: (eventId, requestId, input = {}) => ({
|
3611
4308
|
type: ActionType.REJECT_CORRECTION,
|
3612
4309
|
transactionId: input.transactionId ?? getUUID(),
|
3613
|
-
|
4310
|
+
declaration: {},
|
4311
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3614
4312
|
tennisClubMembershipEvent,
|
3615
4313
|
ActionType.REJECT_CORRECTION
|
3616
4314
|
),
|
@@ -3626,19 +4324,27 @@ function generateActionDocument({
|
|
3626
4324
|
defaults = {}
|
3627
4325
|
}) {
|
3628
4326
|
const actionBase = {
|
4327
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4328
|
+
// @TODO: This should be fixed in the future.
|
3629
4329
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
3630
4330
|
createdBy: getUUID(),
|
3631
4331
|
id: getUUID(),
|
3632
4332
|
createdAtLocation: "TODO",
|
3633
|
-
|
3634
|
-
|
3635
|
-
|
4333
|
+
updatedAtLocation: "TODO",
|
4334
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4335
|
+
annotation: {},
|
4336
|
+
...defaults,
|
4337
|
+
status: ActionStatus.Accepted
|
3636
4338
|
};
|
3637
4339
|
switch (action) {
|
4340
|
+
case ActionType.READ:
|
4341
|
+
return { ...actionBase, type: action };
|
4342
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4343
|
+
return { ...actionBase, type: action };
|
3638
4344
|
case ActionType.DECLARE:
|
3639
4345
|
return { ...actionBase, type: action };
|
3640
4346
|
case ActionType.UNASSIGN:
|
3641
|
-
return { ...actionBase, type: action };
|
4347
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3642
4348
|
case ActionType.ASSIGN:
|
3643
4349
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3644
4350
|
case ActionType.VALIDATE:
|
@@ -3659,14 +4365,13 @@ function generateActionDocument({
|
|
3659
4365
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3660
4366
|
case ActionType.REJECT_CORRECTION:
|
3661
4367
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3662
|
-
case ActionType.CUSTOM:
|
3663
|
-
return { ...actionBase, type: action };
|
3664
4368
|
case ActionType.REGISTER:
|
3665
4369
|
return {
|
3666
4370
|
...actionBase,
|
3667
|
-
type: action
|
3668
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4371
|
+
type: action
|
3669
4372
|
};
|
4373
|
+
case ActionType.DELETE:
|
4374
|
+
case ActionType.DETECT_DUPLICATE:
|
3670
4375
|
default:
|
3671
4376
|
throw new Error(`Unsupported action type: ${action}`);
|
3672
4377
|
}
|
@@ -3681,12 +4386,16 @@ function generateEventDocument({
|
|
3681
4386
|
actions: actions.map(
|
3682
4387
|
(action) => generateActionDocument({ configuration, action })
|
3683
4388
|
),
|
4389
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4390
|
+
// @TODO: This should be fixed in the future.
|
3684
4391
|
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
3685
4392
|
id: getUUID(),
|
4393
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4394
|
+
// @TODO: This should be fixed in the future.
|
3686
4395
|
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
3687
4396
|
};
|
3688
4397
|
}
|
3689
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4398
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3690
4399
|
const action = generateActionDocument({
|
3691
4400
|
configuration: tennisClubMembershipEvent,
|
3692
4401
|
action: actionType
|
@@ -3696,9 +4405,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3696
4405
|
transactionId: getUUID(),
|
3697
4406
|
action: {
|
3698
4407
|
...action,
|
3699
|
-
|
3700
|
-
...action.
|
3701
|
-
...
|
4408
|
+
declaration: {
|
4409
|
+
...action.declaration,
|
4410
|
+
...declaration
|
3702
4411
|
}
|
3703
4412
|
},
|
3704
4413
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3712,10 +4421,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3712
4421
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3713
4422
|
createdBy: overrides.createdBy ?? getUUID(),
|
3714
4423
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
3715
|
-
|
4424
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4425
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3716
4426
|
assignedTo: overrides.assignedTo ?? null,
|
3717
4427
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3718
|
-
|
4428
|
+
declaration: overrides.declaration ?? {
|
3719
4429
|
"recommender.none": true,
|
3720
4430
|
"applicant.firstname": "Danny",
|
3721
4431
|
"applicant.surname": "Doe",
|
@@ -3723,6 +4433,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3723
4433
|
},
|
3724
4434
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3725
4435
|
});
|
4436
|
+
var generateTranslationConfig = (message) => ({
|
4437
|
+
defaultMessage: message,
|
4438
|
+
description: "Description for ${message}",
|
4439
|
+
id: message
|
4440
|
+
});
|
3726
4441
|
|
3727
4442
|
// ../commons/src/events/TemplateConfig.ts
|
3728
4443
|
function isTemplateVariable(value) {
|
@@ -3741,7 +4456,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
3741
4456
|
return true;
|
3742
4457
|
}
|
3743
4458
|
function isFieldConfigDefaultValue(value) {
|
3744
|
-
if (!value)
|
4459
|
+
if (!value) {
|
4460
|
+
return false;
|
4461
|
+
}
|
3745
4462
|
if (isFieldValue(value)) {
|
3746
4463
|
return true;
|
3747
4464
|
}
|