@opencrvs/toolkit 1.8.1-rc.7e34683 → 1.8.1-rc.829977e
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 +433 -796
- 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 +1302 -1389
- package/dist/commons/events/ActionInput.d.ts +658 -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 +475 -846
- package/dist/commons/events/EventIndex.d.ts +184 -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 +288 -164
- package/dist/commons/events/defineConfig.d.ts +129 -30
- package/dist/commons/events/event.d.ts +13 -5
- package/dist/commons/events/field.d.ts +14 -0
- package/dist/commons/events/test.utils.d.ts +17 -13
- package/dist/commons/events/utils.d.ts +236 -64
- package/dist/conditionals/index.js +3 -2
- package/dist/events/index.js +152 -77
- 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,
|
@@ -321,6 +325,7 @@ __export(events_exports, {
|
|
321
325
|
or: () => or,
|
322
326
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
323
327
|
runFieldValidations: () => runFieldValidations,
|
328
|
+
runStructuralValidations: () => runStructuralValidations,
|
324
329
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
325
330
|
user: () => user,
|
326
331
|
validate: () => validate,
|
@@ -555,7 +560,7 @@ var import_zod6 = require("zod");
|
|
555
560
|
var import_zod4 = require("zod");
|
556
561
|
var import_zod_openapi3 = require("zod-openapi");
|
557
562
|
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
|
558
|
-
var
|
563
|
+
var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
|
559
564
|
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
|
560
565
|
);
|
561
566
|
var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
|
@@ -612,8 +617,8 @@ var NameFieldValue = import_zod5.z.object({
|
|
612
617
|
middlename: import_zod5.z.string().optional()
|
613
618
|
});
|
614
619
|
var NameFieldUpdateValue = import_zod5.z.object({
|
615
|
-
firstname: import_zod5.z.string()
|
616
|
-
surname: import_zod5.z.string()
|
620
|
+
firstname: import_zod5.z.string(),
|
621
|
+
surname: import_zod5.z.string(),
|
617
622
|
middlename: import_zod5.z.string().nullish()
|
618
623
|
}).or(import_zod5.z.null()).or(import_zod5.z.undefined());
|
619
624
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
@@ -910,18 +915,32 @@ var SelectDateRangeField = BaseField.extend({
|
|
910
915
|
defaultValue: SelectDateRangeValue.optional(),
|
911
916
|
options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
|
912
917
|
}).describe("Select input with date range options");
|
918
|
+
var NameConfig = import_zod7.z.object({
|
919
|
+
firstname: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional(),
|
920
|
+
middlename: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional(),
|
921
|
+
surname: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional()
|
922
|
+
});
|
913
923
|
var NameField = BaseField.extend({
|
914
924
|
type: import_zod7.z.literal(FieldType.NAME),
|
915
925
|
defaultValue: import_zod7.z.object({
|
916
|
-
firstname: NonEmptyTextValue,
|
917
|
-
|
926
|
+
firstname: NonEmptyTextValue.optional(),
|
927
|
+
middlename: NonEmptyTextValue.optional(),
|
928
|
+
surname: NonEmptyTextValue.optional()
|
918
929
|
}).optional(),
|
919
930
|
configuration: import_zod7.z.object({
|
931
|
+
name: NameConfig.default({
|
932
|
+
firstname: { required: true },
|
933
|
+
surname: { required: true }
|
934
|
+
}).optional(),
|
920
935
|
maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
|
921
936
|
prefix: TranslationConfig.optional(),
|
922
937
|
postfix: TranslationConfig.optional(),
|
923
|
-
includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
|
924
938
|
searchMode: import_zod7.z.boolean().optional()
|
939
|
+
}).default({
|
940
|
+
name: {
|
941
|
+
firstname: { required: true },
|
942
|
+
surname: { required: true }
|
943
|
+
}
|
925
944
|
}).optional()
|
926
945
|
}).describe("Name input field");
|
927
946
|
var PhoneField = BaseField.extend({
|
@@ -1341,7 +1360,7 @@ var SummaryConfig = import_zod14.z.object({
|
|
1341
1360
|
|
1342
1361
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1343
1362
|
var import_zod15 = require("zod");
|
1344
|
-
var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
|
1363
|
+
var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
|
1345
1364
|
var BaseField3 = import_zod15.z.object({
|
1346
1365
|
config: import_zod15.z.object({
|
1347
1366
|
type: MatchType.describe("Determines the type of field")
|
@@ -1395,22 +1414,30 @@ var FieldConfigSchema = BaseField3.extend({
|
|
1395
1414
|
fieldType: import_zod15.z.literal("field"),
|
1396
1415
|
alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
|
1397
1416
|
`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
|
1417
|
+
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1399
1418
|
add a one field as fieldId, and accomodate others in alternateFieldIds`
|
1400
1419
|
),
|
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
|
1420
|
+
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1421
|
+
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1403
1422
|
is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
|
1404
1423
|
related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
|
1405
1424
|
In such case, populate this field (excludeInSearchQuery) with boolean true`)
|
1406
1425
|
});
|
1407
|
-
var
|
1426
|
+
var EventFieldIdInput = import_zod15.z.enum([
|
1408
1427
|
"trackingId",
|
1409
1428
|
"status",
|
1410
1429
|
"legalStatuses.REGISTERED.acceptedAt",
|
1411
1430
|
"legalStatuses.REGISTERED.createdAtLocation",
|
1412
1431
|
"updatedAt"
|
1413
1432
|
]);
|
1433
|
+
var METADATA_FIELD_PREFIX = "event.";
|
1434
|
+
var EventFieldId = import_zod15.z.enum([
|
1435
|
+
`${METADATA_FIELD_PREFIX}trackingId`,
|
1436
|
+
`${METADATA_FIELD_PREFIX}status`,
|
1437
|
+
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
|
1438
|
+
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.createdAtLocation`,
|
1439
|
+
`${METADATA_FIELD_PREFIX}updatedAt`
|
1440
|
+
]);
|
1414
1441
|
var EventFieldConfigSchema = BaseField3.extend({
|
1415
1442
|
fieldId: EventFieldId,
|
1416
1443
|
fieldType: import_zod15.z.literal("event")
|
@@ -1883,10 +1910,6 @@ var ActionStatus = {
|
|
1883
1910
|
Accepted: "Accepted",
|
1884
1911
|
Rejected: "Rejected"
|
1885
1912
|
};
|
1886
|
-
var ActionDetails = import_zod19.z.object({
|
1887
|
-
templateId: import_zod19.z.string().optional(),
|
1888
|
-
isImmediateCorrection: import_zod19.z.boolean().optional()
|
1889
|
-
});
|
1890
1913
|
var ActionBase = import_zod19.z.object({
|
1891
1914
|
id: UUID,
|
1892
1915
|
transactionId: import_zod19.z.string(),
|
@@ -1898,7 +1921,6 @@ var ActionBase = import_zod19.z.object({
|
|
1898
1921
|
createdAtLocation: CreatedAtLocation,
|
1899
1922
|
declaration: ActionUpdate,
|
1900
1923
|
annotation: ActionUpdate.optional().nullable(),
|
1901
|
-
actionDetails: ActionDetails.optional().nullable(),
|
1902
1924
|
status: import_zod19.z.enum([
|
1903
1925
|
ActionStatus.Requested,
|
1904
1926
|
ActionStatus.Accepted,
|
@@ -1908,11 +1930,15 @@ var ActionBase = import_zod19.z.object({
|
|
1908
1930
|
originalActionId: UUID.optional().nullable().describe(
|
1909
1931
|
"Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
|
1910
1932
|
)
|
1933
|
+
// 'content' field reserved for additional data
|
1934
|
+
// Each action can define its own content specifc to the action
|
1935
|
+
// See PrintCertificateAction
|
1911
1936
|
});
|
1912
1937
|
var AssignedAction = ActionBase.merge(
|
1913
1938
|
import_zod19.z.object({
|
1914
1939
|
type: import_zod19.z.literal(ActionType.ASSIGN),
|
1915
1940
|
assignedTo: import_zod19.z.string()
|
1941
|
+
// TODO move into 'content' property
|
1916
1942
|
})
|
1917
1943
|
);
|
1918
1944
|
var UnassignedAction = ActionBase.merge(
|
@@ -1924,6 +1950,7 @@ var RegisterAction = ActionBase.merge(
|
|
1924
1950
|
import_zod19.z.object({
|
1925
1951
|
type: import_zod19.z.literal(ActionType.REGISTER),
|
1926
1952
|
registrationNumber: import_zod19.z.string().optional()
|
1953
|
+
// TODO move into 'content' property
|
1927
1954
|
})
|
1928
1955
|
);
|
1929
1956
|
var DeclareAction = ActionBase.merge(
|
@@ -1944,6 +1971,7 @@ var RejectAction = ActionBase.merge(
|
|
1944
1971
|
import_zod19.z.object({
|
1945
1972
|
type: import_zod19.z.literal(ActionType.REJECT),
|
1946
1973
|
reason: RejectionReason
|
1974
|
+
// TODO move into 'content' property
|
1947
1975
|
})
|
1948
1976
|
);
|
1949
1977
|
var MarkAsDuplicateAction = ActionBase.merge(
|
@@ -1955,6 +1983,7 @@ var ArchiveAction = ActionBase.merge(
|
|
1955
1983
|
import_zod19.z.object({
|
1956
1984
|
type: import_zod19.z.literal(ActionType.ARCHIVE),
|
1957
1985
|
reason: RejectionReason
|
1986
|
+
// TODO move into 'content' property
|
1958
1987
|
})
|
1959
1988
|
);
|
1960
1989
|
var CreatedAction = ActionBase.merge(
|
@@ -1967,9 +1996,13 @@ var NotifiedAction = ActionBase.merge(
|
|
1967
1996
|
type: import_zod19.z.literal(ActionType.NOTIFY)
|
1968
1997
|
})
|
1969
1998
|
);
|
1999
|
+
var PrintContent = import_zod19.z.object({
|
2000
|
+
templateId: import_zod19.z.string().optional()
|
2001
|
+
});
|
1970
2002
|
var PrintCertificateAction = ActionBase.merge(
|
1971
2003
|
import_zod19.z.object({
|
1972
|
-
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
|
2004
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
|
2005
|
+
content: PrintContent.optional().nullable()
|
1973
2006
|
})
|
1974
2007
|
);
|
1975
2008
|
var RequestedCorrectionAction = ActionBase.merge(
|
@@ -1981,12 +2014,15 @@ var ApprovedCorrectionAction = ActionBase.merge(
|
|
1981
2014
|
import_zod19.z.object({
|
1982
2015
|
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
|
1983
2016
|
requestId: import_zod19.z.string()
|
2017
|
+
// TODO move into 'content' property
|
1984
2018
|
})
|
1985
2019
|
);
|
1986
2020
|
var RejectedCorrectionAction = ActionBase.merge(
|
1987
2021
|
import_zod19.z.object({
|
1988
2022
|
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
|
1989
|
-
requestId: import_zod19.z.string()
|
2023
|
+
requestId: import_zod19.z.string(),
|
2024
|
+
// TODO move into 'content' property
|
2025
|
+
reason: RejectionReason
|
1990
2026
|
})
|
1991
2027
|
);
|
1992
2028
|
var ReadAction = ActionBase.merge(
|
@@ -2425,6 +2461,23 @@ function validateFieldInput({
|
|
2425
2461
|
const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
|
2426
2462
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
2427
2463
|
}
|
2464
|
+
function runStructuralValidations({
|
2465
|
+
field: field2,
|
2466
|
+
values
|
2467
|
+
}) {
|
2468
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
2469
|
+
return {
|
2470
|
+
errors: []
|
2471
|
+
};
|
2472
|
+
}
|
2473
|
+
const fieldValidationResult = validateFieldInput({
|
2474
|
+
field: field2,
|
2475
|
+
value: values[field2.id]
|
2476
|
+
});
|
2477
|
+
return {
|
2478
|
+
errors: fieldValidationResult
|
2479
|
+
};
|
2480
|
+
}
|
2428
2481
|
function runFieldValidations({
|
2429
2482
|
field: field2,
|
2430
2483
|
values
|
@@ -2710,16 +2763,16 @@ function timePeriodToDateRange(value) {
|
|
2710
2763
|
let startDate;
|
2711
2764
|
switch (value) {
|
2712
2765
|
case "last7Days":
|
2713
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2766
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
|
2714
2767
|
break;
|
2715
2768
|
case "last30Days":
|
2716
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2769
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
|
2717
2770
|
break;
|
2718
2771
|
case "last90Days":
|
2719
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2772
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
|
2720
2773
|
break;
|
2721
2774
|
case "last365Days":
|
2722
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2775
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
|
2723
2776
|
break;
|
2724
2777
|
}
|
2725
2778
|
return {
|
@@ -3086,8 +3139,9 @@ function createFieldConditionals(fieldId) {
|
|
3086
3139
|
properties: {
|
3087
3140
|
[fieldId]: {
|
3088
3141
|
type: "string",
|
3089
|
-
|
3090
|
-
|
3142
|
+
minLength: 1,
|
3143
|
+
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'.-]*)*$",
|
3144
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
3091
3145
|
}
|
3092
3146
|
}
|
3093
3147
|
}),
|
@@ -3180,6 +3234,19 @@ function createSearchConfig(baseField) {
|
|
3180
3234
|
fuzzy: () => ({
|
3181
3235
|
...baseField,
|
3182
3236
|
config: { type: "fuzzy" }
|
3237
|
+
}),
|
3238
|
+
/**
|
3239
|
+
* Creates a configuration for matching locations and the child locations
|
3240
|
+
* @returns An object containing the field ID and a configuration object with a type of 'within'.
|
3241
|
+
* @example field('createdAtLocation').within()
|
3242
|
+
* // {
|
3243
|
+
* // ...
|
3244
|
+
* // config: { type: 'within' }
|
3245
|
+
* // }
|
3246
|
+
*/
|
3247
|
+
within: () => ({
|
3248
|
+
...baseField,
|
3249
|
+
config: { type: "within" }
|
3183
3250
|
})
|
3184
3251
|
};
|
3185
3252
|
}
|
@@ -3187,7 +3254,7 @@ function createSearchConfig(baseField) {
|
|
3187
3254
|
// ../commons/src/event-config/event-configuration.ts
|
3188
3255
|
function createEventFieldConfig(fieldId) {
|
3189
3256
|
const baseField = {
|
3190
|
-
fieldId
|
3257
|
+
fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
|
3191
3258
|
fieldType: "event"
|
3192
3259
|
};
|
3193
3260
|
return createSearchConfig(baseField);
|
@@ -3244,24 +3311,23 @@ var EventStatus = import_zod23.z.enum([
|
|
3244
3311
|
"DECLARED",
|
3245
3312
|
"VALIDATED",
|
3246
3313
|
"REGISTERED",
|
3247
|
-
"CERTIFIED",
|
3248
3314
|
"ARCHIVED"
|
3249
3315
|
]);
|
3250
|
-
var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
|
3251
3316
|
var InherentFlags = {
|
3252
|
-
|
3317
|
+
PENDING_CERTIFICATION: "pending-certification",
|
3253
3318
|
INCOMPLETE: "incomplete",
|
3254
3319
|
REJECTED: "rejected",
|
3255
3320
|
CORRECTION_REQUESTED: "correction-requested"
|
3256
3321
|
};
|
3257
|
-
var
|
3322
|
+
var ActionFlag = import_zod23.z.string().regex(
|
3258
3323
|
new RegExp(
|
3259
3324
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
3260
3325
|
ActionStatus
|
3261
3326
|
).join("|").toLowerCase()})$`
|
3262
3327
|
),
|
3263
3328
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3264
|
-
)
|
3329
|
+
);
|
3330
|
+
var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
|
3265
3331
|
var ZodDate = import_zod23.z.string().date();
|
3266
3332
|
var ActionCreationMetadata = import_zod23.z.object({
|
3267
3333
|
createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3529,6 +3595,9 @@ var QueryExpression = import_zod25.z.object({
|
|
3529
3595
|
createdAt: import_zod25.z.optional(DateCondition),
|
3530
3596
|
updatedAt: import_zod25.z.optional(DateCondition),
|
3531
3597
|
"legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
|
3598
|
+
"legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
|
3599
|
+
import_zod25.z.union([Within, Exact])
|
3600
|
+
),
|
3532
3601
|
"legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
|
3533
3602
|
import_zod25.z.union([Within, Exact])
|
3534
3603
|
),
|
@@ -3774,7 +3843,8 @@ var WorkqueueConfig = import_zod28.z.object({
|
|
3774
3843
|
})
|
3775
3844
|
),
|
3776
3845
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3777
|
-
icon: AvailableIcons
|
3846
|
+
icon: AvailableIcons,
|
3847
|
+
emptyMessage: TranslationConfig.optional()
|
3778
3848
|
}).describe("Configuration for workqueue.");
|
3779
3849
|
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3780
3850
|
query: true,
|
@@ -3793,7 +3863,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
|
|
3793
3863
|
})
|
3794
3864
|
),
|
3795
3865
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3796
|
-
icon: AvailableIcons
|
3866
|
+
icon: AvailableIcons,
|
3867
|
+
emptyMessage: TranslationConfig.optional()
|
3797
3868
|
});
|
3798
3869
|
function defineWorkqueue(workqueueInput) {
|
3799
3870
|
const queryInput = workqueueInput.query;
|
@@ -3840,7 +3911,6 @@ var BaseActionInput = import_zod29.z.object({
|
|
3840
3911
|
transactionId: import_zod29.z.string(),
|
3841
3912
|
declaration: ActionUpdate.default({}),
|
3842
3913
|
annotation: ActionUpdate.optional(),
|
3843
|
-
actionDetails: ActionDetails.optional(),
|
3844
3914
|
originalActionId: UUID.optional(),
|
3845
3915
|
// should not be part of base action.
|
3846
3916
|
keepAssignment: import_zod29.z.boolean().optional()
|
@@ -3883,7 +3953,8 @@ var DeclareActionInput = BaseActionInput.merge(
|
|
3883
3953
|
);
|
3884
3954
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
3885
3955
|
import_zod29.z.object({
|
3886
|
-
type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
3956
|
+
type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
|
3957
|
+
content: PrintContent.optional()
|
3887
3958
|
})
|
3888
3959
|
);
|
3889
3960
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
@@ -3923,7 +3994,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
|
|
3923
3994
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
3924
3995
|
import_zod29.z.object({
|
3925
3996
|
requestId: import_zod29.z.string(),
|
3926
|
-
type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
3997
|
+
type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
|
3998
|
+
reason: RejectionReason
|
3927
3999
|
})
|
3928
4000
|
);
|
3929
4001
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
@@ -4094,16 +4166,19 @@ function getLegalStatuses(actions) {
|
|
4094
4166
|
}
|
4095
4167
|
|
4096
4168
|
// ../commons/src/events/state/flags.ts
|
4097
|
-
function
|
4169
|
+
function isPendingCertification(actions) {
|
4170
|
+
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
4171
|
+
return false;
|
4172
|
+
}
|
4098
4173
|
return actions.reduce((prev, { type }) => {
|
4099
4174
|
if (type === ActionType.PRINT_CERTIFICATE) {
|
4100
|
-
return
|
4175
|
+
return false;
|
4101
4176
|
}
|
4102
4177
|
if (type === ActionType.APPROVE_CORRECTION) {
|
4103
|
-
return
|
4178
|
+
return true;
|
4104
4179
|
}
|
4105
4180
|
return prev;
|
4106
|
-
},
|
4181
|
+
}, true);
|
4107
4182
|
}
|
4108
4183
|
function isCorrectionRequested(actions) {
|
4109
4184
|
return actions.reduce((prev, { type }) => {
|
@@ -4138,8 +4213,8 @@ function getFlagsFromActions(actions) {
|
|
4138
4213
|
const flag = joinValues([type, status], ":").toLowerCase();
|
4139
4214
|
return flag;
|
4140
4215
|
});
|
4141
|
-
if (
|
4142
|
-
flags.push(InherentFlags.
|
4216
|
+
if (isPendingCertification(sortedActions)) {
|
4217
|
+
flags.push(InherentFlags.PENDING_CERTIFICATION);
|
4143
4218
|
}
|
4144
4219
|
if (isCorrectionRequested(sortedActions)) {
|
4145
4220
|
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
@@ -4170,7 +4245,6 @@ function getStatusFromActions(actions) {
|
|
4170
4245
|
case ActionType.NOTIFY:
|
4171
4246
|
return EventStatus.enum.NOTIFIED;
|
4172
4247
|
case ActionType.PRINT_CERTIFICATE:
|
4173
|
-
return EventStatus.enum.CERTIFIED;
|
4174
4248
|
case ActionType.ASSIGN:
|
4175
4249
|
case ActionType.UNASSIGN:
|
4176
4250
|
case ActionType.REJECT:
|
@@ -5135,7 +5209,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
5135
5209
|
defaultMessage: "Applicant's name",
|
5136
5210
|
description: "This is the label for the field",
|
5137
5211
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
5138
|
-
}
|
5212
|
+
},
|
5213
|
+
configuration: {
|
5214
|
+
name: {
|
5215
|
+
firstname: { required: true },
|
5216
|
+
middlename: { required: false },
|
5217
|
+
surname: { required: true }
|
5218
|
+
}
|
5219
|
+
},
|
5220
|
+
validation: [
|
5221
|
+
{
|
5222
|
+
validator: field("applicant.name").object({
|
5223
|
+
firstname: field("firstname").isValidEnglishName(),
|
5224
|
+
surname: field("surname").isValidEnglishName()
|
5225
|
+
}),
|
5226
|
+
message: {
|
5227
|
+
defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
|
5228
|
+
description: "This is the error message for invalid name",
|
5229
|
+
id: "v2.error.invalidName"
|
5230
|
+
}
|
5231
|
+
}
|
5232
|
+
]
|
5139
5233
|
},
|
5140
5234
|
{
|
5141
5235
|
id: "applicant.email",
|
@@ -5357,22 +5451,6 @@ var statusOptions = [
|
|
5357
5451
|
id: "v2.advancedSearch.form.recordStatusRegistered"
|
5358
5452
|
}
|
5359
5453
|
},
|
5360
|
-
{
|
5361
|
-
value: EventStatus.enum.CERTIFIED,
|
5362
|
-
label: {
|
5363
|
-
defaultMessage: "Certified",
|
5364
|
-
description: "Option for form field: status of record",
|
5365
|
-
id: "v2.advancedSearch.form.recordStatusCertified"
|
5366
|
-
}
|
5367
|
-
},
|
5368
|
-
{
|
5369
|
-
value: VisibleStatus.enum.REJECTED,
|
5370
|
-
label: {
|
5371
|
-
defaultMessage: "Rejected",
|
5372
|
-
description: "Option for form field: status of record",
|
5373
|
-
id: "v2.advancedSearch.form.recordStatusRejected"
|
5374
|
-
}
|
5375
|
-
},
|
5376
5454
|
{
|
5377
5455
|
value: EventStatus.enum.ARCHIVED,
|
5378
5456
|
label: {
|
@@ -6762,7 +6840,7 @@ function eventPayloadGenerator(rng) {
|
|
6762
6840
|
requestId,
|
6763
6841
|
keepAssignment: input.keepAssignment
|
6764
6842
|
}),
|
6765
|
-
reject: (eventId, requestId, input
|
6843
|
+
reject: (eventId, requestId, input) => ({
|
6766
6844
|
type: ActionType.REJECT_CORRECTION,
|
6767
6845
|
transactionId: input.transactionId ?? getUUID(),
|
6768
6846
|
declaration: {},
|
@@ -6773,7 +6851,8 @@ function eventPayloadGenerator(rng) {
|
|
6773
6851
|
),
|
6774
6852
|
eventId,
|
6775
6853
|
requestId,
|
6776
|
-
keepAssignment: input.keepAssignment
|
6854
|
+
keepAssignment: input.keepAssignment,
|
6855
|
+
reason: input.reason ?? { message: "" }
|
6777
6856
|
})
|
6778
6857
|
}
|
6779
6858
|
}
|
@@ -6832,7 +6911,8 @@ function generateActionDocument({
|
|
6832
6911
|
return {
|
6833
6912
|
...actionBase,
|
6834
6913
|
requestId: getUUID(),
|
6835
|
-
type: action
|
6914
|
+
type: action,
|
6915
|
+
reason: { message: "Correction rejection" }
|
6836
6916
|
};
|
6837
6917
|
case ActionType.REGISTER:
|
6838
6918
|
return {
|
@@ -7222,14 +7302,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7222
7302
|
ActionType.REJECT_CORRECTION,
|
7223
7303
|
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7224
7304
|
],
|
7225
|
-
[EventStatus.enum.CERTIFIED]: [
|
7226
|
-
ActionType.READ,
|
7227
|
-
ActionType.PRINT_CERTIFICATE,
|
7228
|
-
ActionType.REQUEST_CORRECTION,
|
7229
|
-
ActionType.APPROVE_CORRECTION,
|
7230
|
-
ActionType.REJECT_CORRECTION,
|
7231
|
-
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7232
|
-
],
|
7233
7305
|
[EventStatus.enum.ARCHIVED]: [
|
7234
7306
|
ActionType.READ,
|
7235
7307
|
ActionType.ASSIGN,
|
@@ -7237,9 +7309,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7237
7309
|
]
|
7238
7310
|
};
|
7239
7311
|
var getAvailableActionsForEvent = (event2) => {
|
7240
|
-
|
7241
|
-
|
7242
|
-
|
7243
|
-
|
7244
|
-
|
7312
|
+
if (event2.flags.includes(InherentFlags.REJECTED)) {
|
7313
|
+
return [
|
7314
|
+
ActionType.READ,
|
7315
|
+
event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
|
7316
|
+
ActionType.ARCHIVE
|
7317
|
+
];
|
7318
|
+
}
|
7319
|
+
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
|
7245
7320
|
};
|
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
|
}
|