@opencrvs/toolkit 1.8.0-rc.fe4d9d5 → 1.8.0-rc.fe7c504
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 +1335 -10468
- package/dist/commons/events/ActionConfig.d.ts +2600 -0
- package/dist/commons/events/ActionDocument.d.ts +1081 -1087
- package/dist/commons/events/ActionInput.d.ts +726 -726
- package/dist/commons/events/ActionType.d.ts +0 -2
- package/dist/commons/events/AdvancedSearchConfig.d.ts +222 -18
- package/dist/commons/events/CompositeFieldValue.d.ts +6 -6
- package/dist/commons/events/CountryConfigQueryInput.d.ts +1234 -572
- package/dist/commons/events/CreatedAtLocation.d.ts +1 -2
- package/dist/commons/events/Draft.d.ts +77 -77
- package/dist/commons/events/EventConfig.d.ts +1458 -0
- package/dist/commons/events/EventDocument.d.ts +706 -711
- package/dist/commons/events/EventIndex.d.ts +135 -151
- package/dist/commons/events/EventMetadata.d.ts +38 -29
- package/dist/commons/events/FieldConfig.d.ts +178 -0
- 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 +1092 -0
- package/dist/commons/events/PageConfig.d.ts +260 -0
- package/dist/commons/events/User.d.ts +6 -3
- package/dist/commons/events/WorkqueueConfig.d.ts +2043 -1033
- package/dist/commons/events/defineConfig.d.ts +294 -0
- package/dist/commons/events/field.d.ts +5 -0
- package/dist/commons/events/test.utils.d.ts +30 -19
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +440 -15
- package/dist/conditionals/index.js +22 -18
- package/dist/events/index.js +303 -185
- package/dist/scopes/index.d.ts +92 -6
- package/dist/scopes/index.js +38 -9
- package/package.json +3 -3
package/dist/events/index.js
CHANGED
@@ -69,7 +69,7 @@ __export(events_exports, {
|
|
69
69
|
Conditional: () => Conditional,
|
70
70
|
ConditionalType: () => ConditionalType,
|
71
71
|
ConfirmableActions: () => ConfirmableActions,
|
72
|
-
|
72
|
+
ContainsFlags: () => ContainsFlags,
|
73
73
|
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
74
74
|
DataEntry: () => DataEntry,
|
75
75
|
DataFieldValue: () => DataFieldValue,
|
@@ -124,6 +124,7 @@ __export(events_exports, {
|
|
124
124
|
GenericAddressValue: () => GenericAddressValue,
|
125
125
|
GeographicalArea: () => GeographicalArea,
|
126
126
|
ImageMimeType: () => ImageMimeType,
|
127
|
+
InherentFlags: () => InherentFlags,
|
127
128
|
LanguageConfig: () => LanguageConfig,
|
128
129
|
LegalStatuses: () => LegalStatuses,
|
129
130
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
@@ -131,7 +132,6 @@ __export(events_exports, {
|
|
131
132
|
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
132
133
|
NameFieldValue: () => NameFieldValue,
|
133
134
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
134
|
-
Not: () => Not,
|
135
135
|
NotifyActionInput: () => NotifyActionInput,
|
136
136
|
NumberFieldValue: () => NumberFieldValue,
|
137
137
|
PageConfig: () => PageConfig,
|
@@ -155,10 +155,10 @@ __export(events_exports, {
|
|
155
155
|
RuralAddressValue: () => RuralAddressValue,
|
156
156
|
SearchField: () => SearchField,
|
157
157
|
SearchQueryParams: () => SearchQueryParams,
|
158
|
+
SearchScopeAccessLevels: () => SearchScopeAccessLevels,
|
158
159
|
SelectOption: () => SelectOption,
|
159
160
|
ShowConditional: () => ShowConditional,
|
160
161
|
SignatureFieldValue: () => SignatureFieldValue,
|
161
|
-
StatusChangingActions: () => StatusChangingActions,
|
162
162
|
SummaryConfig: () => SummaryConfig,
|
163
163
|
TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
|
164
164
|
TestUserRole: () => TestUserRole,
|
@@ -169,6 +169,7 @@ __export(events_exports, {
|
|
169
169
|
UrbanAddressValue: () => UrbanAddressValue,
|
170
170
|
User: () => User,
|
171
171
|
ValidateActionInput: () => ValidateActionInput,
|
172
|
+
ValidationConfig: () => ValidationConfig,
|
172
173
|
VerificationActionConfig: () => VerificationActionConfig,
|
173
174
|
VerificationPageConfig: () => VerificationPageConfig,
|
174
175
|
WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
|
@@ -187,6 +188,7 @@ __export(events_exports, {
|
|
187
188
|
alwaysTrue: () => alwaysTrue,
|
188
189
|
and: () => and,
|
189
190
|
annotationActions: () => annotationActions,
|
191
|
+
applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
|
190
192
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
191
193
|
areConditionsMet: () => areConditionsMet,
|
192
194
|
compositeFieldTypes: () => compositeFieldTypes,
|
@@ -227,8 +229,10 @@ __export(events_exports, {
|
|
227
229
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
228
230
|
generateRandomName: () => generateRandomName,
|
229
231
|
generateRandomSignature: () => generateRandomSignature,
|
232
|
+
generateRegistrationNumber: () => generateRegistrationNumber,
|
230
233
|
generateTransactionId: () => generateTransactionId,
|
231
234
|
generateTranslationConfig: () => generateTranslationConfig,
|
235
|
+
generateUuid: () => generateUuid,
|
232
236
|
generateWorkqueues: () => generateWorkqueues,
|
233
237
|
getAcceptedActions: () => getAcceptedActions,
|
234
238
|
getActionAnnotation: () => getActionAnnotation,
|
@@ -304,6 +308,7 @@ __export(events_exports, {
|
|
304
308
|
omitHiddenFields: () => omitHiddenFields,
|
305
309
|
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
306
310
|
or: () => or,
|
311
|
+
resolveDateOfEvent: () => resolveDateOfEvent,
|
307
312
|
runFieldValidations: () => runFieldValidations,
|
308
313
|
user: () => user,
|
309
314
|
validate: () => validate,
|
@@ -479,8 +484,8 @@ var NameFieldValue = import_zod3.z.object({
|
|
479
484
|
middlename: import_zod3.z.string().optional()
|
480
485
|
});
|
481
486
|
var NameFieldUpdateValue = import_zod3.z.object({
|
482
|
-
firstname: import_zod3.z.string(),
|
483
|
-
surname: import_zod3.z.string(),
|
487
|
+
firstname: import_zod3.z.string().nullish(),
|
488
|
+
surname: import_zod3.z.string().nullish(),
|
484
489
|
middlename: import_zod3.z.string().nullish()
|
485
490
|
}).or(import_zod3.z.null()).or(import_zod3.z.undefined());
|
486
491
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
@@ -571,18 +576,18 @@ var FieldReference = import_zod5.z.object({
|
|
571
576
|
$$field: FieldId
|
572
577
|
}).describe("Reference to a field by its ID");
|
573
578
|
var ParentReference = FieldReference.optional();
|
579
|
+
var ValidationConfig = import_zod5.z.object({
|
580
|
+
validator: Conditional,
|
581
|
+
message: TranslationConfig
|
582
|
+
});
|
574
583
|
var BaseField = import_zod5.z.object({
|
575
584
|
id: FieldId,
|
576
585
|
parent: ParentReference,
|
577
586
|
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
578
587
|
required: import_zod5.z.boolean().default(false).optional(),
|
588
|
+
secured: import_zod5.z.boolean().default(false).optional(),
|
579
589
|
placeholder: TranslationConfig.optional(),
|
580
|
-
validation: import_zod5.z.array(
|
581
|
-
import_zod5.z.object({
|
582
|
-
validator: Conditional,
|
583
|
-
message: TranslationConfig
|
584
|
-
})
|
585
|
-
).default([]).optional(),
|
590
|
+
validation: import_zod5.z.array(ValidationConfig).default([]).optional(),
|
586
591
|
label: TranslationConfig,
|
587
592
|
helperText: TranslationConfig.optional(),
|
588
593
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
@@ -972,16 +977,6 @@ var writeActions = ActionTypes.exclude([
|
|
972
977
|
ActionType.ASSIGN,
|
973
978
|
ActionType.UNASSIGN
|
974
979
|
]);
|
975
|
-
var StatusChangingActions = ActionTypes.extract([
|
976
|
-
ActionType.CREATE,
|
977
|
-
ActionType.NOTIFY,
|
978
|
-
ActionType.DECLARE,
|
979
|
-
ActionType.VALIDATE,
|
980
|
-
ActionType.REGISTER,
|
981
|
-
ActionType.REJECT,
|
982
|
-
ActionType.ARCHIVE,
|
983
|
-
ActionType.PRINT_CERTIFICATE
|
984
|
-
]);
|
985
980
|
var workqueueActions = ActionTypes.exclude([
|
986
981
|
ActionType.CREATE,
|
987
982
|
ActionType.NOTIFY,
|
@@ -1301,6 +1296,9 @@ var BaseField3 = import_zod14.z.object({
|
|
1301
1296
|
'conditionals' to an empty array ('[]') in the search config. This ensures they
|
1302
1297
|
are always rendered in the advanced search form.
|
1303
1298
|
`
|
1299
|
+
),
|
1300
|
+
validations: import_zod14.z.array(ValidationConfig).default([]).optional().describe(
|
1301
|
+
`In advanced search, we sometimes need to override the default field validations.`
|
1304
1302
|
)
|
1305
1303
|
});
|
1306
1304
|
var SearchQueryParams = import_zod14.z.object({
|
@@ -1339,9 +1337,16 @@ var import_lodash = require("lodash");
|
|
1339
1337
|
var import_zod18 = require("zod");
|
1340
1338
|
var import_zod_openapi7 = require("zod-openapi");
|
1341
1339
|
|
1342
|
-
// ../commons/src/
|
1340
|
+
// ../commons/src/uuid.ts
|
1341
|
+
var import_uuid = require("uuid");
|
1343
1342
|
var import_zod15 = require("zod");
|
1344
|
-
var
|
1343
|
+
var UUID = import_zod15.z.string().uuid().brand("UUID");
|
1344
|
+
function getUUID() {
|
1345
|
+
return (0, import_uuid.v4)();
|
1346
|
+
}
|
1347
|
+
|
1348
|
+
// ../commons/src/events/CreatedAtLocation.ts
|
1349
|
+
var CreatedAtLocation = UUID.nullish();
|
1345
1350
|
|
1346
1351
|
// ../commons/src/authentication.ts
|
1347
1352
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
@@ -1606,7 +1611,15 @@ var NotifyRecordScope = import_zod16.z.object({
|
|
1606
1611
|
event: import_zod16.z.array(import_zod16.z.string())
|
1607
1612
|
})
|
1608
1613
|
});
|
1609
|
-
var
|
1614
|
+
var SearchScope = import_zod16.z.object({
|
1615
|
+
type: import_zod16.z.literal("search"),
|
1616
|
+
options: import_zod16.z.object({
|
1617
|
+
event: import_zod16.z.array(import_zod16.z.string()).length(1),
|
1618
|
+
access: import_zod16.z.array(import_zod16.z.enum(["my-jurisdiction", "all"])).length(1)
|
1619
|
+
})
|
1620
|
+
});
|
1621
|
+
var ConfigurableRawScopes = import_zod16.z.discriminatedUnion("type", [
|
1622
|
+
SearchScope,
|
1610
1623
|
CreateUserScope,
|
1611
1624
|
EditUserScope,
|
1612
1625
|
WorkqueueScope,
|
@@ -1777,7 +1790,7 @@ var ActionStatus = {
|
|
1777
1790
|
Rejected: "Rejected"
|
1778
1791
|
};
|
1779
1792
|
var ActionBase = import_zod18.z.object({
|
1780
|
-
id:
|
1793
|
+
id: UUID,
|
1781
1794
|
transactionId: import_zod18.z.string(),
|
1782
1795
|
createdByUserType: TokenUserType,
|
1783
1796
|
createdAt: import_zod18.z.string().datetime(),
|
@@ -1786,14 +1799,16 @@ var ActionBase = import_zod18.z.object({
|
|
1786
1799
|
createdBySignature: import_zod18.z.string().nullish().describe("Reference to signature of the user who created the action"),
|
1787
1800
|
createdAtLocation: CreatedAtLocation,
|
1788
1801
|
declaration: ActionUpdate,
|
1789
|
-
annotation: ActionUpdate.optional(),
|
1802
|
+
annotation: ActionUpdate.optional().nullable(),
|
1790
1803
|
status: import_zod18.z.enum([
|
1791
1804
|
ActionStatus.Requested,
|
1792
1805
|
ActionStatus.Accepted,
|
1793
1806
|
ActionStatus.Rejected
|
1794
1807
|
]),
|
1795
1808
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1796
|
-
originalActionId:
|
1809
|
+
originalActionId: UUID.optional().nullable().describe(
|
1810
|
+
"Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
|
1811
|
+
)
|
1797
1812
|
});
|
1798
1813
|
var AssignedAction = ActionBase.merge(
|
1799
1814
|
import_zod18.z.object({
|
@@ -1803,8 +1818,7 @@ var AssignedAction = ActionBase.merge(
|
|
1803
1818
|
);
|
1804
1819
|
var UnassignedAction = ActionBase.merge(
|
1805
1820
|
import_zod18.z.object({
|
1806
|
-
type: import_zod18.z.literal(ActionType.UNASSIGN)
|
1807
|
-
assignedTo: import_zod18.z.literal(null)
|
1821
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN)
|
1808
1822
|
})
|
1809
1823
|
);
|
1810
1824
|
var RegisterAction = ActionBase.merge(
|
@@ -2128,6 +2142,29 @@ var ajv = new import_ajv.default({
|
|
2128
2142
|
allowUnionTypes: true
|
2129
2143
|
});
|
2130
2144
|
(0, import_ajv_formats.default)(ajv);
|
2145
|
+
ajv.addKeyword({
|
2146
|
+
keyword: "daysFromNow",
|
2147
|
+
type: "string",
|
2148
|
+
schemaType: "object",
|
2149
|
+
$data: true,
|
2150
|
+
errors: true,
|
2151
|
+
validate(schema, data, _, dataContext) {
|
2152
|
+
if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
|
2153
|
+
throw new Error("Validation context must contain $now");
|
2154
|
+
}
|
2155
|
+
const { days, clause } = schema;
|
2156
|
+
if (typeof data !== "string") {
|
2157
|
+
return false;
|
2158
|
+
}
|
2159
|
+
const date = new Date(data);
|
2160
|
+
if (isNaN(date.getTime())) {
|
2161
|
+
return false;
|
2162
|
+
}
|
2163
|
+
const now = new Date(dataContext.rootData.$now);
|
2164
|
+
const offsetDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1e3);
|
2165
|
+
return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
|
2166
|
+
}
|
2167
|
+
});
|
2131
2168
|
function validate(schema, data) {
|
2132
2169
|
return ajv.validate(schema, data);
|
2133
2170
|
}
|
@@ -2193,7 +2230,7 @@ var errorMessages = {
|
|
2193
2230
|
id: "v2.error.invalidEmail"
|
2194
2231
|
},
|
2195
2232
|
requiredField: {
|
2196
|
-
defaultMessage: "Required
|
2233
|
+
defaultMessage: "Required",
|
2197
2234
|
description: "Error message when required field is missing",
|
2198
2235
|
id: "v2.error.required"
|
2199
2236
|
},
|
@@ -2341,12 +2378,6 @@ function getValidatorsForField(fieldId, validations) {
|
|
2341
2378
|
}).filter((x) => x !== null);
|
2342
2379
|
}
|
2343
2380
|
|
2344
|
-
// ../commons/src/uuid.ts
|
2345
|
-
var import_uuid = require("uuid");
|
2346
|
-
function getUUID() {
|
2347
|
-
return (0, import_uuid.v4)();
|
2348
|
-
}
|
2349
|
-
|
2350
2381
|
// ../commons/src/utils.ts
|
2351
2382
|
function getOrThrow(x, message) {
|
2352
2383
|
if (x === void 0 || x === null) {
|
@@ -2354,6 +2385,9 @@ function getOrThrow(x, message) {
|
|
2354
2385
|
}
|
2355
2386
|
return x;
|
2356
2387
|
}
|
2388
|
+
function joinValues(values, separator = " ") {
|
2389
|
+
return values.filter((value) => !!value).join(separator).trim();
|
2390
|
+
}
|
2357
2391
|
|
2358
2392
|
// ../commons/src/events/utils.ts
|
2359
2393
|
function isDeclarationActionConfig(action) {
|
@@ -2455,7 +2489,7 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
2455
2489
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2456
2490
|
createdByUserType: TokenUserType.Enum.user,
|
2457
2491
|
createdBy: "@todo",
|
2458
|
-
createdAtLocation: "
|
2492
|
+
createdAtLocation: "00000000-0000-0000-0000-000000000000",
|
2459
2493
|
status: ActionStatus.Accepted,
|
2460
2494
|
transactionId: "@todo",
|
2461
2495
|
createdByRole: "@todo"
|
@@ -2644,7 +2678,8 @@ var SerializedUserField = import_zod21.z.object({
|
|
2644
2678
|
"id",
|
2645
2679
|
"name",
|
2646
2680
|
"role",
|
2647
|
-
"
|
2681
|
+
"signature",
|
2682
|
+
"avatar",
|
2648
2683
|
"primaryOfficeId"
|
2649
2684
|
])
|
2650
2685
|
});
|
@@ -2748,9 +2783,6 @@ function createEventConditionals() {
|
|
2748
2783
|
})
|
2749
2784
|
};
|
2750
2785
|
}
|
2751
|
-
function getDateFromNow(days) {
|
2752
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2753
|
-
}
|
2754
2786
|
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2755
2787
|
return {
|
2756
2788
|
type: "object",
|
@@ -2769,6 +2801,20 @@ function isFieldReference(value) {
|
|
2769
2801
|
return typeof value === "object" && value !== null && "$$field" in value;
|
2770
2802
|
}
|
2771
2803
|
function createFieldConditionals(fieldId) {
|
2804
|
+
const getDayRange = (days, clause) => ({
|
2805
|
+
type: "object",
|
2806
|
+
properties: {
|
2807
|
+
[fieldId]: {
|
2808
|
+
type: "string",
|
2809
|
+
format: "date",
|
2810
|
+
daysFromNow: {
|
2811
|
+
days,
|
2812
|
+
clause
|
2813
|
+
}
|
2814
|
+
}
|
2815
|
+
},
|
2816
|
+
required: [fieldId]
|
2817
|
+
});
|
2772
2818
|
const getDateRange = (date, clause) => ({
|
2773
2819
|
type: "object",
|
2774
2820
|
properties: {
|
@@ -2787,12 +2833,8 @@ function createFieldConditionals(fieldId) {
|
|
2787
2833
|
$$field: fieldId,
|
2788
2834
|
isAfter: () => ({
|
2789
2835
|
days: (days) => ({
|
2790
|
-
inPast: () => defineFormConditional(
|
2791
|
-
|
2792
|
-
),
|
2793
|
-
inFuture: () => defineFormConditional(
|
2794
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2795
|
-
)
|
2836
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
2837
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
2796
2838
|
}),
|
2797
2839
|
date: (date) => {
|
2798
2840
|
if (isFieldReference(date)) {
|
@@ -2807,16 +2849,12 @@ function createFieldConditionals(fieldId) {
|
|
2807
2849
|
}
|
2808
2850
|
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2809
2851
|
},
|
2810
|
-
now: () => defineFormConditional(getDateRange(
|
2852
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
2811
2853
|
}),
|
2812
2854
|
isBefore: () => ({
|
2813
2855
|
days: (days) => ({
|
2814
|
-
inPast: () => defineFormConditional(
|
2815
|
-
|
2816
|
-
),
|
2817
|
-
inFuture: () => defineFormConditional(
|
2818
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2819
|
-
)
|
2856
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
2857
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
2820
2858
|
}),
|
2821
2859
|
date: (date) => {
|
2822
2860
|
if (isFieldReference(date)) {
|
@@ -2831,7 +2869,7 @@ function createFieldConditionals(fieldId) {
|
|
2831
2869
|
}
|
2832
2870
|
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2833
2871
|
},
|
2834
|
-
now: () => defineFormConditional(getDateRange(
|
2872
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
2835
2873
|
}),
|
2836
2874
|
isEqualTo: (value) => {
|
2837
2875
|
if (isFieldReference(value)) {
|
@@ -3057,8 +3095,11 @@ var EventStatus = import_zod22.z.enum([
|
|
3057
3095
|
"REJECTED",
|
3058
3096
|
"ARCHIVED"
|
3059
3097
|
]);
|
3060
|
-
var
|
3061
|
-
|
3098
|
+
var InherentFlags = {
|
3099
|
+
PRINTED: "printed",
|
3100
|
+
INCOMPLETE: "incomplete",
|
3101
|
+
REJECTED: "rejected",
|
3102
|
+
CORRECTION_REQUESTED: "correction-requested"
|
3062
3103
|
};
|
3063
3104
|
var Flag = import_zod22.z.string().regex(
|
3064
3105
|
new RegExp(
|
@@ -3067,7 +3108,7 @@ var Flag = import_zod22.z.string().regex(
|
|
3067
3108
|
).join("|").toLowerCase()})$`
|
3068
3109
|
),
|
3069
3110
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3070
|
-
).or(import_zod22.z.nativeEnum(
|
3111
|
+
).or(import_zod22.z.nativeEnum(InherentFlags));
|
3071
3112
|
var ZodDate = import_zod22.z.string().date();
|
3072
3113
|
var ActionCreationMetadata = import_zod22.z.object({
|
3073
3114
|
createdAt: import_zod22.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3090,7 +3131,7 @@ var LegalStatuses = import_zod22.z.object({
|
|
3090
3131
|
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
3091
3132
|
});
|
3092
3133
|
var EventMetadata = import_zod22.z.object({
|
3093
|
-
id:
|
3134
|
+
id: UUID,
|
3094
3135
|
type: import_zod22.z.string().describe("The type of event, such as birth, death, or marriage."),
|
3095
3136
|
status: EventStatus,
|
3096
3137
|
legalStatuses: LegalStatuses.describe(
|
@@ -3105,7 +3146,9 @@ var EventMetadata = import_zod22.z.object({
|
|
3105
3146
|
"Location of the user who created the event."
|
3106
3147
|
),
|
3107
3148
|
createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the event."),
|
3108
|
-
updatedAtLocation:
|
3149
|
+
updatedAtLocation: UUID.nullish().describe(
|
3150
|
+
"Location of the user who last changed the status."
|
3151
|
+
),
|
3109
3152
|
updatedAt: import_zod22.z.string().datetime().describe(
|
3110
3153
|
"Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
|
3111
3154
|
),
|
@@ -3284,8 +3327,11 @@ var Range = import_zod24.z.object({
|
|
3284
3327
|
}).openapi({
|
3285
3328
|
ref: "Range"
|
3286
3329
|
});
|
3287
|
-
var
|
3288
|
-
|
3330
|
+
var ContainsFlags = import_zod24.z.object({
|
3331
|
+
anyOf: import_zod24.z.array(Flag).optional(),
|
3332
|
+
noneOf: import_zod24.z.array(Flag).optional()
|
3333
|
+
}).openapi({
|
3334
|
+
ref: "ContainsFlags"
|
3289
3335
|
});
|
3290
3336
|
var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() }).openapi({
|
3291
3337
|
ref: "Within"
|
@@ -3306,7 +3352,7 @@ var DateCondition = import_zod24.z.union([ExactDate, RangeDate]).openapi({
|
|
3306
3352
|
});
|
3307
3353
|
var QueryInput = import_zod24.z.lazy(
|
3308
3354
|
() => import_zod24.z.union([
|
3309
|
-
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf
|
3355
|
+
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
3310
3356
|
import_zod24.z.record(import_zod24.z.string(), QueryInput)
|
3311
3357
|
])
|
3312
3358
|
).openapi({
|
@@ -3330,7 +3376,7 @@ var QueryExpression = import_zod24.z.object({
|
|
3330
3376
|
createdBy: import_zod24.z.optional(Exact),
|
3331
3377
|
updatedBy: import_zod24.z.optional(Exact),
|
3332
3378
|
trackingId: import_zod24.z.optional(Exact),
|
3333
|
-
flags: import_zod24.z.optional(
|
3379
|
+
flags: import_zod24.z.optional(ContainsFlags),
|
3334
3380
|
data: QueryInput
|
3335
3381
|
}).partial().refine((obj) => Object.values(obj).some((val) => val !== void 0), {
|
3336
3382
|
message: "At least one query field must be specified."
|
@@ -3370,6 +3416,10 @@ var QueryType = import_zod24.z.object({
|
|
3370
3416
|
}).openapi({
|
3371
3417
|
ref: "QueryType"
|
3372
3418
|
});
|
3419
|
+
var SearchScopeAccessLevels = {
|
3420
|
+
MY_JURISDICTION: "my-jurisdiction",
|
3421
|
+
ALL: "all"
|
3422
|
+
};
|
3373
3423
|
|
3374
3424
|
// ../commons/src/events/CountryConfigQueryInput.ts
|
3375
3425
|
var SerializableExact = import_zod25.z.object({
|
@@ -3385,6 +3435,11 @@ var SerializedQueryExpression = import_zod25.z.object({
|
|
3385
3435
|
status: import_zod25.z.optional(import_zod25.z.union([AnyOfStatus, ExactStatus])),
|
3386
3436
|
createdAt: import_zod25.z.optional(DateCondition),
|
3387
3437
|
updatedAt: import_zod25.z.optional(DateCondition),
|
3438
|
+
"legalStatus.REGISTERED.createdAt": import_zod25.z.optional(DateCondition),
|
3439
|
+
"legalStatus.REGISTERED.createdAtLocation": import_zod25.z.optional(
|
3440
|
+
import_zod25.z.union([Within, Exact])
|
3441
|
+
),
|
3442
|
+
"legalStatus.REGISTERED.registrationNumber": import_zod25.z.optional(Exact),
|
3388
3443
|
createdAtLocation: import_zod25.z.optional(
|
3389
3444
|
import_zod25.z.union([SerializableWithin, SerializableExact])
|
3390
3445
|
),
|
@@ -3396,7 +3451,7 @@ var SerializedQueryExpression = import_zod25.z.object({
|
|
3396
3451
|
createdByUserType: TokenUserType,
|
3397
3452
|
updatedBy: import_zod25.z.optional(SerializableExact),
|
3398
3453
|
trackingId: import_zod25.z.optional(Exact),
|
3399
|
-
flags: import_zod25.z.optional(
|
3454
|
+
flags: import_zod25.z.optional(ContainsFlags),
|
3400
3455
|
data: QueryInput
|
3401
3456
|
}).partial();
|
3402
3457
|
var Or2 = import_zod25.z.object({
|
@@ -3454,7 +3509,6 @@ var AvailableIcons = import_zod26.z.enum([
|
|
3454
3509
|
"Copy",
|
3455
3510
|
"Database",
|
3456
3511
|
"DotsThreeVertical",
|
3457
|
-
"DownloadSimple",
|
3458
3512
|
"ArrowCounterClockwise",
|
3459
3513
|
"MagnifyingGlassMinus",
|
3460
3514
|
"MagnifyingGlassPlus",
|
@@ -3615,14 +3669,14 @@ var import_zod29 = require("zod");
|
|
3615
3669
|
// ../commons/src/events/ActionInput.ts
|
3616
3670
|
var import_zod28 = require("zod");
|
3617
3671
|
var import_zod_openapi10 = require("zod-openapi");
|
3618
|
-
var import_uuid3 = require("uuid");
|
3619
3672
|
(0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
|
3620
3673
|
var BaseActionInput = import_zod28.z.object({
|
3621
|
-
eventId:
|
3674
|
+
eventId: UUID,
|
3622
3675
|
transactionId: import_zod28.z.string(),
|
3623
3676
|
declaration: ActionUpdate.default({}),
|
3624
3677
|
annotation: ActionUpdate.optional(),
|
3625
|
-
originalActionId:
|
3678
|
+
originalActionId: UUID.optional(),
|
3679
|
+
// should not be part of base action.
|
3626
3680
|
keepAssignment: import_zod28.z.boolean().optional()
|
3627
3681
|
});
|
3628
3682
|
var CreateActionInput = BaseActionInput.merge(
|
@@ -3636,7 +3690,7 @@ var RegisterActionInput = BaseActionInput.merge(
|
|
3636
3690
|
type: import_zod28.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
3637
3691
|
registrationNumber: import_zod28.z.string().optional()
|
3638
3692
|
})
|
3639
|
-
);
|
3693
|
+
).strict();
|
3640
3694
|
var ValidateActionInput = BaseActionInput.merge(
|
3641
3695
|
import_zod28.z.object({
|
3642
3696
|
type: import_zod28.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
@@ -3650,7 +3704,7 @@ var NotifyActionInput = BaseActionInput.merge(
|
|
3650
3704
|
).openapi({
|
3651
3705
|
default: {
|
3652
3706
|
eventId: "<event-id-here>",
|
3653
|
-
transactionId: (
|
3707
|
+
transactionId: getUUID(),
|
3654
3708
|
declaration: {},
|
3655
3709
|
annotation: {},
|
3656
3710
|
type: ActionType.NOTIFY
|
@@ -3717,7 +3771,7 @@ var ReadActionInput = BaseActionInput.merge(
|
|
3717
3771
|
type: import_zod28.z.literal(ActionType.READ).default(ActionType.READ)
|
3718
3772
|
})
|
3719
3773
|
);
|
3720
|
-
var DeleteActionInput = import_zod28.z.object({ eventId:
|
3774
|
+
var DeleteActionInput = import_zod28.z.object({ eventId: UUID });
|
3721
3775
|
var ActionInput = import_zod28.z.discriminatedUnion("type", [
|
3722
3776
|
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
3723
3777
|
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
@@ -3748,8 +3802,8 @@ var ActionInput = import_zod28.z.discriminatedUnion("type", [
|
|
3748
3802
|
|
3749
3803
|
// ../commons/src/events/Draft.ts
|
3750
3804
|
var Draft = import_zod29.z.object({
|
3751
|
-
id:
|
3752
|
-
eventId:
|
3805
|
+
id: UUID,
|
3806
|
+
eventId: UUID,
|
3753
3807
|
transactionId: import_zod29.z.string(),
|
3754
3808
|
createdAt: import_zod29.z.string().datetime(),
|
3755
3809
|
action: ActionBase.extend({
|
@@ -3767,18 +3821,18 @@ var DraftInput = BaseActionInput.extend({
|
|
3767
3821
|
|
3768
3822
|
// ../commons/src/events/EventInput.ts
|
3769
3823
|
var import_zod30 = require("zod");
|
3770
|
-
var
|
3824
|
+
var import_uuid8 = require("uuid");
|
3771
3825
|
var EventInput = import_zod30.z.object({
|
3772
3826
|
transactionId: import_zod30.z.string(),
|
3773
3827
|
type: import_zod30.z.string()
|
3774
|
-
}).openapi({ default: { transactionId: (0,
|
3828
|
+
}).openapi({ default: { transactionId: (0, import_uuid8.v4)(), type: "v2.birth" } });
|
3775
3829
|
|
3776
3830
|
// ../commons/src/events/EventDocument.ts
|
3777
3831
|
var import_zod31 = require("zod");
|
3778
3832
|
var import_zod_openapi11 = require("zod-openapi");
|
3779
3833
|
(0, import_zod_openapi11.extendZodWithOpenApi)(import_zod31.z);
|
3780
3834
|
var EventDocument = import_zod31.z.object({
|
3781
|
-
id:
|
3835
|
+
id: UUID,
|
3782
3836
|
type: import_zod31.z.string(),
|
3783
3837
|
createdAt: import_zod31.z.string().datetime(),
|
3784
3838
|
updatedAt: import_zod31.z.string().datetime(),
|
@@ -3787,6 +3841,7 @@ var EventDocument = import_zod31.z.object({
|
|
3787
3841
|
}).openapi({ ref: "EventDocument" });
|
3788
3842
|
|
3789
3843
|
// ../commons/src/events/state/utils.ts
|
3844
|
+
var import_lodash2 = require("lodash");
|
3790
3845
|
function getActionRequests(actionType, actions) {
|
3791
3846
|
const filtered = actions.filter((action) => action.type === actionType);
|
3792
3847
|
const accept = filtered.find(
|
@@ -3825,29 +3880,38 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3825
3880
|
registrationNumber
|
3826
3881
|
};
|
3827
3882
|
}
|
3883
|
+
var updateActions = ActionTypes.extract([
|
3884
|
+
ActionType.CREATE,
|
3885
|
+
ActionType.NOTIFY,
|
3886
|
+
ActionType.DECLARE,
|
3887
|
+
ActionType.VALIDATE,
|
3888
|
+
ActionType.REGISTER,
|
3889
|
+
ActionType.REJECT,
|
3890
|
+
ActionType.ARCHIVE,
|
3891
|
+
ActionType.PRINT_CERTIFICATE,
|
3892
|
+
ActionType.REQUEST_CORRECTION
|
3893
|
+
]);
|
3828
3894
|
function getActionUpdateMetadata(actions) {
|
3829
3895
|
const createAction = getOrThrow(
|
3830
3896
|
actions.find((action) => action.type === ActionType.CREATE),
|
3831
3897
|
`Event has no ${ActionType.CREATE} action`
|
3832
3898
|
);
|
3833
|
-
|
3834
|
-
|
3835
|
-
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
3841
|
-
|
3842
|
-
|
3899
|
+
const metadataFields = [
|
3900
|
+
"createdAt",
|
3901
|
+
"createdBy",
|
3902
|
+
"createdByUserType",
|
3903
|
+
"createdAtLocation",
|
3904
|
+
"createdByRole"
|
3905
|
+
];
|
3906
|
+
return actions.filter(({ type }) => updateActions.safeParse(type).success).filter(({ status }) => status === ActionStatus.Accepted).reduce(
|
3907
|
+
(_, action) => {
|
3908
|
+
if (action.originalActionId) {
|
3909
|
+
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
3910
|
+
return (0, import_lodash2.pick)(originalAction, metadataFields);
|
3911
|
+
}
|
3912
|
+
return (0, import_lodash2.pick)(action, metadataFields);
|
3843
3913
|
},
|
3844
|
-
|
3845
|
-
createdAt: createAction.createdAt,
|
3846
|
-
createdBy: createAction.createdBy,
|
3847
|
-
createdByUserType: createAction.createdByUserType,
|
3848
|
-
createdAtLocation: createAction.createdAtLocation,
|
3849
|
-
createdByRole: createAction.createdByRole
|
3850
|
-
}
|
3914
|
+
(0, import_lodash2.pick)(createAction, metadataFields)
|
3851
3915
|
);
|
3852
3916
|
}
|
3853
3917
|
function getLegalStatuses(actions) {
|
@@ -3863,15 +3927,69 @@ function getLegalStatuses(actions) {
|
|
3863
3927
|
};
|
3864
3928
|
}
|
3865
3929
|
|
3866
|
-
// ../commons/src/events/state/
|
3867
|
-
function
|
3868
|
-
|
3869
|
-
(
|
3930
|
+
// ../commons/src/events/state/flags.ts
|
3931
|
+
function isCertificatePrinted(actions) {
|
3932
|
+
return actions.reduce((prev, { type }) => {
|
3933
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
3934
|
+
return true;
|
3935
|
+
}
|
3936
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
3937
|
+
return false;
|
3938
|
+
}
|
3939
|
+
return prev;
|
3940
|
+
}, false);
|
3941
|
+
}
|
3942
|
+
function isCorrectionRequested(actions) {
|
3943
|
+
return actions.reduce((prev, { type }) => {
|
3944
|
+
if (type === ActionType.REQUEST_CORRECTION) {
|
3945
|
+
return true;
|
3946
|
+
}
|
3947
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
3948
|
+
return false;
|
3949
|
+
}
|
3950
|
+
if (type === ActionType.REJECT_CORRECTION) {
|
3951
|
+
return false;
|
3952
|
+
}
|
3953
|
+
return prev;
|
3954
|
+
}, false);
|
3955
|
+
}
|
3956
|
+
function isDeclarationIncomplete(actions) {
|
3957
|
+
return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
|
3958
|
+
}
|
3959
|
+
function isRejected(actions) {
|
3960
|
+
return getStatusFromActions(actions) === EventStatus.enum.REJECTED;
|
3961
|
+
}
|
3962
|
+
function getFlagsFromActions(actions) {
|
3963
|
+
const sortedActions = actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
3964
|
+
const actionStatus = sortedActions.reduce(
|
3965
|
+
(actionStatuses, { type, status }) => ({
|
3966
|
+
...actionStatuses,
|
3967
|
+
[type]: status
|
3968
|
+
}),
|
3969
|
+
{}
|
3870
3970
|
);
|
3871
|
-
|
3872
|
-
|
3971
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
3972
|
+
const flag = joinValues([type, status], ":").toLowerCase();
|
3973
|
+
return flag;
|
3974
|
+
});
|
3975
|
+
if (isCertificatePrinted(sortedActions)) {
|
3976
|
+
flags.push(InherentFlags.PRINTED);
|
3873
3977
|
}
|
3874
|
-
|
3978
|
+
if (isCorrectionRequested(sortedActions)) {
|
3979
|
+
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
3980
|
+
}
|
3981
|
+
if (isDeclarationIncomplete(sortedActions)) {
|
3982
|
+
flags.push(InherentFlags.INCOMPLETE);
|
3983
|
+
}
|
3984
|
+
if (isRejected(sortedActions)) {
|
3985
|
+
flags.push(InherentFlags.REJECTED);
|
3986
|
+
}
|
3987
|
+
return flags;
|
3988
|
+
}
|
3989
|
+
|
3990
|
+
// ../commons/src/events/state/index.ts
|
3991
|
+
function getStatusFromActions(actions) {
|
3992
|
+
return actions.filter(({ status }) => status === ActionStatus.Accepted).reduce((status, action) => {
|
3875
3993
|
switch (action.type) {
|
3876
3994
|
case ActionType.CREATE:
|
3877
3995
|
return EventStatus.enum.CREATED;
|
@@ -3901,38 +4019,6 @@ function getStatusFromActions(actions) {
|
|
3901
4019
|
}
|
3902
4020
|
}, EventStatus.enum.CREATED);
|
3903
4021
|
}
|
3904
|
-
function getFlagsFromActions(actions) {
|
3905
|
-
const sortedactions = actions.sort(
|
3906
|
-
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
3907
|
-
);
|
3908
|
-
const actionStatus = sortedactions.reduce(
|
3909
|
-
(actionStatuses, { type, status }) => ({
|
3910
|
-
...actionStatuses,
|
3911
|
-
[type]: status
|
3912
|
-
}),
|
3913
|
-
{}
|
3914
|
-
);
|
3915
|
-
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
3916
|
-
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
3917
|
-
return flag;
|
3918
|
-
});
|
3919
|
-
const isCertificatePrinted = sortedactions.reduce(
|
3920
|
-
(prev, { type }) => {
|
3921
|
-
if (type === ActionType.PRINT_CERTIFICATE) {
|
3922
|
-
return true;
|
3923
|
-
}
|
3924
|
-
if (type === ActionType.APPROVE_CORRECTION) {
|
3925
|
-
return false;
|
3926
|
-
}
|
3927
|
-
return prev;
|
3928
|
-
},
|
3929
|
-
false
|
3930
|
-
);
|
3931
|
-
if (isCertificatePrinted) {
|
3932
|
-
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
3933
|
-
}
|
3934
|
-
return flags;
|
3935
|
-
}
|
3936
4022
|
function getAssignedUserFromActions(actions) {
|
3937
4023
|
return actions.reduce((user2, action) => {
|
3938
4024
|
if (action.type === ActionType.ASSIGN) {
|
@@ -3999,6 +4085,13 @@ function getAcceptedActions(event2) {
|
|
3999
4085
|
);
|
4000
4086
|
}
|
4001
4087
|
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
4088
|
+
function resolveDateOfEvent(eventMetadata, declaration, config) {
|
4089
|
+
if (!config.dateOfEvent) {
|
4090
|
+
return eventMetadata[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
|
4091
|
+
}
|
4092
|
+
const parsedDate = ZodDate.safeParse(declaration[config.dateOfEvent.$$field]);
|
4093
|
+
return parsedDate.success ? parsedDate.data : void 0;
|
4094
|
+
}
|
4002
4095
|
function getCurrentEventState(event2, config) {
|
4003
4096
|
const creationAction = event2.actions.find(
|
4004
4097
|
(action) => action.type === ActionType.CREATE
|
@@ -4012,17 +4105,6 @@ function getCurrentEventState(event2, config) {
|
|
4012
4105
|
const requestActionMetadata = getActionUpdateMetadata(event2.actions);
|
4013
4106
|
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
4014
4107
|
const declaration = aggregateActionDeclarations(acceptedActions);
|
4015
|
-
let dateOfEvent;
|
4016
|
-
if (config.dateOfEvent) {
|
4017
|
-
const parsedDate = ZodDate.safeParse(
|
4018
|
-
declaration[config.dateOfEvent.$$field]
|
4019
|
-
);
|
4020
|
-
if (parsedDate.success) {
|
4021
|
-
dateOfEvent = parsedDate.data;
|
4022
|
-
}
|
4023
|
-
} else {
|
4024
|
-
dateOfEvent = event2[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
|
4025
|
-
}
|
4026
4108
|
return deepDropNulls({
|
4027
4109
|
id: event2.id,
|
4028
4110
|
type: event2.type,
|
@@ -4041,7 +4123,7 @@ function getCurrentEventState(event2, config) {
|
|
4041
4123
|
declaration,
|
4042
4124
|
trackingId: event2.trackingId,
|
4043
4125
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
4044
|
-
dateOfEvent,
|
4126
|
+
dateOfEvent: resolveDateOfEvent(event2, declaration, config),
|
4045
4127
|
flags: getFlagsFromActions(event2.actions)
|
4046
4128
|
});
|
4047
4129
|
}
|
@@ -4070,19 +4152,29 @@ function getCurrentEventStateWithDrafts({
|
|
4070
4152
|
};
|
4071
4153
|
return getCurrentEventState(withDrafts, configuration);
|
4072
4154
|
}
|
4073
|
-
function
|
4155
|
+
function applyDeclarationToEventIndex(eventIndex, declaration, eventConfiguration) {
|
4156
|
+
const updatedDeclaration = deepMerge(eventIndex.declaration, declaration);
|
4157
|
+
return {
|
4158
|
+
...eventIndex,
|
4159
|
+
dateOfEvent: resolveDateOfEvent(
|
4160
|
+
eventIndex,
|
4161
|
+
updatedDeclaration,
|
4162
|
+
eventConfiguration
|
4163
|
+
),
|
4164
|
+
declaration: updatedDeclaration
|
4165
|
+
};
|
4166
|
+
}
|
4167
|
+
function applyDraftsToEventIndex(eventIndex, drafts, eventConfiguration) {
|
4074
4168
|
const indexedAt = eventIndex.updatedAt;
|
4075
4169
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
4076
4170
|
if (activeDrafts.length === 0) {
|
4077
4171
|
return eventIndex;
|
4078
4172
|
}
|
4079
|
-
return
|
4080
|
-
|
4081
|
-
declaration
|
4082
|
-
|
4083
|
-
|
4084
|
-
}
|
4085
|
-
};
|
4173
|
+
return applyDeclarationToEventIndex(
|
4174
|
+
eventIndex,
|
4175
|
+
activeDrafts[activeDrafts.length - 1].declaration,
|
4176
|
+
eventConfiguration
|
4177
|
+
);
|
4086
4178
|
}
|
4087
4179
|
function getAnnotationFromDrafts(drafts) {
|
4088
4180
|
const actions = drafts.map((draft) => draft.action);
|
@@ -4122,24 +4214,37 @@ function generateTransactionId() {
|
|
4122
4214
|
return getUUID();
|
4123
4215
|
}
|
4124
4216
|
|
4125
|
-
// ../commons/src/
|
4217
|
+
// ../commons/src/documents.ts
|
4126
4218
|
var import_zod32 = require("zod");
|
4127
|
-
var
|
4128
|
-
id
|
4129
|
-
|
4130
|
-
|
4131
|
-
|
4132
|
-
|
4133
|
-
|
4219
|
+
var FullDocumentURL = import_zod32.z.string().brand("FullDocumentURL").describe(
|
4220
|
+
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
|
4221
|
+
);
|
4222
|
+
var FullDocumentPath = import_zod32.z.string().brand("FullDocumentPath").describe(
|
4223
|
+
"A full path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
4224
|
+
);
|
4225
|
+
var DocumentPath = import_zod32.z.string().brand("DocumentPath").describe(
|
4226
|
+
"A full identifier starting from the root of the S3 bucket, e.g. /document-id.jpg or /directory/document-id.jpg but never /bucket-name/document-id.jpg"
|
4227
|
+
);
|
4228
|
+
|
4229
|
+
// ../commons/src/events/User.ts
|
4230
|
+
var import_zod33 = require("zod");
|
4231
|
+
var User = import_zod33.z.object({
|
4232
|
+
id: import_zod33.z.string(),
|
4233
|
+
name: import_zod33.z.array(
|
4234
|
+
import_zod33.z.object({
|
4235
|
+
use: import_zod33.z.string(),
|
4236
|
+
given: import_zod33.z.array(import_zod33.z.string()),
|
4237
|
+
family: import_zod33.z.string()
|
4134
4238
|
})
|
4135
4239
|
),
|
4136
|
-
role:
|
4137
|
-
|
4240
|
+
role: import_zod33.z.string(),
|
4241
|
+
avatar: FullDocumentPath.optional(),
|
4242
|
+
signature: FullDocumentPath.optional()
|
4138
4243
|
});
|
4139
4244
|
|
4140
4245
|
// ../commons/src/events/test.utils.ts
|
4141
|
-
var
|
4142
|
-
var
|
4246
|
+
var import_lodash3 = require("lodash");
|
4247
|
+
var import_date_fns3 = require("date-fns");
|
4143
4248
|
|
4144
4249
|
// ../commons/src/field-config/field-configuration.ts
|
4145
4250
|
function createFieldConfig(fieldId, options) {
|
@@ -4819,7 +4924,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
|
|
4819
4924
|
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
4820
4925
|
title: {
|
4821
4926
|
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
4822
|
-
defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
|
4927
|
+
defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration for {applicant.name.firstname}} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
|
4823
4928
|
description: "Title of the review page"
|
4824
4929
|
},
|
4825
4930
|
fields: [
|
@@ -4958,6 +5063,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4958
5063
|
id: "applicant.address",
|
4959
5064
|
type: "ADDRESS",
|
4960
5065
|
required: true,
|
5066
|
+
secured: true,
|
4961
5067
|
conditionals: [],
|
4962
5068
|
label: {
|
4963
5069
|
defaultMessage: "Applicant's address",
|
@@ -6124,8 +6230,8 @@ var v2BirthEvent = defineConfig({
|
|
6124
6230
|
});
|
6125
6231
|
|
6126
6232
|
// ../commons/src/events/test.utils.ts
|
6127
|
-
var
|
6128
|
-
var TestUserRole =
|
6233
|
+
var import_zod34 = require("zod");
|
6234
|
+
var TestUserRole = import_zod34.z.enum([
|
6129
6235
|
"FIELD_AGENT",
|
6130
6236
|
"LOCAL_REGISTRAR",
|
6131
6237
|
"LOCAL_SYSTEM_ADMIN",
|
@@ -6280,7 +6386,11 @@ function eventPayloadGenerator(rng) {
|
|
6280
6386
|
type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
|
6281
6387
|
id
|
6282
6388
|
}),
|
6283
|
-
draft: ({
|
6389
|
+
draft: ({
|
6390
|
+
eventId,
|
6391
|
+
actionType,
|
6392
|
+
annotation
|
6393
|
+
}, input = {}) => (0, import_lodash3.merge)(
|
6284
6394
|
{
|
6285
6395
|
id: getUUID(),
|
6286
6396
|
eventId,
|
@@ -6300,7 +6410,8 @@ function eventPayloadGenerator(rng) {
|
|
6300
6410
|
},
|
6301
6411
|
annotation: {
|
6302
6412
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
6303
|
-
"correction.request.reason": "Child's name was incorrect"
|
6413
|
+
"correction.request.reason": "Child's name was incorrect",
|
6414
|
+
...annotation
|
6304
6415
|
},
|
6305
6416
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
6306
6417
|
createdBy: "@todo",
|
@@ -6334,13 +6445,13 @@ function eventPayloadGenerator(rng) {
|
|
6334
6445
|
notify: (eventId, input = {}) => {
|
6335
6446
|
let declaration = input.declaration;
|
6336
6447
|
if (!declaration) {
|
6337
|
-
const partialDeclaration = (0,
|
6448
|
+
const partialDeclaration = (0, import_lodash3.omitBy)(
|
6338
6449
|
generateActionDeclarationInput(
|
6339
6450
|
tennisClubMembershipEvent,
|
6340
6451
|
ActionType.DECLARE,
|
6341
6452
|
rng
|
6342
6453
|
),
|
6343
|
-
|
6454
|
+
import_lodash3.isString
|
6344
6455
|
);
|
6345
6456
|
declaration = partialDeclaration;
|
6346
6457
|
}
|
@@ -6490,17 +6601,18 @@ function generateActionDocument({
|
|
6490
6601
|
configuration,
|
6491
6602
|
action,
|
6492
6603
|
rng = () => 0.1,
|
6493
|
-
defaults = {}
|
6604
|
+
defaults = {},
|
6605
|
+
user: user2 = {}
|
6494
6606
|
}) {
|
6495
6607
|
const actionBase = {
|
6496
6608
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
6497
6609
|
// @TODO: This should be fixed in the future.
|
6498
6610
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
6499
|
-
createdBy: getUUID(),
|
6611
|
+
createdBy: user2.id ?? getUUID(),
|
6500
6612
|
createdByUserType: TokenUserType.Enum.user,
|
6501
6613
|
createdByRole: TestUserRole.Enum.FIELD_AGENT,
|
6502
6614
|
id: getUUID(),
|
6503
|
-
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
6615
|
+
createdAtLocation: user2.primaryOfficeId ?? "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
6504
6616
|
declaration: generateActionDeclarationInput(configuration, action, rng),
|
6505
6617
|
annotation: {},
|
6506
6618
|
status: ActionStatus.Accepted,
|
@@ -6515,7 +6627,7 @@ function generateActionDocument({
|
|
6515
6627
|
case ActionType.DECLARE:
|
6516
6628
|
return { ...actionBase, type: action };
|
6517
6629
|
case ActionType.UNASSIGN:
|
6518
|
-
return { ...actionBase, type: action
|
6630
|
+
return { ...actionBase, type: action };
|
6519
6631
|
case ActionType.ASSIGN:
|
6520
6632
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
6521
6633
|
case ActionType.VALIDATE:
|
@@ -6554,13 +6666,14 @@ function generateActionDocument({
|
|
6554
6666
|
function generateEventDocument({
|
6555
6667
|
configuration,
|
6556
6668
|
actions,
|
6557
|
-
rng = () => 0.1
|
6669
|
+
rng = () => 0.1,
|
6670
|
+
user: user2
|
6558
6671
|
}) {
|
6559
6672
|
return {
|
6560
6673
|
trackingId: getUUID(),
|
6561
6674
|
type: configuration.id,
|
6562
6675
|
actions: actions.map(
|
6563
|
-
(action) => generateActionDocument({ configuration, action, rng })
|
6676
|
+
(action) => generateActionDocument({ configuration, action, rng, user: user2 })
|
6564
6677
|
),
|
6565
6678
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
6566
6679
|
// @TODO: This should be fixed in the future.
|
@@ -6628,7 +6741,7 @@ function createPrng(seed) {
|
|
6628
6741
|
return state / MODULUS;
|
6629
6742
|
};
|
6630
6743
|
}
|
6631
|
-
function generateUuid(rng) {
|
6744
|
+
function generateUuid(rng = () => 0.1) {
|
6632
6745
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
6633
6746
|
const r = Math.floor(rng() * 16);
|
6634
6747
|
const v = c === "x" ? r : r & 3 | 8;
|
@@ -6640,6 +6753,11 @@ function generateTrackingId(rng) {
|
|
6640
6753
|
const trackingId = uuid.slice(0, 6).toUpperCase();
|
6641
6754
|
return trackingId;
|
6642
6755
|
}
|
6756
|
+
function generateRegistrationNumber(rng) {
|
6757
|
+
const uuid = generateUuid(rng).replace(/-/g, "");
|
6758
|
+
const registrationNumber = uuid.slice(0, 12).toUpperCase();
|
6759
|
+
return registrationNumber;
|
6760
|
+
}
|
6643
6761
|
function generateRandomSignature(rng) {
|
6644
6762
|
return `/random-bucket/${generateUuid(rng)}.png`;
|
6645
6763
|
}
|
@@ -6660,7 +6778,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
6660
6778
|
createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
|
6661
6779
|
updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
|
6662
6780
|
createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
|
6663
|
-
updatedAt: overrides.updatedAt ?? (0,
|
6781
|
+
updatedAt: overrides.updatedAt ?? (0, import_date_fns3.addDays)(new Date(createdAt), 1).toISOString(),
|
6664
6782
|
assignedTo: overrides.assignedTo ?? null,
|
6665
6783
|
updatedBy: overrides.updatedBy ?? generateUuid(rng),
|
6666
6784
|
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
@@ -6732,7 +6850,7 @@ function isFieldConfigDefaultValue(value) {
|
|
6732
6850
|
}
|
6733
6851
|
|
6734
6852
|
// ../commons/src/events/scopes.ts
|
6735
|
-
var
|
6853
|
+
var import_lodash4 = require("lodash");
|
6736
6854
|
var CONFIG_GET_ALLOWED_SCOPES = [
|
6737
6855
|
SCOPES.RECORD_DECLARE,
|
6738
6856
|
SCOPES.RECORD_READ,
|
@@ -6816,19 +6934,19 @@ var WRITE_ACTION_SCOPES = [
|
|
6816
6934
|
...ACTION_ALLOWED_SCOPES[ActionType.PRINT_CERTIFICATE]
|
6817
6935
|
];
|
6818
6936
|
function hasAnyOfScopes(a, b) {
|
6819
|
-
return (0,
|
6937
|
+
return (0, import_lodash4.intersection)(a, b).length > 0;
|
6820
6938
|
}
|
6821
6939
|
|
6822
6940
|
// ../commons/src/events/serializers/user/deserializer.ts
|
6823
|
-
var
|
6941
|
+
var import_zod35 = require("zod");
|
6824
6942
|
var UserWithPrimaryOffice = User.extend({
|
6825
|
-
primaryOfficeId:
|
6943
|
+
primaryOfficeId: import_zod35.z.string()
|
6826
6944
|
});
|
6827
6945
|
function userDeserializer(serializedUserField, user2) {
|
6828
6946
|
if (typeof serializedUserField === "string") {
|
6829
6947
|
return serializedUserField;
|
6830
6948
|
}
|
6831
|
-
if (serializedUserField.$userField === "name" || serializedUserField.$userField === "
|
6949
|
+
if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signature" || serializedUserField.$userField === "avatar") {
|
6832
6950
|
throw new Error(
|
6833
6951
|
`Deserializer for ${serializedUserField.$userField} is not implemented yet`
|
6834
6952
|
);
|