@opencrvs/toolkit 1.8.1-rc.38b4f18 → 1.8.1-rc.448a7dd
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 +391 -392
- package/dist/commons/conditionals/validate.d.ts +11 -2
- package/dist/commons/events/ActionConfig.d.ts +3924 -642
- package/dist/commons/events/ActionDocument.d.ts +736 -736
- package/dist/commons/events/ActionInput.d.ts +600 -600
- package/dist/commons/events/AdvancedSearchConfig.d.ts +49 -31
- package/dist/commons/events/CompositeFieldValue.d.ts +6 -6
- package/dist/commons/events/CountryConfigQueryInput.d.ts +88 -88
- package/dist/commons/events/Draft.d.ts +48 -48
- package/dist/commons/events/EventConfig.d.ts +1259 -240
- package/dist/commons/events/EventDocument.d.ts +432 -432
- package/dist/commons/events/EventIndex.d.ts +62 -62
- package/dist/commons/events/EventMetadata.d.ts +9 -9
- package/dist/commons/events/FieldConfig.d.ts +517 -71
- package/dist/commons/events/FieldTypeMapping.d.ts +16 -16
- package/dist/commons/events/FieldValue.d.ts +12 -12
- package/dist/commons/events/FormConfig.d.ts +1956 -378
- package/dist/commons/events/PageConfig.d.ts +524 -82
- package/dist/commons/events/WorkqueueConfig.d.ts +199 -164
- package/dist/commons/events/defineConfig.d.ts +181 -46
- package/dist/commons/events/event.d.ts +61 -7
- package/dist/commons/events/test.utils.d.ts +12 -12
- package/dist/commons/events/utils.d.ts +330 -90
- package/dist/conditionals/index.js +3 -2
- package/dist/events/index.js +252 -95
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
- package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
- package/dist/commons/conditionals/validate.test.d.ts +0 -2
- package/dist/commons/events/utils.test.d.ts +0 -2
@@ -287,8 +287,9 @@ function createFieldConditionals(fieldId) {
|
|
287
287
|
properties: {
|
288
288
|
[fieldId]: {
|
289
289
|
type: "string",
|
290
|
-
|
291
|
-
|
290
|
+
minLength: 1,
|
291
|
+
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'.-]*)*$",
|
292
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
292
293
|
}
|
293
294
|
}
|
294
295
|
}),
|
package/dist/events/index.js
CHANGED
@@ -40,6 +40,7 @@ __export(events_exports, {
|
|
40
40
|
ActionConfigBase: () => ActionConfigBase,
|
41
41
|
ActionCreationMetadata: () => ActionCreationMetadata,
|
42
42
|
ActionDocument: () => ActionDocument,
|
43
|
+
ActionFlag: () => ActionFlag,
|
43
44
|
ActionFormConfig: () => ActionFormConfig,
|
44
45
|
ActionInput: () => ActionInput,
|
45
46
|
ActionStatus: () => ActionStatus,
|
@@ -95,6 +96,7 @@ __export(events_exports, {
|
|
95
96
|
EventDocument: () => EventDocument,
|
96
97
|
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
97
98
|
EventFieldId: () => EventFieldId,
|
99
|
+
EventFieldIdInput: () => EventFieldIdInput,
|
98
100
|
EventIndex: () => EventIndex,
|
99
101
|
EventInput: () => EventInput,
|
100
102
|
EventMetadata: () => EventMetadata,
|
@@ -129,8 +131,10 @@ __export(events_exports, {
|
|
129
131
|
InherentFlags: () => InherentFlags,
|
130
132
|
LanguageConfig: () => LanguageConfig,
|
131
133
|
LegalStatuses: () => LegalStatuses,
|
134
|
+
METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
|
132
135
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
133
136
|
MimeType: () => MimeType,
|
137
|
+
NameConfig: () => NameConfig,
|
134
138
|
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
135
139
|
NameFieldValue: () => NameFieldValue,
|
136
140
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
@@ -168,6 +172,7 @@ __export(events_exports, {
|
|
168
172
|
TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
|
169
173
|
TEST_SYSTEM_IANA_TIMEZONE: () => TEST_SYSTEM_IANA_TIMEZONE,
|
170
174
|
TestUserRole: () => TestUserRole,
|
175
|
+
TextField: () => TextField,
|
171
176
|
TextValue: () => TextValue,
|
172
177
|
TimeValue: () => TimeValue,
|
173
178
|
TranslationConfig: () => TranslationConfig,
|
@@ -179,7 +184,6 @@ __export(events_exports, {
|
|
179
184
|
ValidationConfig: () => ValidationConfig,
|
180
185
|
VerificationActionConfig: () => VerificationActionConfig,
|
181
186
|
VerificationPageConfig: () => VerificationPageConfig,
|
182
|
-
VisibleStatus: () => VisibleStatus,
|
183
187
|
WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
|
184
188
|
Within: () => Within,
|
185
189
|
WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
|
@@ -198,6 +202,7 @@ __export(events_exports, {
|
|
198
202
|
annotationActions: () => annotationActions,
|
199
203
|
applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
|
200
204
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
205
|
+
areCertificateConditionsMet: () => areCertificateConditionsMet,
|
201
206
|
areConditionsMet: () => areConditionsMet,
|
202
207
|
compositeFieldTypes: () => compositeFieldTypes,
|
203
208
|
createEmptyDraft: () => createEmptyDraft,
|
@@ -321,6 +326,7 @@ __export(events_exports, {
|
|
321
326
|
or: () => or,
|
322
327
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
323
328
|
runFieldValidations: () => runFieldValidations,
|
329
|
+
runStructuralValidations: () => runStructuralValidations,
|
324
330
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
325
331
|
user: () => user,
|
326
332
|
validate: () => validate,
|
@@ -555,7 +561,7 @@ var import_zod6 = require("zod");
|
|
555
561
|
var import_zod4 = require("zod");
|
556
562
|
var import_zod_openapi3 = require("zod-openapi");
|
557
563
|
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
|
558
|
-
var
|
564
|
+
var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
|
559
565
|
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
|
560
566
|
);
|
561
567
|
var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
|
@@ -607,13 +613,13 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
|
|
607
613
|
zipCode: import_zod5.z.string().nullish()
|
608
614
|
});
|
609
615
|
var NameFieldValue = import_zod5.z.object({
|
610
|
-
firstname: import_zod5.z.string()
|
611
|
-
surname: import_zod5.z.string()
|
616
|
+
firstname: import_zod5.z.string(),
|
617
|
+
surname: import_zod5.z.string(),
|
612
618
|
middlename: import_zod5.z.string().optional()
|
613
619
|
});
|
614
620
|
var NameFieldUpdateValue = import_zod5.z.object({
|
615
|
-
firstname: import_zod5.z.string()
|
616
|
-
surname: import_zod5.z.string()
|
621
|
+
firstname: import_zod5.z.string(),
|
622
|
+
surname: import_zod5.z.string(),
|
617
623
|
middlename: import_zod5.z.string().nullish()
|
618
624
|
}).or(import_zod5.z.null()).or(import_zod5.z.undefined());
|
619
625
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
@@ -910,18 +916,32 @@ var SelectDateRangeField = BaseField.extend({
|
|
910
916
|
defaultValue: SelectDateRangeValue.optional(),
|
911
917
|
options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
|
912
918
|
}).describe("Select input with date range options");
|
919
|
+
var NameConfig = import_zod7.z.object({
|
920
|
+
firstname: import_zod7.z.object({ required: import_zod7.z.boolean(), label: TranslationConfig.optional() }).optional(),
|
921
|
+
middlename: import_zod7.z.object({ required: import_zod7.z.boolean(), label: TranslationConfig.optional() }).optional(),
|
922
|
+
surname: import_zod7.z.object({ required: import_zod7.z.boolean(), label: TranslationConfig.optional() }).optional()
|
923
|
+
});
|
913
924
|
var NameField = BaseField.extend({
|
914
925
|
type: import_zod7.z.literal(FieldType.NAME),
|
915
926
|
defaultValue: import_zod7.z.object({
|
916
|
-
firstname: NonEmptyTextValue,
|
917
|
-
|
927
|
+
firstname: NonEmptyTextValue.optional(),
|
928
|
+
middlename: NonEmptyTextValue.optional(),
|
929
|
+
surname: NonEmptyTextValue.optional()
|
918
930
|
}).optional(),
|
919
931
|
configuration: import_zod7.z.object({
|
932
|
+
name: NameConfig.default({
|
933
|
+
firstname: { required: true },
|
934
|
+
surname: { required: true }
|
935
|
+
}).optional(),
|
936
|
+
order: import_zod7.z.array(import_zod7.z.enum(["firstname", "middlename", "surname"])).optional(),
|
920
937
|
maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
|
921
938
|
prefix: TranslationConfig.optional(),
|
922
|
-
postfix: TranslationConfig.optional()
|
923
|
-
|
924
|
-
|
939
|
+
postfix: TranslationConfig.optional()
|
940
|
+
}).default({
|
941
|
+
name: {
|
942
|
+
firstname: { required: true },
|
943
|
+
surname: { required: true }
|
944
|
+
}
|
925
945
|
}).optional()
|
926
946
|
}).describe("Name input field");
|
927
947
|
var PhoneField = BaseField.extend({
|
@@ -984,10 +1004,32 @@ var Office = BaseField.extend({
|
|
984
1004
|
}).describe("Input field for an office");
|
985
1005
|
var Address = BaseField.extend({
|
986
1006
|
type: import_zod7.z.literal(FieldType.ADDRESS),
|
987
|
-
defaultValue: AddressFieldValue.optional(),
|
988
1007
|
configuration: import_zod7.z.object({
|
989
|
-
|
990
|
-
|
1008
|
+
lineSeparator: import_zod7.z.string().optional(),
|
1009
|
+
fields: import_zod7.z.array(
|
1010
|
+
import_zod7.z.enum([
|
1011
|
+
"number",
|
1012
|
+
"country",
|
1013
|
+
"province",
|
1014
|
+
"addressType",
|
1015
|
+
"district",
|
1016
|
+
"urbanOrRural",
|
1017
|
+
"town",
|
1018
|
+
"residentialArea",
|
1019
|
+
"street",
|
1020
|
+
"zipCode",
|
1021
|
+
"village",
|
1022
|
+
"state",
|
1023
|
+
"district2",
|
1024
|
+
"cityOrTown",
|
1025
|
+
"addressLine1",
|
1026
|
+
"addressLine2",
|
1027
|
+
"addressLine3",
|
1028
|
+
"postcodeOrZip"
|
1029
|
+
])
|
1030
|
+
).optional()
|
1031
|
+
}).optional(),
|
1032
|
+
defaultValue: AddressFieldValue.optional()
|
991
1033
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
992
1034
|
var DataEntry = import_zod7.z.union([
|
993
1035
|
import_zod7.z.object({
|
@@ -1223,7 +1265,8 @@ var CertificateConfig = import_zod11.z.object({
|
|
1223
1265
|
delayed: import_zod11.z.number()
|
1224
1266
|
}),
|
1225
1267
|
svgUrl: import_zod11.z.string(),
|
1226
|
-
fonts: import_zod11.z.record(FontFamily).optional()
|
1268
|
+
fonts: import_zod11.z.record(FontFamily).optional(),
|
1269
|
+
conditionals: import_zod11.z.array(ShowConditional).optional()
|
1227
1270
|
});
|
1228
1271
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
1229
1272
|
hash: import_zod11.z.string().optional(),
|
@@ -1395,22 +1438,30 @@ var FieldConfigSchema = BaseField3.extend({
|
|
1395
1438
|
fieldType: import_zod15.z.literal("field"),
|
1396
1439
|
alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
|
1397
1440
|
`Sometimes there might be need to search a value against multiple field of same FormField type. For example
|
1398
|
-
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1441
|
+
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1399
1442
|
add a one field as fieldId, and accomodate others in alternateFieldIds`
|
1400
1443
|
),
|
1401
|
-
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1402
|
-
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1444
|
+
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1445
|
+
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1403
1446
|
is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
|
1404
1447
|
related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
|
1405
1448
|
In such case, populate this field (excludeInSearchQuery) with boolean true`)
|
1406
1449
|
});
|
1407
|
-
var
|
1450
|
+
var EventFieldIdInput = import_zod15.z.enum([
|
1408
1451
|
"trackingId",
|
1409
1452
|
"status",
|
1410
1453
|
"legalStatuses.REGISTERED.acceptedAt",
|
1411
1454
|
"legalStatuses.REGISTERED.createdAtLocation",
|
1412
1455
|
"updatedAt"
|
1413
1456
|
]);
|
1457
|
+
var METADATA_FIELD_PREFIX = "event.";
|
1458
|
+
var EventFieldId = import_zod15.z.enum([
|
1459
|
+
`${METADATA_FIELD_PREFIX}trackingId`,
|
1460
|
+
`${METADATA_FIELD_PREFIX}status`,
|
1461
|
+
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
|
1462
|
+
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.createdAtLocation`,
|
1463
|
+
`${METADATA_FIELD_PREFIX}updatedAt`
|
1464
|
+
]);
|
1414
1465
|
var EventFieldConfigSchema = BaseField3.extend({
|
1415
1466
|
fieldId: EventFieldId,
|
1416
1467
|
fieldType: import_zod15.z.literal("event")
|
@@ -2045,7 +2096,7 @@ var ResolvedUser = import_zod19.z.object({
|
|
2045
2096
|
});
|
2046
2097
|
|
2047
2098
|
// ../commons/src/conditionals/validate.ts
|
2048
|
-
var
|
2099
|
+
var import__ = __toESM(require("ajv/dist/2019"));
|
2049
2100
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
2050
2101
|
var import_date_fns = require("date-fns");
|
2051
2102
|
|
@@ -2259,9 +2310,11 @@ var isNonInteractiveFieldType = (field2) => {
|
|
2259
2310
|
};
|
2260
2311
|
|
2261
2312
|
// ../commons/src/conditionals/validate.ts
|
2262
|
-
var ajv = new
|
2313
|
+
var ajv = new import__.default({
|
2263
2314
|
$data: true,
|
2264
|
-
allowUnionTypes: true
|
2315
|
+
allowUnionTypes: true,
|
2316
|
+
strict: false
|
2317
|
+
// Allow minContains and other newer features
|
2265
2318
|
});
|
2266
2319
|
(0, import_ajv_formats.default)(ajv);
|
2267
2320
|
ajv.addKeyword({
|
@@ -2434,6 +2487,23 @@ function validateFieldInput({
|
|
2434
2487
|
const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
|
2435
2488
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
2436
2489
|
}
|
2490
|
+
function runStructuralValidations({
|
2491
|
+
field: field2,
|
2492
|
+
values
|
2493
|
+
}) {
|
2494
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
2495
|
+
return {
|
2496
|
+
errors: []
|
2497
|
+
};
|
2498
|
+
}
|
2499
|
+
const fieldValidationResult = validateFieldInput({
|
2500
|
+
field: field2,
|
2501
|
+
value: values[field2.id]
|
2502
|
+
});
|
2503
|
+
return {
|
2504
|
+
errors: fieldValidationResult
|
2505
|
+
};
|
2506
|
+
}
|
2437
2507
|
function runFieldValidations({
|
2438
2508
|
field: field2,
|
2439
2509
|
values
|
@@ -2499,6 +2569,11 @@ function getValidatorsForField(fieldId, validations) {
|
|
2499
2569
|
};
|
2500
2570
|
}).filter((x) => x !== null);
|
2501
2571
|
}
|
2572
|
+
function areCertificateConditionsMet(conditions, values) {
|
2573
|
+
return conditions.every((condition) => {
|
2574
|
+
return ajv.validate(condition.conditional, values);
|
2575
|
+
});
|
2576
|
+
}
|
2502
2577
|
|
2503
2578
|
// ../commons/src/utils.ts
|
2504
2579
|
function getOrThrow(x, message) {
|
@@ -2719,16 +2794,16 @@ function timePeriodToDateRange(value) {
|
|
2719
2794
|
let startDate;
|
2720
2795
|
switch (value) {
|
2721
2796
|
case "last7Days":
|
2722
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2797
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
|
2723
2798
|
break;
|
2724
2799
|
case "last30Days":
|
2725
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2800
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
|
2726
2801
|
break;
|
2727
2802
|
case "last90Days":
|
2728
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2803
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
|
2729
2804
|
break;
|
2730
2805
|
case "last365Days":
|
2731
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2806
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
|
2732
2807
|
break;
|
2733
2808
|
}
|
2734
2809
|
return {
|
@@ -3095,8 +3170,9 @@ function createFieldConditionals(fieldId) {
|
|
3095
3170
|
properties: {
|
3096
3171
|
[fieldId]: {
|
3097
3172
|
type: "string",
|
3098
|
-
|
3099
|
-
|
3173
|
+
minLength: 1,
|
3174
|
+
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'.-]*)*$",
|
3175
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
3100
3176
|
}
|
3101
3177
|
}
|
3102
3178
|
}),
|
@@ -3209,7 +3285,7 @@ function createSearchConfig(baseField) {
|
|
3209
3285
|
// ../commons/src/event-config/event-configuration.ts
|
3210
3286
|
function createEventFieldConfig(fieldId) {
|
3211
3287
|
const baseField = {
|
3212
|
-
fieldId
|
3288
|
+
fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
|
3213
3289
|
fieldType: "event"
|
3214
3290
|
};
|
3215
3291
|
return createSearchConfig(baseField);
|
@@ -3222,32 +3298,107 @@ function eventFn(fieldId) {
|
|
3222
3298
|
var event = Object.assign(eventFn, {
|
3223
3299
|
/**
|
3224
3300
|
* Checks if the event contains a specific action type.
|
3301
|
+
* Can be used directly as a conditional or chained with additional methods.
|
3225
3302
|
* @param action - The action type to check for.
|
3226
3303
|
*/
|
3227
|
-
hasAction: (action) =>
|
3228
|
-
|
3229
|
-
|
3230
|
-
|
3304
|
+
hasAction: (action) => {
|
3305
|
+
const basicConditional = defineConditional({
|
3306
|
+
type: "object",
|
3307
|
+
properties: {
|
3308
|
+
$event: {
|
3309
|
+
type: "object",
|
3310
|
+
properties: {
|
3311
|
+
actions: {
|
3312
|
+
type: "array",
|
3313
|
+
contains: {
|
3314
|
+
type: "object",
|
3315
|
+
properties: {
|
3316
|
+
type: {
|
3317
|
+
const: action
|
3318
|
+
}
|
3319
|
+
},
|
3320
|
+
required: ["type"]
|
3321
|
+
}
|
3322
|
+
}
|
3323
|
+
},
|
3324
|
+
required: ["actions"]
|
3325
|
+
}
|
3326
|
+
},
|
3327
|
+
required: ["$event"]
|
3328
|
+
});
|
3329
|
+
const buildActionConstraints = (additionalFields) => {
|
3330
|
+
const actionProperties = {
|
3331
|
+
type: { const: action }
|
3332
|
+
};
|
3333
|
+
const requiredFields = ["type"];
|
3334
|
+
if (additionalFields) {
|
3335
|
+
Object.entries(additionalFields).forEach(([key, value]) => {
|
3336
|
+
actionProperties[key] = { const: value };
|
3337
|
+
requiredFields.push(key);
|
3338
|
+
});
|
3339
|
+
}
|
3340
|
+
return { actionProperties, requiredFields };
|
3341
|
+
};
|
3342
|
+
const createCountConditional = (countType, count, additionalFields) => {
|
3343
|
+
const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
|
3344
|
+
return defineConditional({
|
3231
3345
|
type: "object",
|
3232
3346
|
properties: {
|
3233
|
-
|
3234
|
-
type: "
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3347
|
+
$event: {
|
3348
|
+
type: "object",
|
3349
|
+
properties: {
|
3350
|
+
actions: {
|
3351
|
+
type: "array",
|
3352
|
+
contains: {
|
3353
|
+
type: "object",
|
3354
|
+
properties: actionProperties,
|
3355
|
+
required: requiredFields
|
3356
|
+
},
|
3357
|
+
[countType]: count
|
3358
|
+
}
|
3359
|
+
},
|
3360
|
+
required: ["actions"]
|
3244
3361
|
}
|
3245
3362
|
},
|
3246
|
-
required: ["
|
3247
|
-
}
|
3248
|
-
}
|
3249
|
-
|
3250
|
-
|
3363
|
+
required: ["$event"]
|
3364
|
+
});
|
3365
|
+
};
|
3366
|
+
const withMinMax = (additionalFields) => {
|
3367
|
+
return {
|
3368
|
+
/**
|
3369
|
+
* Creates a conditional that checks if the event contains a specific action type
|
3370
|
+
* with a minimum count of occurrences.
|
3371
|
+
*
|
3372
|
+
* @param minCount - The minimum number of actions required.
|
3373
|
+
*/
|
3374
|
+
minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
|
3375
|
+
/**
|
3376
|
+
* Builds a conditional that sets a maximum count for the number of actions.
|
3377
|
+
* This is useful for limiting the number of actions of a specific type in a single event.
|
3378
|
+
*/
|
3379
|
+
maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
|
3380
|
+
};
|
3381
|
+
};
|
3382
|
+
const chainableMethods = {
|
3383
|
+
/**
|
3384
|
+
* Adds additional field constraints to the action matching.
|
3385
|
+
*
|
3386
|
+
* @param fields - Object containing additional fields to match on the action.
|
3387
|
+
*/
|
3388
|
+
withFields: (fields) => withMinMax(fields),
|
3389
|
+
/**
|
3390
|
+
* Adds template ID constraint to the action matching.
|
3391
|
+
* This is a convenience method that adds content.templateId to the fields.
|
3392
|
+
*
|
3393
|
+
* @param id - The template ID to match against.
|
3394
|
+
*/
|
3395
|
+
withTemplate: (id) => withMinMax({
|
3396
|
+
content: { templateId: id }
|
3397
|
+
}),
|
3398
|
+
...withMinMax()
|
3399
|
+
};
|
3400
|
+
return { ...basicConditional, ...chainableMethods };
|
3401
|
+
},
|
3251
3402
|
field(field2) {
|
3252
3403
|
return {
|
3253
3404
|
$event: field2
|
@@ -3266,24 +3417,23 @@ var EventStatus = import_zod23.z.enum([
|
|
3266
3417
|
"DECLARED",
|
3267
3418
|
"VALIDATED",
|
3268
3419
|
"REGISTERED",
|
3269
|
-
"CERTIFIED",
|
3270
3420
|
"ARCHIVED"
|
3271
3421
|
]);
|
3272
|
-
var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
|
3273
3422
|
var InherentFlags = {
|
3274
|
-
|
3423
|
+
PENDING_CERTIFICATION: "pending-certification",
|
3275
3424
|
INCOMPLETE: "incomplete",
|
3276
3425
|
REJECTED: "rejected",
|
3277
3426
|
CORRECTION_REQUESTED: "correction-requested"
|
3278
3427
|
};
|
3279
|
-
var
|
3428
|
+
var ActionFlag = import_zod23.z.string().regex(
|
3280
3429
|
new RegExp(
|
3281
3430
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
3282
3431
|
ActionStatus
|
3283
3432
|
).join("|").toLowerCase()})$`
|
3284
3433
|
),
|
3285
3434
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3286
|
-
)
|
3435
|
+
);
|
3436
|
+
var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
|
3287
3437
|
var ZodDate = import_zod23.z.string().date();
|
3288
3438
|
var ActionCreationMetadata = import_zod23.z.object({
|
3289
3439
|
createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3799,7 +3949,8 @@ var WorkqueueConfig = import_zod28.z.object({
|
|
3799
3949
|
})
|
3800
3950
|
),
|
3801
3951
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3802
|
-
icon: AvailableIcons
|
3952
|
+
icon: AvailableIcons,
|
3953
|
+
emptyMessage: TranslationConfig.optional()
|
3803
3954
|
}).describe("Configuration for workqueue.");
|
3804
3955
|
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3805
3956
|
query: true,
|
@@ -3818,7 +3969,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
|
|
3818
3969
|
})
|
3819
3970
|
),
|
3820
3971
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3821
|
-
icon: AvailableIcons
|
3972
|
+
icon: AvailableIcons,
|
3973
|
+
emptyMessage: TranslationConfig.optional()
|
3822
3974
|
});
|
3823
3975
|
function defineWorkqueue(workqueueInput) {
|
3824
3976
|
const queryInput = workqueueInput.query;
|
@@ -4120,16 +4272,19 @@ function getLegalStatuses(actions) {
|
|
4120
4272
|
}
|
4121
4273
|
|
4122
4274
|
// ../commons/src/events/state/flags.ts
|
4123
|
-
function
|
4275
|
+
function isPendingCertification(actions) {
|
4276
|
+
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
4277
|
+
return false;
|
4278
|
+
}
|
4124
4279
|
return actions.reduce((prev, { type }) => {
|
4125
4280
|
if (type === ActionType.PRINT_CERTIFICATE) {
|
4126
|
-
return
|
4281
|
+
return false;
|
4127
4282
|
}
|
4128
4283
|
if (type === ActionType.APPROVE_CORRECTION) {
|
4129
|
-
return
|
4284
|
+
return true;
|
4130
4285
|
}
|
4131
4286
|
return prev;
|
4132
|
-
},
|
4287
|
+
}, true);
|
4133
4288
|
}
|
4134
4289
|
function isCorrectionRequested(actions) {
|
4135
4290
|
return actions.reduce((prev, { type }) => {
|
@@ -4164,8 +4319,8 @@ function getFlagsFromActions(actions) {
|
|
4164
4319
|
const flag = joinValues([type, status], ":").toLowerCase();
|
4165
4320
|
return flag;
|
4166
4321
|
});
|
4167
|
-
if (
|
4168
|
-
flags.push(InherentFlags.
|
4322
|
+
if (isPendingCertification(sortedActions)) {
|
4323
|
+
flags.push(InherentFlags.PENDING_CERTIFICATION);
|
4169
4324
|
}
|
4170
4325
|
if (isCorrectionRequested(sortedActions)) {
|
4171
4326
|
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
@@ -4196,7 +4351,6 @@ function getStatusFromActions(actions) {
|
|
4196
4351
|
case ActionType.NOTIFY:
|
4197
4352
|
return EventStatus.enum.NOTIFIED;
|
4198
4353
|
case ActionType.PRINT_CERTIFICATE:
|
4199
|
-
return EventStatus.enum.CERTIFIED;
|
4200
4354
|
case ActionType.ASSIGN:
|
4201
4355
|
case ActionType.UNASSIGN:
|
4202
4356
|
case ActionType.REJECT:
|
@@ -4325,7 +4479,7 @@ function getCurrentEventStateWithDrafts({
|
|
4325
4479
|
configuration
|
4326
4480
|
}) {
|
4327
4481
|
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
4328
|
-
const activeDrafts =
|
4482
|
+
const activeDrafts = drafts.map((draft) => draft.action).flatMap((action) => {
|
4329
4483
|
if (action.type === ActionType.REQUEST_CORRECTION) {
|
4330
4484
|
return [
|
4331
4485
|
action,
|
@@ -5161,7 +5315,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
5161
5315
|
defaultMessage: "Applicant's name",
|
5162
5316
|
description: "This is the label for the field",
|
5163
5317
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
5164
|
-
}
|
5318
|
+
},
|
5319
|
+
configuration: {
|
5320
|
+
name: {
|
5321
|
+
firstname: { required: true },
|
5322
|
+
middlename: { required: false },
|
5323
|
+
surname: { required: true }
|
5324
|
+
}
|
5325
|
+
},
|
5326
|
+
validation: [
|
5327
|
+
{
|
5328
|
+
validator: field("applicant.name").object({
|
5329
|
+
firstname: field("firstname").isValidEnglishName(),
|
5330
|
+
surname: field("surname").isValidEnglishName()
|
5331
|
+
}),
|
5332
|
+
message: {
|
5333
|
+
defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
|
5334
|
+
description: "This is the error message for invalid name",
|
5335
|
+
id: "v2.error.invalidName"
|
5336
|
+
}
|
5337
|
+
}
|
5338
|
+
]
|
5165
5339
|
},
|
5166
5340
|
{
|
5167
5341
|
id: "applicant.email",
|
@@ -5383,22 +5557,6 @@ var statusOptions = [
|
|
5383
5557
|
id: "v2.advancedSearch.form.recordStatusRegistered"
|
5384
5558
|
}
|
5385
5559
|
},
|
5386
|
-
{
|
5387
|
-
value: EventStatus.enum.CERTIFIED,
|
5388
|
-
label: {
|
5389
|
-
defaultMessage: "Certified",
|
5390
|
-
description: "Option for form field: status of record",
|
5391
|
-
id: "v2.advancedSearch.form.recordStatusCertified"
|
5392
|
-
}
|
5393
|
-
},
|
5394
|
-
{
|
5395
|
-
value: VisibleStatus.enum.REJECTED,
|
5396
|
-
label: {
|
5397
|
-
defaultMessage: "Rejected",
|
5398
|
-
description: "Option for form field: status of record",
|
5399
|
-
id: "v2.advancedSearch.form.recordStatusRejected"
|
5400
|
-
}
|
5401
|
-
},
|
5402
5560
|
{
|
5403
5561
|
value: EventStatus.enum.ARCHIVED,
|
5404
5562
|
label: {
|
@@ -6850,7 +7008,11 @@ function generateActionDocument({
|
|
6850
7008
|
case ActionType.NOTIFY:
|
6851
7009
|
return { ...actionBase, type: action };
|
6852
7010
|
case ActionType.PRINT_CERTIFICATE:
|
6853
|
-
return {
|
7011
|
+
return {
|
7012
|
+
...actionBase,
|
7013
|
+
type: action,
|
7014
|
+
content: defaults.content
|
7015
|
+
};
|
6854
7016
|
case ActionType.REQUEST_CORRECTION:
|
6855
7017
|
return { ...actionBase, type: action };
|
6856
7018
|
case ActionType.APPROVE_CORRECTION:
|
@@ -7250,14 +7412,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7250
7412
|
ActionType.REJECT_CORRECTION,
|
7251
7413
|
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7252
7414
|
],
|
7253
|
-
[EventStatus.enum.CERTIFIED]: [
|
7254
|
-
ActionType.READ,
|
7255
|
-
ActionType.PRINT_CERTIFICATE,
|
7256
|
-
ActionType.REQUEST_CORRECTION,
|
7257
|
-
ActionType.APPROVE_CORRECTION,
|
7258
|
-
ActionType.REJECT_CORRECTION,
|
7259
|
-
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7260
|
-
],
|
7261
7415
|
[EventStatus.enum.ARCHIVED]: [
|
7262
7416
|
ActionType.READ,
|
7263
7417
|
ActionType.ASSIGN,
|
@@ -7265,9 +7419,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7265
7419
|
]
|
7266
7420
|
};
|
7267
7421
|
var getAvailableActionsForEvent = (event2) => {
|
7268
|
-
|
7269
|
-
|
7270
|
-
|
7271
|
-
|
7272
|
-
|
7422
|
+
if (event2.flags.includes(InherentFlags.REJECTED)) {
|
7423
|
+
return [
|
7424
|
+
ActionType.READ,
|
7425
|
+
event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
|
7426
|
+
ActionType.ARCHIVE
|
7427
|
+
];
|
7428
|
+
}
|
7429
|
+
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
|
7273
7430
|
};
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
"@opencrvs/commons/events": ["../commons/src/events/index.ts"]
|
20
20
|
}
|
21
21
|
},
|
22
|
-
"references": [{ "path": "../commons" }],
|
22
|
+
"references": [{ "path": "../commons/tsconfig-commonjs.json" }],
|
23
23
|
"include": ["src/**/*.ts"],
|
24
24
|
"exclude": ["**/node_modules/**", "dist"]
|
25
25
|
}
|