@opencrvs/toolkit 1.8.0-rc.fa564ca → 1.8.0-rc.fa82472
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 +6661 -391
- package/dist/commons/conditionals/conditionals.d.ts +4 -0
- package/dist/commons/conditionals/validate.d.ts +6 -0
- package/dist/commons/events/ActionConfig.d.ts +18678 -6326
- package/dist/commons/events/ActionDocument.d.ts +1713 -204
- package/dist/commons/events/ActionInput.d.ts +1380 -180
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +75 -3
- package/dist/commons/events/CompositeFieldValue.d.ts +28 -0
- package/dist/commons/events/Constants.d.ts +1 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +254 -168
- package/dist/commons/events/Draft.d.ts +117 -16
- package/dist/commons/events/EventConfig.d.ts +8242 -2365
- package/dist/commons/events/EventDocument.d.ts +1096 -152
- package/dist/commons/events/EventIndex.d.ts +793 -118
- package/dist/commons/events/EventMetadata.d.ts +38 -35
- package/dist/commons/events/FieldConfig.d.ts +1572 -746
- package/dist/commons/events/FieldType.d.ts +4 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +89 -50
- package/dist/commons/events/FieldValue.d.ts +41 -5
- package/dist/commons/events/FormConfig.d.ts +7640 -2444
- package/dist/commons/events/PageConfig.d.ts +2816 -1540
- package/dist/commons/events/SummaryConfig.d.ts +0 -5
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
- package/dist/commons/events/WorkqueueConfig.d.ts +3266 -1503
- package/dist/commons/events/defineConfig.d.ts +959 -13
- package/dist/commons/events/field.d.ts +4 -0
- package/dist/commons/events/scopes.d.ts +6 -0
- package/dist/commons/events/test.utils.d.ts +137 -38
- package/dist/commons/events/utils.d.ts +9661 -10
- package/dist/conditionals/index.js +18 -1
- package/dist/events/index.js +1488 -928
- package/dist/scopes/index.d.ts +4 -1
- package/dist/scopes/index.js +67 -17
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -56,6 +56,7 @@ __export(events_exports, {
|
|
56
56
|
ArchiveActionInput: () => ArchiveActionInput,
|
57
57
|
AssignActionInput: () => AssignActionInput,
|
58
58
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
59
|
+
BIRTH_EVENT: () => BIRTH_EVENT,
|
59
60
|
BaseActionInput: () => BaseActionInput,
|
60
61
|
BearerTokenByUserType: () => BearerTokenByUserType,
|
61
62
|
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
@@ -101,9 +102,8 @@ __export(events_exports, {
|
|
101
102
|
EventSearchIndex: () => EventSearchIndex,
|
102
103
|
EventState: () => EventState,
|
103
104
|
EventStatus: () => EventStatus,
|
104
|
-
EventStatusEnum: () => EventStatusEnum,
|
105
|
-
EventStatuses: () => EventStatuses,
|
106
105
|
Exact: () => Exact,
|
106
|
+
ExactDate: () => ExactDate,
|
107
107
|
ExactStatus: () => ExactStatus,
|
108
108
|
FieldConditional: () => FieldConditional,
|
109
109
|
FieldConfig: () => FieldConfig,
|
@@ -127,6 +127,8 @@ __export(events_exports, {
|
|
127
127
|
LegalStatuses: () => LegalStatuses,
|
128
128
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
129
129
|
MimeType: () => MimeType,
|
130
|
+
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
131
|
+
NameFieldValue: () => NameFieldValue,
|
130
132
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
131
133
|
Not: () => Not,
|
132
134
|
NotifyActionInput: () => NotifyActionInput,
|
@@ -138,6 +140,7 @@ __export(events_exports, {
|
|
138
140
|
QueryInput: () => QueryInput,
|
139
141
|
QueryType: () => QueryType,
|
140
142
|
Range: () => Range,
|
143
|
+
RangeDate: () => RangeDate,
|
141
144
|
ReadActionInput: () => ReadActionInput,
|
142
145
|
RegisterAction: () => RegisterAction,
|
143
146
|
RegisterActionInput: () => RegisterActionInput,
|
@@ -154,8 +157,10 @@ __export(events_exports, {
|
|
154
157
|
SelectOption: () => SelectOption,
|
155
158
|
ShowConditional: () => ShowConditional,
|
156
159
|
SignatureFieldValue: () => SignatureFieldValue,
|
160
|
+
StatusChangingActions: () => StatusChangingActions,
|
157
161
|
SummaryConfig: () => SummaryConfig,
|
158
162
|
TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
|
163
|
+
TestUserRole: () => TestUserRole,
|
159
164
|
TextValue: () => TextValue,
|
160
165
|
TranslationConfig: () => TranslationConfig,
|
161
166
|
UnassignActionInput: () => UnassignActionInput,
|
@@ -165,6 +170,7 @@ __export(events_exports, {
|
|
165
170
|
ValidateActionInput: () => ValidateActionInput,
|
166
171
|
VerificationActionConfig: () => VerificationActionConfig,
|
167
172
|
VerificationPageConfig: () => VerificationPageConfig,
|
173
|
+
WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
|
168
174
|
Within: () => Within,
|
169
175
|
WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
|
170
176
|
WorkqueueColumn: () => WorkqueueColumn,
|
@@ -173,6 +179,7 @@ __export(events_exports, {
|
|
173
179
|
WorkqueueColumnValue: () => WorkqueueColumnValue,
|
174
180
|
WorkqueueConfig: () => WorkqueueConfig,
|
175
181
|
WorkqueueConfigInput: () => WorkqueueConfigInput,
|
182
|
+
WorkqueueConfigWithoutQuery: () => WorkqueueConfigWithoutQuery,
|
176
183
|
WorkqueueCountInput: () => WorkqueueCountInput,
|
177
184
|
WorkqueueCountOutput: () => WorkqueueCountOutput,
|
178
185
|
ZodDate: () => ZodDate,
|
@@ -185,9 +192,8 @@ __export(events_exports, {
|
|
185
192
|
createEmptyDraft: () => createEmptyDraft,
|
186
193
|
createEventConditionals: () => createEventConditionals,
|
187
194
|
createFieldConditionals: () => createFieldConditionals,
|
188
|
-
|
195
|
+
createPrng: () => createPrng,
|
189
196
|
createValidationSchema: () => createValidationSchema,
|
190
|
-
dateOfEventColumn: () => dateOfEventColumn,
|
191
197
|
deepDropNulls: () => deepDropNulls,
|
192
198
|
deepMerge: () => deepMerge,
|
193
199
|
defaultWorkqueueColumns: () => defaultWorkqueueColumns,
|
@@ -207,7 +213,6 @@ __export(events_exports, {
|
|
207
213
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
208
214
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
209
215
|
eventQueryDataGenerator: () => eventQueryDataGenerator,
|
210
|
-
eventStatuses: () => eventStatuses,
|
211
216
|
field: () => field,
|
212
217
|
fieldTypes: () => fieldTypes,
|
213
218
|
filterUnallowedActions: () => filterUnallowedActions,
|
@@ -220,6 +225,7 @@ __export(events_exports, {
|
|
220
225
|
generateActionDocument: () => generateActionDocument,
|
221
226
|
generateEventDocument: () => generateEventDocument,
|
222
227
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
228
|
+
generateRandomName: () => generateRandomName,
|
223
229
|
generateRandomSignature: () => generateRandomSignature,
|
224
230
|
generateTransactionId: () => generateTransactionId,
|
225
231
|
generateTranslationConfig: () => generateTranslationConfig,
|
@@ -230,17 +236,23 @@ __export(events_exports, {
|
|
230
236
|
getActionReview: () => getActionReview,
|
231
237
|
getActionReviewFields: () => getActionReviewFields,
|
232
238
|
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
239
|
+
getAllUniqueFields: () => getAllUniqueFields,
|
233
240
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
234
241
|
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
235
242
|
getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
|
236
243
|
getCurrentEventState: () => getCurrentEventState,
|
237
244
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
238
245
|
getDeclaration: () => getDeclaration,
|
246
|
+
getDeclarationFieldById: () => getDeclarationFieldById,
|
239
247
|
getDeclarationFields: () => getDeclarationFields,
|
240
248
|
getDeclarationPages: () => getDeclarationPages,
|
249
|
+
getEventConfigById: () => getEventConfigById,
|
241
250
|
getMixedPath: () => getMixedPath,
|
251
|
+
getRandomDate: () => getRandomDate,
|
242
252
|
getRandomDatetime: () => getRandomDatetime,
|
243
253
|
getStatusFromActions: () => getStatusFromActions,
|
254
|
+
getUserActionsByStatus: () => getUserActionsByStatus,
|
255
|
+
getValidatorsForField: () => getValidatorsForField,
|
244
256
|
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
245
257
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
246
258
|
isAddressFieldType: () => isAddressFieldType,
|
@@ -263,14 +275,17 @@ __export(events_exports, {
|
|
263
275
|
isFieldVisible: () => isFieldVisible,
|
264
276
|
isFileFieldType: () => isFileFieldType,
|
265
277
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
278
|
+
isIdFieldType: () => isIdFieldType,
|
266
279
|
isLocationFieldType: () => isLocationFieldType,
|
267
280
|
isMetaAction: () => isMetaAction,
|
281
|
+
isNameFieldType: () => isNameFieldType,
|
268
282
|
isNonInteractiveFieldType: () => isNonInteractiveFieldType,
|
269
283
|
isNumberFieldType: () => isNumberFieldType,
|
270
284
|
isOfficeFieldType: () => isOfficeFieldType,
|
271
285
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
272
286
|
isPageVisible: () => isPageVisible,
|
273
287
|
isParagraphFieldType: () => isParagraphFieldType,
|
288
|
+
isPhoneFieldType: () => isPhoneFieldType,
|
274
289
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
275
290
|
isSelectFieldType: () => isSelectFieldType,
|
276
291
|
isSignatureFieldType: () => isSignatureFieldType,
|
@@ -280,6 +295,7 @@ __export(events_exports, {
|
|
280
295
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
281
296
|
isVerificationPage: () => isVerificationPage,
|
282
297
|
isWriteAction: () => isWriteAction,
|
298
|
+
mandatoryColumns: () => mandatoryColumns,
|
283
299
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
284
300
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
285
301
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
@@ -300,6 +316,7 @@ module.exports = __toCommonJS(events_exports);
|
|
300
316
|
|
301
317
|
// ../commons/src/events/Constants.ts
|
302
318
|
var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
|
319
|
+
var BIRTH_EVENT = "v2-birth";
|
303
320
|
|
304
321
|
// ../commons/src/events/ActionConfig.ts
|
305
322
|
var import_zod9 = require("zod");
|
@@ -378,6 +395,9 @@ var TranslationConfig = import_zod2.z.object({
|
|
378
395
|
|
379
396
|
// ../commons/src/events/FieldType.ts
|
380
397
|
var FieldType = {
|
398
|
+
NAME: "NAME",
|
399
|
+
PHONE: "PHONE",
|
400
|
+
ID: "ID",
|
381
401
|
ADDRESS: "ADDRESS",
|
382
402
|
TEXT: "TEXT",
|
383
403
|
NUMBER: "NUMBER",
|
@@ -454,6 +474,16 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
|
|
454
474
|
number: import_zod3.z.string().nullish(),
|
455
475
|
zipCode: import_zod3.z.string().nullish()
|
456
476
|
});
|
477
|
+
var NameFieldValue = import_zod3.z.object({
|
478
|
+
firstname: import_zod3.z.string(),
|
479
|
+
surname: import_zod3.z.string(),
|
480
|
+
middlename: import_zod3.z.string().optional()
|
481
|
+
});
|
482
|
+
var NameFieldUpdateValue = import_zod3.z.object({
|
483
|
+
firstname: import_zod3.z.string(),
|
484
|
+
surname: import_zod3.z.string(),
|
485
|
+
middlename: import_zod3.z.string().nullish()
|
486
|
+
}).or(import_zod3.z.null()).or(import_zod3.z.undefined());
|
457
487
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
458
488
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
459
489
|
village: import_zod3.z.string().nullish()
|
@@ -515,7 +545,9 @@ var FieldValue = import_zod4.z.union([
|
|
515
545
|
UrbanAddressValue,
|
516
546
|
RuralAddressValue,
|
517
547
|
DataFieldValue,
|
518
|
-
GenericAddressValue
|
548
|
+
GenericAddressValue,
|
549
|
+
NameFieldValue,
|
550
|
+
NameFieldUpdateValue
|
519
551
|
]);
|
520
552
|
var FieldUpdateValue = import_zod4.z.union([
|
521
553
|
TextValue,
|
@@ -528,7 +560,8 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
528
560
|
UrbanAddressUpdateValue,
|
529
561
|
RuralAddressUpdateValue,
|
530
562
|
DataFieldValue,
|
531
|
-
GenericAddressUpdateValue
|
563
|
+
GenericAddressUpdateValue,
|
564
|
+
NameFieldUpdateValue
|
532
565
|
]);
|
533
566
|
|
534
567
|
// ../commons/src/events/FieldConfig.ts
|
@@ -705,6 +738,26 @@ var Select = BaseField.extend({
|
|
705
738
|
defaultValue: TextValue.optional(),
|
706
739
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
707
740
|
}).describe("Select input");
|
741
|
+
var NameField = BaseField.extend({
|
742
|
+
type: import_zod5.z.literal(FieldType.NAME),
|
743
|
+
defaultValue: import_zod5.z.object({
|
744
|
+
firstname: NonEmptyTextValue,
|
745
|
+
surname: NonEmptyTextValue
|
746
|
+
}).optional(),
|
747
|
+
configuration: import_zod5.z.object({
|
748
|
+
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
749
|
+
prefix: TranslationConfig.optional(),
|
750
|
+
postfix: TranslationConfig.optional()
|
751
|
+
}).optional()
|
752
|
+
}).describe("Name input field");
|
753
|
+
var PhoneField = BaseField.extend({
|
754
|
+
defaultValue: NonEmptyTextValue.optional(),
|
755
|
+
type: import_zod5.z.literal(FieldType.PHONE)
|
756
|
+
}).describe("Phone input field");
|
757
|
+
var IdField = BaseField.extend({
|
758
|
+
defaultValue: NonEmptyTextValue.optional(),
|
759
|
+
type: import_zod5.z.literal(FieldType.ID)
|
760
|
+
}).describe("ID input field");
|
708
761
|
var Checkbox = BaseField.extend({
|
709
762
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
710
763
|
defaultValue: CheckboxFieldValue.optional()
|
@@ -784,6 +837,9 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
784
837
|
BulletList,
|
785
838
|
PageHeader,
|
786
839
|
Select,
|
840
|
+
NameField,
|
841
|
+
PhoneField,
|
842
|
+
IdField,
|
787
843
|
Checkbox,
|
788
844
|
File,
|
789
845
|
Country,
|
@@ -917,6 +973,16 @@ var writeActions = ActionTypes.exclude([
|
|
917
973
|
ActionType.ASSIGN,
|
918
974
|
ActionType.UNASSIGN
|
919
975
|
]);
|
976
|
+
var StatusChangingActions = ActionTypes.extract([
|
977
|
+
ActionType.CREATE,
|
978
|
+
ActionType.NOTIFY,
|
979
|
+
ActionType.DECLARE,
|
980
|
+
ActionType.VALIDATE,
|
981
|
+
ActionType.REGISTER,
|
982
|
+
ActionType.REJECT,
|
983
|
+
ActionType.ARCHIVE,
|
984
|
+
ActionType.PRINT_CERTIFICATE
|
985
|
+
]);
|
920
986
|
var workqueueActions = ActionTypes.exclude([
|
921
987
|
ActionType.CREATE,
|
922
988
|
ActionType.NOTIFY,
|
@@ -1097,7 +1163,7 @@ var LanguageConfig = import_zod11.z.object({
|
|
1097
1163
|
});
|
1098
1164
|
|
1099
1165
|
// ../commons/src/events/EventConfig.ts
|
1100
|
-
var
|
1166
|
+
var import_zod20 = require("zod");
|
1101
1167
|
|
1102
1168
|
// ../commons/src/events/DeduplicationConfig.ts
|
1103
1169
|
var import_zod12 = require("zod");
|
@@ -1189,8 +1255,7 @@ var Field = BaseField2.extend({
|
|
1189
1255
|
value: TranslationConfig.describe(
|
1190
1256
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1191
1257
|
),
|
1192
|
-
label: TranslationConfig
|
1193
|
-
emptyValueMessage: TranslationConfig.optional()
|
1258
|
+
label: TranslationConfig
|
1194
1259
|
}).describe("Custom configured field");
|
1195
1260
|
var SummaryConfig = import_zod13.z.object({
|
1196
1261
|
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
@@ -1206,35 +1271,35 @@ var BaseField3 = import_zod14.z.object({
|
|
1206
1271
|
options: import_zod14.z.array(SelectOption).optional(),
|
1207
1272
|
searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
|
1208
1273
|
`
|
1209
|
-
This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
|
1274
|
+
This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
|
1210
1275
|
when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
|
1211
1276
|
|
1212
|
-
For example, a field config like { id: "child.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
|
1277
|
+
For example, a field config like { id: "child.name.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
|
1213
1278
|
|
1214
1279
|
A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
|
1215
1280
|
|
1216
|
-
So, if both child.firstname and mother.firstname are used in a search, the resulting search criteria labels would be "First Name(s)", "First Name(s)",
|
1281
|
+
So, if both child.name.firstname and mother.firstname are used in a search, the resulting search criteria labels would be "First Name(s)", "First Name(s)",
|
1217
1282
|
which is ambiguous.
|
1218
1283
|
|
1219
|
-
Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
|
1220
|
-
descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
|
1284
|
+
Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
|
1285
|
+
descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
|
1221
1286
|
label would be "Applicant Applicant's First Name", which is redundant and awkward.
|
1222
1287
|
|
1223
|
-
By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
|
1288
|
+
By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
|
1224
1289
|
in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
|
1225
1290
|
`
|
1226
1291
|
),
|
1227
1292
|
conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
|
1228
1293
|
`
|
1229
1294
|
In advanced search, we sometimes need to override the default field visibility conditionals.
|
1230
|
-
|
1231
|
-
For example, Informant fields in the declaration form may have conditional logic
|
1232
|
-
that hides them based on other field values. Since the advanced search form reuses
|
1295
|
+
|
1296
|
+
For example, Informant fields in the declaration form may have conditional logic
|
1297
|
+
that hides them based on other field values. Since the advanced search form reuses
|
1233
1298
|
the declaration form config, those same conditionals would apply by default.
|
1234
|
-
|
1299
|
+
|
1235
1300
|
However, in advanced search we often want to make all Informant fields searchable,
|
1236
|
-
regardless of their original visibility logic. To do this, we explicitly set their
|
1237
|
-
'conditionals' to an empty array ('[]') in the search config. This ensures they
|
1301
|
+
regardless of their original visibility logic. To do this, we explicitly set their
|
1302
|
+
'conditionals' to an empty array ('[]') in the search config. This ensures they
|
1238
1303
|
are always rendered in the advanced search form.
|
1239
1304
|
`
|
1240
1305
|
)
|
@@ -1272,127 +1337,552 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1272
1337
|
var import_lodash = require("lodash");
|
1273
1338
|
|
1274
1339
|
// ../commons/src/events/ActionDocument.ts
|
1275
|
-
var
|
1340
|
+
var import_zod18 = require("zod");
|
1276
1341
|
var import_zod_openapi7 = require("zod-openapi");
|
1277
1342
|
|
1278
1343
|
// ../commons/src/events/CreatedAtLocation.ts
|
1279
1344
|
var import_zod15 = require("zod");
|
1280
1345
|
var CreatedAtLocation = import_zod15.z.string().nullish();
|
1281
1346
|
|
1347
|
+
// ../commons/src/authentication.ts
|
1348
|
+
var import_jwt_decode = __toESM(require("jwt-decode"));
|
1349
|
+
var import_zod17 = require("zod");
|
1350
|
+
|
1351
|
+
// ../commons/src/scopes.ts
|
1352
|
+
var import_zod16 = require("zod");
|
1353
|
+
var SCOPES = {
|
1354
|
+
// TODO v1.8 legacy scopes
|
1355
|
+
NATLSYSADMIN: "natlsysadmin",
|
1356
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
1357
|
+
DECLARE: "declare",
|
1358
|
+
REGISTER: "register",
|
1359
|
+
VALIDATE: "validate",
|
1360
|
+
DEMO: "demo",
|
1361
|
+
CERTIFY: "certify",
|
1362
|
+
PERFORMANCE: "performance",
|
1363
|
+
SYSADMIN: "sysadmin",
|
1364
|
+
TEAMS: "teams",
|
1365
|
+
CONFIG: "config",
|
1366
|
+
// systems / integrations
|
1367
|
+
WEBHOOK: "webhook",
|
1368
|
+
NATIONALID: "nationalId",
|
1369
|
+
NOTIFICATION_API: "notification-api",
|
1370
|
+
RECORDSEARCH: "recordsearch",
|
1371
|
+
/**
|
1372
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
1373
|
+
*/
|
1374
|
+
RECORD_DECLARE: "record.declare-birth",
|
1375
|
+
// declare
|
1376
|
+
RECORD_IMPORT: "record.import",
|
1377
|
+
// declare
|
1378
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
1379
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
1380
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
1381
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
1382
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
1383
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
1384
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
1385
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
1386
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
1387
|
+
// validate
|
1388
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
1389
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
1390
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
1391
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
1392
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
1393
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
1394
|
+
// register
|
1395
|
+
RECORD_REGISTER: "record.register",
|
1396
|
+
// certify
|
1397
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
1398
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
1399
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
1400
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
1401
|
+
// v1.8
|
1402
|
+
/**
|
1403
|
+
* This scope is used to **print and **issue certified copies of a record
|
1404
|
+
* after it has been registered. Previously Registrars had this permission.
|
1405
|
+
*/
|
1406
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
1407
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
1408
|
+
// v1.8
|
1409
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
1410
|
+
// v1.8
|
1411
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
1412
|
+
// v1.8
|
1413
|
+
// correct
|
1414
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
1415
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
1416
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
1417
|
+
// v1.8
|
1418
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
1419
|
+
// v1.8
|
1420
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
1421
|
+
// v1.8
|
1422
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
1423
|
+
// v1.8
|
1424
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
1425
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
1426
|
+
// search
|
1427
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
1428
|
+
SEARCH_BIRTH: "search.birth",
|
1429
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
1430
|
+
SEARCH_DEATH: "search.death",
|
1431
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
1432
|
+
SEARCH_MARRIAGE: "search.marriage",
|
1433
|
+
// audit v1.8
|
1434
|
+
RECORD_READ: "record.read",
|
1435
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
1436
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
1437
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
1438
|
+
// profile
|
1439
|
+
PROFILE_UPDATE: "profile.update",
|
1440
|
+
//v1.8
|
1441
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
1442
|
+
// performance
|
1443
|
+
PERFORMANCE_READ: "performance.read",
|
1444
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
1445
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
1446
|
+
// organisation
|
1447
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
1448
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
1449
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
1450
|
+
// user
|
1451
|
+
USER_READ: "user.read:all",
|
1452
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
1453
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
1454
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
1455
|
+
//v1.8
|
1456
|
+
USER_CREATE: "user.create:all",
|
1457
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
1458
|
+
USER_UPDATE: "user.update:all",
|
1459
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
1460
|
+
// config
|
1461
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
1462
|
+
// data seeding
|
1463
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
1464
|
+
};
|
1465
|
+
var LegacyScopes = import_zod16.z.union([
|
1466
|
+
import_zod16.z.literal(SCOPES.NATLSYSADMIN),
|
1467
|
+
import_zod16.z.literal(SCOPES.BYPASSRATELIMIT),
|
1468
|
+
import_zod16.z.literal(SCOPES.DECLARE),
|
1469
|
+
import_zod16.z.literal(SCOPES.REGISTER),
|
1470
|
+
import_zod16.z.literal(SCOPES.VALIDATE),
|
1471
|
+
import_zod16.z.literal(SCOPES.DEMO),
|
1472
|
+
import_zod16.z.literal(SCOPES.CERTIFY),
|
1473
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE),
|
1474
|
+
import_zod16.z.literal(SCOPES.SYSADMIN),
|
1475
|
+
import_zod16.z.literal(SCOPES.TEAMS),
|
1476
|
+
import_zod16.z.literal(SCOPES.CONFIG)
|
1477
|
+
]);
|
1478
|
+
var IntegrationScopes = import_zod16.z.union([
|
1479
|
+
import_zod16.z.literal(SCOPES.WEBHOOK),
|
1480
|
+
import_zod16.z.literal(SCOPES.NATIONALID),
|
1481
|
+
import_zod16.z.literal(SCOPES.NOTIFICATION_API),
|
1482
|
+
import_zod16.z.literal(SCOPES.RECORDSEARCH)
|
1483
|
+
]);
|
1484
|
+
var DeclareScopes = import_zod16.z.union([
|
1485
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE),
|
1486
|
+
import_zod16.z.literal(SCOPES.RECORD_IMPORT),
|
1487
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
1488
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
1489
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
1490
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
1491
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
1492
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
1493
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
1494
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
|
1495
|
+
]);
|
1496
|
+
var UnassignScope = import_zod16.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
|
1497
|
+
var ValidateScopes = import_zod16.z.union([
|
1498
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
1499
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
1500
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
1501
|
+
import_zod16.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
1502
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
1503
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
|
1504
|
+
]);
|
1505
|
+
var RegisterScope = import_zod16.z.literal(SCOPES.RECORD_REGISTER);
|
1506
|
+
var CertifyScopes = import_zod16.z.union([
|
1507
|
+
import_zod16.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
1508
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
1509
|
+
import_zod16.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
1510
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
1511
|
+
import_zod16.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
1512
|
+
import_zod16.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
1513
|
+
import_zod16.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
1514
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
|
1515
|
+
]);
|
1516
|
+
var CorrectionScopes = import_zod16.z.union([
|
1517
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
1518
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
1519
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
1520
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
1521
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
1522
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
1523
|
+
import_zod16.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
1524
|
+
import_zod16.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
|
1525
|
+
]);
|
1526
|
+
var SearchScopes = import_zod16.z.union([
|
1527
|
+
import_zod16.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
1528
|
+
import_zod16.z.literal(SCOPES.SEARCH_BIRTH),
|
1529
|
+
import_zod16.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
1530
|
+
import_zod16.z.literal(SCOPES.SEARCH_DEATH),
|
1531
|
+
import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
1532
|
+
import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE)
|
1533
|
+
]);
|
1534
|
+
var AuditScopes = import_zod16.z.union([
|
1535
|
+
import_zod16.z.literal(SCOPES.RECORD_READ),
|
1536
|
+
import_zod16.z.literal(SCOPES.RECORD_READ_AUDIT),
|
1537
|
+
import_zod16.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
1538
|
+
import_zod16.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
|
1539
|
+
]);
|
1540
|
+
var ProfileScopes = import_zod16.z.union([
|
1541
|
+
import_zod16.z.literal(SCOPES.PROFILE_UPDATE),
|
1542
|
+
import_zod16.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
|
1543
|
+
]);
|
1544
|
+
var PerformanceScopes = import_zod16.z.union([
|
1545
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE_READ),
|
1546
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
1547
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
|
1548
|
+
]);
|
1549
|
+
var OrganisationScopes = import_zod16.z.union([
|
1550
|
+
import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
1551
|
+
import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
1552
|
+
import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
|
1553
|
+
]);
|
1554
|
+
var UserScopes = import_zod16.z.union([
|
1555
|
+
import_zod16.z.literal(SCOPES.USER_READ),
|
1556
|
+
import_zod16.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
1557
|
+
import_zod16.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
1558
|
+
import_zod16.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
1559
|
+
import_zod16.z.literal(SCOPES.USER_CREATE),
|
1560
|
+
import_zod16.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
1561
|
+
import_zod16.z.literal(SCOPES.USER_UPDATE),
|
1562
|
+
import_zod16.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
|
1563
|
+
]);
|
1564
|
+
var ConfigScope = import_zod16.z.literal(SCOPES.CONFIG_UPDATE_ALL);
|
1565
|
+
var DataSeedingScope = import_zod16.z.literal(SCOPES.USER_DATA_SEEDING);
|
1566
|
+
var LiteralScopes = import_zod16.z.union([
|
1567
|
+
LegacyScopes,
|
1568
|
+
IntegrationScopes,
|
1569
|
+
UnassignScope,
|
1570
|
+
DeclareScopes,
|
1571
|
+
ValidateScopes,
|
1572
|
+
RegisterScope,
|
1573
|
+
CertifyScopes,
|
1574
|
+
CorrectionScopes,
|
1575
|
+
SearchScopes,
|
1576
|
+
AuditScopes,
|
1577
|
+
ProfileScopes,
|
1578
|
+
PerformanceScopes,
|
1579
|
+
OrganisationScopes,
|
1580
|
+
UserScopes,
|
1581
|
+
ConfigScope,
|
1582
|
+
DataSeedingScope
|
1583
|
+
]);
|
1584
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
1585
|
+
var rawConfigurableScope = import_zod16.z.string().regex(rawConfigurableScopeRegex);
|
1586
|
+
var CreateUserScope = import_zod16.z.object({
|
1587
|
+
type: import_zod16.z.literal("user.create"),
|
1588
|
+
options: import_zod16.z.object({
|
1589
|
+
role: import_zod16.z.array(import_zod16.z.string())
|
1590
|
+
})
|
1591
|
+
});
|
1592
|
+
var EditUserScope = import_zod16.z.object({
|
1593
|
+
type: import_zod16.z.literal("user.edit"),
|
1594
|
+
options: import_zod16.z.object({
|
1595
|
+
role: import_zod16.z.array(import_zod16.z.string())
|
1596
|
+
})
|
1597
|
+
});
|
1598
|
+
var WorkqueueScope = import_zod16.z.object({
|
1599
|
+
type: import_zod16.z.literal("workqueue"),
|
1600
|
+
options: import_zod16.z.object({
|
1601
|
+
id: import_zod16.z.array(import_zod16.z.string())
|
1602
|
+
})
|
1603
|
+
});
|
1604
|
+
var NotifyRecordScope = import_zod16.z.object({
|
1605
|
+
type: import_zod16.z.literal("record.notify"),
|
1606
|
+
options: import_zod16.z.object({
|
1607
|
+
event: import_zod16.z.array(import_zod16.z.string())
|
1608
|
+
})
|
1609
|
+
});
|
1610
|
+
var ConfigurableScopes = import_zod16.z.discriminatedUnion("type", [
|
1611
|
+
CreateUserScope,
|
1612
|
+
EditUserScope,
|
1613
|
+
WorkqueueScope,
|
1614
|
+
NotifyRecordScope
|
1615
|
+
]);
|
1616
|
+
var scopes = Object.values(SCOPES);
|
1617
|
+
var ActionScopes = import_zod16.z.union([
|
1618
|
+
DeclareScopes,
|
1619
|
+
ValidateScopes,
|
1620
|
+
RegisterScope,
|
1621
|
+
CertifyScopes,
|
1622
|
+
CorrectionScopes
|
1623
|
+
]);
|
1624
|
+
|
1625
|
+
// ../commons/src/authentication.ts
|
1626
|
+
var DEFAULT_ROLES_DEFINITION = [
|
1627
|
+
{
|
1628
|
+
id: "FIELD_AGENT",
|
1629
|
+
label: {
|
1630
|
+
defaultMessage: "Field Agent",
|
1631
|
+
description: "Name for user role Field Agent",
|
1632
|
+
id: "userRole.fieldAgent"
|
1633
|
+
},
|
1634
|
+
scopes: [
|
1635
|
+
// new scopes
|
1636
|
+
SCOPES.RECORD_DECLARE_BIRTH,
|
1637
|
+
SCOPES.RECORD_DECLARE_DEATH,
|
1638
|
+
SCOPES.RECORD_DECLARE_MARRIAGE,
|
1639
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
1640
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
1641
|
+
SCOPES.SEARCH_BIRTH,
|
1642
|
+
SCOPES.SEARCH_DEATH,
|
1643
|
+
SCOPES.SEARCH_MARRIAGE
|
1644
|
+
]
|
1645
|
+
},
|
1646
|
+
{
|
1647
|
+
id: "REGISTRATION_AGENT",
|
1648
|
+
label: {
|
1649
|
+
defaultMessage: "Registration Agent",
|
1650
|
+
description: "Name for user role Registration Agent",
|
1651
|
+
id: "userRole.registrationAgent"
|
1652
|
+
},
|
1653
|
+
scopes: [
|
1654
|
+
SCOPES.PERFORMANCE,
|
1655
|
+
SCOPES.CERTIFY,
|
1656
|
+
SCOPES.RECORD_DECLARE_BIRTH,
|
1657
|
+
SCOPES.RECORD_DECLARE_DEATH,
|
1658
|
+
SCOPES.RECORD_DECLARE_MARRIAGE,
|
1659
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
1660
|
+
SCOPES.RECORD_SUBMIT_FOR_UPDATES,
|
1661
|
+
SCOPES.RECORD_DECLARATION_ARCHIVE,
|
1662
|
+
SCOPES.RECORD_DECLARATION_REINSTATE,
|
1663
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION,
|
1664
|
+
SCOPES.RECORD_REGISTRATION_PRINT,
|
1665
|
+
SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
|
1666
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
1667
|
+
SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
|
1668
|
+
SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
|
1669
|
+
SCOPES.RECORD_CREATE_COMMENTS,
|
1670
|
+
SCOPES.PERFORMANCE_READ,
|
1671
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1672
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1673
|
+
SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
|
1674
|
+
SCOPES.SEARCH_BIRTH,
|
1675
|
+
SCOPES.SEARCH_DEATH,
|
1676
|
+
SCOPES.SEARCH_MARRIAGE
|
1677
|
+
]
|
1678
|
+
},
|
1679
|
+
{
|
1680
|
+
id: "LOCAL_REGISTRAR",
|
1681
|
+
label: {
|
1682
|
+
defaultMessage: "Local Registrar",
|
1683
|
+
description: "Name for user role Local Registrar",
|
1684
|
+
id: "userRole.localRegistrar"
|
1685
|
+
},
|
1686
|
+
scopes: [
|
1687
|
+
SCOPES.PERFORMANCE,
|
1688
|
+
SCOPES.CERTIFY,
|
1689
|
+
SCOPES.RECORD_DECLARE_BIRTH,
|
1690
|
+
SCOPES.RECORD_DECLARE_DEATH,
|
1691
|
+
SCOPES.RECORD_DECLARE_MARRIAGE,
|
1692
|
+
SCOPES.RECORD_SUBMIT_FOR_UPDATES,
|
1693
|
+
SCOPES.RECORD_REVIEW_DUPLICATES,
|
1694
|
+
SCOPES.RECORD_DECLARATION_ARCHIVE,
|
1695
|
+
SCOPES.RECORD_DECLARATION_REINSTATE,
|
1696
|
+
SCOPES.RECORD_REGISTER,
|
1697
|
+
SCOPES.RECORD_REGISTRATION_CORRECT,
|
1698
|
+
SCOPES.RECORD_REGISTRATION_PRINT,
|
1699
|
+
SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
|
1700
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
1701
|
+
SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
|
1702
|
+
SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
|
1703
|
+
SCOPES.RECORD_CREATE_COMMENTS,
|
1704
|
+
SCOPES.PERFORMANCE_READ,
|
1705
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1706
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1707
|
+
SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
|
1708
|
+
SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
|
1709
|
+
SCOPES.SEARCH_BIRTH,
|
1710
|
+
SCOPES.SEARCH_DEATH,
|
1711
|
+
SCOPES.SEARCH_MARRIAGE
|
1712
|
+
]
|
1713
|
+
},
|
1714
|
+
{
|
1715
|
+
id: "LOCAL_SYSTEM_ADMIN",
|
1716
|
+
label: {
|
1717
|
+
defaultMessage: "Local System Admin",
|
1718
|
+
description: "Name for user role Local System Admin",
|
1719
|
+
id: "userRole.localSystemAdmin"
|
1720
|
+
},
|
1721
|
+
scopes: [
|
1722
|
+
SCOPES.SYSADMIN,
|
1723
|
+
SCOPES.USER_READ_MY_OFFICE,
|
1724
|
+
SCOPES.USER_CREATE_MY_JURISDICTION,
|
1725
|
+
SCOPES.USER_UPDATE_MY_JURISDICTION,
|
1726
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1727
|
+
SCOPES.PERFORMANCE_READ,
|
1728
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1729
|
+
SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
|
1730
|
+
// 'organisation.read-users' ?
|
1731
|
+
]
|
1732
|
+
},
|
1733
|
+
{
|
1734
|
+
id: "NATIONAL_SYSTEM_ADMIN",
|
1735
|
+
label: {
|
1736
|
+
defaultMessage: "National System Admin",
|
1737
|
+
description: "Name for user role National System Admin",
|
1738
|
+
id: "userRole.nationalSystemAdmin"
|
1739
|
+
},
|
1740
|
+
scopes: [
|
1741
|
+
SCOPES.SYSADMIN,
|
1742
|
+
SCOPES.NATLSYSADMIN,
|
1743
|
+
SCOPES.USER_CREATE,
|
1744
|
+
SCOPES.USER_READ,
|
1745
|
+
SCOPES.USER_UPDATE,
|
1746
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1747
|
+
SCOPES.PERFORMANCE_READ,
|
1748
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1749
|
+
SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
|
1750
|
+
// 'organisation.read-users' ?
|
1751
|
+
]
|
1752
|
+
},
|
1753
|
+
{
|
1754
|
+
id: "PERFORMANCE_MANAGER",
|
1755
|
+
label: {
|
1756
|
+
defaultMessage: "Performance Manager",
|
1757
|
+
description: "Name for user role Performance Manager",
|
1758
|
+
id: "userRole.performanceManager"
|
1759
|
+
},
|
1760
|
+
scopes: [
|
1761
|
+
SCOPES.PERFORMANCE,
|
1762
|
+
SCOPES.PERFORMANCE_READ,
|
1763
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1764
|
+
SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
|
1765
|
+
]
|
1766
|
+
}
|
1767
|
+
];
|
1768
|
+
var TokenUserType = import_zod17.z.enum(["user", "system"]);
|
1769
|
+
var TokenWithBearer = import_zod17.z.string().regex(/^Bearer\s/);
|
1770
|
+
|
1282
1771
|
// ../commons/src/events/ActionDocument.ts
|
1283
|
-
(0, import_zod_openapi7.extendZodWithOpenApi)(
|
1284
|
-
var ActionUpdate =
|
1285
|
-
var EventState =
|
1772
|
+
(0, import_zod_openapi7.extendZodWithOpenApi)(import_zod18.z);
|
1773
|
+
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1774
|
+
var EventState = import_zod18.z.record(import_zod18.z.string(), FieldValue);
|
1286
1775
|
var ActionStatus = {
|
1287
1776
|
Requested: "Requested",
|
1288
1777
|
Accepted: "Accepted",
|
1289
1778
|
Rejected: "Rejected"
|
1290
1779
|
};
|
1291
|
-
var ActionBase =
|
1292
|
-
id:
|
1293
|
-
transactionId:
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1780
|
+
var ActionBase = import_zod18.z.object({
|
1781
|
+
id: import_zod18.z.string(),
|
1782
|
+
transactionId: import_zod18.z.string(),
|
1783
|
+
createdByUserType: TokenUserType,
|
1784
|
+
createdAt: import_zod18.z.string().datetime(),
|
1785
|
+
createdBy: import_zod18.z.string(),
|
1786
|
+
createdByRole: import_zod18.z.string(),
|
1787
|
+
createdBySignature: import_zod18.z.string().nullish().describe("Reference to signature of the user who created the action"),
|
1298
1788
|
createdAtLocation: CreatedAtLocation,
|
1299
1789
|
declaration: ActionUpdate,
|
1300
1790
|
annotation: ActionUpdate.optional(),
|
1301
|
-
status:
|
1791
|
+
status: import_zod18.z.enum([
|
1302
1792
|
ActionStatus.Requested,
|
1303
1793
|
ActionStatus.Accepted,
|
1304
1794
|
ActionStatus.Rejected
|
1305
1795
|
]),
|
1306
1796
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1307
|
-
originalActionId:
|
1797
|
+
originalActionId: import_zod18.z.string().optional()
|
1308
1798
|
});
|
1309
1799
|
var AssignedAction = ActionBase.merge(
|
1310
|
-
|
1311
|
-
type:
|
1312
|
-
assignedTo:
|
1800
|
+
import_zod18.z.object({
|
1801
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1802
|
+
assignedTo: import_zod18.z.string()
|
1313
1803
|
})
|
1314
1804
|
);
|
1315
1805
|
var UnassignedAction = ActionBase.merge(
|
1316
|
-
|
1317
|
-
type:
|
1318
|
-
assignedTo:
|
1806
|
+
import_zod18.z.object({
|
1807
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1808
|
+
assignedTo: import_zod18.z.literal(null)
|
1319
1809
|
})
|
1320
1810
|
);
|
1321
1811
|
var RegisterAction = ActionBase.merge(
|
1322
|
-
|
1323
|
-
type:
|
1324
|
-
registrationNumber:
|
1812
|
+
import_zod18.z.object({
|
1813
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1814
|
+
registrationNumber: import_zod18.z.string().optional()
|
1325
1815
|
})
|
1326
1816
|
);
|
1327
1817
|
var DeclareAction = ActionBase.merge(
|
1328
|
-
|
1329
|
-
type:
|
1818
|
+
import_zod18.z.object({
|
1819
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1330
1820
|
})
|
1331
1821
|
);
|
1332
1822
|
var ValidateAction = ActionBase.merge(
|
1333
|
-
|
1334
|
-
type:
|
1823
|
+
import_zod18.z.object({
|
1824
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1335
1825
|
})
|
1336
1826
|
);
|
1337
|
-
var RejectionReason =
|
1338
|
-
message:
|
1339
|
-
isDuplicate:
|
1827
|
+
var RejectionReason = import_zod18.z.object({
|
1828
|
+
message: import_zod18.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
|
1829
|
+
isDuplicate: import_zod18.z.boolean().optional().describe("If a declaration is duplicated")
|
1340
1830
|
});
|
1341
1831
|
var RejectAction = ActionBase.merge(
|
1342
|
-
|
1343
|
-
type:
|
1832
|
+
import_zod18.z.object({
|
1833
|
+
type: import_zod18.z.literal(ActionType.REJECT),
|
1344
1834
|
reason: RejectionReason
|
1345
1835
|
})
|
1346
1836
|
);
|
1347
1837
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1348
|
-
|
1349
|
-
type:
|
1838
|
+
import_zod18.z.object({
|
1839
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1350
1840
|
})
|
1351
1841
|
);
|
1352
1842
|
var ArchiveAction = ActionBase.merge(
|
1353
|
-
|
1354
|
-
type:
|
1843
|
+
import_zod18.z.object({
|
1844
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE),
|
1355
1845
|
reason: RejectionReason
|
1356
1846
|
})
|
1357
1847
|
);
|
1358
1848
|
var CreatedAction = ActionBase.merge(
|
1359
|
-
|
1360
|
-
type:
|
1849
|
+
import_zod18.z.object({
|
1850
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1361
1851
|
})
|
1362
1852
|
);
|
1363
1853
|
var NotifiedAction = ActionBase.merge(
|
1364
|
-
|
1365
|
-
type:
|
1854
|
+
import_zod18.z.object({
|
1855
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1366
1856
|
})
|
1367
1857
|
);
|
1368
1858
|
var PrintCertificateAction = ActionBase.merge(
|
1369
|
-
|
1370
|
-
type:
|
1859
|
+
import_zod18.z.object({
|
1860
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1371
1861
|
})
|
1372
1862
|
);
|
1373
1863
|
var RequestedCorrectionAction = ActionBase.merge(
|
1374
|
-
|
1375
|
-
type:
|
1864
|
+
import_zod18.z.object({
|
1865
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1376
1866
|
})
|
1377
1867
|
);
|
1378
1868
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1379
|
-
|
1380
|
-
type:
|
1381
|
-
requestId:
|
1869
|
+
import_zod18.z.object({
|
1870
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1871
|
+
requestId: import_zod18.z.string()
|
1382
1872
|
})
|
1383
1873
|
);
|
1384
1874
|
var RejectedCorrectionAction = ActionBase.merge(
|
1385
|
-
|
1386
|
-
type:
|
1387
|
-
requestId:
|
1875
|
+
import_zod18.z.object({
|
1876
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1877
|
+
requestId: import_zod18.z.string()
|
1388
1878
|
})
|
1389
1879
|
);
|
1390
1880
|
var ReadAction = ActionBase.merge(
|
1391
|
-
|
1392
|
-
type:
|
1881
|
+
import_zod18.z.object({
|
1882
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1393
1883
|
})
|
1394
1884
|
);
|
1395
|
-
var ActionDocument =
|
1885
|
+
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1396
1886
|
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1397
1887
|
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1398
1888
|
RejectAction.openapi({ ref: "RejectAction" }),
|
@@ -1415,20 +1905,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
|
|
1415
1905
|
declaration: true,
|
1416
1906
|
annotation: true
|
1417
1907
|
}).merge(
|
1418
|
-
|
1419
|
-
type:
|
1420
|
-
status:
|
1908
|
+
import_zod18.z.object({
|
1909
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1910
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1421
1911
|
})
|
1422
1912
|
);
|
1423
|
-
var Action =
|
1424
|
-
var ResolvedUser =
|
1425
|
-
id:
|
1426
|
-
role:
|
1427
|
-
name:
|
1428
|
-
|
1429
|
-
use:
|
1430
|
-
given:
|
1431
|
-
family:
|
1913
|
+
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1914
|
+
var ResolvedUser = import_zod18.z.object({
|
1915
|
+
id: import_zod18.z.string(),
|
1916
|
+
role: import_zod18.z.string(),
|
1917
|
+
name: import_zod18.z.array(
|
1918
|
+
import_zod18.z.object({
|
1919
|
+
use: import_zod18.z.string(),
|
1920
|
+
given: import_zod18.z.array(import_zod18.z.string()),
|
1921
|
+
family: import_zod18.z.string()
|
1432
1922
|
})
|
1433
1923
|
)
|
1434
1924
|
});
|
@@ -1439,7 +1929,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1439
1929
|
var import_date_fns = require("date-fns");
|
1440
1930
|
|
1441
1931
|
// ../commons/src/events/FieldTypeMapping.ts
|
1442
|
-
var
|
1932
|
+
var import_zod19 = require("zod");
|
1443
1933
|
function mapFieldTypeToZod(type, required) {
|
1444
1934
|
let schema;
|
1445
1935
|
switch (type) {
|
@@ -1465,6 +1955,8 @@ function mapFieldTypeToZod(type, required) {
|
|
1465
1955
|
case FieldType.ADMINISTRATIVE_AREA:
|
1466
1956
|
case FieldType.FACILITY:
|
1467
1957
|
case FieldType.OFFICE:
|
1958
|
+
case FieldType.PHONE:
|
1959
|
+
case FieldType.ID:
|
1468
1960
|
schema = required ? NonEmptyTextValue : TextValue;
|
1469
1961
|
break;
|
1470
1962
|
case FieldType.NUMBER:
|
@@ -1486,6 +1978,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1486
1978
|
case FieldType.DATA:
|
1487
1979
|
schema = DataFieldValue;
|
1488
1980
|
break;
|
1981
|
+
case FieldType.NAME:
|
1982
|
+
schema = required ? NameFieldValue : NameFieldUpdateValue;
|
1983
|
+
break;
|
1489
1984
|
}
|
1490
1985
|
return required ? schema : schema.nullish();
|
1491
1986
|
}
|
@@ -1494,59 +1989,7 @@ function createValidationSchema(config) {
|
|
1494
1989
|
for (const field2 of config) {
|
1495
1990
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1496
1991
|
}
|
1497
|
-
return
|
1498
|
-
}
|
1499
|
-
function mapFieldTypeToMockValue(field2, i) {
|
1500
|
-
switch (field2.type) {
|
1501
|
-
case FieldType.DIVIDER:
|
1502
|
-
case FieldType.TEXT:
|
1503
|
-
case FieldType.TEXTAREA:
|
1504
|
-
case FieldType.BULLET_LIST:
|
1505
|
-
case FieldType.PAGE_HEADER:
|
1506
|
-
case FieldType.LOCATION:
|
1507
|
-
case FieldType.SELECT:
|
1508
|
-
case FieldType.COUNTRY:
|
1509
|
-
case FieldType.RADIO_GROUP:
|
1510
|
-
case FieldType.PARAGRAPH:
|
1511
|
-
case FieldType.ADMINISTRATIVE_AREA:
|
1512
|
-
case FieldType.FACILITY:
|
1513
|
-
case FieldType.OFFICE:
|
1514
|
-
return `${field2.id}-${field2.type}-${i}`;
|
1515
|
-
case FieldType.NUMBER:
|
1516
|
-
return 19;
|
1517
|
-
case FieldType.EMAIL:
|
1518
|
-
return "test@opencrvs.org";
|
1519
|
-
case FieldType.ADDRESS:
|
1520
|
-
return {
|
1521
|
-
country: "FAR",
|
1522
|
-
addressType: AddressType.DOMESTIC,
|
1523
|
-
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1524
|
-
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1525
|
-
urbanOrRural: "URBAN",
|
1526
|
-
town: "Example Town",
|
1527
|
-
residentialArea: "Example Residential Area",
|
1528
|
-
street: "Example Street",
|
1529
|
-
number: "55",
|
1530
|
-
zipCode: "123456"
|
1531
|
-
};
|
1532
|
-
case FieldType.DATE:
|
1533
|
-
return "2021-01-01";
|
1534
|
-
case FieldType.DATE_RANGE:
|
1535
|
-
return ["2021-01-01", "2021-01-02"];
|
1536
|
-
case FieldType.CHECKBOX:
|
1537
|
-
return true;
|
1538
|
-
case FieldType.SIGNATURE:
|
1539
|
-
case FieldType.FILE:
|
1540
|
-
return {
|
1541
|
-
filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
|
1542
|
-
originalFilename: "abcd.png",
|
1543
|
-
type: "image/png"
|
1544
|
-
};
|
1545
|
-
case FieldType.FILE_WITH_OPTIONS:
|
1546
|
-
return null;
|
1547
|
-
case FieldType.DATA:
|
1548
|
-
return {};
|
1549
|
-
}
|
1992
|
+
return import_zod19.z.object(shape);
|
1550
1993
|
}
|
1551
1994
|
function mapFieldTypeToEmptyValue(field2) {
|
1552
1995
|
switch (field2.type) {
|
@@ -1569,6 +2012,9 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1569
2012
|
case FieldType.CHECKBOX:
|
1570
2013
|
case FieldType.DATE_RANGE:
|
1571
2014
|
case FieldType.DATA:
|
2015
|
+
case FieldType.NAME:
|
2016
|
+
case FieldType.PHONE:
|
2017
|
+
case FieldType.ID:
|
1572
2018
|
return null;
|
1573
2019
|
case FieldType.ADDRESS:
|
1574
2020
|
return {
|
@@ -1613,7 +2059,16 @@ var isTextFieldType = (field2) => {
|
|
1613
2059
|
var isNumberFieldType = (field2) => {
|
1614
2060
|
return field2.config.type === FieldType.NUMBER;
|
1615
2061
|
};
|
1616
|
-
var
|
2062
|
+
var isNameFieldType = (field2) => {
|
2063
|
+
return field2.config.type === FieldType.NAME;
|
2064
|
+
};
|
2065
|
+
var isPhoneFieldType = (field2) => {
|
2066
|
+
return field2.config.type === FieldType.PHONE;
|
2067
|
+
};
|
2068
|
+
var isIdFieldType = (field2) => {
|
2069
|
+
return field2.config.type === FieldType.ID;
|
2070
|
+
};
|
2071
|
+
var isTextAreaFieldType = (field2) => {
|
1617
2072
|
return field2.config.type === FieldType.TEXTAREA;
|
1618
2073
|
};
|
1619
2074
|
var isSignatureFieldType = (field2) => {
|
@@ -1747,6 +2202,11 @@ var errorMessages = {
|
|
1747
2202
|
defaultMessage: "Invalid input",
|
1748
2203
|
description: "Error message when generic field is invalid",
|
1749
2204
|
id: "v2.error.invalid"
|
2205
|
+
},
|
2206
|
+
unexpectedField: {
|
2207
|
+
defaultMessage: "Unexpected field",
|
2208
|
+
description: "Error message when field is not expected",
|
2209
|
+
id: "v2.error.unexpectedField"
|
1750
2210
|
}
|
1751
2211
|
};
|
1752
2212
|
function createIntlError(message) {
|
@@ -1842,6 +2302,45 @@ function runFieldValidations({
|
|
1842
2302
|
errors: [...fieldValidationResult, ...customValidationResults]
|
1843
2303
|
};
|
1844
2304
|
}
|
2305
|
+
function getValidatorsForField(fieldId, validations) {
|
2306
|
+
return validations.map(({ validator, message }) => {
|
2307
|
+
const jsonSchema = validator;
|
2308
|
+
const $form = jsonSchema.properties.$form;
|
2309
|
+
if ($form.properties?.[fieldId]?.type === "object") {
|
2310
|
+
return {
|
2311
|
+
message,
|
2312
|
+
validator: {
|
2313
|
+
...jsonSchema,
|
2314
|
+
properties: {
|
2315
|
+
$form: {
|
2316
|
+
type: "object",
|
2317
|
+
properties: $form.properties?.[fieldId]?.properties || {},
|
2318
|
+
required: $form.properties?.[fieldId]?.required || []
|
2319
|
+
}
|
2320
|
+
}
|
2321
|
+
}
|
2322
|
+
};
|
2323
|
+
}
|
2324
|
+
if (!$form.properties?.[fieldId]) {
|
2325
|
+
return null;
|
2326
|
+
}
|
2327
|
+
return {
|
2328
|
+
message,
|
2329
|
+
validator: {
|
2330
|
+
...jsonSchema,
|
2331
|
+
properties: {
|
2332
|
+
$form: {
|
2333
|
+
type: "object",
|
2334
|
+
properties: {
|
2335
|
+
[fieldId]: $form.properties?.[fieldId]
|
2336
|
+
},
|
2337
|
+
required: $form.required?.includes(fieldId) ? [fieldId] : []
|
2338
|
+
}
|
2339
|
+
}
|
2340
|
+
}
|
2341
|
+
};
|
2342
|
+
}).filter((x) => x !== null);
|
2343
|
+
}
|
1845
2344
|
|
1846
2345
|
// ../commons/src/uuid.ts
|
1847
2346
|
var import_uuid = require("uuid");
|
@@ -1888,6 +2387,13 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1888
2387
|
function getAllAnnotationFields(config) {
|
1889
2388
|
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1890
2389
|
}
|
2390
|
+
function getAllUniqueFields(eventConfig) {
|
2391
|
+
return (0, import_lodash.uniqBy)(getDeclarationFields(eventConfig), (field2) => field2.id);
|
2392
|
+
}
|
2393
|
+
function getDeclarationFieldById(config, fieldId) {
|
2394
|
+
const field2 = getAllUniqueFields(config).find((f) => f.id === fieldId);
|
2395
|
+
return getOrThrow(field2, `Field with id ${fieldId} not found in event config`);
|
2396
|
+
}
|
1891
2397
|
var findRecordActionPages = (config, actionType) => {
|
1892
2398
|
const action = config.actions.find((a) => a.type === actionType);
|
1893
2399
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1948,6 +2454,7 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1948
2454
|
declaration: {},
|
1949
2455
|
annotation: {},
|
1950
2456
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2457
|
+
createdByUserType: TokenUserType.Enum.user,
|
1951
2458
|
createdBy: "@todo",
|
1952
2459
|
createdAtLocation: "@todo",
|
1953
2460
|
status: ActionStatus.Accepted,
|
@@ -1993,8 +2500,9 @@ function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
|
1993
2500
|
);
|
1994
2501
|
}
|
1995
2502
|
function deepMerge(currentDocument, actionDocument) {
|
2503
|
+
const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
|
1996
2504
|
return (0, import_lodash.mergeWith)(
|
1997
|
-
|
2505
|
+
(0, import_lodash.cloneDeep)(currentDocumentClone),
|
1998
2506
|
actionDocument,
|
1999
2507
|
(previousValue, incomingValue) => {
|
2000
2508
|
if (incomingValue === void 0) {
|
@@ -2042,12 +2550,18 @@ function getMixedPath(obj, path, defaultValue) {
|
|
2042
2550
|
const result = resolve(obj, parts);
|
2043
2551
|
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
2044
2552
|
}
|
2553
|
+
function getEventConfigById(eventConfigs, id) {
|
2554
|
+
const eventConfig = eventConfigs.find(
|
2555
|
+
(eventConfiguration) => eventConfiguration.id === id
|
2556
|
+
);
|
2557
|
+
return getOrThrow(eventConfig, `Event config for ${id} not found`);
|
2558
|
+
}
|
2045
2559
|
|
2046
2560
|
// ../commons/src/events/EventConfig.ts
|
2047
2561
|
var import_zod_openapi8 = require("zod-openapi");
|
2048
|
-
(0, import_zod_openapi8.extendZodWithOpenApi)(
|
2049
|
-
var EventConfig =
|
2050
|
-
id:
|
2562
|
+
(0, import_zod_openapi8.extendZodWithOpenApi)(import_zod20.z);
|
2563
|
+
var EventConfig = import_zod20.z.object({
|
2564
|
+
id: import_zod20.z.string().describe(
|
2051
2565
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
2052
2566
|
),
|
2053
2567
|
dateOfEvent: FieldReference.optional(),
|
@@ -2057,10 +2571,10 @@ var EventConfig = import_zod18.z.object({
|
|
2057
2571
|
),
|
2058
2572
|
summary: SummaryConfig,
|
2059
2573
|
label: TranslationConfig,
|
2060
|
-
actions:
|
2574
|
+
actions: import_zod20.z.array(ActionConfig),
|
2061
2575
|
declaration: DeclarationFormConfig,
|
2062
|
-
deduplication:
|
2063
|
-
advancedSearch:
|
2576
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
2577
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
2064
2578
|
}).superRefine((event2, ctx) => {
|
2065
2579
|
const allFields = findAllFields(event2);
|
2066
2580
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -2122,12 +2636,12 @@ var definePage = (page) => PageConfig.parse(page);
|
|
2122
2636
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
2123
2637
|
|
2124
2638
|
// ../commons/src/events/WorkqueueConfig.ts
|
2125
|
-
var
|
2639
|
+
var import_zod27 = require("zod");
|
2126
2640
|
|
2127
2641
|
// ../commons/src/events/serializers/user/serializer.ts
|
2128
|
-
var
|
2129
|
-
var SerializedUserField =
|
2130
|
-
$userField:
|
2642
|
+
var import_zod21 = require("zod");
|
2643
|
+
var SerializedUserField = import_zod21.z.object({
|
2644
|
+
$userField: import_zod21.z.enum([
|
2131
2645
|
"id",
|
2132
2646
|
"name",
|
2133
2647
|
"role",
|
@@ -2328,7 +2842,7 @@ function createFieldConditionals(fieldId) {
|
|
2328
2842
|
properties: {
|
2329
2843
|
[fieldId]: {
|
2330
2844
|
type: ["string", "boolean"],
|
2331
|
-
const: { $data:
|
2845
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
2332
2846
|
},
|
2333
2847
|
[comparedFieldId]: { type: ["string", "boolean"] }
|
2334
2848
|
},
|
@@ -2438,6 +2952,23 @@ function createFieldConditionals(fieldId) {
|
|
2438
2952
|
}
|
2439
2953
|
},
|
2440
2954
|
required: [fieldId]
|
2955
|
+
}),
|
2956
|
+
getId: () => ({ fieldId }),
|
2957
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2958
|
+
object: (options) => defineFormConditional({
|
2959
|
+
type: "object",
|
2960
|
+
properties: {
|
2961
|
+
[fieldId]: {
|
2962
|
+
type: "object",
|
2963
|
+
properties: Object.fromEntries(
|
2964
|
+
Object.entries(options).map(([key, value]) => {
|
2965
|
+
return [key, value.properties.$form.properties[key]];
|
2966
|
+
})
|
2967
|
+
),
|
2968
|
+
required: Object.keys(options)
|
2969
|
+
}
|
2970
|
+
},
|
2971
|
+
required: [fieldId]
|
2441
2972
|
})
|
2442
2973
|
};
|
2443
2974
|
}
|
@@ -2513,87 +3044,78 @@ var event = Object.assign(eventFn, {
|
|
2513
3044
|
});
|
2514
3045
|
|
2515
3046
|
// ../commons/src/events/WorkqueueColumnConfig.ts
|
2516
|
-
var
|
3047
|
+
var import_zod23 = require("zod");
|
2517
3048
|
|
2518
3049
|
// ../commons/src/events/EventMetadata.ts
|
2519
|
-
var
|
2520
|
-
var EventStatus =
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
var eventStatusValues = [
|
2531
|
-
EventStatus.CREATED,
|
2532
|
-
EventStatus.NOTIFIED,
|
2533
|
-
EventStatus.DECLARED,
|
2534
|
-
EventStatus.VALIDATED,
|
2535
|
-
EventStatus.REGISTERED,
|
2536
|
-
EventStatus.CERTIFIED,
|
2537
|
-
EventStatus.REJECTED,
|
2538
|
-
EventStatus.ARCHIVED
|
2539
|
-
];
|
2540
|
-
var EventStatusEnum = import_zod20.z.enum(eventStatusValues);
|
3050
|
+
var import_zod22 = require("zod");
|
3051
|
+
var EventStatus = import_zod22.z.enum([
|
3052
|
+
"CREATED",
|
3053
|
+
"NOTIFIED",
|
3054
|
+
"DECLARED",
|
3055
|
+
"VALIDATED",
|
3056
|
+
"REGISTERED",
|
3057
|
+
"CERTIFIED",
|
3058
|
+
"REJECTED",
|
3059
|
+
"ARCHIVED"
|
3060
|
+
]);
|
2541
3061
|
var CustomFlags = {
|
2542
3062
|
CERTIFICATE_PRINTED: "certificate-printed"
|
2543
3063
|
};
|
2544
|
-
var Flag =
|
3064
|
+
var Flag = import_zod22.z.string().regex(
|
2545
3065
|
new RegExp(
|
2546
3066
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
2547
3067
|
ActionStatus
|
2548
3068
|
).join("|").toLowerCase()})$`
|
2549
3069
|
),
|
2550
3070
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2551
|
-
).or(
|
2552
|
-
var
|
2553
|
-
var
|
2554
|
-
|
2555
|
-
|
2556
|
-
createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
|
2557
|
-
createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
|
3071
|
+
).or(import_zod22.z.nativeEnum(CustomFlags));
|
3072
|
+
var ZodDate = import_zod22.z.string().date();
|
3073
|
+
var ActionCreationMetadata = import_zod22.z.object({
|
3074
|
+
createdAt: import_zod22.z.string().datetime().describe("The timestamp when the action request was created."),
|
3075
|
+
createdBy: import_zod22.z.string().describe("ID of the user who created the action request."),
|
2558
3076
|
createdAtLocation: CreatedAtLocation.describe(
|
2559
3077
|
"Location of the user who created the action request."
|
2560
3078
|
),
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
3079
|
+
createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
|
3080
|
+
acceptedAt: import_zod22.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
3081
|
+
createdByRole: import_zod22.z.string().describe("Role of the user at the time of action request creation."),
|
3082
|
+
createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the action request.")
|
2564
3083
|
});
|
2565
3084
|
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2566
|
-
registrationNumber:
|
3085
|
+
registrationNumber: import_zod22.z.string().describe(
|
2567
3086
|
"Registration number of the event. Always present for accepted registrations."
|
2568
3087
|
)
|
2569
3088
|
});
|
2570
|
-
var LegalStatuses =
|
2571
|
-
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2572
|
-
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
3089
|
+
var LegalStatuses = import_zod22.z.object({
|
3090
|
+
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
3091
|
+
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2573
3092
|
});
|
2574
|
-
var EventMetadata =
|
2575
|
-
id:
|
2576
|
-
type:
|
2577
|
-
status:
|
3093
|
+
var EventMetadata = import_zod22.z.object({
|
3094
|
+
id: import_zod22.z.string(),
|
3095
|
+
type: import_zod22.z.string().describe("The type of event, such as birth, death, or marriage."),
|
3096
|
+
status: EventStatus,
|
2578
3097
|
legalStatuses: LegalStatuses.describe(
|
2579
3098
|
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2580
3099
|
),
|
2581
|
-
createdAt:
|
3100
|
+
createdAt: import_zod22.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2582
3101
|
dateOfEvent: ZodDate.nullish(),
|
2583
|
-
createdBy:
|
2584
|
-
|
3102
|
+
createdBy: import_zod22.z.string().describe("ID of the user who created the event."),
|
3103
|
+
createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
|
3104
|
+
updatedByUserRole: import_zod22.z.string().describe("Role of the user who last changed the status."),
|
2585
3105
|
createdAtLocation: CreatedAtLocation.describe(
|
2586
3106
|
"Location of the user who created the event."
|
2587
3107
|
),
|
2588
|
-
createdBySignature:
|
2589
|
-
updatedAtLocation:
|
2590
|
-
updatedAt:
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
3108
|
+
createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the event."),
|
3109
|
+
updatedAtLocation: import_zod22.z.string().nullish().describe("Location of the user who last changed the status."),
|
3110
|
+
updatedAt: import_zod22.z.string().datetime().describe(
|
3111
|
+
"Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
|
3112
|
+
),
|
3113
|
+
assignedTo: import_zod22.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
3114
|
+
updatedBy: import_zod22.z.string().nullish().describe("ID of the user who last changed the status."),
|
3115
|
+
trackingId: import_zod22.z.string().describe(
|
2594
3116
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
2595
3117
|
),
|
2596
|
-
flags:
|
3118
|
+
flags: import_zod22.z.array(Flag)
|
2597
3119
|
});
|
2598
3120
|
var EventMetadataKeysArray = [
|
2599
3121
|
"id",
|
@@ -2602,6 +3124,7 @@ var EventMetadataKeysArray = [
|
|
2602
3124
|
"createdAt",
|
2603
3125
|
"dateOfEvent",
|
2604
3126
|
"createdBy",
|
3127
|
+
"createdByUserType",
|
2605
3128
|
"updatedByUserRole",
|
2606
3129
|
"createdAtLocation",
|
2607
3130
|
"updatedAtLocation",
|
@@ -2612,7 +3135,7 @@ var EventMetadataKeysArray = [
|
|
2612
3135
|
"legalStatuses",
|
2613
3136
|
"flags"
|
2614
3137
|
];
|
2615
|
-
var EventMetadataKeys =
|
3138
|
+
var EventMetadataKeys = import_zod22.z.enum(EventMetadataKeysArray);
|
2616
3139
|
var eventMetadataLabelMap = {
|
2617
3140
|
"event.assignedTo": {
|
2618
3141
|
id: "event.assignedTo.label",
|
@@ -2624,6 +3147,11 @@ var eventMetadataLabelMap = {
|
|
2624
3147
|
defaultMessage: "Created",
|
2625
3148
|
description: "Created At"
|
2626
3149
|
},
|
3150
|
+
"event.createdByUserType": {
|
3151
|
+
id: "event.createdByUserType.label",
|
3152
|
+
defaultMessage: "createdByUserType",
|
3153
|
+
description: "createdByUserType:user or system"
|
3154
|
+
},
|
2627
3155
|
"event.dateOfEvent": {
|
2628
3156
|
id: "event.dateOfEvent.label",
|
2629
3157
|
defaultMessage: "Date of Event",
|
@@ -2689,13 +3217,14 @@ var eventMetadataLabelMap = {
|
|
2689
3217
|
// ../commons/src/events/WorkqueueColumnConfig.ts
|
2690
3218
|
var WorkqueueColumnKeysArray = [
|
2691
3219
|
...EventMetadataKeysArray,
|
2692
|
-
"title"
|
3220
|
+
"title",
|
3221
|
+
"outbox"
|
2693
3222
|
];
|
2694
|
-
var WorkqueueColumnKeys =
|
2695
|
-
var WorkqueueColumnValue =
|
3223
|
+
var WorkqueueColumnKeys = import_zod23.z.enum(WorkqueueColumnKeysArray);
|
3224
|
+
var WorkqueueColumnValue = import_zod23.z.object({
|
2696
3225
|
$event: WorkqueueColumnKeys
|
2697
3226
|
});
|
2698
|
-
var WorkqueueColumn =
|
3227
|
+
var WorkqueueColumn = import_zod23.z.object({
|
2699
3228
|
label: TranslationConfig,
|
2700
3229
|
value: WorkqueueColumnValue
|
2701
3230
|
});
|
@@ -2706,96 +3235,112 @@ function defineWorkqueuesColumns(workqueueColumns) {
|
|
2706
3235
|
}
|
2707
3236
|
|
2708
3237
|
// ../commons/src/events/CountryConfigQueryInput.ts
|
2709
|
-
var
|
3238
|
+
var import_zod25 = require("zod");
|
2710
3239
|
|
2711
3240
|
// ../commons/src/events/EventIndex.ts
|
2712
|
-
var
|
3241
|
+
var import_zod24 = require("zod");
|
2713
3242
|
var import_zod_openapi9 = require("zod-openapi");
|
2714
|
-
(0, import_zod_openapi9.extendZodWithOpenApi)(
|
3243
|
+
(0, import_zod_openapi9.extendZodWithOpenApi)(import_zod24.z);
|
2715
3244
|
var EventIndex = EventMetadata.extend({
|
2716
3245
|
declaration: EventState
|
2717
3246
|
}).openapi({
|
2718
3247
|
ref: "EventIndex"
|
2719
3248
|
});
|
2720
|
-
var EventSearchIndex =
|
2721
|
-
|
2722
|
-
type:
|
3249
|
+
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
3250
|
+
import_zod24.z.object({
|
3251
|
+
type: import_zod24.z.string()
|
2723
3252
|
// Ensures "type" (event-id) exists and is a string
|
2724
3253
|
})
|
2725
3254
|
).openapi({
|
2726
3255
|
ref: "EventSearchIndex"
|
2727
3256
|
});
|
2728
|
-
var Fuzzy =
|
3257
|
+
var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() }).openapi({
|
2729
3258
|
ref: "Fuzzy"
|
2730
3259
|
});
|
2731
|
-
var Exact =
|
3260
|
+
var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() }).openapi({
|
2732
3261
|
ref: "Exact"
|
2733
3262
|
});
|
2734
|
-
var
|
2735
|
-
type:
|
2736
|
-
|
3263
|
+
var ExactStatus = import_zod24.z.object({
|
3264
|
+
type: import_zod24.z.literal("exact"),
|
3265
|
+
term: EventStatus
|
2737
3266
|
}).openapi({
|
2738
|
-
ref: "
|
3267
|
+
ref: "ExactStatus"
|
2739
3268
|
});
|
2740
|
-
var
|
2741
|
-
type:
|
2742
|
-
|
3269
|
+
var AnyOf = import_zod24.z.object({
|
3270
|
+
type: import_zod24.z.literal("anyOf"),
|
3271
|
+
terms: import_zod24.z.array(import_zod24.z.string())
|
2743
3272
|
}).openapi({
|
2744
|
-
ref: "
|
3273
|
+
ref: "AnyOf"
|
2745
3274
|
});
|
2746
|
-
var AnyOfStatus =
|
2747
|
-
type:
|
2748
|
-
terms:
|
3275
|
+
var AnyOfStatus = import_zod24.z.object({
|
3276
|
+
type: import_zod24.z.literal("anyOf"),
|
3277
|
+
terms: import_zod24.z.array(EventStatus)
|
2749
3278
|
}).openapi({
|
2750
3279
|
ref: "AnyOfStatus"
|
2751
3280
|
});
|
2752
|
-
var Range =
|
2753
|
-
type:
|
2754
|
-
gte:
|
2755
|
-
lte:
|
3281
|
+
var Range = import_zod24.z.object({
|
3282
|
+
type: import_zod24.z.literal("range"),
|
3283
|
+
gte: import_zod24.z.string(),
|
3284
|
+
lte: import_zod24.z.string()
|
2756
3285
|
}).openapi({
|
2757
3286
|
ref: "Range"
|
2758
3287
|
});
|
2759
|
-
var Not =
|
3288
|
+
var Not = import_zod24.z.object({ type: import_zod24.z.literal("not"), term: import_zod24.z.string() }).openapi({
|
2760
3289
|
ref: "Not"
|
2761
3290
|
});
|
2762
|
-
var Within =
|
3291
|
+
var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() }).openapi({
|
2763
3292
|
ref: "Within"
|
2764
3293
|
});
|
2765
|
-
var
|
3294
|
+
var RangeDate = Range.extend({
|
3295
|
+
gte: import_zod24.z.string().date().or(import_zod24.z.string().datetime()),
|
3296
|
+
lte: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
|
3297
|
+
}).openapi({
|
3298
|
+
ref: "RangeDate"
|
3299
|
+
});
|
3300
|
+
var ExactDate = Exact.extend({
|
3301
|
+
term: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
|
3302
|
+
}).openapi({
|
3303
|
+
ref: "ExactDate"
|
3304
|
+
});
|
3305
|
+
var DateCondition = import_zod24.z.union([ExactDate, RangeDate]).openapi({
|
2766
3306
|
ref: "DateCondition"
|
2767
3307
|
});
|
2768
|
-
var QueryInput =
|
2769
|
-
() =>
|
2770
|
-
|
2771
|
-
|
3308
|
+
var QueryInput = import_zod24.z.lazy(
|
3309
|
+
() => import_zod24.z.union([
|
3310
|
+
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
3311
|
+
import_zod24.z.record(import_zod24.z.string(), QueryInput)
|
2772
3312
|
])
|
2773
3313
|
).openapi({
|
2774
3314
|
ref: "QueryInput"
|
2775
3315
|
});
|
2776
|
-
var QueryExpression =
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
"legalStatus.REGISTERED.
|
2783
|
-
|
3316
|
+
var QueryExpression = import_zod24.z.object({
|
3317
|
+
id: import_zod24.z.optional(import_zod24.z.string()),
|
3318
|
+
eventType: import_zod24.z.string(),
|
3319
|
+
status: import_zod24.z.optional(import_zod24.z.union([AnyOfStatus, ExactStatus])),
|
3320
|
+
createdAt: import_zod24.z.optional(DateCondition),
|
3321
|
+
updatedAt: import_zod24.z.optional(DateCondition),
|
3322
|
+
"legalStatus.REGISTERED.createdAt": import_zod24.z.optional(DateCondition),
|
3323
|
+
"legalStatus.REGISTERED.createdAtLocation": import_zod24.z.optional(
|
3324
|
+
import_zod24.z.union([Within, Exact])
|
2784
3325
|
),
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
3326
|
+
"legalStatus.REGISTERED.registrationNumber": import_zod24.z.optional(Exact),
|
3327
|
+
createdAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
3328
|
+
updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
3329
|
+
assignedTo: import_zod24.z.optional(Exact),
|
3330
|
+
createdByUserType: TokenUserType,
|
3331
|
+
createdBy: import_zod24.z.optional(Exact),
|
3332
|
+
updatedBy: import_zod24.z.optional(Exact),
|
3333
|
+
trackingId: import_zod24.z.optional(Exact),
|
3334
|
+
flags: import_zod24.z.optional(import_zod24.z.array(import_zod24.z.union([AnyOf, Not]))),
|
2792
3335
|
data: QueryInput
|
2793
|
-
}).partial().
|
3336
|
+
}).partial().refine((obj) => Object.values(obj).some((val) => val !== void 0), {
|
3337
|
+
message: "At least one query field must be specified."
|
3338
|
+
}).openapi({
|
2794
3339
|
ref: "QueryExpression"
|
2795
3340
|
});
|
2796
|
-
var QueryType =
|
2797
|
-
type:
|
2798
|
-
clauses:
|
3341
|
+
var QueryType = import_zod24.z.object({
|
3342
|
+
type: import_zod24.z.literal("and").or(import_zod24.z.literal("or")).openapi({ default: "and" }),
|
3343
|
+
clauses: import_zod24.z.preprocess(
|
2799
3344
|
(val) => {
|
2800
3345
|
if (typeof val === "string") {
|
2801
3346
|
return [JSON.parse(val)];
|
@@ -2805,22 +3350,13 @@ var QueryType = import_zod22.z.object({
|
|
2805
3350
|
}
|
2806
3351
|
return val;
|
2807
3352
|
},
|
2808
|
-
|
3353
|
+
import_zod24.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
|
2809
3354
|
default: [
|
2810
3355
|
{
|
2811
3356
|
eventType: TENNIS_CLUB_MEMBERSHIP,
|
2812
3357
|
status: {
|
2813
3358
|
type: "anyOf",
|
2814
|
-
terms:
|
2815
|
-
"CREATED",
|
2816
|
-
"NOTIFIED",
|
2817
|
-
"DECLARED",
|
2818
|
-
"VALIDATED",
|
2819
|
-
"REGISTERED",
|
2820
|
-
"CERTIFIED",
|
2821
|
-
"REJECTED",
|
2822
|
-
"ARCHIVED"
|
2823
|
-
]
|
3359
|
+
terms: EventStatus.options
|
2824
3360
|
},
|
2825
3361
|
updatedAt: {
|
2826
3362
|
type: "range",
|
@@ -2837,50 +3373,51 @@ var QueryType = import_zod22.z.object({
|
|
2837
3373
|
});
|
2838
3374
|
|
2839
3375
|
// ../commons/src/events/CountryConfigQueryInput.ts
|
2840
|
-
var SerializableExact =
|
2841
|
-
type:
|
2842
|
-
term:
|
3376
|
+
var SerializableExact = import_zod25.z.object({
|
3377
|
+
type: import_zod25.z.literal("exact"),
|
3378
|
+
term: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
|
2843
3379
|
});
|
2844
|
-
var SerializableWithin =
|
2845
|
-
type:
|
2846
|
-
location:
|
3380
|
+
var SerializableWithin = import_zod25.z.object({
|
3381
|
+
type: import_zod25.z.literal("within"),
|
3382
|
+
location: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
|
2847
3383
|
});
|
2848
|
-
var SerializedQueryExpression =
|
2849
|
-
eventType:
|
2850
|
-
status:
|
2851
|
-
createdAt:
|
2852
|
-
updatedAt:
|
2853
|
-
createdAtLocation:
|
2854
|
-
|
3384
|
+
var SerializedQueryExpression = import_zod25.z.object({
|
3385
|
+
eventType: import_zod25.z.string(),
|
3386
|
+
status: import_zod25.z.optional(import_zod25.z.union([AnyOfStatus, ExactStatus])),
|
3387
|
+
createdAt: import_zod25.z.optional(DateCondition),
|
3388
|
+
updatedAt: import_zod25.z.optional(DateCondition),
|
3389
|
+
createdAtLocation: import_zod25.z.optional(
|
3390
|
+
import_zod25.z.union([SerializableWithin, SerializableExact])
|
2855
3391
|
),
|
2856
|
-
updatedAtLocation:
|
2857
|
-
|
3392
|
+
updatedAtLocation: import_zod25.z.optional(
|
3393
|
+
import_zod25.z.union([SerializableWithin, SerializableExact])
|
2858
3394
|
),
|
2859
|
-
assignedTo:
|
2860
|
-
createdBy:
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
3395
|
+
assignedTo: import_zod25.z.optional(SerializableExact),
|
3396
|
+
createdBy: import_zod25.z.optional(SerializableExact),
|
3397
|
+
createdByUserType: TokenUserType,
|
3398
|
+
updatedBy: import_zod25.z.optional(SerializableExact),
|
3399
|
+
trackingId: import_zod25.z.optional(Exact),
|
3400
|
+
flags: import_zod25.z.optional(import_zod25.z.array(import_zod25.z.union([AnyOf, Not]))),
|
2864
3401
|
data: QueryInput
|
2865
3402
|
}).partial();
|
2866
|
-
var Or2 =
|
2867
|
-
type:
|
2868
|
-
clauses:
|
3403
|
+
var Or2 = import_zod25.z.object({
|
3404
|
+
type: import_zod25.z.literal("or"),
|
3405
|
+
clauses: import_zod25.z.array(SerializedQueryExpression)
|
2869
3406
|
});
|
2870
|
-
var And2 =
|
2871
|
-
type:
|
2872
|
-
clauses:
|
3407
|
+
var And2 = import_zod25.z.object({
|
3408
|
+
type: import_zod25.z.literal("and"),
|
3409
|
+
clauses: import_zod25.z.array(SerializedQueryExpression)
|
2873
3410
|
});
|
2874
|
-
var CountryConfigQueryType =
|
2875
|
-
var CountryConfigQueryInputType =
|
3411
|
+
var CountryConfigQueryType = import_zod25.z.discriminatedUnion("type", [And2, Or2]);
|
3412
|
+
var CountryConfigQueryInputType = import_zod25.z.union([
|
2876
3413
|
SerializedQueryExpression,
|
2877
3414
|
And2,
|
2878
3415
|
Or2
|
2879
3416
|
]);
|
2880
3417
|
|
2881
3418
|
// ../commons/src/icons.ts
|
2882
|
-
var
|
2883
|
-
var AvailableIcons =
|
3419
|
+
var import_zod26 = require("zod");
|
3420
|
+
var AvailableIcons = import_zod26.z.enum([
|
2884
3421
|
"Archived",
|
2885
3422
|
"Assigned",
|
2886
3423
|
"Certified",
|
@@ -2984,7 +3521,7 @@ var AvailableIcons = import_zod24.z.enum([
|
|
2984
3521
|
]);
|
2985
3522
|
|
2986
3523
|
// ../commons/src/events/WorkqueueConfig.ts
|
2987
|
-
var
|
3524
|
+
var mandatoryColumns = defineWorkqueuesColumns([
|
2988
3525
|
{
|
2989
3526
|
label: {
|
2990
3527
|
id: "workqueues.dateOfEvent",
|
@@ -3002,38 +3539,42 @@ var dateOfEventColumn = defineWorkqueuesColumns([
|
|
3002
3539
|
value: event.field("updatedAt")
|
3003
3540
|
}
|
3004
3541
|
]);
|
3005
|
-
var WorkqueueActionsWithDefault =
|
3542
|
+
var WorkqueueActionsWithDefault = import_zod27.z.enum([
|
3006
3543
|
...workqueueActions.options,
|
3007
3544
|
"DEFAULT"
|
3008
3545
|
]);
|
3009
|
-
var WorkqueueConfig =
|
3010
|
-
slug:
|
3546
|
+
var WorkqueueConfig = import_zod27.z.object({
|
3547
|
+
slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
|
3011
3548
|
name: TranslationConfig.describe(
|
3012
3549
|
"Title of the workflow (both in navigation and on the page)"
|
3013
3550
|
),
|
3014
3551
|
query: CountryConfigQueryType,
|
3015
|
-
actions:
|
3016
|
-
|
3552
|
+
actions: import_zod27.z.array(
|
3553
|
+
import_zod27.z.object({
|
3017
3554
|
type: WorkqueueActionsWithDefault,
|
3018
|
-
conditionals:
|
3555
|
+
conditionals: import_zod27.z.array(Conditional).optional()
|
3019
3556
|
})
|
3020
3557
|
),
|
3021
|
-
columns:
|
3558
|
+
columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3022
3559
|
icon: AvailableIcons
|
3023
3560
|
}).describe("Configuration for workqueue.");
|
3024
|
-
var
|
3025
|
-
|
3561
|
+
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3562
|
+
query: true,
|
3563
|
+
columns: true
|
3564
|
+
});
|
3565
|
+
var WorkqueueConfigInput = import_zod27.z.object({
|
3566
|
+
slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
|
3026
3567
|
name: TranslationConfig.describe(
|
3027
3568
|
"Title of the workflow (both in navigation and on the page)"
|
3028
3569
|
),
|
3029
3570
|
query: CountryConfigQueryInputType,
|
3030
|
-
actions:
|
3031
|
-
|
3571
|
+
actions: import_zod27.z.array(
|
3572
|
+
import_zod27.z.object({
|
3032
3573
|
type: WorkqueueActionsWithDefault,
|
3033
|
-
conditionals:
|
3574
|
+
conditionals: import_zod27.z.array(Conditional).optional()
|
3034
3575
|
})
|
3035
3576
|
),
|
3036
|
-
columns:
|
3577
|
+
columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3037
3578
|
icon: AvailableIcons
|
3038
3579
|
});
|
3039
3580
|
function defineWorkqueue(workqueueInput) {
|
@@ -3044,10 +3585,10 @@ function defineWorkqueue(workqueueInput) {
|
|
3044
3585
|
function defineWorkqueues(workqueues) {
|
3045
3586
|
return workqueues.map((workqueue) => defineWorkqueue(workqueue));
|
3046
3587
|
}
|
3047
|
-
var WorkqueueCountInput =
|
3048
|
-
|
3588
|
+
var WorkqueueCountInput = import_zod27.z.array(
|
3589
|
+
import_zod27.z.object({ slug: import_zod27.z.string(), query: QueryType })
|
3049
3590
|
);
|
3050
|
-
var WorkqueueCountOutput =
|
3591
|
+
var WorkqueueCountOutput = import_zod27.z.record(import_zod27.z.string(), import_zod27.z.number());
|
3051
3592
|
|
3052
3593
|
// ../commons/src/events/workqueueDefaultColumns.ts
|
3053
3594
|
var defaultWorkqueueColumns = [
|
@@ -3070,42 +3611,42 @@ var defaultWorkqueueColumns = [
|
|
3070
3611
|
];
|
3071
3612
|
|
3072
3613
|
// ../commons/src/events/Draft.ts
|
3073
|
-
var
|
3614
|
+
var import_zod29 = require("zod");
|
3074
3615
|
|
3075
3616
|
// ../commons/src/events/ActionInput.ts
|
3076
|
-
var
|
3617
|
+
var import_zod28 = require("zod");
|
3077
3618
|
var import_zod_openapi10 = require("zod-openapi");
|
3078
3619
|
var import_uuid3 = require("uuid");
|
3079
|
-
(0, import_zod_openapi10.extendZodWithOpenApi)(
|
3080
|
-
var BaseActionInput =
|
3081
|
-
eventId:
|
3082
|
-
transactionId:
|
3620
|
+
(0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
|
3621
|
+
var BaseActionInput = import_zod28.z.object({
|
3622
|
+
eventId: import_zod28.z.string(),
|
3623
|
+
transactionId: import_zod28.z.string(),
|
3083
3624
|
declaration: ActionUpdate.default({}),
|
3084
3625
|
annotation: ActionUpdate.optional(),
|
3085
|
-
originalActionId:
|
3086
|
-
keepAssignment:
|
3626
|
+
originalActionId: import_zod28.z.string().optional(),
|
3627
|
+
keepAssignment: import_zod28.z.boolean().optional()
|
3087
3628
|
});
|
3088
3629
|
var CreateActionInput = BaseActionInput.merge(
|
3089
|
-
|
3090
|
-
type:
|
3630
|
+
import_zod28.z.object({
|
3631
|
+
type: import_zod28.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
3091
3632
|
createdAtLocation: CreatedAtLocation
|
3092
3633
|
})
|
3093
3634
|
);
|
3094
3635
|
var RegisterActionInput = BaseActionInput.merge(
|
3095
|
-
|
3096
|
-
type:
|
3097
|
-
registrationNumber:
|
3636
|
+
import_zod28.z.object({
|
3637
|
+
type: import_zod28.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
3638
|
+
registrationNumber: import_zod28.z.string().optional()
|
3098
3639
|
})
|
3099
3640
|
);
|
3100
3641
|
var ValidateActionInput = BaseActionInput.merge(
|
3101
|
-
|
3102
|
-
type:
|
3103
|
-
duplicates:
|
3642
|
+
import_zod28.z.object({
|
3643
|
+
type: import_zod28.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
3644
|
+
duplicates: import_zod28.z.array(import_zod28.z.string())
|
3104
3645
|
})
|
3105
3646
|
);
|
3106
3647
|
var NotifyActionInput = BaseActionInput.merge(
|
3107
|
-
|
3108
|
-
type:
|
3648
|
+
import_zod28.z.object({
|
3649
|
+
type: import_zod28.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
3109
3650
|
})
|
3110
3651
|
).openapi({
|
3111
3652
|
default: {
|
@@ -3117,68 +3658,68 @@ var NotifyActionInput = BaseActionInput.merge(
|
|
3117
3658
|
}
|
3118
3659
|
});
|
3119
3660
|
var DeclareActionInput = BaseActionInput.merge(
|
3120
|
-
|
3121
|
-
type:
|
3661
|
+
import_zod28.z.object({
|
3662
|
+
type: import_zod28.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
3122
3663
|
})
|
3123
3664
|
);
|
3124
3665
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
3125
|
-
|
3126
|
-
type:
|
3666
|
+
import_zod28.z.object({
|
3667
|
+
type: import_zod28.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
3127
3668
|
})
|
3128
3669
|
);
|
3129
3670
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
3130
|
-
|
3131
|
-
type:
|
3671
|
+
import_zod28.z.object({
|
3672
|
+
type: import_zod28.z.literal(ActionType.REJECT).default(ActionType.REJECT),
|
3132
3673
|
reason: RejectionReason
|
3133
3674
|
})
|
3134
3675
|
);
|
3135
3676
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
3136
|
-
|
3137
|
-
type:
|
3677
|
+
import_zod28.z.object({
|
3678
|
+
type: import_zod28.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
3138
3679
|
})
|
3139
3680
|
);
|
3140
3681
|
var ArchiveActionInput = BaseActionInput.merge(
|
3141
|
-
|
3142
|
-
type:
|
3682
|
+
import_zod28.z.object({
|
3683
|
+
type: import_zod28.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
|
3143
3684
|
reason: RejectionReason
|
3144
3685
|
})
|
3145
3686
|
);
|
3146
3687
|
var AssignActionInput = BaseActionInput.merge(
|
3147
|
-
|
3148
|
-
type:
|
3149
|
-
assignedTo:
|
3688
|
+
import_zod28.z.object({
|
3689
|
+
type: import_zod28.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
3690
|
+
assignedTo: import_zod28.z.string()
|
3150
3691
|
})
|
3151
3692
|
);
|
3152
3693
|
var UnassignActionInput = BaseActionInput.merge(
|
3153
|
-
|
3154
|
-
type:
|
3155
|
-
assignedTo:
|
3694
|
+
import_zod28.z.object({
|
3695
|
+
type: import_zod28.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
3696
|
+
assignedTo: import_zod28.z.literal(null).default(null)
|
3156
3697
|
})
|
3157
3698
|
);
|
3158
3699
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
3159
|
-
|
3160
|
-
type:
|
3700
|
+
import_zod28.z.object({
|
3701
|
+
type: import_zod28.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
3161
3702
|
})
|
3162
3703
|
);
|
3163
3704
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
3164
|
-
|
3165
|
-
requestId:
|
3166
|
-
type:
|
3705
|
+
import_zod28.z.object({
|
3706
|
+
requestId: import_zod28.z.string(),
|
3707
|
+
type: import_zod28.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
3167
3708
|
})
|
3168
3709
|
);
|
3169
3710
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
3170
|
-
|
3171
|
-
requestId:
|
3172
|
-
type:
|
3711
|
+
import_zod28.z.object({
|
3712
|
+
requestId: import_zod28.z.string(),
|
3713
|
+
type: import_zod28.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
3173
3714
|
})
|
3174
3715
|
);
|
3175
3716
|
var ReadActionInput = BaseActionInput.merge(
|
3176
|
-
|
3177
|
-
type:
|
3717
|
+
import_zod28.z.object({
|
3718
|
+
type: import_zod28.z.literal(ActionType.READ).default(ActionType.READ)
|
3178
3719
|
})
|
3179
3720
|
);
|
3180
|
-
var DeleteActionInput =
|
3181
|
-
var ActionInput =
|
3721
|
+
var DeleteActionInput = import_zod28.z.object({ eventId: import_zod28.z.string() });
|
3722
|
+
var ActionInput = import_zod28.z.discriminatedUnion("type", [
|
3182
3723
|
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
3183
3724
|
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
3184
3725
|
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
@@ -3207,18 +3748,18 @@ var ActionInput = import_zod26.z.discriminatedUnion("type", [
|
|
3207
3748
|
});
|
3208
3749
|
|
3209
3750
|
// ../commons/src/events/Draft.ts
|
3210
|
-
var Draft =
|
3211
|
-
id:
|
3212
|
-
eventId:
|
3213
|
-
transactionId:
|
3214
|
-
createdAt:
|
3751
|
+
var Draft = import_zod29.z.object({
|
3752
|
+
id: import_zod29.z.string(),
|
3753
|
+
eventId: import_zod29.z.string(),
|
3754
|
+
transactionId: import_zod29.z.string(),
|
3755
|
+
createdAt: import_zod29.z.string().datetime(),
|
3215
3756
|
action: ActionBase.extend({
|
3216
3757
|
type: ActionTypes
|
3217
3758
|
}).omit({ id: true })
|
3218
3759
|
});
|
3219
3760
|
var DraftInput = BaseActionInput.extend({
|
3220
3761
|
type: ActionTypes,
|
3221
|
-
status:
|
3762
|
+
status: import_zod29.z.enum([
|
3222
3763
|
ActionStatus.Requested,
|
3223
3764
|
ActionStatus.Accepted,
|
3224
3765
|
ActionStatus.Rejected
|
@@ -3226,24 +3767,24 @@ var DraftInput = BaseActionInput.extend({
|
|
3226
3767
|
});
|
3227
3768
|
|
3228
3769
|
// ../commons/src/events/EventInput.ts
|
3229
|
-
var
|
3770
|
+
var import_zod30 = require("zod");
|
3230
3771
|
var import_uuid4 = require("uuid");
|
3231
|
-
var EventInput =
|
3232
|
-
transactionId:
|
3233
|
-
type:
|
3772
|
+
var EventInput = import_zod30.z.object({
|
3773
|
+
transactionId: import_zod30.z.string(),
|
3774
|
+
type: import_zod30.z.string()
|
3234
3775
|
}).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
|
3235
3776
|
|
3236
3777
|
// ../commons/src/events/EventDocument.ts
|
3237
|
-
var
|
3778
|
+
var import_zod31 = require("zod");
|
3238
3779
|
var import_zod_openapi11 = require("zod-openapi");
|
3239
|
-
(0, import_zod_openapi11.extendZodWithOpenApi)(
|
3240
|
-
var EventDocument =
|
3241
|
-
id:
|
3242
|
-
type:
|
3243
|
-
createdAt:
|
3244
|
-
updatedAt:
|
3245
|
-
actions:
|
3246
|
-
trackingId:
|
3780
|
+
(0, import_zod_openapi11.extendZodWithOpenApi)(import_zod31.z);
|
3781
|
+
var EventDocument = import_zod31.z.object({
|
3782
|
+
id: import_zod31.z.string(),
|
3783
|
+
type: import_zod31.z.string(),
|
3784
|
+
createdAt: import_zod31.z.string().datetime(),
|
3785
|
+
updatedAt: import_zod31.z.string().datetime(),
|
3786
|
+
actions: import_zod31.z.array(Action),
|
3787
|
+
trackingId: import_zod31.z.string()
|
3247
3788
|
}).openapi({ ref: "EventDocument" });
|
3248
3789
|
|
3249
3790
|
// ../commons/src/events/state/utils.ts
|
@@ -3277,6 +3818,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3277
3818
|
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
3278
3819
|
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
3279
3820
|
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
3821
|
+
createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
|
3280
3822
|
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
3281
3823
|
acceptedAt: acceptAction.createdAt,
|
3282
3824
|
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
@@ -3284,17 +3826,18 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3284
3826
|
registrationNumber
|
3285
3827
|
};
|
3286
3828
|
}
|
3287
|
-
function
|
3829
|
+
function getActionUpdateMetadata(actions) {
|
3288
3830
|
const createAction = getOrThrow(
|
3289
3831
|
actions.find((action) => action.type === ActionType.CREATE),
|
3290
3832
|
`Event has no ${ActionType.CREATE} action`
|
3291
3833
|
);
|
3292
|
-
return
|
3834
|
+
return StatusChangingActions.options.reduce(
|
3293
3835
|
(metadata, actionType) => {
|
3294
3836
|
const { accept, request } = getActionRequests(actionType, actions);
|
3295
3837
|
return {
|
3296
3838
|
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
3297
3839
|
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
3840
|
+
createdByUserType: request?.createdByUserType ?? accept?.createdByUserType ?? metadata.createdByUserType,
|
3298
3841
|
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
3299
3842
|
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
3300
3843
|
};
|
@@ -3302,6 +3845,7 @@ function getDeclarationActionUpdateMetadata(actions) {
|
|
3302
3845
|
{
|
3303
3846
|
createdAt: createAction.createdAt,
|
3304
3847
|
createdBy: createAction.createdBy,
|
3848
|
+
createdByUserType: createAction.createdByUserType,
|
3305
3849
|
createdAtLocation: createAction.createdAtLocation,
|
3306
3850
|
createdByRole: createAction.createdByRole
|
3307
3851
|
}
|
@@ -3309,11 +3853,11 @@ function getDeclarationActionUpdateMetadata(actions) {
|
|
3309
3853
|
}
|
3310
3854
|
function getLegalStatuses(actions) {
|
3311
3855
|
return {
|
3312
|
-
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
3856
|
+
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
3313
3857
|
ActionType.DECLARE,
|
3314
3858
|
actions
|
3315
3859
|
),
|
3316
|
-
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
3860
|
+
[EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
|
3317
3861
|
ActionType.REGISTER,
|
3318
3862
|
actions
|
3319
3863
|
)
|
@@ -3326,26 +3870,26 @@ function getStatusFromActions(actions) {
|
|
3326
3870
|
(a) => a.status === ActionStatus.Rejected
|
3327
3871
|
);
|
3328
3872
|
if (hasRejectedAction) {
|
3329
|
-
return EventStatus.REJECTED;
|
3873
|
+
return EventStatus.enum.REJECTED;
|
3330
3874
|
}
|
3331
3875
|
return actions.reduce((status, action) => {
|
3332
3876
|
switch (action.type) {
|
3333
3877
|
case ActionType.CREATE:
|
3334
|
-
return EventStatus.CREATED;
|
3878
|
+
return EventStatus.enum.CREATED;
|
3335
3879
|
case ActionType.DECLARE:
|
3336
|
-
return EventStatus.DECLARED;
|
3880
|
+
return EventStatus.enum.DECLARED;
|
3337
3881
|
case ActionType.VALIDATE:
|
3338
|
-
return EventStatus.VALIDATED;
|
3882
|
+
return EventStatus.enum.VALIDATED;
|
3339
3883
|
case ActionType.REGISTER:
|
3340
|
-
return EventStatus.REGISTERED;
|
3884
|
+
return EventStatus.enum.REGISTERED;
|
3341
3885
|
case ActionType.REJECT:
|
3342
|
-
return EventStatus.REJECTED;
|
3886
|
+
return EventStatus.enum.REJECTED;
|
3343
3887
|
case ActionType.ARCHIVE:
|
3344
|
-
return EventStatus.ARCHIVED;
|
3888
|
+
return EventStatus.enum.ARCHIVED;
|
3345
3889
|
case ActionType.NOTIFY:
|
3346
|
-
return EventStatus.NOTIFIED;
|
3890
|
+
return EventStatus.enum.NOTIFIED;
|
3347
3891
|
case ActionType.PRINT_CERTIFICATE:
|
3348
|
-
return EventStatus.CERTIFIED;
|
3892
|
+
return EventStatus.enum.CERTIFIED;
|
3349
3893
|
case ActionType.ASSIGN:
|
3350
3894
|
case ActionType.UNASSIGN:
|
3351
3895
|
case ActionType.REQUEST_CORRECTION:
|
@@ -3356,7 +3900,7 @@ function getStatusFromActions(actions) {
|
|
3356
3900
|
default:
|
3357
3901
|
return status;
|
3358
3902
|
}
|
3359
|
-
}, EventStatus.CREATED);
|
3903
|
+
}, EventStatus.enum.CREATED);
|
3360
3904
|
}
|
3361
3905
|
function getFlagsFromActions(actions) {
|
3362
3906
|
const sortedactions = actions.sort(
|
@@ -3448,7 +3992,7 @@ function deepDropNulls(obj) {
|
|
3448
3992
|
return obj;
|
3449
3993
|
}
|
3450
3994
|
function isUndeclaredDraft(status) {
|
3451
|
-
return status === EventStatus.CREATED;
|
3995
|
+
return status === EventStatus.enum.CREATED;
|
3452
3996
|
}
|
3453
3997
|
function getAcceptedActions(event2) {
|
3454
3998
|
return event2.actions.filter(
|
@@ -3463,10 +4007,11 @@ function getCurrentEventState(event2, config) {
|
|
3463
4007
|
if (!creationAction) {
|
3464
4008
|
throw new Error(`Event ${event2.id} has no creation action`);
|
3465
4009
|
}
|
3466
|
-
const acceptedActions = getAcceptedActions(event2)
|
3467
|
-
|
3468
|
-
event2.actions
|
4010
|
+
const acceptedActions = getAcceptedActions(event2).sort(
|
4011
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
3469
4012
|
);
|
4013
|
+
const requestActionMetadata = getActionUpdateMetadata(event2.actions);
|
4014
|
+
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
3470
4015
|
const declaration = aggregateActionDeclarations(acceptedActions);
|
3471
4016
|
let dateOfEvent;
|
3472
4017
|
if (config.dateOfEvent) {
|
@@ -3486,16 +4031,17 @@ function getCurrentEventState(event2, config) {
|
|
3486
4031
|
legalStatuses: getLegalStatuses(event2.actions),
|
3487
4032
|
createdAt: creationAction.createdAt,
|
3488
4033
|
createdBy: creationAction.createdBy,
|
4034
|
+
createdByUserType: creationAction.createdByUserType,
|
3489
4035
|
createdAtLocation: creationAction.createdAtLocation,
|
3490
4036
|
createdBySignature: creationAction.createdBySignature,
|
3491
|
-
updatedAt:
|
4037
|
+
updatedAt: acceptedActionMetadata.createdAt,
|
3492
4038
|
assignedTo: getAssignedUserFromActions(acceptedActions),
|
3493
4039
|
assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
|
3494
|
-
updatedBy:
|
3495
|
-
updatedAtLocation:
|
4040
|
+
updatedBy: requestActionMetadata.createdBy,
|
4041
|
+
updatedAtLocation: requestActionMetadata.createdAtLocation,
|
3496
4042
|
declaration,
|
3497
4043
|
trackingId: event2.trackingId,
|
3498
|
-
updatedByUserRole:
|
4044
|
+
updatedByUserRole: requestActionMetadata.createdByRole,
|
3499
4045
|
dateOfEvent,
|
3500
4046
|
flags: getFlagsFromActions(event2.actions)
|
3501
4047
|
});
|
@@ -3578,18 +4124,18 @@ function generateTransactionId() {
|
|
3578
4124
|
}
|
3579
4125
|
|
3580
4126
|
// ../commons/src/events/User.ts
|
3581
|
-
var
|
3582
|
-
var User =
|
3583
|
-
id:
|
3584
|
-
name:
|
3585
|
-
|
3586
|
-
use:
|
3587
|
-
given:
|
3588
|
-
family:
|
4127
|
+
var import_zod32 = require("zod");
|
4128
|
+
var User = import_zod32.z.object({
|
4129
|
+
id: import_zod32.z.string(),
|
4130
|
+
name: import_zod32.z.array(
|
4131
|
+
import_zod32.z.object({
|
4132
|
+
use: import_zod32.z.string(),
|
4133
|
+
given: import_zod32.z.array(import_zod32.z.string()),
|
4134
|
+
family: import_zod32.z.string()
|
3589
4135
|
})
|
3590
4136
|
),
|
3591
|
-
role:
|
3592
|
-
signatureFilename:
|
4137
|
+
role: import_zod32.z.string(),
|
4138
|
+
signatureFilename: import_zod32.z.string().optional()
|
3593
4139
|
});
|
3594
4140
|
|
3595
4141
|
// ../commons/src/events/test.utils.ts
|
@@ -4274,7 +4820,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
|
|
4274
4820
|
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
4275
4821
|
title: {
|
4276
4822
|
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
4277
|
-
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
4823
|
+
defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
|
4278
4824
|
description: "Title of the review page"
|
4279
4825
|
},
|
4280
4826
|
fields: [
|
@@ -4319,27 +4865,17 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4319
4865
|
},
|
4320
4866
|
fields: [
|
4321
4867
|
{
|
4322
|
-
id: "applicant.
|
4323
|
-
type: FieldType.
|
4868
|
+
id: "applicant.name",
|
4869
|
+
type: FieldType.NAME,
|
4324
4870
|
required: true,
|
4871
|
+
hideLabel: true,
|
4325
4872
|
conditionals: [],
|
4326
4873
|
label: {
|
4327
|
-
defaultMessage: "Applicant's
|
4874
|
+
defaultMessage: "Applicant's name",
|
4328
4875
|
description: "This is the label for the field",
|
4329
4876
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
4330
4877
|
}
|
4331
4878
|
},
|
4332
|
-
{
|
4333
|
-
id: "applicant.surname",
|
4334
|
-
type: FieldType.TEXT,
|
4335
|
-
required: true,
|
4336
|
-
conditionals: [],
|
4337
|
-
label: {
|
4338
|
-
defaultMessage: "Applicant's surname",
|
4339
|
-
description: "This is the label for the field",
|
4340
|
-
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.surname.label"
|
4341
|
-
}
|
4342
|
-
},
|
4343
4879
|
{
|
4344
4880
|
id: "applicant.email",
|
4345
4881
|
type: "EMAIL",
|
@@ -4473,8 +5009,9 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4473
5009
|
}
|
4474
5010
|
},
|
4475
5011
|
{
|
4476
|
-
id: "recommender.
|
4477
|
-
type: FieldType.
|
5012
|
+
id: "recommender.name",
|
5013
|
+
type: FieldType.NAME,
|
5014
|
+
hideLabel: true,
|
4478
5015
|
required: true,
|
4479
5016
|
conditionals: [
|
4480
5017
|
{
|
@@ -4483,27 +5020,11 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4483
5020
|
}
|
4484
5021
|
],
|
4485
5022
|
label: {
|
4486
|
-
defaultMessage: "Recommender's
|
5023
|
+
defaultMessage: "Recommender's name",
|
4487
5024
|
description: "This is the label for the field",
|
4488
5025
|
id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label"
|
4489
5026
|
}
|
4490
5027
|
},
|
4491
|
-
{
|
4492
|
-
id: "recommender.surname",
|
4493
|
-
type: FieldType.TEXT,
|
4494
|
-
required: true,
|
4495
|
-
conditionals: [
|
4496
|
-
{
|
4497
|
-
type: ConditionalType.SHOW,
|
4498
|
-
conditional: field("recommender.none").isFalsy()
|
4499
|
-
}
|
4500
|
-
],
|
4501
|
-
label: {
|
4502
|
-
defaultMessage: "Recommender's surname",
|
4503
|
-
description: "This is the label for the field",
|
4504
|
-
id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label"
|
4505
|
-
}
|
4506
|
-
},
|
4507
5028
|
{
|
4508
5029
|
id: "recommender.id",
|
4509
5030
|
type: FieldType.TEXT,
|
@@ -4534,7 +5055,7 @@ var statusOptions = [
|
|
4534
5055
|
}
|
4535
5056
|
},
|
4536
5057
|
{
|
4537
|
-
value: EventStatus.CREATED,
|
5058
|
+
value: EventStatus.enum.CREATED,
|
4538
5059
|
label: {
|
4539
5060
|
defaultMessage: "Draft",
|
4540
5061
|
description: "Option for form field: status of record",
|
@@ -4542,7 +5063,7 @@ var statusOptions = [
|
|
4542
5063
|
}
|
4543
5064
|
},
|
4544
5065
|
{
|
4545
|
-
value: EventStatus.NOTIFIED,
|
5066
|
+
value: EventStatus.enum.NOTIFIED,
|
4546
5067
|
label: {
|
4547
5068
|
defaultMessage: "Notified",
|
4548
5069
|
description: "Option for form field: status of record",
|
@@ -4550,7 +5071,7 @@ var statusOptions = [
|
|
4550
5071
|
}
|
4551
5072
|
},
|
4552
5073
|
{
|
4553
|
-
value: EventStatus.DECLARED,
|
5074
|
+
value: EventStatus.enum.DECLARED,
|
4554
5075
|
label: {
|
4555
5076
|
defaultMessage: "Declared",
|
4556
5077
|
description: "Option for form field: status of record",
|
@@ -4558,7 +5079,7 @@ var statusOptions = [
|
|
4558
5079
|
}
|
4559
5080
|
},
|
4560
5081
|
{
|
4561
|
-
value: EventStatus.VALIDATED,
|
5082
|
+
value: EventStatus.enum.VALIDATED,
|
4562
5083
|
label: {
|
4563
5084
|
defaultMessage: "Validated",
|
4564
5085
|
description: "Option for form field: status of record",
|
@@ -4566,7 +5087,7 @@ var statusOptions = [
|
|
4566
5087
|
}
|
4567
5088
|
},
|
4568
5089
|
{
|
4569
|
-
value: EventStatus.REGISTERED,
|
5090
|
+
value: EventStatus.enum.REGISTERED,
|
4570
5091
|
label: {
|
4571
5092
|
defaultMessage: "Registered",
|
4572
5093
|
description: "Option for form field: status of record",
|
@@ -4574,7 +5095,7 @@ var statusOptions = [
|
|
4574
5095
|
}
|
4575
5096
|
},
|
4576
5097
|
{
|
4577
|
-
value: EventStatus.CERTIFIED,
|
5098
|
+
value: EventStatus.enum.CERTIFIED,
|
4578
5099
|
label: {
|
4579
5100
|
defaultMessage: "Certified",
|
4580
5101
|
description: "Option for form field: status of record",
|
@@ -4582,7 +5103,7 @@ var statusOptions = [
|
|
4582
5103
|
}
|
4583
5104
|
},
|
4584
5105
|
{
|
4585
|
-
value: EventStatus.REJECTED,
|
5106
|
+
value: EventStatus.enum.REJECTED,
|
4586
5107
|
label: {
|
4587
5108
|
defaultMessage: "Rejected",
|
4588
5109
|
description: "Option for form field: status of record",
|
@@ -4590,7 +5111,7 @@ var statusOptions = [
|
|
4590
5111
|
}
|
4591
5112
|
},
|
4592
5113
|
{
|
4593
|
-
value: EventStatus.ARCHIVED,
|
5114
|
+
value: EventStatus.enum.ARCHIVED,
|
4594
5115
|
label: {
|
4595
5116
|
defaultMessage: "Archived",
|
4596
5117
|
description: "Option for form field: status of record",
|
@@ -4654,38 +5175,25 @@ var tennisClubMembershipEvent = defineConfig({
|
|
4654
5175
|
id: "v2.event.tennis-club-membership.label"
|
4655
5176
|
},
|
4656
5177
|
title: {
|
4657
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
5178
|
+
defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
|
4658
5179
|
description: "This is the title of the summary",
|
4659
5180
|
id: "v2.event.tennis-club-membership.title"
|
4660
5181
|
},
|
4661
5182
|
summary: {
|
4662
5183
|
fields: [
|
4663
5184
|
{
|
4664
|
-
|
5185
|
+
fieldId: "applicant.name",
|
4665
5186
|
label: {
|
4666
|
-
defaultMessage: "Applicant's
|
5187
|
+
defaultMessage: "Applicant's name",
|
4667
5188
|
description: "This is the label for the field",
|
4668
5189
|
id: "event.tennis-club-membership.summary.field.firstname.label"
|
4669
5190
|
},
|
4670
|
-
value: {
|
4671
|
-
defaultMessage: "{applicant.firstname}",
|
4672
|
-
description: "This is the value to show in the summary",
|
4673
|
-
id: "event.tennis-club-membership.summary.field.firstname"
|
4674
|
-
},
|
4675
5191
|
emptyValueMessage: {
|
4676
5192
|
defaultMessage: "First name is not provided",
|
4677
5193
|
description: "This is the message to show when the field is empty",
|
4678
5194
|
id: "event.tennis-club-membership.summary.field.firstname.empty"
|
4679
5195
|
}
|
4680
5196
|
},
|
4681
|
-
{
|
4682
|
-
fieldId: "applicant.surname",
|
4683
|
-
label: {
|
4684
|
-
defaultMessage: "Applicant's last name",
|
4685
|
-
description: "Label for surname",
|
4686
|
-
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
4687
|
-
}
|
4688
|
-
},
|
4689
5197
|
{
|
4690
5198
|
fieldId: "applicant.email"
|
4691
5199
|
}
|
@@ -5021,8 +5529,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
5021
5529
|
id: "v2.event.tennis-club-membership.search.applicants"
|
5022
5530
|
},
|
5023
5531
|
fields: [
|
5024
|
-
field("applicant.
|
5025
|
-
field("applicant.surname").fuzzy(),
|
5532
|
+
field("applicant.name").fuzzy(),
|
5026
5533
|
field("applicant.dob").range(),
|
5027
5534
|
field("applicant.email").exact()
|
5028
5535
|
]
|
@@ -5033,10 +5540,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
5033
5540
|
description: "Recommender details search field section title",
|
5034
5541
|
id: "v2.event.tennis-club-membership.search.recommender"
|
5035
5542
|
},
|
5036
|
-
fields: [
|
5037
|
-
field("recommender.firstname").fuzzy(),
|
5038
|
-
field("recommender.surname").fuzzy()
|
5039
|
-
]
|
5543
|
+
fields: [field("recommender.name").fuzzy()]
|
5040
5544
|
}
|
5041
5545
|
],
|
5042
5546
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
@@ -5051,21 +5555,21 @@ var footballClubMembershipEvent = defineConfig({
|
|
5051
5555
|
id: "event.football-club-membership.label"
|
5052
5556
|
},
|
5053
5557
|
title: {
|
5054
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
5558
|
+
defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
|
5055
5559
|
description: "This is the title of the summary",
|
5056
5560
|
id: "v2.event.football-club-membership.title"
|
5057
5561
|
},
|
5058
5562
|
summary: {
|
5059
5563
|
fields: [
|
5060
5564
|
{
|
5061
|
-
id: "applicant.firstname",
|
5565
|
+
id: "applicant.name.firstname",
|
5062
5566
|
label: {
|
5063
5567
|
defaultMessage: "Applicant's first name",
|
5064
5568
|
description: "This is the label for the field",
|
5065
5569
|
id: "event.football-club-membership.summary.field.firstname.label"
|
5066
5570
|
},
|
5067
5571
|
value: {
|
5068
|
-
defaultMessage: "{applicant.firstname}",
|
5572
|
+
defaultMessage: "{applicant.name.firstname}",
|
5069
5573
|
description: "This is the value to show in the summary",
|
5070
5574
|
id: "event.football-club-membership.summary.field.firstname"
|
5071
5575
|
},
|
@@ -5076,7 +5580,7 @@ var footballClubMembershipEvent = defineConfig({
|
|
5076
5580
|
}
|
5077
5581
|
},
|
5078
5582
|
{
|
5079
|
-
fieldId: "applicant.surname",
|
5583
|
+
fieldId: "applicant.name.surname",
|
5080
5584
|
label: {
|
5081
5585
|
defaultMessage: "Applicant's last name",
|
5082
5586
|
description: "Label for surname",
|
@@ -5418,8 +5922,7 @@ var footballClubMembershipEvent = defineConfig({
|
|
5418
5922
|
id: "v2.event.football-club-membership.search.applicants"
|
5419
5923
|
},
|
5420
5924
|
fields: [
|
5421
|
-
field("applicant.
|
5422
|
-
field("applicant.surname").fuzzy(),
|
5925
|
+
field("applicant.name").fuzzy(),
|
5423
5926
|
field("applicant.dob").range(),
|
5424
5927
|
field("applicant.email").exact()
|
5425
5928
|
]
|
@@ -5430,10 +5933,7 @@ var footballClubMembershipEvent = defineConfig({
|
|
5430
5933
|
description: "Recommender details search field section title",
|
5431
5934
|
id: "v2.event.football-club-membership.search.recommender"
|
5432
5935
|
},
|
5433
|
-
fields: [
|
5434
|
-
field("recommender.firstname").fuzzy(),
|
5435
|
-
field("recommender.surname").fuzzy()
|
5436
|
-
]
|
5936
|
+
fields: [field("recommender.name").fuzzy()]
|
5437
5937
|
}
|
5438
5938
|
],
|
5439
5939
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
@@ -5498,33 +5998,261 @@ var libraryMembershipEvent = defineConfig({
|
|
5498
5998
|
declaration: libraryMembershipForm
|
5499
5999
|
});
|
5500
6000
|
|
6001
|
+
// ../commons/src/fixtures/v2-birth-event.ts
|
6002
|
+
var child = defineFormPage({
|
6003
|
+
id: "child",
|
6004
|
+
type: PageTypes.enum.FORM,
|
6005
|
+
title: {
|
6006
|
+
defaultMessage: "Child's details",
|
6007
|
+
description: "Form section title for Child",
|
6008
|
+
id: "v2.form.birth.child.title"
|
6009
|
+
},
|
6010
|
+
fields: [
|
6011
|
+
{
|
6012
|
+
id: "child.firstNames",
|
6013
|
+
type: FieldType.TEXT,
|
6014
|
+
required: true,
|
6015
|
+
configuration: { maxLength: 32 },
|
6016
|
+
hideLabel: true,
|
6017
|
+
label: {
|
6018
|
+
defaultMessage: "Child's first name",
|
6019
|
+
description: "This is the label for the field",
|
6020
|
+
id: "v2.event.birth.action.declare.form.section.child.field.name.label"
|
6021
|
+
}
|
6022
|
+
},
|
6023
|
+
{
|
6024
|
+
id: "child.familyName",
|
6025
|
+
type: FieldType.TEXT,
|
6026
|
+
required: true,
|
6027
|
+
configuration: { maxLength: 32 },
|
6028
|
+
hideLabel: true,
|
6029
|
+
label: {
|
6030
|
+
defaultMessage: "Child's last name",
|
6031
|
+
description: "This is the label for the field",
|
6032
|
+
id: "v2.event.birth.action.declare.form.section.child.field.name.label"
|
6033
|
+
}
|
6034
|
+
},
|
6035
|
+
{
|
6036
|
+
id: "child.DoB",
|
6037
|
+
type: "DATE",
|
6038
|
+
required: true,
|
6039
|
+
label: {
|
6040
|
+
defaultMessage: "Date of birth",
|
6041
|
+
description: "This is the label for the field",
|
6042
|
+
id: "v2.event.birth.action.declare.form.section.child.field.dob.label"
|
6043
|
+
}
|
6044
|
+
}
|
6045
|
+
]
|
6046
|
+
});
|
6047
|
+
var mother = defineFormPage({
|
6048
|
+
id: "mother",
|
6049
|
+
type: PageTypes.enum.FORM,
|
6050
|
+
title: {
|
6051
|
+
defaultMessage: "Mother's details",
|
6052
|
+
description: "Form section title for mothers details",
|
6053
|
+
id: "v2.form.section.mother.title"
|
6054
|
+
},
|
6055
|
+
fields: [
|
6056
|
+
{
|
6057
|
+
id: "mother.firstNames",
|
6058
|
+
configuration: { maxLength: 32 },
|
6059
|
+
type: FieldType.TEXT,
|
6060
|
+
required: true,
|
6061
|
+
label: {
|
6062
|
+
defaultMessage: "First name(s)",
|
6063
|
+
description: "This is the label for the field",
|
6064
|
+
id: `v2.event.birth.action.declare.form.section.person.field.firstname.label`
|
6065
|
+
}
|
6066
|
+
},
|
6067
|
+
{
|
6068
|
+
id: `mother.familyName`,
|
6069
|
+
configuration: { maxLength: 32 },
|
6070
|
+
type: FieldType.TEXT,
|
6071
|
+
required: true,
|
6072
|
+
label: {
|
6073
|
+
defaultMessage: "Last name",
|
6074
|
+
description: "This is the label for the field",
|
6075
|
+
id: `v2.event.birth.action.declare.form.section.person.field.surname.label`
|
6076
|
+
}
|
6077
|
+
},
|
6078
|
+
{
|
6079
|
+
id: `mother.DoB`,
|
6080
|
+
type: "DATE",
|
6081
|
+
required: true,
|
6082
|
+
label: {
|
6083
|
+
defaultMessage: "Date of birth",
|
6084
|
+
description: "This is the label for the field",
|
6085
|
+
id: `v2.event.birth.action.declare.form.section.person.field.dob.label`
|
6086
|
+
}
|
6087
|
+
},
|
6088
|
+
{
|
6089
|
+
id: "mother.identifier",
|
6090
|
+
type: FieldType.ID,
|
6091
|
+
required: true,
|
6092
|
+
label: {
|
6093
|
+
defaultMessage: "ID Number",
|
6094
|
+
description: "This is the label for the field",
|
6095
|
+
id: `v2.event.birth.action.declare.form.section.person.field.nid.label`
|
6096
|
+
}
|
6097
|
+
}
|
6098
|
+
]
|
6099
|
+
});
|
6100
|
+
var BIRTH_DECLARATION_FORM = defineDeclarationForm({
|
6101
|
+
label: {
|
6102
|
+
defaultMessage: "Birth decalration form",
|
6103
|
+
id: "v2.event.birth.action.declare.form.label",
|
6104
|
+
description: "This is what this form is referred as in the system"
|
6105
|
+
},
|
6106
|
+
pages: [child, mother]
|
6107
|
+
});
|
6108
|
+
var v2BirthEvent = defineConfig({
|
6109
|
+
id: BIRTH_EVENT,
|
6110
|
+
title: {
|
6111
|
+
defaultMessage: "{child.name.firstname} {child.name.surname}",
|
6112
|
+
description: "This is the title of the summary",
|
6113
|
+
id: "v2.event.birth.title"
|
6114
|
+
},
|
6115
|
+
label: {
|
6116
|
+
defaultMessage: "Birth",
|
6117
|
+
description: "This is what this event is referred as in the system",
|
6118
|
+
id: "v2.event.birth.label"
|
6119
|
+
},
|
6120
|
+
summary: {
|
6121
|
+
fields: []
|
6122
|
+
},
|
6123
|
+
actions: [],
|
6124
|
+
declaration: BIRTH_DECLARATION_FORM
|
6125
|
+
});
|
6126
|
+
|
5501
6127
|
// ../commons/src/events/test.utils.ts
|
5502
|
-
|
6128
|
+
var import_zod33 = require("zod");
|
6129
|
+
var TestUserRole = import_zod33.z.enum([
|
6130
|
+
"FIELD_AGENT",
|
6131
|
+
"LOCAL_REGISTRAR",
|
6132
|
+
"LOCAL_SYSTEM_ADMIN",
|
6133
|
+
"NATIONAL_REGISTRAR",
|
6134
|
+
"REGISTRATION_AGENT"
|
6135
|
+
]);
|
6136
|
+
function pickRandom(rng, items) {
|
6137
|
+
return items[Math.floor(rng() * items.length)];
|
6138
|
+
}
|
6139
|
+
function generateRandomName(rng) {
|
6140
|
+
const firstnames = [
|
6141
|
+
"Danny",
|
6142
|
+
"John",
|
6143
|
+
"Jane",
|
6144
|
+
"Emily",
|
6145
|
+
"Michael",
|
6146
|
+
"Sarah",
|
6147
|
+
"Chris",
|
6148
|
+
"Jessica",
|
6149
|
+
"Sara",
|
6150
|
+
"Sarachella",
|
6151
|
+
"Sarandera",
|
6152
|
+
"Zara"
|
6153
|
+
];
|
6154
|
+
const surnames = [
|
6155
|
+
"Doe",
|
6156
|
+
"Smith",
|
6157
|
+
"Johnson",
|
6158
|
+
"Brown",
|
6159
|
+
"Williams",
|
6160
|
+
"Jones",
|
6161
|
+
"Garcia",
|
6162
|
+
"Miller",
|
6163
|
+
"Saranen",
|
6164
|
+
"Sarajanen",
|
6165
|
+
"Sarthua",
|
6166
|
+
"Tsarakovski",
|
6167
|
+
"Salamander",
|
6168
|
+
"Zarathustra"
|
6169
|
+
];
|
6170
|
+
return {
|
6171
|
+
firstname: pickRandom(rng, firstnames),
|
6172
|
+
surname: pickRandom(rng, surnames)
|
6173
|
+
};
|
6174
|
+
}
|
6175
|
+
function mapFieldTypeToMockValue(field2, i, rng) {
|
6176
|
+
switch (field2.type) {
|
6177
|
+
case FieldType.DIVIDER:
|
6178
|
+
case FieldType.TEXT:
|
6179
|
+
case FieldType.TEXTAREA:
|
6180
|
+
case FieldType.BULLET_LIST:
|
6181
|
+
case FieldType.PAGE_HEADER:
|
6182
|
+
case FieldType.LOCATION:
|
6183
|
+
case FieldType.SELECT:
|
6184
|
+
case FieldType.COUNTRY:
|
6185
|
+
case FieldType.RADIO_GROUP:
|
6186
|
+
case FieldType.PARAGRAPH:
|
6187
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
6188
|
+
case FieldType.FACILITY:
|
6189
|
+
case FieldType.PHONE:
|
6190
|
+
case FieldType.ID:
|
6191
|
+
case FieldType.OFFICE:
|
6192
|
+
return `${field2.id}-${field2.type}-${i}`;
|
6193
|
+
case FieldType.NAME:
|
6194
|
+
return generateRandomName(rng);
|
6195
|
+
case FieldType.NUMBER:
|
6196
|
+
return 19;
|
6197
|
+
case FieldType.EMAIL:
|
6198
|
+
return "test@opencrvs.org";
|
6199
|
+
case FieldType.ADDRESS:
|
6200
|
+
return {
|
6201
|
+
country: "FAR",
|
6202
|
+
addressType: AddressType.DOMESTIC,
|
6203
|
+
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
6204
|
+
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
6205
|
+
urbanOrRural: "URBAN",
|
6206
|
+
town: "Example Town",
|
6207
|
+
residentialArea: "Example Residential Area",
|
6208
|
+
street: "Example Street",
|
6209
|
+
number: "55",
|
6210
|
+
zipCode: "123456"
|
6211
|
+
};
|
6212
|
+
case FieldType.DATE:
|
6213
|
+
return "2021-01-01";
|
6214
|
+
case FieldType.DATE_RANGE:
|
6215
|
+
return ["2021-01-01", "2021-01-02"];
|
6216
|
+
case FieldType.CHECKBOX:
|
6217
|
+
return true;
|
6218
|
+
case FieldType.SIGNATURE:
|
6219
|
+
case FieldType.FILE:
|
6220
|
+
return {
|
6221
|
+
filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
|
6222
|
+
originalFilename: "abcd.png",
|
6223
|
+
type: "image/png"
|
6224
|
+
};
|
6225
|
+
case FieldType.FILE_WITH_OPTIONS:
|
6226
|
+
case FieldType.DATA:
|
6227
|
+
return void 0;
|
6228
|
+
}
|
6229
|
+
}
|
6230
|
+
function fieldConfigsToActionPayload(fields, rng) {
|
5503
6231
|
return fields.reduce(
|
5504
6232
|
(acc, field2, i) => ({
|
5505
6233
|
...acc,
|
5506
|
-
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
6234
|
+
[field2.id]: mapFieldTypeToMockValue(field2, i, rng)
|
5507
6235
|
}),
|
5508
6236
|
{}
|
5509
6237
|
);
|
5510
6238
|
}
|
5511
|
-
function generateActionDeclarationInput(configuration, action) {
|
6239
|
+
function generateActionDeclarationInput(configuration, action, rng) {
|
5512
6240
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
5513
6241
|
if (parsed.success) {
|
5514
6242
|
const fields = getDeclarationFields(configuration);
|
5515
6243
|
const declarationConfig = getDeclaration(configuration);
|
5516
|
-
const declaration = fieldConfigsToActionPayload(fields);
|
6244
|
+
const declaration = fieldConfigsToActionPayload(fields, rng);
|
5517
6245
|
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
5518
6246
|
}
|
5519
6247
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
5520
6248
|
return {};
|
5521
6249
|
}
|
5522
|
-
function generateActionAnnotationInput(configuration, action) {
|
6250
|
+
function generateActionAnnotationInput(configuration, action, rng) {
|
5523
6251
|
const actionConfig = configuration.actions.find(
|
5524
6252
|
(ac) => ac.type === action
|
5525
6253
|
);
|
5526
6254
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
5527
|
-
const annotation = fieldConfigsToActionPayload(annotationFields);
|
6255
|
+
const annotation = fieldConfigsToActionPayload(annotationFields, rng);
|
5528
6256
|
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
5529
6257
|
findRecordActionPages(configuration, action),
|
5530
6258
|
annotation
|
@@ -5542,198 +6270,227 @@ function generateActionAnnotationInput(configuration, action) {
|
|
5542
6270
|
...visiblePageVerificationMap
|
5543
6271
|
};
|
5544
6272
|
}
|
5545
|
-
|
5546
|
-
|
5547
|
-
|
5548
|
-
type: input.type ?? TENNIS_CLUB_MEMBERSHIP
|
5549
|
-
}),
|
5550
|
-
patch: (id, input = {}) => ({
|
5551
|
-
transactionId: input.transactionId ?? getUUID(),
|
5552
|
-
type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
|
5553
|
-
id
|
5554
|
-
}),
|
5555
|
-
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
5556
|
-
{
|
5557
|
-
id: getUUID(),
|
5558
|
-
eventId,
|
5559
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
5560
|
-
transactionId: getUUID(),
|
5561
|
-
action: {
|
5562
|
-
transactionId: getUUID(),
|
5563
|
-
type: actionType,
|
5564
|
-
status: ActionStatus.Accepted,
|
5565
|
-
declaration: {
|
5566
|
-
"applicant.firstname": "Max",
|
5567
|
-
"applicant.surname": "McLaren",
|
5568
|
-
"applicant.dob": "2020-01-02",
|
5569
|
-
"recommender.none": true
|
5570
|
-
},
|
5571
|
-
annotation: {
|
5572
|
-
"correction.requester.relationship": "ANOTHER_AGENT",
|
5573
|
-
"correction.request.reason": "Child's name was incorrect"
|
5574
|
-
},
|
5575
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
5576
|
-
createdBy: "@todo",
|
5577
|
-
createdByRole: "@todo",
|
5578
|
-
createdAtLocation: "@todo"
|
5579
|
-
}
|
5580
|
-
},
|
5581
|
-
input
|
5582
|
-
),
|
5583
|
-
actions: {
|
5584
|
-
declare: (eventId, input = {}) => ({
|
5585
|
-
type: ActionType.DECLARE,
|
5586
|
-
transactionId: input.transactionId ?? getUUID(),
|
5587
|
-
declaration: input.declaration ?? generateActionDeclarationInput(
|
5588
|
-
tennisClubMembershipEvent,
|
5589
|
-
ActionType.DECLARE
|
5590
|
-
),
|
5591
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5592
|
-
tennisClubMembershipEvent,
|
5593
|
-
ActionType.DECLARE
|
5594
|
-
),
|
5595
|
-
eventId
|
5596
|
-
}),
|
5597
|
-
/**
|
5598
|
-
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
5599
|
-
*/
|
5600
|
-
notify: (eventId, input = {}) => {
|
5601
|
-
let declaration = input.declaration;
|
5602
|
-
if (!declaration) {
|
5603
|
-
const partialDeclaration = (0, import_lodash2.omitBy)(
|
5604
|
-
generateActionDeclarationInput(
|
5605
|
-
tennisClubMembershipEvent,
|
5606
|
-
ActionType.DECLARE
|
5607
|
-
),
|
5608
|
-
import_lodash2.isString
|
5609
|
-
);
|
5610
|
-
declaration = partialDeclaration;
|
5611
|
-
}
|
5612
|
-
return {
|
5613
|
-
type: ActionType.NOTIFY,
|
5614
|
-
transactionId: input.transactionId ?? getUUID(),
|
5615
|
-
declaration,
|
5616
|
-
eventId
|
5617
|
-
};
|
5618
|
-
},
|
5619
|
-
validate: (eventId, input = {}) => ({
|
5620
|
-
type: ActionType.VALIDATE,
|
5621
|
-
transactionId: input.transactionId ?? getUUID(),
|
5622
|
-
declaration: input.declaration ?? generateActionDeclarationInput(
|
5623
|
-
tennisClubMembershipEvent,
|
5624
|
-
ActionType.VALIDATE
|
5625
|
-
),
|
5626
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5627
|
-
tennisClubMembershipEvent,
|
5628
|
-
ActionType.VALIDATE
|
5629
|
-
),
|
5630
|
-
duplicates: [],
|
5631
|
-
eventId
|
5632
|
-
}),
|
5633
|
-
assign: (eventId, input = {}) => ({
|
5634
|
-
type: ActionType.ASSIGN,
|
5635
|
-
transactionId: input.transactionId ?? getUUID(),
|
5636
|
-
declaration: {},
|
5637
|
-
assignedTo: input.assignedTo ?? getUUID(),
|
5638
|
-
eventId
|
5639
|
-
}),
|
5640
|
-
unassign: (eventId, input = {}) => ({
|
5641
|
-
type: ActionType.UNASSIGN,
|
5642
|
-
transactionId: input.transactionId ?? getUUID(),
|
5643
|
-
declaration: {},
|
5644
|
-
assignedTo: null,
|
5645
|
-
eventId
|
5646
|
-
}),
|
5647
|
-
archive: (eventId, input = {}, isDuplicate) => ({
|
5648
|
-
type: ActionType.ARCHIVE,
|
5649
|
-
transactionId: input.transactionId ?? getUUID(),
|
5650
|
-
declaration: {},
|
5651
|
-
// @TODO: Check whether generator is needed?
|
5652
|
-
annotation: {},
|
5653
|
-
duplicates: [],
|
5654
|
-
eventId,
|
5655
|
-
reason: {
|
5656
|
-
message: `${ActionType.ARCHIVE}`,
|
5657
|
-
isDuplicate: isDuplicate ?? false
|
5658
|
-
}
|
5659
|
-
}),
|
5660
|
-
reject: (eventId, input = {}) => ({
|
5661
|
-
type: ActionType.REJECT,
|
5662
|
-
transactionId: input.transactionId ?? getUUID(),
|
5663
|
-
declaration: {},
|
5664
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5665
|
-
tennisClubMembershipEvent,
|
5666
|
-
ActionType.REJECT
|
5667
|
-
),
|
5668
|
-
duplicates: [],
|
5669
|
-
eventId,
|
5670
|
-
reason: { message: `${ActionType.REJECT}` }
|
5671
|
-
}),
|
5672
|
-
register: (eventId, input = {}) => ({
|
5673
|
-
type: ActionType.REGISTER,
|
6273
|
+
function eventPayloadGenerator(rng) {
|
6274
|
+
return {
|
6275
|
+
create: (input = {}) => ({
|
5674
6276
|
transactionId: input.transactionId ?? getUUID(),
|
5675
|
-
|
5676
|
-
tennisClubMembershipEvent,
|
5677
|
-
ActionType.REGISTER
|
5678
|
-
),
|
5679
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5680
|
-
tennisClubMembershipEvent,
|
5681
|
-
ActionType.REGISTER
|
5682
|
-
),
|
5683
|
-
eventId
|
6277
|
+
type: input.type ?? TENNIS_CLUB_MEMBERSHIP
|
5684
6278
|
}),
|
5685
|
-
|
5686
|
-
type: ActionType.PRINT_CERTIFICATE,
|
6279
|
+
patch: (id, input = {}) => ({
|
5687
6280
|
transactionId: input.transactionId ?? getUUID(),
|
5688
|
-
|
5689
|
-
|
5690
|
-
tennisClubMembershipEvent,
|
5691
|
-
ActionType.PRINT_CERTIFICATE
|
5692
|
-
),
|
5693
|
-
eventId
|
6281
|
+
type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
|
6282
|
+
id
|
5694
6283
|
}),
|
5695
|
-
|
5696
|
-
|
5697
|
-
|
6284
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
6285
|
+
{
|
6286
|
+
id: getUUID(),
|
6287
|
+
eventId,
|
6288
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
6289
|
+
transactionId: getUUID(),
|
6290
|
+
action: {
|
6291
|
+
transactionId: getUUID(),
|
6292
|
+
type: actionType,
|
6293
|
+
status: ActionStatus.Accepted,
|
6294
|
+
declaration: {
|
6295
|
+
"applicant.name": {
|
6296
|
+
firstname: "Max",
|
6297
|
+
surname: "McLaren"
|
6298
|
+
},
|
6299
|
+
"applicant.dob": "2020-01-02",
|
6300
|
+
"recommender.none": true
|
6301
|
+
},
|
6302
|
+
annotation: {
|
6303
|
+
"correction.requester.relationship": "ANOTHER_AGENT",
|
6304
|
+
"correction.request.reason": "Child's name was incorrect"
|
6305
|
+
},
|
6306
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
6307
|
+
createdBy: "@todo",
|
6308
|
+
createdByUserType: TokenUserType.Enum.user,
|
6309
|
+
createdByRole: "@todo",
|
6310
|
+
createdAtLocation: "@todo"
|
6311
|
+
}
|
6312
|
+
},
|
6313
|
+
input
|
6314
|
+
),
|
6315
|
+
actions: {
|
6316
|
+
declare: (eventId, input = {}) => ({
|
6317
|
+
type: ActionType.DECLARE,
|
5698
6318
|
transactionId: input.transactionId ?? getUUID(),
|
5699
6319
|
declaration: input.declaration ?? generateActionDeclarationInput(
|
5700
6320
|
tennisClubMembershipEvent,
|
5701
|
-
ActionType.
|
6321
|
+
ActionType.DECLARE,
|
6322
|
+
rng
|
5702
6323
|
),
|
5703
6324
|
annotation: input.annotation ?? generateActionAnnotationInput(
|
5704
6325
|
tennisClubMembershipEvent,
|
5705
|
-
ActionType.
|
6326
|
+
ActionType.DECLARE,
|
6327
|
+
rng
|
5706
6328
|
),
|
6329
|
+
eventId,
|
6330
|
+
...input
|
6331
|
+
}),
|
6332
|
+
/**
|
6333
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
6334
|
+
*/
|
6335
|
+
notify: (eventId, input = {}) => {
|
6336
|
+
let declaration = input.declaration;
|
6337
|
+
if (!declaration) {
|
6338
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
6339
|
+
generateActionDeclarationInput(
|
6340
|
+
tennisClubMembershipEvent,
|
6341
|
+
ActionType.DECLARE,
|
6342
|
+
rng
|
6343
|
+
),
|
6344
|
+
import_lodash2.isString
|
6345
|
+
);
|
6346
|
+
declaration = partialDeclaration;
|
6347
|
+
}
|
6348
|
+
return {
|
6349
|
+
type: ActionType.NOTIFY,
|
6350
|
+
transactionId: input.transactionId ?? getUUID(),
|
6351
|
+
declaration,
|
6352
|
+
eventId,
|
6353
|
+
keepAssignment: input.keepAssignment
|
6354
|
+
};
|
6355
|
+
},
|
6356
|
+
validate: (eventId, input = {}) => ({
|
6357
|
+
type: ActionType.VALIDATE,
|
6358
|
+
transactionId: input.transactionId ?? getUUID(),
|
6359
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
6360
|
+
tennisClubMembershipEvent,
|
6361
|
+
ActionType.VALIDATE,
|
6362
|
+
rng
|
6363
|
+
),
|
6364
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6365
|
+
tennisClubMembershipEvent,
|
6366
|
+
ActionType.VALIDATE,
|
6367
|
+
rng
|
6368
|
+
),
|
6369
|
+
duplicates: [],
|
6370
|
+
eventId,
|
6371
|
+
...input
|
6372
|
+
}),
|
6373
|
+
assign: (eventId, input = {}) => ({
|
6374
|
+
type: ActionType.ASSIGN,
|
6375
|
+
transactionId: input.transactionId ?? getUUID(),
|
6376
|
+
declaration: {},
|
6377
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
6378
|
+
eventId
|
6379
|
+
}),
|
6380
|
+
unassign: (eventId, input = {}) => ({
|
6381
|
+
type: ActionType.UNASSIGN,
|
6382
|
+
transactionId: input.transactionId ?? getUUID(),
|
6383
|
+
declaration: {},
|
6384
|
+
assignedTo: null,
|
5707
6385
|
eventId
|
5708
6386
|
}),
|
5709
|
-
|
5710
|
-
type: ActionType.
|
6387
|
+
archive: (eventId, input = {}, isDuplicate) => ({
|
6388
|
+
type: ActionType.ARCHIVE,
|
6389
|
+
transactionId: input.transactionId ?? getUUID(),
|
6390
|
+
declaration: {},
|
6391
|
+
// @TODO: Check whether generator is needed?
|
6392
|
+
annotation: {},
|
6393
|
+
duplicates: [],
|
6394
|
+
eventId,
|
6395
|
+
reason: {
|
6396
|
+
message: `${ActionType.ARCHIVE}`,
|
6397
|
+
isDuplicate: isDuplicate ?? false
|
6398
|
+
},
|
6399
|
+
...input
|
6400
|
+
}),
|
6401
|
+
reject: (eventId, input = {}) => ({
|
6402
|
+
type: ActionType.REJECT,
|
5711
6403
|
transactionId: input.transactionId ?? getUUID(),
|
5712
6404
|
declaration: {},
|
5713
6405
|
annotation: input.annotation ?? generateActionAnnotationInput(
|
5714
6406
|
tennisClubMembershipEvent,
|
5715
|
-
ActionType.
|
6407
|
+
ActionType.REJECT,
|
6408
|
+
rng
|
5716
6409
|
),
|
6410
|
+
duplicates: [],
|
5717
6411
|
eventId,
|
5718
|
-
|
6412
|
+
reason: { message: `${ActionType.REJECT}` },
|
6413
|
+
...input
|
5719
6414
|
}),
|
5720
|
-
|
5721
|
-
type: ActionType.
|
6415
|
+
register: (eventId, input = {}) => ({
|
6416
|
+
type: ActionType.REGISTER,
|
6417
|
+
transactionId: input.transactionId ?? getUUID(),
|
6418
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
6419
|
+
tennisClubMembershipEvent,
|
6420
|
+
ActionType.REGISTER,
|
6421
|
+
rng
|
6422
|
+
),
|
6423
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6424
|
+
tennisClubMembershipEvent,
|
6425
|
+
ActionType.REGISTER,
|
6426
|
+
rng
|
6427
|
+
),
|
6428
|
+
eventId,
|
6429
|
+
...input
|
6430
|
+
}),
|
6431
|
+
printCertificate: (eventId, input = {}) => ({
|
6432
|
+
type: ActionType.PRINT_CERTIFICATE,
|
5722
6433
|
transactionId: input.transactionId ?? getUUID(),
|
5723
6434
|
declaration: {},
|
5724
6435
|
annotation: input.annotation ?? generateActionAnnotationInput(
|
5725
6436
|
tennisClubMembershipEvent,
|
5726
|
-
ActionType.
|
6437
|
+
ActionType.PRINT_CERTIFICATE,
|
6438
|
+
rng
|
5727
6439
|
),
|
5728
6440
|
eventId,
|
5729
|
-
|
5730
|
-
})
|
6441
|
+
...input
|
6442
|
+
}),
|
6443
|
+
correction: {
|
6444
|
+
request: (eventId, input = {}) => ({
|
6445
|
+
type: ActionType.REQUEST_CORRECTION,
|
6446
|
+
transactionId: input.transactionId ?? getUUID(),
|
6447
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
6448
|
+
tennisClubMembershipEvent,
|
6449
|
+
ActionType.REQUEST_CORRECTION,
|
6450
|
+
rng
|
6451
|
+
),
|
6452
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6453
|
+
tennisClubMembershipEvent,
|
6454
|
+
ActionType.REQUEST_CORRECTION,
|
6455
|
+
rng
|
6456
|
+
),
|
6457
|
+
eventId,
|
6458
|
+
keepAssignment: input.keepAssignment
|
6459
|
+
}),
|
6460
|
+
approve: (eventId, requestId, input = {}) => ({
|
6461
|
+
type: ActionType.APPROVE_CORRECTION,
|
6462
|
+
transactionId: input.transactionId ?? getUUID(),
|
6463
|
+
declaration: {},
|
6464
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6465
|
+
tennisClubMembershipEvent,
|
6466
|
+
ActionType.APPROVE_CORRECTION,
|
6467
|
+
rng
|
6468
|
+
),
|
6469
|
+
eventId,
|
6470
|
+
requestId,
|
6471
|
+
keepAssignment: input.keepAssignment
|
6472
|
+
}),
|
6473
|
+
reject: (eventId, requestId, input = {}) => ({
|
6474
|
+
type: ActionType.REJECT_CORRECTION,
|
6475
|
+
transactionId: input.transactionId ?? getUUID(),
|
6476
|
+
declaration: {},
|
6477
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6478
|
+
tennisClubMembershipEvent,
|
6479
|
+
ActionType.REJECT_CORRECTION,
|
6480
|
+
rng
|
6481
|
+
),
|
6482
|
+
eventId,
|
6483
|
+
requestId,
|
6484
|
+
keepAssignment: input.keepAssignment
|
6485
|
+
})
|
6486
|
+
}
|
5731
6487
|
}
|
5732
|
-
}
|
5733
|
-
}
|
6488
|
+
};
|
6489
|
+
}
|
5734
6490
|
function generateActionDocument({
|
5735
6491
|
configuration,
|
5736
6492
|
action,
|
6493
|
+
rng = () => 0.1,
|
5737
6494
|
defaults = {}
|
5738
6495
|
}) {
|
5739
6496
|
const actionBase = {
|
@@ -5741,10 +6498,11 @@ function generateActionDocument({
|
|
5741
6498
|
// @TODO: This should be fixed in the future.
|
5742
6499
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
5743
6500
|
createdBy: getUUID(),
|
5744
|
-
|
6501
|
+
createdByUserType: TokenUserType.Enum.user,
|
6502
|
+
createdByRole: TestUserRole.Enum.FIELD_AGENT,
|
5745
6503
|
id: getUUID(),
|
5746
6504
|
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
5747
|
-
declaration: generateActionDeclarationInput(configuration, action),
|
6505
|
+
declaration: generateActionDeclarationInput(configuration, action, rng),
|
5748
6506
|
annotation: {},
|
5749
6507
|
status: ActionStatus.Accepted,
|
5750
6508
|
transactionId: getUUID(),
|
@@ -5796,13 +6554,14 @@ function generateActionDocument({
|
|
5796
6554
|
}
|
5797
6555
|
function generateEventDocument({
|
5798
6556
|
configuration,
|
5799
|
-
actions
|
6557
|
+
actions,
|
6558
|
+
rng = () => 0.1
|
5800
6559
|
}) {
|
5801
6560
|
return {
|
5802
6561
|
trackingId: getUUID(),
|
5803
6562
|
type: configuration.id,
|
5804
6563
|
actions: actions.map(
|
5805
|
-
(action) => generateActionDocument({ configuration, action })
|
6564
|
+
(action) => generateActionDocument({ configuration, action, rng })
|
5806
6565
|
),
|
5807
6566
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
5808
6567
|
// @TODO: This should be fixed in the future.
|
@@ -5813,10 +6572,16 @@ function generateEventDocument({
|
|
5813
6572
|
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
5814
6573
|
};
|
5815
6574
|
}
|
5816
|
-
function generateEventDraftDocument(
|
6575
|
+
function generateEventDraftDocument({
|
6576
|
+
eventId,
|
6577
|
+
actionType,
|
6578
|
+
rng = () => 0.1,
|
6579
|
+
declaration = {}
|
6580
|
+
}) {
|
5817
6581
|
const action = generateActionDocument({
|
5818
6582
|
configuration: tennisClubMembershipEvent,
|
5819
|
-
action: actionType
|
6583
|
+
action: actionType,
|
6584
|
+
rng
|
5820
6585
|
});
|
5821
6586
|
return {
|
5822
6587
|
id: getUUID(),
|
@@ -5832,51 +6597,29 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
5832
6597
|
eventId
|
5833
6598
|
};
|
5834
6599
|
}
|
5835
|
-
function pickRandom(rng, items) {
|
5836
|
-
return items[Math.floor(rng() * items.length)];
|
5837
|
-
}
|
5838
6600
|
function getRandomDatetime(rng, start, end) {
|
5839
6601
|
const range = end.getTime() - start.getTime();
|
5840
6602
|
const offset = Math.floor(rng() * range);
|
5841
6603
|
const randomDate = new Date(start.getTime() + offset);
|
5842
6604
|
return randomDate.toISOString();
|
5843
6605
|
}
|
6606
|
+
function getRandomDate(rng, start, end) {
|
6607
|
+
const datetime = getRandomDatetime(rng, new Date(start), new Date(end));
|
6608
|
+
return datetime.split("T")[0];
|
6609
|
+
}
|
5844
6610
|
function generateRandomApplicant(rng) {
|
5845
|
-
const
|
5846
|
-
|
5847
|
-
"John",
|
5848
|
-
"Jane",
|
5849
|
-
"Emily",
|
5850
|
-
"Michael",
|
5851
|
-
"Sarah",
|
5852
|
-
"Chris",
|
5853
|
-
"Jessica"
|
5854
|
-
];
|
5855
|
-
const surnames = [
|
5856
|
-
"Doe",
|
5857
|
-
"Smith",
|
5858
|
-
"Johnson",
|
5859
|
-
"Brown",
|
5860
|
-
"Williams",
|
5861
|
-
"Jones",
|
5862
|
-
"Garcia",
|
5863
|
-
"Miller"
|
5864
|
-
];
|
5865
|
-
const randomFirstName = pickRandom(rng, firstNames);
|
5866
|
-
const randomSurname = pickRandom(rng, surnames);
|
5867
|
-
const randomDob = getRandomDatetime(
|
5868
|
-
rng,
|
5869
|
-
/* @__PURE__ */ new Date("1990-01-01"),
|
5870
|
-
/* @__PURE__ */ new Date("2010-12-31")
|
5871
|
-
).split("T")[0];
|
6611
|
+
const { firstname, surname } = generateRandomName(rng);
|
6612
|
+
const randomDob = getRandomDate(rng, "1990-01-01", "2010-12-31");
|
5872
6613
|
return {
|
5873
6614
|
"recommender.none": true,
|
5874
|
-
"applicant.
|
5875
|
-
|
6615
|
+
"applicant.name": {
|
6616
|
+
firstname,
|
6617
|
+
surname
|
6618
|
+
},
|
5876
6619
|
"applicant.dob": randomDob
|
5877
6620
|
};
|
5878
6621
|
}
|
5879
|
-
function
|
6622
|
+
function createPrng(seed) {
|
5880
6623
|
const MODULUS = 2 ** 32;
|
5881
6624
|
const MULTIPLIER = 1664525;
|
5882
6625
|
const INCREMENT = 1013904223;
|
@@ -5902,7 +6645,7 @@ function generateRandomSignature(rng) {
|
|
5902
6645
|
return `/random-bucket/${generateUuid(rng)}.png`;
|
5903
6646
|
}
|
5904
6647
|
var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
5905
|
-
const rng =
|
6648
|
+
const rng = createPrng(seed);
|
5906
6649
|
const createdAt = getRandomDatetime(
|
5907
6650
|
rng,
|
5908
6651
|
/* @__PURE__ */ new Date("2024-01-01"),
|
@@ -5911,8 +6654,9 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
5911
6654
|
return {
|
5912
6655
|
id: overrides.id ?? generateUuid(rng),
|
5913
6656
|
type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
|
5914
|
-
status: overrides.status ?? pickRandom(rng,
|
6657
|
+
status: overrides.status ?? pickRandom(rng, EventStatus.options),
|
5915
6658
|
createdAt: overrides.createdAt ?? createdAt,
|
6659
|
+
createdByUserType: overrides.createdByUserType ?? "user",
|
5916
6660
|
createdBy: overrides.createdBy ?? generateUuid(rng),
|
5917
6661
|
createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
|
5918
6662
|
updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
|
@@ -5965,7 +6709,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
5965
6709
|
if (isTemplateVariable(value)) {
|
5966
6710
|
return false;
|
5967
6711
|
}
|
5968
|
-
if (typeof value === "object" &&
|
6712
|
+
if (typeof value === "object" && // @todo remove ts-ignore
|
6713
|
+
//@ts-ignore
|
6714
|
+
Object.values(value).some((val) => isTemplateVariable(val))) {
|
5969
6715
|
return false;
|
5970
6716
|
}
|
5971
6717
|
return true;
|
@@ -5988,234 +6734,6 @@ function isFieldConfigDefaultValue(value) {
|
|
5988
6734
|
|
5989
6735
|
// ../commons/src/events/scopes.ts
|
5990
6736
|
var import_lodash3 = require("lodash");
|
5991
|
-
|
5992
|
-
// ../commons/src/scopes.ts
|
5993
|
-
var import_zod31 = require("zod");
|
5994
|
-
var SCOPES = {
|
5995
|
-
// TODO v1.8 legacy scopes
|
5996
|
-
NATLSYSADMIN: "natlsysadmin",
|
5997
|
-
BYPASSRATELIMIT: "bypassratelimit",
|
5998
|
-
DECLARE: "declare",
|
5999
|
-
REGISTER: "register",
|
6000
|
-
VALIDATE: "validate",
|
6001
|
-
DEMO: "demo",
|
6002
|
-
CERTIFY: "certify",
|
6003
|
-
PERFORMANCE: "performance",
|
6004
|
-
SYSADMIN: "sysadmin",
|
6005
|
-
TEAMS: "teams",
|
6006
|
-
CONFIG: "config",
|
6007
|
-
// systems / integrations
|
6008
|
-
WEBHOOK: "webhook",
|
6009
|
-
NATIONALID: "nationalId",
|
6010
|
-
NOTIFICATION_API: "notification-api",
|
6011
|
-
RECORDSEARCH: "recordsearch",
|
6012
|
-
/**
|
6013
|
-
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
6014
|
-
*/
|
6015
|
-
RECORD_DECLARE: "record.declare-birth",
|
6016
|
-
// declare
|
6017
|
-
RECORD_IMPORT: "record.import",
|
6018
|
-
// declare
|
6019
|
-
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
6020
|
-
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
6021
|
-
RECORD_DECLARE_DEATH: "record.declare-death",
|
6022
|
-
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
6023
|
-
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
6024
|
-
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
6025
|
-
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
6026
|
-
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
6027
|
-
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
6028
|
-
// validate
|
6029
|
-
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
6030
|
-
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
6031
|
-
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
6032
|
-
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
6033
|
-
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
6034
|
-
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
6035
|
-
// register
|
6036
|
-
RECORD_REGISTER: "record.register",
|
6037
|
-
// certify
|
6038
|
-
RECORD_EXPORT_RECORDS: "record.export-records",
|
6039
|
-
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
6040
|
-
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
6041
|
-
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
6042
|
-
// v1.8
|
6043
|
-
/**
|
6044
|
-
* This scope is used to **print and **issue certified copies of a record
|
6045
|
-
* after it has been registered. Previously Registrars had this permission.
|
6046
|
-
*/
|
6047
|
-
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
6048
|
-
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
6049
|
-
// v1.8
|
6050
|
-
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
6051
|
-
// v1.8
|
6052
|
-
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
6053
|
-
// v1.8
|
6054
|
-
// correct
|
6055
|
-
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
6056
|
-
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
6057
|
-
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
6058
|
-
// v1.8
|
6059
|
-
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
6060
|
-
// v1.8
|
6061
|
-
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
6062
|
-
// v1.8
|
6063
|
-
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
6064
|
-
// v1.8
|
6065
|
-
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
6066
|
-
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
6067
|
-
// search
|
6068
|
-
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
6069
|
-
SEARCH_BIRTH: "search.birth",
|
6070
|
-
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
6071
|
-
SEARCH_DEATH: "search.death",
|
6072
|
-
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
6073
|
-
SEARCH_MARRIAGE: "search.marriage",
|
6074
|
-
// audit v1.8
|
6075
|
-
RECORD_READ: "record.read",
|
6076
|
-
RECORD_READ_AUDIT: "record.read-audit",
|
6077
|
-
RECORD_READ_COMMENTS: "record.read-comments",
|
6078
|
-
RECORD_CREATE_COMMENTS: "record.create-comments",
|
6079
|
-
// profile
|
6080
|
-
PROFILE_UPDATE: "profile.update",
|
6081
|
-
//v1.8
|
6082
|
-
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
6083
|
-
// performance
|
6084
|
-
PERFORMANCE_READ: "performance.read",
|
6085
|
-
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
6086
|
-
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
6087
|
-
// organisation
|
6088
|
-
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
6089
|
-
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
6090
|
-
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
6091
|
-
// user
|
6092
|
-
USER_READ: "user.read:all",
|
6093
|
-
USER_READ_MY_OFFICE: "user.read:my-office",
|
6094
|
-
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
6095
|
-
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
6096
|
-
//v1.8
|
6097
|
-
USER_CREATE: "user.create:all",
|
6098
|
-
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
6099
|
-
USER_UPDATE: "user.update:all",
|
6100
|
-
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
6101
|
-
// config
|
6102
|
-
CONFIG_UPDATE_ALL: "config.update:all",
|
6103
|
-
// data seeding
|
6104
|
-
USER_DATA_SEEDING: "user.data-seeding"
|
6105
|
-
};
|
6106
|
-
var LiteralScopes = import_zod31.z.union([
|
6107
|
-
import_zod31.z.literal(SCOPES.NATLSYSADMIN),
|
6108
|
-
import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
|
6109
|
-
import_zod31.z.literal(SCOPES.DECLARE),
|
6110
|
-
import_zod31.z.literal(SCOPES.REGISTER),
|
6111
|
-
import_zod31.z.literal(SCOPES.VALIDATE),
|
6112
|
-
import_zod31.z.literal(SCOPES.DEMO),
|
6113
|
-
import_zod31.z.literal(SCOPES.CERTIFY),
|
6114
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE),
|
6115
|
-
import_zod31.z.literal(SCOPES.SYSADMIN),
|
6116
|
-
import_zod31.z.literal(SCOPES.TEAMS),
|
6117
|
-
import_zod31.z.literal(SCOPES.CONFIG),
|
6118
|
-
import_zod31.z.literal(SCOPES.WEBHOOK),
|
6119
|
-
import_zod31.z.literal(SCOPES.NATIONALID),
|
6120
|
-
import_zod31.z.literal(SCOPES.NOTIFICATION_API),
|
6121
|
-
import_zod31.z.literal(SCOPES.RECORDSEARCH),
|
6122
|
-
import_zod31.z.literal(SCOPES.RECORD_IMPORT),
|
6123
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
6124
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
6125
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
6126
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
6127
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
6128
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
6129
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
6130
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
6131
|
-
import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
6132
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
6133
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
6134
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
6135
|
-
import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
6136
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
6137
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
6138
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTER),
|
6139
|
-
import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
6140
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
6141
|
-
import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
6142
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
6143
|
-
import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
6144
|
-
import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
6145
|
-
import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
6146
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
6147
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
6148
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
6149
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
6150
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
6151
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
6152
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
6153
|
-
import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
6154
|
-
import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
6155
|
-
import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
6156
|
-
import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
|
6157
|
-
import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
6158
|
-
import_zod31.z.literal(SCOPES.SEARCH_DEATH),
|
6159
|
-
import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
6160
|
-
import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
|
6161
|
-
import_zod31.z.literal(SCOPES.RECORD_READ),
|
6162
|
-
import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
|
6163
|
-
import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
6164
|
-
import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
6165
|
-
import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
|
6166
|
-
import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
6167
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
|
6168
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
6169
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
6170
|
-
import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
6171
|
-
import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
6172
|
-
import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
6173
|
-
import_zod31.z.literal(SCOPES.USER_READ),
|
6174
|
-
import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
6175
|
-
import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
6176
|
-
import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
6177
|
-
import_zod31.z.literal(SCOPES.USER_CREATE),
|
6178
|
-
import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
6179
|
-
import_zod31.z.literal(SCOPES.USER_UPDATE),
|
6180
|
-
import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
6181
|
-
import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
6182
|
-
import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
|
6183
|
-
]);
|
6184
|
-
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
6185
|
-
var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
|
6186
|
-
var CreateUserScope = import_zod31.z.object({
|
6187
|
-
type: import_zod31.z.literal("user.create"),
|
6188
|
-
options: import_zod31.z.object({
|
6189
|
-
role: import_zod31.z.array(import_zod31.z.string())
|
6190
|
-
})
|
6191
|
-
});
|
6192
|
-
var EditUserScope = import_zod31.z.object({
|
6193
|
-
type: import_zod31.z.literal("user.edit"),
|
6194
|
-
options: import_zod31.z.object({
|
6195
|
-
role: import_zod31.z.array(import_zod31.z.string())
|
6196
|
-
})
|
6197
|
-
});
|
6198
|
-
var WorkqueueScope = import_zod31.z.object({
|
6199
|
-
type: import_zod31.z.literal("workqueue"),
|
6200
|
-
options: import_zod31.z.object({
|
6201
|
-
id: import_zod31.z.array(import_zod31.z.string())
|
6202
|
-
})
|
6203
|
-
});
|
6204
|
-
var NotifyRecordScope = import_zod31.z.object({
|
6205
|
-
type: import_zod31.z.literal("record.notify"),
|
6206
|
-
options: import_zod31.z.object({
|
6207
|
-
event: import_zod31.z.array(import_zod31.z.string())
|
6208
|
-
})
|
6209
|
-
});
|
6210
|
-
var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
|
6211
|
-
CreateUserScope,
|
6212
|
-
EditUserScope,
|
6213
|
-
WorkqueueScope,
|
6214
|
-
NotifyRecordScope
|
6215
|
-
]);
|
6216
|
-
var scopes = Object.values(SCOPES);
|
6217
|
-
|
6218
|
-
// ../commons/src/events/scopes.ts
|
6219
6737
|
var CONFIG_GET_ALLOWED_SCOPES = [
|
6220
6738
|
SCOPES.RECORD_DECLARE,
|
6221
6739
|
SCOPES.RECORD_READ,
|
@@ -6292,6 +6810,12 @@ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
|
|
6292
6810
|
[ActionType.UNASSIGN]: [],
|
6293
6811
|
[ActionType.DETECT_DUPLICATE]: []
|
6294
6812
|
};
|
6813
|
+
var WRITE_ACTION_SCOPES = [
|
6814
|
+
...ACTION_ALLOWED_SCOPES[ActionType.DECLARE],
|
6815
|
+
...ACTION_ALLOWED_SCOPES[ActionType.VALIDATE],
|
6816
|
+
...ACTION_ALLOWED_SCOPES[ActionType.REGISTER],
|
6817
|
+
...ACTION_ALLOWED_SCOPES[ActionType.PRINT_CERTIFICATE]
|
6818
|
+
];
|
6295
6819
|
function hasAnyOfScopes(a, b) {
|
6296
6820
|
return (0, import_lodash3.intersection)(a, b).length > 0;
|
6297
6821
|
}
|
@@ -6311,11 +6835,44 @@ function filterUnallowedActions(actions, userScopes) {
|
|
6311
6835
|
}
|
6312
6836
|
return [ActionType.READ];
|
6313
6837
|
}
|
6838
|
+
function getUserActionsByStatus(status, assignmentActions, userScopes) {
|
6839
|
+
switch (status) {
|
6840
|
+
case EventStatus.enum.CREATED: {
|
6841
|
+
return [ActionType.READ, ActionType.DECLARE, ActionType.DELETE];
|
6842
|
+
}
|
6843
|
+
case EventStatus.enum.NOTIFIED:
|
6844
|
+
case EventStatus.enum.DECLARED: {
|
6845
|
+
return [...assignmentActions, ActionType.READ, ActionType.VALIDATE];
|
6846
|
+
}
|
6847
|
+
case EventStatus.enum.VALIDATED: {
|
6848
|
+
return [...assignmentActions, ActionType.READ, ActionType.REGISTER];
|
6849
|
+
}
|
6850
|
+
case EventStatus.enum.CERTIFIED:
|
6851
|
+
case EventStatus.enum.REGISTERED: {
|
6852
|
+
return [
|
6853
|
+
...assignmentActions,
|
6854
|
+
ActionType.READ,
|
6855
|
+
ActionType.PRINT_CERTIFICATE,
|
6856
|
+
ActionType.REQUEST_CORRECTION
|
6857
|
+
];
|
6858
|
+
}
|
6859
|
+
case EventStatus.enum.REJECTED: {
|
6860
|
+
const validateScopes = ACTION_ALLOWED_SCOPES[ActionType.VALIDATE];
|
6861
|
+
const canValidate = hasAnyOfScopes(userScopes, validateScopes);
|
6862
|
+
const declarationAction = canValidate ? ActionType.VALIDATE : ActionType.DECLARE;
|
6863
|
+
return [...assignmentActions, ActionType.READ, declarationAction];
|
6864
|
+
}
|
6865
|
+
case EventStatus.enum.ARCHIVED:
|
6866
|
+
return [...assignmentActions, ActionType.READ];
|
6867
|
+
default:
|
6868
|
+
return [ActionType.READ];
|
6869
|
+
}
|
6870
|
+
}
|
6314
6871
|
|
6315
6872
|
// ../commons/src/events/serializers/user/deserializer.ts
|
6316
|
-
var
|
6873
|
+
var import_zod34 = require("zod");
|
6317
6874
|
var UserWithPrimaryOffice = User.extend({
|
6318
|
-
primaryOfficeId:
|
6875
|
+
primaryOfficeId: import_zod34.z.string()
|
6319
6876
|
});
|
6320
6877
|
function userDeserializer(serializedUserField, user2) {
|
6321
6878
|
if (typeof serializedUserField === "string") {
|
@@ -6335,6 +6892,7 @@ function deserializeQueryExpression(expression, user2) {
|
|
6335
6892
|
...expression.assignedTo,
|
6336
6893
|
term: userDeserializer(expression.assignedTo.term, user2)
|
6337
6894
|
},
|
6895
|
+
createdByUserType: expression.createdByUserType,
|
6338
6896
|
createdBy: expression.createdBy && {
|
6339
6897
|
...expression.createdBy,
|
6340
6898
|
term: userDeserializer(expression.createdBy.term, user2)
|
@@ -6370,6 +6928,8 @@ function deserializeQuery(query, user2) {
|
|
6370
6928
|
...query,
|
6371
6929
|
clauses: query.clauses.map(
|
6372
6930
|
(clause) => deserializeQueryExpression(clause, user2)
|
6931
|
+
// SAFETY: This cast should be safe because `query.clauses` has already been validated as non-empty by the Zod schema.
|
6932
|
+
// Without the cast, TypeScript cannot infer the tuple type required by the target interface.
|
6373
6933
|
)
|
6374
6934
|
};
|
6375
6935
|
}
|