@opencrvs/toolkit 1.8.0-rc.fc43738 → 1.8.0-rc.fd16d13
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/dist/commons/api/router.d.ts +6267 -2532
- package/dist/commons/conditionals/conditionals.d.ts +2 -2
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +33 -6
- package/dist/commons/conditionals/validate.test.d.ts +2 -0
- package/dist/commons/events/ActionConfig.d.ts +6 -24
- package/dist/commons/events/ActionDocument.d.ts +2747 -1183
- package/dist/commons/events/ActionInput.d.ts +4120 -1864
- package/dist/commons/events/ActionType.d.ts +1 -1
- package/dist/commons/events/CompositeFieldValue.d.ts +374 -0
- package/dist/commons/events/Draft.d.ts +376 -163
- package/dist/commons/events/EventConfig.d.ts +4 -28
- package/dist/commons/events/EventDocument.d.ts +3275 -1385
- package/dist/commons/events/EventIndex.d.ts +3 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +51 -3
- package/dist/commons/events/FieldType.d.ts +4 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +226 -40
- package/dist/commons/events/FieldValue.d.ts +119 -68
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/defineConfig.d.ts +1 -7
- package/dist/commons/events/index.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +183 -69
- package/dist/commons/events/utils.d.ts +114 -3
- package/dist/events/index.js +750 -489
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -36,12 +36,14 @@ __export(events_exports, {
|
|
36
36
|
ActionConfigBase: () => ActionConfigBase,
|
37
37
|
ActionDocument: () => ActionDocument,
|
38
38
|
ActionInput: () => ActionInput,
|
39
|
-
ActionMetadata: () => ActionMetadata,
|
40
39
|
ActionType: () => ActionType,
|
40
|
+
ActionUpdate: () => ActionUpdate,
|
41
|
+
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
41
42
|
AddressFieldValue: () => AddressFieldValue,
|
43
|
+
AdministrativeAreas: () => AdministrativeAreas,
|
42
44
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
43
45
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
44
|
-
|
46
|
+
ArchiveActionInput: () => ArchiveActionInput,
|
45
47
|
BaseActionInput: () => BaseActionInput,
|
46
48
|
CertificateConfig: () => CertificateConfig,
|
47
49
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
@@ -67,12 +69,16 @@ __export(events_exports, {
|
|
67
69
|
EventStatuses: () => EventStatuses,
|
68
70
|
FieldConfig: () => FieldConfig,
|
69
71
|
FieldType: () => FieldType,
|
72
|
+
FieldUpdateValue: () => FieldUpdateValue,
|
70
73
|
FieldValue: () => FieldValue,
|
71
74
|
FileFieldValue: () => FileFieldValue,
|
72
75
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
73
76
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
74
77
|
FormConfig: () => FormConfig,
|
75
78
|
FormPage: () => FormPage,
|
79
|
+
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
80
|
+
GenericAddressValue: () => GenericAddressValue,
|
81
|
+
GeographicalArea: () => GeographicalArea,
|
76
82
|
LanguageConfig: () => LanguageConfig,
|
77
83
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
78
84
|
NotifyActionInput: () => NotifyActionInput,
|
@@ -84,20 +90,28 @@ __export(events_exports, {
|
|
84
90
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
85
91
|
RequiredTextValue: () => RequiredTextValue,
|
86
92
|
ResolvedUser: () => ResolvedUser,
|
93
|
+
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
94
|
+
RuralAddressValue: () => RuralAddressValue,
|
87
95
|
ShowConditional: () => ShowConditional,
|
88
96
|
SummaryConfig: () => SummaryConfig,
|
89
97
|
TextValue: () => TextValue,
|
90
98
|
TranslationConfig: () => TranslationConfig,
|
99
|
+
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
100
|
+
UrbanAddressValue: () => UrbanAddressValue,
|
91
101
|
ValidateActionInput: () => ValidateActionInput,
|
92
102
|
WorkqueueConfig: () => WorkqueueConfig,
|
93
103
|
alwaysTrue: () => alwaysTrue,
|
94
104
|
and: () => and,
|
95
105
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
106
|
+
compositeFieldTypes: () => compositeFieldTypes,
|
107
|
+
createEmptyDraft: () => createEmptyDraft,
|
96
108
|
createValidationSchema: () => createValidationSchema,
|
109
|
+
deepDropNulls: () => deepDropNulls,
|
97
110
|
defineConditional: () => defineConditional,
|
98
111
|
defineConfig: () => defineConfig,
|
99
112
|
defineForm: () => defineForm,
|
100
113
|
defineFormPage: () => defineFormPage,
|
114
|
+
errorMessages: () => errorMessages,
|
101
115
|
event: () => event,
|
102
116
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
103
117
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
@@ -109,13 +123,16 @@ __export(events_exports, {
|
|
109
123
|
findActiveActionForm: () => findActiveActionForm,
|
110
124
|
findActiveActionFormFields: () => findActiveActionFormFields,
|
111
125
|
findActiveActionFormPages: () => findActiveActionFormPages,
|
126
|
+
findActiveDrafts: () => findActiveDrafts,
|
112
127
|
findInputPageFields: () => findInputPageFields,
|
113
128
|
findPageFields: () => findPageFields,
|
129
|
+
generateActionDocument: () => generateActionDocument,
|
114
130
|
generateActionInput: () => generateActionInput,
|
115
131
|
generateEventDocument: () => generateEventDocument,
|
116
132
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
117
133
|
generateTransactionId: () => generateTransactionId,
|
118
134
|
getActiveActionFields: () => getActiveActionFields,
|
135
|
+
getActiveActionFormPages: () => getActiveActionFormPages,
|
119
136
|
getAllFields: () => getAllFields,
|
120
137
|
getAllPages: () => getAllPages,
|
121
138
|
getCurrentEventState: () => getCurrentEventState,
|
@@ -133,22 +150,26 @@ __export(events_exports, {
|
|
133
150
|
isDividerFieldType: () => isDividerFieldType,
|
134
151
|
isEmailFieldType: () => isEmailFieldType,
|
135
152
|
isFacilityFieldType: () => isFacilityFieldType,
|
153
|
+
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
136
154
|
isFieldEnabled: () => isFieldEnabled,
|
155
|
+
isFieldValue: () => isFieldValue,
|
156
|
+
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
137
157
|
isFieldVisible: () => isFieldVisible,
|
138
158
|
isFileFieldType: () => isFileFieldType,
|
139
159
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
140
160
|
isLocationFieldType: () => isLocationFieldType,
|
141
161
|
isNumberFieldType: () => isNumberFieldType,
|
142
162
|
isOfficeFieldType: () => isOfficeFieldType,
|
143
|
-
isOptionalUncheckedCheckbox: () => isOptionalUncheckedCheckbox,
|
144
163
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
145
164
|
isParagraphFieldType: () => isParagraphFieldType,
|
146
165
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
147
166
|
isSelectFieldType: () => isSelectFieldType,
|
148
167
|
isSignatureFieldType: () => isSignatureFieldType,
|
168
|
+
isTemplateVariable: () => isTemplateVariable,
|
149
169
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
150
170
|
isTextFieldType: () => isTextFieldType,
|
151
171
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
172
|
+
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
152
173
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
153
174
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
154
175
|
not: () => not,
|
@@ -163,7 +184,7 @@ __export(events_exports, {
|
|
163
184
|
module.exports = __toCommonJS(events_exports);
|
164
185
|
|
165
186
|
// ../commons/src/events/ActionConfig.ts
|
166
|
-
var
|
187
|
+
var import_zod7 = require("zod");
|
167
188
|
|
168
189
|
// ../commons/src/events/Conditional.ts
|
169
190
|
var import_zod = require("zod");
|
@@ -192,10 +213,10 @@ var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
|
192
213
|
]);
|
193
214
|
|
194
215
|
// ../commons/src/events/FormConfig.ts
|
195
|
-
var
|
216
|
+
var import_zod6 = require("zod");
|
196
217
|
|
197
218
|
// ../commons/src/events/FieldConfig.ts
|
198
|
-
var
|
219
|
+
var import_zod5 = require("zod");
|
199
220
|
|
200
221
|
// ../commons/src/events/TranslationConfig.ts
|
201
222
|
var import_zod2 = require("zod");
|
@@ -235,39 +256,80 @@ var FieldType = {
|
|
235
256
|
SIGNATURE: "SIGNATURE"
|
236
257
|
};
|
237
258
|
var fieldTypes = Object.values(FieldType);
|
259
|
+
var compositeFieldTypes = [
|
260
|
+
FieldType.ADDRESS,
|
261
|
+
FieldType.FILE_WITH_OPTIONS,
|
262
|
+
FieldType.FILE
|
263
|
+
];
|
238
264
|
|
239
265
|
// ../commons/src/events/FieldValue.ts
|
266
|
+
var import_zod4 = require("zod");
|
267
|
+
|
268
|
+
// ../commons/src/events/CompositeFieldValue.ts
|
240
269
|
var import_zod3 = require("zod");
|
241
|
-
var
|
242
|
-
|
243
|
-
|
244
|
-
|
270
|
+
var GeographicalArea = {
|
271
|
+
URBAN: "URBAN",
|
272
|
+
RURAL: "RURAL"
|
273
|
+
};
|
245
274
|
var FileFieldValue = import_zod3.z.object({
|
246
275
|
filename: import_zod3.z.string(),
|
247
276
|
originalFilename: import_zod3.z.string(),
|
248
277
|
type: import_zod3.z.string()
|
249
278
|
});
|
250
279
|
var AdminStructure = import_zod3.z.object({
|
251
|
-
country: import_zod3.z.
|
280
|
+
country: import_zod3.z.literal(process.env.country || "FAR"),
|
252
281
|
province: import_zod3.z.string(),
|
253
282
|
district: import_zod3.z.string()
|
254
283
|
});
|
255
|
-
var
|
256
|
-
urbanOrRural: import_zod3.z.literal(
|
284
|
+
var UrbanAddressValue = AdminStructure.extend({
|
285
|
+
urbanOrRural: import_zod3.z.literal(GeographicalArea.URBAN),
|
257
286
|
town: import_zod3.z.string().optional(),
|
258
287
|
residentialArea: import_zod3.z.string().optional(),
|
259
288
|
street: import_zod3.z.string().optional(),
|
260
289
|
number: import_zod3.z.string().optional(),
|
261
290
|
zipCode: import_zod3.z.string().optional()
|
262
291
|
});
|
263
|
-
var
|
264
|
-
urbanOrRural: import_zod3.z.literal(
|
292
|
+
var RuralAddressValue = AdminStructure.extend({
|
293
|
+
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
265
294
|
village: import_zod3.z.string().optional()
|
266
295
|
});
|
267
|
-
var
|
268
|
-
|
269
|
-
|
270
|
-
|
296
|
+
var UrbanAddressUpdateValue = AdminStructure.extend({
|
297
|
+
urbanOrRural: import_zod3.z.literal(GeographicalArea.URBAN),
|
298
|
+
town: import_zod3.z.string().nullish(),
|
299
|
+
residentialArea: import_zod3.z.string().nullish(),
|
300
|
+
street: import_zod3.z.string().nullish(),
|
301
|
+
number: import_zod3.z.string().nullish(),
|
302
|
+
zipCode: import_zod3.z.string().nullish()
|
303
|
+
});
|
304
|
+
var RuralAddressUpdateValue = AdminStructure.extend({
|
305
|
+
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
306
|
+
village: import_zod3.z.string().nullish()
|
307
|
+
});
|
308
|
+
var GenericAddressValue = import_zod3.z.object({
|
309
|
+
country: import_zod3.z.string().refine((value) => value !== process.env.country || "FAR"),
|
310
|
+
state: import_zod3.z.string(),
|
311
|
+
district2: import_zod3.z.string(),
|
312
|
+
cityOrTown: import_zod3.z.string().optional(),
|
313
|
+
addressLine1: import_zod3.z.string().optional(),
|
314
|
+
addressLine2: import_zod3.z.string().optional(),
|
315
|
+
addressLine3: import_zod3.z.string().optional(),
|
316
|
+
postcodeOrZip: import_zod3.z.string().optional()
|
317
|
+
});
|
318
|
+
var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
|
319
|
+
var GenericAddressUpdateValue = import_zod3.z.object({
|
320
|
+
country: import_zod3.z.string().refine((value) => value !== process.env.country || "FAR"),
|
321
|
+
state: import_zod3.z.string(),
|
322
|
+
district2: import_zod3.z.string(),
|
323
|
+
cityOrTown: import_zod3.z.string().nullish(),
|
324
|
+
addressLine1: import_zod3.z.string().nullish(),
|
325
|
+
addressLine2: import_zod3.z.string().nullish(),
|
326
|
+
addressLine3: import_zod3.z.string().nullish(),
|
327
|
+
postcodeOrZip: import_zod3.z.string().nullish()
|
328
|
+
});
|
329
|
+
var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
|
330
|
+
UrbanAddressUpdateValue,
|
331
|
+
RuralAddressUpdateValue
|
332
|
+
]).or(GenericAddressUpdateValue);
|
271
333
|
var FileFieldValueWithOption = import_zod3.z.object({
|
272
334
|
filename: import_zod3.z.string(),
|
273
335
|
originalFilename: import_zod3.z.string(),
|
@@ -275,30 +337,48 @@ var FileFieldValueWithOption = import_zod3.z.object({
|
|
275
337
|
option: import_zod3.z.string()
|
276
338
|
});
|
277
339
|
var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
278
|
-
|
279
|
-
|
280
|
-
var
|
340
|
+
|
341
|
+
// ../commons/src/events/FieldValue.ts
|
342
|
+
var TextValue = import_zod4.z.string();
|
343
|
+
var RequiredTextValue = TextValue.min(1);
|
344
|
+
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
345
|
+
var EmailValue = import_zod4.z.string().email();
|
346
|
+
var CheckboxFieldValue = import_zod4.z.boolean();
|
347
|
+
var NumberFieldValue = import_zod4.z.number();
|
348
|
+
var FieldValue = import_zod4.z.union([
|
281
349
|
TextValue,
|
282
350
|
DateValue,
|
351
|
+
CheckboxFieldValue,
|
352
|
+
NumberFieldValue,
|
283
353
|
FileFieldValue,
|
284
354
|
FileFieldWithOptionValue,
|
355
|
+
UrbanAddressValue,
|
356
|
+
RuralAddressValue,
|
357
|
+
GenericAddressValue
|
358
|
+
]);
|
359
|
+
var FieldUpdateValue = import_zod4.z.union([
|
360
|
+
TextValue,
|
361
|
+
DateValue,
|
285
362
|
CheckboxFieldValue,
|
286
363
|
NumberFieldValue,
|
287
|
-
|
288
|
-
|
364
|
+
FileFieldValue,
|
365
|
+
FileFieldWithOptionValue,
|
366
|
+
UrbanAddressUpdateValue,
|
367
|
+
RuralAddressUpdateValue,
|
368
|
+
GenericAddressUpdateValue
|
289
369
|
]);
|
290
370
|
|
291
371
|
// ../commons/src/events/FieldConfig.ts
|
292
|
-
var FieldId =
|
293
|
-
var DependencyExpression =
|
294
|
-
dependsOn:
|
295
|
-
expression:
|
372
|
+
var FieldId = import_zod5.z.string();
|
373
|
+
var DependencyExpression = import_zod5.z.object({
|
374
|
+
dependsOn: import_zod5.z.array(FieldId).default([]),
|
375
|
+
expression: import_zod5.z.string()
|
296
376
|
});
|
297
|
-
var BaseField =
|
377
|
+
var BaseField = import_zod5.z.object({
|
298
378
|
id: FieldId,
|
299
|
-
defaultValue:
|
379
|
+
defaultValue: import_zod5.z.union([
|
300
380
|
// These are the currently supported default values types
|
301
|
-
|
381
|
+
import_zod5.z.union([
|
302
382
|
TextValue,
|
303
383
|
RequiredTextValue,
|
304
384
|
DateValue,
|
@@ -307,82 +387,82 @@ var BaseField = import_zod4.z.object({
|
|
307
387
|
]),
|
308
388
|
DependencyExpression
|
309
389
|
]).optional(),
|
310
|
-
conditionals:
|
311
|
-
required:
|
312
|
-
disabled:
|
313
|
-
hidden:
|
390
|
+
conditionals: import_zod5.z.array(ActionConditional).default([]).optional(),
|
391
|
+
required: import_zod5.z.boolean().default(false).optional(),
|
392
|
+
disabled: import_zod5.z.boolean().default(false).optional(),
|
393
|
+
hidden: import_zod5.z.boolean().default(false).optional(),
|
314
394
|
placeholder: TranslationConfig.optional(),
|
315
|
-
validation:
|
316
|
-
|
395
|
+
validation: import_zod5.z.array(
|
396
|
+
import_zod5.z.object({
|
317
397
|
validator: Conditional(),
|
318
398
|
message: TranslationConfig
|
319
399
|
})
|
320
400
|
).default([]).optional(),
|
321
|
-
dependsOn:
|
401
|
+
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
322
402
|
label: TranslationConfig,
|
323
|
-
hideLabel:
|
403
|
+
hideLabel: import_zod5.z.boolean().default(false).optional()
|
324
404
|
});
|
325
405
|
var Divider = BaseField.extend({
|
326
|
-
type:
|
406
|
+
type: import_zod5.z.literal(FieldType.DIVIDER)
|
327
407
|
});
|
328
408
|
var TextField = BaseField.extend({
|
329
|
-
type:
|
330
|
-
defaultValue:
|
331
|
-
configuration:
|
332
|
-
maxLength:
|
333
|
-
type:
|
409
|
+
type: import_zod5.z.literal(FieldType.TEXT),
|
410
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
|
411
|
+
configuration: import_zod5.z.object({
|
412
|
+
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
413
|
+
type: import_zod5.z.enum(["text", "password"]).optional(),
|
334
414
|
prefix: TranslationConfig.optional(),
|
335
415
|
postfix: TranslationConfig.optional()
|
336
416
|
}).default({ type: "text" }).optional()
|
337
417
|
}).describe("Text input");
|
338
418
|
var NumberField = BaseField.extend({
|
339
|
-
type:
|
340
|
-
defaultValue:
|
341
|
-
configuration:
|
342
|
-
min:
|
343
|
-
max:
|
419
|
+
type: import_zod5.z.literal(FieldType.NUMBER),
|
420
|
+
defaultValue: import_zod5.z.union([NumberFieldValue, DependencyExpression]).optional(),
|
421
|
+
configuration: import_zod5.z.object({
|
422
|
+
min: import_zod5.z.number().optional().describe("Minimum value"),
|
423
|
+
max: import_zod5.z.number().optional().describe("Maximum value"),
|
344
424
|
prefix: TranslationConfig.optional(),
|
345
425
|
postfix: TranslationConfig.optional()
|
346
426
|
}).optional()
|
347
427
|
}).describe("Number input");
|
348
428
|
var TextAreaField = BaseField.extend({
|
349
|
-
type:
|
350
|
-
defaultValue:
|
351
|
-
configuration:
|
352
|
-
maxLength:
|
353
|
-
rows:
|
354
|
-
cols:
|
429
|
+
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
430
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
|
431
|
+
configuration: import_zod5.z.object({
|
432
|
+
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
433
|
+
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
434
|
+
cols: import_zod5.z.number().optional().describe("Number of visible columns"),
|
355
435
|
prefix: TranslationConfig.optional(),
|
356
436
|
postfix: TranslationConfig.optional()
|
357
437
|
}).default({ rows: 4 }).optional()
|
358
438
|
}).describe("Multiline text input");
|
359
439
|
var SignatureField = BaseField.extend({
|
360
|
-
type:
|
440
|
+
type: import_zod5.z.literal(FieldType.SIGNATURE),
|
361
441
|
signaturePromptLabel: TranslationConfig.describe(
|
362
442
|
"Title of the signature modal"
|
363
443
|
),
|
364
|
-
configuration:
|
365
|
-
maxSizeMb:
|
366
|
-
allowedFileFormats:
|
444
|
+
configuration: import_zod5.z.object({
|
445
|
+
maxSizeMb: import_zod5.z.number().optional().describe("Maximum file size in MB"),
|
446
|
+
allowedFileFormats: import_zod5.z.array(import_zod5.z.string()).optional().describe("List of allowed file formats for the signature")
|
367
447
|
}).default({}).optional()
|
368
448
|
}).describe("Signature input field");
|
369
449
|
var EmailField = BaseField.extend({
|
370
|
-
type:
|
371
|
-
configuration:
|
372
|
-
maxLength:
|
450
|
+
type: import_zod5.z.literal(FieldType.EMAIL),
|
451
|
+
configuration: import_zod5.z.object({
|
452
|
+
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
373
453
|
}).default({ maxLength: 10 }).optional(),
|
374
|
-
defaultValue:
|
454
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
375
455
|
});
|
376
456
|
var DateField = BaseField.extend({
|
377
|
-
type:
|
378
|
-
defaultValue:
|
379
|
-
configuration:
|
457
|
+
type: import_zod5.z.literal(FieldType.DATE),
|
458
|
+
defaultValue: import_zod5.z.union([DateValue, DependencyExpression]).optional(),
|
459
|
+
configuration: import_zod5.z.object({
|
380
460
|
notice: TranslationConfig.describe(
|
381
461
|
"Text to display above the date input"
|
382
462
|
).optional()
|
383
463
|
}).optional()
|
384
464
|
}).describe("A single date input (dd-mm-YYYY)");
|
385
|
-
var HtmlFontVariant =
|
465
|
+
var HtmlFontVariant = import_zod5.z.enum([
|
386
466
|
"reg12",
|
387
467
|
"reg14",
|
388
468
|
"reg16",
|
@@ -393,97 +473,102 @@ var HtmlFontVariant = import_zod4.z.enum([
|
|
393
473
|
"h1"
|
394
474
|
]);
|
395
475
|
var Paragraph = BaseField.extend({
|
396
|
-
type:
|
397
|
-
defaultValue:
|
398
|
-
configuration:
|
399
|
-
styles:
|
476
|
+
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
477
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
|
478
|
+
configuration: import_zod5.z.object({
|
479
|
+
styles: import_zod5.z.object({
|
400
480
|
fontVariant: HtmlFontVariant.optional()
|
401
481
|
}).optional()
|
402
482
|
}).default({})
|
403
483
|
}).describe("A read-only HTML <p> paragraph");
|
404
484
|
var PageHeader = BaseField.extend({
|
405
|
-
type:
|
406
|
-
defaultValue:
|
485
|
+
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
486
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
407
487
|
}).describe("A read-only header component for form pages");
|
408
488
|
var File = BaseField.extend({
|
409
|
-
type:
|
410
|
-
options:
|
411
|
-
style:
|
412
|
-
fullWidth:
|
489
|
+
type: import_zod5.z.literal(FieldType.FILE),
|
490
|
+
options: import_zod5.z.object({
|
491
|
+
style: import_zod5.z.object({
|
492
|
+
fullWidth: import_zod5.z.boolean().describe(
|
413
493
|
"Whether the file upload button should take the full width of the container or not"
|
414
494
|
)
|
415
495
|
})
|
416
496
|
}).optional()
|
417
497
|
}).describe("File upload");
|
418
|
-
var SelectOption =
|
419
|
-
value:
|
498
|
+
var SelectOption = import_zod5.z.object({
|
499
|
+
value: import_zod5.z.string().describe("The value of the option"),
|
420
500
|
label: TranslationConfig.describe("The label of the option")
|
421
501
|
});
|
422
502
|
var RadioGroup = BaseField.extend({
|
423
|
-
type:
|
424
|
-
defaultValue:
|
425
|
-
options:
|
426
|
-
configuration:
|
427
|
-
styles:
|
428
|
-
size:
|
503
|
+
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
504
|
+
defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
|
505
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
506
|
+
configuration: import_zod5.z.object({
|
507
|
+
styles: import_zod5.z.object({
|
508
|
+
size: import_zod5.z.enum(["NORMAL", "LARGE"]).optional()
|
429
509
|
}).optional()
|
430
510
|
}).optional()
|
431
511
|
}).describe("Grouped radio options");
|
432
512
|
var BulletList = BaseField.extend({
|
433
|
-
type:
|
434
|
-
defaultValue:
|
435
|
-
items:
|
436
|
-
configuration:
|
437
|
-
styles:
|
513
|
+
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
514
|
+
defaultValue: import_zod5.z.string().optional(),
|
515
|
+
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
516
|
+
configuration: import_zod5.z.object({
|
517
|
+
styles: import_zod5.z.object({
|
438
518
|
fontVariant: HtmlFontVariant.optional()
|
439
519
|
}).optional()
|
440
520
|
}).default({})
|
441
521
|
}).describe("A list of bullet points");
|
442
522
|
var Select = BaseField.extend({
|
443
|
-
type:
|
444
|
-
defaultValue:
|
445
|
-
options:
|
523
|
+
type: import_zod5.z.literal(FieldType.SELECT),
|
524
|
+
defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
|
525
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
446
526
|
}).describe("Select input");
|
447
527
|
var Checkbox = BaseField.extend({
|
448
|
-
type:
|
449
|
-
defaultValue:
|
528
|
+
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
529
|
+
defaultValue: import_zod5.z.union([CheckboxFieldValue, DependencyExpression]).optional()
|
450
530
|
}).describe("Boolean checkbox field");
|
451
531
|
var Country = BaseField.extend({
|
452
|
-
type:
|
453
|
-
defaultValue:
|
532
|
+
type: import_zod5.z.literal(FieldType.COUNTRY),
|
533
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
454
534
|
}).describe("Country select field");
|
455
|
-
var
|
456
|
-
|
457
|
-
|
535
|
+
var AdministrativeAreas = import_zod5.z.enum([
|
536
|
+
"ADMIN_STRUCTURE",
|
537
|
+
"HEALTH_FACILITY",
|
538
|
+
"CRVS_OFFICE"
|
539
|
+
]);
|
540
|
+
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
541
|
+
partOf: import_zod5.z.object({
|
542
|
+
$data: import_zod5.z.string()
|
458
543
|
}).optional().describe("Parent location"),
|
459
|
-
type:
|
544
|
+
type: AdministrativeAreas
|
460
545
|
}).describe("Administrative area options");
|
461
546
|
var AdministrativeArea = BaseField.extend({
|
462
|
-
type:
|
463
|
-
defaultValue:
|
547
|
+
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
548
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
|
464
549
|
configuration: AdministrativeAreaConfiguration
|
465
550
|
}).describe("Administrative area input field e.g. facility, office");
|
466
551
|
var Location = BaseField.extend({
|
467
|
-
type:
|
468
|
-
defaultValue:
|
552
|
+
type: import_zod5.z.literal(FieldType.LOCATION),
|
553
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
469
554
|
}).describe("Input field for a location");
|
470
555
|
var FileUploadWithOptions = BaseField.extend({
|
471
|
-
type:
|
472
|
-
options:
|
556
|
+
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
557
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
473
558
|
}).describe("Select input");
|
474
559
|
var Facility = BaseField.extend({
|
475
|
-
type:
|
476
|
-
defaultValue:
|
560
|
+
type: import_zod5.z.literal(FieldType.FACILITY),
|
561
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
477
562
|
}).describe("Input field for a facility");
|
478
563
|
var Office = BaseField.extend({
|
479
|
-
type:
|
480
|
-
defaultValue:
|
564
|
+
type: import_zod5.z.literal(FieldType.OFFICE),
|
565
|
+
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
481
566
|
}).describe("Input field for an office");
|
482
567
|
var Address = BaseField.extend({
|
483
|
-
type:
|
568
|
+
type: import_zod5.z.literal(FieldType.ADDRESS),
|
484
569
|
defaultValue: AddressFieldValue.optional()
|
485
570
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
486
|
-
var FieldConfig =
|
571
|
+
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
487
572
|
Address,
|
488
573
|
TextField,
|
489
574
|
NumberField,
|
@@ -508,28 +593,28 @@ var FieldConfig = import_zod4.z.discriminatedUnion("type", [
|
|
508
593
|
]);
|
509
594
|
|
510
595
|
// ../commons/src/events/FormConfig.ts
|
511
|
-
var FormPage =
|
512
|
-
id:
|
596
|
+
var FormPage = import_zod6.z.object({
|
597
|
+
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
513
598
|
title: TranslationConfig.describe("Header title of the page"),
|
514
|
-
fields:
|
599
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
515
600
|
});
|
516
|
-
var FormConfig =
|
601
|
+
var FormConfig = import_zod6.z.object({
|
517
602
|
label: TranslationConfig.describe("Human readable description of the form"),
|
518
|
-
version:
|
519
|
-
id:
|
603
|
+
version: import_zod6.z.object({
|
604
|
+
id: import_zod6.z.string().describe(
|
520
605
|
"Form version. Semantic versioning recommended. Example: 0.0.1"
|
521
606
|
),
|
522
607
|
label: TranslationConfig.describe(
|
523
608
|
"Human readable description of the version"
|
524
609
|
)
|
525
610
|
}),
|
526
|
-
active:
|
527
|
-
pages:
|
528
|
-
review:
|
611
|
+
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
612
|
+
pages: import_zod6.z.array(FormPage),
|
613
|
+
review: import_zod6.z.object({
|
529
614
|
title: TranslationConfig.describe(
|
530
615
|
"Title of the form to show in review page"
|
531
616
|
),
|
532
|
-
fields:
|
617
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
533
618
|
})
|
534
619
|
});
|
535
620
|
|
@@ -551,96 +636,90 @@ var ActionType = {
|
|
551
636
|
CUSTOM: "CUSTOM",
|
552
637
|
REJECT: "REJECT",
|
553
638
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
554
|
-
|
639
|
+
ARCHIVE: "ARCHIVE"
|
555
640
|
};
|
556
641
|
|
557
642
|
// ../commons/src/events/ActionConfig.ts
|
558
|
-
var ActionConditional2 =
|
643
|
+
var ActionConditional2 = import_zod7.z.discriminatedUnion("type", [
|
559
644
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
560
645
|
ShowConditional,
|
561
646
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
562
647
|
EnableConditional
|
563
648
|
]);
|
564
|
-
var ActionConfigBase =
|
649
|
+
var ActionConfigBase = import_zod7.z.object({
|
565
650
|
label: TranslationConfig,
|
566
|
-
conditionals:
|
567
|
-
draft:
|
568
|
-
forms:
|
651
|
+
conditionals: import_zod7.z.array(ActionConditional2).optional().default([]),
|
652
|
+
draft: import_zod7.z.boolean().optional(),
|
653
|
+
forms: import_zod7.z.array(FormConfig)
|
569
654
|
});
|
570
655
|
var DeclareConfig = ActionConfigBase.merge(
|
571
|
-
|
572
|
-
type:
|
656
|
+
import_zod7.z.object({
|
657
|
+
type: import_zod7.z.literal(ActionType.DECLARE)
|
573
658
|
})
|
574
659
|
);
|
575
660
|
var ValidateConfig = ActionConfigBase.merge(
|
576
|
-
|
577
|
-
type:
|
661
|
+
import_zod7.z.object({
|
662
|
+
type: import_zod7.z.literal(ActionType.VALIDATE)
|
578
663
|
})
|
579
664
|
);
|
580
665
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
581
|
-
|
582
|
-
type:
|
583
|
-
comment: import_zod6.z.string(),
|
584
|
-
isDuplicate: import_zod6.z.boolean()
|
666
|
+
import_zod7.z.object({
|
667
|
+
type: import_zod7.z.literal(ActionType.REJECT)
|
585
668
|
})
|
586
669
|
);
|
587
670
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
588
|
-
|
589
|
-
type:
|
590
|
-
comment: import_zod6.z.string(),
|
591
|
-
duplicates: import_zod6.z.array(import_zod6.z.string()).describe("UUIDs of duplicate records")
|
671
|
+
import_zod7.z.object({
|
672
|
+
type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
592
673
|
})
|
593
674
|
);
|
594
|
-
var
|
595
|
-
|
596
|
-
type:
|
597
|
-
comment: import_zod6.z.string(),
|
598
|
-
isDuplicate: import_zod6.z.boolean()
|
675
|
+
var ArchiveConfig = ActionConfigBase.merge(
|
676
|
+
import_zod7.z.object({
|
677
|
+
type: import_zod7.z.literal(ActionType.ARCHIVE)
|
599
678
|
})
|
600
679
|
);
|
601
680
|
var RegisterConfig = ActionConfigBase.merge(
|
602
|
-
|
603
|
-
type:
|
681
|
+
import_zod7.z.object({
|
682
|
+
type: import_zod7.z.literal(ActionType.REGISTER)
|
604
683
|
})
|
605
684
|
);
|
606
685
|
var DeleteConfig = ActionConfigBase.merge(
|
607
|
-
|
608
|
-
type:
|
686
|
+
import_zod7.z.object({
|
687
|
+
type: import_zod7.z.literal(ActionType.DELETE)
|
609
688
|
})
|
610
689
|
);
|
611
690
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
612
|
-
|
613
|
-
type:
|
691
|
+
import_zod7.z.object({
|
692
|
+
type: import_zod7.z.literal(ActionType.PRINT_CERTIFICATE)
|
614
693
|
})
|
615
694
|
);
|
616
695
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
617
|
-
|
618
|
-
type:
|
619
|
-
onboardingForm:
|
620
|
-
additionalDetailsForm:
|
696
|
+
import_zod7.z.object({
|
697
|
+
type: import_zod7.z.literal(ActionType.REQUEST_CORRECTION),
|
698
|
+
onboardingForm: import_zod7.z.array(FormPage),
|
699
|
+
additionalDetailsForm: import_zod7.z.array(FormPage)
|
621
700
|
})
|
622
701
|
);
|
623
702
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
624
|
-
|
625
|
-
type:
|
703
|
+
import_zod7.z.object({
|
704
|
+
type: import_zod7.z.literal(ActionType.REJECT_CORRECTION)
|
626
705
|
})
|
627
706
|
);
|
628
707
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
629
|
-
|
630
|
-
type:
|
708
|
+
import_zod7.z.object({
|
709
|
+
type: import_zod7.z.literal(ActionType.APPROVE_CORRECTION)
|
631
710
|
})
|
632
711
|
);
|
633
712
|
var CustomConfig = ActionConfigBase.merge(
|
634
|
-
|
635
|
-
type:
|
713
|
+
import_zod7.z.object({
|
714
|
+
type: import_zod7.z.literal(ActionType.CUSTOM)
|
636
715
|
})
|
637
716
|
);
|
638
|
-
var ActionConfig =
|
717
|
+
var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
639
718
|
DeclareConfig,
|
640
719
|
ValidateConfig,
|
641
720
|
RejectDeclarationConfig,
|
642
721
|
MarkedAsDuplicateConfig,
|
643
|
-
|
722
|
+
ArchiveConfig,
|
644
723
|
RegisterConfig,
|
645
724
|
DeleteConfig,
|
646
725
|
PrintCertificateActionConfig,
|
@@ -651,97 +730,97 @@ var ActionConfig = import_zod6.z.discriminatedUnion("type", [
|
|
651
730
|
]);
|
652
731
|
|
653
732
|
// ../commons/src/events/offline/CertificateConfig.ts
|
654
|
-
var
|
655
|
-
var FontFamily =
|
656
|
-
normal:
|
657
|
-
bold:
|
658
|
-
italics:
|
659
|
-
bolditalics:
|
733
|
+
var import_zod8 = require("zod");
|
734
|
+
var FontFamily = import_zod8.z.object({
|
735
|
+
normal: import_zod8.z.string(),
|
736
|
+
bold: import_zod8.z.string(),
|
737
|
+
italics: import_zod8.z.string(),
|
738
|
+
bolditalics: import_zod8.z.string()
|
660
739
|
});
|
661
|
-
var CertificateConfig =
|
662
|
-
id:
|
663
|
-
event:
|
740
|
+
var CertificateConfig = import_zod8.z.object({
|
741
|
+
id: import_zod8.z.string(),
|
742
|
+
event: import_zod8.z.string(),
|
664
743
|
label: TranslationConfig,
|
665
|
-
isDefault:
|
666
|
-
fee:
|
667
|
-
onTime:
|
668
|
-
late:
|
669
|
-
delayed:
|
744
|
+
isDefault: import_zod8.z.boolean(),
|
745
|
+
fee: import_zod8.z.object({
|
746
|
+
onTime: import_zod8.z.number(),
|
747
|
+
late: import_zod8.z.number(),
|
748
|
+
delayed: import_zod8.z.number()
|
670
749
|
}),
|
671
|
-
svgUrl:
|
672
|
-
fonts:
|
750
|
+
svgUrl: import_zod8.z.string(),
|
751
|
+
fonts: import_zod8.z.record(FontFamily).optional()
|
673
752
|
});
|
674
753
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
675
|
-
hash:
|
676
|
-
svg:
|
754
|
+
hash: import_zod8.z.string().optional(),
|
755
|
+
svg: import_zod8.z.string()
|
677
756
|
});
|
678
757
|
|
679
758
|
// ../commons/src/events/offline/LanguageConfig.ts
|
680
|
-
var
|
681
|
-
var LanguageConfig =
|
682
|
-
lang:
|
759
|
+
var import_zod9 = require("zod");
|
760
|
+
var LanguageConfig = import_zod9.z.object({
|
761
|
+
lang: import_zod9.z.string(),
|
683
762
|
/**
|
684
763
|
* client.csv contents
|
685
764
|
*/
|
686
|
-
messages:
|
765
|
+
messages: import_zod9.z.record(import_zod9.z.string())
|
687
766
|
});
|
688
767
|
|
689
768
|
// ../commons/src/events/EventConfig.ts
|
690
|
-
var
|
769
|
+
var import_zod18 = require("zod");
|
691
770
|
|
692
771
|
// ../commons/src/events/DeduplicationConfig.ts
|
693
|
-
var
|
694
|
-
var FieldReference =
|
695
|
-
var Matcher =
|
696
|
-
fieldId:
|
697
|
-
options:
|
698
|
-
boost:
|
772
|
+
var import_zod10 = require("zod");
|
773
|
+
var FieldReference = import_zod10.z.string();
|
774
|
+
var Matcher = import_zod10.z.object({
|
775
|
+
fieldId: import_zod10.z.string(),
|
776
|
+
options: import_zod10.z.object({
|
777
|
+
boost: import_zod10.z.number().optional()
|
699
778
|
}).optional().default({})
|
700
779
|
});
|
701
780
|
var FuzzyMatcher = Matcher.extend({
|
702
|
-
type:
|
703
|
-
options:
|
781
|
+
type: import_zod10.z.literal("fuzzy"),
|
782
|
+
options: import_zod10.z.object({
|
704
783
|
/**
|
705
784
|
* Names of length 3 or less characters = 0 edits allowed
|
706
785
|
* Names of length 4 - 6 characters = 1 edit allowed
|
707
786
|
* Names of length >7 characters = 2 edits allowed
|
708
787
|
*/
|
709
|
-
fuzziness:
|
710
|
-
boost:
|
788
|
+
fuzziness: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]).optional().default("AUTO:4,7"),
|
789
|
+
boost: import_zod10.z.number().optional().default(1)
|
711
790
|
}).optional().default({})
|
712
791
|
});
|
713
792
|
var StrictMatcher = Matcher.extend({
|
714
|
-
type:
|
715
|
-
options:
|
716
|
-
boost:
|
793
|
+
type: import_zod10.z.literal("strict"),
|
794
|
+
options: import_zod10.z.object({
|
795
|
+
boost: import_zod10.z.number().optional().default(1)
|
717
796
|
}).optional().default({})
|
718
797
|
});
|
719
798
|
var DateRangeMatcher = Matcher.extend({
|
720
|
-
type:
|
721
|
-
options:
|
722
|
-
days:
|
799
|
+
type: import_zod10.z.literal("dateRange"),
|
800
|
+
options: import_zod10.z.object({
|
801
|
+
days: import_zod10.z.number(),
|
723
802
|
origin: FieldReference,
|
724
|
-
boost:
|
803
|
+
boost: import_zod10.z.number().optional().default(1)
|
725
804
|
})
|
726
805
|
});
|
727
806
|
var DateDistanceMatcher = Matcher.extend({
|
728
|
-
type:
|
729
|
-
options:
|
730
|
-
days:
|
807
|
+
type: import_zod10.z.literal("dateDistance"),
|
808
|
+
options: import_zod10.z.object({
|
809
|
+
days: import_zod10.z.number(),
|
731
810
|
origin: FieldReference,
|
732
|
-
boost:
|
811
|
+
boost: import_zod10.z.number().optional().default(1)
|
733
812
|
})
|
734
813
|
});
|
735
|
-
var And =
|
736
|
-
type:
|
737
|
-
clauses:
|
814
|
+
var And = import_zod10.z.object({
|
815
|
+
type: import_zod10.z.literal("and"),
|
816
|
+
clauses: import_zod10.z.lazy(() => Clause.array())
|
738
817
|
});
|
739
|
-
var Or =
|
740
|
-
type:
|
741
|
-
clauses:
|
818
|
+
var Or = import_zod10.z.object({
|
819
|
+
type: import_zod10.z.literal("or"),
|
820
|
+
clauses: import_zod10.z.lazy(() => Clause.array())
|
742
821
|
});
|
743
|
-
var Clause =
|
744
|
-
() =>
|
822
|
+
var Clause = import_zod10.z.lazy(
|
823
|
+
() => import_zod10.z.discriminatedUnion("type", [
|
745
824
|
And,
|
746
825
|
Or,
|
747
826
|
FuzzyMatcher,
|
@@ -750,37 +829,37 @@ var Clause = import_zod9.z.lazy(
|
|
750
829
|
DateDistanceMatcher
|
751
830
|
])
|
752
831
|
);
|
753
|
-
var DeduplicationConfig =
|
754
|
-
id:
|
832
|
+
var DeduplicationConfig = import_zod10.z.object({
|
833
|
+
id: import_zod10.z.string(),
|
755
834
|
label: TranslationConfig,
|
756
835
|
query: Clause
|
757
836
|
});
|
758
837
|
|
759
838
|
// ../commons/src/events/SummaryConfig.ts
|
760
|
-
var
|
761
|
-
var Field =
|
762
|
-
id:
|
839
|
+
var import_zod11 = require("zod");
|
840
|
+
var Field = import_zod11.z.object({
|
841
|
+
id: import_zod11.z.string().describe("Id of summary field"),
|
763
842
|
value: TranslationConfig.describe(
|
764
843
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
765
844
|
),
|
766
845
|
label: TranslationConfig,
|
767
846
|
emptyValueMessage: TranslationConfig.optional()
|
768
847
|
});
|
769
|
-
var Title =
|
770
|
-
id:
|
848
|
+
var Title = import_zod11.z.object({
|
849
|
+
id: import_zod11.z.string(),
|
771
850
|
label: TranslationConfig.describe("Title content"),
|
772
851
|
emptyValueMessage: TranslationConfig.optional()
|
773
852
|
});
|
774
|
-
var SummaryConfig =
|
853
|
+
var SummaryConfig = import_zod11.z.object({
|
775
854
|
title: Title.describe("Title of summary view."),
|
776
|
-
fields:
|
855
|
+
fields: import_zod11.z.array(Field).describe("Fields rendered in summary view.")
|
777
856
|
}).describe("Configuration for summary in event.");
|
778
857
|
|
779
858
|
// ../commons/src/events/WorkqueueConfig.ts
|
780
|
-
var
|
859
|
+
var import_zod13 = require("zod");
|
781
860
|
|
782
861
|
// ../commons/src/events/EventMetadata.ts
|
783
|
-
var
|
862
|
+
var import_zod12 = require("zod");
|
784
863
|
var EventStatus = {
|
785
864
|
CREATED: "CREATED",
|
786
865
|
NOTIFIED: "NOTIFIED",
|
@@ -792,18 +871,18 @@ var EventStatus = {
|
|
792
871
|
ARCHIVED: "ARCHIVED"
|
793
872
|
};
|
794
873
|
var eventStatuses = Object.values(EventStatus);
|
795
|
-
var EventStatuses =
|
796
|
-
var EventMetadata =
|
797
|
-
id:
|
798
|
-
type:
|
874
|
+
var EventStatuses = import_zod12.z.nativeEnum(EventStatus);
|
875
|
+
var EventMetadata = import_zod12.z.object({
|
876
|
+
id: import_zod12.z.string(),
|
877
|
+
type: import_zod12.z.string(),
|
799
878
|
status: EventStatuses,
|
800
|
-
createdAt:
|
801
|
-
createdBy:
|
802
|
-
createdAtLocation:
|
803
|
-
modifiedAt:
|
804
|
-
assignedTo:
|
805
|
-
updatedBy:
|
806
|
-
trackingId:
|
879
|
+
createdAt: import_zod12.z.string().datetime(),
|
880
|
+
createdBy: import_zod12.z.string(),
|
881
|
+
createdAtLocation: import_zod12.z.string(),
|
882
|
+
modifiedAt: import_zod12.z.string().datetime(),
|
883
|
+
assignedTo: import_zod12.z.string().nullish(),
|
884
|
+
updatedBy: import_zod12.z.string(),
|
885
|
+
trackingId: import_zod12.z.string()
|
807
886
|
});
|
808
887
|
var eventMetadataLabelMap = {
|
809
888
|
"event.assignedTo": {
|
@@ -859,24 +938,24 @@ var eventMetadataLabelMap = {
|
|
859
938
|
};
|
860
939
|
|
861
940
|
// ../commons/src/events/WorkqueueConfig.ts
|
862
|
-
var WorkqueueConfig =
|
863
|
-
id:
|
864
|
-
filters:
|
865
|
-
|
866
|
-
status:
|
941
|
+
var WorkqueueConfig = import_zod13.z.object({
|
942
|
+
id: import_zod13.z.string().describe("Unique identifier for workqueue."),
|
943
|
+
filters: import_zod13.z.array(
|
944
|
+
import_zod13.z.object({
|
945
|
+
status: import_zod13.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
867
946
|
})
|
868
947
|
).describe("Filters to be applied to workqueue.")
|
869
948
|
}).describe("Configuration for workqueue.");
|
870
949
|
|
871
950
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
872
|
-
var
|
873
|
-
var AdvancedSearchConfig =
|
951
|
+
var import_zod14 = require("zod");
|
952
|
+
var AdvancedSearchConfig = import_zod14.z.object({
|
874
953
|
title: TranslationConfig.describe("Advanced search tab title"),
|
875
|
-
fields:
|
876
|
-
|
877
|
-
fieldId:
|
878
|
-
config:
|
879
|
-
type:
|
954
|
+
fields: import_zod14.z.array(
|
955
|
+
import_zod14.z.object({
|
956
|
+
fieldId: import_zod14.z.string(),
|
957
|
+
config: import_zod14.z.object({
|
958
|
+
type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
880
959
|
}).optional().describe("Configuration options for the field")
|
881
960
|
})
|
882
961
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -886,12 +965,12 @@ var AdvancedSearchConfig = import_zod13.z.object({
|
|
886
965
|
var import_lodash = require("lodash");
|
887
966
|
|
888
967
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
889
|
-
var
|
968
|
+
var import_zod16 = require("zod");
|
890
969
|
|
891
970
|
// ../commons/src/workqueues/defaultColumns.ts
|
892
|
-
var
|
893
|
-
var WorkQueueColumnConfig =
|
894
|
-
id:
|
971
|
+
var import_zod15 = require("zod");
|
972
|
+
var WorkQueueColumnConfig = import_zod15.z.object({
|
973
|
+
id: import_zod15.z.string(),
|
895
974
|
label: TranslationConfig
|
896
975
|
});
|
897
976
|
var defaultColumns = {
|
@@ -928,16 +1007,16 @@ var defaultColumns = {
|
|
928
1007
|
}
|
929
1008
|
}
|
930
1009
|
};
|
931
|
-
var DefaultColumnKeys =
|
1010
|
+
var DefaultColumnKeys = import_zod15.z.enum(
|
932
1011
|
Object.keys(defaultColumns)
|
933
1012
|
);
|
934
1013
|
|
935
1014
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
936
|
-
var rootWorkqueueConfig =
|
937
|
-
id:
|
1015
|
+
var rootWorkqueueConfig = import_zod16.z.object({
|
1016
|
+
id: import_zod16.z.string(),
|
938
1017
|
title: TranslationConfig,
|
939
|
-
columns:
|
940
|
-
defaultColumns:
|
1018
|
+
columns: import_zod16.z.array(WorkQueueColumnConfig),
|
1019
|
+
defaultColumns: import_zod16.z.array(DefaultColumnKeys)
|
941
1020
|
});
|
942
1021
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
943
1022
|
|
@@ -1017,7 +1096,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1017
1096
|
var import_date_fns = require("date-fns");
|
1018
1097
|
|
1019
1098
|
// ../commons/src/events/FieldTypeMapping.ts
|
1020
|
-
var
|
1099
|
+
var import_zod17 = require("zod");
|
1021
1100
|
function mapFieldTypeToZod(type, required) {
|
1022
1101
|
let schema;
|
1023
1102
|
switch (type) {
|
@@ -1057,17 +1136,17 @@ function mapFieldTypeToZod(type, required) {
|
|
1057
1136
|
schema = FileFieldWithOptionValue;
|
1058
1137
|
break;
|
1059
1138
|
case FieldType.ADDRESS:
|
1060
|
-
schema =
|
1139
|
+
schema = AddressFieldUpdateValue;
|
1061
1140
|
break;
|
1062
1141
|
}
|
1063
|
-
return required ? schema : schema.
|
1142
|
+
return required ? schema : schema.nullish();
|
1064
1143
|
}
|
1065
1144
|
function createValidationSchema(config) {
|
1066
1145
|
const shape = {};
|
1067
1146
|
for (const field2 of config) {
|
1068
1147
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1069
1148
|
}
|
1070
|
-
return
|
1149
|
+
return import_zod17.z.object(shape);
|
1071
1150
|
}
|
1072
1151
|
function mapFieldTypeToMockValue(field2, i) {
|
1073
1152
|
switch (field2.type) {
|
@@ -1092,7 +1171,7 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1092
1171
|
return "test@opencrvs.org";
|
1093
1172
|
case FieldType.ADDRESS:
|
1094
1173
|
return {
|
1095
|
-
country: "FAR",
|
1174
|
+
country: process.env.COUNTRY || "FAR",
|
1096
1175
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1097
1176
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1098
1177
|
urbanOrRural: "URBAN",
|
@@ -1116,6 +1195,50 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1116
1195
|
return null;
|
1117
1196
|
}
|
1118
1197
|
}
|
1198
|
+
function mapFieldTypeToEmptyValue(field2) {
|
1199
|
+
switch (field2.type) {
|
1200
|
+
case FieldType.DIVIDER:
|
1201
|
+
case FieldType.TEXT:
|
1202
|
+
case FieldType.TEXTAREA:
|
1203
|
+
case FieldType.BULLET_LIST:
|
1204
|
+
case FieldType.PAGE_HEADER:
|
1205
|
+
case FieldType.LOCATION:
|
1206
|
+
case FieldType.SELECT:
|
1207
|
+
case FieldType.COUNTRY:
|
1208
|
+
case FieldType.RADIO_GROUP:
|
1209
|
+
case FieldType.SIGNATURE:
|
1210
|
+
case FieldType.PARAGRAPH:
|
1211
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
1212
|
+
case FieldType.FACILITY:
|
1213
|
+
case FieldType.OFFICE:
|
1214
|
+
case FieldType.NUMBER:
|
1215
|
+
case FieldType.EMAIL:
|
1216
|
+
case FieldType.DATE:
|
1217
|
+
case FieldType.CHECKBOX:
|
1218
|
+
return null;
|
1219
|
+
case FieldType.ADDRESS:
|
1220
|
+
return {
|
1221
|
+
country: null,
|
1222
|
+
province: null,
|
1223
|
+
district: null,
|
1224
|
+
urbanOrRural: "URBAN",
|
1225
|
+
// Default to urban needed for validation
|
1226
|
+
town: null,
|
1227
|
+
residentialArea: null,
|
1228
|
+
street: null,
|
1229
|
+
number: null,
|
1230
|
+
zipCode: null
|
1231
|
+
};
|
1232
|
+
case FieldType.FILE:
|
1233
|
+
return {
|
1234
|
+
filename: "",
|
1235
|
+
originalFilename: "",
|
1236
|
+
type: ""
|
1237
|
+
};
|
1238
|
+
case FieldType.FILE_WITH_OPTIONS:
|
1239
|
+
return [];
|
1240
|
+
}
|
1241
|
+
}
|
1119
1242
|
var isParagraphFieldType = (field2) => {
|
1120
1243
|
return field2.config.type === FieldType.PARAGRAPH;
|
1121
1244
|
};
|
@@ -1215,49 +1338,76 @@ function isFieldVisible(field2, form) {
|
|
1215
1338
|
function isFieldEnabled(field2, form) {
|
1216
1339
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1217
1340
|
}
|
1341
|
+
var errorMessages = {
|
1342
|
+
hiddenField: {
|
1343
|
+
id: "v2.error.hidden",
|
1344
|
+
defaultMessage: "Hidden or disabled field should not receive a value",
|
1345
|
+
description: "Error message when field is hidden or disabled, but a value was received"
|
1346
|
+
},
|
1347
|
+
invalidDate: {
|
1348
|
+
defaultMessage: "Invalid date field",
|
1349
|
+
description: "Error message when date field is invalid",
|
1350
|
+
id: "v2.error.invalidDate"
|
1351
|
+
},
|
1352
|
+
invalidEmail: {
|
1353
|
+
defaultMessage: "Invalid email address",
|
1354
|
+
description: "Error message when email address is invalid",
|
1355
|
+
id: "v2.error.invalidEmail"
|
1356
|
+
},
|
1357
|
+
requiredField: {
|
1358
|
+
defaultMessage: "Required for registration",
|
1359
|
+
description: "Error message when required field is missing",
|
1360
|
+
id: "v2.error.required"
|
1361
|
+
},
|
1362
|
+
invalidInput: {
|
1363
|
+
defaultMessage: "Invalid input",
|
1364
|
+
description: "Error message when generic field is invalid",
|
1365
|
+
id: "v2.error.invalid"
|
1366
|
+
}
|
1367
|
+
};
|
1368
|
+
var createIntlError = (message) => ({
|
1369
|
+
message: {
|
1370
|
+
message
|
1371
|
+
}
|
1372
|
+
});
|
1218
1373
|
var zodToIntlErrorMap = (issue, _ctx) => {
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
|
1224
|
-
description: "This is the error message for invalid date fields",
|
1225
|
-
id: "v2.error.invalidDate"
|
1226
|
-
}
|
1374
|
+
switch (issue.code) {
|
1375
|
+
case "invalid_string": {
|
1376
|
+
if (_ctx.data === "") {
|
1377
|
+
return createIntlError(errorMessages.requiredField);
|
1227
1378
|
}
|
1228
|
-
|
1229
|
-
|
1230
|
-
if (issue.code === "invalid_string" && issue.validation === "email") {
|
1231
|
-
return {
|
1232
|
-
message: {
|
1233
|
-
message: {
|
1234
|
-
defaultMessage: "Invalid email address",
|
1235
|
-
description: "This is the error message for invalid email fields",
|
1236
|
-
id: "v2.error.invalidEmail"
|
1237
|
-
}
|
1379
|
+
if (issue.validation === "date") {
|
1380
|
+
return createIntlError(errorMessages.invalidDate);
|
1238
1381
|
}
|
1239
|
-
|
1240
|
-
|
1241
|
-
if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
|
1242
|
-
return {
|
1243
|
-
message: {
|
1244
|
-
message: {
|
1245
|
-
defaultMessage: "Required for registration",
|
1246
|
-
description: "This is the error message for required fields",
|
1247
|
-
id: "v2.error.required"
|
1248
|
-
}
|
1382
|
+
if (issue.validation === "email") {
|
1383
|
+
return createIntlError(errorMessages.invalidEmail);
|
1249
1384
|
}
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
defaultMessage: "Invalid input",
|
1256
|
-
description: "This is the error message for invalid field value",
|
1257
|
-
id: "v2.error.invalid"
|
1385
|
+
break;
|
1386
|
+
}
|
1387
|
+
case "invalid_type": {
|
1388
|
+
if (issue.expected !== issue.received && issue.received === "undefined") {
|
1389
|
+
return createIntlError(errorMessages.requiredField);
|
1258
1390
|
}
|
1391
|
+
break;
|
1259
1392
|
}
|
1260
|
-
|
1393
|
+
case "too_small": {
|
1394
|
+
if (issue.message === void 0) {
|
1395
|
+
return createIntlError(errorMessages.requiredField);
|
1396
|
+
}
|
1397
|
+
break;
|
1398
|
+
}
|
1399
|
+
case "invalid_union": {
|
1400
|
+
for (const { issues } of issue.unionErrors) {
|
1401
|
+
for (const e of issues) {
|
1402
|
+
if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
|
1403
|
+
return createIntlError(errorMessages.invalidInput);
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
}
|
1407
|
+
return createIntlError(errorMessages.requiredField);
|
1408
|
+
}
|
1409
|
+
}
|
1410
|
+
return createIntlError(errorMessages.invalidInput);
|
1261
1411
|
};
|
1262
1412
|
function getFieldValidationErrors({
|
1263
1413
|
field: field2,
|
@@ -1272,11 +1422,7 @@ function getFieldValidationErrors({
|
|
1272
1422
|
return {
|
1273
1423
|
errors: [
|
1274
1424
|
{
|
1275
|
-
message:
|
1276
|
-
id: "v2.error.hidden",
|
1277
|
-
defaultMessage: "Hidden or disabled field should not receive a value",
|
1278
|
-
description: "Error message when field is hidden or disabled, but a value was received"
|
1279
|
-
}
|
1425
|
+
message: errorMessages.hiddenField
|
1280
1426
|
}
|
1281
1427
|
]
|
1282
1428
|
};
|
@@ -1294,8 +1440,8 @@ function getFieldValidationErrors({
|
|
1294
1440
|
conditionalParameters
|
1295
1441
|
});
|
1296
1442
|
return {
|
1297
|
-
// Assumes that custom validation errors are
|
1298
|
-
errors: [...
|
1443
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1444
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1299
1445
|
};
|
1300
1446
|
}
|
1301
1447
|
function runCustomFieldValidations({
|
@@ -1320,6 +1466,20 @@ function validateFieldInput({
|
|
1320
1466
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1321
1467
|
}
|
1322
1468
|
|
1469
|
+
// ../commons/src/utils.ts
|
1470
|
+
function getOrThrow(x, message) {
|
1471
|
+
if (x === void 0 || x === null) {
|
1472
|
+
throw new Error(message);
|
1473
|
+
}
|
1474
|
+
return x;
|
1475
|
+
}
|
1476
|
+
|
1477
|
+
// ../commons/src/uuid.ts
|
1478
|
+
var import_uuid = require("uuid");
|
1479
|
+
function getUUID() {
|
1480
|
+
return (0, import_uuid.v4)();
|
1481
|
+
}
|
1482
|
+
|
1323
1483
|
// ../commons/src/events/utils.ts
|
1324
1484
|
function isMetadataField(field2) {
|
1325
1485
|
return field2 in eventMetadataLabelMap;
|
@@ -1389,7 +1549,7 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1389
1549
|
);
|
1390
1550
|
if (!rootWorkqueue) {
|
1391
1551
|
throw new Error(
|
1392
|
-
`Invalid workqueue configuration: workqueue not found with id:
|
1552
|
+
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1393
1553
|
);
|
1394
1554
|
}
|
1395
1555
|
});
|
@@ -1416,6 +1576,12 @@ var findActiveActionFields = (configuration, action) => {
|
|
1416
1576
|
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1417
1577
|
return allFields;
|
1418
1578
|
};
|
1579
|
+
var getActiveActionFormPages = (configuration, action) => {
|
1580
|
+
return getOrThrow(
|
1581
|
+
findActiveActionForm(configuration, action)?.pages,
|
1582
|
+
"Form configuration not found for type: " + configuration.id
|
1583
|
+
);
|
1584
|
+
};
|
1419
1585
|
function getActiveActionFields(configuration, action) {
|
1420
1586
|
const fields = findActiveActionFields(configuration, action);
|
1421
1587
|
if (!fields) {
|
@@ -1431,16 +1597,13 @@ function getEventConfiguration(eventConfigurations, type) {
|
|
1431
1597
|
return config;
|
1432
1598
|
}
|
1433
1599
|
function isOptionalUncheckedCheckbox(field2, form) {
|
1434
|
-
if (field2.type !== FieldType.CHECKBOX) {
|
1435
|
-
return false;
|
1436
|
-
}
|
1437
|
-
if (field2.required) {
|
1600
|
+
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1438
1601
|
return false;
|
1439
1602
|
}
|
1440
1603
|
return !form[field2.id];
|
1441
1604
|
}
|
1442
1605
|
function stripHiddenFields(fields, data) {
|
1443
|
-
return (0, import_lodash.omitBy)(data, (
|
1606
|
+
return (0, import_lodash.omitBy)(data, (_2, fieldId) => {
|
1444
1607
|
const field2 = fields.find((f) => f.id === fieldId);
|
1445
1608
|
if (!field2) {
|
1446
1609
|
return true;
|
@@ -1451,18 +1614,39 @@ function stripHiddenFields(fields, data) {
|
|
1451
1614
|
return !isFieldVisible(field2, data);
|
1452
1615
|
});
|
1453
1616
|
}
|
1617
|
+
function findActiveDrafts(event2, drafts) {
|
1618
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1619
|
+
const lastAction = actions[actions.length - 1];
|
1620
|
+
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1621
|
+
}
|
1622
|
+
function createEmptyDraft(eventId, draftId, actionType) {
|
1623
|
+
return {
|
1624
|
+
id: draftId,
|
1625
|
+
eventId,
|
1626
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1627
|
+
transactionId: getUUID(),
|
1628
|
+
action: {
|
1629
|
+
type: actionType,
|
1630
|
+
data: {},
|
1631
|
+
metadata: {},
|
1632
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1633
|
+
createdBy: "@todo",
|
1634
|
+
createdAtLocation: "@todo"
|
1635
|
+
}
|
1636
|
+
};
|
1637
|
+
}
|
1454
1638
|
|
1455
1639
|
// ../commons/src/events/EventConfig.ts
|
1456
|
-
var EventConfig =
|
1457
|
-
id:
|
1640
|
+
var EventConfig = import_zod18.z.object({
|
1641
|
+
id: import_zod18.z.string().describe(
|
1458
1642
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1459
1643
|
),
|
1460
1644
|
summary: SummaryConfig,
|
1461
1645
|
label: TranslationConfig,
|
1462
|
-
actions:
|
1463
|
-
workqueues:
|
1464
|
-
deduplication:
|
1465
|
-
advancedSearch:
|
1646
|
+
actions: import_zod18.z.array(ActionConfig),
|
1647
|
+
workqueues: import_zod18.z.array(WorkqueueConfig),
|
1648
|
+
deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
|
1649
|
+
advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
|
1466
1650
|
}).superRefine((event2, ctx) => {
|
1467
1651
|
const allFields = findPageFields(event2);
|
1468
1652
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1495,107 +1679,107 @@ var defineForm = (form) => FormConfig.parse(form);
|
|
1495
1679
|
var defineFormPage = (formPage) => FormPage.parse(formPage);
|
1496
1680
|
|
1497
1681
|
// ../commons/src/events/Draft.ts
|
1498
|
-
var
|
1682
|
+
var import_zod21 = require("zod");
|
1499
1683
|
|
1500
1684
|
// ../commons/src/events/ActionDocument.ts
|
1501
|
-
var
|
1502
|
-
var
|
1503
|
-
var ActionBase =
|
1504
|
-
id:
|
1505
|
-
createdAt:
|
1506
|
-
createdBy:
|
1507
|
-
data:
|
1508
|
-
metadata:
|
1509
|
-
createdAtLocation:
|
1685
|
+
var import_zod19 = require("zod");
|
1686
|
+
var ActionUpdate = import_zod19.z.record(import_zod19.z.string(), FieldUpdateValue);
|
1687
|
+
var ActionBase = import_zod19.z.object({
|
1688
|
+
id: import_zod19.z.string(),
|
1689
|
+
createdAt: import_zod19.z.string().datetime(),
|
1690
|
+
createdBy: import_zod19.z.string(),
|
1691
|
+
data: ActionUpdate,
|
1692
|
+
metadata: ActionUpdate.optional(),
|
1693
|
+
createdAtLocation: import_zod19.z.string()
|
1510
1694
|
});
|
1511
1695
|
var AssignedAction = ActionBase.merge(
|
1512
|
-
|
1513
|
-
type:
|
1514
|
-
assignedTo:
|
1696
|
+
import_zod19.z.object({
|
1697
|
+
type: import_zod19.z.literal(ActionType.ASSIGN),
|
1698
|
+
assignedTo: import_zod19.z.string()
|
1515
1699
|
})
|
1516
1700
|
);
|
1517
1701
|
var UnassignedAction = ActionBase.merge(
|
1518
|
-
|
1519
|
-
type:
|
1702
|
+
import_zod19.z.object({
|
1703
|
+
type: import_zod19.z.literal(ActionType.UNASSIGN)
|
1520
1704
|
})
|
1521
1705
|
);
|
1522
1706
|
var RegisterAction = ActionBase.merge(
|
1523
|
-
|
1524
|
-
type:
|
1525
|
-
identifiers:
|
1526
|
-
trackingId:
|
1527
|
-
registrationNumber:
|
1707
|
+
import_zod19.z.object({
|
1708
|
+
type: import_zod19.z.literal(ActionType.REGISTER),
|
1709
|
+
identifiers: import_zod19.z.object({
|
1710
|
+
trackingId: import_zod19.z.string(),
|
1711
|
+
registrationNumber: import_zod19.z.string()
|
1528
1712
|
})
|
1529
1713
|
})
|
1530
1714
|
);
|
1531
1715
|
var DeclareAction = ActionBase.merge(
|
1532
|
-
|
1533
|
-
type:
|
1716
|
+
import_zod19.z.object({
|
1717
|
+
type: import_zod19.z.literal(ActionType.DECLARE)
|
1534
1718
|
})
|
1535
1719
|
);
|
1536
1720
|
var ValidateAction = ActionBase.merge(
|
1537
|
-
|
1538
|
-
type:
|
1721
|
+
import_zod19.z.object({
|
1722
|
+
type: import_zod19.z.literal(ActionType.VALIDATE)
|
1539
1723
|
})
|
1540
1724
|
);
|
1541
1725
|
var RejectAction = ActionBase.merge(
|
1542
|
-
|
1543
|
-
type:
|
1726
|
+
import_zod19.z.object({
|
1727
|
+
type: import_zod19.z.literal(ActionType.REJECT)
|
1544
1728
|
})
|
1545
1729
|
);
|
1546
1730
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1547
|
-
|
1548
|
-
type:
|
1731
|
+
import_zod19.z.object({
|
1732
|
+
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1549
1733
|
})
|
1550
1734
|
);
|
1551
|
-
var
|
1552
|
-
|
1553
|
-
type:
|
1735
|
+
var ArchiveAction = ActionBase.merge(
|
1736
|
+
import_zod19.z.object({
|
1737
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE)
|
1554
1738
|
})
|
1555
1739
|
);
|
1556
1740
|
var CreatedAction = ActionBase.merge(
|
1557
|
-
|
1558
|
-
type:
|
1741
|
+
import_zod19.z.object({
|
1742
|
+
type: import_zod19.z.literal(ActionType.CREATE)
|
1559
1743
|
})
|
1560
1744
|
);
|
1561
1745
|
var NotifiedAction = ActionBase.merge(
|
1562
|
-
|
1563
|
-
type:
|
1746
|
+
import_zod19.z.object({
|
1747
|
+
type: import_zod19.z.literal(ActionType.NOTIFY)
|
1564
1748
|
})
|
1565
1749
|
);
|
1566
1750
|
var PrintCertificateAction = ActionBase.merge(
|
1567
|
-
|
1568
|
-
type:
|
1751
|
+
import_zod19.z.object({
|
1752
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
|
1569
1753
|
})
|
1570
1754
|
);
|
1571
1755
|
var RequestedCorrectionAction = ActionBase.merge(
|
1572
|
-
|
1573
|
-
type:
|
1756
|
+
import_zod19.z.object({
|
1757
|
+
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION)
|
1574
1758
|
})
|
1575
1759
|
);
|
1576
1760
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1577
|
-
|
1578
|
-
type:
|
1579
|
-
requestId:
|
1761
|
+
import_zod19.z.object({
|
1762
|
+
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
|
1763
|
+
requestId: import_zod19.z.string()
|
1580
1764
|
})
|
1581
1765
|
);
|
1582
1766
|
var RejectedCorrectionAction = ActionBase.merge(
|
1583
|
-
|
1584
|
-
type:
|
1585
|
-
requestId:
|
1767
|
+
import_zod19.z.object({
|
1768
|
+
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
|
1769
|
+
requestId: import_zod19.z.string()
|
1586
1770
|
})
|
1587
1771
|
);
|
1588
1772
|
var CustomAction = ActionBase.merge(
|
1589
|
-
|
1590
|
-
type:
|
1773
|
+
import_zod19.z.object({
|
1774
|
+
type: import_zod19.z.literal(ActionType.CUSTOM)
|
1591
1775
|
})
|
1592
1776
|
);
|
1593
|
-
var ActionDocument =
|
1777
|
+
var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
1594
1778
|
CreatedAction,
|
1595
1779
|
ValidateAction,
|
1596
1780
|
RejectAction,
|
1597
1781
|
MarkAsDuplicateAction,
|
1598
|
-
|
1782
|
+
ArchiveAction,
|
1599
1783
|
NotifiedAction,
|
1600
1784
|
RegisterAction,
|
1601
1785
|
DeclareAction,
|
@@ -1607,108 +1791,106 @@ var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
|
1607
1791
|
PrintCertificateAction,
|
1608
1792
|
CustomAction
|
1609
1793
|
]);
|
1610
|
-
var ResolvedUser =
|
1611
|
-
id:
|
1612
|
-
role:
|
1613
|
-
name:
|
1614
|
-
|
1615
|
-
use:
|
1616
|
-
given:
|
1617
|
-
family:
|
1794
|
+
var ResolvedUser = import_zod19.z.object({
|
1795
|
+
id: import_zod19.z.string(),
|
1796
|
+
role: import_zod19.z.string(),
|
1797
|
+
name: import_zod19.z.array(
|
1798
|
+
import_zod19.z.object({
|
1799
|
+
use: import_zod19.z.string(),
|
1800
|
+
given: import_zod19.z.array(import_zod19.z.string()),
|
1801
|
+
family: import_zod19.z.string()
|
1618
1802
|
})
|
1619
1803
|
)
|
1620
1804
|
});
|
1621
1805
|
|
1622
1806
|
// ../commons/src/events/ActionInput.ts
|
1623
|
-
var
|
1624
|
-
var BaseActionInput =
|
1625
|
-
eventId:
|
1626
|
-
transactionId:
|
1627
|
-
|
1628
|
-
|
1629
|
-
metadata: import_zod19.z.record(import_zod19.z.string(), FieldValue).optional()
|
1807
|
+
var import_zod20 = require("zod");
|
1808
|
+
var BaseActionInput = import_zod20.z.object({
|
1809
|
+
eventId: import_zod20.z.string(),
|
1810
|
+
transactionId: import_zod20.z.string(),
|
1811
|
+
data: ActionUpdate,
|
1812
|
+
metadata: ActionUpdate.optional()
|
1630
1813
|
});
|
1631
1814
|
var CreateActionInput = BaseActionInput.merge(
|
1632
|
-
|
1633
|
-
type:
|
1634
|
-
createdAtLocation:
|
1815
|
+
import_zod20.z.object({
|
1816
|
+
type: import_zod20.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1817
|
+
createdAtLocation: import_zod20.z.string()
|
1635
1818
|
})
|
1636
1819
|
);
|
1637
1820
|
var RegisterActionInput = BaseActionInput.merge(
|
1638
|
-
|
1639
|
-
type:
|
1640
|
-
identifiers:
|
1641
|
-
trackingId:
|
1642
|
-
registrationNumber:
|
1821
|
+
import_zod20.z.object({
|
1822
|
+
type: import_zod20.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1823
|
+
identifiers: import_zod20.z.object({
|
1824
|
+
trackingId: import_zod20.z.string(),
|
1825
|
+
registrationNumber: import_zod20.z.string()
|
1643
1826
|
})
|
1644
1827
|
})
|
1645
1828
|
);
|
1646
1829
|
var ValidateActionInput = BaseActionInput.merge(
|
1647
|
-
|
1648
|
-
type:
|
1649
|
-
duplicates:
|
1830
|
+
import_zod20.z.object({
|
1831
|
+
type: import_zod20.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1832
|
+
duplicates: import_zod20.z.array(import_zod20.z.string())
|
1650
1833
|
})
|
1651
1834
|
);
|
1652
1835
|
var NotifyActionInput = BaseActionInput.merge(
|
1653
|
-
|
1654
|
-
type:
|
1655
|
-
createdAtLocation: import_zod19.z.string()
|
1836
|
+
import_zod20.z.object({
|
1837
|
+
type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1656
1838
|
})
|
1657
1839
|
);
|
1658
1840
|
var DeclareActionInput = BaseActionInput.merge(
|
1659
|
-
|
1660
|
-
type:
|
1841
|
+
import_zod20.z.object({
|
1842
|
+
type: import_zod20.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1661
1843
|
})
|
1662
1844
|
);
|
1663
1845
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1664
|
-
|
1665
|
-
type:
|
1846
|
+
import_zod20.z.object({
|
1847
|
+
type: import_zod20.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1666
1848
|
})
|
1667
1849
|
);
|
1668
1850
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1669
|
-
|
1670
|
-
type:
|
1851
|
+
import_zod20.z.object({
|
1852
|
+
type: import_zod20.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1671
1853
|
})
|
1672
1854
|
);
|
1673
1855
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1674
|
-
|
1675
|
-
type:
|
1856
|
+
import_zod20.z.object({
|
1857
|
+
type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1676
1858
|
})
|
1677
1859
|
);
|
1678
|
-
var
|
1679
|
-
|
1680
|
-
type:
|
1860
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
1861
|
+
import_zod20.z.object({
|
1862
|
+
type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1681
1863
|
})
|
1682
1864
|
);
|
1683
1865
|
var AssignActionInput = BaseActionInput.merge(
|
1684
|
-
|
1685
|
-
type:
|
1686
|
-
assignedTo:
|
1866
|
+
import_zod20.z.object({
|
1867
|
+
type: import_zod20.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1868
|
+
assignedTo: import_zod20.z.string()
|
1687
1869
|
})
|
1688
1870
|
);
|
1689
1871
|
var UnassignActionInput = BaseActionInput.merge(
|
1690
|
-
|
1691
|
-
type:
|
1872
|
+
import_zod20.z.object({
|
1873
|
+
type: import_zod20.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
|
1692
1874
|
})
|
1693
1875
|
);
|
1694
1876
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1695
|
-
|
1696
|
-
type:
|
1877
|
+
import_zod20.z.object({
|
1878
|
+
type: import_zod20.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1697
1879
|
})
|
1698
1880
|
);
|
1699
1881
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1700
|
-
|
1701
|
-
requestId:
|
1702
|
-
type:
|
1882
|
+
import_zod20.z.object({
|
1883
|
+
requestId: import_zod20.z.string(),
|
1884
|
+
type: import_zod20.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1703
1885
|
})
|
1704
1886
|
);
|
1705
1887
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1706
|
-
|
1707
|
-
requestId:
|
1708
|
-
type:
|
1888
|
+
import_zod20.z.object({
|
1889
|
+
requestId: import_zod20.z.string(),
|
1890
|
+
type: import_zod20.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1709
1891
|
})
|
1710
1892
|
);
|
1711
|
-
var ActionInput =
|
1893
|
+
var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
1712
1894
|
CreateActionInput,
|
1713
1895
|
ValidateActionInput,
|
1714
1896
|
RegisterActionInput,
|
@@ -1716,7 +1898,7 @@ var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
|
1716
1898
|
DeclareActionInput,
|
1717
1899
|
RejectDeclarationActionInput,
|
1718
1900
|
MarkedAsDuplicateActionInput,
|
1719
|
-
|
1901
|
+
ArchiveActionInput,
|
1720
1902
|
AssignActionInput,
|
1721
1903
|
UnassignActionInput,
|
1722
1904
|
PrintCertificateActionInput,
|
@@ -1726,50 +1908,51 @@ var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
|
1726
1908
|
]);
|
1727
1909
|
|
1728
1910
|
// ../commons/src/events/Draft.ts
|
1729
|
-
var Draft =
|
1730
|
-
id:
|
1731
|
-
eventId:
|
1732
|
-
transactionId:
|
1733
|
-
createdAt:
|
1911
|
+
var Draft = import_zod21.z.object({
|
1912
|
+
id: import_zod21.z.string(),
|
1913
|
+
eventId: import_zod21.z.string(),
|
1914
|
+
transactionId: import_zod21.z.string(),
|
1915
|
+
createdAt: import_zod21.z.string().datetime(),
|
1734
1916
|
action: ActionBase.extend({
|
1735
|
-
type:
|
1917
|
+
type: import_zod21.z.enum(Object.values(ActionType))
|
1736
1918
|
}).omit({ id: true })
|
1737
1919
|
});
|
1738
1920
|
var DraftInput = BaseActionInput.extend({
|
1739
|
-
type:
|
1921
|
+
type: import_zod21.z.enum(Object.values(ActionType))
|
1740
1922
|
});
|
1741
1923
|
|
1742
1924
|
// ../commons/src/events/EventInput.ts
|
1743
|
-
var
|
1744
|
-
var EventInput =
|
1745
|
-
transactionId:
|
1746
|
-
type:
|
1925
|
+
var import_zod22 = require("zod");
|
1926
|
+
var EventInput = import_zod22.z.object({
|
1927
|
+
transactionId: import_zod22.z.string(),
|
1928
|
+
type: import_zod22.z.string()
|
1747
1929
|
});
|
1748
1930
|
|
1749
1931
|
// ../commons/src/events/EventDocument.ts
|
1750
|
-
var
|
1751
|
-
var EventDocument =
|
1752
|
-
id:
|
1753
|
-
type:
|
1754
|
-
createdAt:
|
1755
|
-
updatedAt:
|
1756
|
-
actions:
|
1757
|
-
trackingId:
|
1932
|
+
var import_zod23 = require("zod");
|
1933
|
+
var EventDocument = import_zod23.z.object({
|
1934
|
+
id: import_zod23.z.string(),
|
1935
|
+
type: import_zod23.z.string(),
|
1936
|
+
createdAt: import_zod23.z.string().datetime(),
|
1937
|
+
updatedAt: import_zod23.z.string().datetime(),
|
1938
|
+
actions: import_zod23.z.array(ActionDocument),
|
1939
|
+
trackingId: import_zod23.z.string()
|
1758
1940
|
});
|
1759
1941
|
|
1760
1942
|
// ../commons/src/events/EventIndex.ts
|
1761
|
-
var
|
1943
|
+
var import_zod24 = require("zod");
|
1762
1944
|
var EventIndex = EventMetadata.extend({
|
1763
|
-
data:
|
1945
|
+
data: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
|
1764
1946
|
});
|
1765
|
-
var EventSearchIndex =
|
1766
|
-
|
1767
|
-
type:
|
1947
|
+
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
1948
|
+
import_zod24.z.object({
|
1949
|
+
type: import_zod24.z.string()
|
1768
1950
|
// Ensures "type" (event-id) exists and is a string
|
1769
1951
|
})
|
1770
1952
|
);
|
1771
1953
|
|
1772
1954
|
// ../commons/src/events/state/index.ts
|
1955
|
+
var _ = __toESM(require("lodash"));
|
1773
1956
|
function getStatusFromActions(actions) {
|
1774
1957
|
return actions.reduce((status, action) => {
|
1775
1958
|
if (action.type === ActionType.CREATE) {
|
@@ -1787,9 +1970,12 @@ function getStatusFromActions(actions) {
|
|
1787
1970
|
if (action.type === ActionType.REJECT) {
|
1788
1971
|
return EventStatus.REJECTED;
|
1789
1972
|
}
|
1790
|
-
if (action.type === ActionType.
|
1973
|
+
if (action.type === ActionType.ARCHIVE) {
|
1791
1974
|
return EventStatus.ARCHIVED;
|
1792
1975
|
}
|
1976
|
+
if (action.type === ActionType.NOTIFY) {
|
1977
|
+
return EventStatus.NOTIFIED;
|
1978
|
+
}
|
1793
1979
|
return status;
|
1794
1980
|
}, EventStatus.CREATED);
|
1795
1981
|
}
|
@@ -1818,19 +2004,46 @@ function getData(actions) {
|
|
1818
2004
|
if (!requestAction) {
|
1819
2005
|
return status;
|
1820
2006
|
}
|
2007
|
+
return deepMerge(status, requestAction.data);
|
2008
|
+
}
|
2009
|
+
return deepMerge(status, action.data);
|
2010
|
+
}, {});
|
2011
|
+
}
|
2012
|
+
function deepDropNulls(obj) {
|
2013
|
+
if (!_.isObject(obj)) return obj;
|
2014
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2015
|
+
if (_.isObject(value)) {
|
2016
|
+
value = deepDropNulls(value);
|
2017
|
+
}
|
2018
|
+
if (value !== null) {
|
1821
2019
|
return {
|
1822
|
-
...
|
1823
|
-
|
2020
|
+
...acc,
|
2021
|
+
[key]: value
|
1824
2022
|
};
|
1825
2023
|
}
|
1826
|
-
return
|
1827
|
-
...status,
|
1828
|
-
...action.data
|
1829
|
-
};
|
2024
|
+
return acc;
|
1830
2025
|
}, {});
|
1831
2026
|
}
|
1832
|
-
function
|
1833
|
-
return
|
2027
|
+
function deepMerge(currentDocument, actionDocument) {
|
2028
|
+
return _.mergeWith(
|
2029
|
+
currentDocument,
|
2030
|
+
actionDocument,
|
2031
|
+
(previousValue, incomingValue) => {
|
2032
|
+
if (incomingValue === void 0) {
|
2033
|
+
return previousValue;
|
2034
|
+
}
|
2035
|
+
if (_.isArray(incomingValue)) {
|
2036
|
+
return incomingValue;
|
2037
|
+
}
|
2038
|
+
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2039
|
+
return void 0;
|
2040
|
+
}
|
2041
|
+
return incomingValue;
|
2042
|
+
}
|
2043
|
+
);
|
2044
|
+
}
|
2045
|
+
function isUndeclaredDraft(status) {
|
2046
|
+
return status === EventStatus.CREATED;
|
1834
2047
|
}
|
1835
2048
|
function getCurrentEventState(event2) {
|
1836
2049
|
const creationAction = event2.actions.find(
|
@@ -1840,7 +2053,7 @@ function getCurrentEventState(event2) {
|
|
1840
2053
|
throw new Error(`Event ${event2.id} has no creation action`);
|
1841
2054
|
}
|
1842
2055
|
const latestAction = event2.actions[event2.actions.length - 1];
|
1843
|
-
return {
|
2056
|
+
return deepDropNulls({
|
1844
2057
|
id: event2.id,
|
1845
2058
|
type: event2.type,
|
1846
2059
|
status: getStatusFromActions(event2.actions),
|
@@ -1852,14 +2065,11 @@ function getCurrentEventState(event2) {
|
|
1852
2065
|
updatedBy: latestAction.createdBy,
|
1853
2066
|
data: getData(event2.actions),
|
1854
2067
|
trackingId: event2.trackingId
|
1855
|
-
};
|
2068
|
+
});
|
1856
2069
|
}
|
1857
2070
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
1858
|
-
const actions = event2.actions.slice().sort();
|
1859
|
-
const
|
1860
|
-
const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(
|
1861
|
-
({ createdAt }) => new Date(createdAt) > new Date(lastAction.createdAt)
|
1862
|
-
).map((draft) => draft.action).flatMap((action) => {
|
2071
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2072
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
1863
2073
|
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1864
2074
|
return [
|
1865
2075
|
action,
|
@@ -1892,20 +2102,21 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
1892
2102
|
}
|
1893
2103
|
};
|
1894
2104
|
}
|
1895
|
-
function getMetadataForAction(
|
2105
|
+
function getMetadataForAction({
|
2106
|
+
event: event2,
|
2107
|
+
actionType,
|
2108
|
+
drafts
|
2109
|
+
}) {
|
1896
2110
|
const action = event2.actions.find((action2) => actionType === action2.type);
|
1897
|
-
const
|
2111
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
1898
2112
|
const sorted = [
|
1899
2113
|
...action ? [action] : [],
|
1900
|
-
...
|
2114
|
+
...eventDrafts.map((draft) => draft.action)
|
1901
2115
|
].sort();
|
1902
2116
|
const metadata = sorted.reduce((metadata2, action2) => {
|
1903
|
-
return {
|
1904
|
-
...metadata2,
|
1905
|
-
...action2.metadata
|
1906
|
-
};
|
2117
|
+
return deepMerge(metadata2, action2.metadata ?? {});
|
1907
2118
|
}, {});
|
1908
|
-
return metadata;
|
2119
|
+
return deepDropNulls(metadata);
|
1909
2120
|
}
|
1910
2121
|
|
1911
2122
|
// ../commons/src/events/defineConfig.ts
|
@@ -1919,12 +2130,6 @@ var defineConfig = (config) => {
|
|
1919
2130
|
});
|
1920
2131
|
};
|
1921
2132
|
|
1922
|
-
// ../commons/src/uuid.ts
|
1923
|
-
var import_uuid = require("uuid");
|
1924
|
-
function getUUID() {
|
1925
|
-
return (0, import_uuid.v4)();
|
1926
|
-
}
|
1927
|
-
|
1928
2133
|
// ../commons/src/events/transactions.ts
|
1929
2134
|
function generateTransactionId() {
|
1930
2135
|
return getUUID();
|
@@ -2796,7 +3001,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
2796
3001
|
review: {
|
2797
3002
|
title: {
|
2798
3003
|
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
2799
|
-
defaultMessage: "Member declaration{
|
3004
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
2800
3005
|
description: "Title of the form to show in review page"
|
2801
3006
|
},
|
2802
3007
|
fields: [
|
@@ -3344,6 +3549,24 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3344
3549
|
})
|
3345
3550
|
}
|
3346
3551
|
]
|
3552
|
+
},
|
3553
|
+
{
|
3554
|
+
type: ActionType.ARCHIVE,
|
3555
|
+
label: {
|
3556
|
+
id: "v2.event.tennis-club-membership.action.archive.label",
|
3557
|
+
defaultMessage: "Archive",
|
3558
|
+
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3559
|
+
},
|
3560
|
+
forms: [TENNIS_CLUB_FORM]
|
3561
|
+
},
|
3562
|
+
{
|
3563
|
+
type: ActionType.REJECT,
|
3564
|
+
label: {
|
3565
|
+
id: "v2.event.tennis-club-membership.action.reject.label",
|
3566
|
+
defaultMessage: "Reject",
|
3567
|
+
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3568
|
+
},
|
3569
|
+
forms: [TENNIS_CLUB_FORM]
|
3347
3570
|
}
|
3348
3571
|
],
|
3349
3572
|
advancedSearch: [
|
@@ -3424,9 +3647,9 @@ var eventPayloadGenerator = {
|
|
3424
3647
|
eventId
|
3425
3648
|
}),
|
3426
3649
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3427
|
-
type: ActionType.
|
3650
|
+
type: ActionType.ARCHIVE,
|
3428
3651
|
transactionId: input.transactionId ?? getUUID(),
|
3429
|
-
data: input.data ??
|
3652
|
+
data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
|
3430
3653
|
metadata: { isDuplicate: isDuplicate ?? false },
|
3431
3654
|
duplicates: [],
|
3432
3655
|
eventId
|
@@ -3434,7 +3657,7 @@ var eventPayloadGenerator = {
|
|
3434
3657
|
reject: (eventId, input = {}) => ({
|
3435
3658
|
type: ActionType.REJECT,
|
3436
3659
|
transactionId: input.transactionId ?? getUUID(),
|
3437
|
-
data: input.data ??
|
3660
|
+
data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
|
3438
3661
|
duplicates: [],
|
3439
3662
|
eventId
|
3440
3663
|
}),
|
@@ -3489,15 +3712,19 @@ var eventPayloadGenerator = {
|
|
3489
3712
|
};
|
3490
3713
|
function generateActionDocument({
|
3491
3714
|
configuration,
|
3492
|
-
action
|
3715
|
+
action,
|
3716
|
+
defaults = {}
|
3493
3717
|
}) {
|
3494
3718
|
const actionBase = {
|
3495
|
-
createdAt
|
3719
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3720
|
+
// @TODO: This should be fixed in the future.
|
3721
|
+
createdAt: new Date(Date.now() - 500).toISOString(),
|
3496
3722
|
createdBy: getUUID(),
|
3497
3723
|
id: getUUID(),
|
3498
3724
|
createdAtLocation: "TODO",
|
3499
3725
|
data: generateActionInput(configuration, action),
|
3500
|
-
metadata: {}
|
3726
|
+
metadata: {},
|
3727
|
+
...defaults
|
3501
3728
|
};
|
3502
3729
|
switch (action) {
|
3503
3730
|
case ActionType.DECLARE:
|
@@ -3508,7 +3735,7 @@ function generateActionDocument({
|
|
3508
3735
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3509
3736
|
case ActionType.VALIDATE:
|
3510
3737
|
return { ...actionBase, type: action };
|
3511
|
-
case ActionType.
|
3738
|
+
case ActionType.ARCHIVE:
|
3512
3739
|
return { ...actionBase, type: action };
|
3513
3740
|
case ActionType.REJECT:
|
3514
3741
|
return { ...actionBase, type: action };
|
@@ -3546,9 +3773,13 @@ function generateEventDocument({
|
|
3546
3773
|
actions: actions.map(
|
3547
3774
|
(action) => generateActionDocument({ configuration, action })
|
3548
3775
|
),
|
3549
|
-
createdAt
|
3776
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3777
|
+
// @TODO: This should be fixed in the future.
|
3778
|
+
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
3550
3779
|
id: getUUID(),
|
3551
|
-
|
3780
|
+
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3781
|
+
// @TODO: This should be fixed in the future.
|
3782
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
3552
3783
|
};
|
3553
3784
|
}
|
3554
3785
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
|
@@ -3588,3 +3819,33 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3588
3819
|
},
|
3589
3820
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3590
3821
|
});
|
3822
|
+
|
3823
|
+
// ../commons/src/events/TemplateConfig.ts
|
3824
|
+
function isTemplateVariable(value) {
|
3825
|
+
return typeof value === "string" && value.startsWith("$");
|
3826
|
+
}
|
3827
|
+
function isFieldValue(value) {
|
3828
|
+
return FieldValue.safeParse(value).success;
|
3829
|
+
}
|
3830
|
+
function isFieldValueWithoutTemplates(value) {
|
3831
|
+
if (isTemplateVariable(value)) {
|
3832
|
+
return false;
|
3833
|
+
}
|
3834
|
+
if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
|
3835
|
+
return false;
|
3836
|
+
}
|
3837
|
+
return true;
|
3838
|
+
}
|
3839
|
+
function isFieldConfigDefaultValue(value) {
|
3840
|
+
if (!value) return false;
|
3841
|
+
if (isFieldValue(value)) {
|
3842
|
+
return true;
|
3843
|
+
}
|
3844
|
+
if (isTemplateVariable(value)) {
|
3845
|
+
return true;
|
3846
|
+
}
|
3847
|
+
if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
|
3848
|
+
return Object.values(value).every((v) => isFieldConfigDefaultValue(v));
|
3849
|
+
}
|
3850
|
+
return false;
|
3851
|
+
}
|