@opencrvs/toolkit 1.8.0-rc.f9d33b7 → 1.8.0-rc.f9fb039
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 +920 -287
- package/dist/commons/events/ActionConfig.d.ts +12137 -1475
- package/dist/commons/events/ActionDocument.d.ts +433 -413
- package/dist/commons/events/ActionInput.d.ts +180 -180
- package/dist/commons/events/AdvancedSearchConfig.d.ts +212 -48
- package/dist/commons/events/Draft.d.ts +24 -26
- package/dist/commons/events/EventConfig.d.ts +6173 -1007
- package/dist/commons/events/EventDocument.d.ts +247 -312
- package/dist/commons/events/EventIndex.d.ts +710 -45
- package/dist/commons/events/EventMetadata.d.ts +263 -11
- package/dist/commons/events/FieldConfig.d.ts +850 -69
- package/dist/commons/events/FieldType.d.ts +3 -2
- package/dist/commons/events/FieldTypeMapping.d.ts +11 -4
- package/dist/commons/events/FieldValue.d.ts +6 -3
- package/dist/commons/events/FormConfig.d.ts +5749 -925
- package/dist/commons/events/PageConfig.d.ts +1191 -3
- package/dist/commons/events/WorkqueueConfig.d.ts +1362 -8
- package/dist/commons/events/defineConfig.d.ts +533 -3
- package/dist/commons/events/event.d.ts +37 -8
- package/dist/commons/events/field.d.ts +19 -10
- package/dist/commons/events/test.utils.d.ts +7 -7
- package/dist/commons/events/utils.d.ts +308 -21
- package/dist/events/index.js +1016 -724
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -36,6 +36,7 @@ __export(events_exports, {
|
|
36
36
|
ActionConditional: () => ActionConditional,
|
37
37
|
ActionConfig: () => ActionConfig,
|
38
38
|
ActionConfigBase: () => ActionConfigBase,
|
39
|
+
ActionCreationMetadata: () => ActionCreationMetadata,
|
39
40
|
ActionDocument: () => ActionDocument,
|
40
41
|
ActionFormConfig: () => ActionFormConfig,
|
41
42
|
ActionInput: () => ActionInput,
|
@@ -62,9 +63,13 @@ __export(events_exports, {
|
|
62
63
|
Conditional: () => Conditional,
|
63
64
|
ConditionalType: () => ConditionalType,
|
64
65
|
ConfirmableActions: () => ConfirmableActions,
|
66
|
+
CustomFlags: () => CustomFlags,
|
67
|
+
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
65
68
|
DataEntry: () => DataEntry,
|
66
69
|
DataFieldValue: () => DataFieldValue,
|
70
|
+
DateRangeFieldValue: () => DateRangeFieldValue,
|
67
71
|
DateValue: () => DateValue,
|
72
|
+
DatetimeValue: () => DatetimeValue,
|
68
73
|
DeclarationActionConfig: () => DeclarationActionConfig,
|
69
74
|
DeclarationActions: () => DeclarationActions,
|
70
75
|
DeclarationFormConfig: () => DeclarationFormConfig,
|
@@ -86,7 +91,10 @@ __export(events_exports, {
|
|
86
91
|
EventIndex: () => EventIndex,
|
87
92
|
EventInput: () => EventInput,
|
88
93
|
EventMetadata: () => EventMetadata,
|
94
|
+
EventMetadataKeys: () => EventMetadataKeys,
|
95
|
+
EventMetadataParameter: () => EventMetadataParameter,
|
89
96
|
EventSearchIndex: () => EventSearchIndex,
|
97
|
+
EventState: () => EventState,
|
90
98
|
EventStatus: () => EventStatus,
|
91
99
|
EventStatuses: () => EventStatuses,
|
92
100
|
FieldConditional: () => FieldConditional,
|
@@ -98,6 +106,7 @@ __export(events_exports, {
|
|
98
106
|
FileFieldValue: () => FileFieldValue,
|
99
107
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
100
108
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
109
|
+
Flag: () => Flag,
|
101
110
|
FormConfig: () => FormConfig,
|
102
111
|
FormPageConfig: () => FormPageConfig,
|
103
112
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
@@ -105,8 +114,8 @@ __export(events_exports, {
|
|
105
114
|
GeographicalArea: () => GeographicalArea,
|
106
115
|
ImageMimeType: () => ImageMimeType,
|
107
116
|
LanguageConfig: () => LanguageConfig,
|
117
|
+
LegalStatuses: () => LegalStatuses,
|
108
118
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
109
|
-
MatchType: () => MatchType,
|
110
119
|
MimeType: () => MimeType,
|
111
120
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
112
121
|
NotifyActionInput: () => NotifyActionInput,
|
@@ -119,6 +128,7 @@ __export(events_exports, {
|
|
119
128
|
ReadActionInput: () => ReadActionInput,
|
120
129
|
RegisterAction: () => RegisterAction,
|
121
130
|
RegisterActionInput: () => RegisterActionInput,
|
131
|
+
RegistrationCreationMetadata: () => RegistrationCreationMetadata,
|
122
132
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
123
133
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
124
134
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
@@ -192,6 +202,7 @@ __export(events_exports, {
|
|
192
202
|
getDeclaration: () => getDeclaration,
|
193
203
|
getDeclarationFields: () => getDeclarationFields,
|
194
204
|
getDeclarationPages: () => getDeclarationPages,
|
205
|
+
getMixedPath: () => getMixedPath,
|
195
206
|
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
196
207
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
197
208
|
isAddressFieldType: () => isAddressFieldType,
|
@@ -202,6 +213,7 @@ __export(events_exports, {
|
|
202
213
|
isCountryFieldType: () => isCountryFieldType,
|
203
214
|
isDataFieldType: () => isDataFieldType,
|
204
215
|
isDateFieldType: () => isDateFieldType,
|
216
|
+
isDateRangeFieldType: () => isDateRangeFieldType,
|
205
217
|
isDividerFieldType: () => isDividerFieldType,
|
206
218
|
isEmailFieldType: () => isEmailFieldType,
|
207
219
|
isFacilityFieldType: () => isFacilityFieldType,
|
@@ -317,6 +329,7 @@ var FieldType = {
|
|
317
329
|
TEXTAREA: "TEXTAREA",
|
318
330
|
EMAIL: "EMAIL",
|
319
331
|
DATE: "DATE",
|
332
|
+
DATE_RANGE: "DATE_RANGE",
|
320
333
|
PARAGRAPH: "PARAGRAPH",
|
321
334
|
PAGE_HEADER: "PAGE_HEADER",
|
322
335
|
RADIO_GROUP: "RADIO_GROUP",
|
@@ -336,6 +349,7 @@ var FieldType = {
|
|
336
349
|
};
|
337
350
|
var fieldTypes = Object.values(FieldType);
|
338
351
|
var compositeFieldTypes = [
|
352
|
+
FieldType.DATE_RANGE,
|
339
353
|
FieldType.ADDRESS,
|
340
354
|
FieldType.FILE_WITH_OPTIONS,
|
341
355
|
FieldType.FILE
|
@@ -428,6 +442,8 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
428
442
|
var TextValue = import_zod4.z.string();
|
429
443
|
var NonEmptyTextValue = TextValue.min(1);
|
430
444
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
445
|
+
var DatetimeValue = import_zod4.z.string().datetime();
|
446
|
+
var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
|
431
447
|
var EmailValue = import_zod4.z.string().email();
|
432
448
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
433
449
|
var NumberFieldValue = import_zod4.z.number();
|
@@ -435,6 +451,7 @@ var DataFieldValue = import_zod4.z.undefined();
|
|
435
451
|
var FieldValue = import_zod4.z.union([
|
436
452
|
TextValue,
|
437
453
|
DateValue,
|
454
|
+
DateRangeFieldValue,
|
438
455
|
CheckboxFieldValue,
|
439
456
|
NumberFieldValue,
|
440
457
|
FileFieldValue,
|
@@ -447,6 +464,7 @@ var FieldValue = import_zod4.z.union([
|
|
447
464
|
var FieldUpdateValue = import_zod4.z.union([
|
448
465
|
TextValue,
|
449
466
|
DateValue,
|
467
|
+
DateRangeFieldValue,
|
450
468
|
CheckboxFieldValue,
|
451
469
|
NumberFieldValue,
|
452
470
|
FileFieldValue,
|
@@ -482,6 +500,7 @@ var BaseField = import_zod5.z.object({
|
|
482
500
|
})
|
483
501
|
).default([]).optional(),
|
484
502
|
label: TranslationConfig,
|
503
|
+
helperText: TranslationConfig.optional(),
|
485
504
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
486
505
|
});
|
487
506
|
var Divider = BaseField.extend({
|
@@ -554,6 +573,17 @@ var DateField = BaseField.extend({
|
|
554
573
|
).optional()
|
555
574
|
}).optional()
|
556
575
|
}).describe("A single date input (dd-mm-YYYY)");
|
576
|
+
var DateRangeField = BaseField.extend({
|
577
|
+
type: import_zod5.z.literal(FieldType.DATE_RANGE),
|
578
|
+
defaultValue: DateRangeFieldValue.optional(),
|
579
|
+
configuration: import_zod5.z.object({
|
580
|
+
notice: TranslationConfig.describe(
|
581
|
+
"Text to display above the date input"
|
582
|
+
).optional()
|
583
|
+
}).optional()
|
584
|
+
}).describe(
|
585
|
+
"A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
|
586
|
+
);
|
557
587
|
var HtmlFontVariant = import_zod5.z.enum([
|
558
588
|
"reg12",
|
559
589
|
"reg14",
|
@@ -693,6 +723,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
693
723
|
NumberField,
|
694
724
|
TextAreaField,
|
695
725
|
DateField,
|
726
|
+
DateRangeField,
|
696
727
|
Paragraph,
|
697
728
|
RadioGroup,
|
698
729
|
BulletList,
|
@@ -974,7 +1005,7 @@ var LanguageConfig = import_zod11.z.object({
|
|
974
1005
|
});
|
975
1006
|
|
976
1007
|
// ../commons/src/events/EventConfig.ts
|
977
|
-
var
|
1008
|
+
var import_zod17 = require("zod");
|
978
1009
|
|
979
1010
|
// ../commons/src/events/DeduplicationConfig.ts
|
980
1011
|
var import_zod12 = require("zod");
|
@@ -1072,18 +1103,26 @@ var SummaryConfig = import_zod13.z.object({
|
|
1072
1103
|
|
1073
1104
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1074
1105
|
var import_zod14 = require("zod");
|
1075
|
-
var MatchType = import_zod14.z.enum(["
|
1106
|
+
var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
|
1076
1107
|
var BaseField3 = import_zod14.z.object({
|
1077
1108
|
config: import_zod14.z.object({
|
1078
1109
|
type: MatchType.describe("Determines the type of field")
|
1079
1110
|
}),
|
1080
|
-
options: import_zod14.z.array(SelectOption).optional()
|
1111
|
+
options: import_zod14.z.array(SelectOption).optional(),
|
1112
|
+
// If we ever need to override default field conditionals in advanced search
|
1113
|
+
conditionals: import_zod14.z.array(FieldConditional).default([]).optional()
|
1081
1114
|
});
|
1082
1115
|
var FieldConfigSchema = BaseField3.extend({
|
1083
1116
|
fieldId: import_zod14.z.string(),
|
1084
1117
|
fieldType: import_zod14.z.literal("field")
|
1085
1118
|
});
|
1086
|
-
var EventFieldId = import_zod14.z.enum([
|
1119
|
+
var EventFieldId = import_zod14.z.enum([
|
1120
|
+
"trackingId",
|
1121
|
+
"status",
|
1122
|
+
"registeredAt",
|
1123
|
+
"registeredAtLocation",
|
1124
|
+
"updatedAt"
|
1125
|
+
]);
|
1087
1126
|
var EventFieldConfigSchema = BaseField3.extend({
|
1088
1127
|
fieldId: EventFieldId,
|
1089
1128
|
fieldType: import_zod14.z.literal("event")
|
@@ -1100,13 +1139,162 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1100
1139
|
// ../commons/src/events/utils.ts
|
1101
1140
|
var import_lodash = require("lodash");
|
1102
1141
|
|
1142
|
+
// ../commons/src/events/ActionDocument.ts
|
1143
|
+
var import_zod15 = require("zod");
|
1144
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1145
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
|
1146
|
+
var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
|
1147
|
+
var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
|
1148
|
+
var ActionStatus = {
|
1149
|
+
Requested: "Requested",
|
1150
|
+
Accepted: "Accepted",
|
1151
|
+
Rejected: "Rejected"
|
1152
|
+
};
|
1153
|
+
var ActionBase = import_zod15.z.object({
|
1154
|
+
id: import_zod15.z.string(),
|
1155
|
+
transactionId: import_zod15.z.string(),
|
1156
|
+
createdAt: import_zod15.z.string().datetime(),
|
1157
|
+
createdBy: import_zod15.z.string(),
|
1158
|
+
createdByRole: import_zod15.z.string(),
|
1159
|
+
declaration: ActionUpdate,
|
1160
|
+
annotation: ActionUpdate.optional(),
|
1161
|
+
createdAtLocation: import_zod15.z.string(),
|
1162
|
+
status: import_zod15.z.enum([
|
1163
|
+
ActionStatus.Requested,
|
1164
|
+
ActionStatus.Accepted,
|
1165
|
+
ActionStatus.Rejected
|
1166
|
+
]),
|
1167
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1168
|
+
originalActionId: import_zod15.z.string().optional()
|
1169
|
+
});
|
1170
|
+
var AssignedAction = ActionBase.merge(
|
1171
|
+
import_zod15.z.object({
|
1172
|
+
type: import_zod15.z.literal(ActionType.ASSIGN),
|
1173
|
+
assignedTo: import_zod15.z.string()
|
1174
|
+
})
|
1175
|
+
);
|
1176
|
+
var UnassignedAction = ActionBase.merge(
|
1177
|
+
import_zod15.z.object({
|
1178
|
+
type: import_zod15.z.literal(ActionType.UNASSIGN),
|
1179
|
+
assignedTo: import_zod15.z.literal(null)
|
1180
|
+
})
|
1181
|
+
);
|
1182
|
+
var RegisterAction = ActionBase.merge(
|
1183
|
+
import_zod15.z.object({
|
1184
|
+
type: import_zod15.z.literal(ActionType.REGISTER),
|
1185
|
+
registrationNumber: import_zod15.z.string().optional()
|
1186
|
+
})
|
1187
|
+
);
|
1188
|
+
var DeclareAction = ActionBase.merge(
|
1189
|
+
import_zod15.z.object({
|
1190
|
+
type: import_zod15.z.literal(ActionType.DECLARE)
|
1191
|
+
})
|
1192
|
+
);
|
1193
|
+
var ValidateAction = ActionBase.merge(
|
1194
|
+
import_zod15.z.object({
|
1195
|
+
type: import_zod15.z.literal(ActionType.VALIDATE)
|
1196
|
+
})
|
1197
|
+
);
|
1198
|
+
var RejectAction = ActionBase.merge(
|
1199
|
+
import_zod15.z.object({
|
1200
|
+
type: import_zod15.z.literal(ActionType.REJECT)
|
1201
|
+
})
|
1202
|
+
);
|
1203
|
+
var MarkAsDuplicateAction = ActionBase.merge(
|
1204
|
+
import_zod15.z.object({
|
1205
|
+
type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1206
|
+
})
|
1207
|
+
);
|
1208
|
+
var ArchiveAction = ActionBase.merge(
|
1209
|
+
import_zod15.z.object({
|
1210
|
+
type: import_zod15.z.literal(ActionType.ARCHIVE)
|
1211
|
+
})
|
1212
|
+
);
|
1213
|
+
var CreatedAction = ActionBase.merge(
|
1214
|
+
import_zod15.z.object({
|
1215
|
+
type: import_zod15.z.literal(ActionType.CREATE)
|
1216
|
+
})
|
1217
|
+
);
|
1218
|
+
var NotifiedAction = ActionBase.merge(
|
1219
|
+
import_zod15.z.object({
|
1220
|
+
type: import_zod15.z.literal(ActionType.NOTIFY)
|
1221
|
+
})
|
1222
|
+
);
|
1223
|
+
var PrintCertificateAction = ActionBase.merge(
|
1224
|
+
import_zod15.z.object({
|
1225
|
+
type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
|
1226
|
+
})
|
1227
|
+
);
|
1228
|
+
var RequestedCorrectionAction = ActionBase.merge(
|
1229
|
+
import_zod15.z.object({
|
1230
|
+
type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
|
1231
|
+
})
|
1232
|
+
);
|
1233
|
+
var ApprovedCorrectionAction = ActionBase.merge(
|
1234
|
+
import_zod15.z.object({
|
1235
|
+
type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
|
1236
|
+
requestId: import_zod15.z.string()
|
1237
|
+
})
|
1238
|
+
);
|
1239
|
+
var RejectedCorrectionAction = ActionBase.merge(
|
1240
|
+
import_zod15.z.object({
|
1241
|
+
type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
|
1242
|
+
requestId: import_zod15.z.string()
|
1243
|
+
})
|
1244
|
+
);
|
1245
|
+
var ReadAction = ActionBase.merge(
|
1246
|
+
import_zod15.z.object({
|
1247
|
+
type: import_zod15.z.literal(ActionType.READ)
|
1248
|
+
})
|
1249
|
+
);
|
1250
|
+
var ActionDocument = import_zod15.z.discriminatedUnion("type", [
|
1251
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1252
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1253
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1254
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1255
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1256
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1257
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1258
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1259
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1260
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1261
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1262
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1263
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1264
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1265
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1266
|
+
]).openapi({
|
1267
|
+
ref: "ActionDocument"
|
1268
|
+
});
|
1269
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1270
|
+
declaration: true,
|
1271
|
+
annotation: true
|
1272
|
+
}).merge(
|
1273
|
+
import_zod15.z.object({
|
1274
|
+
type: import_zod15.z.enum(ConfirmableActions),
|
1275
|
+
status: import_zod15.z.literal(ActionStatus.Rejected)
|
1276
|
+
})
|
1277
|
+
);
|
1278
|
+
var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1279
|
+
var ResolvedUser = import_zod15.z.object({
|
1280
|
+
id: import_zod15.z.string(),
|
1281
|
+
role: import_zod15.z.string(),
|
1282
|
+
name: import_zod15.z.array(
|
1283
|
+
import_zod15.z.object({
|
1284
|
+
use: import_zod15.z.string(),
|
1285
|
+
given: import_zod15.z.array(import_zod15.z.string()),
|
1286
|
+
family: import_zod15.z.string()
|
1287
|
+
})
|
1288
|
+
)
|
1289
|
+
});
|
1290
|
+
|
1103
1291
|
// ../commons/src/conditionals/validate.ts
|
1104
1292
|
var import_ajv = __toESM(require("ajv"));
|
1105
1293
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1106
1294
|
var import_date_fns = require("date-fns");
|
1107
1295
|
|
1108
1296
|
// ../commons/src/events/FieldTypeMapping.ts
|
1109
|
-
var
|
1297
|
+
var import_zod16 = require("zod");
|
1110
1298
|
function mapFieldTypeToZod(type, required) {
|
1111
1299
|
let schema;
|
1112
1300
|
switch (type) {
|
@@ -1116,6 +1304,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1116
1304
|
case FieldType.EMAIL:
|
1117
1305
|
schema = EmailValue;
|
1118
1306
|
break;
|
1307
|
+
case FieldType.DATE_RANGE:
|
1308
|
+
schema = DateRangeFieldValue;
|
1309
|
+
break;
|
1119
1310
|
case FieldType.TEXT:
|
1120
1311
|
case FieldType.TEXTAREA:
|
1121
1312
|
case FieldType.DIVIDER:
|
@@ -1158,7 +1349,7 @@ function createValidationSchema(config) {
|
|
1158
1349
|
for (const field2 of config) {
|
1159
1350
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1160
1351
|
}
|
1161
|
-
return
|
1352
|
+
return import_zod16.z.object(shape);
|
1162
1353
|
}
|
1163
1354
|
function mapFieldTypeToMockValue(field2, i) {
|
1164
1355
|
switch (field2.type) {
|
@@ -1196,6 +1387,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1196
1387
|
};
|
1197
1388
|
case FieldType.DATE:
|
1198
1389
|
return "2021-01-01";
|
1390
|
+
case FieldType.DATE_RANGE:
|
1391
|
+
return ["2021-01-01", "2021-01-02"];
|
1199
1392
|
case FieldType.CHECKBOX:
|
1200
1393
|
return true;
|
1201
1394
|
case FieldType.FILE:
|
@@ -1230,6 +1423,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1230
1423
|
case FieldType.EMAIL:
|
1231
1424
|
case FieldType.DATE:
|
1232
1425
|
case FieldType.CHECKBOX:
|
1426
|
+
case FieldType.DATE_RANGE:
|
1233
1427
|
case FieldType.DATA:
|
1234
1428
|
return null;
|
1235
1429
|
case FieldType.ADDRESS:
|
@@ -1262,6 +1456,9 @@ var isParagraphFieldType = (field2) => {
|
|
1262
1456
|
var isDateFieldType = (field2) => {
|
1263
1457
|
return field2.config.type === FieldType.DATE;
|
1264
1458
|
};
|
1459
|
+
var isDateRangeFieldType = (field2) => {
|
1460
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1461
|
+
};
|
1265
1462
|
var isPageHeaderFieldType = (field2) => {
|
1266
1463
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1267
1464
|
};
|
@@ -1604,7 +1801,10 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1604
1801
|
annotation: {},
|
1605
1802
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1606
1803
|
createdBy: "@todo",
|
1607
|
-
createdAtLocation: "@todo"
|
1804
|
+
createdAtLocation: "@todo",
|
1805
|
+
status: ActionStatus.Accepted,
|
1806
|
+
transactionId: "@todo",
|
1807
|
+
createdByRole: "@todo"
|
1608
1808
|
}
|
1609
1809
|
};
|
1610
1810
|
}
|
@@ -1676,25 +1876,43 @@ var findAllFields = (config) => {
|
|
1676
1876
|
...getAllAnnotationFields(config)
|
1677
1877
|
]);
|
1678
1878
|
};
|
1879
|
+
function getMixedPath(obj, path, defaultValue) {
|
1880
|
+
const parts = path.split(".");
|
1881
|
+
const resolve = (current, segments) => {
|
1882
|
+
if (current == null || segments.length === 0) {
|
1883
|
+
return current;
|
1884
|
+
}
|
1885
|
+
for (let i = segments.length; i > 0; i--) {
|
1886
|
+
const compoundKey = segments.slice(0, i).join(".");
|
1887
|
+
if ((0, import_lodash.has)(current, compoundKey)) {
|
1888
|
+
const next = (0, import_lodash.get)(current, compoundKey);
|
1889
|
+
return resolve(next, segments.slice(i));
|
1890
|
+
}
|
1891
|
+
}
|
1892
|
+
return void 0;
|
1893
|
+
};
|
1894
|
+
const result = resolve(obj, parts);
|
1895
|
+
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
1896
|
+
}
|
1679
1897
|
|
1680
1898
|
// ../commons/src/events/EventConfig.ts
|
1681
|
-
var
|
1682
|
-
(0,
|
1683
|
-
var EventConfig =
|
1684
|
-
id:
|
1899
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1900
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
|
1901
|
+
var EventConfig = import_zod17.z.object({
|
1902
|
+
id: import_zod17.z.string().describe(
|
1685
1903
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1686
1904
|
),
|
1687
|
-
dateOfEvent:
|
1905
|
+
dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
|
1688
1906
|
title: TranslationConfig,
|
1689
1907
|
fallbackTitle: TranslationConfig.optional().describe(
|
1690
1908
|
"This is a fallback title if actual title resolves to empty string"
|
1691
1909
|
),
|
1692
1910
|
summary: SummaryConfig,
|
1693
1911
|
label: TranslationConfig,
|
1694
|
-
actions:
|
1912
|
+
actions: import_zod17.z.array(ActionConfig),
|
1695
1913
|
declaration: DeclarationFormConfig,
|
1696
|
-
deduplication:
|
1697
|
-
advancedSearch:
|
1914
|
+
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1915
|
+
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1698
1916
|
}).superRefine((event2, ctx) => {
|
1699
1917
|
const allFields = findAllFields(event2);
|
1700
1918
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1756,350 +1974,92 @@ var definePage = (page) => PageConfig.parse(page);
|
|
1756
1974
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1757
1975
|
|
1758
1976
|
// ../commons/src/events/WorkqueueConfig.ts
|
1759
|
-
var import_zod17 = require("zod");
|
1760
|
-
var WorkqueueConfig = import_zod17.z.object({
|
1761
|
-
slug: import_zod17.z.string().describe("Determines the url of the workqueue."),
|
1762
|
-
name: TranslationConfig.describe(
|
1763
|
-
"Title of the workflow (both in navigation and on the page)"
|
1764
|
-
),
|
1765
|
-
/**
|
1766
|
-
* Placeholder untill the following gets merged to develop
|
1767
|
-
* https://github.com/opencrvs/opencrvs-core/blob/5fbe9854a88504a7a13fcc856b3e82594b70c38c/packages/commons/src/events/EventIndex.ts#L92-L93
|
1768
|
-
*/
|
1769
|
-
query: import_zod17.z.string(),
|
1770
|
-
actions: import_zod17.z.array(
|
1771
|
-
import_zod17.z.object({
|
1772
|
-
type: import_zod17.z.string(),
|
1773
|
-
conditionals: import_zod17.z.array(Conditional).optional()
|
1774
|
-
})
|
1775
|
-
)
|
1776
|
-
}).describe("Configuration for workqueue.");
|
1777
|
-
function defineWorkqueue(workqueues) {
|
1778
|
-
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
1779
|
-
}
|
1780
|
-
|
1781
|
-
// ../commons/src/events/Draft.ts
|
1782
1977
|
var import_zod20 = require("zod");
|
1783
1978
|
|
1784
|
-
// ../commons/src/events/
|
1979
|
+
// ../commons/src/events/EventIndex.ts
|
1980
|
+
var import_zod19 = require("zod");
|
1981
|
+
|
1982
|
+
// ../commons/src/events/EventMetadata.ts
|
1785
1983
|
var import_zod18 = require("zod");
|
1786
|
-
var
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1984
|
+
var EventStatus = {
|
1985
|
+
CREATED: "CREATED",
|
1986
|
+
NOTIFIED: "NOTIFIED",
|
1987
|
+
DECLARED: "DECLARED",
|
1988
|
+
VALIDATED: "VALIDATED",
|
1989
|
+
REGISTERED: "REGISTERED",
|
1990
|
+
CERTIFIED: "CERTIFIED",
|
1991
|
+
REJECTED: "REJECTED",
|
1992
|
+
ARCHIVED: "ARCHIVED"
|
1793
1993
|
};
|
1794
|
-
var
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1994
|
+
var CustomFlags = {
|
1995
|
+
CERTIFICATE_PRINTED: "certificate-printed"
|
1996
|
+
};
|
1997
|
+
var Flag = import_zod18.z.string().regex(
|
1998
|
+
new RegExp(
|
1999
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
|
2000
|
+
),
|
2001
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2002
|
+
).or(import_zod18.z.nativeEnum(CustomFlags));
|
2003
|
+
var eventStatuses = Object.values(EventStatus);
|
2004
|
+
var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
|
2005
|
+
var ZodDate = import_zod18.z.string().date();
|
2006
|
+
var ActionCreationMetadata = import_zod18.z.object({
|
2007
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
|
2008
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
|
2009
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
|
2010
|
+
acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
2011
|
+
createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
|
1811
2012
|
});
|
1812
|
-
var
|
1813
|
-
import_zod18.z.
|
1814
|
-
|
1815
|
-
|
1816
|
-
})
|
1817
|
-
);
|
1818
|
-
var UnassignedAction = ActionBase.merge(
|
1819
|
-
import_zod18.z.object({
|
1820
|
-
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1821
|
-
assignedTo: import_zod18.z.literal(null)
|
1822
|
-
})
|
1823
|
-
);
|
1824
|
-
var RegisterAction = ActionBase.merge(
|
1825
|
-
import_zod18.z.object({
|
1826
|
-
type: import_zod18.z.literal(ActionType.REGISTER),
|
1827
|
-
registrationNumber: import_zod18.z.string().optional()
|
1828
|
-
})
|
1829
|
-
);
|
1830
|
-
var DeclareAction = ActionBase.merge(
|
1831
|
-
import_zod18.z.object({
|
1832
|
-
type: import_zod18.z.literal(ActionType.DECLARE)
|
1833
|
-
})
|
1834
|
-
);
|
1835
|
-
var ValidateAction = ActionBase.merge(
|
1836
|
-
import_zod18.z.object({
|
1837
|
-
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1838
|
-
})
|
1839
|
-
);
|
1840
|
-
var RejectAction = ActionBase.merge(
|
1841
|
-
import_zod18.z.object({
|
1842
|
-
type: import_zod18.z.literal(ActionType.REJECT)
|
1843
|
-
})
|
1844
|
-
);
|
1845
|
-
var MarkAsDuplicateAction = ActionBase.merge(
|
1846
|
-
import_zod18.z.object({
|
1847
|
-
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1848
|
-
})
|
1849
|
-
);
|
1850
|
-
var ArchiveAction = ActionBase.merge(
|
1851
|
-
import_zod18.z.object({
|
1852
|
-
type: import_zod18.z.literal(ActionType.ARCHIVE)
|
1853
|
-
})
|
1854
|
-
);
|
1855
|
-
var CreatedAction = ActionBase.merge(
|
1856
|
-
import_zod18.z.object({
|
1857
|
-
type: import_zod18.z.literal(ActionType.CREATE)
|
1858
|
-
})
|
1859
|
-
);
|
1860
|
-
var NotifiedAction = ActionBase.merge(
|
1861
|
-
import_zod18.z.object({
|
1862
|
-
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1863
|
-
})
|
1864
|
-
);
|
1865
|
-
var PrintCertificateAction = ActionBase.merge(
|
1866
|
-
import_zod18.z.object({
|
1867
|
-
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1868
|
-
})
|
1869
|
-
);
|
1870
|
-
var RequestedCorrectionAction = ActionBase.merge(
|
1871
|
-
import_zod18.z.object({
|
1872
|
-
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1873
|
-
})
|
1874
|
-
);
|
1875
|
-
var ApprovedCorrectionAction = ActionBase.merge(
|
1876
|
-
import_zod18.z.object({
|
1877
|
-
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1878
|
-
requestId: import_zod18.z.string()
|
1879
|
-
})
|
1880
|
-
);
|
1881
|
-
var RejectedCorrectionAction = ActionBase.merge(
|
1882
|
-
import_zod18.z.object({
|
1883
|
-
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1884
|
-
requestId: import_zod18.z.string()
|
1885
|
-
})
|
1886
|
-
);
|
1887
|
-
var ReadAction = ActionBase.merge(
|
1888
|
-
import_zod18.z.object({
|
1889
|
-
type: import_zod18.z.literal(ActionType.READ)
|
1890
|
-
})
|
1891
|
-
);
|
1892
|
-
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1893
|
-
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1894
|
-
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1895
|
-
RejectAction.openapi({ ref: "RejectAction" }),
|
1896
|
-
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1897
|
-
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1898
|
-
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1899
|
-
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1900
|
-
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1901
|
-
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1902
|
-
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1903
|
-
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1904
|
-
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1905
|
-
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1906
|
-
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1907
|
-
ReadAction.openapi({ ref: "ReadAction" })
|
1908
|
-
]).openapi({
|
1909
|
-
ref: "ActionDocument"
|
2013
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2014
|
+
registrationNumber: import_zod18.z.string().describe(
|
2015
|
+
"Registration number of the event. Always present for accepted registrations."
|
2016
|
+
)
|
1910
2017
|
});
|
1911
|
-
var
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
createdAtLocation: true
|
1917
|
-
}).merge(
|
1918
|
-
import_zod18.z.object({
|
1919
|
-
type: import_zod18.z.enum(ConfirmableActions),
|
1920
|
-
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1921
|
-
})
|
1922
|
-
);
|
1923
|
-
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1924
|
-
var ResolvedUser = import_zod18.z.object({
|
2018
|
+
var LegalStatuses = import_zod18.z.object({
|
2019
|
+
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2020
|
+
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2021
|
+
});
|
2022
|
+
var EventMetadata = import_zod18.z.object({
|
1925
2023
|
id: import_zod18.z.string(),
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
)
|
2024
|
+
type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
|
2025
|
+
status: EventStatuses,
|
2026
|
+
legalStatuses: LegalStatuses.describe(
|
2027
|
+
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2028
|
+
),
|
2029
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2030
|
+
dateOfEvent: ZodDate.nullish(),
|
2031
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
|
2032
|
+
updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
|
2033
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
|
2034
|
+
updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
|
2035
|
+
updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
|
2036
|
+
assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
2037
|
+
updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
|
2038
|
+
trackingId: import_zod18.z.string().describe(
|
2039
|
+
"System-generated tracking ID used by informants or registrars to look up the event."
|
2040
|
+
),
|
2041
|
+
flags: import_zod18.z.array(Flag)
|
1934
2042
|
});
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
import_zod19.z.object({
|
1956
|
-
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1957
|
-
registrationNumber: import_zod19.z.string().optional()
|
1958
|
-
})
|
1959
|
-
);
|
1960
|
-
var ValidateActionInput = BaseActionInput.merge(
|
1961
|
-
import_zod19.z.object({
|
1962
|
-
type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1963
|
-
duplicates: import_zod19.z.array(import_zod19.z.string())
|
1964
|
-
})
|
1965
|
-
);
|
1966
|
-
var NotifyActionInput = BaseActionInput.merge(
|
1967
|
-
import_zod19.z.object({
|
1968
|
-
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1969
|
-
})
|
1970
|
-
);
|
1971
|
-
var DeclareActionInput = BaseActionInput.merge(
|
1972
|
-
import_zod19.z.object({
|
1973
|
-
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1974
|
-
})
|
1975
|
-
);
|
1976
|
-
var PrintCertificateActionInput = BaseActionInput.merge(
|
1977
|
-
import_zod19.z.object({
|
1978
|
-
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1979
|
-
})
|
1980
|
-
);
|
1981
|
-
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1982
|
-
import_zod19.z.object({
|
1983
|
-
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1984
|
-
})
|
1985
|
-
);
|
1986
|
-
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1987
|
-
import_zod19.z.object({
|
1988
|
-
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1989
|
-
})
|
1990
|
-
);
|
1991
|
-
var ArchiveActionInput = BaseActionInput.merge(
|
1992
|
-
import_zod19.z.object({
|
1993
|
-
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1994
|
-
})
|
1995
|
-
);
|
1996
|
-
var AssignActionInput = BaseActionInput.merge(
|
1997
|
-
import_zod19.z.object({
|
1998
|
-
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1999
|
-
assignedTo: import_zod19.z.string()
|
2000
|
-
})
|
2001
|
-
);
|
2002
|
-
var UnassignActionInput = BaseActionInput.merge(
|
2003
|
-
import_zod19.z.object({
|
2004
|
-
type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2005
|
-
assignedTo: import_zod19.z.literal(null).default(null)
|
2006
|
-
})
|
2007
|
-
);
|
2008
|
-
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2009
|
-
import_zod19.z.object({
|
2010
|
-
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2011
|
-
})
|
2012
|
-
);
|
2013
|
-
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2014
|
-
import_zod19.z.object({
|
2015
|
-
requestId: import_zod19.z.string(),
|
2016
|
-
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2017
|
-
})
|
2018
|
-
);
|
2019
|
-
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2020
|
-
import_zod19.z.object({
|
2021
|
-
requestId: import_zod19.z.string(),
|
2022
|
-
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2023
|
-
})
|
2024
|
-
);
|
2025
|
-
var ReadActionInput = BaseActionInput.merge(
|
2026
|
-
import_zod19.z.object({
|
2027
|
-
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
2028
|
-
})
|
2029
|
-
);
|
2030
|
-
var DeleteActionInput = import_zod19.z.object({ eventId: import_zod19.z.string() });
|
2031
|
-
var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
2032
|
-
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2033
|
-
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2034
|
-
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2035
|
-
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2036
|
-
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2037
|
-
RejectDeclarationActionInput.openapi({
|
2038
|
-
ref: "RejectDeclarationActionInput"
|
2039
|
-
}),
|
2040
|
-
MarkedAsDuplicateActionInput.openapi({
|
2041
|
-
ref: "MarkedAsDuplicateActionInput"
|
2042
|
-
}),
|
2043
|
-
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2044
|
-
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2045
|
-
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2046
|
-
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2047
|
-
RequestCorrectionActionInput.openapi({
|
2048
|
-
ref: "RequestCorrectionActionInput"
|
2049
|
-
}),
|
2050
|
-
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2051
|
-
ApproveCorrectionActionInput.openapi({
|
2052
|
-
ref: "ApproveCorrectionActionInput"
|
2053
|
-
}),
|
2054
|
-
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2055
|
-
]).openapi({
|
2056
|
-
ref: "ActionInput"
|
2057
|
-
});
|
2058
|
-
|
2059
|
-
// ../commons/src/events/Draft.ts
|
2060
|
-
var Draft = import_zod20.z.object({
|
2061
|
-
id: import_zod20.z.string(),
|
2062
|
-
eventId: import_zod20.z.string(),
|
2063
|
-
transactionId: import_zod20.z.string(),
|
2064
|
-
createdAt: import_zod20.z.string().datetime(),
|
2065
|
-
action: ActionBase.extend({
|
2066
|
-
type: ActionTypes
|
2067
|
-
}).omit({ id: true })
|
2068
|
-
});
|
2069
|
-
var DraftInput = BaseActionInput.extend({
|
2070
|
-
type: ActionTypes
|
2071
|
-
});
|
2072
|
-
|
2073
|
-
// ../commons/src/events/EventMetadata.ts
|
2074
|
-
var import_zod21 = require("zod");
|
2075
|
-
var EventStatus = {
|
2076
|
-
CREATED: "CREATED",
|
2077
|
-
NOTIFIED: "NOTIFIED",
|
2078
|
-
DECLARED: "DECLARED",
|
2079
|
-
VALIDATED: "VALIDATED",
|
2080
|
-
REGISTERED: "REGISTERED",
|
2081
|
-
CERTIFIED: "CERTIFIED",
|
2082
|
-
REJECTED: "REJECTED",
|
2083
|
-
ARCHIVED: "ARCHIVED"
|
2084
|
-
};
|
2085
|
-
var eventStatuses = Object.values(EventStatus);
|
2086
|
-
var EventStatuses = import_zod21.z.nativeEnum(EventStatus);
|
2087
|
-
var ZodDate = import_zod21.z.string().date();
|
2088
|
-
var EventMetadata = import_zod21.z.object({
|
2089
|
-
id: import_zod21.z.string(),
|
2090
|
-
type: import_zod21.z.string(),
|
2091
|
-
status: EventStatuses,
|
2092
|
-
createdAt: import_zod21.z.string().datetime(),
|
2093
|
-
dateOfEvent: ZodDate.nullish(),
|
2094
|
-
createdBy: import_zod21.z.string(),
|
2095
|
-
updatedByUserRole: import_zod21.z.string(),
|
2096
|
-
createdAtLocation: import_zod21.z.string(),
|
2097
|
-
updatedAtLocation: import_zod21.z.string(),
|
2098
|
-
updatedAt: import_zod21.z.string().datetime(),
|
2099
|
-
assignedTo: import_zod21.z.string().nullish(),
|
2100
|
-
updatedBy: import_zod21.z.string(),
|
2101
|
-
trackingId: import_zod21.z.string(),
|
2102
|
-
registrationNumber: import_zod21.z.string().nullish()
|
2043
|
+
var EventMetadataKeys = import_zod18.z.enum([
|
2044
|
+
"id",
|
2045
|
+
"type",
|
2046
|
+
"status",
|
2047
|
+
"createdAt",
|
2048
|
+
"dateOfEvent",
|
2049
|
+
"createdBy",
|
2050
|
+
"updatedByUserRole",
|
2051
|
+
"createdAtLocation",
|
2052
|
+
"updatedAtLocation",
|
2053
|
+
"updatedAt",
|
2054
|
+
"assignedTo",
|
2055
|
+
"updatedBy",
|
2056
|
+
"trackingId",
|
2057
|
+
"legalStatuses",
|
2058
|
+
"flags"
|
2059
|
+
]);
|
2060
|
+
var EventMetadataParameter = import_zod18.z.object({
|
2061
|
+
// @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
|
2062
|
+
$event: EventMetadataKeys
|
2103
2063
|
});
|
2104
2064
|
var eventMetadataLabelMap = {
|
2105
2065
|
"event.assignedTo": {
|
@@ -2167,302 +2127,64 @@ var eventMetadataLabelMap = {
|
|
2167
2127
|
defaultMessage: "Tracking ID",
|
2168
2128
|
description: "Tracking ID"
|
2169
2129
|
},
|
2170
|
-
"event.
|
2171
|
-
id: "event.
|
2172
|
-
defaultMessage: "
|
2173
|
-
description: "
|
2130
|
+
"event.flags": {
|
2131
|
+
id: "event.flags.label",
|
2132
|
+
defaultMessage: "Flags",
|
2133
|
+
description: "Flags"
|
2174
2134
|
}
|
2175
2135
|
};
|
2176
2136
|
|
2177
|
-
// ../commons/src/events/EventInput.ts
|
2178
|
-
var import_zod22 = require("zod");
|
2179
|
-
var EventInput = import_zod22.z.object({
|
2180
|
-
transactionId: import_zod22.z.string(),
|
2181
|
-
type: import_zod22.z.string(),
|
2182
|
-
dateOfEvent: import_zod22.z.object({ fieldId: import_zod22.z.string() }).optional()
|
2183
|
-
});
|
2184
|
-
|
2185
|
-
// ../commons/src/events/EventDocument.ts
|
2186
|
-
var import_zod23 = require("zod");
|
2187
|
-
var import_zod_openapi6 = require("zod-openapi");
|
2188
|
-
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod23.z);
|
2189
|
-
var EventDocument = import_zod23.z.object({
|
2190
|
-
id: import_zod23.z.string(),
|
2191
|
-
type: import_zod23.z.string(),
|
2192
|
-
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional(),
|
2193
|
-
createdAt: import_zod23.z.string().datetime(),
|
2194
|
-
updatedAt: import_zod23.z.string().datetime(),
|
2195
|
-
updatedAtLocation: import_zod23.z.string(),
|
2196
|
-
actions: import_zod23.z.array(Action),
|
2197
|
-
trackingId: import_zod23.z.string()
|
2198
|
-
}).openapi({ ref: "EventDocument" });
|
2199
|
-
|
2200
2137
|
// ../commons/src/events/EventIndex.ts
|
2201
|
-
var import_zod24 = require("zod");
|
2202
2138
|
var EventIndex = EventMetadata.extend({
|
2203
|
-
declaration:
|
2139
|
+
declaration: EventState
|
2204
2140
|
});
|
2205
|
-
var EventSearchIndex =
|
2206
|
-
|
2207
|
-
type:
|
2141
|
+
var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
|
2142
|
+
import_zod19.z.object({
|
2143
|
+
type: import_zod19.z.string()
|
2208
2144
|
// Ensures "type" (event-id) exists and is a string
|
2209
2145
|
})
|
2210
2146
|
);
|
2211
|
-
var Fuzzy =
|
2212
|
-
var Exact =
|
2213
|
-
var AnyOf =
|
2214
|
-
type:
|
2215
|
-
terms:
|
2147
|
+
var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
|
2148
|
+
var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
|
2149
|
+
var AnyOf = import_zod19.z.object({
|
2150
|
+
type: import_zod19.z.literal("anyOf"),
|
2151
|
+
terms: import_zod19.z.array(import_zod19.z.string())
|
2216
2152
|
});
|
2217
|
-
var Range =
|
2218
|
-
type:
|
2219
|
-
gte:
|
2220
|
-
lte:
|
2153
|
+
var Range = import_zod19.z.object({
|
2154
|
+
type: import_zod19.z.literal("range"),
|
2155
|
+
gte: import_zod19.z.string(),
|
2156
|
+
lte: import_zod19.z.string()
|
2221
2157
|
});
|
2222
|
-
var
|
2223
|
-
var
|
2224
|
-
var
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2158
|
+
var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
|
2159
|
+
var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
|
2160
|
+
var DateCondition = import_zod19.z.union([Exact, Range]);
|
2161
|
+
var QueryInput = import_zod19.z.lazy(
|
2162
|
+
() => import_zod19.z.union([
|
2163
|
+
import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
2164
|
+
import_zod19.z.record(import_zod19.z.string(), QueryInput)
|
2228
2165
|
])
|
2229
2166
|
);
|
2230
|
-
var QueryExpression =
|
2231
|
-
type:
|
2232
|
-
eventType:
|
2233
|
-
status:
|
2234
|
-
createdAt:
|
2235
|
-
updatedAt:
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2167
|
+
var QueryExpression = import_zod19.z.object({
|
2168
|
+
type: import_zod19.z.literal("and"),
|
2169
|
+
eventType: import_zod19.z.string(),
|
2170
|
+
status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
|
2171
|
+
createdAt: import_zod19.z.optional(DateCondition),
|
2172
|
+
updatedAt: import_zod19.z.optional(DateCondition),
|
2173
|
+
registeredAt: import_zod19.z.optional(DateCondition),
|
2174
|
+
registeredAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2175
|
+
createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2176
|
+
updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2177
|
+
createdBy: import_zod19.z.optional(Exact),
|
2178
|
+
updatedBy: import_zod19.z.optional(Exact),
|
2179
|
+
trackingId: import_zod19.z.optional(Exact),
|
2180
|
+
flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
|
2241
2181
|
data: QueryInput
|
2242
2182
|
}).partial();
|
2243
|
-
var Or2 =
|
2244
|
-
type:
|
2245
|
-
clauses:
|
2183
|
+
var Or2 = import_zod19.z.object({
|
2184
|
+
type: import_zod19.z.literal("or"),
|
2185
|
+
clauses: import_zod19.z.array(QueryExpression)
|
2246
2186
|
});
|
2247
|
-
var QueryType =
|
2248
|
-
|
2249
|
-
// ../commons/src/events/state/index.ts
|
2250
|
-
function getStatusFromActions(actions) {
|
2251
|
-
const hasRejectedAction = actions.some(
|
2252
|
-
(a) => a.status === ActionStatus.Rejected
|
2253
|
-
);
|
2254
|
-
if (hasRejectedAction) {
|
2255
|
-
return EventStatus.REJECTED;
|
2256
|
-
}
|
2257
|
-
return actions.reduce((status, action) => {
|
2258
|
-
switch (action.type) {
|
2259
|
-
case ActionType.CREATE:
|
2260
|
-
return EventStatus.CREATED;
|
2261
|
-
case ActionType.DECLARE:
|
2262
|
-
return EventStatus.DECLARED;
|
2263
|
-
case ActionType.VALIDATE:
|
2264
|
-
return EventStatus.VALIDATED;
|
2265
|
-
case ActionType.REGISTER:
|
2266
|
-
return EventStatus.REGISTERED;
|
2267
|
-
case ActionType.REJECT:
|
2268
|
-
return EventStatus.REJECTED;
|
2269
|
-
case ActionType.ARCHIVE:
|
2270
|
-
return EventStatus.ARCHIVED;
|
2271
|
-
case ActionType.NOTIFY:
|
2272
|
-
return EventStatus.NOTIFIED;
|
2273
|
-
case ActionType.PRINT_CERTIFICATE:
|
2274
|
-
return EventStatus.CERTIFIED;
|
2275
|
-
case ActionType.ASSIGN:
|
2276
|
-
case ActionType.UNASSIGN:
|
2277
|
-
case ActionType.REQUEST_CORRECTION:
|
2278
|
-
case ActionType.APPROVE_CORRECTION:
|
2279
|
-
case ActionType.MARKED_AS_DUPLICATE:
|
2280
|
-
case ActionType.REJECT_CORRECTION:
|
2281
|
-
case ActionType.READ:
|
2282
|
-
default:
|
2283
|
-
return status;
|
2284
|
-
}
|
2285
|
-
}, EventStatus.CREATED);
|
2286
|
-
}
|
2287
|
-
function getLastUpdatedByUserRoleFromActions(actions) {
|
2288
|
-
const actionsWithRoles = actions.filter(
|
2289
|
-
(action) => !isWriteAction(action.type) && action.status !== ActionStatus.Rejected
|
2290
|
-
).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2291
|
-
const lastAction = actionsWithRoles.at(-1);
|
2292
|
-
if (!lastAction) {
|
2293
|
-
throw new Error(
|
2294
|
-
"Should never happen, at least CREATE action should be present"
|
2295
|
-
);
|
2296
|
-
}
|
2297
|
-
return ActionDocument.parse(lastAction).createdByRole;
|
2298
|
-
}
|
2299
|
-
function getAssignedUserFromActions(actions) {
|
2300
|
-
return actions.reduce((user2, action) => {
|
2301
|
-
if (action.type === ActionType.ASSIGN) {
|
2302
|
-
return action.assignedTo;
|
2303
|
-
}
|
2304
|
-
if (action.type === ActionType.UNASSIGN) {
|
2305
|
-
return null;
|
2306
|
-
}
|
2307
|
-
return user2;
|
2308
|
-
}, null);
|
2309
|
-
}
|
2310
|
-
function aggregateActionDeclarations(actions) {
|
2311
|
-
const excludedActions = [
|
2312
|
-
ActionType.REQUEST_CORRECTION,
|
2313
|
-
ActionType.PRINT_CERTIFICATE
|
2314
|
-
];
|
2315
|
-
return actions.reduce((status, action) => {
|
2316
|
-
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2317
|
-
return status;
|
2318
|
-
}
|
2319
|
-
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2320
|
-
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2321
|
-
if (!requestAction) {
|
2322
|
-
return status;
|
2323
|
-
}
|
2324
|
-
return deepMerge(status, requestAction.declaration);
|
2325
|
-
}
|
2326
|
-
return deepMerge(status, action.declaration);
|
2327
|
-
}, {});
|
2328
|
-
}
|
2329
|
-
function deepDropNulls(obj) {
|
2330
|
-
if (Array.isArray(obj)) {
|
2331
|
-
return obj.map(deepDropNulls);
|
2332
|
-
}
|
2333
|
-
if (obj !== null && typeof obj === "object") {
|
2334
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2335
|
-
const cleanedValue = deepDropNulls(value);
|
2336
|
-
if (cleanedValue !== null) {
|
2337
|
-
;
|
2338
|
-
acc[key] = cleanedValue;
|
2339
|
-
}
|
2340
|
-
return acc;
|
2341
|
-
}, {});
|
2342
|
-
}
|
2343
|
-
return obj;
|
2344
|
-
}
|
2345
|
-
function isUndeclaredDraft(status) {
|
2346
|
-
return status === EventStatus.CREATED;
|
2347
|
-
}
|
2348
|
-
function getAcceptedActions(event2) {
|
2349
|
-
return event2.actions.filter(
|
2350
|
-
(a) => a.status === ActionStatus.Accepted
|
2351
|
-
);
|
2352
|
-
}
|
2353
|
-
function getCurrentEventState(event2) {
|
2354
|
-
const creationAction = event2.actions.find(
|
2355
|
-
(action) => action.type === ActionType.CREATE
|
2356
|
-
);
|
2357
|
-
if (!creationAction) {
|
2358
|
-
throw new Error(`Event ${event2.id} has no creation action`);
|
2359
|
-
}
|
2360
|
-
const activeActions = getAcceptedActions(event2);
|
2361
|
-
const latestAction = activeActions[activeActions.length - 1];
|
2362
|
-
const registrationAction = activeActions.find(
|
2363
|
-
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2364
|
-
);
|
2365
|
-
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2366
|
-
const declaration = aggregateActionDeclarations(activeActions);
|
2367
|
-
let dateOfEvent = event2.createdAt.split("T")[0];
|
2368
|
-
if (event2.dateOfEvent) {
|
2369
|
-
const parsedDate = ZodDate.safeParse(declaration[event2.dateOfEvent.fieldId]);
|
2370
|
-
dateOfEvent = parsedDate.success ? parsedDate.data : null;
|
2371
|
-
}
|
2372
|
-
return deepDropNulls({
|
2373
|
-
id: event2.id,
|
2374
|
-
type: event2.type,
|
2375
|
-
status: getStatusFromActions(event2.actions),
|
2376
|
-
createdAt: event2.createdAt,
|
2377
|
-
createdBy: creationAction.createdBy,
|
2378
|
-
createdAtLocation: creationAction.createdAtLocation ?? "",
|
2379
|
-
// @todo remove using empty string
|
2380
|
-
updatedAt: latestAction.createdAt,
|
2381
|
-
assignedTo: getAssignedUserFromActions(activeActions),
|
2382
|
-
updatedBy: latestAction.createdBy,
|
2383
|
-
updatedAtLocation: event2.updatedAtLocation,
|
2384
|
-
declaration,
|
2385
|
-
trackingId: event2.trackingId,
|
2386
|
-
registrationNumber,
|
2387
|
-
updatedByUserRole: getLastUpdatedByUserRoleFromActions(event2.actions),
|
2388
|
-
dateOfEvent
|
2389
|
-
});
|
2390
|
-
}
|
2391
|
-
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2392
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2393
|
-
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2394
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2395
|
-
return [
|
2396
|
-
action,
|
2397
|
-
{
|
2398
|
-
...action,
|
2399
|
-
type: ActionType.APPROVE_CORRECTION
|
2400
|
-
}
|
2401
|
-
];
|
2402
|
-
}
|
2403
|
-
return [action];
|
2404
|
-
});
|
2405
|
-
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2406
|
-
const withDrafts = {
|
2407
|
-
...event2,
|
2408
|
-
actions: actionWithDrafts
|
2409
|
-
};
|
2410
|
-
return getCurrentEventState(withDrafts);
|
2411
|
-
}
|
2412
|
-
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2413
|
-
const indexedAt = eventIndex.updatedAt;
|
2414
|
-
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2415
|
-
if (activeDrafts.length === 0) {
|
2416
|
-
return eventIndex;
|
2417
|
-
}
|
2418
|
-
return {
|
2419
|
-
...eventIndex,
|
2420
|
-
declaration: {
|
2421
|
-
...eventIndex.declaration,
|
2422
|
-
...activeDrafts[activeDrafts.length - 1].declaration
|
2423
|
-
}
|
2424
|
-
};
|
2425
|
-
}
|
2426
|
-
function getAnnotationFromDrafts(drafts) {
|
2427
|
-
const actions = drafts.map((draft) => draft.action);
|
2428
|
-
const annotation = actions.reduce((ann, action) => {
|
2429
|
-
return deepMerge(ann, action.annotation ?? {});
|
2430
|
-
}, {});
|
2431
|
-
return deepDropNulls(annotation);
|
2432
|
-
}
|
2433
|
-
function getActionAnnotation({
|
2434
|
-
event: event2,
|
2435
|
-
actionType,
|
2436
|
-
drafts = []
|
2437
|
-
}) {
|
2438
|
-
const activeActions = getAcceptedActions(event2);
|
2439
|
-
const action = activeActions.find(
|
2440
|
-
(activeAction) => actionType === activeAction.type
|
2441
|
-
);
|
2442
|
-
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2443
|
-
const sorted = [
|
2444
|
-
...action ? [action] : [],
|
2445
|
-
...eventDrafts.map((draft) => draft.action)
|
2446
|
-
].sort();
|
2447
|
-
const annotation = sorted.reduce((ann, sortedAction) => {
|
2448
|
-
return deepMerge(ann, sortedAction.annotation ?? {});
|
2449
|
-
}, {});
|
2450
|
-
return deepDropNulls(annotation);
|
2451
|
-
}
|
2452
|
-
|
2453
|
-
// ../commons/src/events/defineConfig.ts
|
2454
|
-
var defineConfig = (config) => {
|
2455
|
-
const input = EventConfig.parse(config);
|
2456
|
-
return input;
|
2457
|
-
};
|
2458
|
-
|
2459
|
-
// ../commons/src/events/transactions.ts
|
2460
|
-
function generateTransactionId() {
|
2461
|
-
return getUUID();
|
2462
|
-
}
|
2463
|
-
|
2464
|
-
// ../commons/src/events/test.utils.ts
|
2465
|
-
var import_lodash2 = require("lodash");
|
2187
|
+
var QueryType = import_zod19.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
2466
2188
|
|
2467
2189
|
// ../commons/src/conditionals/conditionals.ts
|
2468
2190
|
function defineConditional(schema) {
|
@@ -2747,81 +2469,619 @@ function createFieldConditionals(fieldId) {
|
|
2747
2469
|
},
|
2748
2470
|
required: [fieldId]
|
2749
2471
|
}),
|
2750
|
-
isBetween: (min, max) => defineFormConditional({
|
2751
|
-
type: "object",
|
2752
|
-
properties: {
|
2753
|
-
[fieldId]: {
|
2754
|
-
type: "number",
|
2755
|
-
minimum: min,
|
2756
|
-
maximum: max
|
2472
|
+
isBetween: (min, max) => defineFormConditional({
|
2473
|
+
type: "object",
|
2474
|
+
properties: {
|
2475
|
+
[fieldId]: {
|
2476
|
+
type: "number",
|
2477
|
+
minimum: min,
|
2478
|
+
maximum: max
|
2479
|
+
}
|
2480
|
+
},
|
2481
|
+
required: [fieldId]
|
2482
|
+
}),
|
2483
|
+
getId: () => ({ fieldId })
|
2484
|
+
};
|
2485
|
+
}
|
2486
|
+
|
2487
|
+
// ../commons/src/searchConfigs.ts
|
2488
|
+
function createSearchConfigs(baseField) {
|
2489
|
+
return {
|
2490
|
+
/**
|
2491
|
+
* Creates a range configuration for the specified field.
|
2492
|
+
*
|
2493
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2494
|
+
*
|
2495
|
+
* @example event('registeredAt').range()
|
2496
|
+
* // {
|
2497
|
+
* // ...
|
2498
|
+
* // config: { type: 'range' }
|
2499
|
+
* // }
|
2500
|
+
*/
|
2501
|
+
range: () => ({
|
2502
|
+
...baseField,
|
2503
|
+
config: { type: "range" }
|
2504
|
+
}),
|
2505
|
+
/**
|
2506
|
+
* Creates a configuration for exact matching of the specified field.
|
2507
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2508
|
+
* @example field('dob').exact()
|
2509
|
+
* // {
|
2510
|
+
* // ...
|
2511
|
+
* // config: { type: 'exact' }
|
2512
|
+
* // }
|
2513
|
+
*/
|
2514
|
+
exact: () => ({
|
2515
|
+
...baseField,
|
2516
|
+
config: { type: "exact" }
|
2517
|
+
}),
|
2518
|
+
/**
|
2519
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
2520
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2521
|
+
* @example field('name').fuzzy()
|
2522
|
+
* // {
|
2523
|
+
* // ...
|
2524
|
+
* // config: { type: 'fuzzy' }
|
2525
|
+
* // }
|
2526
|
+
*/
|
2527
|
+
fuzzy: () => ({
|
2528
|
+
...baseField,
|
2529
|
+
config: { type: "fuzzy" }
|
2530
|
+
})
|
2531
|
+
};
|
2532
|
+
}
|
2533
|
+
|
2534
|
+
// ../commons/src/event-config/event-configuration.ts
|
2535
|
+
function createEventFieldConfig(fieldId, options) {
|
2536
|
+
const baseField = {
|
2537
|
+
fieldId,
|
2538
|
+
options,
|
2539
|
+
fieldType: "event"
|
2540
|
+
};
|
2541
|
+
return createSearchConfigs(baseField);
|
2542
|
+
}
|
2543
|
+
|
2544
|
+
// ../commons/src/events/event.ts
|
2545
|
+
function eventFn(fieldId, options) {
|
2546
|
+
return createEventFieldConfig(fieldId, options);
|
2547
|
+
}
|
2548
|
+
var event = Object.assign(eventFn, {
|
2549
|
+
...createEventConditionals(),
|
2550
|
+
field(field2) {
|
2551
|
+
return {
|
2552
|
+
$event: field2
|
2553
|
+
};
|
2554
|
+
}
|
2555
|
+
});
|
2556
|
+
|
2557
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
2558
|
+
var WorkqueueConfig = import_zod20.z.object({
|
2559
|
+
slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
|
2560
|
+
name: TranslationConfig.describe(
|
2561
|
+
"Title of the workflow (both in navigation and on the page)"
|
2562
|
+
),
|
2563
|
+
query: QueryType,
|
2564
|
+
actions: import_zod20.z.array(
|
2565
|
+
import_zod20.z.object({
|
2566
|
+
type: import_zod20.z.string(),
|
2567
|
+
conditionals: import_zod20.z.array(Conditional).optional()
|
2568
|
+
})
|
2569
|
+
),
|
2570
|
+
columns: import_zod20.z.array(
|
2571
|
+
import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
|
2572
|
+
).default([
|
2573
|
+
{
|
2574
|
+
label: {
|
2575
|
+
id: "workqueues.dateOfEvent",
|
2576
|
+
defaultMessage: "Date of Event",
|
2577
|
+
description: "Label for workqueue column: dateOfEvent"
|
2578
|
+
},
|
2579
|
+
value: event.field("dateOfEvent")
|
2580
|
+
}
|
2581
|
+
])
|
2582
|
+
}).describe("Configuration for workqueue.");
|
2583
|
+
function defineWorkqueue(workqueues) {
|
2584
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
2585
|
+
}
|
2586
|
+
|
2587
|
+
// ../commons/src/events/Draft.ts
|
2588
|
+
var import_zod22 = require("zod");
|
2589
|
+
|
2590
|
+
// ../commons/src/events/ActionInput.ts
|
2591
|
+
var import_zod21 = require("zod");
|
2592
|
+
var import_zod_openapi5 = require("zod-openapi");
|
2593
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
|
2594
|
+
var BaseActionInput = import_zod21.z.object({
|
2595
|
+
eventId: import_zod21.z.string(),
|
2596
|
+
transactionId: import_zod21.z.string(),
|
2597
|
+
declaration: ActionUpdate.default({}),
|
2598
|
+
annotation: ActionUpdate.optional(),
|
2599
|
+
originalActionId: import_zod21.z.string().optional(),
|
2600
|
+
keepAssignment: import_zod21.z.boolean().optional()
|
2601
|
+
});
|
2602
|
+
var CreateActionInput = BaseActionInput.merge(
|
2603
|
+
import_zod21.z.object({
|
2604
|
+
type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2605
|
+
createdAtLocation: import_zod21.z.string()
|
2606
|
+
})
|
2607
|
+
);
|
2608
|
+
var RegisterActionInput = BaseActionInput.merge(
|
2609
|
+
import_zod21.z.object({
|
2610
|
+
type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2611
|
+
registrationNumber: import_zod21.z.string().optional()
|
2612
|
+
})
|
2613
|
+
);
|
2614
|
+
var ValidateActionInput = BaseActionInput.merge(
|
2615
|
+
import_zod21.z.object({
|
2616
|
+
type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2617
|
+
duplicates: import_zod21.z.array(import_zod21.z.string())
|
2618
|
+
})
|
2619
|
+
);
|
2620
|
+
var NotifyActionInput = BaseActionInput.merge(
|
2621
|
+
import_zod21.z.object({
|
2622
|
+
type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2623
|
+
})
|
2624
|
+
);
|
2625
|
+
var DeclareActionInput = BaseActionInput.merge(
|
2626
|
+
import_zod21.z.object({
|
2627
|
+
type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2628
|
+
})
|
2629
|
+
);
|
2630
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
2631
|
+
import_zod21.z.object({
|
2632
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2633
|
+
})
|
2634
|
+
);
|
2635
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2636
|
+
import_zod21.z.object({
|
2637
|
+
type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2638
|
+
})
|
2639
|
+
);
|
2640
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2641
|
+
import_zod21.z.object({
|
2642
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2643
|
+
})
|
2644
|
+
);
|
2645
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2646
|
+
import_zod21.z.object({
|
2647
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2648
|
+
})
|
2649
|
+
);
|
2650
|
+
var AssignActionInput = BaseActionInput.merge(
|
2651
|
+
import_zod21.z.object({
|
2652
|
+
type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2653
|
+
assignedTo: import_zod21.z.string()
|
2654
|
+
})
|
2655
|
+
);
|
2656
|
+
var UnassignActionInput = BaseActionInput.merge(
|
2657
|
+
import_zod21.z.object({
|
2658
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2659
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
2660
|
+
})
|
2661
|
+
);
|
2662
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2663
|
+
import_zod21.z.object({
|
2664
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2665
|
+
})
|
2666
|
+
);
|
2667
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2668
|
+
import_zod21.z.object({
|
2669
|
+
requestId: import_zod21.z.string(),
|
2670
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2671
|
+
})
|
2672
|
+
);
|
2673
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2674
|
+
import_zod21.z.object({
|
2675
|
+
requestId: import_zod21.z.string(),
|
2676
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2677
|
+
})
|
2678
|
+
);
|
2679
|
+
var ReadActionInput = BaseActionInput.merge(
|
2680
|
+
import_zod21.z.object({
|
2681
|
+
type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
|
2682
|
+
})
|
2683
|
+
);
|
2684
|
+
var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
|
2685
|
+
var ActionInput = import_zod21.z.discriminatedUnion("type", [
|
2686
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2687
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2688
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2689
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2690
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2691
|
+
RejectDeclarationActionInput.openapi({
|
2692
|
+
ref: "RejectDeclarationActionInput"
|
2693
|
+
}),
|
2694
|
+
MarkedAsDuplicateActionInput.openapi({
|
2695
|
+
ref: "MarkedAsDuplicateActionInput"
|
2696
|
+
}),
|
2697
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2698
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2699
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2700
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2701
|
+
RequestCorrectionActionInput.openapi({
|
2702
|
+
ref: "RequestCorrectionActionInput"
|
2703
|
+
}),
|
2704
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2705
|
+
ApproveCorrectionActionInput.openapi({
|
2706
|
+
ref: "ApproveCorrectionActionInput"
|
2707
|
+
}),
|
2708
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2709
|
+
]).openapi({
|
2710
|
+
ref: "ActionInput"
|
2711
|
+
});
|
2712
|
+
|
2713
|
+
// ../commons/src/events/Draft.ts
|
2714
|
+
var Draft = import_zod22.z.object({
|
2715
|
+
id: import_zod22.z.string(),
|
2716
|
+
eventId: import_zod22.z.string(),
|
2717
|
+
transactionId: import_zod22.z.string(),
|
2718
|
+
createdAt: import_zod22.z.string().datetime(),
|
2719
|
+
action: ActionBase.extend({
|
2720
|
+
type: ActionTypes
|
2721
|
+
}).omit({ id: true })
|
2722
|
+
});
|
2723
|
+
var DraftInput = BaseActionInput.extend({
|
2724
|
+
type: ActionTypes,
|
2725
|
+
status: import_zod22.z.enum([
|
2726
|
+
ActionStatus.Requested,
|
2727
|
+
ActionStatus.Accepted,
|
2728
|
+
ActionStatus.Rejected
|
2729
|
+
])
|
2730
|
+
});
|
2731
|
+
|
2732
|
+
// ../commons/src/events/EventInput.ts
|
2733
|
+
var import_zod23 = require("zod");
|
2734
|
+
var EventInput = import_zod23.z.object({
|
2735
|
+
transactionId: import_zod23.z.string(),
|
2736
|
+
type: import_zod23.z.string(),
|
2737
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
|
2738
|
+
});
|
2739
|
+
|
2740
|
+
// ../commons/src/events/EventDocument.ts
|
2741
|
+
var import_zod24 = require("zod");
|
2742
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2743
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
|
2744
|
+
var EventDocument = import_zod24.z.object({
|
2745
|
+
id: import_zod24.z.string(),
|
2746
|
+
type: import_zod24.z.string(),
|
2747
|
+
dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
|
2748
|
+
createdAt: import_zod24.z.string().datetime(),
|
2749
|
+
updatedAt: import_zod24.z.string().datetime(),
|
2750
|
+
registeredAt: import_zod24.z.string().datetime().optional(),
|
2751
|
+
// search based on registeration date
|
2752
|
+
registeredAtLocation: import_zod24.z.string().optional(),
|
2753
|
+
// search based on registeration location
|
2754
|
+
actions: import_zod24.z.array(Action),
|
2755
|
+
trackingId: import_zod24.z.string()
|
2756
|
+
}).openapi({ ref: "EventDocument" });
|
2757
|
+
|
2758
|
+
// ../commons/src/events/state/utils.ts
|
2759
|
+
function getActionRequests(actionType, actions) {
|
2760
|
+
const filtered = actions.filter((action) => action.type === actionType);
|
2761
|
+
const accept = filtered.find(
|
2762
|
+
(action) => action.status === ActionStatus.Accepted
|
2763
|
+
);
|
2764
|
+
const request = filtered.find(
|
2765
|
+
(action) => action.status === ActionStatus.Requested
|
2766
|
+
);
|
2767
|
+
const reject = filtered.find(
|
2768
|
+
(action) => action.status === ActionStatus.Rejected
|
2769
|
+
);
|
2770
|
+
return {
|
2771
|
+
reject,
|
2772
|
+
accept,
|
2773
|
+
request
|
2774
|
+
};
|
2775
|
+
}
|
2776
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
2777
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
2778
|
+
actionType,
|
2779
|
+
actions
|
2780
|
+
);
|
2781
|
+
if (!acceptAction) {
|
2782
|
+
return null;
|
2783
|
+
}
|
2784
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
2785
|
+
return {
|
2786
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
2787
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
2788
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
2789
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
2790
|
+
acceptedAt: acceptAction.createdAt,
|
2791
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
2792
|
+
registrationNumber
|
2793
|
+
};
|
2794
|
+
}
|
2795
|
+
function getDeclarationActionUpdateMetadata(actions) {
|
2796
|
+
const createAction = getOrThrow(
|
2797
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
2798
|
+
`Event has no ${ActionType.CREATE} action`
|
2799
|
+
);
|
2800
|
+
return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
|
2801
|
+
(metadata, actionType) => {
|
2802
|
+
const { accept, request } = getActionRequests(actionType, actions);
|
2803
|
+
return {
|
2804
|
+
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
2805
|
+
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
2806
|
+
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
2807
|
+
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
2808
|
+
};
|
2809
|
+
},
|
2810
|
+
{
|
2811
|
+
createdAt: createAction.createdAt,
|
2812
|
+
createdBy: createAction.createdBy,
|
2813
|
+
createdAtLocation: createAction.createdAtLocation,
|
2814
|
+
createdByRole: createAction.createdByRole
|
2815
|
+
}
|
2816
|
+
);
|
2817
|
+
}
|
2818
|
+
function getLegalStatuses(actions) {
|
2819
|
+
return {
|
2820
|
+
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
2821
|
+
ActionType.DECLARE,
|
2822
|
+
actions
|
2823
|
+
),
|
2824
|
+
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
2825
|
+
ActionType.REGISTER,
|
2826
|
+
actions
|
2827
|
+
)
|
2828
|
+
};
|
2829
|
+
}
|
2830
|
+
|
2831
|
+
// ../commons/src/events/state/index.ts
|
2832
|
+
function getStatusFromActions(actions) {
|
2833
|
+
const hasRejectedAction = actions.some(
|
2834
|
+
(a) => a.status === ActionStatus.Rejected
|
2835
|
+
);
|
2836
|
+
if (hasRejectedAction) {
|
2837
|
+
return EventStatus.REJECTED;
|
2838
|
+
}
|
2839
|
+
return actions.reduce((status, action) => {
|
2840
|
+
switch (action.type) {
|
2841
|
+
case ActionType.CREATE:
|
2842
|
+
return EventStatus.CREATED;
|
2843
|
+
case ActionType.DECLARE:
|
2844
|
+
return EventStatus.DECLARED;
|
2845
|
+
case ActionType.VALIDATE:
|
2846
|
+
return EventStatus.VALIDATED;
|
2847
|
+
case ActionType.REGISTER:
|
2848
|
+
return EventStatus.REGISTERED;
|
2849
|
+
case ActionType.REJECT:
|
2850
|
+
return EventStatus.REJECTED;
|
2851
|
+
case ActionType.ARCHIVE:
|
2852
|
+
return EventStatus.ARCHIVED;
|
2853
|
+
case ActionType.NOTIFY:
|
2854
|
+
return EventStatus.NOTIFIED;
|
2855
|
+
case ActionType.PRINT_CERTIFICATE:
|
2856
|
+
return EventStatus.CERTIFIED;
|
2857
|
+
case ActionType.ASSIGN:
|
2858
|
+
case ActionType.UNASSIGN:
|
2859
|
+
case ActionType.REQUEST_CORRECTION:
|
2860
|
+
case ActionType.APPROVE_CORRECTION:
|
2861
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2862
|
+
case ActionType.REJECT_CORRECTION:
|
2863
|
+
case ActionType.READ:
|
2864
|
+
default:
|
2865
|
+
return status;
|
2866
|
+
}
|
2867
|
+
}, EventStatus.CREATED);
|
2868
|
+
}
|
2869
|
+
function getFlagsFromActions(actions) {
|
2870
|
+
const sortedactions = actions.sort(
|
2871
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
2872
|
+
);
|
2873
|
+
const actionStatus = sortedactions.reduce(
|
2874
|
+
(actionStatuses, { type, status }) => ({
|
2875
|
+
...actionStatuses,
|
2876
|
+
[type]: status
|
2877
|
+
}),
|
2878
|
+
{}
|
2879
|
+
);
|
2880
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
2881
|
+
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
2882
|
+
return flag;
|
2883
|
+
});
|
2884
|
+
const isCertificatePrinted = sortedactions.reduce(
|
2885
|
+
(prev, { type }) => {
|
2886
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
2887
|
+
return true;
|
2888
|
+
}
|
2889
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
2890
|
+
return false;
|
2891
|
+
}
|
2892
|
+
return prev;
|
2893
|
+
},
|
2894
|
+
false
|
2895
|
+
);
|
2896
|
+
if (isCertificatePrinted) {
|
2897
|
+
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
2898
|
+
}
|
2899
|
+
return flags;
|
2900
|
+
}
|
2901
|
+
function getAssignedUserFromActions(actions) {
|
2902
|
+
return actions.reduce((user2, action) => {
|
2903
|
+
if (action.type === ActionType.ASSIGN) {
|
2904
|
+
return action.assignedTo;
|
2905
|
+
}
|
2906
|
+
if (action.type === ActionType.UNASSIGN) {
|
2907
|
+
return null;
|
2908
|
+
}
|
2909
|
+
return user2;
|
2910
|
+
}, null);
|
2911
|
+
}
|
2912
|
+
function aggregateActionDeclarations(actions) {
|
2913
|
+
const excludedActions = [
|
2914
|
+
ActionType.REQUEST_CORRECTION,
|
2915
|
+
ActionType.PRINT_CERTIFICATE
|
2916
|
+
];
|
2917
|
+
return actions.reduce((status, action) => {
|
2918
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2919
|
+
return status;
|
2920
|
+
}
|
2921
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2922
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2923
|
+
if (!requestAction) {
|
2924
|
+
return status;
|
2925
|
+
}
|
2926
|
+
return deepMerge(status, requestAction.declaration);
|
2927
|
+
}
|
2928
|
+
return deepMerge(status, action.declaration);
|
2929
|
+
}, {});
|
2930
|
+
}
|
2931
|
+
function deepDropNulls(obj) {
|
2932
|
+
if (Array.isArray(obj)) {
|
2933
|
+
return obj.map(deepDropNulls);
|
2934
|
+
}
|
2935
|
+
if (obj !== null && typeof obj === "object") {
|
2936
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2937
|
+
const cleanedValue = deepDropNulls(value);
|
2938
|
+
if (cleanedValue !== null) {
|
2939
|
+
;
|
2940
|
+
acc[key] = cleanedValue;
|
2941
|
+
}
|
2942
|
+
return acc;
|
2943
|
+
}, {});
|
2944
|
+
}
|
2945
|
+
return obj;
|
2946
|
+
}
|
2947
|
+
function isUndeclaredDraft(status) {
|
2948
|
+
return status === EventStatus.CREATED;
|
2949
|
+
}
|
2950
|
+
function getAcceptedActions(event2) {
|
2951
|
+
return event2.actions.filter(
|
2952
|
+
(a) => a.status === ActionStatus.Accepted
|
2953
|
+
);
|
2954
|
+
}
|
2955
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
2956
|
+
function getCurrentEventState(event2) {
|
2957
|
+
const creationAction = event2.actions.find(
|
2958
|
+
(action) => action.type === ActionType.CREATE
|
2959
|
+
);
|
2960
|
+
if (!creationAction) {
|
2961
|
+
throw new Error(`Event ${event2.id} has no creation action`);
|
2962
|
+
}
|
2963
|
+
const acceptedActions = getAcceptedActions(event2);
|
2964
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
2965
|
+
event2.actions
|
2966
|
+
);
|
2967
|
+
const declaration = aggregateActionDeclarations(acceptedActions);
|
2968
|
+
const dateOfEvent = ZodDate.safeParse(
|
2969
|
+
event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
|
2970
|
+
).data ?? null;
|
2971
|
+
return deepDropNulls({
|
2972
|
+
id: event2.id,
|
2973
|
+
type: event2.type,
|
2974
|
+
status: getStatusFromActions(event2.actions),
|
2975
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
2976
|
+
createdAt: creationAction.createdAt,
|
2977
|
+
createdBy: creationAction.createdBy,
|
2978
|
+
createdAtLocation: creationAction.createdAtLocation,
|
2979
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
2980
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
2981
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
2982
|
+
declaration,
|
2983
|
+
trackingId: event2.trackingId,
|
2984
|
+
// @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
|
2985
|
+
updatedByUserRole: declarationUpdateMetadata.createdByRole,
|
2986
|
+
dateOfEvent,
|
2987
|
+
flags: getFlagsFromActions(event2.actions)
|
2988
|
+
});
|
2989
|
+
}
|
2990
|
+
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2991
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2992
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2993
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2994
|
+
return [
|
2995
|
+
action,
|
2996
|
+
{
|
2997
|
+
...action,
|
2998
|
+
type: ActionType.APPROVE_CORRECTION
|
2757
2999
|
}
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
3000
|
+
];
|
3001
|
+
}
|
3002
|
+
return [action];
|
3003
|
+
});
|
3004
|
+
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
3005
|
+
const withDrafts = {
|
3006
|
+
...event2,
|
3007
|
+
actions: actionWithDrafts
|
3008
|
+
};
|
3009
|
+
return getCurrentEventState(withDrafts);
|
3010
|
+
}
|
3011
|
+
function applyDraftsToEventIndex(eventIndex, drafts) {
|
3012
|
+
const indexedAt = eventIndex.updatedAt;
|
3013
|
+
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
3014
|
+
if (activeDrafts.length === 0) {
|
3015
|
+
return eventIndex;
|
3016
|
+
}
|
3017
|
+
return {
|
3018
|
+
...eventIndex,
|
3019
|
+
declaration: {
|
3020
|
+
...eventIndex.declaration,
|
3021
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
3022
|
+
}
|
2762
3023
|
};
|
2763
3024
|
}
|
3025
|
+
function getAnnotationFromDrafts(drafts) {
|
3026
|
+
const actions = drafts.map((draft) => draft.action);
|
3027
|
+
const annotation = actions.reduce((ann, action) => {
|
3028
|
+
return deepMerge(ann, action.annotation ?? {});
|
3029
|
+
}, {});
|
3030
|
+
return deepDropNulls(annotation);
|
3031
|
+
}
|
3032
|
+
function getActionAnnotation({
|
3033
|
+
event: event2,
|
3034
|
+
actionType,
|
3035
|
+
drafts = []
|
3036
|
+
}) {
|
3037
|
+
const activeActions = getAcceptedActions(event2);
|
3038
|
+
const action = activeActions.find(
|
3039
|
+
(activeAction) => actionType === activeAction.type
|
3040
|
+
);
|
3041
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
3042
|
+
const sorted = [
|
3043
|
+
...action ? [action] : [],
|
3044
|
+
...eventDrafts.map((draft) => draft.action)
|
3045
|
+
].sort();
|
3046
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
3047
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
3048
|
+
}, {});
|
3049
|
+
return deepDropNulls(annotation);
|
3050
|
+
}
|
3051
|
+
|
3052
|
+
// ../commons/src/events/defineConfig.ts
|
3053
|
+
var defineConfig = (config) => {
|
3054
|
+
const input = EventConfig.parse(config);
|
3055
|
+
return input;
|
3056
|
+
};
|
3057
|
+
|
3058
|
+
// ../commons/src/events/transactions.ts
|
3059
|
+
function generateTransactionId() {
|
3060
|
+
return getUUID();
|
3061
|
+
}
|
3062
|
+
|
3063
|
+
// ../commons/src/events/test.utils.ts
|
3064
|
+
var import_lodash2 = require("lodash");
|
2764
3065
|
|
2765
3066
|
// ../commons/src/field-config/field-configuration.ts
|
2766
|
-
function createFieldConfigs(fieldId) {
|
3067
|
+
function createFieldConfigs(fieldId, options) {
|
2767
3068
|
const baseField = {
|
2768
3069
|
fieldId,
|
2769
|
-
fieldType: "field"
|
2770
|
-
|
2771
|
-
return {
|
2772
|
-
/**
|
2773
|
-
* Creates a range configuration for the specified field.
|
2774
|
-
*
|
2775
|
-
* @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
|
2776
|
-
*
|
2777
|
-
* @example field('age').range()
|
2778
|
-
* // {
|
2779
|
-
* // fieldId: 'age',
|
2780
|
-
* // config: { type: 'RANGE' }
|
2781
|
-
* // }
|
2782
|
-
*/
|
2783
|
-
range: () => ({
|
2784
|
-
...baseField,
|
2785
|
-
config: { type: "RANGE" }
|
2786
|
-
}),
|
2787
|
-
/**
|
2788
|
-
* Creates a configuration for exact matching of the specified field.
|
2789
|
-
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2790
|
-
* @example field('dob').exact()
|
2791
|
-
* // {
|
2792
|
-
* // fieldId: 'dob',
|
2793
|
-
* // config: { type: 'EXACT' }
|
2794
|
-
* // }
|
2795
|
-
*/
|
2796
|
-
exact: () => ({
|
2797
|
-
...baseField,
|
2798
|
-
config: { type: "EXACT" }
|
2799
|
-
}),
|
2800
|
-
/**
|
2801
|
-
* Creates a configuration for fuzzy matching of the specified field.
|
2802
|
-
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2803
|
-
* @example field('name').fuzzy()
|
2804
|
-
* // {
|
2805
|
-
* // fieldId: 'name',
|
2806
|
-
* // config: { type: 'FUZZY' }
|
2807
|
-
* // }
|
2808
|
-
*/
|
2809
|
-
fuzzy: () => ({
|
2810
|
-
...baseField,
|
2811
|
-
config: { type: "FUZZY" }
|
2812
|
-
})
|
3070
|
+
fieldType: "field",
|
3071
|
+
...options
|
2813
3072
|
};
|
3073
|
+
return createSearchConfigs(baseField);
|
2814
3074
|
}
|
2815
3075
|
|
2816
3076
|
// ../commons/src/events/field.ts
|
2817
|
-
function field(fieldId) {
|
3077
|
+
function field(fieldId, options = {}) {
|
2818
3078
|
return {
|
2819
3079
|
/**
|
2820
3080
|
* @private Internal property used for field reference tracking.
|
2821
3081
|
*/
|
2822
3082
|
_fieldId: fieldId,
|
2823
3083
|
...createFieldConditionals(fieldId),
|
2824
|
-
...createFieldConfigs(fieldId)
|
3084
|
+
...createFieldConfigs(fieldId, options)
|
2825
3085
|
};
|
2826
3086
|
}
|
2827
3087
|
|
@@ -4093,7 +4353,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
4093
4353
|
description: "This is what this event is referred as in the system",
|
4094
4354
|
id: "v2.event.tennis-club-membership.search"
|
4095
4355
|
},
|
4096
|
-
fields: [field("applicant.dob").exact()]
|
4356
|
+
fields: [field("applicant.dob").exact(), event("registeredAt").exact()]
|
4097
4357
|
}
|
4098
4358
|
],
|
4099
4359
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
@@ -4176,8 +4436,7 @@ var eventPayloadGenerator = {
|
|
4176
4436
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4177
4437
|
createdBy: "@todo",
|
4178
4438
|
createdByRole: "@todo",
|
4179
|
-
createdAtLocation: "@todo"
|
4180
|
-
updatedAtLocation: "@todo"
|
4439
|
+
createdAtLocation: "@todo"
|
4181
4440
|
}
|
4182
4441
|
},
|
4183
4442
|
input
|
@@ -4340,13 +4599,12 @@ function generateActionDocument({
|
|
4340
4599
|
createdBy: getUUID(),
|
4341
4600
|
createdByRole: "FIELD_AGENT",
|
4342
4601
|
id: getUUID(),
|
4343
|
-
createdAtLocation: "
|
4344
|
-
updatedAtLocation: "TODO",
|
4602
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4345
4603
|
declaration: generateActionDeclarationInput(configuration, action),
|
4346
4604
|
annotation: {},
|
4347
|
-
...defaults,
|
4348
4605
|
status: ActionStatus.Accepted,
|
4349
|
-
transactionId: getUUID()
|
4606
|
+
transactionId: getUUID(),
|
4607
|
+
...defaults
|
4350
4608
|
};
|
4351
4609
|
switch (action) {
|
4352
4610
|
case ActionType.READ:
|
@@ -4405,8 +4663,7 @@ function generateEventDocument({
|
|
4405
4663
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4406
4664
|
// @TODO: This should be fixed in the future.
|
4407
4665
|
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4408
|
-
dateOfEvent: configuration.dateOfEvent
|
4409
|
-
updatedAtLocation: getUUID()
|
4666
|
+
dateOfEvent: configuration.dateOfEvent
|
4410
4667
|
};
|
4411
4668
|
}
|
4412
4669
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4428,10 +4685,64 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4428
4685
|
eventId
|
4429
4686
|
};
|
4430
4687
|
}
|
4688
|
+
function getEventStatus() {
|
4689
|
+
const statuses = [
|
4690
|
+
EventStatus.CREATED,
|
4691
|
+
EventStatus.REGISTERED,
|
4692
|
+
EventStatus.DECLARED
|
4693
|
+
];
|
4694
|
+
const randomIndex = Math.floor(Math.random() * 3);
|
4695
|
+
return statuses[randomIndex];
|
4696
|
+
}
|
4697
|
+
function getTrackingId() {
|
4698
|
+
const uuid = getUUID().replace(/-/g, "");
|
4699
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4700
|
+
return trackingId;
|
4701
|
+
}
|
4702
|
+
function getRandomApplicant() {
|
4703
|
+
const firstNames = [
|
4704
|
+
"Danny",
|
4705
|
+
"John",
|
4706
|
+
"Jane",
|
4707
|
+
"Emily",
|
4708
|
+
"Michael",
|
4709
|
+
"Sarah",
|
4710
|
+
"Chris",
|
4711
|
+
"Jessica"
|
4712
|
+
];
|
4713
|
+
const surnames = [
|
4714
|
+
"Doe",
|
4715
|
+
"Smith",
|
4716
|
+
"Johnson",
|
4717
|
+
"Brown",
|
4718
|
+
"Williams",
|
4719
|
+
"Jones",
|
4720
|
+
"Garcia",
|
4721
|
+
"Miller"
|
4722
|
+
];
|
4723
|
+
function getRandomDate(start, end) {
|
4724
|
+
const randomDate = new Date(
|
4725
|
+
start.getTime() + Math.random() * (end.getTime() - start.getTime())
|
4726
|
+
);
|
4727
|
+
return randomDate.toISOString().split("T")[0];
|
4728
|
+
}
|
4729
|
+
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
4730
|
+
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
|
4731
|
+
const randomDob = getRandomDate(
|
4732
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
4733
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
4734
|
+
);
|
4735
|
+
return {
|
4736
|
+
"recommender.none": true,
|
4737
|
+
"applicant.firstname": randomFirstName,
|
4738
|
+
"applicant.surname": randomSurname,
|
4739
|
+
"applicant.dob": randomDob
|
4740
|
+
};
|
4741
|
+
}
|
4431
4742
|
var eventQueryDataGenerator = (overrides = {}) => ({
|
4432
4743
|
id: overrides.id ?? getUUID(),
|
4433
|
-
type: overrides.type ?? "
|
4434
|
-
status: overrides.status ??
|
4744
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4745
|
+
status: overrides.status ?? getEventStatus(),
|
4435
4746
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4436
4747
|
createdBy: overrides.createdBy ?? getUUID(),
|
4437
4748
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
@@ -4440,13 +4751,10 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4440
4751
|
assignedTo: overrides.assignedTo ?? null,
|
4441
4752
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4442
4753
|
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
"applicant.dob": "1999-11-11"
|
4448
|
-
},
|
4449
|
-
trackingId: overrides.trackingId ?? "M3F8YQ"
|
4754
|
+
flags: [],
|
4755
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
4756
|
+
declaration: overrides.declaration ?? getRandomApplicant(),
|
4757
|
+
trackingId: overrides.trackingId ?? getTrackingId()
|
4450
4758
|
});
|
4451
4759
|
var generateTranslationConfig = (message) => ({
|
4452
4760
|
defaultMessage: message,
|
@@ -4679,19 +4987,3 @@ function filterUnallowedActions(actions, userScopes) {
|
|
4679
4987
|
}
|
4680
4988
|
return [ActionType.READ];
|
4681
4989
|
}
|
4682
|
-
|
4683
|
-
// ../commons/src/event-config/event-configuration.ts
|
4684
|
-
function createEventFieldConfig(fieldId, options) {
|
4685
|
-
return {
|
4686
|
-
fieldId,
|
4687
|
-
options,
|
4688
|
-
config: { type: "EXACT" },
|
4689
|
-
fieldType: "event"
|
4690
|
-
};
|
4691
|
-
}
|
4692
|
-
|
4693
|
-
// ../commons/src/events/event.ts
|
4694
|
-
function eventFn(fieldId, options) {
|
4695
|
-
return createEventFieldConfig(fieldId, options);
|
4696
|
-
}
|
4697
|
-
var event = Object.assign(eventFn, createEventConditionals());
|