@opencrvs/toolkit 1.8.0-rc.fbb7263 → 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 +5020 -22
- package/dist/commons/conditionals/conditionals.d.ts +1 -0
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +27 -0
- 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 +2079 -3
- package/dist/commons/events/ActionInput.d.ts +3132 -12
- package/dist/commons/events/ActionType.d.ts +6 -1
- package/dist/commons/events/CompositeFieldValue.d.ts +152 -2
- package/dist/commons/events/Draft.d.ts +288 -0
- package/dist/commons/events/EventConfig.d.ts +4 -28
- package/dist/commons/events/EventDocument.d.ts +2525 -5
- package/dist/commons/events/FieldConfig.d.ts +62 -1
- package/dist/commons/events/FieldType.d.ts +4 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +132 -2
- package/dist/commons/events/FieldValue.d.ts +72 -0
- 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 +1 -0
- package/dist/commons/events/test.utils.d.ts +147 -3
- package/dist/commons/events/utils.d.ts +121 -0
- package/dist/conditionals/index.js +17 -0
- package/dist/events/index.js +314 -91
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -40,9 +40,11 @@ __export(events_exports, {
|
|
40
40
|
ActionUpdate: () => ActionUpdate,
|
41
41
|
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
42
42
|
AddressFieldValue: () => AddressFieldValue,
|
43
|
+
AddressType: () => AddressType,
|
44
|
+
AdministrativeAreas: () => AdministrativeAreas,
|
43
45
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
44
46
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
45
|
-
|
47
|
+
ArchiveActionInput: () => ArchiveActionInput,
|
46
48
|
BaseActionInput: () => BaseActionInput,
|
47
49
|
CertificateConfig: () => CertificateConfig,
|
48
50
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
@@ -75,8 +77,11 @@ __export(events_exports, {
|
|
75
77
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
76
78
|
FormConfig: () => FormConfig,
|
77
79
|
FormPage: () => FormPage,
|
80
|
+
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
81
|
+
GenericAddressValue: () => GenericAddressValue,
|
78
82
|
GeographicalArea: () => GeographicalArea,
|
79
83
|
LanguageConfig: () => LanguageConfig,
|
84
|
+
LatentActions: () => LatentActions,
|
80
85
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
81
86
|
NotifyActionInput: () => NotifyActionInput,
|
82
87
|
NumberFieldValue: () => NumberFieldValue,
|
@@ -100,12 +105,15 @@ __export(events_exports, {
|
|
100
105
|
alwaysTrue: () => alwaysTrue,
|
101
106
|
and: () => and,
|
102
107
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
108
|
+
compositeFieldTypes: () => compositeFieldTypes,
|
109
|
+
createEmptyDraft: () => createEmptyDraft,
|
103
110
|
createValidationSchema: () => createValidationSchema,
|
104
111
|
deepDropNulls: () => deepDropNulls,
|
105
112
|
defineConditional: () => defineConditional,
|
106
113
|
defineConfig: () => defineConfig,
|
107
114
|
defineForm: () => defineForm,
|
108
115
|
defineFormPage: () => defineFormPage,
|
116
|
+
errorMessages: () => errorMessages,
|
109
117
|
event: () => event,
|
110
118
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
111
119
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
@@ -117,6 +125,7 @@ __export(events_exports, {
|
|
117
125
|
findActiveActionForm: () => findActiveActionForm,
|
118
126
|
findActiveActionFormFields: () => findActiveActionFormFields,
|
119
127
|
findActiveActionFormPages: () => findActiveActionFormPages,
|
128
|
+
findActiveDrafts: () => findActiveDrafts,
|
120
129
|
findInputPageFields: () => findInputPageFields,
|
121
130
|
findPageFields: () => findPageFields,
|
122
131
|
generateActionDocument: () => generateActionDocument,
|
@@ -125,6 +134,7 @@ __export(events_exports, {
|
|
125
134
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
126
135
|
generateTransactionId: () => generateTransactionId,
|
127
136
|
getActiveActionFields: () => getActiveActionFields,
|
137
|
+
getActiveActionFormPages: () => getActiveActionFormPages,
|
128
138
|
getAllFields: () => getAllFields,
|
129
139
|
getAllPages: () => getAllPages,
|
130
140
|
getCurrentEventState: () => getCurrentEventState,
|
@@ -142,7 +152,10 @@ __export(events_exports, {
|
|
142
152
|
isDividerFieldType: () => isDividerFieldType,
|
143
153
|
isEmailFieldType: () => isEmailFieldType,
|
144
154
|
isFacilityFieldType: () => isFacilityFieldType,
|
155
|
+
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
145
156
|
isFieldEnabled: () => isFieldEnabled,
|
157
|
+
isFieldValue: () => isFieldValue,
|
158
|
+
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
146
159
|
isFieldVisible: () => isFieldVisible,
|
147
160
|
isFileFieldType: () => isFileFieldType,
|
148
161
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
@@ -154,9 +167,11 @@ __export(events_exports, {
|
|
154
167
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
155
168
|
isSelectFieldType: () => isSelectFieldType,
|
156
169
|
isSignatureFieldType: () => isSignatureFieldType,
|
170
|
+
isTemplateVariable: () => isTemplateVariable,
|
157
171
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
158
172
|
isTextFieldType: () => isTextFieldType,
|
159
173
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
174
|
+
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
160
175
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
161
176
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
162
177
|
not: () => not,
|
@@ -243,6 +258,11 @@ var FieldType = {
|
|
243
258
|
SIGNATURE: "SIGNATURE"
|
244
259
|
};
|
245
260
|
var fieldTypes = Object.values(FieldType);
|
261
|
+
var compositeFieldTypes = [
|
262
|
+
FieldType.ADDRESS,
|
263
|
+
FieldType.FILE_WITH_OPTIONS,
|
264
|
+
FieldType.FILE
|
265
|
+
];
|
246
266
|
|
247
267
|
// ../commons/src/events/FieldValue.ts
|
248
268
|
var import_zod4 = require("zod");
|
@@ -253,6 +273,10 @@ var GeographicalArea = {
|
|
253
273
|
URBAN: "URBAN",
|
254
274
|
RURAL: "RURAL"
|
255
275
|
};
|
276
|
+
var AddressType = {
|
277
|
+
DOMESTIC: "DOMESTIC",
|
278
|
+
INTERNATIONAL: "INTERNATIONAL"
|
279
|
+
};
|
256
280
|
var FileFieldValue = import_zod3.z.object({
|
257
281
|
filename: import_zod3.z.string(),
|
258
282
|
originalFilename: import_zod3.z.string(),
|
@@ -260,6 +284,7 @@ var FileFieldValue = import_zod3.z.object({
|
|
260
284
|
});
|
261
285
|
var AdminStructure = import_zod3.z.object({
|
262
286
|
country: import_zod3.z.string(),
|
287
|
+
addressType: import_zod3.z.literal(AddressType.DOMESTIC),
|
263
288
|
province: import_zod3.z.string(),
|
264
289
|
district: import_zod3.z.string()
|
265
290
|
});
|
@@ -287,14 +312,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
|
|
287
312
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
288
313
|
village: import_zod3.z.string().nullish()
|
289
314
|
});
|
290
|
-
var
|
291
|
-
|
292
|
-
|
293
|
-
|
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
|
+
});
|
294
338
|
var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
|
295
339
|
UrbanAddressUpdateValue,
|
296
340
|
RuralAddressUpdateValue
|
297
|
-
]);
|
341
|
+
]).or(GenericAddressUpdateValue);
|
298
342
|
var FileFieldValueWithOption = import_zod3.z.object({
|
299
343
|
filename: import_zod3.z.string(),
|
300
344
|
originalFilename: import_zod3.z.string(),
|
@@ -318,7 +362,8 @@ var FieldValue = import_zod4.z.union([
|
|
318
362
|
FileFieldValue,
|
319
363
|
FileFieldWithOptionValue,
|
320
364
|
UrbanAddressValue,
|
321
|
-
RuralAddressValue
|
365
|
+
RuralAddressValue,
|
366
|
+
GenericAddressValue
|
322
367
|
]);
|
323
368
|
var FieldUpdateValue = import_zod4.z.union([
|
324
369
|
TextValue,
|
@@ -328,7 +373,8 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
328
373
|
FileFieldValue,
|
329
374
|
FileFieldWithOptionValue,
|
330
375
|
UrbanAddressUpdateValue,
|
331
|
-
RuralAddressUpdateValue
|
376
|
+
RuralAddressUpdateValue,
|
377
|
+
GenericAddressUpdateValue
|
332
378
|
]);
|
333
379
|
|
334
380
|
// ../commons/src/events/FieldConfig.ts
|
@@ -495,11 +541,16 @@ var Country = BaseField.extend({
|
|
495
541
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
496
542
|
defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
|
497
543
|
}).describe("Country select field");
|
544
|
+
var AdministrativeAreas = import_zod5.z.enum([
|
545
|
+
"ADMIN_STRUCTURE",
|
546
|
+
"HEALTH_FACILITY",
|
547
|
+
"CRVS_OFFICE"
|
548
|
+
]);
|
498
549
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
499
550
|
partOf: import_zod5.z.object({
|
500
551
|
$data: import_zod5.z.string()
|
501
552
|
}).optional().describe("Parent location"),
|
502
|
-
type:
|
553
|
+
type: AdministrativeAreas
|
503
554
|
}).describe("Administrative area options");
|
504
555
|
var AdministrativeArea = BaseField.extend({
|
505
556
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
@@ -594,8 +645,9 @@ var ActionType = {
|
|
594
645
|
CUSTOM: "CUSTOM",
|
595
646
|
REJECT: "REJECT",
|
596
647
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
597
|
-
|
648
|
+
ARCHIVE: "ARCHIVE"
|
598
649
|
};
|
650
|
+
var LatentActions = [ActionType.ARCHIVE, ActionType.REJECT];
|
599
651
|
|
600
652
|
// ../commons/src/events/ActionConfig.ts
|
601
653
|
var ActionConditional2 = import_zod7.z.discriminatedUnion("type", [
|
@@ -622,23 +674,17 @@ var ValidateConfig = ActionConfigBase.merge(
|
|
622
674
|
);
|
623
675
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
624
676
|
import_zod7.z.object({
|
625
|
-
type: import_zod7.z.literal(ActionType.REJECT)
|
626
|
-
comment: import_zod7.z.string(),
|
627
|
-
isDuplicate: import_zod7.z.boolean()
|
677
|
+
type: import_zod7.z.literal(ActionType.REJECT)
|
628
678
|
})
|
629
679
|
);
|
630
680
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
631
681
|
import_zod7.z.object({
|
632
|
-
type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
633
|
-
comment: import_zod7.z.string(),
|
634
|
-
duplicates: import_zod7.z.array(import_zod7.z.string()).describe("UUIDs of duplicate records")
|
682
|
+
type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
635
683
|
})
|
636
684
|
);
|
637
|
-
var
|
685
|
+
var ArchiveConfig = ActionConfigBase.merge(
|
638
686
|
import_zod7.z.object({
|
639
|
-
type: import_zod7.z.literal(ActionType.
|
640
|
-
comment: import_zod7.z.string(),
|
641
|
-
isDuplicate: import_zod7.z.boolean()
|
687
|
+
type: import_zod7.z.literal(ActionType.ARCHIVE)
|
642
688
|
})
|
643
689
|
);
|
644
690
|
var RegisterConfig = ActionConfigBase.merge(
|
@@ -683,7 +729,7 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
683
729
|
ValidateConfig,
|
684
730
|
RejectDeclarationConfig,
|
685
731
|
MarkedAsDuplicateConfig,
|
686
|
-
|
732
|
+
ArchiveConfig,
|
687
733
|
RegisterConfig,
|
688
734
|
DeleteConfig,
|
689
735
|
PrintCertificateActionConfig,
|
@@ -1136,6 +1182,7 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1136
1182
|
case FieldType.ADDRESS:
|
1137
1183
|
return {
|
1138
1184
|
country: "FAR",
|
1185
|
+
addressType: AddressType.DOMESTIC,
|
1139
1186
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1140
1187
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1141
1188
|
urbanOrRural: "URBAN",
|
@@ -1159,6 +1206,51 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1159
1206
|
return null;
|
1160
1207
|
}
|
1161
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
|
+
}
|
1162
1254
|
var isParagraphFieldType = (field2) => {
|
1163
1255
|
return field2.config.type === FieldType.PARAGRAPH;
|
1164
1256
|
};
|
@@ -1258,49 +1350,76 @@ function isFieldVisible(field2, form) {
|
|
1258
1350
|
function isFieldEnabled(field2, form) {
|
1259
1351
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1260
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
|
+
});
|
1261
1385
|
var zodToIntlErrorMap = (issue, _ctx) => {
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
|
1267
|
-
description: "This is the error message for invalid date fields",
|
1268
|
-
id: "v2.error.invalidDate"
|
1269
|
-
}
|
1386
|
+
switch (issue.code) {
|
1387
|
+
case "invalid_string": {
|
1388
|
+
if (_ctx.data === "") {
|
1389
|
+
return createIntlError(errorMessages.requiredField);
|
1270
1390
|
}
|
1271
|
-
|
1272
|
-
|
1273
|
-
if (issue.code === "invalid_string" && issue.validation === "email") {
|
1274
|
-
return {
|
1275
|
-
message: {
|
1276
|
-
message: {
|
1277
|
-
defaultMessage: "Invalid email address",
|
1278
|
-
description: "This is the error message for invalid email fields",
|
1279
|
-
id: "v2.error.invalidEmail"
|
1280
|
-
}
|
1391
|
+
if (issue.validation === "date") {
|
1392
|
+
return createIntlError(errorMessages.invalidDate);
|
1281
1393
|
}
|
1282
|
-
|
1283
|
-
|
1284
|
-
if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
|
1285
|
-
return {
|
1286
|
-
message: {
|
1287
|
-
message: {
|
1288
|
-
defaultMessage: "Required for registration",
|
1289
|
-
description: "This is the error message for required fields",
|
1290
|
-
id: "v2.error.required"
|
1291
|
-
}
|
1394
|
+
if (issue.validation === "email") {
|
1395
|
+
return createIntlError(errorMessages.invalidEmail);
|
1292
1396
|
}
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1397
|
+
break;
|
1398
|
+
}
|
1399
|
+
case "invalid_type": {
|
1400
|
+
if (issue.expected !== issue.received && issue.received === "undefined") {
|
1401
|
+
return createIntlError(errorMessages.requiredField);
|
1402
|
+
}
|
1403
|
+
break;
|
1404
|
+
}
|
1405
|
+
case "too_small": {
|
1406
|
+
if (issue.message === void 0) {
|
1407
|
+
return createIntlError(errorMessages.requiredField);
|
1301
1408
|
}
|
1409
|
+
break;
|
1302
1410
|
}
|
1303
|
-
|
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);
|
1304
1423
|
};
|
1305
1424
|
function getFieldValidationErrors({
|
1306
1425
|
field: field2,
|
@@ -1315,11 +1434,7 @@ function getFieldValidationErrors({
|
|
1315
1434
|
return {
|
1316
1435
|
errors: [
|
1317
1436
|
{
|
1318
|
-
message:
|
1319
|
-
id: "v2.error.hidden",
|
1320
|
-
defaultMessage: "Hidden or disabled field should not receive a value",
|
1321
|
-
description: "Error message when field is hidden or disabled, but a value was received"
|
1322
|
-
}
|
1437
|
+
message: errorMessages.hiddenField
|
1323
1438
|
}
|
1324
1439
|
]
|
1325
1440
|
};
|
@@ -1337,8 +1452,8 @@ function getFieldValidationErrors({
|
|
1337
1452
|
conditionalParameters
|
1338
1453
|
});
|
1339
1454
|
return {
|
1340
|
-
// Assumes that custom validation errors are
|
1341
|
-
errors: [...
|
1455
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1456
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1342
1457
|
};
|
1343
1458
|
}
|
1344
1459
|
function runCustomFieldValidations({
|
@@ -1363,6 +1478,20 @@ function validateFieldInput({
|
|
1363
1478
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1364
1479
|
}
|
1365
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
|
+
|
1366
1495
|
// ../commons/src/events/utils.ts
|
1367
1496
|
function isMetadataField(field2) {
|
1368
1497
|
return field2 in eventMetadataLabelMap;
|
@@ -1432,7 +1561,7 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1432
1561
|
);
|
1433
1562
|
if (!rootWorkqueue) {
|
1434
1563
|
throw new Error(
|
1435
|
-
`Invalid workqueue configuration: workqueue not found with id:
|
1564
|
+
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1436
1565
|
);
|
1437
1566
|
}
|
1438
1567
|
});
|
@@ -1459,7 +1588,16 @@ var findActiveActionFields = (configuration, action) => {
|
|
1459
1588
|
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1460
1589
|
return allFields;
|
1461
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
|
+
};
|
1462
1597
|
function getActiveActionFields(configuration, action) {
|
1598
|
+
if (LatentActions.some((latentAction) => latentAction === action)) {
|
1599
|
+
return getActiveActionFields(configuration, ActionType.DECLARE);
|
1600
|
+
}
|
1463
1601
|
const fields = findActiveActionFields(configuration, action);
|
1464
1602
|
if (!fields) {
|
1465
1603
|
throw new Error(`No active field config found for action type ${action}`);
|
@@ -1491,6 +1629,27 @@ function stripHiddenFields(fields, data) {
|
|
1491
1629
|
return !isFieldVisible(field2, data);
|
1492
1630
|
});
|
1493
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
|
+
}
|
1494
1653
|
|
1495
1654
|
// ../commons/src/events/EventConfig.ts
|
1496
1655
|
var EventConfig = import_zod18.z.object({
|
@@ -1588,9 +1747,9 @@ var MarkAsDuplicateAction = ActionBase.merge(
|
|
1588
1747
|
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1589
1748
|
})
|
1590
1749
|
);
|
1591
|
-
var
|
1750
|
+
var ArchiveAction = ActionBase.merge(
|
1592
1751
|
import_zod19.z.object({
|
1593
|
-
type: import_zod19.z.literal(ActionType.
|
1752
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE)
|
1594
1753
|
})
|
1595
1754
|
);
|
1596
1755
|
var CreatedAction = ActionBase.merge(
|
@@ -1635,7 +1794,7 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1635
1794
|
ValidateAction,
|
1636
1795
|
RejectAction,
|
1637
1796
|
MarkAsDuplicateAction,
|
1638
|
-
|
1797
|
+
ArchiveAction,
|
1639
1798
|
NotifiedAction,
|
1640
1799
|
RegisterAction,
|
1641
1800
|
DeclareAction,
|
@@ -1713,9 +1872,9 @@ var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
|
1713
1872
|
type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1714
1873
|
})
|
1715
1874
|
);
|
1716
|
-
var
|
1875
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
1717
1876
|
import_zod20.z.object({
|
1718
|
-
type: import_zod20.z.literal(ActionType.
|
1877
|
+
type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1719
1878
|
})
|
1720
1879
|
);
|
1721
1880
|
var AssignActionInput = BaseActionInput.merge(
|
@@ -1754,7 +1913,7 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
1754
1913
|
DeclareActionInput,
|
1755
1914
|
RejectDeclarationActionInput,
|
1756
1915
|
MarkedAsDuplicateActionInput,
|
1757
|
-
|
1916
|
+
ArchiveActionInput,
|
1758
1917
|
AssignActionInput,
|
1759
1918
|
UnassignActionInput,
|
1760
1919
|
PrintCertificateActionInput,
|
@@ -1826,7 +1985,7 @@ function getStatusFromActions(actions) {
|
|
1826
1985
|
if (action.type === ActionType.REJECT) {
|
1827
1986
|
return EventStatus.REJECTED;
|
1828
1987
|
}
|
1829
|
-
if (action.type === ActionType.
|
1988
|
+
if (action.type === ActionType.ARCHIVE) {
|
1830
1989
|
return EventStatus.ARCHIVED;
|
1831
1990
|
}
|
1832
1991
|
if (action.type === ActionType.NOTIFY) {
|
@@ -1898,8 +2057,8 @@ function deepMerge(currentDocument, actionDocument) {
|
|
1898
2057
|
}
|
1899
2058
|
);
|
1900
2059
|
}
|
1901
|
-
function isUndeclaredDraft(
|
1902
|
-
return
|
2060
|
+
function isUndeclaredDraft(status) {
|
2061
|
+
return status === EventStatus.CREATED;
|
1903
2062
|
}
|
1904
2063
|
function getCurrentEventState(event2) {
|
1905
2064
|
const creationAction = event2.actions.find(
|
@@ -1924,9 +2083,8 @@ function getCurrentEventState(event2) {
|
|
1924
2083
|
});
|
1925
2084
|
}
|
1926
2085
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
1927
|
-
const actions = event2.actions.slice().sort();
|
1928
|
-
const
|
1929
|
-
const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(({ createdAt }) => createdAt > lastAction.createdAt).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) => {
|
1930
2088
|
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1931
2089
|
return [
|
1932
2090
|
action,
|
@@ -1987,12 +2145,6 @@ var defineConfig = (config) => {
|
|
1987
2145
|
});
|
1988
2146
|
};
|
1989
2147
|
|
1990
|
-
// ../commons/src/uuid.ts
|
1991
|
-
var import_uuid = require("uuid");
|
1992
|
-
function getUUID() {
|
1993
|
-
return (0, import_uuid.v4)();
|
1994
|
-
}
|
1995
|
-
|
1996
2148
|
// ../commons/src/events/transactions.ts
|
1997
2149
|
function generateTransactionId() {
|
1998
2150
|
return getUUID();
|
@@ -2209,6 +2361,23 @@ function field(fieldId) {
|
|
2209
2361
|
}
|
2210
2362
|
},
|
2211
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"]
|
2212
2381
|
})
|
2213
2382
|
};
|
2214
2383
|
}
|
@@ -3412,6 +3581,24 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3412
3581
|
})
|
3413
3582
|
}
|
3414
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]
|
3415
3602
|
}
|
3416
3603
|
],
|
3417
3604
|
advancedSearch: [
|
@@ -3492,9 +3679,9 @@ var eventPayloadGenerator = {
|
|
3492
3679
|
eventId
|
3493
3680
|
}),
|
3494
3681
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3495
|
-
type: ActionType.
|
3682
|
+
type: ActionType.ARCHIVE,
|
3496
3683
|
transactionId: input.transactionId ?? getUUID(),
|
3497
|
-
data: input.data ??
|
3684
|
+
data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
|
3498
3685
|
metadata: { isDuplicate: isDuplicate ?? false },
|
3499
3686
|
duplicates: [],
|
3500
3687
|
eventId
|
@@ -3502,7 +3689,7 @@ var eventPayloadGenerator = {
|
|
3502
3689
|
reject: (eventId, input = {}) => ({
|
3503
3690
|
type: ActionType.REJECT,
|
3504
3691
|
transactionId: input.transactionId ?? getUUID(),
|
3505
|
-
data: input.data ??
|
3692
|
+
data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
|
3506
3693
|
duplicates: [],
|
3507
3694
|
eventId
|
3508
3695
|
}),
|
@@ -3561,7 +3748,9 @@ function generateActionDocument({
|
|
3561
3748
|
defaults = {}
|
3562
3749
|
}) {
|
3563
3750
|
const actionBase = {
|
3564
|
-
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(),
|
3565
3754
|
createdBy: getUUID(),
|
3566
3755
|
id: getUUID(),
|
3567
3756
|
createdAtLocation: "TODO",
|
@@ -3578,7 +3767,7 @@ function generateActionDocument({
|
|
3578
3767
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3579
3768
|
case ActionType.VALIDATE:
|
3580
3769
|
return { ...actionBase, type: action };
|
3581
|
-
case ActionType.
|
3770
|
+
case ActionType.ARCHIVE:
|
3582
3771
|
return { ...actionBase, type: action };
|
3583
3772
|
case ActionType.REJECT:
|
3584
3773
|
return { ...actionBase, type: action };
|
@@ -3616,9 +3805,13 @@ function generateEventDocument({
|
|
3616
3805
|
actions: actions.map(
|
3617
3806
|
(action) => generateActionDocument({ configuration, action })
|
3618
3807
|
),
|
3619
|
-
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(),
|
3620
3811
|
id: getUUID(),
|
3621
|
-
|
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()
|
3622
3815
|
};
|
3623
3816
|
}
|
3624
3817
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
|
@@ -3658,3 +3851,33 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3658
3851
|
},
|
3659
3852
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3660
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
|
+
}
|