@opencrvs/toolkit 1.8.1-rc.20fdb4a → 1.8.1-rc.22fb1a7
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 +409 -392
- package/dist/commons/conditionals/validate.d.ts +11 -2
- package/dist/commons/events/ActionConfig.d.ts +2004 -366
- package/dist/commons/events/ActionDocument.d.ts +1252 -716
- package/dist/commons/events/ActionInput.d.ts +626 -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 +673 -146
- package/dist/commons/events/EventDocument.d.ts +451 -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 +254 -43
- 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 +1032 -246
- package/dist/commons/events/PageConfig.d.ts +264 -46
- package/dist/commons/events/WorkqueueConfig.d.ts +199 -164
- package/dist/commons/events/defineConfig.d.ts +127 -28
- 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 +234 -58
- package/dist/conditionals/index.js +3 -2
- package/dist/events/index.js +280 -123
- 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
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,
|
@@ -139,6 +143,7 @@ __export(events_exports, {
|
|
139
143
|
PageConfig: () => PageConfig,
|
140
144
|
PageTypes: () => PageTypes,
|
141
145
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
146
|
+
PrintContent: () => PrintContent,
|
142
147
|
QueryExpression: () => QueryExpression,
|
143
148
|
QueryInput: () => QueryInput,
|
144
149
|
QueryType: () => QueryType,
|
@@ -167,6 +172,7 @@ __export(events_exports, {
|
|
167
172
|
TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
|
168
173
|
TEST_SYSTEM_IANA_TIMEZONE: () => TEST_SYSTEM_IANA_TIMEZONE,
|
169
174
|
TestUserRole: () => TestUserRole,
|
175
|
+
TextField: () => TextField,
|
170
176
|
TextValue: () => TextValue,
|
171
177
|
TimeValue: () => TimeValue,
|
172
178
|
TranslationConfig: () => TranslationConfig,
|
@@ -178,7 +184,6 @@ __export(events_exports, {
|
|
178
184
|
ValidationConfig: () => ValidationConfig,
|
179
185
|
VerificationActionConfig: () => VerificationActionConfig,
|
180
186
|
VerificationPageConfig: () => VerificationPageConfig,
|
181
|
-
VisibleStatus: () => VisibleStatus,
|
182
187
|
WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
|
183
188
|
Within: () => Within,
|
184
189
|
WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
|
@@ -197,6 +202,7 @@ __export(events_exports, {
|
|
197
202
|
annotationActions: () => annotationActions,
|
198
203
|
applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
|
199
204
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
205
|
+
areCertificateConditionsMet: () => areCertificateConditionsMet,
|
200
206
|
areConditionsMet: () => areConditionsMet,
|
201
207
|
compositeFieldTypes: () => compositeFieldTypes,
|
202
208
|
createEmptyDraft: () => createEmptyDraft,
|
@@ -320,6 +326,7 @@ __export(events_exports, {
|
|
320
326
|
or: () => or,
|
321
327
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
322
328
|
runFieldValidations: () => runFieldValidations,
|
329
|
+
runStructuralValidations: () => runStructuralValidations,
|
323
330
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
324
331
|
user: () => user,
|
325
332
|
validate: () => validate,
|
@@ -554,7 +561,7 @@ var import_zod6 = require("zod");
|
|
554
561
|
var import_zod4 = require("zod");
|
555
562
|
var import_zod_openapi3 = require("zod-openapi");
|
556
563
|
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
|
557
|
-
var
|
564
|
+
var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
|
558
565
|
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
|
559
566
|
);
|
560
567
|
var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
|
@@ -606,13 +613,13 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
|
|
606
613
|
zipCode: import_zod5.z.string().nullish()
|
607
614
|
});
|
608
615
|
var NameFieldValue = import_zod5.z.object({
|
609
|
-
firstname: import_zod5.z.string()
|
610
|
-
surname: import_zod5.z.string()
|
616
|
+
firstname: import_zod5.z.string(),
|
617
|
+
surname: import_zod5.z.string(),
|
611
618
|
middlename: import_zod5.z.string().optional()
|
612
619
|
});
|
613
620
|
var NameFieldUpdateValue = import_zod5.z.object({
|
614
|
-
firstname: import_zod5.z.string()
|
615
|
-
surname: import_zod5.z.string()
|
621
|
+
firstname: import_zod5.z.string(),
|
622
|
+
surname: import_zod5.z.string(),
|
616
623
|
middlename: import_zod5.z.string().nullish()
|
617
624
|
}).or(import_zod5.z.null()).or(import_zod5.z.undefined());
|
618
625
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
@@ -909,18 +916,32 @@ var SelectDateRangeField = BaseField.extend({
|
|
909
916
|
defaultValue: SelectDateRangeValue.optional(),
|
910
917
|
options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
|
911
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() }).optional(),
|
921
|
+
middlename: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional(),
|
922
|
+
surname: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional()
|
923
|
+
});
|
912
924
|
var NameField = BaseField.extend({
|
913
925
|
type: import_zod7.z.literal(FieldType.NAME),
|
914
926
|
defaultValue: import_zod7.z.object({
|
915
|
-
firstname: NonEmptyTextValue,
|
916
|
-
|
927
|
+
firstname: NonEmptyTextValue.optional(),
|
928
|
+
middlename: NonEmptyTextValue.optional(),
|
929
|
+
surname: NonEmptyTextValue.optional()
|
917
930
|
}).optional(),
|
918
931
|
configuration: import_zod7.z.object({
|
932
|
+
name: NameConfig.default({
|
933
|
+
firstname: { required: true },
|
934
|
+
surname: { required: true }
|
935
|
+
}).optional(),
|
919
936
|
maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
|
920
937
|
prefix: TranslationConfig.optional(),
|
921
938
|
postfix: TranslationConfig.optional(),
|
922
|
-
includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
|
923
939
|
searchMode: import_zod7.z.boolean().optional()
|
940
|
+
}).default({
|
941
|
+
name: {
|
942
|
+
firstname: { required: true },
|
943
|
+
surname: { required: true }
|
944
|
+
}
|
924
945
|
}).optional()
|
925
946
|
}).describe("Name input field");
|
926
947
|
var PhoneField = BaseField.extend({
|
@@ -1222,7 +1243,8 @@ var CertificateConfig = import_zod11.z.object({
|
|
1222
1243
|
delayed: import_zod11.z.number()
|
1223
1244
|
}),
|
1224
1245
|
svgUrl: import_zod11.z.string(),
|
1225
|
-
fonts: import_zod11.z.record(FontFamily).optional()
|
1246
|
+
fonts: import_zod11.z.record(FontFamily).optional(),
|
1247
|
+
conditionals: import_zod11.z.array(ShowConditional).optional()
|
1226
1248
|
});
|
1227
1249
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
1228
1250
|
hash: import_zod11.z.string().optional(),
|
@@ -1394,22 +1416,30 @@ var FieldConfigSchema = BaseField3.extend({
|
|
1394
1416
|
fieldType: import_zod15.z.literal("field"),
|
1395
1417
|
alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
|
1396
1418
|
`Sometimes there might be need to search a value against multiple field of same FormField type. For example
|
1397
|
-
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1419
|
+
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1398
1420
|
add a one field as fieldId, and accomodate others in alternateFieldIds`
|
1399
1421
|
),
|
1400
|
-
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1401
|
-
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1422
|
+
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1423
|
+
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1402
1424
|
is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
|
1403
1425
|
related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
|
1404
1426
|
In such case, populate this field (excludeInSearchQuery) with boolean true`)
|
1405
1427
|
});
|
1406
|
-
var
|
1428
|
+
var EventFieldIdInput = import_zod15.z.enum([
|
1407
1429
|
"trackingId",
|
1408
1430
|
"status",
|
1409
1431
|
"legalStatuses.REGISTERED.acceptedAt",
|
1410
1432
|
"legalStatuses.REGISTERED.createdAtLocation",
|
1411
1433
|
"updatedAt"
|
1412
1434
|
]);
|
1435
|
+
var METADATA_FIELD_PREFIX = "event.";
|
1436
|
+
var EventFieldId = import_zod15.z.enum([
|
1437
|
+
`${METADATA_FIELD_PREFIX}trackingId`,
|
1438
|
+
`${METADATA_FIELD_PREFIX}status`,
|
1439
|
+
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
|
1440
|
+
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.createdAtLocation`,
|
1441
|
+
`${METADATA_FIELD_PREFIX}updatedAt`
|
1442
|
+
]);
|
1413
1443
|
var EventFieldConfigSchema = BaseField3.extend({
|
1414
1444
|
fieldId: EventFieldId,
|
1415
1445
|
fieldType: import_zod15.z.literal("event")
|
@@ -1902,11 +1932,15 @@ var ActionBase = import_zod19.z.object({
|
|
1902
1932
|
originalActionId: UUID.optional().nullable().describe(
|
1903
1933
|
"Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
|
1904
1934
|
)
|
1935
|
+
// 'content' field reserved for additional data
|
1936
|
+
// Each action can define its own content specifc to the action
|
1937
|
+
// See PrintCertificateAction
|
1905
1938
|
});
|
1906
1939
|
var AssignedAction = ActionBase.merge(
|
1907
1940
|
import_zod19.z.object({
|
1908
1941
|
type: import_zod19.z.literal(ActionType.ASSIGN),
|
1909
1942
|
assignedTo: import_zod19.z.string()
|
1943
|
+
// TODO move into 'content' property
|
1910
1944
|
})
|
1911
1945
|
);
|
1912
1946
|
var UnassignedAction = ActionBase.merge(
|
@@ -1918,6 +1952,7 @@ var RegisterAction = ActionBase.merge(
|
|
1918
1952
|
import_zod19.z.object({
|
1919
1953
|
type: import_zod19.z.literal(ActionType.REGISTER),
|
1920
1954
|
registrationNumber: import_zod19.z.string().optional()
|
1955
|
+
// TODO move into 'content' property
|
1921
1956
|
})
|
1922
1957
|
);
|
1923
1958
|
var DeclareAction = ActionBase.merge(
|
@@ -1938,6 +1973,7 @@ var RejectAction = ActionBase.merge(
|
|
1938
1973
|
import_zod19.z.object({
|
1939
1974
|
type: import_zod19.z.literal(ActionType.REJECT),
|
1940
1975
|
reason: RejectionReason
|
1976
|
+
// TODO move into 'content' property
|
1941
1977
|
})
|
1942
1978
|
);
|
1943
1979
|
var MarkAsDuplicateAction = ActionBase.merge(
|
@@ -1949,6 +1985,7 @@ var ArchiveAction = ActionBase.merge(
|
|
1949
1985
|
import_zod19.z.object({
|
1950
1986
|
type: import_zod19.z.literal(ActionType.ARCHIVE),
|
1951
1987
|
reason: RejectionReason
|
1988
|
+
// TODO move into 'content' property
|
1952
1989
|
})
|
1953
1990
|
);
|
1954
1991
|
var CreatedAction = ActionBase.merge(
|
@@ -1961,9 +1998,13 @@ var NotifiedAction = ActionBase.merge(
|
|
1961
1998
|
type: import_zod19.z.literal(ActionType.NOTIFY)
|
1962
1999
|
})
|
1963
2000
|
);
|
2001
|
+
var PrintContent = import_zod19.z.object({
|
2002
|
+
templateId: import_zod19.z.string().optional()
|
2003
|
+
});
|
1964
2004
|
var PrintCertificateAction = ActionBase.merge(
|
1965
2005
|
import_zod19.z.object({
|
1966
|
-
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
|
2006
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
|
2007
|
+
content: PrintContent.optional().nullable()
|
1967
2008
|
})
|
1968
2009
|
);
|
1969
2010
|
var RequestedCorrectionAction = ActionBase.merge(
|
@@ -1975,12 +2016,14 @@ var ApprovedCorrectionAction = ActionBase.merge(
|
|
1975
2016
|
import_zod19.z.object({
|
1976
2017
|
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
|
1977
2018
|
requestId: import_zod19.z.string()
|
2019
|
+
// TODO move into 'content' property
|
1978
2020
|
})
|
1979
2021
|
);
|
1980
2022
|
var RejectedCorrectionAction = ActionBase.merge(
|
1981
2023
|
import_zod19.z.object({
|
1982
2024
|
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
|
1983
2025
|
requestId: import_zod19.z.string(),
|
2026
|
+
// TODO move into 'content' property
|
1984
2027
|
reason: RejectionReason
|
1985
2028
|
})
|
1986
2029
|
);
|
@@ -2031,7 +2074,7 @@ var ResolvedUser = import_zod19.z.object({
|
|
2031
2074
|
});
|
2032
2075
|
|
2033
2076
|
// ../commons/src/conditionals/validate.ts
|
2034
|
-
var
|
2077
|
+
var import__ = __toESM(require("ajv/dist/2019"));
|
2035
2078
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
2036
2079
|
var import_date_fns = require("date-fns");
|
2037
2080
|
|
@@ -2245,12 +2288,17 @@ var isNonInteractiveFieldType = (field2) => {
|
|
2245
2288
|
};
|
2246
2289
|
|
2247
2290
|
// ../commons/src/conditionals/validate.ts
|
2248
|
-
var
|
2291
|
+
var AJV_OPTIONS = {
|
2249
2292
|
$data: true,
|
2250
|
-
allowUnionTypes: true
|
2251
|
-
|
2252
|
-
|
2253
|
-
ajv
|
2293
|
+
allowUnionTypes: true,
|
2294
|
+
// This must be here to prevent memory leaks
|
2295
|
+
// https://www.poberezkin.com/posts/2021-02-11-ajv-version-7-big-changes-and-improvements.html#caching-compiled-schemas
|
2296
|
+
// https://github.com/ajv-validator/ajv/issues/1413
|
2297
|
+
addUsedSchema: false,
|
2298
|
+
strict: false
|
2299
|
+
// Allow minContains and other newer features
|
2300
|
+
};
|
2301
|
+
var daysFromNow = {
|
2254
2302
|
keyword: "daysFromNow",
|
2255
2303
|
type: "string",
|
2256
2304
|
schemaType: "object",
|
@@ -2272,8 +2320,11 @@ ajv.addKeyword({
|
|
2272
2320
|
const offsetDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1e3);
|
2273
2321
|
return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
|
2274
2322
|
}
|
2275
|
-
}
|
2323
|
+
};
|
2276
2324
|
function validate(schema, data) {
|
2325
|
+
const ajv = new import__.default(AJV_OPTIONS);
|
2326
|
+
(0, import_ajv_formats.default)(ajv);
|
2327
|
+
ajv.addKeyword(daysFromNow);
|
2277
2328
|
return ajv.validate(schema, data);
|
2278
2329
|
}
|
2279
2330
|
function isConditionMet(conditional, values) {
|
@@ -2420,6 +2471,23 @@ function validateFieldInput({
|
|
2420
2471
|
const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
|
2421
2472
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
2422
2473
|
}
|
2474
|
+
function runStructuralValidations({
|
2475
|
+
field: field2,
|
2476
|
+
values
|
2477
|
+
}) {
|
2478
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
2479
|
+
return {
|
2480
|
+
errors: []
|
2481
|
+
};
|
2482
|
+
}
|
2483
|
+
const fieldValidationResult = validateFieldInput({
|
2484
|
+
field: field2,
|
2485
|
+
value: values[field2.id]
|
2486
|
+
});
|
2487
|
+
return {
|
2488
|
+
errors: fieldValidationResult
|
2489
|
+
};
|
2490
|
+
}
|
2423
2491
|
function runFieldValidations({
|
2424
2492
|
field: field2,
|
2425
2493
|
values
|
@@ -2485,6 +2553,14 @@ function getValidatorsForField(fieldId, validations) {
|
|
2485
2553
|
};
|
2486
2554
|
}).filter((x) => x !== null);
|
2487
2555
|
}
|
2556
|
+
function areCertificateConditionsMet(conditions, values) {
|
2557
|
+
const ajv = new import__.default(AJV_OPTIONS);
|
2558
|
+
(0, import_ajv_formats.default)(ajv);
|
2559
|
+
ajv.addKeyword(daysFromNow);
|
2560
|
+
return conditions.every((condition) => {
|
2561
|
+
return ajv.validate(condition.conditional, values);
|
2562
|
+
});
|
2563
|
+
}
|
2488
2564
|
|
2489
2565
|
// ../commons/src/utils.ts
|
2490
2566
|
function getOrThrow(x, message) {
|
@@ -2705,16 +2781,16 @@ function timePeriodToDateRange(value) {
|
|
2705
2781
|
let startDate;
|
2706
2782
|
switch (value) {
|
2707
2783
|
case "last7Days":
|
2708
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2784
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
|
2709
2785
|
break;
|
2710
2786
|
case "last30Days":
|
2711
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2787
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
|
2712
2788
|
break;
|
2713
2789
|
case "last90Days":
|
2714
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2790
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
|
2715
2791
|
break;
|
2716
2792
|
case "last365Days":
|
2717
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2793
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
|
2718
2794
|
break;
|
2719
2795
|
}
|
2720
2796
|
return {
|
@@ -3081,8 +3157,9 @@ function createFieldConditionals(fieldId) {
|
|
3081
3157
|
properties: {
|
3082
3158
|
[fieldId]: {
|
3083
3159
|
type: "string",
|
3084
|
-
|
3085
|
-
|
3160
|
+
minLength: 1,
|
3161
|
+
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'.-]*)*$",
|
3162
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
3086
3163
|
}
|
3087
3164
|
}
|
3088
3165
|
}),
|
@@ -3195,7 +3272,7 @@ function createSearchConfig(baseField) {
|
|
3195
3272
|
// ../commons/src/event-config/event-configuration.ts
|
3196
3273
|
function createEventFieldConfig(fieldId) {
|
3197
3274
|
const baseField = {
|
3198
|
-
fieldId
|
3275
|
+
fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
|
3199
3276
|
fieldType: "event"
|
3200
3277
|
};
|
3201
3278
|
return createSearchConfig(baseField);
|
@@ -3208,32 +3285,107 @@ function eventFn(fieldId) {
|
|
3208
3285
|
var event = Object.assign(eventFn, {
|
3209
3286
|
/**
|
3210
3287
|
* Checks if the event contains a specific action type.
|
3288
|
+
* Can be used directly as a conditional or chained with additional methods.
|
3211
3289
|
* @param action - The action type to check for.
|
3212
3290
|
*/
|
3213
|
-
hasAction: (action) =>
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3291
|
+
hasAction: (action) => {
|
3292
|
+
const basicConditional = defineConditional({
|
3293
|
+
type: "object",
|
3294
|
+
properties: {
|
3295
|
+
$event: {
|
3296
|
+
type: "object",
|
3297
|
+
properties: {
|
3298
|
+
actions: {
|
3299
|
+
type: "array",
|
3300
|
+
contains: {
|
3301
|
+
type: "object",
|
3302
|
+
properties: {
|
3303
|
+
type: {
|
3304
|
+
const: action
|
3305
|
+
}
|
3306
|
+
},
|
3307
|
+
required: ["type"]
|
3308
|
+
}
|
3309
|
+
}
|
3310
|
+
},
|
3311
|
+
required: ["actions"]
|
3312
|
+
}
|
3313
|
+
},
|
3314
|
+
required: ["$event"]
|
3315
|
+
});
|
3316
|
+
const buildActionConstraints = (additionalFields) => {
|
3317
|
+
const actionProperties = {
|
3318
|
+
type: { const: action }
|
3319
|
+
};
|
3320
|
+
const requiredFields = ["type"];
|
3321
|
+
if (additionalFields) {
|
3322
|
+
Object.entries(additionalFields).forEach(([key, value]) => {
|
3323
|
+
actionProperties[key] = { const: value };
|
3324
|
+
requiredFields.push(key);
|
3325
|
+
});
|
3326
|
+
}
|
3327
|
+
return { actionProperties, requiredFields };
|
3328
|
+
};
|
3329
|
+
const createCountConditional = (countType, count, additionalFields) => {
|
3330
|
+
const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
|
3331
|
+
return defineConditional({
|
3217
3332
|
type: "object",
|
3218
3333
|
properties: {
|
3219
|
-
|
3220
|
-
type: "
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
|
3226
|
-
|
3227
|
-
|
3228
|
-
|
3229
|
-
|
3334
|
+
$event: {
|
3335
|
+
type: "object",
|
3336
|
+
properties: {
|
3337
|
+
actions: {
|
3338
|
+
type: "array",
|
3339
|
+
contains: {
|
3340
|
+
type: "object",
|
3341
|
+
properties: actionProperties,
|
3342
|
+
required: requiredFields
|
3343
|
+
},
|
3344
|
+
[countType]: count
|
3345
|
+
}
|
3346
|
+
},
|
3347
|
+
required: ["actions"]
|
3230
3348
|
}
|
3231
3349
|
},
|
3232
|
-
required: ["
|
3233
|
-
}
|
3234
|
-
}
|
3235
|
-
|
3236
|
-
|
3350
|
+
required: ["$event"]
|
3351
|
+
});
|
3352
|
+
};
|
3353
|
+
const withMinMax = (additionalFields) => {
|
3354
|
+
return {
|
3355
|
+
/**
|
3356
|
+
* Creates a conditional that checks if the event contains a specific action type
|
3357
|
+
* with a minimum count of occurrences.
|
3358
|
+
*
|
3359
|
+
* @param minCount - The minimum number of actions required.
|
3360
|
+
*/
|
3361
|
+
minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
|
3362
|
+
/**
|
3363
|
+
* Builds a conditional that sets a maximum count for the number of actions.
|
3364
|
+
* This is useful for limiting the number of actions of a specific type in a single event.
|
3365
|
+
*/
|
3366
|
+
maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
|
3367
|
+
};
|
3368
|
+
};
|
3369
|
+
const chainableMethods = {
|
3370
|
+
/**
|
3371
|
+
* Adds additional field constraints to the action matching.
|
3372
|
+
*
|
3373
|
+
* @param fields - Object containing additional fields to match on the action.
|
3374
|
+
*/
|
3375
|
+
withFields: (fields) => withMinMax(fields),
|
3376
|
+
/**
|
3377
|
+
* Adds template ID constraint to the action matching.
|
3378
|
+
* This is a convenience method that adds content.templateId to the fields.
|
3379
|
+
*
|
3380
|
+
* @param id - The template ID to match against.
|
3381
|
+
*/
|
3382
|
+
withTemplate: (id) => withMinMax({
|
3383
|
+
content: { templateId: id }
|
3384
|
+
}),
|
3385
|
+
...withMinMax()
|
3386
|
+
};
|
3387
|
+
return { ...basicConditional, ...chainableMethods };
|
3388
|
+
},
|
3237
3389
|
field(field2) {
|
3238
3390
|
return {
|
3239
3391
|
$event: field2
|
@@ -3252,24 +3404,23 @@ var EventStatus = import_zod23.z.enum([
|
|
3252
3404
|
"DECLARED",
|
3253
3405
|
"VALIDATED",
|
3254
3406
|
"REGISTERED",
|
3255
|
-
"CERTIFIED",
|
3256
3407
|
"ARCHIVED"
|
3257
3408
|
]);
|
3258
|
-
var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
|
3259
3409
|
var InherentFlags = {
|
3260
|
-
|
3410
|
+
PENDING_CERTIFICATION: "pending-certification",
|
3261
3411
|
INCOMPLETE: "incomplete",
|
3262
3412
|
REJECTED: "rejected",
|
3263
3413
|
CORRECTION_REQUESTED: "correction-requested"
|
3264
3414
|
};
|
3265
|
-
var
|
3415
|
+
var ActionFlag = import_zod23.z.string().regex(
|
3266
3416
|
new RegExp(
|
3267
3417
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
3268
3418
|
ActionStatus
|
3269
3419
|
).join("|").toLowerCase()})$`
|
3270
3420
|
),
|
3271
3421
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3272
|
-
)
|
3422
|
+
);
|
3423
|
+
var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
|
3273
3424
|
var ZodDate = import_zod23.z.string().date();
|
3274
3425
|
var ActionCreationMetadata = import_zod23.z.object({
|
3275
3426
|
createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3785,7 +3936,8 @@ var WorkqueueConfig = import_zod28.z.object({
|
|
3785
3936
|
})
|
3786
3937
|
),
|
3787
3938
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3788
|
-
icon: AvailableIcons
|
3939
|
+
icon: AvailableIcons,
|
3940
|
+
emptyMessage: TranslationConfig.optional()
|
3789
3941
|
}).describe("Configuration for workqueue.");
|
3790
3942
|
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3791
3943
|
query: true,
|
@@ -3804,7 +3956,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
|
|
3804
3956
|
})
|
3805
3957
|
),
|
3806
3958
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3807
|
-
icon: AvailableIcons
|
3959
|
+
icon: AvailableIcons,
|
3960
|
+
emptyMessage: TranslationConfig.optional()
|
3808
3961
|
});
|
3809
3962
|
function defineWorkqueue(workqueueInput) {
|
3810
3963
|
const queryInput = workqueueInput.query;
|
@@ -3893,7 +4046,8 @@ var DeclareActionInput = BaseActionInput.merge(
|
|
3893
4046
|
);
|
3894
4047
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
3895
4048
|
import_zod29.z.object({
|
3896
|
-
type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
4049
|
+
type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
|
4050
|
+
content: PrintContent.optional()
|
3897
4051
|
})
|
3898
4052
|
);
|
3899
4053
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
@@ -4105,16 +4259,19 @@ function getLegalStatuses(actions) {
|
|
4105
4259
|
}
|
4106
4260
|
|
4107
4261
|
// ../commons/src/events/state/flags.ts
|
4108
|
-
function
|
4262
|
+
function isPendingCertification(actions) {
|
4263
|
+
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
4264
|
+
return false;
|
4265
|
+
}
|
4109
4266
|
return actions.reduce((prev, { type }) => {
|
4110
4267
|
if (type === ActionType.PRINT_CERTIFICATE) {
|
4111
|
-
return
|
4268
|
+
return false;
|
4112
4269
|
}
|
4113
4270
|
if (type === ActionType.APPROVE_CORRECTION) {
|
4114
|
-
return
|
4271
|
+
return true;
|
4115
4272
|
}
|
4116
4273
|
return prev;
|
4117
|
-
},
|
4274
|
+
}, true);
|
4118
4275
|
}
|
4119
4276
|
function isCorrectionRequested(actions) {
|
4120
4277
|
return actions.reduce((prev, { type }) => {
|
@@ -4149,8 +4306,8 @@ function getFlagsFromActions(actions) {
|
|
4149
4306
|
const flag = joinValues([type, status], ":").toLowerCase();
|
4150
4307
|
return flag;
|
4151
4308
|
});
|
4152
|
-
if (
|
4153
|
-
flags.push(InherentFlags.
|
4309
|
+
if (isPendingCertification(sortedActions)) {
|
4310
|
+
flags.push(InherentFlags.PENDING_CERTIFICATION);
|
4154
4311
|
}
|
4155
4312
|
if (isCorrectionRequested(sortedActions)) {
|
4156
4313
|
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
@@ -4181,7 +4338,6 @@ function getStatusFromActions(actions) {
|
|
4181
4338
|
case ActionType.NOTIFY:
|
4182
4339
|
return EventStatus.enum.NOTIFIED;
|
4183
4340
|
case ActionType.PRINT_CERTIFICATE:
|
4184
|
-
return EventStatus.enum.CERTIFIED;
|
4185
4341
|
case ActionType.ASSIGN:
|
4186
4342
|
case ActionType.UNASSIGN:
|
4187
4343
|
case ActionType.REJECT:
|
@@ -5146,7 +5302,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
5146
5302
|
defaultMessage: "Applicant's name",
|
5147
5303
|
description: "This is the label for the field",
|
5148
5304
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
5149
|
-
}
|
5305
|
+
},
|
5306
|
+
configuration: {
|
5307
|
+
name: {
|
5308
|
+
firstname: { required: true },
|
5309
|
+
middlename: { required: false },
|
5310
|
+
surname: { required: true }
|
5311
|
+
}
|
5312
|
+
},
|
5313
|
+
validation: [
|
5314
|
+
{
|
5315
|
+
validator: field("applicant.name").object({
|
5316
|
+
firstname: field("firstname").isValidEnglishName(),
|
5317
|
+
surname: field("surname").isValidEnglishName()
|
5318
|
+
}),
|
5319
|
+
message: {
|
5320
|
+
defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
|
5321
|
+
description: "This is the error message for invalid name",
|
5322
|
+
id: "v2.error.invalidName"
|
5323
|
+
}
|
5324
|
+
}
|
5325
|
+
]
|
5150
5326
|
},
|
5151
5327
|
{
|
5152
5328
|
id: "applicant.email",
|
@@ -5368,22 +5544,6 @@ var statusOptions = [
|
|
5368
5544
|
id: "v2.advancedSearch.form.recordStatusRegistered"
|
5369
5545
|
}
|
5370
5546
|
},
|
5371
|
-
{
|
5372
|
-
value: EventStatus.enum.CERTIFIED,
|
5373
|
-
label: {
|
5374
|
-
defaultMessage: "Certified",
|
5375
|
-
description: "Option for form field: status of record",
|
5376
|
-
id: "v2.advancedSearch.form.recordStatusCertified"
|
5377
|
-
}
|
5378
|
-
},
|
5379
|
-
{
|
5380
|
-
value: VisibleStatus.enum.REJECTED,
|
5381
|
-
label: {
|
5382
|
-
defaultMessage: "Rejected",
|
5383
|
-
description: "Option for form field: status of record",
|
5384
|
-
id: "v2.advancedSearch.form.recordStatusRejected"
|
5385
|
-
}
|
5386
|
-
},
|
5387
5547
|
{
|
5388
5548
|
value: EventStatus.enum.ARCHIVED,
|
5389
5549
|
label: {
|
@@ -5590,44 +5750,41 @@ var tennisClubMembershipEvent = defineConfig({
|
|
5590
5750
|
},
|
5591
5751
|
{
|
5592
5752
|
id: "identity-check",
|
5593
|
-
type: PageTypes.enum.
|
5753
|
+
type: PageTypes.enum.VERIFICATION,
|
5594
5754
|
title: {
|
5595
|
-
id: "event.
|
5596
|
-
defaultMessage: "Verify
|
5755
|
+
id: "v2.event.birth.action.correction.form.section.requester.identity.verify.title",
|
5756
|
+
defaultMessage: "Verify ID",
|
5597
5757
|
description: "This is the title of the section"
|
5598
5758
|
},
|
5599
|
-
fields: [
|
5600
|
-
|
5601
|
-
|
5602
|
-
type: "PAGE_HEADER",
|
5759
|
+
fields: [],
|
5760
|
+
actions: {
|
5761
|
+
verify: {
|
5603
5762
|
label: {
|
5604
|
-
|
5605
|
-
|
5606
|
-
|
5763
|
+
defaultMessage: "Verified",
|
5764
|
+
description: "This is the label for the verification button",
|
5765
|
+
id: "v2.event.birth.action.correction.form.verify"
|
5607
5766
|
}
|
5608
5767
|
},
|
5609
|
-
{
|
5610
|
-
id: "correction.identity-check.verified",
|
5611
|
-
type: "RADIO_GROUP",
|
5768
|
+
cancel: {
|
5612
5769
|
label: {
|
5613
|
-
|
5614
|
-
|
5615
|
-
|
5770
|
+
defaultMessage: "Identity does not match",
|
5771
|
+
description: "This is the label for the verification cancellation button",
|
5772
|
+
id: "v2.event.birth.action.correction.form.cancel"
|
5616
5773
|
},
|
5617
|
-
|
5618
|
-
|
5619
|
-
|
5620
|
-
|
5621
|
-
|
5622
|
-
|
5623
|
-
|
5624
|
-
|
5625
|
-
|
5626
|
-
|
5774
|
+
confirmation: {
|
5775
|
+
title: {
|
5776
|
+
defaultMessage: "Correct without proof of ID?",
|
5777
|
+
description: "This is the title for the verification cancellation modal",
|
5778
|
+
id: "v2.event.birth.action.correction.form.cancel.confirmation.title"
|
5779
|
+
},
|
5780
|
+
body: {
|
5781
|
+
defaultMessage: "Please be aware that if you proceed, you will be responsible for making a change to this record without the necessary proof of identification",
|
5782
|
+
description: "This is the body for the verification cancellation modal",
|
5783
|
+
id: "v2.event.birth.action.correction.form.cancel.confirmation.body"
|
5627
5784
|
}
|
5628
|
-
|
5785
|
+
}
|
5629
5786
|
}
|
5630
|
-
|
5787
|
+
}
|
5631
5788
|
},
|
5632
5789
|
{
|
5633
5790
|
id: "correction-request.supporting-documents",
|
@@ -6601,6 +6758,7 @@ function eventPayloadGenerator(rng) {
|
|
6601
6758
|
annotation: {
|
6602
6759
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
6603
6760
|
"correction.request.reason": "Child's name was incorrect",
|
6761
|
+
"identity-check": true,
|
6604
6762
|
...annotation
|
6605
6763
|
},
|
6606
6764
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -6835,7 +6993,11 @@ function generateActionDocument({
|
|
6835
6993
|
case ActionType.NOTIFY:
|
6836
6994
|
return { ...actionBase, type: action };
|
6837
6995
|
case ActionType.PRINT_CERTIFICATE:
|
6838
|
-
return {
|
6996
|
+
return {
|
6997
|
+
...actionBase,
|
6998
|
+
type: action,
|
6999
|
+
content: defaults.content
|
7000
|
+
};
|
6839
7001
|
case ActionType.REQUEST_CORRECTION:
|
6840
7002
|
return { ...actionBase, type: action };
|
6841
7003
|
case ActionType.APPROVE_CORRECTION:
|
@@ -7235,14 +7397,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7235
7397
|
ActionType.REJECT_CORRECTION,
|
7236
7398
|
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7237
7399
|
],
|
7238
|
-
[EventStatus.enum.CERTIFIED]: [
|
7239
|
-
ActionType.READ,
|
7240
|
-
ActionType.PRINT_CERTIFICATE,
|
7241
|
-
ActionType.REQUEST_CORRECTION,
|
7242
|
-
ActionType.APPROVE_CORRECTION,
|
7243
|
-
ActionType.REJECT_CORRECTION,
|
7244
|
-
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7245
|
-
],
|
7246
7400
|
[EventStatus.enum.ARCHIVED]: [
|
7247
7401
|
ActionType.READ,
|
7248
7402
|
ActionType.ASSIGN,
|
@@ -7250,9 +7404,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7250
7404
|
]
|
7251
7405
|
};
|
7252
7406
|
var getAvailableActionsForEvent = (event2) => {
|
7253
|
-
|
7254
|
-
|
7255
|
-
|
7256
|
-
|
7257
|
-
|
7407
|
+
if (event2.flags.includes(InherentFlags.REJECTED)) {
|
7408
|
+
return [
|
7409
|
+
ActionType.READ,
|
7410
|
+
event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
|
7411
|
+
ActionType.ARCHIVE
|
7412
|
+
];
|
7413
|
+
}
|
7414
|
+
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
|
7258
7415
|
};
|