@opencrvs/toolkit 1.8.1-rc.bbbfede → 1.8.1-rc.bbdfdc1
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/build.sh +5 -0
- package/dist/commons/api/router.d.ts +433 -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 +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 -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 +17 -13
- package/dist/commons/events/utils.d.ts +236 -64
- package/dist/commons/notification/UserNotifications.d.ts +547 -0
- package/dist/commons/notification/index.d.ts +2 -0
- package/dist/conditionals/index.js +3 -2
- package/dist/events/index.js +162 -87
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js +5362 -0
- package/package.json +3 -2
- package/tsconfig.json +3 -2
- package/tsconfig.tsbuildinfo +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,15 @@ 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
|
-
requestId: import_zod19.z.string()
|
2025
|
+
requestId: import_zod19.z.string(),
|
2026
|
+
// TODO move into 'content' property
|
2027
|
+
reason: RejectionReason
|
1992
2028
|
})
|
1993
2029
|
);
|
1994
2030
|
var ReadAction = ActionBase.merge(
|
@@ -2429,6 +2465,23 @@ function validateFieldInput({
|
|
2429
2465
|
const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
|
2430
2466
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
2431
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
|
+
}
|
2432
2485
|
function runFieldValidations({
|
2433
2486
|
field: field2,
|
2434
2487
|
values
|
@@ -2719,16 +2772,16 @@ function timePeriodToDateRange(value) {
|
|
2719
2772
|
let startDate;
|
2720
2773
|
switch (value) {
|
2721
2774
|
case "last7Days":
|
2722
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2775
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
|
2723
2776
|
break;
|
2724
2777
|
case "last30Days":
|
2725
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2778
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
|
2726
2779
|
break;
|
2727
2780
|
case "last90Days":
|
2728
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2781
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
|
2729
2782
|
break;
|
2730
2783
|
case "last365Days":
|
2731
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2784
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
|
2732
2785
|
break;
|
2733
2786
|
}
|
2734
2787
|
return {
|
@@ -3095,8 +3148,9 @@ function createFieldConditionals(fieldId) {
|
|
3095
3148
|
properties: {
|
3096
3149
|
[fieldId]: {
|
3097
3150
|
type: "string",
|
3098
|
-
|
3099
|
-
|
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."
|
3100
3154
|
}
|
3101
3155
|
}
|
3102
3156
|
}),
|
@@ -3189,6 +3243,19 @@ function createSearchConfig(baseField) {
|
|
3189
3243
|
fuzzy: () => ({
|
3190
3244
|
...baseField,
|
3191
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" }
|
3192
3259
|
})
|
3193
3260
|
};
|
3194
3261
|
}
|
@@ -3196,7 +3263,7 @@ function createSearchConfig(baseField) {
|
|
3196
3263
|
// ../commons/src/event-config/event-configuration.ts
|
3197
3264
|
function createEventFieldConfig(fieldId) {
|
3198
3265
|
const baseField = {
|
3199
|
-
fieldId
|
3266
|
+
fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
|
3200
3267
|
fieldType: "event"
|
3201
3268
|
};
|
3202
3269
|
return createSearchConfig(baseField);
|
@@ -3299,12 +3366,12 @@ var event = Object.assign(eventFn, {
|
|
3299
3366
|
withFields: (fields) => withMinMax(fields),
|
3300
3367
|
/**
|
3301
3368
|
* Adds template ID constraint to the action matching.
|
3302
|
-
* This is a convenience method that adds
|
3369
|
+
* This is a convenience method that adds content.templateId to the fields.
|
3303
3370
|
*
|
3304
3371
|
* @param id - The template ID to match against.
|
3305
3372
|
*/
|
3306
3373
|
withTemplate: (id) => withMinMax({
|
3307
|
-
|
3374
|
+
content: { templateId: id }
|
3308
3375
|
}),
|
3309
3376
|
...withMinMax()
|
3310
3377
|
};
|
@@ -3328,24 +3395,23 @@ var EventStatus = import_zod23.z.enum([
|
|
3328
3395
|
"DECLARED",
|
3329
3396
|
"VALIDATED",
|
3330
3397
|
"REGISTERED",
|
3331
|
-
"CERTIFIED",
|
3332
3398
|
"ARCHIVED"
|
3333
3399
|
]);
|
3334
|
-
var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
|
3335
3400
|
var InherentFlags = {
|
3336
|
-
|
3401
|
+
PENDING_CERTIFICATION: "pending-certification",
|
3337
3402
|
INCOMPLETE: "incomplete",
|
3338
3403
|
REJECTED: "rejected",
|
3339
3404
|
CORRECTION_REQUESTED: "correction-requested"
|
3340
3405
|
};
|
3341
|
-
var
|
3406
|
+
var ActionFlag = import_zod23.z.string().regex(
|
3342
3407
|
new RegExp(
|
3343
3408
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
3344
3409
|
ActionStatus
|
3345
3410
|
).join("|").toLowerCase()})$`
|
3346
3411
|
),
|
3347
3412
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3348
|
-
)
|
3413
|
+
);
|
3414
|
+
var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
|
3349
3415
|
var ZodDate = import_zod23.z.string().date();
|
3350
3416
|
var ActionCreationMetadata = import_zod23.z.object({
|
3351
3417
|
createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3394,9 +3460,7 @@ var EventMetadata = import_zod23.z.object({
|
|
3394
3460
|
trackingId: import_zod23.z.string().describe(
|
3395
3461
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
3396
3462
|
),
|
3397
|
-
flags: import_zod23.z.array(Flag)
|
3398
|
-
copiesPrintedForTemplate: import_zod23.z.number().optional(),
|
3399
|
-
modifiedAt: import_zod23.z.string().optional()
|
3463
|
+
flags: import_zod23.z.array(Flag)
|
3400
3464
|
});
|
3401
3465
|
var EventMetadataKeysArray = [
|
3402
3466
|
"id",
|
@@ -3615,6 +3679,9 @@ var QueryExpression = import_zod25.z.object({
|
|
3615
3679
|
createdAt: import_zod25.z.optional(DateCondition),
|
3616
3680
|
updatedAt: import_zod25.z.optional(DateCondition),
|
3617
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
|
+
),
|
3618
3685
|
"legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
|
3619
3686
|
import_zod25.z.union([Within, Exact])
|
3620
3687
|
),
|
@@ -3860,7 +3927,8 @@ var WorkqueueConfig = import_zod28.z.object({
|
|
3860
3927
|
})
|
3861
3928
|
),
|
3862
3929
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3863
|
-
icon: AvailableIcons
|
3930
|
+
icon: AvailableIcons,
|
3931
|
+
emptyMessage: TranslationConfig.optional()
|
3864
3932
|
}).describe("Configuration for workqueue.");
|
3865
3933
|
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3866
3934
|
query: true,
|
@@ -3879,7 +3947,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
|
|
3879
3947
|
})
|
3880
3948
|
),
|
3881
3949
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3882
|
-
icon: AvailableIcons
|
3950
|
+
icon: AvailableIcons,
|
3951
|
+
emptyMessage: TranslationConfig.optional()
|
3883
3952
|
});
|
3884
3953
|
function defineWorkqueue(workqueueInput) {
|
3885
3954
|
const queryInput = workqueueInput.query;
|
@@ -3926,7 +3995,6 @@ var BaseActionInput = import_zod29.z.object({
|
|
3926
3995
|
transactionId: import_zod29.z.string(),
|
3927
3996
|
declaration: ActionUpdate.default({}),
|
3928
3997
|
annotation: ActionUpdate.optional(),
|
3929
|
-
actionDetails: ActionDetails.optional(),
|
3930
3998
|
originalActionId: UUID.optional(),
|
3931
3999
|
// should not be part of base action.
|
3932
4000
|
keepAssignment: import_zod29.z.boolean().optional()
|
@@ -3969,7 +4037,8 @@ var DeclareActionInput = BaseActionInput.merge(
|
|
3969
4037
|
);
|
3970
4038
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
3971
4039
|
import_zod29.z.object({
|
3972
|
-
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()
|
3973
4042
|
})
|
3974
4043
|
);
|
3975
4044
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
@@ -4009,7 +4078,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
|
|
4009
4078
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
4010
4079
|
import_zod29.z.object({
|
4011
4080
|
requestId: import_zod29.z.string(),
|
4012
|
-
type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
4081
|
+
type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
|
4082
|
+
reason: RejectionReason
|
4013
4083
|
})
|
4014
4084
|
);
|
4015
4085
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
@@ -4180,16 +4250,19 @@ function getLegalStatuses(actions) {
|
|
4180
4250
|
}
|
4181
4251
|
|
4182
4252
|
// ../commons/src/events/state/flags.ts
|
4183
|
-
function
|
4253
|
+
function isPendingCertification(actions) {
|
4254
|
+
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
4255
|
+
return false;
|
4256
|
+
}
|
4184
4257
|
return actions.reduce((prev, { type }) => {
|
4185
4258
|
if (type === ActionType.PRINT_CERTIFICATE) {
|
4186
|
-
return
|
4259
|
+
return false;
|
4187
4260
|
}
|
4188
4261
|
if (type === ActionType.APPROVE_CORRECTION) {
|
4189
|
-
return
|
4262
|
+
return true;
|
4190
4263
|
}
|
4191
4264
|
return prev;
|
4192
|
-
},
|
4265
|
+
}, true);
|
4193
4266
|
}
|
4194
4267
|
function isCorrectionRequested(actions) {
|
4195
4268
|
return actions.reduce((prev, { type }) => {
|
@@ -4224,8 +4297,8 @@ function getFlagsFromActions(actions) {
|
|
4224
4297
|
const flag = joinValues([type, status], ":").toLowerCase();
|
4225
4298
|
return flag;
|
4226
4299
|
});
|
4227
|
-
if (
|
4228
|
-
flags.push(InherentFlags.
|
4300
|
+
if (isPendingCertification(sortedActions)) {
|
4301
|
+
flags.push(InherentFlags.PENDING_CERTIFICATION);
|
4229
4302
|
}
|
4230
4303
|
if (isCorrectionRequested(sortedActions)) {
|
4231
4304
|
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
@@ -4256,7 +4329,6 @@ function getStatusFromActions(actions) {
|
|
4256
4329
|
case ActionType.NOTIFY:
|
4257
4330
|
return EventStatus.enum.NOTIFIED;
|
4258
4331
|
case ActionType.PRINT_CERTIFICATE:
|
4259
|
-
return EventStatus.enum.CERTIFIED;
|
4260
4332
|
case ActionType.ASSIGN:
|
4261
4333
|
case ActionType.UNASSIGN:
|
4262
4334
|
case ActionType.REJECT:
|
@@ -4376,8 +4448,7 @@ function getCurrentEventState(event2, config) {
|
|
4376
4448
|
trackingId: event2.trackingId,
|
4377
4449
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
4378
4450
|
dateOfEvent: resolveDateOfEvent(event2, declaration, config),
|
4379
|
-
flags: getFlagsFromActions(event2.actions)
|
4380
|
-
copiesPrintedForTemplate: event2.copiesPrintedForTemplate ?? 0
|
4451
|
+
flags: getFlagsFromActions(event2.actions)
|
4381
4452
|
});
|
4382
4453
|
}
|
4383
4454
|
function getCurrentEventStateWithDrafts({
|
@@ -5222,7 +5293,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
5222
5293
|
defaultMessage: "Applicant's name",
|
5223
5294
|
description: "This is the label for the field",
|
5224
5295
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
5225
|
-
}
|
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
|
+
]
|
5226
5317
|
},
|
5227
5318
|
{
|
5228
5319
|
id: "applicant.email",
|
@@ -5444,22 +5535,6 @@ var statusOptions = [
|
|
5444
5535
|
id: "v2.advancedSearch.form.recordStatusRegistered"
|
5445
5536
|
}
|
5446
5537
|
},
|
5447
|
-
{
|
5448
|
-
value: EventStatus.enum.CERTIFIED,
|
5449
|
-
label: {
|
5450
|
-
defaultMessage: "Certified",
|
5451
|
-
description: "Option for form field: status of record",
|
5452
|
-
id: "v2.advancedSearch.form.recordStatusCertified"
|
5453
|
-
}
|
5454
|
-
},
|
5455
|
-
{
|
5456
|
-
value: VisibleStatus.enum.REJECTED,
|
5457
|
-
label: {
|
5458
|
-
defaultMessage: "Rejected",
|
5459
|
-
description: "Option for form field: status of record",
|
5460
|
-
id: "v2.advancedSearch.form.recordStatusRejected"
|
5461
|
-
}
|
5462
|
-
},
|
5463
5538
|
{
|
5464
5539
|
value: EventStatus.enum.ARCHIVED,
|
5465
5540
|
label: {
|
@@ -6849,7 +6924,7 @@ function eventPayloadGenerator(rng) {
|
|
6849
6924
|
requestId,
|
6850
6925
|
keepAssignment: input.keepAssignment
|
6851
6926
|
}),
|
6852
|
-
reject: (eventId, requestId, input
|
6927
|
+
reject: (eventId, requestId, input) => ({
|
6853
6928
|
type: ActionType.REJECT_CORRECTION,
|
6854
6929
|
transactionId: input.transactionId ?? getUUID(),
|
6855
6930
|
declaration: {},
|
@@ -6860,7 +6935,8 @@ function eventPayloadGenerator(rng) {
|
|
6860
6935
|
),
|
6861
6936
|
eventId,
|
6862
6937
|
requestId,
|
6863
|
-
keepAssignment: input.keepAssignment
|
6938
|
+
keepAssignment: input.keepAssignment,
|
6939
|
+
reason: input.reason ?? { message: "" }
|
6864
6940
|
})
|
6865
6941
|
}
|
6866
6942
|
}
|
@@ -6910,7 +6986,11 @@ function generateActionDocument({
|
|
6910
6986
|
case ActionType.NOTIFY:
|
6911
6987
|
return { ...actionBase, type: action };
|
6912
6988
|
case ActionType.PRINT_CERTIFICATE:
|
6913
|
-
return {
|
6989
|
+
return {
|
6990
|
+
...actionBase,
|
6991
|
+
type: action,
|
6992
|
+
content: defaults.content
|
6993
|
+
};
|
6914
6994
|
case ActionType.REQUEST_CORRECTION:
|
6915
6995
|
return { ...actionBase, type: action };
|
6916
6996
|
case ActionType.APPROVE_CORRECTION:
|
@@ -6919,7 +6999,8 @@ function generateActionDocument({
|
|
6919
6999
|
return {
|
6920
7000
|
...actionBase,
|
6921
7001
|
requestId: getUUID(),
|
6922
|
-
type: action
|
7002
|
+
type: action,
|
7003
|
+
reason: { message: "Correction rejection" }
|
6923
7004
|
};
|
6924
7005
|
case ActionType.REGISTER:
|
6925
7006
|
return {
|
@@ -7054,8 +7135,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
7054
7135
|
flags: [],
|
7055
7136
|
legalStatuses: overrides.legalStatuses ?? {},
|
7056
7137
|
declaration: overrides.declaration ?? generateRandomApplicant(rng),
|
7057
|
-
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7058
|
-
copiesPrintedForTemplate: overrides.copiesPrintedForTemplate ?? 0
|
7138
|
+
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7059
7139
|
};
|
7060
7140
|
};
|
7061
7141
|
var generateTranslationConfig = (message) => ({
|
@@ -7310,14 +7390,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7310
7390
|
ActionType.REJECT_CORRECTION,
|
7311
7391
|
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7312
7392
|
],
|
7313
|
-
[EventStatus.enum.CERTIFIED]: [
|
7314
|
-
ActionType.READ,
|
7315
|
-
ActionType.PRINT_CERTIFICATE,
|
7316
|
-
ActionType.REQUEST_CORRECTION,
|
7317
|
-
ActionType.APPROVE_CORRECTION,
|
7318
|
-
ActionType.REJECT_CORRECTION,
|
7319
|
-
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7320
|
-
],
|
7321
7393
|
[EventStatus.enum.ARCHIVED]: [
|
7322
7394
|
ActionType.READ,
|
7323
7395
|
ActionType.ASSIGN,
|
@@ -7325,9 +7397,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7325
7397
|
]
|
7326
7398
|
};
|
7327
7399
|
var getAvailableActionsForEvent = (event2) => {
|
7328
|
-
|
7329
|
-
|
7330
|
-
|
7331
|
-
|
7332
|
-
|
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];
|
7333
7408
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notification/index.ts"],"names":[],"mappings":"AAUA,cAAc,gCAAgC,CAAA"}
|