@opencrvs/toolkit 1.8.0-rc.ff73871 → 1.8.0-rc.ffb4f66
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 +6676 -9341
- package/dist/commons/conditionals/conditionals.d.ts +26 -3
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +41 -17
- package/dist/commons/conditionals/validate.test.d.ts +2 -0
- package/dist/commons/events/ActionConfig.d.ts +1123 -2074
- package/dist/commons/events/ActionDocument.d.ts +9488 -312
- package/dist/commons/events/ActionInput.d.ts +5328 -471
- package/dist/commons/events/ActionType.d.ts +26 -11
- 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 +351 -48
- package/dist/commons/events/EventConfig.d.ts +551 -1230
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +3340 -424
- package/dist/commons/events/EventIndex.d.ts +6 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +526 -74
- package/dist/commons/events/FieldType.d.ts +2 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +124 -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 +91 -222
- 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 +195 -73
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +166 -81
- package/dist/events/index.js +1413 -813
- 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,9 +58,18 @@ __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,
|
@@ -67,6 +83,7 @@ __export(events_exports, {
|
|
67
83
|
EventSearchIndex: () => EventSearchIndex,
|
68
84
|
EventStatus: () => EventStatus,
|
69
85
|
EventStatuses: () => EventStatuses,
|
86
|
+
FieldConditional: () => FieldConditional,
|
70
87
|
FieldConfig: () => FieldConfig,
|
71
88
|
FieldType: () => FieldType,
|
72
89
|
FieldUpdateValue: () => FieldUpdateValue,
|
@@ -75,13 +92,21 @@ __export(events_exports, {
|
|
75
92
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
76
93
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
77
94
|
FormConfig: () => FormConfig,
|
78
|
-
|
95
|
+
FormPageConfig: () => FormPageConfig,
|
96
|
+
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
97
|
+
GenericAddressValue: () => GenericAddressValue,
|
79
98
|
GeographicalArea: () => GeographicalArea,
|
99
|
+
ImageMimeType: () => ImageMimeType,
|
80
100
|
LanguageConfig: () => LanguageConfig,
|
81
101
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
102
|
+
MimeType: () => MimeType,
|
82
103
|
NotifyActionInput: () => NotifyActionInput,
|
83
104
|
NumberFieldValue: () => NumberFieldValue,
|
105
|
+
PageConfig: () => PageConfig,
|
106
|
+
PageTypes: () => PageTypes,
|
84
107
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
108
|
+
ReadActionInput: () => ReadActionInput,
|
109
|
+
RegisterAction: () => RegisterAction,
|
85
110
|
RegisterActionInput: () => RegisterActionInput,
|
86
111
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
87
112
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -94,20 +119,30 @@ __export(events_exports, {
|
|
94
119
|
SummaryConfig: () => SummaryConfig,
|
95
120
|
TextValue: () => TextValue,
|
96
121
|
TranslationConfig: () => TranslationConfig,
|
122
|
+
UnassignActionInput: () => UnassignActionInput,
|
97
123
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
98
124
|
UrbanAddressValue: () => UrbanAddressValue,
|
99
125
|
ValidateActionInput: () => ValidateActionInput,
|
126
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
127
|
+
VerificationPageConfig: () => VerificationPageConfig,
|
100
128
|
WorkqueueConfig: () => WorkqueueConfig,
|
101
129
|
alwaysTrue: () => alwaysTrue,
|
102
130
|
and: () => and,
|
131
|
+
annotationActions: () => annotationActions,
|
103
132
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
104
133
|
compositeFieldTypes: () => compositeFieldTypes,
|
134
|
+
createEmptyDraft: () => createEmptyDraft,
|
105
135
|
createValidationSchema: () => createValidationSchema,
|
106
136
|
deepDropNulls: () => deepDropNulls,
|
137
|
+
deepMerge: () => deepMerge,
|
138
|
+
defineActionForm: () => defineActionForm,
|
107
139
|
defineConditional: () => defineConditional,
|
108
140
|
defineConfig: () => defineConfig,
|
109
|
-
|
141
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
142
|
+
defineFormConditional: () => defineFormConditional,
|
110
143
|
defineFormPage: () => defineFormPage,
|
144
|
+
definePage: () => definePage,
|
145
|
+
errorMessages: () => errorMessages,
|
111
146
|
event: () => event,
|
112
147
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
113
148
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
@@ -115,37 +150,42 @@ __export(events_exports, {
|
|
115
150
|
eventStatuses: () => eventStatuses,
|
116
151
|
field: () => field,
|
117
152
|
fieldTypes: () => fieldTypes,
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
153
|
+
findActiveDrafts: () => findActiveDrafts,
|
154
|
+
findAllFields: () => findAllFields,
|
155
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
156
|
+
findRecordActionPages: () => findRecordActionPages,
|
157
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
158
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
124
159
|
generateActionDocument: () => generateActionDocument,
|
125
|
-
generateActionInput: () => generateActionInput,
|
126
160
|
generateEventDocument: () => generateEventDocument,
|
127
161
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
128
162
|
generateTransactionId: () => generateTransactionId,
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
163
|
+
generateTranslationConfig: () => generateTranslationConfig,
|
164
|
+
getAcceptedActions: () => getAcceptedActions,
|
165
|
+
getActionAnnotation: () => getActionAnnotation,
|
166
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
167
|
+
getActionReview: () => getActionReview,
|
168
|
+
getActionReviewFields: () => getActionReviewFields,
|
169
|
+
getAllAnnotationFields: () => getAllAnnotationFields,
|
170
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
133
171
|
getCurrentEventState: () => getCurrentEventState,
|
134
172
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
135
|
-
|
173
|
+
getDeclaration: () => getDeclaration,
|
174
|
+
getDeclarationFields: () => getDeclarationFields,
|
175
|
+
getDeclarationPages: () => getDeclarationPages,
|
136
176
|
getFieldValidationErrors: () => getFieldValidationErrors,
|
137
|
-
getFormFields: () => getFormFields,
|
138
|
-
getMetadataForAction: () => getMetadataForAction,
|
139
177
|
isAddressFieldType: () => isAddressFieldType,
|
140
178
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
141
179
|
isBulletListFieldType: () => isBulletListFieldType,
|
142
180
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
143
181
|
isCountryFieldType: () => isCountryFieldType,
|
182
|
+
isDataFieldType: () => isDataFieldType,
|
144
183
|
isDateFieldType: () => isDateFieldType,
|
145
184
|
isDividerFieldType: () => isDividerFieldType,
|
146
185
|
isEmailFieldType: () => isEmailFieldType,
|
147
186
|
isFacilityFieldType: () => isFacilityFieldType,
|
148
187
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
188
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
149
189
|
isFieldEnabled: () => isFieldEnabled,
|
150
190
|
isFieldValue: () => isFieldValue,
|
151
191
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -156,6 +196,7 @@ __export(events_exports, {
|
|
156
196
|
isNumberFieldType: () => isNumberFieldType,
|
157
197
|
isOfficeFieldType: () => isOfficeFieldType,
|
158
198
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
199
|
+
isPageVisible: () => isPageVisible,
|
159
200
|
isParagraphFieldType: () => isParagraphFieldType,
|
160
201
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
161
202
|
isSelectFieldType: () => isSelectFieldType,
|
@@ -164,50 +205,71 @@ __export(events_exports, {
|
|
164
205
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
165
206
|
isTextFieldType: () => isTextFieldType,
|
166
207
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
208
|
+
isVerificationPage: () => isVerificationPage,
|
209
|
+
isWriteAction: () => isWriteAction,
|
167
210
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
168
211
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
169
212
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
213
|
+
never: () => never,
|
170
214
|
not: () => not,
|
215
|
+
omitHiddenFields: () => omitHiddenFields,
|
216
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
171
217
|
or: () => or,
|
172
|
-
resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
|
173
|
-
stripHiddenFields: () => stripHiddenFields,
|
174
218
|
user: () => user,
|
175
219
|
validate: () => validate,
|
176
220
|
validateFieldInput: () => validateFieldInput,
|
177
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
221
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
222
|
+
writeActions: () => writeActions
|
178
223
|
});
|
179
224
|
module.exports = __toCommonJS(events_exports);
|
180
225
|
|
181
226
|
// ../commons/src/events/ActionConfig.ts
|
182
|
-
var
|
227
|
+
var import_zod9 = require("zod");
|
183
228
|
|
184
229
|
// ../commons/src/events/Conditional.ts
|
185
230
|
var import_zod = require("zod");
|
186
|
-
|
187
|
-
|
188
|
-
|
231
|
+
var Conditional = import_zod.z.custom(
|
232
|
+
(val) => typeof val === "object" && val !== null
|
233
|
+
);
|
189
234
|
var ConditionalType = {
|
190
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
191
235
|
SHOW: "SHOW",
|
192
|
-
|
193
|
-
|
236
|
+
ENABLE: "ENABLE",
|
237
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
194
238
|
};
|
195
239
|
var ShowConditional = import_zod.z.object({
|
196
240
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
197
|
-
conditional: Conditional
|
198
|
-
})
|
241
|
+
conditional: Conditional
|
242
|
+
}).describe(
|
243
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
244
|
+
);
|
199
245
|
var EnableConditional = import_zod.z.object({
|
200
246
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
201
|
-
conditional: Conditional
|
202
|
-
})
|
247
|
+
conditional: Conditional
|
248
|
+
}).describe(
|
249
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
250
|
+
);
|
203
251
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
204
252
|
// Action can be shown / hidden
|
205
253
|
ShowConditional,
|
206
254
|
// Action can be shown to the user in the list but as disabled
|
207
255
|
EnableConditional
|
208
256
|
]);
|
257
|
+
var DisplayOnReviewConditional = import_zod.z.object({
|
258
|
+
type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
259
|
+
conditional: Conditional
|
260
|
+
}).describe(
|
261
|
+
"If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
|
262
|
+
);
|
263
|
+
var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
264
|
+
// Field input can be shown / hidden
|
265
|
+
ShowConditional,
|
266
|
+
// Field input can be shown to the user but as disabled
|
267
|
+
EnableConditional,
|
268
|
+
// Field output can be shown / hidden on the review page
|
269
|
+
DisplayOnReviewConditional
|
270
|
+
]);
|
209
271
|
|
210
|
-
// ../commons/src/events/
|
272
|
+
// ../commons/src/events/PageConfig.ts
|
211
273
|
var import_zod6 = require("zod");
|
212
274
|
|
213
275
|
// ../commons/src/events/FieldConfig.ts
|
@@ -248,7 +310,8 @@ var FieldType = {
|
|
248
310
|
ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
|
249
311
|
FACILITY: "FACILITY",
|
250
312
|
OFFICE: "OFFICE",
|
251
|
-
SIGNATURE: "SIGNATURE"
|
313
|
+
SIGNATURE: "SIGNATURE",
|
314
|
+
DATA: "DATA"
|
252
315
|
};
|
253
316
|
var fieldTypes = Object.values(FieldType);
|
254
317
|
var compositeFieldTypes = [
|
@@ -266,6 +329,10 @@ var GeographicalArea = {
|
|
266
329
|
URBAN: "URBAN",
|
267
330
|
RURAL: "RURAL"
|
268
331
|
};
|
332
|
+
var AddressType = {
|
333
|
+
DOMESTIC: "DOMESTIC",
|
334
|
+
INTERNATIONAL: "INTERNATIONAL"
|
335
|
+
};
|
269
336
|
var FileFieldValue = import_zod3.z.object({
|
270
337
|
filename: import_zod3.z.string(),
|
271
338
|
originalFilename: import_zod3.z.string(),
|
@@ -273,6 +340,7 @@ var FileFieldValue = import_zod3.z.object({
|
|
273
340
|
});
|
274
341
|
var AdminStructure = import_zod3.z.object({
|
275
342
|
country: import_zod3.z.string(),
|
343
|
+
addressType: import_zod3.z.literal(AddressType.DOMESTIC),
|
276
344
|
province: import_zod3.z.string(),
|
277
345
|
district: import_zod3.z.string()
|
278
346
|
});
|
@@ -300,14 +368,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
|
|
300
368
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
301
369
|
village: import_zod3.z.string().nullish()
|
302
370
|
});
|
303
|
-
var
|
304
|
-
|
305
|
-
|
306
|
-
|
371
|
+
var GenericAddressValue = import_zod3.z.object({
|
372
|
+
country: import_zod3.z.string(),
|
373
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
374
|
+
state: import_zod3.z.string(),
|
375
|
+
district2: import_zod3.z.string(),
|
376
|
+
cityOrTown: import_zod3.z.string().optional(),
|
377
|
+
addressLine1: import_zod3.z.string().optional(),
|
378
|
+
addressLine2: import_zod3.z.string().optional(),
|
379
|
+
addressLine3: import_zod3.z.string().optional(),
|
380
|
+
postcodeOrZip: import_zod3.z.string().optional()
|
381
|
+
});
|
382
|
+
var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
|
383
|
+
var GenericAddressUpdateValue = import_zod3.z.object({
|
384
|
+
country: import_zod3.z.string(),
|
385
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
386
|
+
state: import_zod3.z.string(),
|
387
|
+
district2: import_zod3.z.string(),
|
388
|
+
cityOrTown: import_zod3.z.string().nullish(),
|
389
|
+
addressLine1: import_zod3.z.string().nullish(),
|
390
|
+
addressLine2: import_zod3.z.string().nullish(),
|
391
|
+
addressLine3: import_zod3.z.string().nullish(),
|
392
|
+
postcodeOrZip: import_zod3.z.string().nullish()
|
393
|
+
});
|
307
394
|
var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
|
308
395
|
UrbanAddressUpdateValue,
|
309
396
|
RuralAddressUpdateValue
|
310
|
-
]);
|
397
|
+
]).or(GenericAddressUpdateValue);
|
311
398
|
var FileFieldValueWithOption = import_zod3.z.object({
|
312
399
|
filename: import_zod3.z.string(),
|
313
400
|
originalFilename: import_zod3.z.string(),
|
@@ -323,6 +410,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
|
|
323
410
|
var EmailValue = import_zod4.z.string().email();
|
324
411
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
325
412
|
var NumberFieldValue = import_zod4.z.number();
|
413
|
+
var DataFieldValue = import_zod4.z.undefined();
|
326
414
|
var FieldValue = import_zod4.z.union([
|
327
415
|
TextValue,
|
328
416
|
DateValue,
|
@@ -331,7 +419,9 @@ var FieldValue = import_zod4.z.union([
|
|
331
419
|
FileFieldValue,
|
332
420
|
FileFieldWithOptionValue,
|
333
421
|
UrbanAddressValue,
|
334
|
-
RuralAddressValue
|
422
|
+
RuralAddressValue,
|
423
|
+
DataFieldValue,
|
424
|
+
GenericAddressValue
|
335
425
|
]);
|
336
426
|
var FieldUpdateValue = import_zod4.z.union([
|
337
427
|
TextValue,
|
@@ -341,7 +431,9 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
341
431
|
FileFieldValue,
|
342
432
|
FileFieldWithOptionValue,
|
343
433
|
UrbanAddressUpdateValue,
|
344
|
-
RuralAddressUpdateValue
|
434
|
+
RuralAddressUpdateValue,
|
435
|
+
DataFieldValue,
|
436
|
+
GenericAddressUpdateValue
|
345
437
|
]);
|
346
438
|
|
347
439
|
// ../commons/src/events/FieldConfig.ts
|
@@ -363,14 +455,14 @@ var BaseField = import_zod5.z.object({
|
|
363
455
|
]),
|
364
456
|
DependencyExpression
|
365
457
|
]).optional(),
|
366
|
-
conditionals: import_zod5.z.array(
|
458
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
367
459
|
required: import_zod5.z.boolean().default(false).optional(),
|
368
460
|
disabled: import_zod5.z.boolean().default(false).optional(),
|
369
461
|
hidden: import_zod5.z.boolean().default(false).optional(),
|
370
462
|
placeholder: TranslationConfig.optional(),
|
371
463
|
validation: import_zod5.z.array(
|
372
464
|
import_zod5.z.object({
|
373
|
-
validator: Conditional
|
465
|
+
validator: Conditional,
|
374
466
|
message: TranslationConfig
|
375
467
|
})
|
376
468
|
).default([]).optional(),
|
@@ -412,15 +504,25 @@ var TextAreaField = BaseField.extend({
|
|
412
504
|
postfix: TranslationConfig.optional()
|
413
505
|
}).default({ rows: 4 }).optional()
|
414
506
|
}).describe("Multiline text input");
|
507
|
+
var ImageMimeType = import_zod5.z.enum([
|
508
|
+
"image/png",
|
509
|
+
"image/jpg",
|
510
|
+
"image/jpeg",
|
511
|
+
"image/svg+xml"
|
512
|
+
]);
|
513
|
+
var MimeType = ImageMimeType;
|
514
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
415
515
|
var SignatureField = BaseField.extend({
|
416
516
|
type: import_zod5.z.literal(FieldType.SIGNATURE),
|
417
517
|
signaturePromptLabel: TranslationConfig.describe(
|
418
518
|
"Title of the signature modal"
|
419
519
|
),
|
420
520
|
configuration: import_zod5.z.object({
|
421
|
-
|
422
|
-
|
423
|
-
}).default({
|
521
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
522
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
523
|
+
}).default({
|
524
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
525
|
+
})
|
424
526
|
}).describe("Signature input field");
|
425
527
|
var EmailField = BaseField.extend({
|
426
528
|
type: import_zod5.z.literal(FieldType.EMAIL),
|
@@ -463,13 +565,17 @@ var PageHeader = BaseField.extend({
|
|
463
565
|
}).describe("A read-only header component for form pages");
|
464
566
|
var File = BaseField.extend({
|
465
567
|
type: import_zod5.z.literal(FieldType.FILE),
|
466
|
-
|
568
|
+
configuration: import_zod5.z.object({
|
569
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
570
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
467
571
|
style: import_zod5.z.object({
|
468
|
-
|
572
|
+
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
469
573
|
"Whether the file upload button should take the full width of the container or not"
|
470
574
|
)
|
471
|
-
})
|
472
|
-
}).
|
575
|
+
}).optional()
|
576
|
+
}).default({
|
577
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
578
|
+
})
|
473
579
|
}).describe("File upload");
|
474
580
|
var SelectOption = import_zod5.z.object({
|
475
581
|
value: import_zod5.z.string().describe("The value of the option"),
|
@@ -515,7 +621,7 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
515
621
|
]);
|
516
622
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
517
623
|
partOf: import_zod5.z.object({
|
518
|
-
$
|
624
|
+
$declaration: import_zod5.z.string()
|
519
625
|
}).optional().describe("Parent location"),
|
520
626
|
type: AdministrativeAreas
|
521
627
|
}).describe("Administrative area options");
|
@@ -530,8 +636,14 @@ var Location = BaseField.extend({
|
|
530
636
|
}).describe("Input field for a location");
|
531
637
|
var FileUploadWithOptions = BaseField.extend({
|
532
638
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
533
|
-
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
534
|
-
|
639
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
640
|
+
configuration: import_zod5.z.object({
|
641
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
642
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
643
|
+
}).default({
|
644
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
645
|
+
})
|
646
|
+
});
|
535
647
|
var Facility = BaseField.extend({
|
536
648
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
537
649
|
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
@@ -544,6 +656,22 @@ var Address = BaseField.extend({
|
|
544
656
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
545
657
|
defaultValue: AddressFieldValue.optional()
|
546
658
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
659
|
+
var DataEntry = import_zod5.z.union([
|
660
|
+
import_zod5.z.object({
|
661
|
+
label: TranslationConfig,
|
662
|
+
value: import_zod5.z.string()
|
663
|
+
}),
|
664
|
+
import_zod5.z.object({
|
665
|
+
fieldId: import_zod5.z.string()
|
666
|
+
})
|
667
|
+
]);
|
668
|
+
var DataField = BaseField.extend({
|
669
|
+
type: import_zod5.z.literal(FieldType.DATA),
|
670
|
+
configuration: import_zod5.z.object({
|
671
|
+
subtitle: TranslationConfig.optional(),
|
672
|
+
data: import_zod5.z.array(DataEntry)
|
673
|
+
})
|
674
|
+
}).describe("Data field for displaying read-only data");
|
547
675
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
548
676
|
Address,
|
549
677
|
TextField,
|
@@ -565,138 +693,210 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
565
693
|
Office,
|
566
694
|
SignatureField,
|
567
695
|
EmailField,
|
568
|
-
FileUploadWithOptions
|
696
|
+
FileUploadWithOptions,
|
697
|
+
DataField
|
698
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
569
699
|
]);
|
570
700
|
|
571
|
-
// ../commons/src/events/
|
572
|
-
var
|
701
|
+
// ../commons/src/events/PageConfig.ts
|
702
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
703
|
+
var PageConfigBase = import_zod6.z.object({
|
573
704
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
574
705
|
title: TranslationConfig.describe("Header title of the page"),
|
575
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
706
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
707
|
+
conditional: Conditional.optional().describe(
|
708
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
709
|
+
)
|
576
710
|
});
|
577
|
-
var
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
label: TranslationConfig
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
pages: import_zod6.z.array(FormPage),
|
589
|
-
review: import_zod6.z.object({
|
590
|
-
title: TranslationConfig.describe(
|
591
|
-
"Title of the form to show in review page"
|
592
|
-
),
|
593
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
711
|
+
var FormPageConfig = PageConfigBase.extend({
|
712
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
713
|
+
});
|
714
|
+
var VerificationActionConfig = import_zod6.z.object({
|
715
|
+
verify: import_zod6.z.object({ label: TranslationConfig }),
|
716
|
+
cancel: import_zod6.z.object({
|
717
|
+
label: TranslationConfig,
|
718
|
+
confirmation: import_zod6.z.object({
|
719
|
+
title: TranslationConfig,
|
720
|
+
body: TranslationConfig
|
721
|
+
})
|
594
722
|
})
|
723
|
+
}).describe("Actions available on the verification page");
|
724
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
725
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
726
|
+
actions: VerificationActionConfig
|
595
727
|
});
|
728
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
729
|
+
FormPageConfig,
|
730
|
+
VerificationPageConfig
|
731
|
+
]);
|
596
732
|
|
597
733
|
// ../commons/src/events/ActionType.ts
|
734
|
+
var import_zod7 = require("zod");
|
598
735
|
var ActionType = {
|
736
|
+
// Pre-declaration actions
|
737
|
+
DELETE: "DELETE",
|
599
738
|
CREATE: "CREATE",
|
600
|
-
ASSIGN: "ASSIGN",
|
601
|
-
UNASSIGN: "UNASSIGN",
|
602
|
-
REGISTER: "REGISTER",
|
603
|
-
VALIDATE: "VALIDATE",
|
604
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
605
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
606
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
607
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
608
739
|
NOTIFY: "NOTIFY",
|
740
|
+
// Declaration actions
|
609
741
|
DECLARE: "DECLARE",
|
610
|
-
|
611
|
-
|
612
|
-
|
742
|
+
VALIDATE: "VALIDATE",
|
743
|
+
REGISTER: "REGISTER",
|
744
|
+
// Declaration system actions. Non-configurable.
|
745
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
613
746
|
REJECT: "REJECT",
|
747
|
+
// REJECT_DECLARATION
|
614
748
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
615
|
-
|
749
|
+
// MARK_AS_DUPLICATE
|
750
|
+
ARCHIVE: "ARCHIVE",
|
751
|
+
// Record actions
|
752
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
753
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
754
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
755
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
756
|
+
// General actions
|
757
|
+
READ: "READ",
|
758
|
+
ASSIGN: "ASSIGN",
|
759
|
+
UNASSIGN: "UNASSIGN"
|
616
760
|
};
|
761
|
+
var ConfirmableActions = [
|
762
|
+
ActionType.NOTIFY,
|
763
|
+
ActionType.DECLARE,
|
764
|
+
ActionType.VALIDATE,
|
765
|
+
ActionType.REGISTER,
|
766
|
+
ActionType.REJECT,
|
767
|
+
ActionType.ARCHIVE,
|
768
|
+
ActionType.PRINT_CERTIFICATE
|
769
|
+
];
|
770
|
+
var ActionTypes = import_zod7.z.enum([
|
771
|
+
"DELETE",
|
772
|
+
"CREATE",
|
773
|
+
"NOTIFY",
|
774
|
+
"DECLARE",
|
775
|
+
"VALIDATE",
|
776
|
+
"REGISTER",
|
777
|
+
"DETECT_DUPLICATE",
|
778
|
+
"REJECT",
|
779
|
+
"MARKED_AS_DUPLICATE",
|
780
|
+
"ARCHIVE",
|
781
|
+
"PRINT_CERTIFICATE",
|
782
|
+
"REQUEST_CORRECTION",
|
783
|
+
"REJECT_CORRECTION",
|
784
|
+
"APPROVE_CORRECTION",
|
785
|
+
"READ",
|
786
|
+
"ASSIGN",
|
787
|
+
"UNASSIGN"
|
788
|
+
]);
|
789
|
+
var declarationActionValues = [
|
790
|
+
ActionTypes.enum.DECLARE,
|
791
|
+
ActionTypes.enum.VALIDATE,
|
792
|
+
ActionTypes.enum.REGISTER
|
793
|
+
];
|
794
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
795
|
+
var declarationUpdateActionValues = [
|
796
|
+
...declarationActionValues,
|
797
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
798
|
+
];
|
799
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
800
|
+
declarationUpdateActionValues
|
801
|
+
);
|
802
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
803
|
+
var writeActions = ActionTypes.exclude([
|
804
|
+
ActionType.CREATE,
|
805
|
+
ActionType.READ,
|
806
|
+
ActionType.ASSIGN,
|
807
|
+
ActionType.UNASSIGN
|
808
|
+
]);
|
809
|
+
|
810
|
+
// ../commons/src/events/FormConfig.ts
|
811
|
+
var import_zod8 = require("zod");
|
812
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
813
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
814
|
+
pages: import_zod8.z.array(FormPageConfig)
|
815
|
+
}).describe("Configuration for a declaration form");
|
816
|
+
var ActionFormConfig = import_zod8.z.object({
|
817
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
818
|
+
pages: import_zod8.z.array(PageConfig)
|
819
|
+
});
|
820
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
617
821
|
|
618
822
|
// ../commons/src/events/ActionConfig.ts
|
619
|
-
var ActionConditional2 =
|
823
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
620
824
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
621
825
|
ShowConditional,
|
622
826
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
623
827
|
EnableConditional
|
624
828
|
]);
|
625
|
-
var
|
829
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
830
|
+
title: TranslationConfig.describe("Title of the review page"),
|
831
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
832
|
+
}).describe("Configuration for **declaration** review page.");
|
833
|
+
var ActionConfigBase = import_zod9.z.object({
|
626
834
|
label: TranslationConfig,
|
627
|
-
conditionals:
|
628
|
-
draft:
|
629
|
-
forms: import_zod7.z.array(FormConfig)
|
835
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
836
|
+
draft: import_zod9.z.boolean().optional()
|
630
837
|
});
|
631
838
|
var DeclareConfig = ActionConfigBase.merge(
|
632
|
-
|
633
|
-
type:
|
839
|
+
import_zod9.z.object({
|
840
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
841
|
+
review: DeclarationReviewConfig
|
634
842
|
})
|
635
843
|
);
|
636
844
|
var ValidateConfig = ActionConfigBase.merge(
|
637
|
-
|
638
|
-
type:
|
845
|
+
import_zod9.z.object({
|
846
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
847
|
+
review: DeclarationReviewConfig
|
848
|
+
})
|
849
|
+
);
|
850
|
+
var RegisterConfig = ActionConfigBase.merge(
|
851
|
+
import_zod9.z.object({
|
852
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
853
|
+
review: DeclarationReviewConfig
|
639
854
|
})
|
640
855
|
);
|
641
856
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
642
|
-
|
643
|
-
type:
|
644
|
-
comment: import_zod7.z.string(),
|
645
|
-
isDuplicate: import_zod7.z.boolean()
|
857
|
+
import_zod9.z.object({
|
858
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
646
859
|
})
|
647
860
|
);
|
648
861
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
649
|
-
|
650
|
-
type:
|
651
|
-
comment: import_zod7.z.string(),
|
652
|
-
duplicates: import_zod7.z.array(import_zod7.z.string()).describe("UUIDs of duplicate records")
|
862
|
+
import_zod9.z.object({
|
863
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
653
864
|
})
|
654
865
|
);
|
655
866
|
var ArchiveConfig = ActionConfigBase.merge(
|
656
|
-
|
657
|
-
type:
|
658
|
-
comment: import_zod7.z.string(),
|
659
|
-
isDuplicate: import_zod7.z.boolean()
|
660
|
-
})
|
661
|
-
);
|
662
|
-
var RegisterConfig = ActionConfigBase.merge(
|
663
|
-
import_zod7.z.object({
|
664
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
867
|
+
import_zod9.z.object({
|
868
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
665
869
|
})
|
666
870
|
);
|
667
871
|
var DeleteConfig = ActionConfigBase.merge(
|
668
|
-
|
669
|
-
type:
|
872
|
+
import_zod9.z.object({
|
873
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
670
874
|
})
|
671
875
|
);
|
672
876
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
673
|
-
|
674
|
-
type:
|
877
|
+
import_zod9.z.object({
|
878
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
879
|
+
printForm: ActionFormConfig
|
675
880
|
})
|
676
881
|
);
|
677
882
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
678
|
-
|
679
|
-
type:
|
680
|
-
onboardingForm:
|
681
|
-
additionalDetailsForm:
|
883
|
+
import_zod9.z.object({
|
884
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
885
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
886
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
682
887
|
})
|
683
888
|
);
|
684
889
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
685
|
-
|
686
|
-
type:
|
890
|
+
import_zod9.z.object({
|
891
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
687
892
|
})
|
688
893
|
);
|
689
894
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
690
|
-
|
691
|
-
type:
|
692
|
-
})
|
693
|
-
);
|
694
|
-
var CustomConfig = ActionConfigBase.merge(
|
695
|
-
import_zod7.z.object({
|
696
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
895
|
+
import_zod9.z.object({
|
896
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
697
897
|
})
|
698
898
|
);
|
699
|
-
var ActionConfig =
|
899
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
700
900
|
DeclareConfig,
|
701
901
|
ValidateConfig,
|
702
902
|
RejectDeclarationConfig,
|
@@ -707,102 +907,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
707
907
|
PrintCertificateActionConfig,
|
708
908
|
RequestCorrectionConfig,
|
709
909
|
RejectCorrectionConfig,
|
710
|
-
ApproveCorrectionConfig
|
711
|
-
|
910
|
+
ApproveCorrectionConfig
|
911
|
+
]);
|
912
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
913
|
+
DeclareConfig,
|
914
|
+
ValidateConfig,
|
915
|
+
RegisterConfig
|
712
916
|
]);
|
713
917
|
|
714
918
|
// ../commons/src/events/offline/CertificateConfig.ts
|
715
|
-
var
|
716
|
-
var FontFamily =
|
717
|
-
normal:
|
718
|
-
bold:
|
719
|
-
italics:
|
720
|
-
bolditalics:
|
919
|
+
var import_zod10 = require("zod");
|
920
|
+
var FontFamily = import_zod10.z.object({
|
921
|
+
normal: import_zod10.z.string(),
|
922
|
+
bold: import_zod10.z.string(),
|
923
|
+
italics: import_zod10.z.string(),
|
924
|
+
bolditalics: import_zod10.z.string()
|
721
925
|
});
|
722
|
-
var CertificateConfig =
|
723
|
-
id:
|
724
|
-
event:
|
926
|
+
var CertificateConfig = import_zod10.z.object({
|
927
|
+
id: import_zod10.z.string(),
|
928
|
+
event: import_zod10.z.string(),
|
725
929
|
label: TranslationConfig,
|
726
|
-
isDefault:
|
727
|
-
fee:
|
728
|
-
onTime:
|
729
|
-
late:
|
730
|
-
delayed:
|
930
|
+
isDefault: import_zod10.z.boolean(),
|
931
|
+
fee: import_zod10.z.object({
|
932
|
+
onTime: import_zod10.z.number(),
|
933
|
+
late: import_zod10.z.number(),
|
934
|
+
delayed: import_zod10.z.number()
|
731
935
|
}),
|
732
|
-
svgUrl:
|
733
|
-
fonts:
|
936
|
+
svgUrl: import_zod10.z.string(),
|
937
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
734
938
|
});
|
735
939
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
736
|
-
hash:
|
737
|
-
svg:
|
940
|
+
hash: import_zod10.z.string().optional(),
|
941
|
+
svg: import_zod10.z.string()
|
738
942
|
});
|
739
943
|
|
740
944
|
// ../commons/src/events/offline/LanguageConfig.ts
|
741
|
-
var
|
742
|
-
var LanguageConfig =
|
743
|
-
lang:
|
945
|
+
var import_zod11 = require("zod");
|
946
|
+
var LanguageConfig = import_zod11.z.object({
|
947
|
+
lang: import_zod11.z.string(),
|
744
948
|
/**
|
745
949
|
* client.csv contents
|
746
950
|
*/
|
747
|
-
messages:
|
951
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
748
952
|
});
|
749
953
|
|
750
954
|
// ../commons/src/events/EventConfig.ts
|
751
|
-
var
|
955
|
+
var import_zod20 = require("zod");
|
752
956
|
|
753
957
|
// ../commons/src/events/DeduplicationConfig.ts
|
754
|
-
var
|
755
|
-
var FieldReference =
|
756
|
-
var Matcher =
|
757
|
-
fieldId:
|
758
|
-
options:
|
759
|
-
boost:
|
958
|
+
var import_zod12 = require("zod");
|
959
|
+
var FieldReference = import_zod12.z.string();
|
960
|
+
var Matcher = import_zod12.z.object({
|
961
|
+
fieldId: import_zod12.z.string(),
|
962
|
+
options: import_zod12.z.object({
|
963
|
+
boost: import_zod12.z.number().optional()
|
760
964
|
}).optional().default({})
|
761
965
|
});
|
762
966
|
var FuzzyMatcher = Matcher.extend({
|
763
|
-
type:
|
764
|
-
options:
|
967
|
+
type: import_zod12.z.literal("fuzzy"),
|
968
|
+
options: import_zod12.z.object({
|
765
969
|
/**
|
766
970
|
* Names of length 3 or less characters = 0 edits allowed
|
767
971
|
* Names of length 4 - 6 characters = 1 edit allowed
|
768
972
|
* Names of length >7 characters = 2 edits allowed
|
769
973
|
*/
|
770
|
-
fuzziness:
|
771
|
-
boost:
|
974
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
975
|
+
boost: import_zod12.z.number().optional().default(1)
|
772
976
|
}).optional().default({})
|
773
977
|
});
|
774
978
|
var StrictMatcher = Matcher.extend({
|
775
|
-
type:
|
776
|
-
options:
|
777
|
-
boost:
|
979
|
+
type: import_zod12.z.literal("strict"),
|
980
|
+
options: import_zod12.z.object({
|
981
|
+
boost: import_zod12.z.number().optional().default(1)
|
778
982
|
}).optional().default({})
|
779
983
|
});
|
780
984
|
var DateRangeMatcher = Matcher.extend({
|
781
|
-
type:
|
782
|
-
options:
|
783
|
-
days:
|
985
|
+
type: import_zod12.z.literal("dateRange"),
|
986
|
+
options: import_zod12.z.object({
|
987
|
+
days: import_zod12.z.number(),
|
784
988
|
origin: FieldReference,
|
785
|
-
boost:
|
989
|
+
boost: import_zod12.z.number().optional().default(1)
|
786
990
|
})
|
787
991
|
});
|
788
992
|
var DateDistanceMatcher = Matcher.extend({
|
789
|
-
type:
|
790
|
-
options:
|
791
|
-
days:
|
993
|
+
type: import_zod12.z.literal("dateDistance"),
|
994
|
+
options: import_zod12.z.object({
|
995
|
+
days: import_zod12.z.number(),
|
792
996
|
origin: FieldReference,
|
793
|
-
boost:
|
997
|
+
boost: import_zod12.z.number().optional().default(1)
|
794
998
|
})
|
795
999
|
});
|
796
|
-
var And =
|
797
|
-
type:
|
798
|
-
|
1000
|
+
var And = import_zod12.z.object({
|
1001
|
+
type: import_zod12.z.literal("and"),
|
1002
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1003
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
799
1004
|
});
|
800
|
-
var Or =
|
801
|
-
type:
|
802
|
-
|
1005
|
+
var Or = import_zod12.z.object({
|
1006
|
+
type: import_zod12.z.literal("or"),
|
1007
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1008
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
803
1009
|
});
|
804
|
-
var Clause =
|
805
|
-
() =>
|
1010
|
+
var Clause = import_zod12.z.lazy(
|
1011
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
806
1012
|
And,
|
807
1013
|
Or,
|
808
1014
|
FuzzyMatcher,
|
@@ -811,37 +1017,37 @@ var Clause = import_zod10.z.lazy(
|
|
811
1017
|
DateDistanceMatcher
|
812
1018
|
])
|
813
1019
|
);
|
814
|
-
var DeduplicationConfig =
|
815
|
-
id:
|
1020
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1021
|
+
id: import_zod12.z.string(),
|
816
1022
|
label: TranslationConfig,
|
817
1023
|
query: Clause
|
818
1024
|
});
|
819
1025
|
|
820
1026
|
// ../commons/src/events/SummaryConfig.ts
|
821
|
-
var
|
822
|
-
var Field =
|
823
|
-
id:
|
1027
|
+
var import_zod13 = require("zod");
|
1028
|
+
var Field = import_zod13.z.object({
|
1029
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
824
1030
|
value: TranslationConfig.describe(
|
825
1031
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
826
1032
|
),
|
827
1033
|
label: TranslationConfig,
|
828
1034
|
emptyValueMessage: TranslationConfig.optional()
|
829
1035
|
});
|
830
|
-
var Title =
|
831
|
-
id:
|
1036
|
+
var Title = import_zod13.z.object({
|
1037
|
+
id: import_zod13.z.string(),
|
832
1038
|
label: TranslationConfig.describe("Title content"),
|
833
1039
|
emptyValueMessage: TranslationConfig.optional()
|
834
1040
|
});
|
835
|
-
var SummaryConfig =
|
1041
|
+
var SummaryConfig = import_zod13.z.object({
|
836
1042
|
title: Title.describe("Title of summary view."),
|
837
|
-
fields:
|
1043
|
+
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
838
1044
|
}).describe("Configuration for summary in event.");
|
839
1045
|
|
840
1046
|
// ../commons/src/events/WorkqueueConfig.ts
|
841
|
-
var
|
1047
|
+
var import_zod15 = require("zod");
|
842
1048
|
|
843
1049
|
// ../commons/src/events/EventMetadata.ts
|
844
|
-
var
|
1050
|
+
var import_zod14 = require("zod");
|
845
1051
|
var EventStatus = {
|
846
1052
|
CREATED: "CREATED",
|
847
1053
|
NOTIFIED: "NOTIFIED",
|
@@ -853,18 +1059,19 @@ var EventStatus = {
|
|
853
1059
|
ARCHIVED: "ARCHIVED"
|
854
1060
|
};
|
855
1061
|
var eventStatuses = Object.values(EventStatus);
|
856
|
-
var EventStatuses =
|
857
|
-
var EventMetadata =
|
858
|
-
id:
|
859
|
-
type:
|
1062
|
+
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1063
|
+
var EventMetadata = import_zod14.z.object({
|
1064
|
+
id: import_zod14.z.string(),
|
1065
|
+
type: import_zod14.z.string(),
|
860
1066
|
status: EventStatuses,
|
861
|
-
createdAt:
|
862
|
-
createdBy:
|
863
|
-
createdAtLocation:
|
864
|
-
modifiedAt:
|
865
|
-
assignedTo:
|
866
|
-
updatedBy:
|
867
|
-
trackingId:
|
1067
|
+
createdAt: import_zod14.z.string().datetime(),
|
1068
|
+
createdBy: import_zod14.z.string(),
|
1069
|
+
createdAtLocation: import_zod14.z.string(),
|
1070
|
+
modifiedAt: import_zod14.z.string().datetime(),
|
1071
|
+
assignedTo: import_zod14.z.string().nullish(),
|
1072
|
+
updatedBy: import_zod14.z.string(),
|
1073
|
+
trackingId: import_zod14.z.string(),
|
1074
|
+
registrationNumber: import_zod14.z.string().nullish()
|
868
1075
|
});
|
869
1076
|
var eventMetadataLabelMap = {
|
870
1077
|
"event.assignedTo": {
|
@@ -916,28 +1123,33 @@ var eventMetadataLabelMap = {
|
|
916
1123
|
id: "event.trackingId.label",
|
917
1124
|
defaultMessage: "Tracking ID",
|
918
1125
|
description: "Tracking ID"
|
1126
|
+
},
|
1127
|
+
"event.registrationNumber": {
|
1128
|
+
id: "event.registrationNumber.label",
|
1129
|
+
defaultMessage: "Registration Number",
|
1130
|
+
description: "Registration Number"
|
919
1131
|
}
|
920
1132
|
};
|
921
1133
|
|
922
1134
|
// ../commons/src/events/WorkqueueConfig.ts
|
923
|
-
var WorkqueueConfig =
|
924
|
-
id:
|
925
|
-
filters:
|
926
|
-
|
927
|
-
status:
|
1135
|
+
var WorkqueueConfig = import_zod15.z.object({
|
1136
|
+
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1137
|
+
filters: import_zod15.z.array(
|
1138
|
+
import_zod15.z.object({
|
1139
|
+
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
928
1140
|
})
|
929
1141
|
).describe("Filters to be applied to workqueue.")
|
930
1142
|
}).describe("Configuration for workqueue.");
|
931
1143
|
|
932
1144
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
933
|
-
var
|
934
|
-
var AdvancedSearchConfig =
|
1145
|
+
var import_zod16 = require("zod");
|
1146
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
935
1147
|
title: TranslationConfig.describe("Advanced search tab title"),
|
936
|
-
fields:
|
937
|
-
|
938
|
-
fieldId:
|
939
|
-
config:
|
940
|
-
type:
|
1148
|
+
fields: import_zod16.z.array(
|
1149
|
+
import_zod16.z.object({
|
1150
|
+
fieldId: import_zod16.z.string(),
|
1151
|
+
config: import_zod16.z.object({
|
1152
|
+
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
941
1153
|
}).optional().describe("Configuration options for the field")
|
942
1154
|
})
|
943
1155
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -947,12 +1159,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
947
1159
|
var import_lodash = require("lodash");
|
948
1160
|
|
949
1161
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
950
|
-
var
|
1162
|
+
var import_zod18 = require("zod");
|
951
1163
|
|
952
1164
|
// ../commons/src/workqueues/defaultColumns.ts
|
953
|
-
var
|
954
|
-
var WorkQueueColumnConfig =
|
955
|
-
id:
|
1165
|
+
var import_zod17 = require("zod");
|
1166
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1167
|
+
id: import_zod17.z.string(),
|
956
1168
|
label: TranslationConfig
|
957
1169
|
});
|
958
1170
|
var defaultColumns = {
|
@@ -989,16 +1201,16 @@ var defaultColumns = {
|
|
989
1201
|
}
|
990
1202
|
}
|
991
1203
|
};
|
992
|
-
var DefaultColumnKeys =
|
1204
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
993
1205
|
Object.keys(defaultColumns)
|
994
1206
|
);
|
995
1207
|
|
996
1208
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
997
|
-
var rootWorkqueueConfig =
|
998
|
-
id:
|
1209
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1210
|
+
id: import_zod18.z.string(),
|
999
1211
|
title: TranslationConfig,
|
1000
|
-
columns:
|
1001
|
-
defaultColumns:
|
1212
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1213
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1002
1214
|
});
|
1003
1215
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1004
1216
|
|
@@ -1078,7 +1290,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1078
1290
|
var import_date_fns = require("date-fns");
|
1079
1291
|
|
1080
1292
|
// ../commons/src/events/FieldTypeMapping.ts
|
1081
|
-
var
|
1293
|
+
var import_zod19 = require("zod");
|
1082
1294
|
function mapFieldTypeToZod(type, required) {
|
1083
1295
|
let schema;
|
1084
1296
|
switch (type) {
|
@@ -1120,6 +1332,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1120
1332
|
case FieldType.ADDRESS:
|
1121
1333
|
schema = AddressFieldUpdateValue;
|
1122
1334
|
break;
|
1335
|
+
case FieldType.DATA:
|
1336
|
+
schema = DataFieldValue;
|
1337
|
+
break;
|
1123
1338
|
}
|
1124
1339
|
return required ? schema : schema.nullish();
|
1125
1340
|
}
|
@@ -1128,7 +1343,7 @@ function createValidationSchema(config) {
|
|
1128
1343
|
for (const field2 of config) {
|
1129
1344
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1130
1345
|
}
|
1131
|
-
return
|
1346
|
+
return import_zod19.z.object(shape);
|
1132
1347
|
}
|
1133
1348
|
function mapFieldTypeToMockValue(field2, i) {
|
1134
1349
|
switch (field2.type) {
|
@@ -1154,6 +1369,7 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1154
1369
|
case FieldType.ADDRESS:
|
1155
1370
|
return {
|
1156
1371
|
country: "FAR",
|
1372
|
+
addressType: AddressType.DOMESTIC,
|
1157
1373
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1158
1374
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1159
1375
|
urbanOrRural: "URBAN",
|
@@ -1175,6 +1391,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1175
1391
|
};
|
1176
1392
|
case FieldType.FILE_WITH_OPTIONS:
|
1177
1393
|
return null;
|
1394
|
+
case FieldType.DATA:
|
1395
|
+
return {};
|
1178
1396
|
}
|
1179
1397
|
}
|
1180
1398
|
function mapFieldTypeToEmptyValue(field2) {
|
@@ -1197,10 +1415,12 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1197
1415
|
case FieldType.EMAIL:
|
1198
1416
|
case FieldType.DATE:
|
1199
1417
|
case FieldType.CHECKBOX:
|
1418
|
+
case FieldType.DATA:
|
1200
1419
|
return null;
|
1201
1420
|
case FieldType.ADDRESS:
|
1202
1421
|
return {
|
1203
1422
|
country: null,
|
1423
|
+
addressType: AddressType.DOMESTIC,
|
1204
1424
|
province: null,
|
1205
1425
|
district: null,
|
1206
1426
|
urbanOrRural: "URBAN",
|
@@ -1284,10 +1504,14 @@ var isFacilityFieldType = (field2) => {
|
|
1284
1504
|
var isOfficeFieldType = (field2) => {
|
1285
1505
|
return field2.config.type === FieldType.OFFICE;
|
1286
1506
|
};
|
1507
|
+
var isDataFieldType = (field2) => {
|
1508
|
+
return field2.config.type === FieldType.DATA;
|
1509
|
+
};
|
1287
1510
|
|
1288
1511
|
// ../commons/src/conditionals/validate.ts
|
1289
1512
|
var ajv = new import_ajv.default({
|
1290
|
-
$data: true
|
1513
|
+
$data: true,
|
1514
|
+
allowUnionTypes: true
|
1291
1515
|
});
|
1292
1516
|
(0, import_ajv_formats.default)(ajv);
|
1293
1517
|
function validate(schema, data) {
|
@@ -1320,88 +1544,81 @@ function isFieldVisible(field2, form) {
|
|
1320
1544
|
function isFieldEnabled(field2, form) {
|
1321
1545
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1322
1546
|
}
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
description: "This is the error message for required fields",
|
1352
|
-
id: "v2.error.required"
|
1353
|
-
}
|
1354
|
-
}
|
1355
|
-
};
|
1547
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1548
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1549
|
+
}
|
1550
|
+
var errorMessages = {
|
1551
|
+
hiddenField: {
|
1552
|
+
id: "v2.error.hidden",
|
1553
|
+
defaultMessage: "Hidden or disabled field should not receive a value",
|
1554
|
+
description: "Error message when field is hidden or disabled, but a value was received"
|
1555
|
+
},
|
1556
|
+
invalidDate: {
|
1557
|
+
defaultMessage: "Invalid date field",
|
1558
|
+
description: "Error message when date field is invalid",
|
1559
|
+
id: "v2.error.invalidDate"
|
1560
|
+
},
|
1561
|
+
invalidEmail: {
|
1562
|
+
defaultMessage: "Invalid email address",
|
1563
|
+
description: "Error message when email address is invalid",
|
1564
|
+
id: "v2.error.invalidEmail"
|
1565
|
+
},
|
1566
|
+
requiredField: {
|
1567
|
+
defaultMessage: "Required for registration",
|
1568
|
+
description: "Error message when required field is missing",
|
1569
|
+
id: "v2.error.required"
|
1570
|
+
},
|
1571
|
+
invalidInput: {
|
1572
|
+
defaultMessage: "Invalid input",
|
1573
|
+
description: "Error message when generic field is invalid",
|
1574
|
+
id: "v2.error.invalid"
|
1356
1575
|
}
|
1576
|
+
};
|
1577
|
+
function createIntlError(message) {
|
1357
1578
|
return {
|
1358
1579
|
message: {
|
1359
|
-
message
|
1360
|
-
defaultMessage: "Invalid input",
|
1361
|
-
description: "This is the error message for invalid field value",
|
1362
|
-
id: "v2.error.invalid"
|
1363
|
-
}
|
1580
|
+
message
|
1364
1581
|
}
|
1365
1582
|
};
|
1366
|
-
}
|
1367
|
-
function
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1583
|
+
}
|
1584
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1585
|
+
switch (issue.code) {
|
1586
|
+
case "invalid_string": {
|
1587
|
+
if (_ctx.data === "") {
|
1588
|
+
return createIntlError(errorMessages.requiredField);
|
1589
|
+
}
|
1590
|
+
if (issue.validation === "date") {
|
1591
|
+
return createIntlError(errorMessages.invalidDate);
|
1592
|
+
}
|
1593
|
+
if (issue.validation === "email") {
|
1594
|
+
return createIntlError(errorMessages.invalidEmail);
|
1595
|
+
}
|
1596
|
+
break;
|
1597
|
+
}
|
1598
|
+
case "invalid_type": {
|
1599
|
+
if (issue.expected !== issue.received && issue.received === "undefined") {
|
1600
|
+
return createIntlError(errorMessages.requiredField);
|
1601
|
+
}
|
1602
|
+
break;
|
1603
|
+
}
|
1604
|
+
case "too_small": {
|
1605
|
+
if (issue.message === void 0) {
|
1606
|
+
return createIntlError(errorMessages.requiredField);
|
1607
|
+
}
|
1608
|
+
break;
|
1609
|
+
}
|
1610
|
+
case "invalid_union": {
|
1611
|
+
for (const { issues } of issue.unionErrors) {
|
1612
|
+
for (const e of issues) {
|
1613
|
+
if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
|
1614
|
+
return createIntlError(errorMessages.invalidInput);
|
1385
1615
|
}
|
1386
|
-
|
1387
|
-
}
|
1616
|
+
}
|
1617
|
+
}
|
1618
|
+
return createIntlError(errorMessages.requiredField);
|
1388
1619
|
}
|
1389
|
-
return {
|
1390
|
-
errors: []
|
1391
|
-
};
|
1392
1620
|
}
|
1393
|
-
|
1394
|
-
field: field2,
|
1395
|
-
value: values[field2.id]
|
1396
|
-
});
|
1397
|
-
const customValidationResults = runCustomFieldValidations({
|
1398
|
-
field: field2,
|
1399
|
-
conditionalParameters
|
1400
|
-
});
|
1401
|
-
return {
|
1402
|
-
// Assumes that custom validation errors are more important than field validation errors
|
1403
|
-
errors: [...customValidationResults, ...fieldValidationResult]
|
1404
|
-
};
|
1621
|
+
return createIntlError(errorMessages.invalidInput);
|
1405
1622
|
}
|
1406
1623
|
function runCustomFieldValidations({
|
1407
1624
|
field: field2,
|
@@ -1424,6 +1641,59 @@ function validateFieldInput({
|
|
1424
1641
|
);
|
1425
1642
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1426
1643
|
}
|
1644
|
+
function runFieldValidations({
|
1645
|
+
field: field2,
|
1646
|
+
values
|
1647
|
+
}) {
|
1648
|
+
const conditionalParameters = {
|
1649
|
+
$form: values,
|
1650
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1651
|
+
};
|
1652
|
+
const fieldValidationResult = validateFieldInput({
|
1653
|
+
field: field2,
|
1654
|
+
value: values[field2.id]
|
1655
|
+
});
|
1656
|
+
const customValidationResults = runCustomFieldValidations({
|
1657
|
+
field: field2,
|
1658
|
+
conditionalParameters
|
1659
|
+
});
|
1660
|
+
return {
|
1661
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1662
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1663
|
+
};
|
1664
|
+
}
|
1665
|
+
function getFieldValidationErrors({
|
1666
|
+
field: field2,
|
1667
|
+
values
|
1668
|
+
}) {
|
1669
|
+
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1670
|
+
if (values[field2.id]) {
|
1671
|
+
return {
|
1672
|
+
errors: [
|
1673
|
+
{
|
1674
|
+
message: errorMessages.hiddenField
|
1675
|
+
}
|
1676
|
+
]
|
1677
|
+
};
|
1678
|
+
}
|
1679
|
+
return {
|
1680
|
+
errors: []
|
1681
|
+
};
|
1682
|
+
}
|
1683
|
+
return runFieldValidations({
|
1684
|
+
field: field2,
|
1685
|
+
values
|
1686
|
+
});
|
1687
|
+
}
|
1688
|
+
|
1689
|
+
// ../commons/src/uuid.ts
|
1690
|
+
var import_uuid = require("uuid");
|
1691
|
+
function getUUID() {
|
1692
|
+
return (0, import_uuid.v4)();
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
// ../commons/src/events/utils.ts
|
1696
|
+
var import_date_fns2 = require("date-fns");
|
1427
1697
|
|
1428
1698
|
// ../commons/src/utils.ts
|
1429
1699
|
function getOrThrow(x, message) {
|
@@ -1434,66 +1704,63 @@ function getOrThrow(x, message) {
|
|
1434
1704
|
}
|
1435
1705
|
|
1436
1706
|
// ../commons/src/events/utils.ts
|
1437
|
-
function
|
1438
|
-
return
|
1439
|
-
}
|
1440
|
-
|
1441
|
-
return (
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
);
|
1707
|
+
function isDeclarationActionConfig(action) {
|
1708
|
+
return DeclarationActions.safeParse(action.type).success;
|
1709
|
+
}
|
1710
|
+
function getDeclarationFields(configuration) {
|
1711
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1712
|
+
}
|
1713
|
+
function getDeclarationPages(configuration) {
|
1714
|
+
return configuration.declaration.pages;
|
1715
|
+
}
|
1716
|
+
function getDeclaration(configuration) {
|
1717
|
+
return configuration.declaration;
|
1718
|
+
}
|
1719
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1720
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1721
|
+
return [
|
1722
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1723
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1724
|
+
];
|
1725
|
+
}
|
1726
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1727
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1728
|
+
}
|
1729
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1730
|
+
return actionConfig.review.fields;
|
1731
|
+
}
|
1732
|
+
return [];
|
1464
1733
|
};
|
1465
|
-
var
|
1466
|
-
|
1467
|
-
refFields
|
1468
|
-
}) => {
|
1469
|
-
return refFields.map((field2) => {
|
1470
|
-
if (field2.label) {
|
1471
|
-
return field2;
|
1472
|
-
}
|
1473
|
-
if (isMetadataField(field2.id)) {
|
1474
|
-
return {
|
1475
|
-
...field2,
|
1476
|
-
label: eventMetadataLabelMap[field2.id]
|
1477
|
-
};
|
1478
|
-
}
|
1479
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1480
|
-
if (!pageLabel) {
|
1481
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1482
|
-
}
|
1483
|
-
return {
|
1484
|
-
...field2,
|
1485
|
-
label: pageLabel.label
|
1486
|
-
};
|
1487
|
-
});
|
1734
|
+
var getAllAnnotationFields = (config) => {
|
1735
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1488
1736
|
};
|
1489
|
-
|
1490
|
-
return
|
1491
|
-
...
|
1492
|
-
...
|
1737
|
+
var findAllFields = (config) => {
|
1738
|
+
return (0, import_lodash.flattenDeep)([
|
1739
|
+
...getDeclarationFields(config),
|
1740
|
+
...getAllAnnotationFields(config)
|
1493
1741
|
]);
|
1742
|
+
};
|
1743
|
+
var findRecordActionPages = (config, actionType) => {
|
1744
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1745
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1746
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1747
|
+
}
|
1748
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1749
|
+
return action.printForm.pages;
|
1750
|
+
}
|
1751
|
+
return [];
|
1752
|
+
};
|
1753
|
+
function getActionReview(configuration, actionType) {
|
1754
|
+
const [actionConfig] = configuration.actions.filter(
|
1755
|
+
(a) => a.type === actionType
|
1756
|
+
);
|
1757
|
+
return getOrThrow(
|
1758
|
+
actionConfig.review,
|
1759
|
+
`No review config found for ${actionType}`
|
1760
|
+
);
|
1494
1761
|
}
|
1495
|
-
function
|
1496
|
-
return configuration
|
1762
|
+
function getActionReviewFields(configuration, actionType) {
|
1763
|
+
return getActionReview(configuration, actionType).fields;
|
1497
1764
|
}
|
1498
1765
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1499
1766
|
workqueueConfigs.map((workqueue) => {
|
@@ -1502,85 +1769,98 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1502
1769
|
);
|
1503
1770
|
if (!rootWorkqueue) {
|
1504
1771
|
throw new Error(
|
1505
|
-
`Invalid workqueue configuration: workqueue not found with id:
|
1772
|
+
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1506
1773
|
);
|
1507
1774
|
}
|
1508
1775
|
});
|
1509
1776
|
}
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
return form;
|
1514
|
-
};
|
1515
|
-
var findActiveActionFormPages = (configuration, action) => {
|
1516
|
-
return findActiveActionForm(configuration, action)?.pages;
|
1517
|
-
};
|
1518
|
-
var getFormFields = (formConfig) => {
|
1519
|
-
return formConfig.pages.flatMap((p) => p.fields);
|
1520
|
-
};
|
1521
|
-
var findActiveActionFormFields = (configuration, action) => {
|
1522
|
-
const form = findActiveActionForm(configuration, action);
|
1523
|
-
return form ? getFormFields(form) : void 0;
|
1524
|
-
};
|
1525
|
-
var findActiveActionFields = (configuration, action) => {
|
1526
|
-
const form = findActiveActionForm(configuration, action);
|
1527
|
-
const reviewFields = form?.review.fields;
|
1528
|
-
const formFields = form ? getFormFields(form) : void 0;
|
1529
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1530
|
-
return allFields;
|
1531
|
-
};
|
1532
|
-
var getActiveActionFormPages = (configuration, action) => {
|
1533
|
-
return getOrThrow(
|
1534
|
-
findActiveActionForm(configuration, action)?.pages,
|
1535
|
-
"Form configuration not found for type: " + configuration.id
|
1536
|
-
);
|
1537
|
-
};
|
1538
|
-
function getActiveActionFields(configuration, action) {
|
1539
|
-
const fields = findActiveActionFields(configuration, action);
|
1540
|
-
if (!fields) {
|
1541
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1542
|
-
}
|
1543
|
-
return fields;
|
1544
|
-
}
|
1545
|
-
function getEventConfiguration(eventConfigurations, type) {
|
1546
|
-
const config = eventConfigurations.find((config2) => config2.id === type);
|
1547
|
-
if (!config) {
|
1548
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1549
|
-
}
|
1550
|
-
return config;
|
1551
|
-
}
|
1552
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1553
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1554
|
-
return false;
|
1777
|
+
function isPageVisible(page, formValues) {
|
1778
|
+
if (!page.conditional) {
|
1779
|
+
return true;
|
1555
1780
|
}
|
1556
|
-
return
|
1781
|
+
return validate(page.conditional, {
|
1782
|
+
$form: formValues,
|
1783
|
+
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1784
|
+
});
|
1557
1785
|
}
|
1558
|
-
function
|
1559
|
-
return (0, import_lodash.omitBy)(
|
1786
|
+
function omitHiddenFields(fields, values) {
|
1787
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1560
1788
|
const field2 = fields.find((f) => f.id === fieldId);
|
1561
1789
|
if (!field2) {
|
1562
1790
|
return true;
|
1563
1791
|
}
|
1564
|
-
|
1565
|
-
return true;
|
1566
|
-
}
|
1567
|
-
return !isFieldVisible(field2, data);
|
1792
|
+
return !isFieldVisible(field2, values);
|
1568
1793
|
});
|
1569
1794
|
}
|
1795
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1796
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1797
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1798
|
+
}
|
1799
|
+
function findActiveDrafts(event2, drafts) {
|
1800
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1801
|
+
const lastAction = actions[actions.length - 1];
|
1802
|
+
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1803
|
+
}
|
1804
|
+
function createEmptyDraft(eventId, draftId, actionType) {
|
1805
|
+
return {
|
1806
|
+
id: draftId,
|
1807
|
+
eventId,
|
1808
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1809
|
+
transactionId: getUUID(),
|
1810
|
+
action: {
|
1811
|
+
type: actionType,
|
1812
|
+
declaration: {},
|
1813
|
+
annotation: {},
|
1814
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1815
|
+
createdBy: "@todo",
|
1816
|
+
createdAtLocation: "@todo"
|
1817
|
+
}
|
1818
|
+
};
|
1819
|
+
}
|
1820
|
+
function isVerificationPage(page) {
|
1821
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
1822
|
+
}
|
1823
|
+
function deepMerge(currentDocument, actionDocument) {
|
1824
|
+
return (0, import_lodash.mergeWith)(
|
1825
|
+
currentDocument,
|
1826
|
+
actionDocument,
|
1827
|
+
(previousValue, incomingValue) => {
|
1828
|
+
if (incomingValue === void 0) {
|
1829
|
+
return previousValue;
|
1830
|
+
}
|
1831
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1832
|
+
return incomingValue;
|
1833
|
+
}
|
1834
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1835
|
+
return void 0;
|
1836
|
+
}
|
1837
|
+
return incomingValue;
|
1838
|
+
}
|
1839
|
+
);
|
1840
|
+
}
|
1841
|
+
function findLastAssignmentAction(actions) {
|
1842
|
+
return actions.filter(
|
1843
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1844
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1845
|
+
}
|
1846
|
+
function isWriteAction(actionType) {
|
1847
|
+
return writeActions.safeParse(actionType).success;
|
1848
|
+
}
|
1570
1849
|
|
1571
1850
|
// ../commons/src/events/EventConfig.ts
|
1572
|
-
var EventConfig =
|
1573
|
-
id:
|
1851
|
+
var EventConfig = import_zod20.z.object({
|
1852
|
+
id: import_zod20.z.string().describe(
|
1574
1853
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1575
1854
|
),
|
1576
1855
|
summary: SummaryConfig,
|
1577
1856
|
label: TranslationConfig,
|
1578
|
-
actions:
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1857
|
+
actions: import_zod20.z.array(ActionConfig),
|
1858
|
+
declaration: DeclarationFormConfig,
|
1859
|
+
workqueues: import_zod20.z.array(WorkqueueConfig),
|
1860
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
1861
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1582
1862
|
}).superRefine((event2, ctx) => {
|
1583
|
-
const allFields =
|
1863
|
+
const allFields = findAllFields(event2);
|
1584
1864
|
const fieldIds = allFields.map((field2) => field2.id);
|
1585
1865
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1586
1866
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1607,106 +1887,118 @@ var EventConfig = import_zod18.z.object({
|
|
1607
1887
|
});
|
1608
1888
|
|
1609
1889
|
// ../commons/src/events/EventConfigInput.ts
|
1610
|
-
var
|
1611
|
-
var
|
1890
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1891
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1892
|
+
var definePage = (page) => PageConfig.parse(page);
|
1893
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1612
1894
|
|
1613
1895
|
// ../commons/src/events/Draft.ts
|
1614
|
-
var
|
1896
|
+
var import_zod23 = require("zod");
|
1615
1897
|
|
1616
1898
|
// ../commons/src/events/ActionDocument.ts
|
1617
|
-
var
|
1618
|
-
var ActionUpdate =
|
1619
|
-
var
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1899
|
+
var import_zod21 = require("zod");
|
1900
|
+
var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
|
1901
|
+
var ActionStatus = {
|
1902
|
+
Requested: "Requested",
|
1903
|
+
Accepted: "Accepted",
|
1904
|
+
Rejected: "Rejected"
|
1905
|
+
};
|
1906
|
+
var ActionBase = import_zod21.z.object({
|
1907
|
+
id: import_zod21.z.string(),
|
1908
|
+
createdAt: import_zod21.z.string().datetime(),
|
1909
|
+
createdBy: import_zod21.z.string(),
|
1910
|
+
declaration: ActionUpdate,
|
1911
|
+
annotation: ActionUpdate.optional(),
|
1912
|
+
createdAtLocation: import_zod21.z.string(),
|
1913
|
+
status: import_zod21.z.enum([
|
1914
|
+
ActionStatus.Requested,
|
1915
|
+
ActionStatus.Accepted,
|
1916
|
+
ActionStatus.Rejected
|
1917
|
+
]),
|
1918
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1919
|
+
originalActionId: import_zod21.z.string().optional()
|
1626
1920
|
});
|
1627
1921
|
var AssignedAction = ActionBase.merge(
|
1628
|
-
|
1629
|
-
type:
|
1630
|
-
assignedTo:
|
1922
|
+
import_zod21.z.object({
|
1923
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1924
|
+
assignedTo: import_zod21.z.string()
|
1631
1925
|
})
|
1632
1926
|
);
|
1633
1927
|
var UnassignedAction = ActionBase.merge(
|
1634
|
-
|
1635
|
-
type:
|
1928
|
+
import_zod21.z.object({
|
1929
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1930
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1636
1931
|
})
|
1637
1932
|
);
|
1638
1933
|
var RegisterAction = ActionBase.merge(
|
1639
|
-
|
1640
|
-
type:
|
1641
|
-
|
1642
|
-
trackingId: import_zod19.z.string(),
|
1643
|
-
registrationNumber: import_zod19.z.string()
|
1644
|
-
})
|
1934
|
+
import_zod21.z.object({
|
1935
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1936
|
+
registrationNumber: import_zod21.z.string().optional()
|
1645
1937
|
})
|
1646
1938
|
);
|
1647
1939
|
var DeclareAction = ActionBase.merge(
|
1648
|
-
|
1649
|
-
type:
|
1940
|
+
import_zod21.z.object({
|
1941
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1650
1942
|
})
|
1651
1943
|
);
|
1652
1944
|
var ValidateAction = ActionBase.merge(
|
1653
|
-
|
1654
|
-
type:
|
1945
|
+
import_zod21.z.object({
|
1946
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1655
1947
|
})
|
1656
1948
|
);
|
1657
1949
|
var RejectAction = ActionBase.merge(
|
1658
|
-
|
1659
|
-
type:
|
1950
|
+
import_zod21.z.object({
|
1951
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1660
1952
|
})
|
1661
1953
|
);
|
1662
1954
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1663
|
-
|
1664
|
-
type:
|
1955
|
+
import_zod21.z.object({
|
1956
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1665
1957
|
})
|
1666
1958
|
);
|
1667
1959
|
var ArchiveAction = ActionBase.merge(
|
1668
|
-
|
1669
|
-
type:
|
1960
|
+
import_zod21.z.object({
|
1961
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1670
1962
|
})
|
1671
1963
|
);
|
1672
1964
|
var CreatedAction = ActionBase.merge(
|
1673
|
-
|
1674
|
-
type:
|
1965
|
+
import_zod21.z.object({
|
1966
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1675
1967
|
})
|
1676
1968
|
);
|
1677
1969
|
var NotifiedAction = ActionBase.merge(
|
1678
|
-
|
1679
|
-
type:
|
1970
|
+
import_zod21.z.object({
|
1971
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1680
1972
|
})
|
1681
1973
|
);
|
1682
1974
|
var PrintCertificateAction = ActionBase.merge(
|
1683
|
-
|
1684
|
-
type:
|
1975
|
+
import_zod21.z.object({
|
1976
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1685
1977
|
})
|
1686
1978
|
);
|
1687
1979
|
var RequestedCorrectionAction = ActionBase.merge(
|
1688
|
-
|
1689
|
-
type:
|
1980
|
+
import_zod21.z.object({
|
1981
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1690
1982
|
})
|
1691
1983
|
);
|
1692
1984
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1693
|
-
|
1694
|
-
type:
|
1695
|
-
requestId:
|
1985
|
+
import_zod21.z.object({
|
1986
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1987
|
+
requestId: import_zod21.z.string()
|
1696
1988
|
})
|
1697
1989
|
);
|
1698
1990
|
var RejectedCorrectionAction = ActionBase.merge(
|
1699
|
-
|
1700
|
-
type:
|
1701
|
-
requestId:
|
1991
|
+
import_zod21.z.object({
|
1992
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1993
|
+
requestId: import_zod21.z.string()
|
1702
1994
|
})
|
1703
1995
|
);
|
1704
|
-
var
|
1705
|
-
|
1706
|
-
type:
|
1996
|
+
var ReadAction = ActionBase.merge(
|
1997
|
+
import_zod21.z.object({
|
1998
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1707
1999
|
})
|
1708
2000
|
);
|
1709
|
-
var ActionDocument =
|
2001
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1710
2002
|
CreatedAction,
|
1711
2003
|
ValidateAction,
|
1712
2004
|
RejectAction,
|
@@ -1721,108 +2013,125 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1721
2013
|
RejectedCorrectionAction,
|
1722
2014
|
UnassignedAction,
|
1723
2015
|
PrintCertificateAction,
|
1724
|
-
|
2016
|
+
ReadAction
|
1725
2017
|
]);
|
1726
|
-
var
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
2018
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
2019
|
+
declaration: true,
|
2020
|
+
annotation: true,
|
2021
|
+
createdBy: true,
|
2022
|
+
createdAtLocation: true
|
2023
|
+
}).merge(
|
2024
|
+
import_zod21.z.object({
|
2025
|
+
type: import_zod21.z.enum(ConfirmableActions),
|
2026
|
+
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2027
|
+
})
|
2028
|
+
);
|
2029
|
+
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2030
|
+
var ResolvedUser = import_zod21.z.object({
|
2031
|
+
id: import_zod21.z.string(),
|
2032
|
+
role: import_zod21.z.string(),
|
2033
|
+
name: import_zod21.z.array(
|
2034
|
+
import_zod21.z.object({
|
2035
|
+
use: import_zod21.z.string(),
|
2036
|
+
given: import_zod21.z.array(import_zod21.z.string()),
|
2037
|
+
family: import_zod21.z.string()
|
1734
2038
|
})
|
1735
2039
|
)
|
1736
2040
|
});
|
1737
2041
|
|
1738
2042
|
// ../commons/src/events/ActionInput.ts
|
1739
|
-
var
|
1740
|
-
var BaseActionInput =
|
1741
|
-
eventId:
|
1742
|
-
transactionId:
|
1743
|
-
|
1744
|
-
|
2043
|
+
var import_zod22 = require("zod");
|
2044
|
+
var BaseActionInput = import_zod22.z.object({
|
2045
|
+
eventId: import_zod22.z.string(),
|
2046
|
+
transactionId: import_zod22.z.string(),
|
2047
|
+
declaration: ActionUpdate.default({}),
|
2048
|
+
annotation: ActionUpdate.optional(),
|
2049
|
+
originalActionId: import_zod22.z.string().optional(),
|
2050
|
+
keepAssignment: import_zod22.z.boolean().optional()
|
1745
2051
|
});
|
1746
2052
|
var CreateActionInput = BaseActionInput.merge(
|
1747
|
-
|
1748
|
-
type:
|
1749
|
-
createdAtLocation:
|
2053
|
+
import_zod22.z.object({
|
2054
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2055
|
+
createdAtLocation: import_zod22.z.string()
|
1750
2056
|
})
|
1751
2057
|
);
|
1752
2058
|
var RegisterActionInput = BaseActionInput.merge(
|
1753
|
-
|
1754
|
-
type:
|
1755
|
-
|
1756
|
-
trackingId: import_zod20.z.string(),
|
1757
|
-
registrationNumber: import_zod20.z.string()
|
1758
|
-
})
|
2059
|
+
import_zod22.z.object({
|
2060
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2061
|
+
registrationNumber: import_zod22.z.string().optional()
|
1759
2062
|
})
|
1760
2063
|
);
|
1761
2064
|
var ValidateActionInput = BaseActionInput.merge(
|
1762
|
-
|
1763
|
-
type:
|
1764
|
-
duplicates:
|
2065
|
+
import_zod22.z.object({
|
2066
|
+
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2067
|
+
duplicates: import_zod22.z.array(import_zod22.z.string())
|
1765
2068
|
})
|
1766
2069
|
);
|
1767
2070
|
var NotifyActionInput = BaseActionInput.merge(
|
1768
|
-
|
1769
|
-
type:
|
2071
|
+
import_zod22.z.object({
|
2072
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1770
2073
|
})
|
1771
2074
|
);
|
1772
2075
|
var DeclareActionInput = BaseActionInput.merge(
|
1773
|
-
|
1774
|
-
type:
|
2076
|
+
import_zod22.z.object({
|
2077
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1775
2078
|
})
|
1776
2079
|
);
|
1777
2080
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1778
|
-
|
1779
|
-
type:
|
2081
|
+
import_zod22.z.object({
|
2082
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1780
2083
|
})
|
1781
2084
|
);
|
1782
2085
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1783
|
-
|
1784
|
-
type:
|
2086
|
+
import_zod22.z.object({
|
2087
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1785
2088
|
})
|
1786
2089
|
);
|
1787
2090
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1788
|
-
|
1789
|
-
type:
|
2091
|
+
import_zod22.z.object({
|
2092
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1790
2093
|
})
|
1791
2094
|
);
|
1792
2095
|
var ArchiveActionInput = BaseActionInput.merge(
|
1793
|
-
|
1794
|
-
type:
|
2096
|
+
import_zod22.z.object({
|
2097
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1795
2098
|
})
|
1796
2099
|
);
|
1797
2100
|
var AssignActionInput = BaseActionInput.merge(
|
1798
|
-
|
1799
|
-
type:
|
1800
|
-
assignedTo:
|
2101
|
+
import_zod22.z.object({
|
2102
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2103
|
+
assignedTo: import_zod22.z.string()
|
1801
2104
|
})
|
1802
2105
|
);
|
1803
2106
|
var UnassignActionInput = BaseActionInput.merge(
|
1804
|
-
|
1805
|
-
type:
|
2107
|
+
import_zod22.z.object({
|
2108
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2109
|
+
assignedTo: import_zod22.z.literal(null).default(null)
|
1806
2110
|
})
|
1807
2111
|
);
|
1808
2112
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1809
|
-
|
1810
|
-
type:
|
2113
|
+
import_zod22.z.object({
|
2114
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1811
2115
|
})
|
1812
2116
|
);
|
1813
2117
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1814
|
-
|
1815
|
-
requestId:
|
1816
|
-
type:
|
2118
|
+
import_zod22.z.object({
|
2119
|
+
requestId: import_zod22.z.string(),
|
2120
|
+
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1817
2121
|
})
|
1818
2122
|
);
|
1819
2123
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1820
|
-
|
1821
|
-
requestId:
|
1822
|
-
type:
|
2124
|
+
import_zod22.z.object({
|
2125
|
+
requestId: import_zod22.z.string(),
|
2126
|
+
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2127
|
+
})
|
2128
|
+
);
|
2129
|
+
var ReadActionInput = BaseActionInput.merge(
|
2130
|
+
import_zod22.z.object({
|
2131
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
1823
2132
|
})
|
1824
2133
|
);
|
1825
|
-
var ActionInput =
|
2134
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
1826
2135
|
CreateActionInput,
|
1827
2136
|
ValidateActionInput,
|
1828
2137
|
RegisterActionInput,
|
@@ -1836,56 +2145,62 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
1836
2145
|
PrintCertificateActionInput,
|
1837
2146
|
RequestCorrectionActionInput,
|
1838
2147
|
RejectCorrectionActionInput,
|
1839
|
-
ApproveCorrectionActionInput
|
2148
|
+
ApproveCorrectionActionInput,
|
2149
|
+
ReadActionInput
|
1840
2150
|
]);
|
1841
2151
|
|
1842
2152
|
// ../commons/src/events/Draft.ts
|
1843
|
-
var Draft =
|
1844
|
-
id:
|
1845
|
-
eventId:
|
1846
|
-
transactionId:
|
1847
|
-
createdAt:
|
2153
|
+
var Draft = import_zod23.z.object({
|
2154
|
+
id: import_zod23.z.string(),
|
2155
|
+
eventId: import_zod23.z.string(),
|
2156
|
+
transactionId: import_zod23.z.string(),
|
2157
|
+
createdAt: import_zod23.z.string().datetime(),
|
1848
2158
|
action: ActionBase.extend({
|
1849
|
-
type:
|
2159
|
+
type: ActionTypes
|
1850
2160
|
}).omit({ id: true })
|
1851
2161
|
});
|
1852
2162
|
var DraftInput = BaseActionInput.extend({
|
1853
|
-
type:
|
2163
|
+
type: ActionTypes
|
1854
2164
|
});
|
1855
2165
|
|
1856
2166
|
// ../commons/src/events/EventInput.ts
|
1857
|
-
var
|
1858
|
-
var EventInput =
|
1859
|
-
transactionId:
|
1860
|
-
type:
|
2167
|
+
var import_zod24 = require("zod");
|
2168
|
+
var EventInput = import_zod24.z.object({
|
2169
|
+
transactionId: import_zod24.z.string(),
|
2170
|
+
type: import_zod24.z.string()
|
1861
2171
|
});
|
1862
2172
|
|
1863
2173
|
// ../commons/src/events/EventDocument.ts
|
1864
|
-
var
|
1865
|
-
var EventDocument =
|
1866
|
-
id:
|
1867
|
-
type:
|
1868
|
-
createdAt:
|
1869
|
-
updatedAt:
|
1870
|
-
actions:
|
1871
|
-
trackingId:
|
2174
|
+
var import_zod25 = require("zod");
|
2175
|
+
var EventDocument = import_zod25.z.object({
|
2176
|
+
id: import_zod25.z.string(),
|
2177
|
+
type: import_zod25.z.string(),
|
2178
|
+
createdAt: import_zod25.z.string().datetime(),
|
2179
|
+
updatedAt: import_zod25.z.string().datetime(),
|
2180
|
+
actions: import_zod25.z.array(Action),
|
2181
|
+
trackingId: import_zod25.z.string()
|
1872
2182
|
});
|
1873
2183
|
|
1874
2184
|
// ../commons/src/events/EventIndex.ts
|
1875
|
-
var
|
2185
|
+
var import_zod26 = require("zod");
|
1876
2186
|
var EventIndex = EventMetadata.extend({
|
1877
|
-
|
2187
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
1878
2188
|
});
|
1879
|
-
var EventSearchIndex =
|
1880
|
-
|
1881
|
-
type:
|
2189
|
+
var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
|
2190
|
+
import_zod26.z.object({
|
2191
|
+
type: import_zod26.z.string()
|
1882
2192
|
// Ensures "type" (event-id) exists and is a string
|
1883
2193
|
})
|
1884
2194
|
);
|
1885
2195
|
|
1886
2196
|
// ../commons/src/events/state/index.ts
|
1887
|
-
var _ = __toESM(require("lodash"));
|
1888
2197
|
function getStatusFromActions(actions) {
|
2198
|
+
const hasRejectedAction = actions.some(
|
2199
|
+
(a) => a.status === ActionStatus.Rejected
|
2200
|
+
);
|
2201
|
+
if (hasRejectedAction) {
|
2202
|
+
return EventStatus.REJECTED;
|
2203
|
+
}
|
1889
2204
|
return actions.reduce((status, action) => {
|
1890
2205
|
if (action.type === ActionType.CREATE) {
|
1891
2206
|
return EventStatus.CREATED;
|
@@ -1922,7 +2237,7 @@ function getAssignedUserFromActions(actions) {
|
|
1922
2237
|
return user2;
|
1923
2238
|
}, null);
|
1924
2239
|
}
|
1925
|
-
function
|
2240
|
+
function aggregateActionDeclarations(actions) {
|
1926
2241
|
const excludedActions = [
|
1927
2242
|
ActionType.REQUEST_CORRECTION,
|
1928
2243
|
ActionType.PRINT_CERTIFICATE
|
@@ -1936,47 +2251,35 @@ function getData(actions) {
|
|
1936
2251
|
if (!requestAction) {
|
1937
2252
|
return status;
|
1938
2253
|
}
|
1939
|
-
return deepMerge(status, requestAction.
|
2254
|
+
return deepMerge(status, requestAction.declaration);
|
1940
2255
|
}
|
1941
|
-
return deepMerge(status, action.
|
2256
|
+
return deepMerge(status, action.declaration);
|
1942
2257
|
}, {});
|
1943
2258
|
}
|
1944
2259
|
function deepDropNulls(obj) {
|
1945
|
-
if (
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
[key]
|
1954
|
-
};
|
1955
|
-
}
|
1956
|
-
return acc;
|
1957
|
-
}, {});
|
1958
|
-
}
|
1959
|
-
function deepMerge(currentDocument, actionDocument) {
|
1960
|
-
return _.mergeWith(
|
1961
|
-
currentDocument,
|
1962
|
-
actionDocument,
|
1963
|
-
(previousValue, incomingValue) => {
|
1964
|
-
if (incomingValue === void 0) {
|
1965
|
-
return previousValue;
|
1966
|
-
}
|
1967
|
-
if (_.isArray(incomingValue)) {
|
1968
|
-
return incomingValue;
|
1969
|
-
}
|
1970
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
1971
|
-
return void 0;
|
2260
|
+
if (Array.isArray(obj)) {
|
2261
|
+
return obj.map(deepDropNulls);
|
2262
|
+
}
|
2263
|
+
if (obj !== null && typeof obj === "object") {
|
2264
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2265
|
+
const cleanedValue = deepDropNulls(value);
|
2266
|
+
if (cleanedValue !== null) {
|
2267
|
+
;
|
2268
|
+
acc[key] = cleanedValue;
|
1972
2269
|
}
|
1973
|
-
return
|
1974
|
-
}
|
1975
|
-
|
2270
|
+
return acc;
|
2271
|
+
}, {});
|
2272
|
+
}
|
2273
|
+
return obj;
|
1976
2274
|
}
|
1977
2275
|
function isUndeclaredDraft(status) {
|
1978
2276
|
return status === EventStatus.CREATED;
|
1979
2277
|
}
|
2278
|
+
function getAcceptedActions(event2) {
|
2279
|
+
return event2.actions.filter(
|
2280
|
+
(a) => a.status === ActionStatus.Accepted
|
2281
|
+
);
|
2282
|
+
}
|
1980
2283
|
function getCurrentEventState(event2) {
|
1981
2284
|
const creationAction = event2.actions.find(
|
1982
2285
|
(action) => action.type === ActionType.CREATE
|
@@ -1984,7 +2287,12 @@ function getCurrentEventState(event2) {
|
|
1984
2287
|
if (!creationAction) {
|
1985
2288
|
throw new Error(`Event ${event2.id} has no creation action`);
|
1986
2289
|
}
|
1987
|
-
const
|
2290
|
+
const activeActions = getAcceptedActions(event2);
|
2291
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2292
|
+
const registrationAction = activeActions.find(
|
2293
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2294
|
+
);
|
2295
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
1988
2296
|
return deepDropNulls({
|
1989
2297
|
id: event2.id,
|
1990
2298
|
type: event2.type,
|
@@ -1993,16 +2301,16 @@ function getCurrentEventState(event2) {
|
|
1993
2301
|
createdBy: creationAction.createdBy,
|
1994
2302
|
createdAtLocation: creationAction.createdAtLocation,
|
1995
2303
|
modifiedAt: latestAction.createdAt,
|
1996
|
-
assignedTo: getAssignedUserFromActions(
|
2304
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
1997
2305
|
updatedBy: latestAction.createdBy,
|
1998
|
-
|
1999
|
-
trackingId: event2.trackingId
|
2306
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2307
|
+
trackingId: event2.trackingId,
|
2308
|
+
registrationNumber
|
2000
2309
|
});
|
2001
2310
|
}
|
2002
2311
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2003
|
-
const actions = event2.actions.slice().sort();
|
2004
|
-
const
|
2005
|
-
const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(({ createdAt }) => createdAt > lastAction.createdAt).map((draft) => draft.action).flatMap((action) => {
|
2312
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2313
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2006
2314
|
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2007
2315
|
return [
|
2008
2316
|
action,
|
@@ -2029,46 +2337,46 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2029
2337
|
}
|
2030
2338
|
return {
|
2031
2339
|
...eventIndex,
|
2032
|
-
|
2033
|
-
...eventIndex.
|
2034
|
-
...activeDrafts[activeDrafts.length - 1].
|
2340
|
+
declaration: {
|
2341
|
+
...eventIndex.declaration,
|
2342
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2035
2343
|
}
|
2036
2344
|
};
|
2037
2345
|
}
|
2038
|
-
function
|
2346
|
+
function getAnnotationFromDrafts(drafts) {
|
2347
|
+
const actions = drafts.map((draft) => draft.action);
|
2348
|
+
const annotation = actions.reduce((ann, action) => {
|
2349
|
+
return deepMerge(ann, action.annotation ?? {});
|
2350
|
+
}, {});
|
2351
|
+
return deepDropNulls(annotation);
|
2352
|
+
}
|
2353
|
+
function getActionAnnotation({
|
2039
2354
|
event: event2,
|
2040
2355
|
actionType,
|
2041
2356
|
drafts
|
2042
2357
|
}) {
|
2043
|
-
const
|
2358
|
+
const activeActions = getAcceptedActions(event2);
|
2359
|
+
const action = activeActions.find(
|
2360
|
+
(activeAction) => actionType === activeAction.type
|
2361
|
+
);
|
2044
2362
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2045
2363
|
const sorted = [
|
2046
2364
|
...action ? [action] : [],
|
2047
2365
|
...eventDrafts.map((draft) => draft.action)
|
2048
2366
|
].sort();
|
2049
|
-
const
|
2050
|
-
return deepMerge(
|
2367
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2368
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2051
2369
|
}, {});
|
2052
|
-
return deepDropNulls(
|
2370
|
+
return deepDropNulls(annotation);
|
2053
2371
|
}
|
2054
2372
|
|
2055
2373
|
// ../commons/src/events/defineConfig.ts
|
2056
2374
|
var defineConfig = (config) => {
|
2057
2375
|
validateWorkqueueConfig(config.workqueues);
|
2058
2376
|
const input = EventConfig.parse(config);
|
2059
|
-
|
2060
|
-
return EventConfig.parse({
|
2061
|
-
...input,
|
2062
|
-
pageFields
|
2063
|
-
});
|
2377
|
+
return input;
|
2064
2378
|
};
|
2065
2379
|
|
2066
|
-
// ../commons/src/uuid.ts
|
2067
|
-
var import_uuid = require("uuid");
|
2068
|
-
function getUUID() {
|
2069
|
-
return (0, import_uuid.v4)();
|
2070
|
-
}
|
2071
|
-
|
2072
2380
|
// ../commons/src/events/transactions.ts
|
2073
2381
|
function generateTransactionId() {
|
2074
2382
|
return getUUID();
|
@@ -2081,6 +2389,16 @@ var import_lodash2 = require("lodash");
|
|
2081
2389
|
function defineConditional(schema) {
|
2082
2390
|
return schema;
|
2083
2391
|
}
|
2392
|
+
function defineFormConditional(schema) {
|
2393
|
+
const schemaWithForm = {
|
2394
|
+
type: "object",
|
2395
|
+
properties: {
|
2396
|
+
$form: schema
|
2397
|
+
},
|
2398
|
+
required: ["$form"]
|
2399
|
+
};
|
2400
|
+
return defineConditional(schemaWithForm);
|
2401
|
+
}
|
2084
2402
|
function alwaysTrue() {
|
2085
2403
|
return {};
|
2086
2404
|
}
|
@@ -2105,6 +2423,9 @@ function not(condition) {
|
|
2105
2423
|
required: []
|
2106
2424
|
});
|
2107
2425
|
}
|
2426
|
+
function never() {
|
2427
|
+
return not(alwaysTrue());
|
2428
|
+
}
|
2108
2429
|
var user = {
|
2109
2430
|
hasScope: (scope) => defineConditional({
|
2110
2431
|
type: "object",
|
@@ -2152,69 +2473,120 @@ var event = {
|
|
2152
2473
|
required: ["$event"]
|
2153
2474
|
})
|
2154
2475
|
};
|
2476
|
+
function getDateFromNow(days) {
|
2477
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2478
|
+
}
|
2479
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2480
|
+
return {
|
2481
|
+
type: "object",
|
2482
|
+
properties: {
|
2483
|
+
[fieldId]: {
|
2484
|
+
type: "string",
|
2485
|
+
format: "date",
|
2486
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2487
|
+
},
|
2488
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2489
|
+
},
|
2490
|
+
required: [fieldId]
|
2491
|
+
};
|
2492
|
+
}
|
2493
|
+
function isFieldReference(value) {
|
2494
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2495
|
+
}
|
2155
2496
|
function field(fieldId) {
|
2156
|
-
const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2157
2497
|
const getDateRange = (date, clause) => ({
|
2158
2498
|
type: "object",
|
2159
2499
|
properties: {
|
2160
|
-
|
2161
|
-
type: "
|
2162
|
-
|
2163
|
-
|
2164
|
-
type: "string",
|
2165
|
-
format: "date",
|
2166
|
-
[clause]: date
|
2167
|
-
}
|
2168
|
-
},
|
2169
|
-
required: [fieldId]
|
2500
|
+
[fieldId]: {
|
2501
|
+
type: "string",
|
2502
|
+
format: "date",
|
2503
|
+
[clause]: date
|
2170
2504
|
}
|
2171
2505
|
},
|
2172
|
-
required: [
|
2506
|
+
required: [fieldId]
|
2173
2507
|
});
|
2174
2508
|
return {
|
2509
|
+
/**
|
2510
|
+
* @private Internal property used for field reference tracking.
|
2511
|
+
*/
|
2512
|
+
_fieldId: fieldId,
|
2175
2513
|
isAfter: () => ({
|
2176
2514
|
days: (days) => ({
|
2177
|
-
inPast: () =>
|
2515
|
+
inPast: () => defineFormConditional(
|
2178
2516
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2179
2517
|
),
|
2180
|
-
inFuture: () =>
|
2518
|
+
inFuture: () => defineFormConditional(
|
2181
2519
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2182
2520
|
)
|
2183
2521
|
}),
|
2184
|
-
date: (date) =>
|
2185
|
-
|
2522
|
+
date: (date) => {
|
2523
|
+
if (isFieldReference(date)) {
|
2524
|
+
const comparedFieldId = date._fieldId;
|
2525
|
+
return defineFormConditional(
|
2526
|
+
getDateRangeToFieldReference(
|
2527
|
+
fieldId,
|
2528
|
+
comparedFieldId,
|
2529
|
+
"formatMinimum"
|
2530
|
+
)
|
2531
|
+
);
|
2532
|
+
}
|
2533
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2534
|
+
},
|
2535
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2186
2536
|
}),
|
2187
2537
|
isBefore: () => ({
|
2188
2538
|
days: (days) => ({
|
2189
|
-
inPast: () =>
|
2539
|
+
inPast: () => defineFormConditional(
|
2190
2540
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2191
2541
|
),
|
2192
|
-
inFuture: () =>
|
2542
|
+
inFuture: () => defineFormConditional(
|
2193
2543
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2194
2544
|
)
|
2195
2545
|
}),
|
2196
|
-
date: (date) =>
|
2197
|
-
|
2546
|
+
date: (date) => {
|
2547
|
+
if (isFieldReference(date)) {
|
2548
|
+
const comparedFieldId = date._fieldId;
|
2549
|
+
return defineFormConditional(
|
2550
|
+
getDateRangeToFieldReference(
|
2551
|
+
fieldId,
|
2552
|
+
comparedFieldId,
|
2553
|
+
"formatMaximum"
|
2554
|
+
)
|
2555
|
+
);
|
2556
|
+
}
|
2557
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2558
|
+
},
|
2559
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2198
2560
|
}),
|
2199
|
-
isEqualTo: (value) =>
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2561
|
+
isEqualTo: (value) => {
|
2562
|
+
if (isFieldReference(value)) {
|
2563
|
+
const comparedFieldId = value._fieldId;
|
2564
|
+
return defineFormConditional({
|
2203
2565
|
type: "object",
|
2204
2566
|
properties: {
|
2205
2567
|
[fieldId]: {
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
const: value
|
2211
|
-
}
|
2568
|
+
type: ["string", "boolean"],
|
2569
|
+
const: { $data: `1/${comparedFieldId}` }
|
2570
|
+
},
|
2571
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2212
2572
|
},
|
2213
|
-
required: [fieldId]
|
2214
|
-
}
|
2215
|
-
}
|
2216
|
-
|
2217
|
-
|
2573
|
+
required: [fieldId, comparedFieldId]
|
2574
|
+
});
|
2575
|
+
}
|
2576
|
+
return defineFormConditional({
|
2577
|
+
type: "object",
|
2578
|
+
properties: {
|
2579
|
+
[fieldId]: {
|
2580
|
+
oneOf: [
|
2581
|
+
{ type: "string", const: value },
|
2582
|
+
{ type: "boolean", const: value }
|
2583
|
+
],
|
2584
|
+
const: value
|
2585
|
+
}
|
2586
|
+
},
|
2587
|
+
required: [fieldId]
|
2588
|
+
});
|
2589
|
+
},
|
2218
2590
|
/**
|
2219
2591
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2220
2592
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2223,91 +2595,102 @@ function field(fieldId) {
|
|
2223
2595
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2224
2596
|
*
|
2225
2597
|
*/
|
2226
|
-
isFalsy: () =>
|
2598
|
+
isFalsy: () => defineFormConditional({
|
2227
2599
|
type: "object",
|
2228
2600
|
properties: {
|
2229
|
-
|
2230
|
-
type: "object",
|
2231
|
-
properties: {
|
2232
|
-
[fieldId]: {
|
2233
|
-
anyOf: [
|
2234
|
-
{ const: "undefined" },
|
2235
|
-
{ const: false },
|
2236
|
-
{ const: null },
|
2237
|
-
{ const: "" }
|
2238
|
-
]
|
2239
|
-
}
|
2240
|
-
},
|
2601
|
+
[fieldId]: {
|
2241
2602
|
anyOf: [
|
2242
|
-
{
|
2243
|
-
|
2244
|
-
},
|
2245
|
-
{
|
2246
|
-
not: {
|
2247
|
-
required: [fieldId]
|
2248
|
-
}
|
2249
|
-
}
|
2603
|
+
{ const: "undefined" },
|
2604
|
+
{ const: false },
|
2605
|
+
{ const: null },
|
2606
|
+
{ const: "" }
|
2250
2607
|
]
|
2251
2608
|
}
|
2252
2609
|
},
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
$form: {
|
2259
|
-
type: "object",
|
2260
|
-
properties: {
|
2261
|
-
[fieldId]: {
|
2262
|
-
type: "string",
|
2263
|
-
enum: ["undefined"]
|
2264
|
-
}
|
2265
|
-
},
|
2610
|
+
anyOf: [
|
2611
|
+
{
|
2612
|
+
required: [fieldId]
|
2613
|
+
},
|
2614
|
+
{
|
2266
2615
|
not: {
|
2267
2616
|
required: [fieldId]
|
2268
2617
|
}
|
2269
2618
|
}
|
2619
|
+
]
|
2620
|
+
}),
|
2621
|
+
isUndefined: () => defineFormConditional({
|
2622
|
+
type: "object",
|
2623
|
+
properties: {
|
2624
|
+
[fieldId]: {
|
2625
|
+
type: "string",
|
2626
|
+
enum: ["undefined"]
|
2627
|
+
}
|
2270
2628
|
},
|
2271
|
-
|
2629
|
+
not: {
|
2630
|
+
required: [fieldId]
|
2631
|
+
}
|
2272
2632
|
}),
|
2273
|
-
inArray: (values) =>
|
2633
|
+
inArray: (values) => defineFormConditional({
|
2274
2634
|
type: "object",
|
2275
2635
|
properties: {
|
2276
|
-
|
2277
|
-
type: "
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2636
|
+
[fieldId]: {
|
2637
|
+
type: "string",
|
2638
|
+
enum: values
|
2639
|
+
}
|
2640
|
+
},
|
2641
|
+
required: [fieldId]
|
2642
|
+
}),
|
2643
|
+
isValidEnglishName: () => defineFormConditional({
|
2644
|
+
type: "object",
|
2645
|
+
properties: {
|
2646
|
+
[fieldId]: {
|
2647
|
+
type: "string",
|
2648
|
+
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
2649
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2650
|
+
}
|
2651
|
+
},
|
2652
|
+
required: [fieldId]
|
2653
|
+
}),
|
2654
|
+
/**
|
2655
|
+
* Checks if the field value matches a given regular expression pattern.
|
2656
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2657
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2658
|
+
*/
|
2659
|
+
matches: (pattern) => defineFormConditional({
|
2660
|
+
type: "object",
|
2661
|
+
properties: {
|
2662
|
+
[fieldId]: {
|
2663
|
+
type: "string",
|
2664
|
+
pattern
|
2665
|
+
}
|
2666
|
+
},
|
2667
|
+
required: [fieldId]
|
2668
|
+
}),
|
2669
|
+
isBetween: (min, max) => defineFormConditional({
|
2670
|
+
type: "object",
|
2671
|
+
properties: {
|
2672
|
+
[fieldId]: {
|
2673
|
+
type: "number",
|
2674
|
+
minimum: min,
|
2675
|
+
maximum: max
|
2285
2676
|
}
|
2286
2677
|
},
|
2287
|
-
required: [
|
2678
|
+
required: [fieldId]
|
2288
2679
|
})
|
2289
2680
|
};
|
2290
2681
|
}
|
2291
2682
|
|
2292
2683
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2293
|
-
var PRINT_CERTIFICATE_FORM =
|
2684
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2294
2685
|
label: {
|
2295
2686
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2296
2687
|
defaultMessage: "Tennis club membership certificate collector",
|
2297
2688
|
description: "This is what this form is referred as in the system"
|
2298
2689
|
},
|
2299
|
-
version: {
|
2300
|
-
id: "1.0.0",
|
2301
|
-
label: {
|
2302
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2303
|
-
defaultMessage: "Version 1",
|
2304
|
-
description: "This is the first version of the form"
|
2305
|
-
}
|
2306
|
-
},
|
2307
|
-
active: true,
|
2308
2690
|
pages: [
|
2309
2691
|
{
|
2310
2692
|
id: "collector",
|
2693
|
+
type: PageTypes.enum.FORM,
|
2311
2694
|
title: {
|
2312
2695
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2313
2696
|
defaultMessage: "Print certified copy",
|
@@ -2322,7 +2705,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2322
2705
|
defaultMessage: "Requester",
|
2323
2706
|
description: "This is the label for the field"
|
2324
2707
|
},
|
2325
|
-
type:
|
2708
|
+
type: FieldType.SELECT,
|
2326
2709
|
options: [
|
2327
2710
|
{
|
2328
2711
|
value: "INFORMANT",
|
@@ -2399,7 +2782,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2399
2782
|
defaultMessage: "Select Type of ID",
|
2400
2783
|
description: "This is the label for selecting the type of ID"
|
2401
2784
|
},
|
2402
|
-
type:
|
2785
|
+
type: FieldType.SELECT,
|
2403
2786
|
options: [
|
2404
2787
|
{
|
2405
2788
|
value: "PASSPORT",
|
@@ -2500,7 +2883,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2500
2883
|
defaultMessage: "Passport Details",
|
2501
2884
|
description: "Field for entering Passport details"
|
2502
2885
|
},
|
2503
|
-
type:
|
2886
|
+
type: FieldType.TEXT
|
2504
2887
|
},
|
2505
2888
|
{
|
2506
2889
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2551,7 +2934,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2551
2934
|
defaultMessage: "Driving License Details",
|
2552
2935
|
description: "Field for entering Driving License details"
|
2553
2936
|
},
|
2554
|
-
type:
|
2937
|
+
type: FieldType.TEXT
|
2555
2938
|
},
|
2556
2939
|
{
|
2557
2940
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2602,7 +2985,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2602
2985
|
defaultMessage: "Refugee Number Details",
|
2603
2986
|
description: "Field for entering Refugee Number details"
|
2604
2987
|
},
|
2605
|
-
type:
|
2988
|
+
type: FieldType.TEXT
|
2606
2989
|
},
|
2607
2990
|
{
|
2608
2991
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2653,7 +3036,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2653
3036
|
defaultMessage: "Alien Number Details",
|
2654
3037
|
description: "Field for entering Alien Number details"
|
2655
3038
|
},
|
2656
|
-
type:
|
3039
|
+
type: FieldType.TEXT
|
2657
3040
|
},
|
2658
3041
|
{
|
2659
3042
|
id: "collector.OTHER.idTypeOther",
|
@@ -2704,7 +3087,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2704
3087
|
defaultMessage: "Other ID Type (if applicable)",
|
2705
3088
|
description: 'Field for entering ID type if "Other" is selected'
|
2706
3089
|
},
|
2707
|
-
type:
|
3090
|
+
type: FieldType.TEXT
|
2708
3091
|
},
|
2709
3092
|
{
|
2710
3093
|
id: "collector.OTHER.firstName",
|
@@ -2755,7 +3138,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2755
3138
|
defaultMessage: "First Name",
|
2756
3139
|
description: "This is the label for the first name field"
|
2757
3140
|
},
|
2758
|
-
type:
|
3141
|
+
type: FieldType.TEXT
|
2759
3142
|
},
|
2760
3143
|
{
|
2761
3144
|
id: "collector.OTHER.lastName",
|
@@ -2806,7 +3189,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2806
3189
|
defaultMessage: "Last Name",
|
2807
3190
|
description: "This is the label for the last name field"
|
2808
3191
|
},
|
2809
|
-
type:
|
3192
|
+
type: FieldType.TEXT
|
2810
3193
|
},
|
2811
3194
|
{
|
2812
3195
|
id: "collector.OTHER.relationshipToMember",
|
@@ -2857,7 +3240,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2857
3240
|
defaultMessage: "Relationship to Member",
|
2858
3241
|
description: "This is the label for the relationship to member field"
|
2859
3242
|
},
|
2860
|
-
type:
|
3243
|
+
type: FieldType.TEXT
|
2861
3244
|
},
|
2862
3245
|
{
|
2863
3246
|
id: "collector.OTHER.signedAffidavit",
|
@@ -2908,66 +3291,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2908
3291
|
defaultMessage: "Signed Affidavit (Optional)",
|
2909
3292
|
description: "This is the label for uploading a signed affidavit"
|
2910
3293
|
},
|
2911
|
-
type:
|
3294
|
+
type: FieldType.FILE
|
2912
3295
|
}
|
2913
3296
|
]
|
2914
|
-
}
|
2915
|
-
],
|
2916
|
-
review: {
|
2917
|
-
title: {
|
2918
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
2919
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
2920
|
-
description: "Title of the form to show in review page"
|
2921
3297
|
},
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
3298
|
+
{
|
3299
|
+
id: "collector.identity.verify",
|
3300
|
+
type: PageTypes.enum.VERIFICATION,
|
3301
|
+
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3302
|
+
title: {
|
3303
|
+
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
3304
|
+
defaultMessage: "Verify their identity",
|
3305
|
+
description: "This is the title of the section"
|
3306
|
+
},
|
3307
|
+
fields: [],
|
3308
|
+
actions: {
|
3309
|
+
verify: {
|
3310
|
+
label: {
|
3311
|
+
defaultMessage: "Verified",
|
3312
|
+
description: "This is the label for the verification button",
|
3313
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.verify"
|
3314
|
+
}
|
3315
|
+
},
|
3316
|
+
cancel: {
|
3317
|
+
label: {
|
3318
|
+
defaultMessage: "Identity does not match",
|
3319
|
+
description: "This is the label for the verification cancellation button",
|
3320
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
|
3321
|
+
},
|
3322
|
+
confirmation: {
|
3323
|
+
title: {
|
3324
|
+
defaultMessage: "Print without proof of ID?",
|
3325
|
+
description: "This is the title for the verification cancellation modal",
|
3326
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
|
3327
|
+
},
|
3328
|
+
body: {
|
3329
|
+
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",
|
3330
|
+
description: "This is the body for the verification cancellation modal",
|
3331
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
|
3332
|
+
}
|
3333
|
+
}
|
3334
|
+
}
|
3335
|
+
}
|
2938
3336
|
}
|
3337
|
+
]
|
3338
|
+
});
|
3339
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3340
|
+
title: {
|
3341
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3342
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3343
|
+
description: "Title of the review page"
|
2939
3344
|
},
|
2940
|
-
|
2941
|
-
|
2942
|
-
id: "
|
2943
|
-
|
2944
|
-
|
3345
|
+
fields: [
|
3346
|
+
{
|
3347
|
+
id: "review.comment",
|
3348
|
+
type: FieldType.TEXTAREA,
|
3349
|
+
label: {
|
3350
|
+
defaultMessage: "Comment",
|
3351
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3352
|
+
description: "Label for the comment field in the review section"
|
3353
|
+
}
|
2945
3354
|
},
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
description: "Label for the comment field in the review section"
|
2954
|
-
}
|
3355
|
+
{
|
3356
|
+
type: FieldType.SIGNATURE,
|
3357
|
+
id: "review.signature",
|
3358
|
+
label: {
|
3359
|
+
defaultMessage: "Signature of informant",
|
3360
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3361
|
+
description: "Label for the signature field in the review section"
|
2955
3362
|
},
|
2956
|
-
{
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
defaultMessage: "Signature of informant",
|
2961
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
2962
|
-
description: "Label for the signature field in the review section"
|
2963
|
-
},
|
2964
|
-
signaturePromptLabel: {
|
2965
|
-
id: "v2.signature.upload.modal.title",
|
2966
|
-
defaultMessage: "Draw signature",
|
2967
|
-
description: "Title for the modal to draw signature"
|
2968
|
-
}
|
3363
|
+
signaturePromptLabel: {
|
3364
|
+
id: "v2.signature.upload.modal.title",
|
3365
|
+
defaultMessage: "Draw signature",
|
3366
|
+
description: "Title for the modal to draw signature"
|
2969
3367
|
}
|
2970
|
-
|
3368
|
+
}
|
3369
|
+
]
|
3370
|
+
};
|
3371
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3372
|
+
label: {
|
3373
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3374
|
+
defaultMessage: "Tennis club membership application",
|
3375
|
+
description: "This is what this form is referred as in the system"
|
2971
3376
|
},
|
2972
3377
|
pages: [
|
2973
3378
|
{
|
@@ -2980,7 +3385,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2980
3385
|
fields: [
|
2981
3386
|
{
|
2982
3387
|
id: "applicant.firstname",
|
2983
|
-
type:
|
3388
|
+
type: FieldType.TEXT,
|
2984
3389
|
required: true,
|
2985
3390
|
conditionals: [],
|
2986
3391
|
label: {
|
@@ -2991,7 +3396,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2991
3396
|
},
|
2992
3397
|
{
|
2993
3398
|
id: "applicant.surname",
|
2994
|
-
type:
|
3399
|
+
type: FieldType.TEXT,
|
2995
3400
|
required: true,
|
2996
3401
|
conditionals: [],
|
2997
3402
|
label: {
|
@@ -3013,9 +3418,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3013
3418
|
},
|
3014
3419
|
{
|
3015
3420
|
id: "applicant.dob",
|
3016
|
-
type:
|
3421
|
+
type: FieldType.DATE,
|
3017
3422
|
required: true,
|
3018
|
-
conditionals: [],
|
3019
3423
|
validation: [
|
3020
3424
|
{
|
3021
3425
|
message: {
|
@@ -3026,15 +3430,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3026
3430
|
validator: field("applicant.dob").isBefore().now()
|
3027
3431
|
}
|
3028
3432
|
],
|
3433
|
+
conditionals: [
|
3434
|
+
{
|
3435
|
+
type: ConditionalType.SHOW,
|
3436
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3437
|
+
}
|
3438
|
+
],
|
3029
3439
|
label: {
|
3030
3440
|
defaultMessage: "Applicant's date of birth",
|
3031
3441
|
description: "This is the label for the field",
|
3032
3442
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3033
3443
|
}
|
3034
3444
|
},
|
3445
|
+
{
|
3446
|
+
id: "applicant.dobUnknown",
|
3447
|
+
type: FieldType.CHECKBOX,
|
3448
|
+
required: false,
|
3449
|
+
label: {
|
3450
|
+
defaultMessage: "Exact date of birth unknown",
|
3451
|
+
description: "This is the label for the field",
|
3452
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3453
|
+
},
|
3454
|
+
conditionals: [
|
3455
|
+
{
|
3456
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3457
|
+
conditional: never()
|
3458
|
+
}
|
3459
|
+
]
|
3460
|
+
},
|
3461
|
+
{
|
3462
|
+
id: "applicant.age",
|
3463
|
+
type: FieldType.NUMBER,
|
3464
|
+
required: true,
|
3465
|
+
label: {
|
3466
|
+
defaultMessage: "Age of tennis-member",
|
3467
|
+
description: "This is the label for the field",
|
3468
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3469
|
+
},
|
3470
|
+
conditionals: [
|
3471
|
+
{
|
3472
|
+
type: ConditionalType.SHOW,
|
3473
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3474
|
+
}
|
3475
|
+
]
|
3476
|
+
},
|
3035
3477
|
{
|
3036
3478
|
id: "applicant.image",
|
3037
|
-
type:
|
3479
|
+
type: FieldType.FILE,
|
3038
3480
|
required: false,
|
3039
3481
|
label: {
|
3040
3482
|
defaultMessage: "Applicant's profile picture",
|
@@ -3055,6 +3497,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3055
3497
|
}
|
3056
3498
|
]
|
3057
3499
|
},
|
3500
|
+
{
|
3501
|
+
id: "senior-pass",
|
3502
|
+
conditional: field("applicant.dob").isBefore().date("1950-01-01"),
|
3503
|
+
title: {
|
3504
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
|
3505
|
+
defaultMessage: "Assign senior pass for applicant",
|
3506
|
+
description: "This is the title of the section"
|
3507
|
+
},
|
3508
|
+
fields: [
|
3509
|
+
{
|
3510
|
+
id: "senior-pass.id",
|
3511
|
+
type: FieldType.TEXT,
|
3512
|
+
required: true,
|
3513
|
+
label: {
|
3514
|
+
defaultMessage: "Senior pass ID",
|
3515
|
+
description: "This is the label for the field",
|
3516
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
|
3517
|
+
}
|
3518
|
+
}
|
3519
|
+
]
|
3520
|
+
},
|
3058
3521
|
{
|
3059
3522
|
id: "recommender",
|
3060
3523
|
title: {
|
@@ -3076,7 +3539,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3076
3539
|
},
|
3077
3540
|
{
|
3078
3541
|
id: "recommender.firstname",
|
3079
|
-
type:
|
3542
|
+
type: FieldType.TEXT,
|
3080
3543
|
required: true,
|
3081
3544
|
conditionals: [
|
3082
3545
|
{
|
@@ -3092,7 +3555,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3092
3555
|
},
|
3093
3556
|
{
|
3094
3557
|
id: "recommender.surname",
|
3095
|
-
type:
|
3558
|
+
type: FieldType.TEXT,
|
3096
3559
|
required: true,
|
3097
3560
|
conditionals: [
|
3098
3561
|
{
|
@@ -3108,7 +3571,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3108
3571
|
},
|
3109
3572
|
{
|
3110
3573
|
id: "recommender.id",
|
3111
|
-
type:
|
3574
|
+
type: FieldType.TEXT,
|
3112
3575
|
required: true,
|
3113
3576
|
conditionals: [
|
3114
3577
|
{
|
@@ -3216,7 +3679,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3216
3679
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3217
3680
|
id: "event.tennis-club-membership.action.declare.label"
|
3218
3681
|
},
|
3219
|
-
|
3682
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3220
3683
|
},
|
3221
3684
|
{
|
3222
3685
|
type: ActionType.VALIDATE,
|
@@ -3225,7 +3688,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3225
3688
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3226
3689
|
id: "event.tennis-club-membership.action.validate.label"
|
3227
3690
|
},
|
3228
|
-
|
3691
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3229
3692
|
},
|
3230
3693
|
{
|
3231
3694
|
type: ActionType.REGISTER,
|
@@ -3234,7 +3697,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3234
3697
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3235
3698
|
id: "event.tennis-club-membership.action.register.label"
|
3236
3699
|
},
|
3237
|
-
|
3700
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3238
3701
|
},
|
3239
3702
|
{
|
3240
3703
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3243,10 +3706,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3243
3706
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3244
3707
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3245
3708
|
},
|
3246
|
-
forms: [TENNIS_CLUB_FORM],
|
3247
3709
|
onboardingForm: [
|
3248
3710
|
{
|
3249
3711
|
id: "correction-requester",
|
3712
|
+
type: PageTypes.enum.FORM,
|
3250
3713
|
title: {
|
3251
3714
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3252
3715
|
defaultMessage: "Correction requester",
|
@@ -3310,6 +3773,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3310
3773
|
},
|
3311
3774
|
{
|
3312
3775
|
id: "identity-check",
|
3776
|
+
type: PageTypes.enum.FORM,
|
3313
3777
|
title: {
|
3314
3778
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3315
3779
|
defaultMessage: "Verify their identity",
|
@@ -3352,6 +3816,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3352
3816
|
additionalDetailsForm: [
|
3353
3817
|
{
|
3354
3818
|
id: "correction-request.supporting-documents",
|
3819
|
+
type: PageTypes.enum.FORM,
|
3355
3820
|
title: {
|
3356
3821
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3357
3822
|
defaultMessage: "Upload supporting documents",
|
@@ -3369,7 +3834,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3369
3834
|
},
|
3370
3835
|
{
|
3371
3836
|
id: "correction.supportingDocs",
|
3372
|
-
type:
|
3837
|
+
type: FieldType.FILE,
|
3373
3838
|
label: {
|
3374
3839
|
id: "correction.corrector.title",
|
3375
3840
|
defaultMessage: "Upload supporting documents",
|
@@ -3413,6 +3878,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3413
3878
|
},
|
3414
3879
|
{
|
3415
3880
|
id: "correction-request.additional-details",
|
3881
|
+
type: PageTypes.enum.FORM,
|
3416
3882
|
title: {
|
3417
3883
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3418
3884
|
defaultMessage: "Reason for correction",
|
@@ -3421,7 +3887,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3421
3887
|
fields: [
|
3422
3888
|
{
|
3423
3889
|
id: "correction.request.reason",
|
3424
|
-
type:
|
3890
|
+
type: FieldType.TEXT,
|
3425
3891
|
label: {
|
3426
3892
|
id: "correction.reason.title",
|
3427
3893
|
defaultMessage: "Reason for correction?",
|
@@ -3434,7 +3900,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3434
3900
|
},
|
3435
3901
|
{
|
3436
3902
|
type: ActionType.APPROVE_CORRECTION,
|
3437
|
-
forms: [TENNIS_CLUB_FORM],
|
3438
3903
|
label: {
|
3439
3904
|
defaultMessage: "Approve correction",
|
3440
3905
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3448,7 +3913,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3448
3913
|
defaultMessage: "Print certificate",
|
3449
3914
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3450
3915
|
},
|
3451
|
-
|
3916
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3452
3917
|
conditionals: [
|
3453
3918
|
{
|
3454
3919
|
type: "SHOW",
|
@@ -3488,6 +3953,22 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3488
3953
|
})
|
3489
3954
|
}
|
3490
3955
|
]
|
3956
|
+
},
|
3957
|
+
{
|
3958
|
+
type: ActionType.ARCHIVE,
|
3959
|
+
label: {
|
3960
|
+
id: "v2.event.tennis-club-membership.action.archive.label",
|
3961
|
+
defaultMessage: "Archive",
|
3962
|
+
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3963
|
+
}
|
3964
|
+
},
|
3965
|
+
{
|
3966
|
+
type: ActionType.REJECT,
|
3967
|
+
label: {
|
3968
|
+
id: "v2.event.tennis-club-membership.action.reject.label",
|
3969
|
+
defaultMessage: "Reject",
|
3970
|
+
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3971
|
+
}
|
3491
3972
|
}
|
3492
3973
|
],
|
3493
3974
|
advancedSearch: [
|
@@ -3503,20 +3984,53 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3503
3984
|
}
|
3504
3985
|
]
|
3505
3986
|
}
|
3506
|
-
]
|
3987
|
+
],
|
3988
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3507
3989
|
});
|
3508
3990
|
|
3509
3991
|
// ../commons/src/events/test.utils.ts
|
3510
|
-
function
|
3511
|
-
|
3512
|
-
const data = fields.reduce(
|
3992
|
+
function fieldConfigsToActionPayload(fields) {
|
3993
|
+
return fields.reduce(
|
3513
3994
|
(acc, field2, i) => ({
|
3514
3995
|
...acc,
|
3515
3996
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3516
3997
|
}),
|
3517
3998
|
{}
|
3518
3999
|
);
|
3519
|
-
|
4000
|
+
}
|
4001
|
+
function generateActionDeclarationInput(configuration, action) {
|
4002
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
4003
|
+
if (parsed.success) {
|
4004
|
+
const fields = getDeclarationFields(configuration);
|
4005
|
+
const declarationConfig = getDeclaration(configuration);
|
4006
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4007
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
4008
|
+
}
|
4009
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
4010
|
+
return {};
|
4011
|
+
}
|
4012
|
+
function generateActionAnnotationInput(configuration, action) {
|
4013
|
+
const actionConfig = configuration.actions.find(
|
4014
|
+
(ac) => ac.type === action
|
4015
|
+
);
|
4016
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4017
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4018
|
+
const visibleVerificationPageIds = findRecordActionPages(
|
4019
|
+
configuration,
|
4020
|
+
action
|
4021
|
+
).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
4022
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
4023
|
+
(acc, pageId) => ({
|
4024
|
+
...acc,
|
4025
|
+
[pageId]: true
|
4026
|
+
}),
|
4027
|
+
{}
|
4028
|
+
);
|
4029
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4030
|
+
return {
|
4031
|
+
...fieldBasedPayload,
|
4032
|
+
...visiblePageVerificationMap
|
4033
|
+
};
|
3520
4034
|
}
|
3521
4035
|
var eventPayloadGenerator = {
|
3522
4036
|
create: (input = {}) => ({
|
@@ -3528,21 +4042,22 @@ var eventPayloadGenerator = {
|
|
3528
4042
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3529
4043
|
id
|
3530
4044
|
}),
|
3531
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4045
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3532
4046
|
{
|
3533
4047
|
id: getUUID(),
|
3534
4048
|
eventId,
|
3535
4049
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3536
4050
|
transactionId: getUUID(),
|
3537
4051
|
action: {
|
3538
|
-
type:
|
3539
|
-
|
4052
|
+
type: actionType,
|
4053
|
+
status: ActionStatus.Accepted,
|
4054
|
+
declaration: {
|
3540
4055
|
"applicant.firstname": "Max",
|
3541
4056
|
"applicant.surname": "McLaren",
|
3542
4057
|
"applicant.dob": "2020-01-02",
|
3543
4058
|
"recommender.none": true
|
3544
4059
|
},
|
3545
|
-
|
4060
|
+
annotation: {
|
3546
4061
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3547
4062
|
"correction.request.reason": "Child's name was incorrect"
|
3548
4063
|
},
|
@@ -3557,41 +4072,104 @@ var eventPayloadGenerator = {
|
|
3557
4072
|
declare: (eventId, input = {}) => ({
|
3558
4073
|
type: ActionType.DECLARE,
|
3559
4074
|
transactionId: input.transactionId ?? getUUID(),
|
3560
|
-
|
4075
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4076
|
+
tennisClubMembershipEvent,
|
4077
|
+
ActionType.DECLARE
|
4078
|
+
),
|
4079
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4080
|
+
tennisClubMembershipEvent,
|
4081
|
+
ActionType.DECLARE
|
4082
|
+
),
|
3561
4083
|
eventId
|
3562
4084
|
}),
|
4085
|
+
/**
|
4086
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4087
|
+
*/
|
4088
|
+
notify: (eventId, input = {}) => {
|
4089
|
+
let declaration = input.declaration;
|
4090
|
+
if (!declaration) {
|
4091
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4092
|
+
generateActionDeclarationInput(
|
4093
|
+
tennisClubMembershipEvent,
|
4094
|
+
ActionType.DECLARE
|
4095
|
+
),
|
4096
|
+
import_lodash2.isString
|
4097
|
+
);
|
4098
|
+
declaration = partialDeclaration;
|
4099
|
+
}
|
4100
|
+
return {
|
4101
|
+
type: ActionType.NOTIFY,
|
4102
|
+
transactionId: input.transactionId ?? getUUID(),
|
4103
|
+
declaration,
|
4104
|
+
eventId
|
4105
|
+
};
|
4106
|
+
},
|
3563
4107
|
validate: (eventId, input = {}) => ({
|
3564
4108
|
type: ActionType.VALIDATE,
|
3565
4109
|
transactionId: input.transactionId ?? getUUID(),
|
3566
|
-
|
4110
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4111
|
+
tennisClubMembershipEvent,
|
4112
|
+
ActionType.VALIDATE
|
4113
|
+
),
|
4114
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4115
|
+
tennisClubMembershipEvent,
|
4116
|
+
ActionType.VALIDATE
|
4117
|
+
),
|
3567
4118
|
duplicates: [],
|
3568
4119
|
eventId
|
3569
4120
|
}),
|
4121
|
+
assign: (eventId, input = {}) => ({
|
4122
|
+
type: ActionType.ASSIGN,
|
4123
|
+
transactionId: input.transactionId ?? getUUID(),
|
4124
|
+
declaration: {},
|
4125
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4126
|
+
eventId
|
4127
|
+
}),
|
4128
|
+
unassign: (eventId, input = {}) => ({
|
4129
|
+
type: ActionType.UNASSIGN,
|
4130
|
+
transactionId: input.transactionId ?? getUUID(),
|
4131
|
+
declaration: {},
|
4132
|
+
assignedTo: null,
|
4133
|
+
eventId
|
4134
|
+
}),
|
3570
4135
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3571
4136
|
type: ActionType.ARCHIVE,
|
3572
4137
|
transactionId: input.transactionId ?? getUUID(),
|
3573
|
-
|
3574
|
-
|
4138
|
+
declaration: {},
|
4139
|
+
// @TODO: Check whether generator is needed?
|
4140
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3575
4141
|
duplicates: [],
|
3576
4142
|
eventId
|
3577
4143
|
}),
|
3578
4144
|
reject: (eventId, input = {}) => ({
|
3579
4145
|
type: ActionType.REJECT,
|
3580
4146
|
transactionId: input.transactionId ?? getUUID(),
|
3581
|
-
|
4147
|
+
declaration: {},
|
4148
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4149
|
+
tennisClubMembershipEvent,
|
4150
|
+
ActionType.REJECT
|
4151
|
+
),
|
3582
4152
|
duplicates: [],
|
3583
4153
|
eventId
|
3584
4154
|
}),
|
3585
4155
|
register: (eventId, input = {}) => ({
|
3586
4156
|
type: ActionType.REGISTER,
|
3587
4157
|
transactionId: input.transactionId ?? getUUID(),
|
3588
|
-
|
4158
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4159
|
+
tennisClubMembershipEvent,
|
4160
|
+
ActionType.REGISTER
|
4161
|
+
),
|
4162
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4163
|
+
tennisClubMembershipEvent,
|
4164
|
+
ActionType.REGISTER
|
4165
|
+
),
|
3589
4166
|
eventId
|
3590
4167
|
}),
|
3591
4168
|
printCertificate: (eventId, input = {}) => ({
|
3592
4169
|
type: ActionType.PRINT_CERTIFICATE,
|
3593
4170
|
transactionId: input.transactionId ?? getUUID(),
|
3594
|
-
|
4171
|
+
declaration: {},
|
4172
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3595
4173
|
tennisClubMembershipEvent,
|
3596
4174
|
ActionType.PRINT_CERTIFICATE
|
3597
4175
|
),
|
@@ -3601,17 +4179,21 @@ var eventPayloadGenerator = {
|
|
3601
4179
|
request: (eventId, input = {}) => ({
|
3602
4180
|
type: ActionType.REQUEST_CORRECTION,
|
3603
4181
|
transactionId: input.transactionId ?? getUUID(),
|
3604
|
-
|
4182
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4183
|
+
tennisClubMembershipEvent,
|
4184
|
+
ActionType.REQUEST_CORRECTION
|
4185
|
+
),
|
4186
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3605
4187
|
tennisClubMembershipEvent,
|
3606
4188
|
ActionType.REQUEST_CORRECTION
|
3607
4189
|
),
|
3608
|
-
metadata: {},
|
3609
4190
|
eventId
|
3610
4191
|
}),
|
3611
4192
|
approve: (eventId, requestId, input = {}) => ({
|
3612
4193
|
type: ActionType.APPROVE_CORRECTION,
|
3613
4194
|
transactionId: input.transactionId ?? getUUID(),
|
3614
|
-
|
4195
|
+
declaration: {},
|
4196
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3615
4197
|
tennisClubMembershipEvent,
|
3616
4198
|
ActionType.APPROVE_CORRECTION
|
3617
4199
|
),
|
@@ -3621,7 +4203,8 @@ var eventPayloadGenerator = {
|
|
3621
4203
|
reject: (eventId, requestId, input = {}) => ({
|
3622
4204
|
type: ActionType.REJECT_CORRECTION,
|
3623
4205
|
transactionId: input.transactionId ?? getUUID(),
|
3624
|
-
|
4206
|
+
declaration: {},
|
4207
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3625
4208
|
tennisClubMembershipEvent,
|
3626
4209
|
ActionType.REJECT_CORRECTION
|
3627
4210
|
),
|
@@ -3637,19 +4220,26 @@ function generateActionDocument({
|
|
3637
4220
|
defaults = {}
|
3638
4221
|
}) {
|
3639
4222
|
const actionBase = {
|
3640
|
-
createdAt
|
4223
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4224
|
+
// @TODO: This should be fixed in the future.
|
4225
|
+
createdAt: new Date(Date.now() - 500).toISOString(),
|
3641
4226
|
createdBy: getUUID(),
|
3642
4227
|
id: getUUID(),
|
3643
4228
|
createdAtLocation: "TODO",
|
3644
|
-
|
3645
|
-
|
3646
|
-
...defaults
|
4229
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4230
|
+
annotation: {},
|
4231
|
+
...defaults,
|
4232
|
+
status: ActionStatus.Accepted
|
3647
4233
|
};
|
3648
4234
|
switch (action) {
|
4235
|
+
case ActionType.READ:
|
4236
|
+
return { ...actionBase, type: action };
|
4237
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4238
|
+
return { ...actionBase, type: action };
|
3649
4239
|
case ActionType.DECLARE:
|
3650
4240
|
return { ...actionBase, type: action };
|
3651
4241
|
case ActionType.UNASSIGN:
|
3652
|
-
return { ...actionBase, type: action };
|
4242
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3653
4243
|
case ActionType.ASSIGN:
|
3654
4244
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3655
4245
|
case ActionType.VALIDATE:
|
@@ -3670,14 +4260,13 @@ function generateActionDocument({
|
|
3670
4260
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3671
4261
|
case ActionType.REJECT_CORRECTION:
|
3672
4262
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3673
|
-
case ActionType.CUSTOM:
|
3674
|
-
return { ...actionBase, type: action };
|
3675
4263
|
case ActionType.REGISTER:
|
3676
4264
|
return {
|
3677
4265
|
...actionBase,
|
3678
|
-
type: action
|
3679
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4266
|
+
type: action
|
3680
4267
|
};
|
4268
|
+
case ActionType.DELETE:
|
4269
|
+
case ActionType.DETECT_DUPLICATE:
|
3681
4270
|
default:
|
3682
4271
|
throw new Error(`Unsupported action type: ${action}`);
|
3683
4272
|
}
|
@@ -3692,12 +4281,16 @@ function generateEventDocument({
|
|
3692
4281
|
actions: actions.map(
|
3693
4282
|
(action) => generateActionDocument({ configuration, action })
|
3694
4283
|
),
|
3695
|
-
createdAt
|
4284
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4285
|
+
// @TODO: This should be fixed in the future.
|
4286
|
+
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
3696
4287
|
id: getUUID(),
|
3697
|
-
|
4288
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4289
|
+
// @TODO: This should be fixed in the future.
|
4290
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
3698
4291
|
};
|
3699
4292
|
}
|
3700
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4293
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3701
4294
|
const action = generateActionDocument({
|
3702
4295
|
configuration: tennisClubMembershipEvent,
|
3703
4296
|
action: actionType
|
@@ -3707,9 +4300,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3707
4300
|
transactionId: getUUID(),
|
3708
4301
|
action: {
|
3709
4302
|
...action,
|
3710
|
-
|
3711
|
-
...action.
|
3712
|
-
...
|
4303
|
+
declaration: {
|
4304
|
+
...action.declaration,
|
4305
|
+
...declaration
|
3713
4306
|
}
|
3714
4307
|
},
|
3715
4308
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3726,7 +4319,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3726
4319
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3727
4320
|
assignedTo: overrides.assignedTo ?? null,
|
3728
4321
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3729
|
-
|
4322
|
+
declaration: overrides.declaration ?? {
|
3730
4323
|
"recommender.none": true,
|
3731
4324
|
"applicant.firstname": "Danny",
|
3732
4325
|
"applicant.surname": "Doe",
|
@@ -3734,6 +4327,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3734
4327
|
},
|
3735
4328
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3736
4329
|
});
|
4330
|
+
var generateTranslationConfig = (message) => ({
|
4331
|
+
defaultMessage: message,
|
4332
|
+
description: "Description for ${message}",
|
4333
|
+
id: message
|
4334
|
+
});
|
3737
4335
|
|
3738
4336
|
// ../commons/src/events/TemplateConfig.ts
|
3739
4337
|
function isTemplateVariable(value) {
|
@@ -3752,7 +4350,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
3752
4350
|
return true;
|
3753
4351
|
}
|
3754
4352
|
function isFieldConfigDefaultValue(value) {
|
3755
|
-
if (!value)
|
4353
|
+
if (!value) {
|
4354
|
+
return false;
|
4355
|
+
}
|
3756
4356
|
if (isFieldValue(value)) {
|
3757
4357
|
return true;
|
3758
4358
|
}
|