@opencrvs/toolkit 1.8.0-rc.f8a9481 → 1.8.0-rc.f8b1f33
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 +4013 -322
- package/dist/commons/conditionals/validate.d.ts +6 -4
- package/dist/commons/events/ActionDocument.d.ts +6 -212
- package/dist/commons/events/ActionInput.d.ts +60 -68
- package/dist/commons/events/CompositeFieldValue.d.ts +0 -3
- package/dist/commons/events/Draft.d.ts +4 -14
- package/dist/commons/events/EventConfig.d.ts +68 -153
- package/dist/commons/events/EventDocument.d.ts +4 -163
- package/dist/commons/events/EventIndex.d.ts +0 -6
- package/dist/commons/events/EventMetadata.d.ts +0 -6
- package/dist/commons/events/FieldConfig.d.ts +10 -51
- package/dist/commons/events/SummaryConfig.d.ts +7 -93
- package/dist/commons/events/User.d.ts +0 -5
- package/dist/commons/events/WorkqueueConfig.d.ts +20 -44
- package/dist/commons/events/defineConfig.d.ts +8 -13
- package/dist/commons/events/index.d.ts +0 -1
- package/dist/commons/events/utils.d.ts +3 -3
- package/dist/events/index.js +514 -652
- package/dist/scopes/index.d.ts +70 -1
- package/dist/scopes/index.js +130 -0
- package/package.json +1 -1
- package/dist/commons/events/scopes.d.ts +0 -25
package/dist/events/index.js
CHANGED
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
30
30
|
// src/events/index.ts
|
31
31
|
var events_exports = {};
|
32
32
|
__export(events_exports, {
|
33
|
-
ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
|
34
33
|
Action: () => Action,
|
35
34
|
ActionBase: () => ActionBase,
|
36
35
|
ActionConditional: () => ActionConditional,
|
@@ -53,7 +52,6 @@ __export(events_exports, {
|
|
53
52
|
AssignActionInput: () => AssignActionInput,
|
54
53
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
55
54
|
BaseActionInput: () => BaseActionInput,
|
56
|
-
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
57
55
|
CertificateConfig: () => CertificateConfig,
|
58
56
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
59
57
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
@@ -71,7 +69,6 @@ __export(events_exports, {
|
|
71
69
|
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
72
70
|
DeclareActionInput: () => DeclareActionInput,
|
73
71
|
DeduplicationConfig: () => DeduplicationConfig,
|
74
|
-
DeleteActionInput: () => DeleteActionInput,
|
75
72
|
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
76
73
|
Draft: () => Draft,
|
77
74
|
DraftInput: () => DraftInput,
|
@@ -133,7 +130,6 @@ __export(events_exports, {
|
|
133
130
|
and: () => and,
|
134
131
|
annotationActions: () => annotationActions,
|
135
132
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
136
|
-
areConditionsMet: () => areConditionsMet,
|
137
133
|
compositeFieldTypes: () => compositeFieldTypes,
|
138
134
|
createEmptyDraft: () => createEmptyDraft,
|
139
135
|
createValidationSchema: () => createValidationSchema,
|
@@ -146,7 +142,6 @@ __export(events_exports, {
|
|
146
142
|
defineFormConditional: () => defineFormConditional,
|
147
143
|
defineFormPage: () => defineFormPage,
|
148
144
|
definePage: () => definePage,
|
149
|
-
defineWorkqueue: () => defineWorkqueue,
|
150
145
|
errorMessages: () => errorMessages,
|
151
146
|
event: () => event,
|
152
147
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -155,7 +150,6 @@ __export(events_exports, {
|
|
155
150
|
eventStatuses: () => eventStatuses,
|
156
151
|
field: () => field,
|
157
152
|
fieldTypes: () => fieldTypes,
|
158
|
-
filterUnallowedActions: () => filterUnallowedActions,
|
159
153
|
findActiveDrafts: () => findActiveDrafts,
|
160
154
|
findAllFields: () => findAllFields,
|
161
155
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
@@ -174,18 +168,16 @@ __export(events_exports, {
|
|
174
168
|
getActionReviewFields: () => getActionReviewFields,
|
175
169
|
getAllAnnotationFields: () => getAllAnnotationFields,
|
176
170
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
177
|
-
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
178
171
|
getCurrentEventState: () => getCurrentEventState,
|
179
172
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
180
173
|
getDeclaration: () => getDeclaration,
|
181
174
|
getDeclarationFields: () => getDeclarationFields,
|
182
175
|
getDeclarationPages: () => getDeclarationPages,
|
183
|
-
|
176
|
+
getFieldValidationErrors: () => getFieldValidationErrors,
|
184
177
|
isAddressFieldType: () => isAddressFieldType,
|
185
178
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
186
179
|
isBulletListFieldType: () => isBulletListFieldType,
|
187
180
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
188
|
-
isConditionMet: () => isConditionMet,
|
189
181
|
isCountryFieldType: () => isCountryFieldType,
|
190
182
|
isDataFieldType: () => isDataFieldType,
|
191
183
|
isDateFieldType: () => isDateFieldType,
|
@@ -223,10 +215,10 @@ __export(events_exports, {
|
|
223
215
|
omitHiddenFields: () => omitHiddenFields,
|
224
216
|
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
225
217
|
or: () => or,
|
226
|
-
runFieldValidations: () => runFieldValidations,
|
227
218
|
user: () => user,
|
228
219
|
validate: () => validate,
|
229
220
|
validateFieldInput: () => validateFieldInput,
|
221
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
230
222
|
writeActions: () => writeActions
|
231
223
|
});
|
232
224
|
module.exports = __toCommonJS(events_exports);
|
@@ -236,12 +228,9 @@ var import_zod9 = require("zod");
|
|
236
228
|
|
237
229
|
// ../commons/src/events/Conditional.ts
|
238
230
|
var import_zod = require("zod");
|
239
|
-
var
|
240
|
-
(
|
241
|
-
|
242
|
-
description: "JSON schema conditional configuration",
|
243
|
-
ref: "Conditional"
|
244
|
-
});
|
231
|
+
var Conditional = import_zod.z.custom(
|
232
|
+
(val) => typeof val === "object" && val !== null
|
233
|
+
);
|
245
234
|
var ConditionalType = {
|
246
235
|
SHOW: "SHOW",
|
247
236
|
ENABLE: "ENABLE",
|
@@ -278,10 +267,7 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
|
278
267
|
EnableConditional,
|
279
268
|
// Field output can be shown / hidden on the review page
|
280
269
|
DisplayOnReviewConditional
|
281
|
-
])
|
282
|
-
description: "Field conditional configuration",
|
283
|
-
ref: "FieldConditional"
|
284
|
-
});
|
270
|
+
]);
|
285
271
|
|
286
272
|
// ../commons/src/events/PageConfig.ts
|
287
273
|
var import_zod6 = require("zod");
|
@@ -291,8 +277,6 @@ var import_zod5 = require("zod");
|
|
291
277
|
|
292
278
|
// ../commons/src/events/TranslationConfig.ts
|
293
279
|
var import_zod2 = require("zod");
|
294
|
-
var import_zod_openapi2 = require("zod-openapi");
|
295
|
-
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod2.z);
|
296
280
|
var TranslationConfig = import_zod2.z.object({
|
297
281
|
id: import_zod2.z.string().describe(
|
298
282
|
"The identifier of the translation referred in translation CSV files"
|
@@ -301,14 +285,8 @@ var TranslationConfig = import_zod2.z.object({
|
|
301
285
|
description: import_zod2.z.string().describe(
|
302
286
|
"Describe the translation for a translator to be able to identify it."
|
303
287
|
)
|
304
|
-
}).openapi({
|
305
|
-
description: "Translation configuration",
|
306
|
-
ref: "TranslationConfig"
|
307
288
|
});
|
308
289
|
|
309
|
-
// ../commons/src/events/FieldConfig.ts
|
310
|
-
var import_zod_openapi3 = require("zod-openapi");
|
311
|
-
|
312
290
|
// ../commons/src/events/FieldType.ts
|
313
291
|
var FieldType = {
|
314
292
|
ADDRESS: "ADDRESS",
|
@@ -459,7 +437,6 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
459
437
|
]);
|
460
438
|
|
461
439
|
// ../commons/src/events/FieldConfig.ts
|
462
|
-
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
|
463
440
|
var FieldId = import_zod5.z.string();
|
464
441
|
var DependencyExpression = import_zod5.z.object({
|
465
442
|
dependsOn: import_zod5.z.array(FieldId).default([]),
|
@@ -595,8 +572,7 @@ var File = BaseField.extend({
|
|
595
572
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
596
573
|
"Whether the file upload button should take the full width of the container or not"
|
597
574
|
)
|
598
|
-
}).optional()
|
599
|
-
fileName: TranslationConfig.optional()
|
575
|
+
}).optional()
|
600
576
|
}).default({
|
601
577
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
602
578
|
})
|
@@ -683,7 +659,7 @@ var Address = BaseField.extend({
|
|
683
659
|
var DataEntry = import_zod5.z.union([
|
684
660
|
import_zod5.z.object({
|
685
661
|
label: TranslationConfig,
|
686
|
-
value:
|
662
|
+
value: import_zod5.z.string()
|
687
663
|
}),
|
688
664
|
import_zod5.z.object({
|
689
665
|
fieldId: import_zod5.z.string()
|
@@ -719,14 +695,10 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
719
695
|
EmailField,
|
720
696
|
FileUploadWithOptions,
|
721
697
|
DataField
|
722
|
-
|
723
|
-
|
724
|
-
ref: "FieldConfig"
|
725
|
-
});
|
698
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
699
|
+
]);
|
726
700
|
|
727
701
|
// ../commons/src/events/PageConfig.ts
|
728
|
-
var import_zod_openapi4 = require("zod-openapi");
|
729
|
-
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
|
730
702
|
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
731
703
|
var PageConfigBase = import_zod6.z.object({
|
732
704
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
@@ -738,9 +710,6 @@ var PageConfigBase = import_zod6.z.object({
|
|
738
710
|
});
|
739
711
|
var FormPageConfig = PageConfigBase.extend({
|
740
712
|
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
741
|
-
}).openapi({
|
742
|
-
description: "Form page configuration",
|
743
|
-
ref: "FormPageConfig"
|
744
713
|
});
|
745
714
|
var VerificationActionConfig = import_zod6.z.object({
|
746
715
|
verify: import_zod6.z.object({ label: TranslationConfig }),
|
@@ -751,10 +720,7 @@ var VerificationActionConfig = import_zod6.z.object({
|
|
751
720
|
body: TranslationConfig
|
752
721
|
})
|
753
722
|
})
|
754
|
-
}).describe("Actions available on the verification page")
|
755
|
-
description: "Verification action configuration",
|
756
|
-
ref: "VerificationActionConfig"
|
757
|
-
});
|
723
|
+
}).describe("Actions available on the verification page");
|
758
724
|
var VerificationPageConfig = FormPageConfig.extend({
|
759
725
|
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
760
726
|
actions: VerificationActionConfig
|
@@ -854,8 +820,6 @@ var ActionFormConfig = import_zod8.z.object({
|
|
854
820
|
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
855
821
|
|
856
822
|
// ../commons/src/events/ActionConfig.ts
|
857
|
-
var import_zod_openapi5 = require("zod-openapi");
|
858
|
-
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
|
859
823
|
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
860
824
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
861
825
|
ShowConditional,
|
@@ -933,24 +897,18 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
|
|
933
897
|
})
|
934
898
|
);
|
935
899
|
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
ref: "PrintCertificateActionConfig"
|
949
|
-
}),
|
950
|
-
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
951
|
-
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
952
|
-
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
953
|
-
]).openapi({ ref: "ActionConfig" });
|
900
|
+
DeclareConfig,
|
901
|
+
ValidateConfig,
|
902
|
+
RejectDeclarationConfig,
|
903
|
+
MarkedAsDuplicateConfig,
|
904
|
+
ArchiveConfig,
|
905
|
+
RegisterConfig,
|
906
|
+
DeleteConfig,
|
907
|
+
PrintCertificateActionConfig,
|
908
|
+
RequestCorrectionConfig,
|
909
|
+
RejectCorrectionConfig,
|
910
|
+
ApproveCorrectionConfig
|
911
|
+
]);
|
954
912
|
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
955
913
|
DeclareConfig,
|
956
914
|
ValidateConfig,
|
@@ -994,12 +952,10 @@ var LanguageConfig = import_zod11.z.object({
|
|
994
952
|
});
|
995
953
|
|
996
954
|
// ../commons/src/events/EventConfig.ts
|
997
|
-
var
|
955
|
+
var import_zod20 = require("zod");
|
998
956
|
|
999
957
|
// ../commons/src/events/DeduplicationConfig.ts
|
1000
958
|
var import_zod12 = require("zod");
|
1001
|
-
var import_zod_openapi6 = require("zod-openapi");
|
1002
|
-
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
|
1003
959
|
var FieldReference = import_zod12.z.string();
|
1004
960
|
var Matcher = import_zod12.z.object({
|
1005
961
|
fieldId: import_zod12.z.string(),
|
@@ -1060,9 +1016,7 @@ var Clause = import_zod12.z.lazy(
|
|
1060
1016
|
DateRangeMatcher,
|
1061
1017
|
DateDistanceMatcher
|
1062
1018
|
])
|
1063
|
-
)
|
1064
|
-
ref: "Clause"
|
1065
|
-
});
|
1019
|
+
);
|
1066
1020
|
var DeduplicationConfig = import_zod12.z.object({
|
1067
1021
|
id: import_zod12.z.string(),
|
1068
1022
|
label: TranslationConfig,
|
@@ -1071,21 +1025,14 @@ var DeduplicationConfig = import_zod12.z.object({
|
|
1071
1025
|
|
1072
1026
|
// ../commons/src/events/SummaryConfig.ts
|
1073
1027
|
var import_zod13 = require("zod");
|
1074
|
-
var
|
1075
|
-
emptyValueMessage: TranslationConfig.optional(),
|
1076
|
-
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1077
|
-
});
|
1078
|
-
var ReferenceField = BaseField2.extend({
|
1079
|
-
fieldId: import_zod13.z.string()
|
1080
|
-
}).describe("Field directly referencing event data with field id");
|
1081
|
-
var Field = BaseField2.extend({
|
1028
|
+
var Field = import_zod13.z.object({
|
1082
1029
|
id: import_zod13.z.string().describe("Id of summary field"),
|
1083
1030
|
value: TranslationConfig.describe(
|
1084
1031
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1085
1032
|
),
|
1086
1033
|
label: TranslationConfig,
|
1087
1034
|
emptyValueMessage: TranslationConfig.optional()
|
1088
|
-
})
|
1035
|
+
});
|
1089
1036
|
var Title = import_zod13.z.object({
|
1090
1037
|
id: import_zod13.z.string(),
|
1091
1038
|
label: TranslationConfig.describe("Title content"),
|
@@ -1093,18 +1040,116 @@ var Title = import_zod13.z.object({
|
|
1093
1040
|
});
|
1094
1041
|
var SummaryConfig = import_zod13.z.object({
|
1095
1042
|
title: Title.describe("Title of summary view."),
|
1096
|
-
fields: import_zod13.z.array(
|
1043
|
+
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
1097
1044
|
}).describe("Configuration for summary in event.");
|
1098
1045
|
|
1099
|
-
// ../commons/src/events/
|
1046
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1047
|
+
var import_zod15 = require("zod");
|
1048
|
+
|
1049
|
+
// ../commons/src/events/EventMetadata.ts
|
1100
1050
|
var import_zod14 = require("zod");
|
1101
|
-
var
|
1051
|
+
var EventStatus = {
|
1052
|
+
CREATED: "CREATED",
|
1053
|
+
NOTIFIED: "NOTIFIED",
|
1054
|
+
DECLARED: "DECLARED",
|
1055
|
+
VALIDATED: "VALIDATED",
|
1056
|
+
REGISTERED: "REGISTERED",
|
1057
|
+
CERTIFIED: "CERTIFIED",
|
1058
|
+
REJECTED: "REJECTED",
|
1059
|
+
ARCHIVED: "ARCHIVED"
|
1060
|
+
};
|
1061
|
+
var eventStatuses = Object.values(EventStatus);
|
1062
|
+
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1063
|
+
var EventMetadata = import_zod14.z.object({
|
1064
|
+
id: import_zod14.z.string(),
|
1065
|
+
type: import_zod14.z.string(),
|
1066
|
+
status: EventStatuses,
|
1067
|
+
createdAt: import_zod14.z.string().datetime(),
|
1068
|
+
createdBy: import_zod14.z.string(),
|
1069
|
+
createdAtLocation: import_zod14.z.string(),
|
1070
|
+
modifiedAt: import_zod14.z.string().datetime(),
|
1071
|
+
assignedTo: import_zod14.z.string().nullish(),
|
1072
|
+
updatedBy: import_zod14.z.string(),
|
1073
|
+
trackingId: import_zod14.z.string(),
|
1074
|
+
registrationNumber: import_zod14.z.string().nullish()
|
1075
|
+
});
|
1076
|
+
var eventMetadataLabelMap = {
|
1077
|
+
"event.assignedTo": {
|
1078
|
+
id: "event.assignedTo.label",
|
1079
|
+
defaultMessage: "Assigned To",
|
1080
|
+
description: "Assigned To"
|
1081
|
+
},
|
1082
|
+
"event.createdAt": {
|
1083
|
+
id: "event.createdAt.label",
|
1084
|
+
defaultMessage: "Created",
|
1085
|
+
description: "Created At"
|
1086
|
+
},
|
1087
|
+
"event.createdAtLocation": {
|
1088
|
+
id: "event.createdAtLocation.label",
|
1089
|
+
defaultMessage: "Location",
|
1090
|
+
description: "Created At Location"
|
1091
|
+
},
|
1092
|
+
"event.createdBy": {
|
1093
|
+
id: "event.createdBy.label",
|
1094
|
+
defaultMessage: "Created By",
|
1095
|
+
description: "Created By"
|
1096
|
+
},
|
1097
|
+
"event.id": {
|
1098
|
+
id: "event.id.label",
|
1099
|
+
defaultMessage: "ID",
|
1100
|
+
description: "ID"
|
1101
|
+
},
|
1102
|
+
"event.modifiedAt": {
|
1103
|
+
id: "event.modifiedAt.label",
|
1104
|
+
defaultMessage: "Updated",
|
1105
|
+
description: "Modified At"
|
1106
|
+
},
|
1107
|
+
"event.status": {
|
1108
|
+
id: "event.status.label",
|
1109
|
+
defaultMessage: "Status",
|
1110
|
+
description: "Status"
|
1111
|
+
},
|
1112
|
+
"event.type": {
|
1113
|
+
id: "event.type.label",
|
1114
|
+
defaultMessage: "Type",
|
1115
|
+
description: "Type"
|
1116
|
+
},
|
1117
|
+
"event.updatedBy": {
|
1118
|
+
id: "event.updatedBy.label",
|
1119
|
+
defaultMessage: "Updated By",
|
1120
|
+
description: "Updated By"
|
1121
|
+
},
|
1122
|
+
"event.trackingId": {
|
1123
|
+
id: "event.trackingId.label",
|
1124
|
+
defaultMessage: "Tracking ID",
|
1125
|
+
description: "Tracking ID"
|
1126
|
+
},
|
1127
|
+
"event.registrationNumber": {
|
1128
|
+
id: "event.registrationNumber.label",
|
1129
|
+
defaultMessage: "Registration Number",
|
1130
|
+
description: "Registration Number"
|
1131
|
+
}
|
1132
|
+
};
|
1133
|
+
|
1134
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1135
|
+
var WorkqueueConfig = import_zod15.z.object({
|
1136
|
+
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1137
|
+
filters: import_zod15.z.array(
|
1138
|
+
import_zod15.z.object({
|
1139
|
+
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1140
|
+
})
|
1141
|
+
).describe("Filters to be applied to workqueue.")
|
1142
|
+
}).describe("Configuration for workqueue.");
|
1143
|
+
|
1144
|
+
// ../commons/src/events/AdvancedSearchConfig.ts
|
1145
|
+
var import_zod16 = require("zod");
|
1146
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
1102
1147
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1103
|
-
fields:
|
1104
|
-
|
1105
|
-
fieldId:
|
1106
|
-
config:
|
1107
|
-
type:
|
1148
|
+
fields: import_zod16.z.array(
|
1149
|
+
import_zod16.z.object({
|
1150
|
+
fieldId: import_zod16.z.string(),
|
1151
|
+
config: import_zod16.z.object({
|
1152
|
+
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1108
1153
|
}).optional().describe("Configuration options for the field")
|
1109
1154
|
})
|
1110
1155
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -1113,13 +1158,139 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1113
1158
|
// ../commons/src/events/utils.ts
|
1114
1159
|
var import_lodash = require("lodash");
|
1115
1160
|
|
1161
|
+
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1162
|
+
var import_zod18 = require("zod");
|
1163
|
+
|
1164
|
+
// ../commons/src/workqueues/defaultColumns.ts
|
1165
|
+
var import_zod17 = require("zod");
|
1166
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1167
|
+
id: import_zod17.z.string(),
|
1168
|
+
label: TranslationConfig
|
1169
|
+
});
|
1170
|
+
var defaultColumns = {
|
1171
|
+
event: {
|
1172
|
+
id: "event",
|
1173
|
+
label: {
|
1174
|
+
defaultMessage: "Event",
|
1175
|
+
description: "This is the label for the workqueue column",
|
1176
|
+
id: "workqueue.default.column.event"
|
1177
|
+
}
|
1178
|
+
},
|
1179
|
+
status: {
|
1180
|
+
id: "status",
|
1181
|
+
label: {
|
1182
|
+
defaultMessage: "Status",
|
1183
|
+
description: "This is the label for the workqueue column",
|
1184
|
+
id: "workqueue.default.column.status"
|
1185
|
+
}
|
1186
|
+
},
|
1187
|
+
createdAt: {
|
1188
|
+
id: "createdAt",
|
1189
|
+
label: {
|
1190
|
+
defaultMessage: "Created",
|
1191
|
+
description: "This is the label for the workqueue column",
|
1192
|
+
id: "workqueue.default.column.createdAt"
|
1193
|
+
}
|
1194
|
+
},
|
1195
|
+
modifiedAt: {
|
1196
|
+
id: "modifiedAt",
|
1197
|
+
label: {
|
1198
|
+
defaultMessage: "Modified",
|
1199
|
+
description: "This is the label for the workqueue column",
|
1200
|
+
id: "workqueue.default.column.modifiedAt"
|
1201
|
+
}
|
1202
|
+
}
|
1203
|
+
};
|
1204
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
1205
|
+
Object.keys(defaultColumns)
|
1206
|
+
);
|
1207
|
+
|
1208
|
+
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1209
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1210
|
+
id: import_zod18.z.string(),
|
1211
|
+
title: TranslationConfig,
|
1212
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1213
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1214
|
+
});
|
1215
|
+
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1216
|
+
|
1217
|
+
// ../commons/src/workqueues/all.ts
|
1218
|
+
var allWorkqueue = defineWorkqueue({
|
1219
|
+
id: "all",
|
1220
|
+
title: {
|
1221
|
+
defaultMessage: "All events",
|
1222
|
+
description: "This is the label for the workqueue",
|
1223
|
+
id: "workqueue.all.label"
|
1224
|
+
},
|
1225
|
+
columns: [
|
1226
|
+
{
|
1227
|
+
id: "title",
|
1228
|
+
label: {
|
1229
|
+
defaultMessage: "Title",
|
1230
|
+
description: "This is the label for the workqueue column",
|
1231
|
+
id: "workqueue.all.column.title"
|
1232
|
+
}
|
1233
|
+
}
|
1234
|
+
],
|
1235
|
+
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1236
|
+
});
|
1237
|
+
|
1238
|
+
// ../commons/src/workqueues/readyForReview.ts
|
1239
|
+
var inReviewWorkqueue = defineWorkqueue({
|
1240
|
+
id: "ready-for-review",
|
1241
|
+
title: {
|
1242
|
+
defaultMessage: "Ready for review",
|
1243
|
+
description: "Label for in review workqueue",
|
1244
|
+
id: "event.workqueue.in-review.label"
|
1245
|
+
},
|
1246
|
+
columns: [
|
1247
|
+
{
|
1248
|
+
id: "title",
|
1249
|
+
label: {
|
1250
|
+
defaultMessage: "Title",
|
1251
|
+
description: "This is the label for the workqueue column",
|
1252
|
+
id: "workqueue.in-reveiw.column.title"
|
1253
|
+
}
|
1254
|
+
}
|
1255
|
+
],
|
1256
|
+
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1257
|
+
});
|
1258
|
+
|
1259
|
+
// ../commons/src/workqueues/readyToPrint.ts
|
1260
|
+
var registeredWorkqueue = defineWorkqueue({
|
1261
|
+
id: "registered",
|
1262
|
+
title: {
|
1263
|
+
defaultMessage: "Ready to print",
|
1264
|
+
description: "Label for registered workqueue",
|
1265
|
+
id: "event.workqueue.registered.label"
|
1266
|
+
},
|
1267
|
+
columns: [
|
1268
|
+
{
|
1269
|
+
id: "title",
|
1270
|
+
label: {
|
1271
|
+
defaultMessage: "Title",
|
1272
|
+
description: "This is the label for the workqueue column",
|
1273
|
+
id: "workqueue.registered.column.title"
|
1274
|
+
}
|
1275
|
+
}
|
1276
|
+
],
|
1277
|
+
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1278
|
+
});
|
1279
|
+
|
1280
|
+
// ../commons/src/workqueues/index.ts
|
1281
|
+
var workqueues = {
|
1282
|
+
all: allWorkqueue,
|
1283
|
+
registered: registeredWorkqueue,
|
1284
|
+
inReview: inReviewWorkqueue
|
1285
|
+
};
|
1286
|
+
|
1116
1287
|
// ../commons/src/conditionals/validate.ts
|
1117
1288
|
var import_ajv = __toESM(require("ajv"));
|
1118
1289
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1119
1290
|
var import_date_fns = require("date-fns");
|
1120
1291
|
|
1121
1292
|
// ../commons/src/events/FieldTypeMapping.ts
|
1122
|
-
var
|
1293
|
+
var import_zod19 = require("zod");
|
1123
1294
|
function mapFieldTypeToZod(type, required) {
|
1124
1295
|
let schema;
|
1125
1296
|
switch (type) {
|
@@ -1172,7 +1343,7 @@ function createValidationSchema(config) {
|
|
1172
1343
|
for (const field2 of config) {
|
1173
1344
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1174
1345
|
}
|
1175
|
-
return
|
1346
|
+
return import_zod19.z.object(shape);
|
1176
1347
|
}
|
1177
1348
|
function mapFieldTypeToMockValue(field2, i) {
|
1178
1349
|
switch (field2.type) {
|
@@ -1346,23 +1517,12 @@ var ajv = new import_ajv.default({
|
|
1346
1517
|
function validate(schema, data) {
|
1347
1518
|
return ajv.validate(schema, data);
|
1348
1519
|
}
|
1349
|
-
function isConditionMet(conditional, values) {
|
1350
|
-
return validate(conditional, {
|
1351
|
-
$form: values,
|
1352
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1353
|
-
});
|
1354
|
-
}
|
1355
1520
|
function getConditionalActionsForField(field2, values) {
|
1356
1521
|
if (!field2.conditionals) {
|
1357
1522
|
return [];
|
1358
1523
|
}
|
1359
1524
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1360
1525
|
}
|
1361
|
-
function areConditionsMet(conditions, values) {
|
1362
|
-
return conditions.every(
|
1363
|
-
(condition) => isConditionMet(condition.conditional, values)
|
1364
|
-
);
|
1365
|
-
}
|
1366
1526
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1367
1527
|
const hasRule = (field2.conditionals ?? []).some(
|
1368
1528
|
(conditional) => conditional.type === conditionalType
|
@@ -1485,11 +1645,6 @@ function runFieldValidations({
|
|
1485
1645
|
field: field2,
|
1486
1646
|
values
|
1487
1647
|
}) {
|
1488
|
-
if (!isFieldVisible(field2, values)) {
|
1489
|
-
return {
|
1490
|
-
errors: []
|
1491
|
-
};
|
1492
|
-
}
|
1493
1648
|
const conditionalParameters = {
|
1494
1649
|
$form: values,
|
1495
1650
|
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
@@ -1507,6 +1662,29 @@ function runFieldValidations({
|
|
1507
1662
|
errors: [...fieldValidationResult, ...customValidationResults]
|
1508
1663
|
};
|
1509
1664
|
}
|
1665
|
+
function getFieldValidationErrors({
|
1666
|
+
field: field2,
|
1667
|
+
values
|
1668
|
+
}) {
|
1669
|
+
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1670
|
+
if (values[field2.id]) {
|
1671
|
+
return {
|
1672
|
+
errors: [
|
1673
|
+
{
|
1674
|
+
message: errorMessages.hiddenField
|
1675
|
+
}
|
1676
|
+
]
|
1677
|
+
};
|
1678
|
+
}
|
1679
|
+
return {
|
1680
|
+
errors: []
|
1681
|
+
};
|
1682
|
+
}
|
1683
|
+
return runFieldValidations({
|
1684
|
+
field: field2,
|
1685
|
+
values
|
1686
|
+
});
|
1687
|
+
}
|
1510
1688
|
|
1511
1689
|
// ../commons/src/uuid.ts
|
1512
1690
|
var import_uuid = require("uuid");
|
@@ -1514,6 +1692,9 @@ function getUUID() {
|
|
1514
1692
|
return (0, import_uuid.v4)();
|
1515
1693
|
}
|
1516
1694
|
|
1695
|
+
// ../commons/src/events/utils.ts
|
1696
|
+
var import_date_fns2 = require("date-fns");
|
1697
|
+
|
1517
1698
|
// ../commons/src/utils.ts
|
1518
1699
|
function getOrThrow(x, message) {
|
1519
1700
|
if (x === void 0 || x === null) {
|
@@ -1581,11 +1762,26 @@ function getActionReview(configuration, actionType) {
|
|
1581
1762
|
function getActionReviewFields(configuration, actionType) {
|
1582
1763
|
return getActionReview(configuration, actionType).fields;
|
1583
1764
|
}
|
1765
|
+
function validateWorkqueueConfig(workqueueConfigs) {
|
1766
|
+
workqueueConfigs.map((workqueue) => {
|
1767
|
+
const rootWorkqueue = Object.values(workqueues).find(
|
1768
|
+
(wq) => wq.id === workqueue.id
|
1769
|
+
);
|
1770
|
+
if (!rootWorkqueue) {
|
1771
|
+
throw new Error(
|
1772
|
+
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1773
|
+
);
|
1774
|
+
}
|
1775
|
+
});
|
1776
|
+
}
|
1584
1777
|
function isPageVisible(page, formValues) {
|
1585
1778
|
if (!page.conditional) {
|
1586
1779
|
return true;
|
1587
1780
|
}
|
1588
|
-
return
|
1781
|
+
return validate(page.conditional, {
|
1782
|
+
$form: formValues,
|
1783
|
+
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1784
|
+
});
|
1589
1785
|
}
|
1590
1786
|
function omitHiddenFields(fields, values) {
|
1591
1787
|
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
@@ -1652,18 +1848,17 @@ function isWriteAction(actionType) {
|
|
1652
1848
|
}
|
1653
1849
|
|
1654
1850
|
// ../commons/src/events/EventConfig.ts
|
1655
|
-
var
|
1656
|
-
|
1657
|
-
var EventConfig = import_zod16.z.object({
|
1658
|
-
id: import_zod16.z.string().describe(
|
1851
|
+
var EventConfig = import_zod20.z.object({
|
1852
|
+
id: import_zod20.z.string().describe(
|
1659
1853
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1660
1854
|
),
|
1661
1855
|
summary: SummaryConfig,
|
1662
1856
|
label: TranslationConfig,
|
1663
|
-
actions:
|
1857
|
+
actions: import_zod20.z.array(ActionConfig),
|
1664
1858
|
declaration: DeclarationFormConfig,
|
1665
|
-
|
1666
|
-
|
1859
|
+
workqueues: import_zod20.z.array(WorkqueueConfig),
|
1860
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
1861
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1667
1862
|
}).superRefine((event2, ctx) => {
|
1668
1863
|
const allFields = findAllFields(event2);
|
1669
1864
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1689,8 +1884,6 @@ var EventConfig = import_zod16.z.object({
|
|
1689
1884
|
path: ["advancedSearch"]
|
1690
1885
|
});
|
1691
1886
|
}
|
1692
|
-
}).openapi({
|
1693
|
-
ref: "EventConfig"
|
1694
1887
|
});
|
1695
1888
|
|
1696
1889
|
// ../commons/src/events/EventConfigInput.ts
|
@@ -1699,312 +1892,269 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
|
1699
1892
|
var definePage = (page) => PageConfig.parse(page);
|
1700
1893
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1701
1894
|
|
1702
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1703
|
-
var import_zod17 = require("zod");
|
1704
|
-
var WorkqueueConfig = import_zod17.z.object({
|
1705
|
-
slug: import_zod17.z.string().describe("Determines the url of the workqueue."),
|
1706
|
-
name: TranslationConfig.describe(
|
1707
|
-
"Title of the workflow (both in navigation and on the page)"
|
1708
|
-
),
|
1709
|
-
/**
|
1710
|
-
* Placeholder untill the following gets merged to develop
|
1711
|
-
* https://github.com/opencrvs/opencrvs-core/blob/5fbe9854a88504a7a13fcc856b3e82594b70c38c/packages/commons/src/events/EventIndex.ts#L92-L93
|
1712
|
-
*/
|
1713
|
-
query: import_zod17.z.string(),
|
1714
|
-
actions: import_zod17.z.array(
|
1715
|
-
import_zod17.z.object({
|
1716
|
-
type: import_zod17.z.string(),
|
1717
|
-
conditionals: import_zod17.z.array(Conditional).optional()
|
1718
|
-
})
|
1719
|
-
)
|
1720
|
-
}).describe("Configuration for workqueue.");
|
1721
|
-
function defineWorkqueue(workqueues) {
|
1722
|
-
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
1723
|
-
}
|
1724
|
-
|
1725
1895
|
// ../commons/src/events/Draft.ts
|
1726
|
-
var
|
1896
|
+
var import_zod23 = require("zod");
|
1727
1897
|
|
1728
1898
|
// ../commons/src/events/ActionDocument.ts
|
1729
|
-
var
|
1730
|
-
var
|
1731
|
-
(0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
|
1732
|
-
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1899
|
+
var import_zod21 = require("zod");
|
1900
|
+
var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
|
1733
1901
|
var ActionStatus = {
|
1734
1902
|
Requested: "Requested",
|
1735
1903
|
Accepted: "Accepted",
|
1736
1904
|
Rejected: "Rejected"
|
1737
1905
|
};
|
1738
|
-
var ActionBase =
|
1739
|
-
id:
|
1740
|
-
|
1741
|
-
|
1742
|
-
createdBy: import_zod18.z.string(),
|
1743
|
-
createdByRole: import_zod18.z.string(),
|
1906
|
+
var ActionBase = import_zod21.z.object({
|
1907
|
+
id: import_zod21.z.string(),
|
1908
|
+
createdAt: import_zod21.z.string().datetime(),
|
1909
|
+
createdBy: import_zod21.z.string(),
|
1744
1910
|
declaration: ActionUpdate,
|
1745
1911
|
annotation: ActionUpdate.optional(),
|
1746
|
-
createdAtLocation:
|
1747
|
-
status:
|
1912
|
+
createdAtLocation: import_zod21.z.string(),
|
1913
|
+
status: import_zod21.z.enum([
|
1748
1914
|
ActionStatus.Requested,
|
1749
1915
|
ActionStatus.Accepted,
|
1750
1916
|
ActionStatus.Rejected
|
1751
1917
|
]),
|
1752
1918
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1753
|
-
originalActionId:
|
1919
|
+
originalActionId: import_zod21.z.string().optional()
|
1754
1920
|
});
|
1755
1921
|
var AssignedAction = ActionBase.merge(
|
1756
|
-
|
1757
|
-
type:
|
1758
|
-
assignedTo:
|
1922
|
+
import_zod21.z.object({
|
1923
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1924
|
+
assignedTo: import_zod21.z.string()
|
1759
1925
|
})
|
1760
1926
|
);
|
1761
1927
|
var UnassignedAction = ActionBase.merge(
|
1762
|
-
|
1763
|
-
type:
|
1764
|
-
assignedTo:
|
1928
|
+
import_zod21.z.object({
|
1929
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1930
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1765
1931
|
})
|
1766
1932
|
);
|
1767
1933
|
var RegisterAction = ActionBase.merge(
|
1768
|
-
|
1769
|
-
type:
|
1770
|
-
registrationNumber:
|
1934
|
+
import_zod21.z.object({
|
1935
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1936
|
+
registrationNumber: import_zod21.z.string().optional()
|
1771
1937
|
})
|
1772
1938
|
);
|
1773
1939
|
var DeclareAction = ActionBase.merge(
|
1774
|
-
|
1775
|
-
type:
|
1940
|
+
import_zod21.z.object({
|
1941
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1776
1942
|
})
|
1777
1943
|
);
|
1778
1944
|
var ValidateAction = ActionBase.merge(
|
1779
|
-
|
1780
|
-
type:
|
1945
|
+
import_zod21.z.object({
|
1946
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1781
1947
|
})
|
1782
1948
|
);
|
1783
1949
|
var RejectAction = ActionBase.merge(
|
1784
|
-
|
1785
|
-
type:
|
1950
|
+
import_zod21.z.object({
|
1951
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1786
1952
|
})
|
1787
1953
|
);
|
1788
1954
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1789
|
-
|
1790
|
-
type:
|
1955
|
+
import_zod21.z.object({
|
1956
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1791
1957
|
})
|
1792
1958
|
);
|
1793
1959
|
var ArchiveAction = ActionBase.merge(
|
1794
|
-
|
1795
|
-
type:
|
1960
|
+
import_zod21.z.object({
|
1961
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1796
1962
|
})
|
1797
1963
|
);
|
1798
1964
|
var CreatedAction = ActionBase.merge(
|
1799
|
-
|
1800
|
-
type:
|
1965
|
+
import_zod21.z.object({
|
1966
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1801
1967
|
})
|
1802
1968
|
);
|
1803
1969
|
var NotifiedAction = ActionBase.merge(
|
1804
|
-
|
1805
|
-
type:
|
1970
|
+
import_zod21.z.object({
|
1971
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1806
1972
|
})
|
1807
1973
|
);
|
1808
1974
|
var PrintCertificateAction = ActionBase.merge(
|
1809
|
-
|
1810
|
-
type:
|
1975
|
+
import_zod21.z.object({
|
1976
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1811
1977
|
})
|
1812
1978
|
);
|
1813
1979
|
var RequestedCorrectionAction = ActionBase.merge(
|
1814
|
-
|
1815
|
-
type:
|
1980
|
+
import_zod21.z.object({
|
1981
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1816
1982
|
})
|
1817
1983
|
);
|
1818
1984
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1819
|
-
|
1820
|
-
type:
|
1821
|
-
requestId:
|
1985
|
+
import_zod21.z.object({
|
1986
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1987
|
+
requestId: import_zod21.z.string()
|
1822
1988
|
})
|
1823
1989
|
);
|
1824
1990
|
var RejectedCorrectionAction = ActionBase.merge(
|
1825
|
-
|
1826
|
-
type:
|
1827
|
-
requestId:
|
1991
|
+
import_zod21.z.object({
|
1992
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1993
|
+
requestId: import_zod21.z.string()
|
1828
1994
|
})
|
1829
1995
|
);
|
1830
1996
|
var ReadAction = ActionBase.merge(
|
1831
|
-
|
1832
|
-
type:
|
1997
|
+
import_zod21.z.object({
|
1998
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1833
1999
|
})
|
1834
2000
|
);
|
1835
|
-
var ActionDocument =
|
1836
|
-
CreatedAction
|
1837
|
-
ValidateAction
|
1838
|
-
RejectAction
|
1839
|
-
MarkAsDuplicateAction
|
1840
|
-
ArchiveAction
|
1841
|
-
NotifiedAction
|
1842
|
-
RegisterAction
|
1843
|
-
DeclareAction
|
1844
|
-
AssignedAction
|
1845
|
-
RequestedCorrectionAction
|
1846
|
-
ApprovedCorrectionAction
|
1847
|
-
RejectedCorrectionAction
|
1848
|
-
UnassignedAction
|
1849
|
-
PrintCertificateAction
|
1850
|
-
ReadAction
|
1851
|
-
])
|
1852
|
-
ref: "ActionDocument"
|
1853
|
-
});
|
2001
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
2002
|
+
CreatedAction,
|
2003
|
+
ValidateAction,
|
2004
|
+
RejectAction,
|
2005
|
+
MarkAsDuplicateAction,
|
2006
|
+
ArchiveAction,
|
2007
|
+
NotifiedAction,
|
2008
|
+
RegisterAction,
|
2009
|
+
DeclareAction,
|
2010
|
+
AssignedAction,
|
2011
|
+
RequestedCorrectionAction,
|
2012
|
+
ApprovedCorrectionAction,
|
2013
|
+
RejectedCorrectionAction,
|
2014
|
+
UnassignedAction,
|
2015
|
+
PrintCertificateAction,
|
2016
|
+
ReadAction
|
2017
|
+
]);
|
1854
2018
|
var AsyncRejectActionDocument = ActionBase.omit({
|
1855
2019
|
declaration: true,
|
1856
2020
|
annotation: true,
|
1857
2021
|
createdBy: true,
|
1858
|
-
createdByRole: true,
|
1859
2022
|
createdAtLocation: true
|
1860
2023
|
}).merge(
|
1861
|
-
|
1862
|
-
type:
|
1863
|
-
status:
|
2024
|
+
import_zod21.z.object({
|
2025
|
+
type: import_zod21.z.enum(ConfirmableActions),
|
2026
|
+
status: import_zod21.z.literal(ActionStatus.Rejected)
|
1864
2027
|
})
|
1865
2028
|
);
|
1866
|
-
var Action =
|
1867
|
-
var ResolvedUser =
|
1868
|
-
id:
|
1869
|
-
role:
|
1870
|
-
name:
|
1871
|
-
|
1872
|
-
use:
|
1873
|
-
given:
|
1874
|
-
family:
|
2029
|
+
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2030
|
+
var ResolvedUser = import_zod21.z.object({
|
2031
|
+
id: import_zod21.z.string(),
|
2032
|
+
role: import_zod21.z.string(),
|
2033
|
+
name: import_zod21.z.array(
|
2034
|
+
import_zod21.z.object({
|
2035
|
+
use: import_zod21.z.string(),
|
2036
|
+
given: import_zod21.z.array(import_zod21.z.string()),
|
2037
|
+
family: import_zod21.z.string()
|
1875
2038
|
})
|
1876
2039
|
)
|
1877
2040
|
});
|
1878
2041
|
|
1879
2042
|
// ../commons/src/events/ActionInput.ts
|
1880
|
-
var
|
1881
|
-
var
|
1882
|
-
|
1883
|
-
|
1884
|
-
eventId: import_zod19.z.string(),
|
1885
|
-
transactionId: import_zod19.z.string(),
|
2043
|
+
var import_zod22 = require("zod");
|
2044
|
+
var BaseActionInput = import_zod22.z.object({
|
2045
|
+
eventId: import_zod22.z.string(),
|
2046
|
+
transactionId: import_zod22.z.string(),
|
1886
2047
|
declaration: ActionUpdate.default({}),
|
1887
2048
|
annotation: ActionUpdate.optional(),
|
1888
|
-
originalActionId:
|
1889
|
-
keepAssignment:
|
2049
|
+
originalActionId: import_zod22.z.string().optional(),
|
2050
|
+
keepAssignment: import_zod22.z.boolean().optional()
|
1890
2051
|
});
|
1891
2052
|
var CreateActionInput = BaseActionInput.merge(
|
1892
|
-
|
1893
|
-
type:
|
1894
|
-
createdAtLocation:
|
2053
|
+
import_zod22.z.object({
|
2054
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2055
|
+
createdAtLocation: import_zod22.z.string()
|
1895
2056
|
})
|
1896
2057
|
);
|
1897
2058
|
var RegisterActionInput = BaseActionInput.merge(
|
1898
|
-
|
1899
|
-
type:
|
1900
|
-
registrationNumber:
|
2059
|
+
import_zod22.z.object({
|
2060
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2061
|
+
registrationNumber: import_zod22.z.string().optional()
|
1901
2062
|
})
|
1902
2063
|
);
|
1903
2064
|
var ValidateActionInput = BaseActionInput.merge(
|
1904
|
-
|
1905
|
-
type:
|
1906
|
-
duplicates:
|
2065
|
+
import_zod22.z.object({
|
2066
|
+
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2067
|
+
duplicates: import_zod22.z.array(import_zod22.z.string())
|
1907
2068
|
})
|
1908
2069
|
);
|
1909
2070
|
var NotifyActionInput = BaseActionInput.merge(
|
1910
|
-
|
1911
|
-
type:
|
2071
|
+
import_zod22.z.object({
|
2072
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1912
2073
|
})
|
1913
2074
|
);
|
1914
2075
|
var DeclareActionInput = BaseActionInput.merge(
|
1915
|
-
|
1916
|
-
type:
|
2076
|
+
import_zod22.z.object({
|
2077
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1917
2078
|
})
|
1918
2079
|
);
|
1919
2080
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1920
|
-
|
1921
|
-
type:
|
2081
|
+
import_zod22.z.object({
|
2082
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1922
2083
|
})
|
1923
2084
|
);
|
1924
2085
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1925
|
-
|
1926
|
-
type:
|
2086
|
+
import_zod22.z.object({
|
2087
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1927
2088
|
})
|
1928
2089
|
);
|
1929
2090
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1930
|
-
|
1931
|
-
type:
|
2091
|
+
import_zod22.z.object({
|
2092
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1932
2093
|
})
|
1933
2094
|
);
|
1934
2095
|
var ArchiveActionInput = BaseActionInput.merge(
|
1935
|
-
|
1936
|
-
type:
|
2096
|
+
import_zod22.z.object({
|
2097
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1937
2098
|
})
|
1938
2099
|
);
|
1939
2100
|
var AssignActionInput = BaseActionInput.merge(
|
1940
|
-
|
1941
|
-
type:
|
1942
|
-
assignedTo:
|
2101
|
+
import_zod22.z.object({
|
2102
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2103
|
+
assignedTo: import_zod22.z.string()
|
1943
2104
|
})
|
1944
2105
|
);
|
1945
2106
|
var UnassignActionInput = BaseActionInput.merge(
|
1946
|
-
|
1947
|
-
type:
|
1948
|
-
assignedTo:
|
2107
|
+
import_zod22.z.object({
|
2108
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2109
|
+
assignedTo: import_zod22.z.literal(null).default(null)
|
1949
2110
|
})
|
1950
2111
|
);
|
1951
2112
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1952
|
-
|
1953
|
-
type:
|
2113
|
+
import_zod22.z.object({
|
2114
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1954
2115
|
})
|
1955
2116
|
);
|
1956
2117
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1957
|
-
|
1958
|
-
requestId:
|
1959
|
-
type:
|
2118
|
+
import_zod22.z.object({
|
2119
|
+
requestId: import_zod22.z.string(),
|
2120
|
+
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1960
2121
|
})
|
1961
2122
|
);
|
1962
2123
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1963
|
-
|
1964
|
-
requestId:
|
1965
|
-
type:
|
2124
|
+
import_zod22.z.object({
|
2125
|
+
requestId: import_zod22.z.string(),
|
2126
|
+
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1966
2127
|
})
|
1967
2128
|
);
|
1968
2129
|
var ReadActionInput = BaseActionInput.merge(
|
1969
|
-
|
1970
|
-
type:
|
2130
|
+
import_zod22.z.object({
|
2131
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
1971
2132
|
})
|
1972
2133
|
);
|
1973
|
-
var
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
RequestCorrectionActionInput.openapi({
|
1991
|
-
ref: "RequestCorrectionActionInput"
|
1992
|
-
}),
|
1993
|
-
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
1994
|
-
ApproveCorrectionActionInput.openapi({
|
1995
|
-
ref: "ApproveCorrectionActionInput"
|
1996
|
-
}),
|
1997
|
-
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
1998
|
-
]).openapi({
|
1999
|
-
ref: "ActionInput"
|
2000
|
-
});
|
2134
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2135
|
+
CreateActionInput,
|
2136
|
+
ValidateActionInput,
|
2137
|
+
RegisterActionInput,
|
2138
|
+
NotifyActionInput,
|
2139
|
+
DeclareActionInput,
|
2140
|
+
RejectDeclarationActionInput,
|
2141
|
+
MarkedAsDuplicateActionInput,
|
2142
|
+
ArchiveActionInput,
|
2143
|
+
AssignActionInput,
|
2144
|
+
UnassignActionInput,
|
2145
|
+
PrintCertificateActionInput,
|
2146
|
+
RequestCorrectionActionInput,
|
2147
|
+
RejectCorrectionActionInput,
|
2148
|
+
ApproveCorrectionActionInput,
|
2149
|
+
ReadActionInput
|
2150
|
+
]);
|
2001
2151
|
|
2002
2152
|
// ../commons/src/events/Draft.ts
|
2003
|
-
var Draft =
|
2004
|
-
id:
|
2005
|
-
eventId:
|
2006
|
-
transactionId:
|
2007
|
-
createdAt:
|
2153
|
+
var Draft = import_zod23.z.object({
|
2154
|
+
id: import_zod23.z.string(),
|
2155
|
+
eventId: import_zod23.z.string(),
|
2156
|
+
transactionId: import_zod23.z.string(),
|
2157
|
+
createdAt: import_zod23.z.string().datetime(),
|
2008
2158
|
action: ActionBase.extend({
|
2009
2159
|
type: ActionTypes
|
2010
2160
|
}).omit({ id: true })
|
@@ -2013,132 +2163,32 @@ var DraftInput = BaseActionInput.extend({
|
|
2013
2163
|
type: ActionTypes
|
2014
2164
|
});
|
2015
2165
|
|
2016
|
-
// ../commons/src/events/EventMetadata.ts
|
2017
|
-
var import_zod21 = require("zod");
|
2018
|
-
var EventStatus = {
|
2019
|
-
CREATED: "CREATED",
|
2020
|
-
NOTIFIED: "NOTIFIED",
|
2021
|
-
DECLARED: "DECLARED",
|
2022
|
-
VALIDATED: "VALIDATED",
|
2023
|
-
REGISTERED: "REGISTERED",
|
2024
|
-
CERTIFIED: "CERTIFIED",
|
2025
|
-
REJECTED: "REJECTED",
|
2026
|
-
ARCHIVED: "ARCHIVED"
|
2027
|
-
};
|
2028
|
-
var eventStatuses = Object.values(EventStatus);
|
2029
|
-
var EventStatuses = import_zod21.z.nativeEnum(EventStatus);
|
2030
|
-
var EventMetadata = import_zod21.z.object({
|
2031
|
-
id: import_zod21.z.string(),
|
2032
|
-
type: import_zod21.z.string(),
|
2033
|
-
status: EventStatuses,
|
2034
|
-
createdAt: import_zod21.z.string().datetime(),
|
2035
|
-
createdBy: import_zod21.z.string(),
|
2036
|
-
updatedByUserRole: import_zod21.z.string(),
|
2037
|
-
createdAtLocation: import_zod21.z.string(),
|
2038
|
-
updatedAtLocation: import_zod21.z.string(),
|
2039
|
-
modifiedAt: import_zod21.z.string().datetime(),
|
2040
|
-
assignedTo: import_zod21.z.string().nullish(),
|
2041
|
-
updatedBy: import_zod21.z.string(),
|
2042
|
-
trackingId: import_zod21.z.string(),
|
2043
|
-
registrationNumber: import_zod21.z.string().nullish()
|
2044
|
-
});
|
2045
|
-
var eventMetadataLabelMap = {
|
2046
|
-
"event.assignedTo": {
|
2047
|
-
id: "event.assignedTo.label",
|
2048
|
-
defaultMessage: "Assigned To",
|
2049
|
-
description: "Assigned To"
|
2050
|
-
},
|
2051
|
-
"event.createdAt": {
|
2052
|
-
id: "event.createdAt.label",
|
2053
|
-
defaultMessage: "Created",
|
2054
|
-
description: "Created At"
|
2055
|
-
},
|
2056
|
-
"event.createdAtLocation": {
|
2057
|
-
id: "event.createdAtLocation.label",
|
2058
|
-
defaultMessage: "Location",
|
2059
|
-
description: "Created At Location"
|
2060
|
-
},
|
2061
|
-
"event.updatedAtLocation": {
|
2062
|
-
id: "event.updatedAtLocation.label",
|
2063
|
-
defaultMessage: "Location",
|
2064
|
-
description: "Updated At Location"
|
2065
|
-
},
|
2066
|
-
"event.createdBy": {
|
2067
|
-
id: "event.createdBy.label",
|
2068
|
-
defaultMessage: "Created By",
|
2069
|
-
description: "Created By"
|
2070
|
-
},
|
2071
|
-
"event.updatedByUserRole": {
|
2072
|
-
id: "event.updatedByUserRole.label",
|
2073
|
-
defaultMessage: "Updated By Role",
|
2074
|
-
description: "Updated By Role"
|
2075
|
-
},
|
2076
|
-
"event.id": {
|
2077
|
-
id: "event.id.label",
|
2078
|
-
defaultMessage: "ID",
|
2079
|
-
description: "ID"
|
2080
|
-
},
|
2081
|
-
"event.modifiedAt": {
|
2082
|
-
id: "event.modifiedAt.label",
|
2083
|
-
defaultMessage: "Updated",
|
2084
|
-
description: "Modified At"
|
2085
|
-
},
|
2086
|
-
"event.status": {
|
2087
|
-
id: "event.status.label",
|
2088
|
-
defaultMessage: "Status",
|
2089
|
-
description: "Status"
|
2090
|
-
},
|
2091
|
-
"event.type": {
|
2092
|
-
id: "event.type.label",
|
2093
|
-
defaultMessage: "Type",
|
2094
|
-
description: "Type"
|
2095
|
-
},
|
2096
|
-
"event.updatedBy": {
|
2097
|
-
id: "event.updatedBy.label",
|
2098
|
-
defaultMessage: "Updated By",
|
2099
|
-
description: "Updated By"
|
2100
|
-
},
|
2101
|
-
"event.trackingId": {
|
2102
|
-
id: "event.trackingId.label",
|
2103
|
-
defaultMessage: "Tracking ID",
|
2104
|
-
description: "Tracking ID"
|
2105
|
-
},
|
2106
|
-
"event.registrationNumber": {
|
2107
|
-
id: "event.registrationNumber.label",
|
2108
|
-
defaultMessage: "Registration Number",
|
2109
|
-
description: "Registration Number"
|
2110
|
-
}
|
2111
|
-
};
|
2112
|
-
|
2113
2166
|
// ../commons/src/events/EventInput.ts
|
2114
|
-
var
|
2115
|
-
var EventInput =
|
2116
|
-
transactionId:
|
2117
|
-
type:
|
2167
|
+
var import_zod24 = require("zod");
|
2168
|
+
var EventInput = import_zod24.z.object({
|
2169
|
+
transactionId: import_zod24.z.string(),
|
2170
|
+
type: import_zod24.z.string()
|
2118
2171
|
});
|
2119
2172
|
|
2120
2173
|
// ../commons/src/events/EventDocument.ts
|
2121
|
-
var
|
2122
|
-
var
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
actions: import_zod23.z.array(Action),
|
2131
|
-
trackingId: import_zod23.z.string()
|
2132
|
-
}).openapi({ ref: "EventDocument" });
|
2174
|
+
var import_zod25 = require("zod");
|
2175
|
+
var EventDocument = import_zod25.z.object({
|
2176
|
+
id: import_zod25.z.string(),
|
2177
|
+
type: import_zod25.z.string(),
|
2178
|
+
createdAt: import_zod25.z.string().datetime(),
|
2179
|
+
updatedAt: import_zod25.z.string().datetime(),
|
2180
|
+
actions: import_zod25.z.array(Action),
|
2181
|
+
trackingId: import_zod25.z.string()
|
2182
|
+
});
|
2133
2183
|
|
2134
2184
|
// ../commons/src/events/EventIndex.ts
|
2135
|
-
var
|
2185
|
+
var import_zod26 = require("zod");
|
2136
2186
|
var EventIndex = EventMetadata.extend({
|
2137
|
-
declaration:
|
2187
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2138
2188
|
});
|
2139
|
-
var EventSearchIndex =
|
2140
|
-
|
2141
|
-
type:
|
2189
|
+
var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
|
2190
|
+
import_zod26.z.object({
|
2191
|
+
type: import_zod26.z.string()
|
2142
2192
|
// Ensures "type" (event-id) exists and is a string
|
2143
2193
|
})
|
2144
2194
|
);
|
@@ -2152,46 +2202,30 @@ function getStatusFromActions(actions) {
|
|
2152
2202
|
return EventStatus.REJECTED;
|
2153
2203
|
}
|
2154
2204
|
return actions.reduce((status, action) => {
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
case ActionType.VALIDATE:
|
2161
|
-
return EventStatus.VALIDATED;
|
2162
|
-
case ActionType.REGISTER:
|
2163
|
-
return EventStatus.REGISTERED;
|
2164
|
-
case ActionType.REJECT:
|
2165
|
-
return EventStatus.REJECTED;
|
2166
|
-
case ActionType.ARCHIVE:
|
2167
|
-
return EventStatus.ARCHIVED;
|
2168
|
-
case ActionType.NOTIFY:
|
2169
|
-
return EventStatus.NOTIFIED;
|
2170
|
-
case ActionType.PRINT_CERTIFICATE:
|
2171
|
-
case ActionType.ASSIGN:
|
2172
|
-
case ActionType.UNASSIGN:
|
2173
|
-
case ActionType.REQUEST_CORRECTION:
|
2174
|
-
case ActionType.APPROVE_CORRECTION:
|
2175
|
-
case ActionType.MARKED_AS_DUPLICATE:
|
2176
|
-
case ActionType.REJECT_CORRECTION:
|
2177
|
-
case ActionType.READ:
|
2178
|
-
default:
|
2179
|
-
return status;
|
2205
|
+
if (action.type === ActionType.CREATE) {
|
2206
|
+
return EventStatus.CREATED;
|
2207
|
+
}
|
2208
|
+
if (action.type === ActionType.DECLARE) {
|
2209
|
+
return EventStatus.DECLARED;
|
2180
2210
|
}
|
2211
|
+
if (action.type === ActionType.VALIDATE) {
|
2212
|
+
return EventStatus.VALIDATED;
|
2213
|
+
}
|
2214
|
+
if (action.type === ActionType.REGISTER) {
|
2215
|
+
return EventStatus.REGISTERED;
|
2216
|
+
}
|
2217
|
+
if (action.type === ActionType.REJECT) {
|
2218
|
+
return EventStatus.REJECTED;
|
2219
|
+
}
|
2220
|
+
if (action.type === ActionType.ARCHIVE) {
|
2221
|
+
return EventStatus.ARCHIVED;
|
2222
|
+
}
|
2223
|
+
if (action.type === ActionType.NOTIFY) {
|
2224
|
+
return EventStatus.NOTIFIED;
|
2225
|
+
}
|
2226
|
+
return status;
|
2181
2227
|
}, EventStatus.CREATED);
|
2182
2228
|
}
|
2183
|
-
function getLastUpdatedByUserRoleFromActions(actions) {
|
2184
|
-
const actionsWithRoles = actions.filter(
|
2185
|
-
(action) => !isWriteAction(action.type) && action.status !== ActionStatus.Rejected
|
2186
|
-
).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2187
|
-
const lastAction = actionsWithRoles.at(-1);
|
2188
|
-
if (!lastAction) {
|
2189
|
-
throw new Error(
|
2190
|
-
"Should never happen, at least CREATE action should be present"
|
2191
|
-
);
|
2192
|
-
}
|
2193
|
-
return ActionDocument.parse(lastAction).createdByRole;
|
2194
|
-
}
|
2195
2229
|
function getAssignedUserFromActions(actions) {
|
2196
2230
|
return actions.reduce((user2, action) => {
|
2197
2231
|
if (action.type === ActionType.ASSIGN) {
|
@@ -2269,11 +2303,9 @@ function getCurrentEventState(event2) {
|
|
2269
2303
|
modifiedAt: latestAction.createdAt,
|
2270
2304
|
assignedTo: getAssignedUserFromActions(activeActions),
|
2271
2305
|
updatedBy: latestAction.createdBy,
|
2272
|
-
updatedAtLocation: event2.updatedAtLocation,
|
2273
2306
|
declaration: aggregateActionDeclarations(activeActions),
|
2274
2307
|
trackingId: event2.trackingId,
|
2275
|
-
registrationNumber
|
2276
|
-
updatedByUserRole: getLastUpdatedByUserRoleFromActions(event2.actions)
|
2308
|
+
registrationNumber
|
2277
2309
|
});
|
2278
2310
|
}
|
2279
2311
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2321,7 +2353,7 @@ function getAnnotationFromDrafts(drafts) {
|
|
2321
2353
|
function getActionAnnotation({
|
2322
2354
|
event: event2,
|
2323
2355
|
actionType,
|
2324
|
-
drafts
|
2356
|
+
drafts
|
2325
2357
|
}) {
|
2326
2358
|
const activeActions = getAcceptedActions(event2);
|
2327
2359
|
const action = activeActions.find(
|
@@ -2340,6 +2372,7 @@ function getActionAnnotation({
|
|
2340
2372
|
|
2341
2373
|
// ../commons/src/events/defineConfig.ts
|
2342
2374
|
var defineConfig = (config) => {
|
2375
|
+
validateWorkqueueConfig(config.workqueues);
|
2343
2376
|
const input = EventConfig.parse(config);
|
2344
2377
|
return input;
|
2345
2378
|
};
|
@@ -3616,6 +3649,28 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3616
3649
|
}
|
3617
3650
|
]
|
3618
3651
|
},
|
3652
|
+
workqueues: [
|
3653
|
+
{
|
3654
|
+
id: "all",
|
3655
|
+
filters: []
|
3656
|
+
},
|
3657
|
+
{
|
3658
|
+
id: "ready-for-review",
|
3659
|
+
filters: [
|
3660
|
+
{
|
3661
|
+
status: ["DECLARED"]
|
3662
|
+
}
|
3663
|
+
]
|
3664
|
+
},
|
3665
|
+
{
|
3666
|
+
id: "registered",
|
3667
|
+
filters: [
|
3668
|
+
{
|
3669
|
+
status: ["REGISTERED"]
|
3670
|
+
}
|
3671
|
+
]
|
3672
|
+
}
|
3673
|
+
],
|
3619
3674
|
actions: [
|
3620
3675
|
{
|
3621
3676
|
type: ActionType.DECLARE,
|
@@ -3994,7 +4049,6 @@ var eventPayloadGenerator = {
|
|
3994
4049
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3995
4050
|
transactionId: getUUID(),
|
3996
4051
|
action: {
|
3997
|
-
transactionId: getUUID(),
|
3998
4052
|
type: actionType,
|
3999
4053
|
status: ActionStatus.Accepted,
|
4000
4054
|
declaration: {
|
@@ -4009,7 +4063,6 @@ var eventPayloadGenerator = {
|
|
4009
4063
|
},
|
4010
4064
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4011
4065
|
createdBy: "@todo",
|
4012
|
-
createdByRole: "@todo",
|
4013
4066
|
createdAtLocation: "@todo"
|
4014
4067
|
}
|
4015
4068
|
},
|
@@ -4171,14 +4224,12 @@ function generateActionDocument({
|
|
4171
4224
|
// @TODO: This should be fixed in the future.
|
4172
4225
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4173
4226
|
createdBy: getUUID(),
|
4174
|
-
createdByRole: "FIELD_AGENT",
|
4175
4227
|
id: getUUID(),
|
4176
4228
|
createdAtLocation: "TODO",
|
4177
4229
|
declaration: generateActionDeclarationInput(configuration, action),
|
4178
4230
|
annotation: {},
|
4179
4231
|
...defaults,
|
4180
|
-
status: ActionStatus.Accepted
|
4181
|
-
transactionId: getUUID()
|
4232
|
+
status: ActionStatus.Accepted
|
4182
4233
|
};
|
4183
4234
|
switch (action) {
|
4184
4235
|
case ActionType.READ:
|
@@ -4236,8 +4287,7 @@ function generateEventDocument({
|
|
4236
4287
|
id: getUUID(),
|
4237
4288
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4238
4289
|
// @TODO: This should be fixed in the future.
|
4239
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4240
|
-
updatedAtLocation: "TODO"
|
4290
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4241
4291
|
};
|
4242
4292
|
}
|
4243
4293
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4266,11 +4316,9 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4266
4316
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4267
4317
|
createdBy: overrides.createdBy ?? getUUID(),
|
4268
4318
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
4269
|
-
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4270
4319
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4271
4320
|
assignedTo: overrides.assignedTo ?? null,
|
4272
4321
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4273
|
-
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4274
4322
|
declaration: overrides.declaration ?? {
|
4275
4323
|
"recommender.none": true,
|
4276
4324
|
"applicant.firstname": "Danny",
|
@@ -4316,189 +4364,3 @@ function isFieldConfigDefaultValue(value) {
|
|
4316
4364
|
}
|
4317
4365
|
return false;
|
4318
4366
|
}
|
4319
|
-
|
4320
|
-
// ../commons/src/events/scopes.ts
|
4321
|
-
var import_lodash3 = require("lodash");
|
4322
|
-
|
4323
|
-
// ../commons/src/scopes.ts
|
4324
|
-
var SCOPES = {
|
4325
|
-
// TODO v1.8 legacy scopes
|
4326
|
-
NATLSYSADMIN: "natlsysadmin",
|
4327
|
-
BYPASSRATELIMIT: "bypassratelimit",
|
4328
|
-
DECLARE: "declare",
|
4329
|
-
REGISTER: "register",
|
4330
|
-
VALIDATE: "validate",
|
4331
|
-
DEMO: "demo",
|
4332
|
-
CERTIFY: "certify",
|
4333
|
-
PERFORMANCE: "performance",
|
4334
|
-
SYSADMIN: "sysadmin",
|
4335
|
-
TEAMS: "teams",
|
4336
|
-
CONFIG: "config",
|
4337
|
-
// systems / integrations
|
4338
|
-
WEBHOOK: "webhook",
|
4339
|
-
NATIONALID: "nationalId",
|
4340
|
-
NOTIFICATION_API: "notification-api",
|
4341
|
-
RECORDSEARCH: "recordsearch",
|
4342
|
-
/**
|
4343
|
-
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4344
|
-
*/
|
4345
|
-
RECORD_DECLARE: "record.declare-birth",
|
4346
|
-
// declare
|
4347
|
-
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4348
|
-
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4349
|
-
RECORD_DECLARE_DEATH: "record.declare-death",
|
4350
|
-
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4351
|
-
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4352
|
-
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4353
|
-
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4354
|
-
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4355
|
-
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4356
|
-
// validate
|
4357
|
-
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4358
|
-
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4359
|
-
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4360
|
-
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4361
|
-
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4362
|
-
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4363
|
-
// register
|
4364
|
-
RECORD_REGISTER: "record.register",
|
4365
|
-
// certify
|
4366
|
-
RECORD_EXPORT_RECORDS: "record.export-records",
|
4367
|
-
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4368
|
-
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4369
|
-
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4370
|
-
// v1.8
|
4371
|
-
/**
|
4372
|
-
* This scope is used to **print and **issue certified copies of a record
|
4373
|
-
* after it has been registered. Previously Registrars had this permission.
|
4374
|
-
*/
|
4375
|
-
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4376
|
-
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4377
|
-
// v1.8
|
4378
|
-
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4379
|
-
// v1.8
|
4380
|
-
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4381
|
-
// v1.8
|
4382
|
-
// correct
|
4383
|
-
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4384
|
-
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4385
|
-
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4386
|
-
// v1.8
|
4387
|
-
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4388
|
-
// v1.8
|
4389
|
-
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4390
|
-
// v1.8
|
4391
|
-
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4392
|
-
// v1.8
|
4393
|
-
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4394
|
-
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4395
|
-
// search
|
4396
|
-
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4397
|
-
SEARCH_BIRTH: "search.birth",
|
4398
|
-
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4399
|
-
SEARCH_DEATH: "search.death",
|
4400
|
-
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4401
|
-
SEARCH_MARRIAGE: "search.marriage",
|
4402
|
-
// audit v1.8
|
4403
|
-
RECORD_READ: "record.read",
|
4404
|
-
RECORD_READ_AUDIT: "record.read-audit",
|
4405
|
-
RECORD_READ_COMMENTS: "record.read-comments",
|
4406
|
-
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4407
|
-
// profile
|
4408
|
-
PROFILE_UPDATE: "profile.update",
|
4409
|
-
//v1.8
|
4410
|
-
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4411
|
-
// performance
|
4412
|
-
PERFORMANCE_READ: "performance.read",
|
4413
|
-
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4414
|
-
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4415
|
-
// organisation
|
4416
|
-
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4417
|
-
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4418
|
-
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4419
|
-
// user
|
4420
|
-
USER_READ: "user.read:all",
|
4421
|
-
USER_READ_MY_OFFICE: "user.read:my-office",
|
4422
|
-
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4423
|
-
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4424
|
-
//v1.8
|
4425
|
-
USER_CREATE: "user.create:all",
|
4426
|
-
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4427
|
-
USER_UPDATE: "user.update:all",
|
4428
|
-
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4429
|
-
// config
|
4430
|
-
CONFIG_UPDATE_ALL: "config.update:all",
|
4431
|
-
// data seeding
|
4432
|
-
USER_DATA_SEEDING: "user.data-seeding"
|
4433
|
-
};
|
4434
|
-
var scopes = Object.values(SCOPES);
|
4435
|
-
|
4436
|
-
// ../commons/src/events/scopes.ts
|
4437
|
-
function hasAnyOfScopes(a, b) {
|
4438
|
-
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4439
|
-
}
|
4440
|
-
var CONFIG_GET_ALLOWED_SCOPES = [
|
4441
|
-
SCOPES.RECORD_DECLARE,
|
4442
|
-
SCOPES.RECORD_READ,
|
4443
|
-
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4444
|
-
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4445
|
-
SCOPES.RECORD_REGISTER,
|
4446
|
-
SCOPES.RECORD_EXPORT_RECORDS,
|
4447
|
-
SCOPES.CONFIG,
|
4448
|
-
SCOPES.CONFIG_UPDATE_ALL
|
4449
|
-
];
|
4450
|
-
var ACTION_ALLOWED_SCOPES = {
|
4451
|
-
[ActionType.READ]: [
|
4452
|
-
SCOPES.RECORD_DECLARE,
|
4453
|
-
SCOPES.RECORD_READ,
|
4454
|
-
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4455
|
-
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4456
|
-
SCOPES.RECORD_REGISTER,
|
4457
|
-
SCOPES.RECORD_EXPORT_RECORDS
|
4458
|
-
],
|
4459
|
-
[ActionType.CREATE]: [
|
4460
|
-
SCOPES.RECORD_DECLARE,
|
4461
|
-
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4462
|
-
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
4463
|
-
],
|
4464
|
-
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
4465
|
-
[ActionType.DECLARE]: [
|
4466
|
-
SCOPES.RECORD_DECLARE,
|
4467
|
-
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4468
|
-
SCOPES.RECORD_REGISTER
|
4469
|
-
],
|
4470
|
-
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
4471
|
-
[ActionType.VALIDATE]: [
|
4472
|
-
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4473
|
-
SCOPES.RECORD_REGISTER
|
4474
|
-
],
|
4475
|
-
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
4476
|
-
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
4477
|
-
[ActionType.REQUEST_CORRECTION]: [
|
4478
|
-
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
4479
|
-
],
|
4480
|
-
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4481
|
-
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4482
|
-
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4483
|
-
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4484
|
-
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
4485
|
-
[ActionType.ASSIGN]: null,
|
4486
|
-
[ActionType.UNASSIGN]: null,
|
4487
|
-
[ActionType.DETECT_DUPLICATE]: []
|
4488
|
-
};
|
4489
|
-
function filterUnallowedActions(actions, userScopes) {
|
4490
|
-
const allowedActions = actions.filter((action) => {
|
4491
|
-
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
4492
|
-
if (requiredScopes === null) {
|
4493
|
-
return true;
|
4494
|
-
}
|
4495
|
-
return hasAnyOfScopes(userScopes, requiredScopes);
|
4496
|
-
});
|
4497
|
-
const hasOtherAllowedActions = allowedActions.some(
|
4498
|
-
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
4499
|
-
);
|
4500
|
-
if (hasOtherAllowedActions) {
|
4501
|
-
return allowedActions;
|
4502
|
-
}
|
4503
|
-
return [ActionType.READ];
|
4504
|
-
}
|