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