@opencrvs/toolkit 1.8.0-rc.f82791e → 1.8.0-rc.f85d424
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 +681 -334
- package/dist/commons/events/ActionConfig.d.ts +4879 -1232
- 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 +34 -36
- package/dist/commons/events/Draft.d.ts +24 -26
- package/dist/commons/events/EventConfig.d.ts +2711 -967
- package/dist/commons/events/EventDocument.d.ts +241 -312
- package/dist/commons/events/EventIndex.d.ts +843 -305
- package/dist/commons/events/EventMetadata.d.ts +264 -11
- package/dist/commons/events/FieldConfig.d.ts +267 -3
- 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 +2279 -629
- package/dist/commons/events/PageConfig.d.ts +406 -0
- package/dist/commons/events/SummaryConfig.d.ts +17 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +1222 -8
- package/dist/commons/events/defineConfig.d.ts +283 -2
- package/dist/commons/events/event.d.ts +3 -1
- package/dist/commons/events/field.d.ts +3 -3
- package/dist/commons/events/scopes.d.ts +1 -1
- package/dist/commons/events/test.utils.d.ts +7 -7
- package/dist/commons/events/utils.d.ts +193 -21
- package/dist/events/index.js +1101 -700
- package/dist/scopes/index.d.ts +137 -1
- package/dist/scopes/index.js +147 -0
- 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,8 +91,12 @@ __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,
|
99
|
+
EventStatusEnum: () => EventStatusEnum,
|
91
100
|
EventStatuses: () => EventStatuses,
|
92
101
|
FieldConditional: () => FieldConditional,
|
93
102
|
FieldConfig: () => FieldConfig,
|
@@ -98,6 +107,7 @@ __export(events_exports, {
|
|
98
107
|
FileFieldValue: () => FileFieldValue,
|
99
108
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
100
109
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
110
|
+
Flag: () => Flag,
|
101
111
|
FormConfig: () => FormConfig,
|
102
112
|
FormPageConfig: () => FormPageConfig,
|
103
113
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
@@ -105,8 +115,8 @@ __export(events_exports, {
|
|
105
115
|
GeographicalArea: () => GeographicalArea,
|
106
116
|
ImageMimeType: () => ImageMimeType,
|
107
117
|
LanguageConfig: () => LanguageConfig,
|
118
|
+
LegalStatuses: () => LegalStatuses,
|
108
119
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
109
|
-
MatchType: () => MatchType,
|
110
120
|
MimeType: () => MimeType,
|
111
121
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
112
122
|
NotifyActionInput: () => NotifyActionInput,
|
@@ -119,6 +129,7 @@ __export(events_exports, {
|
|
119
129
|
ReadActionInput: () => ReadActionInput,
|
120
130
|
RegisterAction: () => RegisterAction,
|
121
131
|
RegisterActionInput: () => RegisterActionInput,
|
132
|
+
RegistrationCreationMetadata: () => RegistrationCreationMetadata,
|
122
133
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
123
134
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
124
135
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
@@ -192,6 +203,7 @@ __export(events_exports, {
|
|
192
203
|
getDeclaration: () => getDeclaration,
|
193
204
|
getDeclarationFields: () => getDeclarationFields,
|
194
205
|
getDeclarationPages: () => getDeclarationPages,
|
206
|
+
getMixedPath: () => getMixedPath,
|
195
207
|
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
196
208
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
197
209
|
isAddressFieldType: () => isAddressFieldType,
|
@@ -202,6 +214,7 @@ __export(events_exports, {
|
|
202
214
|
isCountryFieldType: () => isCountryFieldType,
|
203
215
|
isDataFieldType: () => isDataFieldType,
|
204
216
|
isDateFieldType: () => isDateFieldType,
|
217
|
+
isDateRangeFieldType: () => isDateRangeFieldType,
|
205
218
|
isDividerFieldType: () => isDividerFieldType,
|
206
219
|
isEmailFieldType: () => isEmailFieldType,
|
207
220
|
isFacilityFieldType: () => isFacilityFieldType,
|
@@ -317,6 +330,7 @@ var FieldType = {
|
|
317
330
|
TEXTAREA: "TEXTAREA",
|
318
331
|
EMAIL: "EMAIL",
|
319
332
|
DATE: "DATE",
|
333
|
+
DATE_RANGE: "DATE_RANGE",
|
320
334
|
PARAGRAPH: "PARAGRAPH",
|
321
335
|
PAGE_HEADER: "PAGE_HEADER",
|
322
336
|
RADIO_GROUP: "RADIO_GROUP",
|
@@ -336,6 +350,7 @@ var FieldType = {
|
|
336
350
|
};
|
337
351
|
var fieldTypes = Object.values(FieldType);
|
338
352
|
var compositeFieldTypes = [
|
353
|
+
FieldType.DATE_RANGE,
|
339
354
|
FieldType.ADDRESS,
|
340
355
|
FieldType.FILE_WITH_OPTIONS,
|
341
356
|
FieldType.FILE
|
@@ -428,6 +443,8 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
428
443
|
var TextValue = import_zod4.z.string();
|
429
444
|
var NonEmptyTextValue = TextValue.min(1);
|
430
445
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
446
|
+
var DatetimeValue = import_zod4.z.string().datetime();
|
447
|
+
var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
|
431
448
|
var EmailValue = import_zod4.z.string().email();
|
432
449
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
433
450
|
var NumberFieldValue = import_zod4.z.number();
|
@@ -435,6 +452,7 @@ var DataFieldValue = import_zod4.z.undefined();
|
|
435
452
|
var FieldValue = import_zod4.z.union([
|
436
453
|
TextValue,
|
437
454
|
DateValue,
|
455
|
+
DateRangeFieldValue,
|
438
456
|
CheckboxFieldValue,
|
439
457
|
NumberFieldValue,
|
440
458
|
FileFieldValue,
|
@@ -447,6 +465,7 @@ var FieldValue = import_zod4.z.union([
|
|
447
465
|
var FieldUpdateValue = import_zod4.z.union([
|
448
466
|
TextValue,
|
449
467
|
DateValue,
|
468
|
+
DateRangeFieldValue,
|
450
469
|
CheckboxFieldValue,
|
451
470
|
NumberFieldValue,
|
452
471
|
FileFieldValue,
|
@@ -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");
|
@@ -1056,7 +1087,10 @@ var BaseField2 = import_zod13.z.object({
|
|
1056
1087
|
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1057
1088
|
});
|
1058
1089
|
var ReferenceField = BaseField2.extend({
|
1059
|
-
fieldId: import_zod13.z.string()
|
1090
|
+
fieldId: import_zod13.z.string(),
|
1091
|
+
label: TranslationConfig.optional().describe(
|
1092
|
+
"By default, the configured field's label is used. This can be overridden by providing a custom label."
|
1093
|
+
)
|
1060
1094
|
}).describe("Field directly referencing event data with field id");
|
1061
1095
|
var Field = BaseField2.extend({
|
1062
1096
|
id: import_zod13.z.string().describe("Id of summary field"),
|
@@ -1072,7 +1106,7 @@ var SummaryConfig = import_zod13.z.object({
|
|
1072
1106
|
|
1073
1107
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1074
1108
|
var import_zod14 = require("zod");
|
1075
|
-
var MatchType = import_zod14.z.enum(["
|
1109
|
+
var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
|
1076
1110
|
var BaseField3 = import_zod14.z.object({
|
1077
1111
|
config: import_zod14.z.object({
|
1078
1112
|
type: MatchType.describe("Determines the type of field")
|
@@ -1100,13 +1134,162 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1100
1134
|
// ../commons/src/events/utils.ts
|
1101
1135
|
var import_lodash = require("lodash");
|
1102
1136
|
|
1137
|
+
// ../commons/src/events/ActionDocument.ts
|
1138
|
+
var import_zod15 = require("zod");
|
1139
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1140
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
|
1141
|
+
var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
|
1142
|
+
var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
|
1143
|
+
var ActionStatus = {
|
1144
|
+
Requested: "Requested",
|
1145
|
+
Accepted: "Accepted",
|
1146
|
+
Rejected: "Rejected"
|
1147
|
+
};
|
1148
|
+
var ActionBase = import_zod15.z.object({
|
1149
|
+
id: import_zod15.z.string(),
|
1150
|
+
transactionId: import_zod15.z.string(),
|
1151
|
+
createdAt: import_zod15.z.string().datetime(),
|
1152
|
+
createdBy: import_zod15.z.string(),
|
1153
|
+
createdByRole: import_zod15.z.string(),
|
1154
|
+
declaration: ActionUpdate,
|
1155
|
+
annotation: ActionUpdate.optional(),
|
1156
|
+
createdAtLocation: import_zod15.z.string(),
|
1157
|
+
status: import_zod15.z.enum([
|
1158
|
+
ActionStatus.Requested,
|
1159
|
+
ActionStatus.Accepted,
|
1160
|
+
ActionStatus.Rejected
|
1161
|
+
]),
|
1162
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1163
|
+
originalActionId: import_zod15.z.string().optional()
|
1164
|
+
});
|
1165
|
+
var AssignedAction = ActionBase.merge(
|
1166
|
+
import_zod15.z.object({
|
1167
|
+
type: import_zod15.z.literal(ActionType.ASSIGN),
|
1168
|
+
assignedTo: import_zod15.z.string()
|
1169
|
+
})
|
1170
|
+
);
|
1171
|
+
var UnassignedAction = ActionBase.merge(
|
1172
|
+
import_zod15.z.object({
|
1173
|
+
type: import_zod15.z.literal(ActionType.UNASSIGN),
|
1174
|
+
assignedTo: import_zod15.z.literal(null)
|
1175
|
+
})
|
1176
|
+
);
|
1177
|
+
var RegisterAction = ActionBase.merge(
|
1178
|
+
import_zod15.z.object({
|
1179
|
+
type: import_zod15.z.literal(ActionType.REGISTER),
|
1180
|
+
registrationNumber: import_zod15.z.string().optional()
|
1181
|
+
})
|
1182
|
+
);
|
1183
|
+
var DeclareAction = ActionBase.merge(
|
1184
|
+
import_zod15.z.object({
|
1185
|
+
type: import_zod15.z.literal(ActionType.DECLARE)
|
1186
|
+
})
|
1187
|
+
);
|
1188
|
+
var ValidateAction = ActionBase.merge(
|
1189
|
+
import_zod15.z.object({
|
1190
|
+
type: import_zod15.z.literal(ActionType.VALIDATE)
|
1191
|
+
})
|
1192
|
+
);
|
1193
|
+
var RejectAction = ActionBase.merge(
|
1194
|
+
import_zod15.z.object({
|
1195
|
+
type: import_zod15.z.literal(ActionType.REJECT)
|
1196
|
+
})
|
1197
|
+
);
|
1198
|
+
var MarkAsDuplicateAction = ActionBase.merge(
|
1199
|
+
import_zod15.z.object({
|
1200
|
+
type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1201
|
+
})
|
1202
|
+
);
|
1203
|
+
var ArchiveAction = ActionBase.merge(
|
1204
|
+
import_zod15.z.object({
|
1205
|
+
type: import_zod15.z.literal(ActionType.ARCHIVE)
|
1206
|
+
})
|
1207
|
+
);
|
1208
|
+
var CreatedAction = ActionBase.merge(
|
1209
|
+
import_zod15.z.object({
|
1210
|
+
type: import_zod15.z.literal(ActionType.CREATE)
|
1211
|
+
})
|
1212
|
+
);
|
1213
|
+
var NotifiedAction = ActionBase.merge(
|
1214
|
+
import_zod15.z.object({
|
1215
|
+
type: import_zod15.z.literal(ActionType.NOTIFY)
|
1216
|
+
})
|
1217
|
+
);
|
1218
|
+
var PrintCertificateAction = ActionBase.merge(
|
1219
|
+
import_zod15.z.object({
|
1220
|
+
type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
|
1221
|
+
})
|
1222
|
+
);
|
1223
|
+
var RequestedCorrectionAction = ActionBase.merge(
|
1224
|
+
import_zod15.z.object({
|
1225
|
+
type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
|
1226
|
+
})
|
1227
|
+
);
|
1228
|
+
var ApprovedCorrectionAction = ActionBase.merge(
|
1229
|
+
import_zod15.z.object({
|
1230
|
+
type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
|
1231
|
+
requestId: import_zod15.z.string()
|
1232
|
+
})
|
1233
|
+
);
|
1234
|
+
var RejectedCorrectionAction = ActionBase.merge(
|
1235
|
+
import_zod15.z.object({
|
1236
|
+
type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
|
1237
|
+
requestId: import_zod15.z.string()
|
1238
|
+
})
|
1239
|
+
);
|
1240
|
+
var ReadAction = ActionBase.merge(
|
1241
|
+
import_zod15.z.object({
|
1242
|
+
type: import_zod15.z.literal(ActionType.READ)
|
1243
|
+
})
|
1244
|
+
);
|
1245
|
+
var ActionDocument = import_zod15.z.discriminatedUnion("type", [
|
1246
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1247
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1248
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1249
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1250
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1251
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1252
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1253
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1254
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1255
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1256
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1257
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1258
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1259
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1260
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1261
|
+
]).openapi({
|
1262
|
+
ref: "ActionDocument"
|
1263
|
+
});
|
1264
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1265
|
+
declaration: true,
|
1266
|
+
annotation: true
|
1267
|
+
}).merge(
|
1268
|
+
import_zod15.z.object({
|
1269
|
+
type: import_zod15.z.enum(ConfirmableActions),
|
1270
|
+
status: import_zod15.z.literal(ActionStatus.Rejected)
|
1271
|
+
})
|
1272
|
+
);
|
1273
|
+
var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1274
|
+
var ResolvedUser = import_zod15.z.object({
|
1275
|
+
id: import_zod15.z.string(),
|
1276
|
+
role: import_zod15.z.string(),
|
1277
|
+
name: import_zod15.z.array(
|
1278
|
+
import_zod15.z.object({
|
1279
|
+
use: import_zod15.z.string(),
|
1280
|
+
given: import_zod15.z.array(import_zod15.z.string()),
|
1281
|
+
family: import_zod15.z.string()
|
1282
|
+
})
|
1283
|
+
)
|
1284
|
+
});
|
1285
|
+
|
1103
1286
|
// ../commons/src/conditionals/validate.ts
|
1104
1287
|
var import_ajv = __toESM(require("ajv"));
|
1105
1288
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1106
1289
|
var import_date_fns = require("date-fns");
|
1107
1290
|
|
1108
1291
|
// ../commons/src/events/FieldTypeMapping.ts
|
1109
|
-
var
|
1292
|
+
var import_zod16 = require("zod");
|
1110
1293
|
function mapFieldTypeToZod(type, required) {
|
1111
1294
|
let schema;
|
1112
1295
|
switch (type) {
|
@@ -1116,6 +1299,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1116
1299
|
case FieldType.EMAIL:
|
1117
1300
|
schema = EmailValue;
|
1118
1301
|
break;
|
1302
|
+
case FieldType.DATE_RANGE:
|
1303
|
+
schema = DateRangeFieldValue;
|
1304
|
+
break;
|
1119
1305
|
case FieldType.TEXT:
|
1120
1306
|
case FieldType.TEXTAREA:
|
1121
1307
|
case FieldType.DIVIDER:
|
@@ -1158,7 +1344,7 @@ function createValidationSchema(config) {
|
|
1158
1344
|
for (const field2 of config) {
|
1159
1345
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1160
1346
|
}
|
1161
|
-
return
|
1347
|
+
return import_zod16.z.object(shape);
|
1162
1348
|
}
|
1163
1349
|
function mapFieldTypeToMockValue(field2, i) {
|
1164
1350
|
switch (field2.type) {
|
@@ -1196,6 +1382,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1196
1382
|
};
|
1197
1383
|
case FieldType.DATE:
|
1198
1384
|
return "2021-01-01";
|
1385
|
+
case FieldType.DATE_RANGE:
|
1386
|
+
return ["2021-01-01", "2021-01-02"];
|
1199
1387
|
case FieldType.CHECKBOX:
|
1200
1388
|
return true;
|
1201
1389
|
case FieldType.FILE:
|
@@ -1230,6 +1418,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1230
1418
|
case FieldType.EMAIL:
|
1231
1419
|
case FieldType.DATE:
|
1232
1420
|
case FieldType.CHECKBOX:
|
1421
|
+
case FieldType.DATE_RANGE:
|
1233
1422
|
case FieldType.DATA:
|
1234
1423
|
return null;
|
1235
1424
|
case FieldType.ADDRESS:
|
@@ -1262,6 +1451,9 @@ var isParagraphFieldType = (field2) => {
|
|
1262
1451
|
var isDateFieldType = (field2) => {
|
1263
1452
|
return field2.config.type === FieldType.DATE;
|
1264
1453
|
};
|
1454
|
+
var isDateRangeFieldType = (field2) => {
|
1455
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1456
|
+
};
|
1265
1457
|
var isPageHeaderFieldType = (field2) => {
|
1266
1458
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1267
1459
|
};
|
@@ -1604,7 +1796,10 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1604
1796
|
annotation: {},
|
1605
1797
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1606
1798
|
createdBy: "@todo",
|
1607
|
-
createdAtLocation: "@todo"
|
1799
|
+
createdAtLocation: "@todo",
|
1800
|
+
status: ActionStatus.Accepted,
|
1801
|
+
transactionId: "@todo",
|
1802
|
+
createdByRole: "@todo"
|
1608
1803
|
}
|
1609
1804
|
};
|
1610
1805
|
}
|
@@ -1676,25 +1871,43 @@ var findAllFields = (config) => {
|
|
1676
1871
|
...getAllAnnotationFields(config)
|
1677
1872
|
]);
|
1678
1873
|
};
|
1874
|
+
function getMixedPath(obj, path, defaultValue) {
|
1875
|
+
const parts = path.split(".");
|
1876
|
+
const resolve = (current, segments) => {
|
1877
|
+
if (current == null || segments.length === 0) {
|
1878
|
+
return current;
|
1879
|
+
}
|
1880
|
+
for (let i = segments.length; i > 0; i--) {
|
1881
|
+
const compoundKey = segments.slice(0, i).join(".");
|
1882
|
+
if ((0, import_lodash.has)(current, compoundKey)) {
|
1883
|
+
const next = (0, import_lodash.get)(current, compoundKey);
|
1884
|
+
return resolve(next, segments.slice(i));
|
1885
|
+
}
|
1886
|
+
}
|
1887
|
+
return void 0;
|
1888
|
+
};
|
1889
|
+
const result = resolve(obj, parts);
|
1890
|
+
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
1891
|
+
}
|
1679
1892
|
|
1680
1893
|
// ../commons/src/events/EventConfig.ts
|
1681
|
-
var
|
1682
|
-
(0,
|
1683
|
-
var EventConfig =
|
1684
|
-
id:
|
1894
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1895
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
|
1896
|
+
var EventConfig = import_zod17.z.object({
|
1897
|
+
id: import_zod17.z.string().describe(
|
1685
1898
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1686
1899
|
),
|
1687
|
-
dateOfEvent:
|
1900
|
+
dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
|
1688
1901
|
title: TranslationConfig,
|
1689
1902
|
fallbackTitle: TranslationConfig.optional().describe(
|
1690
1903
|
"This is a fallback title if actual title resolves to empty string"
|
1691
1904
|
),
|
1692
1905
|
summary: SummaryConfig,
|
1693
1906
|
label: TranslationConfig,
|
1694
|
-
actions:
|
1907
|
+
actions: import_zod17.z.array(ActionConfig),
|
1695
1908
|
declaration: DeclarationFormConfig,
|
1696
|
-
deduplication:
|
1697
|
-
advancedSearch:
|
1909
|
+
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1910
|
+
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1698
1911
|
}).superRefine((event2, ctx) => {
|
1699
1912
|
const allFields = findAllFields(event2);
|
1700
1913
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1756,350 +1969,103 @@ var definePage = (page) => PageConfig.parse(page);
|
|
1756
1969
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1757
1970
|
|
1758
1971
|
// ../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
1972
|
var import_zod20 = require("zod");
|
1783
1973
|
|
1784
|
-
// ../commons/src/events/
|
1974
|
+
// ../commons/src/events/EventIndex.ts
|
1975
|
+
var import_zod19 = require("zod");
|
1976
|
+
|
1977
|
+
// ../commons/src/events/EventMetadata.ts
|
1785
1978
|
var import_zod18 = require("zod");
|
1786
|
-
var
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1979
|
+
var EventStatus = {
|
1980
|
+
CREATED: "CREATED",
|
1981
|
+
NOTIFIED: "NOTIFIED",
|
1982
|
+
DECLARED: "DECLARED",
|
1983
|
+
VALIDATED: "VALIDATED",
|
1984
|
+
REGISTERED: "REGISTERED",
|
1985
|
+
CERTIFIED: "CERTIFIED",
|
1986
|
+
REJECTED: "REJECTED",
|
1987
|
+
ARCHIVED: "ARCHIVED"
|
1793
1988
|
};
|
1794
|
-
var
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1989
|
+
var eventStatusValues = [
|
1990
|
+
EventStatus.CREATED,
|
1991
|
+
EventStatus.NOTIFIED,
|
1992
|
+
EventStatus.DECLARED,
|
1993
|
+
EventStatus.VALIDATED,
|
1994
|
+
EventStatus.REGISTERED,
|
1995
|
+
EventStatus.CERTIFIED,
|
1996
|
+
EventStatus.REJECTED,
|
1997
|
+
EventStatus.ARCHIVED
|
1998
|
+
];
|
1999
|
+
var EventStatusEnum = import_zod18.z.enum(eventStatusValues);
|
2000
|
+
var CustomFlags = {
|
2001
|
+
CERTIFICATE_PRINTED: "certificate-printed"
|
2002
|
+
};
|
2003
|
+
var Flag = import_zod18.z.string().regex(
|
2004
|
+
new RegExp(
|
2005
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
|
2006
|
+
),
|
2007
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2008
|
+
).or(import_zod18.z.nativeEnum(CustomFlags));
|
2009
|
+
var eventStatuses = Object.values(EventStatus);
|
2010
|
+
var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
|
2011
|
+
var ZodDate = import_zod18.z.string().date();
|
2012
|
+
var ActionCreationMetadata = import_zod18.z.object({
|
2013
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
|
2014
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
|
2015
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
|
2016
|
+
acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
2017
|
+
createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
|
1811
2018
|
});
|
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"
|
2019
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2020
|
+
registrationNumber: import_zod18.z.string().describe(
|
2021
|
+
"Registration number of the event. Always present for accepted registrations."
|
2022
|
+
)
|
1910
2023
|
});
|
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({
|
2024
|
+
var LegalStatuses = import_zod18.z.object({
|
2025
|
+
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2026
|
+
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2027
|
+
});
|
2028
|
+
var EventMetadata = import_zod18.z.object({
|
1925
2029
|
id: import_zod18.z.string(),
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
)
|
2030
|
+
type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
|
2031
|
+
status: EventStatuses,
|
2032
|
+
legalStatuses: LegalStatuses.describe(
|
2033
|
+
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2034
|
+
),
|
2035
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2036
|
+
dateOfEvent: ZodDate.nullish(),
|
2037
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
|
2038
|
+
updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
|
2039
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
|
2040
|
+
updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
|
2041
|
+
updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
|
2042
|
+
assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
2043
|
+
updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
|
2044
|
+
trackingId: import_zod18.z.string().describe(
|
2045
|
+
"System-generated tracking ID used by informants or registrars to look up the event."
|
2046
|
+
),
|
2047
|
+
flags: import_zod18.z.array(Flag)
|
1934
2048
|
});
|
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()
|
2049
|
+
var EventMetadataKeys = import_zod18.z.enum([
|
2050
|
+
"id",
|
2051
|
+
"type",
|
2052
|
+
"status",
|
2053
|
+
"createdAt",
|
2054
|
+
"dateOfEvent",
|
2055
|
+
"createdBy",
|
2056
|
+
"updatedByUserRole",
|
2057
|
+
"createdAtLocation",
|
2058
|
+
"updatedAtLocation",
|
2059
|
+
"updatedAt",
|
2060
|
+
"assignedTo",
|
2061
|
+
"updatedBy",
|
2062
|
+
"trackingId",
|
2063
|
+
"legalStatuses",
|
2064
|
+
"flags"
|
2065
|
+
]);
|
2066
|
+
var EventMetadataParameter = import_zod18.z.object({
|
2067
|
+
// @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
|
2068
|
+
$event: EventMetadataKeys
|
2103
2069
|
});
|
2104
2070
|
var eventMetadataLabelMap = {
|
2105
2071
|
"event.assignedTo": {
|
@@ -2167,302 +2133,73 @@ var eventMetadataLabelMap = {
|
|
2167
2133
|
defaultMessage: "Tracking ID",
|
2168
2134
|
description: "Tracking ID"
|
2169
2135
|
},
|
2170
|
-
"event.
|
2171
|
-
id: "event.
|
2172
|
-
defaultMessage: "
|
2173
|
-
description: "
|
2136
|
+
"event.flags": {
|
2137
|
+
id: "event.flags.label",
|
2138
|
+
defaultMessage: "Flags",
|
2139
|
+
description: "Flags"
|
2174
2140
|
}
|
2175
2141
|
};
|
2176
2142
|
|
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
2143
|
// ../commons/src/events/EventIndex.ts
|
2201
|
-
var import_zod24 = require("zod");
|
2202
2144
|
var EventIndex = EventMetadata.extend({
|
2203
|
-
declaration:
|
2145
|
+
declaration: EventState
|
2204
2146
|
});
|
2205
|
-
var EventSearchIndex =
|
2206
|
-
|
2207
|
-
type:
|
2147
|
+
var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
|
2148
|
+
import_zod19.z.object({
|
2149
|
+
type: import_zod19.z.string()
|
2208
2150
|
// Ensures "type" (event-id) exists and is a string
|
2209
2151
|
})
|
2210
2152
|
);
|
2211
|
-
var Fuzzy =
|
2212
|
-
var Exact =
|
2213
|
-
var AnyOf =
|
2214
|
-
type:
|
2215
|
-
terms:
|
2153
|
+
var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
|
2154
|
+
var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
|
2155
|
+
var AnyOf = import_zod19.z.object({
|
2156
|
+
type: import_zod19.z.literal("anyOf"),
|
2157
|
+
terms: import_zod19.z.array(import_zod19.z.string())
|
2158
|
+
});
|
2159
|
+
var ExactStatus = import_zod19.z.object({
|
2160
|
+
type: import_zod19.z.literal("exact"),
|
2161
|
+
term: EventStatusEnum
|
2216
2162
|
});
|
2217
|
-
var
|
2218
|
-
type:
|
2219
|
-
|
2220
|
-
lte: import_zod24.z.string()
|
2163
|
+
var AnyOfStatus = import_zod19.z.object({
|
2164
|
+
type: import_zod19.z.literal("anyOf"),
|
2165
|
+
terms: import_zod19.z.array(EventStatusEnum)
|
2221
2166
|
});
|
2222
|
-
var
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2167
|
+
var Range = import_zod19.z.object({
|
2168
|
+
type: import_zod19.z.literal("range"),
|
2169
|
+
gte: import_zod19.z.string(),
|
2170
|
+
lte: import_zod19.z.string()
|
2171
|
+
});
|
2172
|
+
var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
|
2173
|
+
var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
|
2174
|
+
var DateCondition = import_zod19.z.union([Exact, Range]);
|
2175
|
+
var QueryInput = import_zod19.z.lazy(
|
2176
|
+
() => import_zod19.z.union([
|
2177
|
+
import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
2178
|
+
import_zod19.z.record(import_zod19.z.string(), QueryInput)
|
2228
2179
|
])
|
2229
2180
|
);
|
2230
|
-
var QueryExpression =
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2181
|
+
var QueryExpression = import_zod19.z.object({
|
2182
|
+
eventType: import_zod19.z.string(),
|
2183
|
+
status: import_zod19.z.optional(import_zod19.z.union([AnyOfStatus, ExactStatus])),
|
2184
|
+
createdAt: import_zod19.z.optional(DateCondition),
|
2185
|
+
updatedAt: import_zod19.z.optional(DateCondition),
|
2186
|
+
createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2187
|
+
updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2188
|
+
createdBy: import_zod19.z.optional(Exact),
|
2189
|
+
updatedBy: import_zod19.z.optional(Exact),
|
2190
|
+
trackingId: import_zod19.z.optional(Exact),
|
2191
|
+
flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
|
2241
2192
|
data: QueryInput
|
2242
2193
|
}).partial();
|
2243
|
-
var Or2 =
|
2244
|
-
type:
|
2245
|
-
clauses:
|
2194
|
+
var Or2 = import_zod19.z.object({
|
2195
|
+
type: import_zod19.z.literal("or"),
|
2196
|
+
clauses: import_zod19.z.array(QueryExpression)
|
2246
2197
|
});
|
2247
|
-
var
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
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");
|
2198
|
+
var And2 = import_zod19.z.object({
|
2199
|
+
type: import_zod19.z.literal("and"),
|
2200
|
+
clauses: import_zod19.z.array(QueryExpression)
|
2201
|
+
});
|
2202
|
+
var QueryType = import_zod19.z.discriminatedUnion("type", [Or2, And2]);
|
2466
2203
|
|
2467
2204
|
// ../commons/src/conditionals/conditionals.ts
|
2468
2205
|
function defineConditional(schema) {
|
@@ -2747,20 +2484,549 @@ function createFieldConditionals(fieldId) {
|
|
2747
2484
|
},
|
2748
2485
|
required: [fieldId]
|
2749
2486
|
}),
|
2750
|
-
isBetween: (min, max) => defineFormConditional({
|
2751
|
-
type: "object",
|
2752
|
-
properties: {
|
2753
|
-
[fieldId]: {
|
2754
|
-
type: "number",
|
2755
|
-
minimum: min,
|
2756
|
-
maximum: max
|
2487
|
+
isBetween: (min, max) => defineFormConditional({
|
2488
|
+
type: "object",
|
2489
|
+
properties: {
|
2490
|
+
[fieldId]: {
|
2491
|
+
type: "number",
|
2492
|
+
minimum: min,
|
2493
|
+
maximum: max
|
2494
|
+
}
|
2495
|
+
},
|
2496
|
+
required: [fieldId]
|
2497
|
+
}),
|
2498
|
+
getId: () => ({ fieldId })
|
2499
|
+
};
|
2500
|
+
}
|
2501
|
+
|
2502
|
+
// ../commons/src/event-config/event-configuration.ts
|
2503
|
+
function createEventFieldConfig(fieldId, options) {
|
2504
|
+
return {
|
2505
|
+
fieldId,
|
2506
|
+
options,
|
2507
|
+
config: { type: "exact" },
|
2508
|
+
fieldType: "event"
|
2509
|
+
};
|
2510
|
+
}
|
2511
|
+
|
2512
|
+
// ../commons/src/events/event.ts
|
2513
|
+
function eventFn(fieldId, options) {
|
2514
|
+
return createEventFieldConfig(fieldId, options);
|
2515
|
+
}
|
2516
|
+
var event = Object.assign(eventFn, {
|
2517
|
+
...createEventConditionals(),
|
2518
|
+
field(field2) {
|
2519
|
+
return {
|
2520
|
+
$event: field2
|
2521
|
+
};
|
2522
|
+
}
|
2523
|
+
});
|
2524
|
+
|
2525
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
2526
|
+
var WorkqueueConfig = import_zod20.z.object({
|
2527
|
+
slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
|
2528
|
+
name: TranslationConfig.describe(
|
2529
|
+
"Title of the workflow (both in navigation and on the page)"
|
2530
|
+
),
|
2531
|
+
query: QueryType,
|
2532
|
+
actions: import_zod20.z.array(
|
2533
|
+
import_zod20.z.object({
|
2534
|
+
type: import_zod20.z.string(),
|
2535
|
+
conditionals: import_zod20.z.array(Conditional).optional()
|
2536
|
+
})
|
2537
|
+
),
|
2538
|
+
columns: import_zod20.z.array(
|
2539
|
+
import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
|
2540
|
+
).default([
|
2541
|
+
{
|
2542
|
+
label: {
|
2543
|
+
id: "workqueues.dateOfEvent",
|
2544
|
+
defaultMessage: "Date of Event",
|
2545
|
+
description: "Label for workqueue column: dateOfEvent"
|
2546
|
+
},
|
2547
|
+
value: event.field("dateOfEvent")
|
2548
|
+
}
|
2549
|
+
])
|
2550
|
+
}).describe("Configuration for workqueue.");
|
2551
|
+
function defineWorkqueue(workqueues) {
|
2552
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
2553
|
+
}
|
2554
|
+
|
2555
|
+
// ../commons/src/events/Draft.ts
|
2556
|
+
var import_zod22 = require("zod");
|
2557
|
+
|
2558
|
+
// ../commons/src/events/ActionInput.ts
|
2559
|
+
var import_zod21 = require("zod");
|
2560
|
+
var import_zod_openapi5 = require("zod-openapi");
|
2561
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
|
2562
|
+
var BaseActionInput = import_zod21.z.object({
|
2563
|
+
eventId: import_zod21.z.string(),
|
2564
|
+
transactionId: import_zod21.z.string(),
|
2565
|
+
declaration: ActionUpdate.default({}),
|
2566
|
+
annotation: ActionUpdate.optional(),
|
2567
|
+
originalActionId: import_zod21.z.string().optional(),
|
2568
|
+
keepAssignment: import_zod21.z.boolean().optional()
|
2569
|
+
});
|
2570
|
+
var CreateActionInput = BaseActionInput.merge(
|
2571
|
+
import_zod21.z.object({
|
2572
|
+
type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2573
|
+
createdAtLocation: import_zod21.z.string()
|
2574
|
+
})
|
2575
|
+
);
|
2576
|
+
var RegisterActionInput = BaseActionInput.merge(
|
2577
|
+
import_zod21.z.object({
|
2578
|
+
type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2579
|
+
registrationNumber: import_zod21.z.string().optional()
|
2580
|
+
})
|
2581
|
+
);
|
2582
|
+
var ValidateActionInput = BaseActionInput.merge(
|
2583
|
+
import_zod21.z.object({
|
2584
|
+
type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2585
|
+
duplicates: import_zod21.z.array(import_zod21.z.string())
|
2586
|
+
})
|
2587
|
+
);
|
2588
|
+
var NotifyActionInput = BaseActionInput.merge(
|
2589
|
+
import_zod21.z.object({
|
2590
|
+
type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2591
|
+
})
|
2592
|
+
);
|
2593
|
+
var DeclareActionInput = BaseActionInput.merge(
|
2594
|
+
import_zod21.z.object({
|
2595
|
+
type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2596
|
+
})
|
2597
|
+
);
|
2598
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
2599
|
+
import_zod21.z.object({
|
2600
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2601
|
+
})
|
2602
|
+
);
|
2603
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2604
|
+
import_zod21.z.object({
|
2605
|
+
type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2606
|
+
})
|
2607
|
+
);
|
2608
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2609
|
+
import_zod21.z.object({
|
2610
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2611
|
+
})
|
2612
|
+
);
|
2613
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2614
|
+
import_zod21.z.object({
|
2615
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2616
|
+
})
|
2617
|
+
);
|
2618
|
+
var AssignActionInput = BaseActionInput.merge(
|
2619
|
+
import_zod21.z.object({
|
2620
|
+
type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2621
|
+
assignedTo: import_zod21.z.string()
|
2622
|
+
})
|
2623
|
+
);
|
2624
|
+
var UnassignActionInput = BaseActionInput.merge(
|
2625
|
+
import_zod21.z.object({
|
2626
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2627
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
2628
|
+
})
|
2629
|
+
);
|
2630
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2631
|
+
import_zod21.z.object({
|
2632
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2633
|
+
})
|
2634
|
+
);
|
2635
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2636
|
+
import_zod21.z.object({
|
2637
|
+
requestId: import_zod21.z.string(),
|
2638
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2639
|
+
})
|
2640
|
+
);
|
2641
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2642
|
+
import_zod21.z.object({
|
2643
|
+
requestId: import_zod21.z.string(),
|
2644
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2645
|
+
})
|
2646
|
+
);
|
2647
|
+
var ReadActionInput = BaseActionInput.merge(
|
2648
|
+
import_zod21.z.object({
|
2649
|
+
type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
|
2650
|
+
})
|
2651
|
+
);
|
2652
|
+
var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
|
2653
|
+
var ActionInput = import_zod21.z.discriminatedUnion("type", [
|
2654
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2655
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2656
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2657
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2658
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2659
|
+
RejectDeclarationActionInput.openapi({
|
2660
|
+
ref: "RejectDeclarationActionInput"
|
2661
|
+
}),
|
2662
|
+
MarkedAsDuplicateActionInput.openapi({
|
2663
|
+
ref: "MarkedAsDuplicateActionInput"
|
2664
|
+
}),
|
2665
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2666
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2667
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2668
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2669
|
+
RequestCorrectionActionInput.openapi({
|
2670
|
+
ref: "RequestCorrectionActionInput"
|
2671
|
+
}),
|
2672
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2673
|
+
ApproveCorrectionActionInput.openapi({
|
2674
|
+
ref: "ApproveCorrectionActionInput"
|
2675
|
+
}),
|
2676
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2677
|
+
]).openapi({
|
2678
|
+
ref: "ActionInput"
|
2679
|
+
});
|
2680
|
+
|
2681
|
+
// ../commons/src/events/Draft.ts
|
2682
|
+
var Draft = import_zod22.z.object({
|
2683
|
+
id: import_zod22.z.string(),
|
2684
|
+
eventId: import_zod22.z.string(),
|
2685
|
+
transactionId: import_zod22.z.string(),
|
2686
|
+
createdAt: import_zod22.z.string().datetime(),
|
2687
|
+
action: ActionBase.extend({
|
2688
|
+
type: ActionTypes
|
2689
|
+
}).omit({ id: true })
|
2690
|
+
});
|
2691
|
+
var DraftInput = BaseActionInput.extend({
|
2692
|
+
type: ActionTypes,
|
2693
|
+
status: import_zod22.z.enum([
|
2694
|
+
ActionStatus.Requested,
|
2695
|
+
ActionStatus.Accepted,
|
2696
|
+
ActionStatus.Rejected
|
2697
|
+
])
|
2698
|
+
});
|
2699
|
+
|
2700
|
+
// ../commons/src/events/EventInput.ts
|
2701
|
+
var import_zod23 = require("zod");
|
2702
|
+
var EventInput = import_zod23.z.object({
|
2703
|
+
transactionId: import_zod23.z.string(),
|
2704
|
+
type: import_zod23.z.string(),
|
2705
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
|
2706
|
+
});
|
2707
|
+
|
2708
|
+
// ../commons/src/events/EventDocument.ts
|
2709
|
+
var import_zod24 = require("zod");
|
2710
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2711
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
|
2712
|
+
var EventDocument = import_zod24.z.object({
|
2713
|
+
id: import_zod24.z.string(),
|
2714
|
+
type: import_zod24.z.string(),
|
2715
|
+
dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
|
2716
|
+
createdAt: import_zod24.z.string().datetime(),
|
2717
|
+
updatedAt: import_zod24.z.string().datetime(),
|
2718
|
+
actions: import_zod24.z.array(Action),
|
2719
|
+
trackingId: import_zod24.z.string()
|
2720
|
+
}).openapi({ ref: "EventDocument" });
|
2721
|
+
|
2722
|
+
// ../commons/src/events/state/utils.ts
|
2723
|
+
function getActionRequests(actionType, actions) {
|
2724
|
+
const filtered = actions.filter((action) => action.type === actionType);
|
2725
|
+
const accept = filtered.find(
|
2726
|
+
(action) => action.status === ActionStatus.Accepted
|
2727
|
+
);
|
2728
|
+
const request = filtered.find(
|
2729
|
+
(action) => action.status === ActionStatus.Requested
|
2730
|
+
);
|
2731
|
+
const reject = filtered.find(
|
2732
|
+
(action) => action.status === ActionStatus.Rejected
|
2733
|
+
);
|
2734
|
+
return {
|
2735
|
+
reject,
|
2736
|
+
accept,
|
2737
|
+
request
|
2738
|
+
};
|
2739
|
+
}
|
2740
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
2741
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
2742
|
+
actionType,
|
2743
|
+
actions
|
2744
|
+
);
|
2745
|
+
if (!acceptAction) {
|
2746
|
+
return null;
|
2747
|
+
}
|
2748
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
2749
|
+
return {
|
2750
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
2751
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
2752
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
2753
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
2754
|
+
acceptedAt: acceptAction.createdAt,
|
2755
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
2756
|
+
registrationNumber
|
2757
|
+
};
|
2758
|
+
}
|
2759
|
+
function getDeclarationActionUpdateMetadata(actions) {
|
2760
|
+
const createAction = getOrThrow(
|
2761
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
2762
|
+
`Event has no ${ActionType.CREATE} action`
|
2763
|
+
);
|
2764
|
+
return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
|
2765
|
+
(metadata, actionType) => {
|
2766
|
+
const { accept, request } = getActionRequests(actionType, actions);
|
2767
|
+
return {
|
2768
|
+
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
2769
|
+
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
2770
|
+
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
2771
|
+
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
2772
|
+
};
|
2773
|
+
},
|
2774
|
+
{
|
2775
|
+
createdAt: createAction.createdAt,
|
2776
|
+
createdBy: createAction.createdBy,
|
2777
|
+
createdAtLocation: createAction.createdAtLocation,
|
2778
|
+
createdByRole: createAction.createdByRole
|
2779
|
+
}
|
2780
|
+
);
|
2781
|
+
}
|
2782
|
+
function getLegalStatuses(actions) {
|
2783
|
+
return {
|
2784
|
+
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
2785
|
+
ActionType.DECLARE,
|
2786
|
+
actions
|
2787
|
+
),
|
2788
|
+
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
2789
|
+
ActionType.REGISTER,
|
2790
|
+
actions
|
2791
|
+
)
|
2792
|
+
};
|
2793
|
+
}
|
2794
|
+
|
2795
|
+
// ../commons/src/events/state/index.ts
|
2796
|
+
function getStatusFromActions(actions) {
|
2797
|
+
const hasRejectedAction = actions.some(
|
2798
|
+
(a) => a.status === ActionStatus.Rejected
|
2799
|
+
);
|
2800
|
+
if (hasRejectedAction) {
|
2801
|
+
return EventStatus.REJECTED;
|
2802
|
+
}
|
2803
|
+
return actions.reduce((status, action) => {
|
2804
|
+
switch (action.type) {
|
2805
|
+
case ActionType.CREATE:
|
2806
|
+
return EventStatus.CREATED;
|
2807
|
+
case ActionType.DECLARE:
|
2808
|
+
return EventStatus.DECLARED;
|
2809
|
+
case ActionType.VALIDATE:
|
2810
|
+
return EventStatus.VALIDATED;
|
2811
|
+
case ActionType.REGISTER:
|
2812
|
+
return EventStatus.REGISTERED;
|
2813
|
+
case ActionType.REJECT:
|
2814
|
+
return EventStatus.REJECTED;
|
2815
|
+
case ActionType.ARCHIVE:
|
2816
|
+
return EventStatus.ARCHIVED;
|
2817
|
+
case ActionType.NOTIFY:
|
2818
|
+
return EventStatus.NOTIFIED;
|
2819
|
+
case ActionType.PRINT_CERTIFICATE:
|
2820
|
+
return EventStatus.CERTIFIED;
|
2821
|
+
case ActionType.ASSIGN:
|
2822
|
+
case ActionType.UNASSIGN:
|
2823
|
+
case ActionType.REQUEST_CORRECTION:
|
2824
|
+
case ActionType.APPROVE_CORRECTION:
|
2825
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2826
|
+
case ActionType.REJECT_CORRECTION:
|
2827
|
+
case ActionType.READ:
|
2828
|
+
default:
|
2829
|
+
return status;
|
2830
|
+
}
|
2831
|
+
}, EventStatus.CREATED);
|
2832
|
+
}
|
2833
|
+
function getFlagsFromActions(actions) {
|
2834
|
+
const sortedactions = actions.sort(
|
2835
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
2836
|
+
);
|
2837
|
+
const actionStatus = sortedactions.reduce(
|
2838
|
+
(actionStatuses, { type, status }) => ({
|
2839
|
+
...actionStatuses,
|
2840
|
+
[type]: status
|
2841
|
+
}),
|
2842
|
+
{}
|
2843
|
+
);
|
2844
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
2845
|
+
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
2846
|
+
return flag;
|
2847
|
+
});
|
2848
|
+
const isCertificatePrinted = sortedactions.reduce(
|
2849
|
+
(prev, { type }) => {
|
2850
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
2851
|
+
return true;
|
2852
|
+
}
|
2853
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
2854
|
+
return false;
|
2855
|
+
}
|
2856
|
+
return prev;
|
2857
|
+
},
|
2858
|
+
false
|
2859
|
+
);
|
2860
|
+
if (isCertificatePrinted) {
|
2861
|
+
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
2862
|
+
}
|
2863
|
+
return flags;
|
2864
|
+
}
|
2865
|
+
function getAssignedUserFromActions(actions) {
|
2866
|
+
return actions.reduce((user2, action) => {
|
2867
|
+
if (action.type === ActionType.ASSIGN) {
|
2868
|
+
return action.assignedTo;
|
2869
|
+
}
|
2870
|
+
if (action.type === ActionType.UNASSIGN) {
|
2871
|
+
return null;
|
2872
|
+
}
|
2873
|
+
return user2;
|
2874
|
+
}, null);
|
2875
|
+
}
|
2876
|
+
function aggregateActionDeclarations(actions) {
|
2877
|
+
const excludedActions = [
|
2878
|
+
ActionType.REQUEST_CORRECTION,
|
2879
|
+
ActionType.PRINT_CERTIFICATE
|
2880
|
+
];
|
2881
|
+
return actions.reduce((status, action) => {
|
2882
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2883
|
+
return status;
|
2884
|
+
}
|
2885
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2886
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2887
|
+
if (!requestAction) {
|
2888
|
+
return status;
|
2889
|
+
}
|
2890
|
+
return deepMerge(status, requestAction.declaration);
|
2891
|
+
}
|
2892
|
+
return deepMerge(status, action.declaration);
|
2893
|
+
}, {});
|
2894
|
+
}
|
2895
|
+
function deepDropNulls(obj) {
|
2896
|
+
if (Array.isArray(obj)) {
|
2897
|
+
return obj.map(deepDropNulls);
|
2898
|
+
}
|
2899
|
+
if (obj !== null && typeof obj === "object") {
|
2900
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2901
|
+
const cleanedValue = deepDropNulls(value);
|
2902
|
+
if (cleanedValue !== null) {
|
2903
|
+
;
|
2904
|
+
acc[key] = cleanedValue;
|
2905
|
+
}
|
2906
|
+
return acc;
|
2907
|
+
}, {});
|
2908
|
+
}
|
2909
|
+
return obj;
|
2910
|
+
}
|
2911
|
+
function isUndeclaredDraft(status) {
|
2912
|
+
return status === EventStatus.CREATED;
|
2913
|
+
}
|
2914
|
+
function getAcceptedActions(event2) {
|
2915
|
+
return event2.actions.filter(
|
2916
|
+
(a) => a.status === ActionStatus.Accepted
|
2917
|
+
);
|
2918
|
+
}
|
2919
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
2920
|
+
function getCurrentEventState(event2) {
|
2921
|
+
const creationAction = event2.actions.find(
|
2922
|
+
(action) => action.type === ActionType.CREATE
|
2923
|
+
);
|
2924
|
+
if (!creationAction) {
|
2925
|
+
throw new Error(`Event ${event2.id} has no creation action`);
|
2926
|
+
}
|
2927
|
+
const acceptedActions = getAcceptedActions(event2);
|
2928
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
2929
|
+
event2.actions
|
2930
|
+
);
|
2931
|
+
const declaration = aggregateActionDeclarations(acceptedActions);
|
2932
|
+
const dateOfEvent = ZodDate.safeParse(
|
2933
|
+
event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
|
2934
|
+
).data ?? null;
|
2935
|
+
return deepDropNulls({
|
2936
|
+
id: event2.id,
|
2937
|
+
type: event2.type,
|
2938
|
+
status: getStatusFromActions(event2.actions),
|
2939
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
2940
|
+
createdAt: creationAction.createdAt,
|
2941
|
+
createdBy: creationAction.createdBy,
|
2942
|
+
createdAtLocation: creationAction.createdAtLocation,
|
2943
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
2944
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
2945
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
2946
|
+
updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
|
2947
|
+
declaration,
|
2948
|
+
trackingId: event2.trackingId,
|
2949
|
+
// @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
|
2950
|
+
updatedByUserRole: declarationUpdateMetadata.createdByRole,
|
2951
|
+
dateOfEvent,
|
2952
|
+
flags: getFlagsFromActions(event2.actions)
|
2953
|
+
});
|
2954
|
+
}
|
2955
|
+
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2956
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2957
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2958
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2959
|
+
return [
|
2960
|
+
action,
|
2961
|
+
{
|
2962
|
+
...action,
|
2963
|
+
type: ActionType.APPROVE_CORRECTION
|
2757
2964
|
}
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2965
|
+
];
|
2966
|
+
}
|
2967
|
+
return [action];
|
2968
|
+
});
|
2969
|
+
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2970
|
+
const withDrafts = {
|
2971
|
+
...event2,
|
2972
|
+
actions: actionWithDrafts
|
2973
|
+
};
|
2974
|
+
return getCurrentEventState(withDrafts);
|
2975
|
+
}
|
2976
|
+
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2977
|
+
const indexedAt = eventIndex.updatedAt;
|
2978
|
+
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2979
|
+
if (activeDrafts.length === 0) {
|
2980
|
+
return eventIndex;
|
2981
|
+
}
|
2982
|
+
return {
|
2983
|
+
...eventIndex,
|
2984
|
+
declaration: {
|
2985
|
+
...eventIndex.declaration,
|
2986
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2987
|
+
}
|
2762
2988
|
};
|
2763
2989
|
}
|
2990
|
+
function getAnnotationFromDrafts(drafts) {
|
2991
|
+
const actions = drafts.map((draft) => draft.action);
|
2992
|
+
const annotation = actions.reduce((ann, action) => {
|
2993
|
+
return deepMerge(ann, action.annotation ?? {});
|
2994
|
+
}, {});
|
2995
|
+
return deepDropNulls(annotation);
|
2996
|
+
}
|
2997
|
+
function getActionAnnotation({
|
2998
|
+
event: event2,
|
2999
|
+
actionType,
|
3000
|
+
drafts = []
|
3001
|
+
}) {
|
3002
|
+
const activeActions = getAcceptedActions(event2);
|
3003
|
+
const action = activeActions.find(
|
3004
|
+
(activeAction) => actionType === activeAction.type
|
3005
|
+
);
|
3006
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
3007
|
+
const sorted = [
|
3008
|
+
...action ? [action] : [],
|
3009
|
+
...eventDrafts.map((draft) => draft.action)
|
3010
|
+
].sort();
|
3011
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
3012
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
3013
|
+
}, {});
|
3014
|
+
return deepDropNulls(annotation);
|
3015
|
+
}
|
3016
|
+
|
3017
|
+
// ../commons/src/events/defineConfig.ts
|
3018
|
+
var defineConfig = (config) => {
|
3019
|
+
const input = EventConfig.parse(config);
|
3020
|
+
return input;
|
3021
|
+
};
|
3022
|
+
|
3023
|
+
// ../commons/src/events/transactions.ts
|
3024
|
+
function generateTransactionId() {
|
3025
|
+
return getUUID();
|
3026
|
+
}
|
3027
|
+
|
3028
|
+
// ../commons/src/events/test.utils.ts
|
3029
|
+
var import_lodash2 = require("lodash");
|
2764
3030
|
|
2765
3031
|
// ../commons/src/field-config/field-configuration.ts
|
2766
3032
|
function createFieldConfigs(fieldId) {
|
@@ -2772,43 +3038,43 @@ function createFieldConfigs(fieldId) {
|
|
2772
3038
|
/**
|
2773
3039
|
* Creates a range configuration for the specified field.
|
2774
3040
|
*
|
2775
|
-
* @returns An object containing the field ID and a configuration object with a type of '
|
3041
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2776
3042
|
*
|
2777
3043
|
* @example field('age').range()
|
2778
3044
|
* // {
|
2779
3045
|
* // fieldId: 'age',
|
2780
|
-
* // config: { type: '
|
3046
|
+
* // config: { type: 'range' }
|
2781
3047
|
* // }
|
2782
3048
|
*/
|
2783
3049
|
range: () => ({
|
2784
3050
|
...baseField,
|
2785
|
-
config: { type: "
|
3051
|
+
config: { type: "range" }
|
2786
3052
|
}),
|
2787
3053
|
/**
|
2788
3054
|
* 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 '
|
3055
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2790
3056
|
* @example field('dob').exact()
|
2791
3057
|
* // {
|
2792
3058
|
* // fieldId: 'dob',
|
2793
|
-
* // config: { type: '
|
3059
|
+
* // config: { type: 'exact' }
|
2794
3060
|
* // }
|
2795
3061
|
*/
|
2796
3062
|
exact: () => ({
|
2797
3063
|
...baseField,
|
2798
|
-
config: { type: "
|
3064
|
+
config: { type: "exact" }
|
2799
3065
|
}),
|
2800
3066
|
/**
|
2801
3067
|
* 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 '
|
3068
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2803
3069
|
* @example field('name').fuzzy()
|
2804
3070
|
* // {
|
2805
3071
|
* // fieldId: 'name',
|
2806
|
-
* // config: { type: '
|
3072
|
+
* // config: { type: 'fuzzy' }
|
2807
3073
|
* // }
|
2808
3074
|
*/
|
2809
3075
|
fuzzy: () => ({
|
2810
3076
|
...baseField,
|
2811
|
-
config: { type: "
|
3077
|
+
config: { type: "fuzzy" }
|
2812
3078
|
})
|
2813
3079
|
};
|
2814
3080
|
}
|
@@ -3767,22 +4033,15 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3767
4033
|
}
|
3768
4034
|
},
|
3769
4035
|
{
|
3770
|
-
|
4036
|
+
fieldId: "applicant.surname",
|
3771
4037
|
label: {
|
3772
4038
|
defaultMessage: "Applicant's last name",
|
3773
|
-
description: "
|
3774
|
-
id: "event.tennis-club-membership.summary.field.surname.label"
|
3775
|
-
},
|
3776
|
-
value: {
|
3777
|
-
defaultMessage: "{applicant.surname}",
|
3778
|
-
description: "This is the value to show in the summary",
|
3779
|
-
id: "event.tennis-club-membership.summary.field.surname"
|
3780
|
-
},
|
3781
|
-
emptyValueMessage: {
|
3782
|
-
defaultMessage: "Last name is not provided",
|
3783
|
-
description: "This is the message to show when the field is empty",
|
3784
|
-
id: "event.tennis-club-membership.summary.field.surname.empty"
|
4039
|
+
description: "Label for surname",
|
4040
|
+
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
3785
4041
|
}
|
4042
|
+
},
|
4043
|
+
{
|
4044
|
+
fieldId: "applicant.email"
|
3786
4045
|
}
|
3787
4046
|
]
|
3788
4047
|
},
|
@@ -4176,8 +4435,7 @@ var eventPayloadGenerator = {
|
|
4176
4435
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4177
4436
|
createdBy: "@todo",
|
4178
4437
|
createdByRole: "@todo",
|
4179
|
-
createdAtLocation: "@todo"
|
4180
|
-
updatedAtLocation: "@todo"
|
4438
|
+
createdAtLocation: "@todo"
|
4181
4439
|
}
|
4182
4440
|
},
|
4183
4441
|
input
|
@@ -4340,13 +4598,12 @@ function generateActionDocument({
|
|
4340
4598
|
createdBy: getUUID(),
|
4341
4599
|
createdByRole: "FIELD_AGENT",
|
4342
4600
|
id: getUUID(),
|
4343
|
-
createdAtLocation: "
|
4344
|
-
updatedAtLocation: "TODO",
|
4601
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4345
4602
|
declaration: generateActionDeclarationInput(configuration, action),
|
4346
4603
|
annotation: {},
|
4347
|
-
...defaults,
|
4348
4604
|
status: ActionStatus.Accepted,
|
4349
|
-
transactionId: getUUID()
|
4605
|
+
transactionId: getUUID(),
|
4606
|
+
...defaults
|
4350
4607
|
};
|
4351
4608
|
switch (action) {
|
4352
4609
|
case ActionType.READ:
|
@@ -4405,8 +4662,7 @@ function generateEventDocument({
|
|
4405
4662
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4406
4663
|
// @TODO: This should be fixed in the future.
|
4407
4664
|
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4408
|
-
dateOfEvent: configuration.dateOfEvent
|
4409
|
-
updatedAtLocation: getUUID()
|
4665
|
+
dateOfEvent: configuration.dateOfEvent
|
4410
4666
|
};
|
4411
4667
|
}
|
4412
4668
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4428,10 +4684,64 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4428
4684
|
eventId
|
4429
4685
|
};
|
4430
4686
|
}
|
4687
|
+
function getEventStatus() {
|
4688
|
+
const statuses = [
|
4689
|
+
EventStatus.CREATED,
|
4690
|
+
EventStatus.REGISTERED,
|
4691
|
+
EventStatus.DECLARED
|
4692
|
+
];
|
4693
|
+
const randomIndex = Math.floor(Math.random() * 3);
|
4694
|
+
return statuses[randomIndex];
|
4695
|
+
}
|
4696
|
+
function getTrackingId() {
|
4697
|
+
const uuid = getUUID().replace(/-/g, "");
|
4698
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4699
|
+
return trackingId;
|
4700
|
+
}
|
4701
|
+
function getRandomApplicant() {
|
4702
|
+
const firstNames = [
|
4703
|
+
"Danny",
|
4704
|
+
"John",
|
4705
|
+
"Jane",
|
4706
|
+
"Emily",
|
4707
|
+
"Michael",
|
4708
|
+
"Sarah",
|
4709
|
+
"Chris",
|
4710
|
+
"Jessica"
|
4711
|
+
];
|
4712
|
+
const surnames = [
|
4713
|
+
"Doe",
|
4714
|
+
"Smith",
|
4715
|
+
"Johnson",
|
4716
|
+
"Brown",
|
4717
|
+
"Williams",
|
4718
|
+
"Jones",
|
4719
|
+
"Garcia",
|
4720
|
+
"Miller"
|
4721
|
+
];
|
4722
|
+
function getRandomDate(start, end) {
|
4723
|
+
const randomDate = new Date(
|
4724
|
+
start.getTime() + Math.random() * (end.getTime() - start.getTime())
|
4725
|
+
);
|
4726
|
+
return randomDate.toISOString().split("T")[0];
|
4727
|
+
}
|
4728
|
+
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
4729
|
+
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
|
4730
|
+
const randomDob = getRandomDate(
|
4731
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
4732
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
4733
|
+
);
|
4734
|
+
return {
|
4735
|
+
"recommender.none": true,
|
4736
|
+
"applicant.firstname": randomFirstName,
|
4737
|
+
"applicant.surname": randomSurname,
|
4738
|
+
"applicant.dob": randomDob
|
4739
|
+
};
|
4740
|
+
}
|
4431
4741
|
var eventQueryDataGenerator = (overrides = {}) => ({
|
4432
4742
|
id: overrides.id ?? getUUID(),
|
4433
|
-
type: overrides.type ?? "
|
4434
|
-
status: overrides.status ??
|
4743
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4744
|
+
status: overrides.status ?? getEventStatus(),
|
4435
4745
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4436
4746
|
createdBy: overrides.createdBy ?? getUUID(),
|
4437
4747
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
@@ -4440,13 +4750,10 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4440
4750
|
assignedTo: overrides.assignedTo ?? null,
|
4441
4751
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4442
4752
|
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
"applicant.dob": "1999-11-11"
|
4448
|
-
},
|
4449
|
-
trackingId: overrides.trackingId ?? "M3F8YQ"
|
4753
|
+
flags: [],
|
4754
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
4755
|
+
declaration: overrides.declaration ?? getRandomApplicant(),
|
4756
|
+
trackingId: overrides.trackingId ?? getTrackingId()
|
4450
4757
|
});
|
4451
4758
|
var generateTranslationConfig = (message) => ({
|
4452
4759
|
defaultMessage: message,
|
@@ -4490,6 +4797,7 @@ function isFieldConfigDefaultValue(value) {
|
|
4490
4797
|
var import_lodash3 = require("lodash");
|
4491
4798
|
|
4492
4799
|
// ../commons/src/scopes.ts
|
4800
|
+
var import_zod25 = require("zod");
|
4493
4801
|
var SCOPES = {
|
4494
4802
|
// TODO v1.8 legacy scopes
|
4495
4803
|
NATLSYSADMIN: "natlsysadmin",
|
@@ -4600,12 +4908,118 @@ var SCOPES = {
|
|
4600
4908
|
// data seeding
|
4601
4909
|
USER_DATA_SEEDING: "user.data-seeding"
|
4602
4910
|
};
|
4911
|
+
var LiteralScopes = import_zod25.z.union([
|
4912
|
+
import_zod25.z.literal(SCOPES.NATLSYSADMIN),
|
4913
|
+
import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
|
4914
|
+
import_zod25.z.literal(SCOPES.DECLARE),
|
4915
|
+
import_zod25.z.literal(SCOPES.REGISTER),
|
4916
|
+
import_zod25.z.literal(SCOPES.VALIDATE),
|
4917
|
+
import_zod25.z.literal(SCOPES.DEMO),
|
4918
|
+
import_zod25.z.literal(SCOPES.CERTIFY),
|
4919
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE),
|
4920
|
+
import_zod25.z.literal(SCOPES.SYSADMIN),
|
4921
|
+
import_zod25.z.literal(SCOPES.TEAMS),
|
4922
|
+
import_zod25.z.literal(SCOPES.CONFIG),
|
4923
|
+
import_zod25.z.literal(SCOPES.WEBHOOK),
|
4924
|
+
import_zod25.z.literal(SCOPES.NATIONALID),
|
4925
|
+
import_zod25.z.literal(SCOPES.NOTIFICATION_API),
|
4926
|
+
import_zod25.z.literal(SCOPES.RECORDSEARCH),
|
4927
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
4928
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
4929
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
4930
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
4931
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
4932
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
4933
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
4934
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
4935
|
+
import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
4936
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
4937
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
4938
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
4939
|
+
import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
4940
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
4941
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
4942
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTER),
|
4943
|
+
import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
4944
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
4945
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
4946
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
4947
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
4948
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
4949
|
+
import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
4950
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
4951
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
4952
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
4953
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
4954
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
4955
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
4956
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
4957
|
+
import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
4958
|
+
import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
4959
|
+
import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
4960
|
+
import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
|
4961
|
+
import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
4962
|
+
import_zod25.z.literal(SCOPES.SEARCH_DEATH),
|
4963
|
+
import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
4964
|
+
import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
|
4965
|
+
import_zod25.z.literal(SCOPES.RECORD_READ),
|
4966
|
+
import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
|
4967
|
+
import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
4968
|
+
import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
4969
|
+
import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
|
4970
|
+
import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
4971
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
|
4972
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
4973
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
4974
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
4975
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
4976
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
4977
|
+
import_zod25.z.literal(SCOPES.USER_READ),
|
4978
|
+
import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
4979
|
+
import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
4980
|
+
import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
4981
|
+
import_zod25.z.literal(SCOPES.USER_CREATE),
|
4982
|
+
import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
4983
|
+
import_zod25.z.literal(SCOPES.USER_UPDATE),
|
4984
|
+
import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
4985
|
+
import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
4986
|
+
import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
|
4987
|
+
]);
|
4988
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w-]+(?:\|[\w-]+)*)(:?,[\w-]+=[\w-]+(?:\|[\w-]+)*)*)\]$/;
|
4989
|
+
var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
|
4990
|
+
var CreateUserScope = import_zod25.z.object({
|
4991
|
+
type: import_zod25.z.literal("user.create"),
|
4992
|
+
options: import_zod25.z.object({
|
4993
|
+
role: import_zod25.z.array(import_zod25.z.string())
|
4994
|
+
})
|
4995
|
+
});
|
4996
|
+
var EditUserScope = import_zod25.z.object({
|
4997
|
+
type: import_zod25.z.literal("user.edit"),
|
4998
|
+
options: import_zod25.z.object({
|
4999
|
+
role: import_zod25.z.array(import_zod25.z.string())
|
5000
|
+
})
|
5001
|
+
});
|
5002
|
+
var WorkqueueScope = import_zod25.z.object({
|
5003
|
+
type: import_zod25.z.literal("workqueue"),
|
5004
|
+
options: import_zod25.z.object({
|
5005
|
+
id: import_zod25.z.array(import_zod25.z.string())
|
5006
|
+
})
|
5007
|
+
});
|
5008
|
+
var NotifyEventScope = import_zod25.z.object({
|
5009
|
+
type: import_zod25.z.literal("notify.event"),
|
5010
|
+
options: import_zod25.z.object({
|
5011
|
+
event: import_zod25.z.array(import_zod25.z.string())
|
5012
|
+
})
|
5013
|
+
});
|
5014
|
+
var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
|
5015
|
+
CreateUserScope,
|
5016
|
+
EditUserScope,
|
5017
|
+
WorkqueueScope,
|
5018
|
+
NotifyEventScope
|
5019
|
+
]);
|
4603
5020
|
var scopes = Object.values(SCOPES);
|
4604
5021
|
|
4605
5022
|
// ../commons/src/events/scopes.ts
|
4606
|
-
function hasAnyOfScopes(a, b) {
|
4607
|
-
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4608
|
-
}
|
4609
5023
|
var CONFIG_GET_ALLOWED_SCOPES = [
|
4610
5024
|
SCOPES.RECORD_DECLARE,
|
4611
5025
|
SCOPES.RECORD_READ,
|
@@ -4663,6 +5077,9 @@ var ACTION_ALLOWED_SCOPES = {
|
|
4663
5077
|
[ActionType.UNASSIGN]: null,
|
4664
5078
|
[ActionType.DETECT_DUPLICATE]: []
|
4665
5079
|
};
|
5080
|
+
function hasAnyOfScopes(a, b) {
|
5081
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
5082
|
+
}
|
4666
5083
|
function filterUnallowedActions(actions, userScopes) {
|
4667
5084
|
const allowedActions = actions.filter((action) => {
|
4668
5085
|
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
@@ -4679,19 +5096,3 @@ function filterUnallowedActions(actions, userScopes) {
|
|
4679
5096
|
}
|
4680
5097
|
return [ActionType.READ];
|
4681
5098
|
}
|
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());
|