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