@opencrvs/toolkit 1.8.1-rc.5c415ba → 1.8.1-rc.60d51af
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 -800
- package/dist/commons/conditionals/validate.d.ts +8 -0
- package/dist/commons/events/ActionConfig.d.ts +2004 -366
- package/dist/commons/events/ActionDocument.d.ts +1264 -1387
- package/dist/commons/events/ActionInput.d.ts +622 -1136
- package/dist/commons/events/AdvancedSearchConfig.d.ts +83 -65
- 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 -92
- package/dist/commons/events/EventConfig.d.ts +695 -168
- package/dist/commons/events/EventDocument.d.ts +449 -846
- package/dist/commons/events/EventIndex.d.ts +184 -68
- package/dist/commons/events/EventMetadata.d.ts +9 -15
- 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 +288 -164
- package/dist/commons/events/defineConfig.d.ts +129 -30
- package/dist/commons/events/event.d.ts +14 -6
- package/dist/commons/events/field.d.ts +14 -0
- package/dist/commons/events/test.utils.d.ts +12 -12
- package/dist/commons/events/utils.d.ts +236 -64
- package/dist/conditionals/index.js +3 -2
- package/dist/events/index.js +153 -82
- 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
@@ -39,8 +39,8 @@ __export(events_exports, {
|
|
39
39
|
ActionConfig: () => ActionConfig,
|
40
40
|
ActionConfigBase: () => ActionConfigBase,
|
41
41
|
ActionCreationMetadata: () => ActionCreationMetadata,
|
42
|
-
ActionDetails: () => ActionDetails,
|
43
42
|
ActionDocument: () => ActionDocument,
|
43
|
+
ActionFlag: () => ActionFlag,
|
44
44
|
ActionFormConfig: () => ActionFormConfig,
|
45
45
|
ActionInput: () => ActionInput,
|
46
46
|
ActionStatus: () => ActionStatus,
|
@@ -96,6 +96,7 @@ __export(events_exports, {
|
|
96
96
|
EventDocument: () => EventDocument,
|
97
97
|
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
98
98
|
EventFieldId: () => EventFieldId,
|
99
|
+
EventFieldIdInput: () => EventFieldIdInput,
|
99
100
|
EventIndex: () => EventIndex,
|
100
101
|
EventInput: () => EventInput,
|
101
102
|
EventMetadata: () => EventMetadata,
|
@@ -130,8 +131,10 @@ __export(events_exports, {
|
|
130
131
|
InherentFlags: () => InherentFlags,
|
131
132
|
LanguageConfig: () => LanguageConfig,
|
132
133
|
LegalStatuses: () => LegalStatuses,
|
134
|
+
METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
|
133
135
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
134
136
|
MimeType: () => MimeType,
|
137
|
+
NameConfig: () => NameConfig,
|
135
138
|
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
136
139
|
NameFieldValue: () => NameFieldValue,
|
137
140
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
@@ -140,6 +143,7 @@ __export(events_exports, {
|
|
140
143
|
PageConfig: () => PageConfig,
|
141
144
|
PageTypes: () => PageTypes,
|
142
145
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
146
|
+
PrintContent: () => PrintContent,
|
143
147
|
QueryExpression: () => QueryExpression,
|
144
148
|
QueryInput: () => QueryInput,
|
145
149
|
QueryType: () => QueryType,
|
@@ -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,
|
@@ -322,6 +326,7 @@ __export(events_exports, {
|
|
322
326
|
or: () => or,
|
323
327
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
324
328
|
runFieldValidations: () => runFieldValidations,
|
329
|
+
runStructuralValidations: () => runStructuralValidations,
|
325
330
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
326
331
|
user: () => user,
|
327
332
|
validate: () => validate,
|
@@ -556,7 +561,7 @@ var import_zod6 = require("zod");
|
|
556
561
|
var import_zod4 = require("zod");
|
557
562
|
var import_zod_openapi3 = require("zod-openapi");
|
558
563
|
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
|
559
|
-
var
|
564
|
+
var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
|
560
565
|
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
|
561
566
|
);
|
562
567
|
var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
|
@@ -613,8 +618,8 @@ var NameFieldValue = import_zod5.z.object({
|
|
613
618
|
middlename: import_zod5.z.string().optional()
|
614
619
|
});
|
615
620
|
var NameFieldUpdateValue = import_zod5.z.object({
|
616
|
-
firstname: import_zod5.z.string()
|
617
|
-
surname: import_zod5.z.string()
|
621
|
+
firstname: import_zod5.z.string(),
|
622
|
+
surname: import_zod5.z.string(),
|
618
623
|
middlename: import_zod5.z.string().nullish()
|
619
624
|
}).or(import_zod5.z.null()).or(import_zod5.z.undefined());
|
620
625
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
@@ -911,18 +916,32 @@ var SelectDateRangeField = BaseField.extend({
|
|
911
916
|
defaultValue: SelectDateRangeValue.optional(),
|
912
917
|
options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
|
913
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
|
+
});
|
914
924
|
var NameField = BaseField.extend({
|
915
925
|
type: import_zod7.z.literal(FieldType.NAME),
|
916
926
|
defaultValue: import_zod7.z.object({
|
917
|
-
firstname: NonEmptyTextValue,
|
918
|
-
|
927
|
+
firstname: NonEmptyTextValue.optional(),
|
928
|
+
middlename: NonEmptyTextValue.optional(),
|
929
|
+
surname: NonEmptyTextValue.optional()
|
919
930
|
}).optional(),
|
920
931
|
configuration: import_zod7.z.object({
|
932
|
+
name: NameConfig.default({
|
933
|
+
firstname: { required: true },
|
934
|
+
surname: { required: true }
|
935
|
+
}).optional(),
|
921
936
|
maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
|
922
937
|
prefix: TranslationConfig.optional(),
|
923
938
|
postfix: TranslationConfig.optional(),
|
924
|
-
includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
|
925
939
|
searchMode: import_zod7.z.boolean().optional()
|
940
|
+
}).default({
|
941
|
+
name: {
|
942
|
+
firstname: { required: true },
|
943
|
+
surname: { required: true }
|
944
|
+
}
|
926
945
|
}).optional()
|
927
946
|
}).describe("Name input field");
|
928
947
|
var PhoneField = BaseField.extend({
|
@@ -1343,7 +1362,7 @@ var SummaryConfig = import_zod14.z.object({
|
|
1343
1362
|
|
1344
1363
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1345
1364
|
var import_zod15 = require("zod");
|
1346
|
-
var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
|
1365
|
+
var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
|
1347
1366
|
var BaseField3 = import_zod15.z.object({
|
1348
1367
|
config: import_zod15.z.object({
|
1349
1368
|
type: MatchType.describe("Determines the type of field")
|
@@ -1397,22 +1416,30 @@ var FieldConfigSchema = BaseField3.extend({
|
|
1397
1416
|
fieldType: import_zod15.z.literal("field"),
|
1398
1417
|
alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
|
1399
1418
|
`Sometimes there might be need to search a value against multiple field of same FormField type. For example
|
1400
|
-
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
|
1401
1420
|
add a one field as fieldId, and accomodate others in alternateFieldIds`
|
1402
1421
|
),
|
1403
|
-
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1404
|
-
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
|
1405
1424
|
is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
|
1406
1425
|
related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
|
1407
1426
|
In such case, populate this field (excludeInSearchQuery) with boolean true`)
|
1408
1427
|
});
|
1409
|
-
var
|
1428
|
+
var EventFieldIdInput = import_zod15.z.enum([
|
1410
1429
|
"trackingId",
|
1411
1430
|
"status",
|
1412
1431
|
"legalStatuses.REGISTERED.acceptedAt",
|
1413
1432
|
"legalStatuses.REGISTERED.createdAtLocation",
|
1414
1433
|
"updatedAt"
|
1415
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
|
+
]);
|
1416
1443
|
var EventFieldConfigSchema = BaseField3.extend({
|
1417
1444
|
fieldId: EventFieldId,
|
1418
1445
|
fieldType: import_zod15.z.literal("event")
|
@@ -1885,10 +1912,6 @@ var ActionStatus = {
|
|
1885
1912
|
Accepted: "Accepted",
|
1886
1913
|
Rejected: "Rejected"
|
1887
1914
|
};
|
1888
|
-
var ActionDetails = import_zod19.z.object({
|
1889
|
-
templateId: import_zod19.z.string().optional(),
|
1890
|
-
isImmediateCorrection: import_zod19.z.boolean().optional()
|
1891
|
-
});
|
1892
1915
|
var ActionBase = import_zod19.z.object({
|
1893
1916
|
id: UUID,
|
1894
1917
|
transactionId: import_zod19.z.string(),
|
@@ -1900,7 +1923,6 @@ var ActionBase = import_zod19.z.object({
|
|
1900
1923
|
createdAtLocation: CreatedAtLocation,
|
1901
1924
|
declaration: ActionUpdate,
|
1902
1925
|
annotation: ActionUpdate.optional().nullable(),
|
1903
|
-
actionDetails: ActionDetails.optional().nullable(),
|
1904
1926
|
status: import_zod19.z.enum([
|
1905
1927
|
ActionStatus.Requested,
|
1906
1928
|
ActionStatus.Accepted,
|
@@ -1910,11 +1932,15 @@ var ActionBase = import_zod19.z.object({
|
|
1910
1932
|
originalActionId: UUID.optional().nullable().describe(
|
1911
1933
|
"Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
|
1912
1934
|
)
|
1935
|
+
// 'content' field reserved for additional data
|
1936
|
+
// Each action can define its own content specifc to the action
|
1937
|
+
// See PrintCertificateAction
|
1913
1938
|
});
|
1914
1939
|
var AssignedAction = ActionBase.merge(
|
1915
1940
|
import_zod19.z.object({
|
1916
1941
|
type: import_zod19.z.literal(ActionType.ASSIGN),
|
1917
1942
|
assignedTo: import_zod19.z.string()
|
1943
|
+
// TODO move into 'content' property
|
1918
1944
|
})
|
1919
1945
|
);
|
1920
1946
|
var UnassignedAction = ActionBase.merge(
|
@@ -1926,6 +1952,7 @@ var RegisterAction = ActionBase.merge(
|
|
1926
1952
|
import_zod19.z.object({
|
1927
1953
|
type: import_zod19.z.literal(ActionType.REGISTER),
|
1928
1954
|
registrationNumber: import_zod19.z.string().optional()
|
1955
|
+
// TODO move into 'content' property
|
1929
1956
|
})
|
1930
1957
|
);
|
1931
1958
|
var DeclareAction = ActionBase.merge(
|
@@ -1946,6 +1973,7 @@ var RejectAction = ActionBase.merge(
|
|
1946
1973
|
import_zod19.z.object({
|
1947
1974
|
type: import_zod19.z.literal(ActionType.REJECT),
|
1948
1975
|
reason: RejectionReason
|
1976
|
+
// TODO move into 'content' property
|
1949
1977
|
})
|
1950
1978
|
);
|
1951
1979
|
var MarkAsDuplicateAction = ActionBase.merge(
|
@@ -1957,6 +1985,7 @@ var ArchiveAction = ActionBase.merge(
|
|
1957
1985
|
import_zod19.z.object({
|
1958
1986
|
type: import_zod19.z.literal(ActionType.ARCHIVE),
|
1959
1987
|
reason: RejectionReason
|
1988
|
+
// TODO move into 'content' property
|
1960
1989
|
})
|
1961
1990
|
);
|
1962
1991
|
var CreatedAction = ActionBase.merge(
|
@@ -1969,9 +1998,13 @@ var NotifiedAction = ActionBase.merge(
|
|
1969
1998
|
type: import_zod19.z.literal(ActionType.NOTIFY)
|
1970
1999
|
})
|
1971
2000
|
);
|
2001
|
+
var PrintContent = import_zod19.z.object({
|
2002
|
+
templateId: import_zod19.z.string().optional()
|
2003
|
+
});
|
1972
2004
|
var PrintCertificateAction = ActionBase.merge(
|
1973
2005
|
import_zod19.z.object({
|
1974
|
-
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
|
2006
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
|
2007
|
+
content: PrintContent.optional().nullable()
|
1975
2008
|
})
|
1976
2009
|
);
|
1977
2010
|
var RequestedCorrectionAction = ActionBase.merge(
|
@@ -1983,12 +2016,14 @@ var ApprovedCorrectionAction = ActionBase.merge(
|
|
1983
2016
|
import_zod19.z.object({
|
1984
2017
|
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
|
1985
2018
|
requestId: import_zod19.z.string()
|
2019
|
+
// TODO move into 'content' property
|
1986
2020
|
})
|
1987
2021
|
);
|
1988
2022
|
var RejectedCorrectionAction = ActionBase.merge(
|
1989
2023
|
import_zod19.z.object({
|
1990
2024
|
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
|
1991
2025
|
requestId: import_zod19.z.string(),
|
2026
|
+
// TODO move into 'content' property
|
1992
2027
|
reason: RejectionReason
|
1993
2028
|
})
|
1994
2029
|
);
|
@@ -2430,6 +2465,23 @@ function validateFieldInput({
|
|
2430
2465
|
const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
|
2431
2466
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
2432
2467
|
}
|
2468
|
+
function runStructuralValidations({
|
2469
|
+
field: field2,
|
2470
|
+
values
|
2471
|
+
}) {
|
2472
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
2473
|
+
return {
|
2474
|
+
errors: []
|
2475
|
+
};
|
2476
|
+
}
|
2477
|
+
const fieldValidationResult = validateFieldInput({
|
2478
|
+
field: field2,
|
2479
|
+
value: values[field2.id]
|
2480
|
+
});
|
2481
|
+
return {
|
2482
|
+
errors: fieldValidationResult
|
2483
|
+
};
|
2484
|
+
}
|
2433
2485
|
function runFieldValidations({
|
2434
2486
|
field: field2,
|
2435
2487
|
values
|
@@ -2720,16 +2772,16 @@ function timePeriodToDateRange(value) {
|
|
2720
2772
|
let startDate;
|
2721
2773
|
switch (value) {
|
2722
2774
|
case "last7Days":
|
2723
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2775
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
|
2724
2776
|
break;
|
2725
2777
|
case "last30Days":
|
2726
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2778
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
|
2727
2779
|
break;
|
2728
2780
|
case "last90Days":
|
2729
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2781
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
|
2730
2782
|
break;
|
2731
2783
|
case "last365Days":
|
2732
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2784
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
|
2733
2785
|
break;
|
2734
2786
|
}
|
2735
2787
|
return {
|
@@ -3096,8 +3148,9 @@ function createFieldConditionals(fieldId) {
|
|
3096
3148
|
properties: {
|
3097
3149
|
[fieldId]: {
|
3098
3150
|
type: "string",
|
3099
|
-
|
3100
|
-
|
3151
|
+
minLength: 1,
|
3152
|
+
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'.-]*)*$",
|
3153
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
3101
3154
|
}
|
3102
3155
|
}
|
3103
3156
|
}),
|
@@ -3190,6 +3243,19 @@ function createSearchConfig(baseField) {
|
|
3190
3243
|
fuzzy: () => ({
|
3191
3244
|
...baseField,
|
3192
3245
|
config: { type: "fuzzy" }
|
3246
|
+
}),
|
3247
|
+
/**
|
3248
|
+
* Creates a configuration for matching locations and the child locations
|
3249
|
+
* @returns An object containing the field ID and a configuration object with a type of 'within'.
|
3250
|
+
* @example field('createdAtLocation').within()
|
3251
|
+
* // {
|
3252
|
+
* // ...
|
3253
|
+
* // config: { type: 'within' }
|
3254
|
+
* // }
|
3255
|
+
*/
|
3256
|
+
within: () => ({
|
3257
|
+
...baseField,
|
3258
|
+
config: { type: "within" }
|
3193
3259
|
})
|
3194
3260
|
};
|
3195
3261
|
}
|
@@ -3197,7 +3263,7 @@ function createSearchConfig(baseField) {
|
|
3197
3263
|
// ../commons/src/event-config/event-configuration.ts
|
3198
3264
|
function createEventFieldConfig(fieldId) {
|
3199
3265
|
const baseField = {
|
3200
|
-
fieldId
|
3266
|
+
fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
|
3201
3267
|
fieldType: "event"
|
3202
3268
|
};
|
3203
3269
|
return createSearchConfig(baseField);
|
@@ -3300,12 +3366,12 @@ var event = Object.assign(eventFn, {
|
|
3300
3366
|
withFields: (fields) => withMinMax(fields),
|
3301
3367
|
/**
|
3302
3368
|
* Adds template ID constraint to the action matching.
|
3303
|
-
* This is a convenience method that adds
|
3369
|
+
* This is a convenience method that adds content.templateId to the fields.
|
3304
3370
|
*
|
3305
3371
|
* @param id - The template ID to match against.
|
3306
3372
|
*/
|
3307
3373
|
withTemplate: (id) => withMinMax({
|
3308
|
-
|
3374
|
+
content: { templateId: id }
|
3309
3375
|
}),
|
3310
3376
|
...withMinMax()
|
3311
3377
|
};
|
@@ -3329,24 +3395,23 @@ var EventStatus = import_zod23.z.enum([
|
|
3329
3395
|
"DECLARED",
|
3330
3396
|
"VALIDATED",
|
3331
3397
|
"REGISTERED",
|
3332
|
-
"CERTIFIED",
|
3333
3398
|
"ARCHIVED"
|
3334
3399
|
]);
|
3335
|
-
var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
|
3336
3400
|
var InherentFlags = {
|
3337
|
-
|
3401
|
+
PENDING_CERTIFICATION: "pending-certification",
|
3338
3402
|
INCOMPLETE: "incomplete",
|
3339
3403
|
REJECTED: "rejected",
|
3340
3404
|
CORRECTION_REQUESTED: "correction-requested"
|
3341
3405
|
};
|
3342
|
-
var
|
3406
|
+
var ActionFlag = import_zod23.z.string().regex(
|
3343
3407
|
new RegExp(
|
3344
3408
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
3345
3409
|
ActionStatus
|
3346
3410
|
).join("|").toLowerCase()})$`
|
3347
3411
|
),
|
3348
3412
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3349
|
-
)
|
3413
|
+
);
|
3414
|
+
var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
|
3350
3415
|
var ZodDate = import_zod23.z.string().date();
|
3351
3416
|
var ActionCreationMetadata = import_zod23.z.object({
|
3352
3417
|
createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3395,9 +3460,7 @@ var EventMetadata = import_zod23.z.object({
|
|
3395
3460
|
trackingId: import_zod23.z.string().describe(
|
3396
3461
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
3397
3462
|
),
|
3398
|
-
flags: import_zod23.z.array(Flag)
|
3399
|
-
copiesPrintedForTemplate: import_zod23.z.number().optional(),
|
3400
|
-
modifiedAt: import_zod23.z.string().optional()
|
3463
|
+
flags: import_zod23.z.array(Flag)
|
3401
3464
|
});
|
3402
3465
|
var EventMetadataKeysArray = [
|
3403
3466
|
"id",
|
@@ -3616,6 +3679,9 @@ var QueryExpression = import_zod25.z.object({
|
|
3616
3679
|
createdAt: import_zod25.z.optional(DateCondition),
|
3617
3680
|
updatedAt: import_zod25.z.optional(DateCondition),
|
3618
3681
|
"legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
|
3682
|
+
"legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
|
3683
|
+
import_zod25.z.union([Within, Exact])
|
3684
|
+
),
|
3619
3685
|
"legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
|
3620
3686
|
import_zod25.z.union([Within, Exact])
|
3621
3687
|
),
|
@@ -3861,7 +3927,8 @@ var WorkqueueConfig = import_zod28.z.object({
|
|
3861
3927
|
})
|
3862
3928
|
),
|
3863
3929
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3864
|
-
icon: AvailableIcons
|
3930
|
+
icon: AvailableIcons,
|
3931
|
+
emptyMessage: TranslationConfig.optional()
|
3865
3932
|
}).describe("Configuration for workqueue.");
|
3866
3933
|
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3867
3934
|
query: true,
|
@@ -3880,7 +3947,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
|
|
3880
3947
|
})
|
3881
3948
|
),
|
3882
3949
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3883
|
-
icon: AvailableIcons
|
3950
|
+
icon: AvailableIcons,
|
3951
|
+
emptyMessage: TranslationConfig.optional()
|
3884
3952
|
});
|
3885
3953
|
function defineWorkqueue(workqueueInput) {
|
3886
3954
|
const queryInput = workqueueInput.query;
|
@@ -3927,7 +3995,6 @@ var BaseActionInput = import_zod29.z.object({
|
|
3927
3995
|
transactionId: import_zod29.z.string(),
|
3928
3996
|
declaration: ActionUpdate.default({}),
|
3929
3997
|
annotation: ActionUpdate.optional(),
|
3930
|
-
actionDetails: ActionDetails.optional(),
|
3931
3998
|
originalActionId: UUID.optional(),
|
3932
3999
|
// should not be part of base action.
|
3933
4000
|
keepAssignment: import_zod29.z.boolean().optional()
|
@@ -3970,7 +4037,8 @@ var DeclareActionInput = BaseActionInput.merge(
|
|
3970
4037
|
);
|
3971
4038
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
3972
4039
|
import_zod29.z.object({
|
3973
|
-
type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
4040
|
+
type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
|
4041
|
+
content: PrintContent.optional()
|
3974
4042
|
})
|
3975
4043
|
);
|
3976
4044
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
@@ -4182,16 +4250,19 @@ function getLegalStatuses(actions) {
|
|
4182
4250
|
}
|
4183
4251
|
|
4184
4252
|
// ../commons/src/events/state/flags.ts
|
4185
|
-
function
|
4253
|
+
function isPendingCertification(actions) {
|
4254
|
+
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
4255
|
+
return false;
|
4256
|
+
}
|
4186
4257
|
return actions.reduce((prev, { type }) => {
|
4187
4258
|
if (type === ActionType.PRINT_CERTIFICATE) {
|
4188
|
-
return
|
4259
|
+
return false;
|
4189
4260
|
}
|
4190
4261
|
if (type === ActionType.APPROVE_CORRECTION) {
|
4191
|
-
return
|
4262
|
+
return true;
|
4192
4263
|
}
|
4193
4264
|
return prev;
|
4194
|
-
},
|
4265
|
+
}, true);
|
4195
4266
|
}
|
4196
4267
|
function isCorrectionRequested(actions) {
|
4197
4268
|
return actions.reduce((prev, { type }) => {
|
@@ -4226,8 +4297,8 @@ function getFlagsFromActions(actions) {
|
|
4226
4297
|
const flag = joinValues([type, status], ":").toLowerCase();
|
4227
4298
|
return flag;
|
4228
4299
|
});
|
4229
|
-
if (
|
4230
|
-
flags.push(InherentFlags.
|
4300
|
+
if (isPendingCertification(sortedActions)) {
|
4301
|
+
flags.push(InherentFlags.PENDING_CERTIFICATION);
|
4231
4302
|
}
|
4232
4303
|
if (isCorrectionRequested(sortedActions)) {
|
4233
4304
|
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
@@ -4258,7 +4329,6 @@ function getStatusFromActions(actions) {
|
|
4258
4329
|
case ActionType.NOTIFY:
|
4259
4330
|
return EventStatus.enum.NOTIFIED;
|
4260
4331
|
case ActionType.PRINT_CERTIFICATE:
|
4261
|
-
return EventStatus.enum.CERTIFIED;
|
4262
4332
|
case ActionType.ASSIGN:
|
4263
4333
|
case ActionType.UNASSIGN:
|
4264
4334
|
case ActionType.REJECT:
|
@@ -4378,8 +4448,7 @@ function getCurrentEventState(event2, config) {
|
|
4378
4448
|
trackingId: event2.trackingId,
|
4379
4449
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
4380
4450
|
dateOfEvent: resolveDateOfEvent(event2, declaration, config),
|
4381
|
-
flags: getFlagsFromActions(event2.actions)
|
4382
|
-
copiesPrintedForTemplate: event2.copiesPrintedForTemplate ?? 0
|
4451
|
+
flags: getFlagsFromActions(event2.actions)
|
4383
4452
|
});
|
4384
4453
|
}
|
4385
4454
|
function getCurrentEventStateWithDrafts({
|
@@ -5224,7 +5293,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
5224
5293
|
defaultMessage: "Applicant's name",
|
5225
5294
|
description: "This is the label for the field",
|
5226
5295
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
5227
|
-
}
|
5296
|
+
},
|
5297
|
+
configuration: {
|
5298
|
+
name: {
|
5299
|
+
firstname: { required: true },
|
5300
|
+
middlename: { required: false },
|
5301
|
+
surname: { required: true }
|
5302
|
+
}
|
5303
|
+
},
|
5304
|
+
validation: [
|
5305
|
+
{
|
5306
|
+
validator: field("applicant.name").object({
|
5307
|
+
firstname: field("firstname").isValidEnglishName(),
|
5308
|
+
surname: field("surname").isValidEnglishName()
|
5309
|
+
}),
|
5310
|
+
message: {
|
5311
|
+
defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
|
5312
|
+
description: "This is the error message for invalid name",
|
5313
|
+
id: "v2.error.invalidName"
|
5314
|
+
}
|
5315
|
+
}
|
5316
|
+
]
|
5228
5317
|
},
|
5229
5318
|
{
|
5230
5319
|
id: "applicant.email",
|
@@ -5446,22 +5535,6 @@ var statusOptions = [
|
|
5446
5535
|
id: "v2.advancedSearch.form.recordStatusRegistered"
|
5447
5536
|
}
|
5448
5537
|
},
|
5449
|
-
{
|
5450
|
-
value: EventStatus.enum.CERTIFIED,
|
5451
|
-
label: {
|
5452
|
-
defaultMessage: "Certified",
|
5453
|
-
description: "Option for form field: status of record",
|
5454
|
-
id: "v2.advancedSearch.form.recordStatusCertified"
|
5455
|
-
}
|
5456
|
-
},
|
5457
|
-
{
|
5458
|
-
value: VisibleStatus.enum.REJECTED,
|
5459
|
-
label: {
|
5460
|
-
defaultMessage: "Rejected",
|
5461
|
-
description: "Option for form field: status of record",
|
5462
|
-
id: "v2.advancedSearch.form.recordStatusRejected"
|
5463
|
-
}
|
5464
|
-
},
|
5465
5538
|
{
|
5466
5539
|
value: EventStatus.enum.ARCHIVED,
|
5467
5540
|
label: {
|
@@ -6913,7 +6986,11 @@ function generateActionDocument({
|
|
6913
6986
|
case ActionType.NOTIFY:
|
6914
6987
|
return { ...actionBase, type: action };
|
6915
6988
|
case ActionType.PRINT_CERTIFICATE:
|
6916
|
-
return {
|
6989
|
+
return {
|
6990
|
+
...actionBase,
|
6991
|
+
type: action,
|
6992
|
+
content: defaults.content
|
6993
|
+
};
|
6917
6994
|
case ActionType.REQUEST_CORRECTION:
|
6918
6995
|
return { ...actionBase, type: action };
|
6919
6996
|
case ActionType.APPROVE_CORRECTION:
|
@@ -7058,8 +7135,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
7058
7135
|
flags: [],
|
7059
7136
|
legalStatuses: overrides.legalStatuses ?? {},
|
7060
7137
|
declaration: overrides.declaration ?? generateRandomApplicant(rng),
|
7061
|
-
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7062
|
-
copiesPrintedForTemplate: overrides.copiesPrintedForTemplate ?? 0
|
7138
|
+
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7063
7139
|
};
|
7064
7140
|
};
|
7065
7141
|
var generateTranslationConfig = (message) => ({
|
@@ -7314,14 +7390,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7314
7390
|
ActionType.REJECT_CORRECTION,
|
7315
7391
|
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7316
7392
|
],
|
7317
|
-
[EventStatus.enum.CERTIFIED]: [
|
7318
|
-
ActionType.READ,
|
7319
|
-
ActionType.PRINT_CERTIFICATE,
|
7320
|
-
ActionType.REQUEST_CORRECTION,
|
7321
|
-
ActionType.APPROVE_CORRECTION,
|
7322
|
-
ActionType.REJECT_CORRECTION,
|
7323
|
-
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7324
|
-
],
|
7325
7393
|
[EventStatus.enum.ARCHIVED]: [
|
7326
7394
|
ActionType.READ,
|
7327
7395
|
ActionType.ASSIGN,
|
@@ -7329,9 +7397,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7329
7397
|
]
|
7330
7398
|
};
|
7331
7399
|
var getAvailableActionsForEvent = (event2) => {
|
7332
|
-
|
7333
|
-
|
7334
|
-
|
7335
|
-
|
7336
|
-
|
7400
|
+
if (event2.flags.includes(InherentFlags.REJECTED)) {
|
7401
|
+
return [
|
7402
|
+
ActionType.READ,
|
7403
|
+
event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
|
7404
|
+
ActionType.ARCHIVE
|
7405
|
+
];
|
7406
|
+
}
|
7407
|
+
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
|
7337
7408
|
};
|
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
|
}
|