@opencrvs/toolkit 1.8.0-rc.fb5b9fe → 1.8.0-rc.fb8e005
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 +5924 -8783
- 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 +21534 -6326
- package/dist/commons/events/ActionDocument.d.ts +1783 -280
- package/dist/commons/events/ActionInput.d.ts +1382 -182
- package/dist/commons/events/ActionType.d.ts +4 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +279 -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 +1161 -413
- package/dist/commons/events/Draft.d.ts +118 -17
- package/dist/commons/events/EventConfig.d.ts +11557 -4116
- package/dist/commons/events/EventDocument.d.ts +1144 -205
- package/dist/commons/events/EventIndex.d.ts +839 -185
- package/dist/commons/events/EventMetadata.d.ts +52 -40
- package/dist/commons/events/FieldConfig.d.ts +1896 -872
- 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 +8840 -2444
- package/dist/commons/events/PageConfig.d.ts +3104 -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 +4460 -1685
- package/dist/commons/events/defineConfig.d.ts +1279 -17
- package/dist/commons/events/field.d.ts +9 -0
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/scopes.d.ts +1 -2
- package/dist/commons/events/test.utils.d.ts +146 -38
- package/dist/commons/events/utils.d.ts +10117 -10
- package/dist/conditionals/index.js +38 -18
- package/dist/events/index.js +1718 -1057
- package/dist/scopes/index.d.ts +4 -1
- package/dist/scopes/index.js +67 -17
- package/package.json +3 -3
package/dist/events/index.js
CHANGED
@@ -32,6 +32,7 @@ var events_exports = {};
|
|
32
32
|
__export(events_exports, {
|
33
33
|
ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
|
34
34
|
ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
|
35
|
+
AVAILABLE_ACTIONS_BY_EVENT_STATUS: () => AVAILABLE_ACTIONS_BY_EVENT_STATUS,
|
35
36
|
Action: () => Action,
|
36
37
|
ActionBase: () => ActionBase,
|
37
38
|
ActionConditional: () => ActionConditional,
|
@@ -56,6 +57,7 @@ __export(events_exports, {
|
|
56
57
|
ArchiveActionInput: () => ArchiveActionInput,
|
57
58
|
AssignActionInput: () => AssignActionInput,
|
58
59
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
60
|
+
BIRTH_EVENT: () => BIRTH_EVENT,
|
59
61
|
BaseActionInput: () => BaseActionInput,
|
60
62
|
BearerTokenByUserType: () => BearerTokenByUserType,
|
61
63
|
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
@@ -67,7 +69,7 @@ __export(events_exports, {
|
|
67
69
|
Conditional: () => Conditional,
|
68
70
|
ConditionalType: () => ConditionalType,
|
69
71
|
ConfirmableActions: () => ConfirmableActions,
|
70
|
-
|
72
|
+
ContainsFlags: () => ContainsFlags,
|
71
73
|
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
72
74
|
DataEntry: () => DataEntry,
|
73
75
|
DataFieldValue: () => DataFieldValue,
|
@@ -101,9 +103,8 @@ __export(events_exports, {
|
|
101
103
|
EventSearchIndex: () => EventSearchIndex,
|
102
104
|
EventState: () => EventState,
|
103
105
|
EventStatus: () => EventStatus,
|
104
|
-
EventStatusEnum: () => EventStatusEnum,
|
105
|
-
EventStatuses: () => EventStatuses,
|
106
106
|
Exact: () => Exact,
|
107
|
+
ExactDate: () => ExactDate,
|
107
108
|
ExactStatus: () => ExactStatus,
|
108
109
|
FieldConditional: () => FieldConditional,
|
109
110
|
FieldConfig: () => FieldConfig,
|
@@ -123,12 +124,14 @@ __export(events_exports, {
|
|
123
124
|
GenericAddressValue: () => GenericAddressValue,
|
124
125
|
GeographicalArea: () => GeographicalArea,
|
125
126
|
ImageMimeType: () => ImageMimeType,
|
127
|
+
InherentFlags: () => InherentFlags,
|
126
128
|
LanguageConfig: () => LanguageConfig,
|
127
129
|
LegalStatuses: () => LegalStatuses,
|
128
130
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
129
131
|
MimeType: () => MimeType,
|
132
|
+
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
133
|
+
NameFieldValue: () => NameFieldValue,
|
130
134
|
NonEmptyTextValue: () => NonEmptyTextValue,
|
131
|
-
Not: () => Not,
|
132
135
|
NotifyActionInput: () => NotifyActionInput,
|
133
136
|
NumberFieldValue: () => NumberFieldValue,
|
134
137
|
PageConfig: () => PageConfig,
|
@@ -138,6 +141,7 @@ __export(events_exports, {
|
|
138
141
|
QueryInput: () => QueryInput,
|
139
142
|
QueryType: () => QueryType,
|
140
143
|
Range: () => Range,
|
144
|
+
RangeDate: () => RangeDate,
|
141
145
|
ReadActionInput: () => ReadActionInput,
|
142
146
|
RegisterAction: () => RegisterAction,
|
143
147
|
RegisterActionInput: () => RegisterActionInput,
|
@@ -156,6 +160,7 @@ __export(events_exports, {
|
|
156
160
|
SignatureFieldValue: () => SignatureFieldValue,
|
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,
|
@@ -163,15 +168,19 @@ __export(events_exports, {
|
|
163
168
|
UrbanAddressValue: () => UrbanAddressValue,
|
164
169
|
User: () => User,
|
165
170
|
ValidateActionInput: () => ValidateActionInput,
|
171
|
+
ValidationConfig: () => ValidationConfig,
|
166
172
|
VerificationActionConfig: () => VerificationActionConfig,
|
167
173
|
VerificationPageConfig: () => VerificationPageConfig,
|
174
|
+
WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
|
168
175
|
Within: () => Within,
|
176
|
+
WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
|
169
177
|
WorkqueueColumn: () => WorkqueueColumn,
|
170
178
|
WorkqueueColumnKeys: () => WorkqueueColumnKeys,
|
171
179
|
WorkqueueColumnKeysArray: () => WorkqueueColumnKeysArray,
|
172
180
|
WorkqueueColumnValue: () => WorkqueueColumnValue,
|
173
181
|
WorkqueueConfig: () => WorkqueueConfig,
|
174
182
|
WorkqueueConfigInput: () => WorkqueueConfigInput,
|
183
|
+
WorkqueueConfigWithoutQuery: () => WorkqueueConfigWithoutQuery,
|
175
184
|
WorkqueueCountInput: () => WorkqueueCountInput,
|
176
185
|
WorkqueueCountOutput: () => WorkqueueCountOutput,
|
177
186
|
ZodDate: () => ZodDate,
|
@@ -184,9 +193,8 @@ __export(events_exports, {
|
|
184
193
|
createEmptyDraft: () => createEmptyDraft,
|
185
194
|
createEventConditionals: () => createEventConditionals,
|
186
195
|
createFieldConditionals: () => createFieldConditionals,
|
187
|
-
|
196
|
+
createPrng: () => createPrng,
|
188
197
|
createValidationSchema: () => createValidationSchema,
|
189
|
-
dateOfEventColumn: () => dateOfEventColumn,
|
190
198
|
deepDropNulls: () => deepDropNulls,
|
191
199
|
deepMerge: () => deepMerge,
|
192
200
|
defaultWorkqueueColumns: () => defaultWorkqueueColumns,
|
@@ -206,10 +214,8 @@ __export(events_exports, {
|
|
206
214
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
207
215
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
208
216
|
eventQueryDataGenerator: () => eventQueryDataGenerator,
|
209
|
-
eventStatuses: () => eventStatuses,
|
210
217
|
field: () => field,
|
211
218
|
fieldTypes: () => fieldTypes,
|
212
|
-
filterUnallowedActions: () => filterUnallowedActions,
|
213
219
|
findActiveDrafts: () => findActiveDrafts,
|
214
220
|
findAllFields: () => findAllFields,
|
215
221
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
@@ -219,9 +225,12 @@ __export(events_exports, {
|
|
219
225
|
generateActionDocument: () => generateActionDocument,
|
220
226
|
generateEventDocument: () => generateEventDocument,
|
221
227
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
228
|
+
generateRandomName: () => generateRandomName,
|
222
229
|
generateRandomSignature: () => generateRandomSignature,
|
230
|
+
generateRegistrationNumber: () => generateRegistrationNumber,
|
223
231
|
generateTransactionId: () => generateTransactionId,
|
224
232
|
generateTranslationConfig: () => generateTranslationConfig,
|
233
|
+
generateUuid: () => generateUuid,
|
225
234
|
generateWorkqueues: () => generateWorkqueues,
|
226
235
|
getAcceptedActions: () => getAcceptedActions,
|
227
236
|
getActionAnnotation: () => getActionAnnotation,
|
@@ -229,17 +238,22 @@ __export(events_exports, {
|
|
229
238
|
getActionReview: () => getActionReview,
|
230
239
|
getActionReviewFields: () => getActionReviewFields,
|
231
240
|
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
241
|
+
getAllUniqueFields: () => getAllUniqueFields,
|
232
242
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
233
243
|
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
234
244
|
getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
|
235
245
|
getCurrentEventState: () => getCurrentEventState,
|
236
246
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
237
247
|
getDeclaration: () => getDeclaration,
|
248
|
+
getDeclarationFieldById: () => getDeclarationFieldById,
|
238
249
|
getDeclarationFields: () => getDeclarationFields,
|
239
250
|
getDeclarationPages: () => getDeclarationPages,
|
251
|
+
getEventConfigById: () => getEventConfigById,
|
240
252
|
getMixedPath: () => getMixedPath,
|
253
|
+
getRandomDate: () => getRandomDate,
|
241
254
|
getRandomDatetime: () => getRandomDatetime,
|
242
255
|
getStatusFromActions: () => getStatusFromActions,
|
256
|
+
getValidatorsForField: () => getValidatorsForField,
|
243
257
|
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
244
258
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
245
259
|
isAddressFieldType: () => isAddressFieldType,
|
@@ -262,13 +276,17 @@ __export(events_exports, {
|
|
262
276
|
isFieldVisible: () => isFieldVisible,
|
263
277
|
isFileFieldType: () => isFileFieldType,
|
264
278
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
279
|
+
isIdFieldType: () => isIdFieldType,
|
265
280
|
isLocationFieldType: () => isLocationFieldType,
|
281
|
+
isMetaAction: () => isMetaAction,
|
282
|
+
isNameFieldType: () => isNameFieldType,
|
266
283
|
isNonInteractiveFieldType: () => isNonInteractiveFieldType,
|
267
284
|
isNumberFieldType: () => isNumberFieldType,
|
268
285
|
isOfficeFieldType: () => isOfficeFieldType,
|
269
286
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
270
287
|
isPageVisible: () => isPageVisible,
|
271
288
|
isParagraphFieldType: () => isParagraphFieldType,
|
289
|
+
isPhoneFieldType: () => isPhoneFieldType,
|
272
290
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
273
291
|
isSelectFieldType: () => isSelectFieldType,
|
274
292
|
isSignatureFieldType: () => isSignatureFieldType,
|
@@ -278,6 +296,7 @@ __export(events_exports, {
|
|
278
296
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
279
297
|
isVerificationPage: () => isVerificationPage,
|
280
298
|
isWriteAction: () => isWriteAction,
|
299
|
+
mandatoryColumns: () => mandatoryColumns,
|
281
300
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
282
301
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
283
302
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
@@ -291,12 +310,14 @@ __export(events_exports, {
|
|
291
310
|
user: () => user,
|
292
311
|
validate: () => validate,
|
293
312
|
validateFieldInput: () => validateFieldInput,
|
313
|
+
workqueueActions: () => workqueueActions,
|
294
314
|
writeActions: () => writeActions
|
295
315
|
});
|
296
316
|
module.exports = __toCommonJS(events_exports);
|
297
317
|
|
298
318
|
// ../commons/src/events/Constants.ts
|
299
319
|
var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
|
320
|
+
var BIRTH_EVENT = "v2-birth";
|
300
321
|
|
301
322
|
// ../commons/src/events/ActionConfig.ts
|
302
323
|
var import_zod9 = require("zod");
|
@@ -375,6 +396,9 @@ var TranslationConfig = import_zod2.z.object({
|
|
375
396
|
|
376
397
|
// ../commons/src/events/FieldType.ts
|
377
398
|
var FieldType = {
|
399
|
+
NAME: "NAME",
|
400
|
+
PHONE: "PHONE",
|
401
|
+
ID: "ID",
|
378
402
|
ADDRESS: "ADDRESS",
|
379
403
|
TEXT: "TEXT",
|
380
404
|
NUMBER: "NUMBER",
|
@@ -451,6 +475,16 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
|
|
451
475
|
number: import_zod3.z.string().nullish(),
|
452
476
|
zipCode: import_zod3.z.string().nullish()
|
453
477
|
});
|
478
|
+
var NameFieldValue = import_zod3.z.object({
|
479
|
+
firstname: import_zod3.z.string(),
|
480
|
+
surname: import_zod3.z.string(),
|
481
|
+
middlename: import_zod3.z.string().optional()
|
482
|
+
});
|
483
|
+
var NameFieldUpdateValue = import_zod3.z.object({
|
484
|
+
firstname: import_zod3.z.string().nullish(),
|
485
|
+
surname: import_zod3.z.string().nullish(),
|
486
|
+
middlename: import_zod3.z.string().nullish()
|
487
|
+
}).or(import_zod3.z.null()).or(import_zod3.z.undefined());
|
454
488
|
var RuralAddressUpdateValue = AdminStructure.extend({
|
455
489
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
456
490
|
village: import_zod3.z.string().nullish()
|
@@ -512,7 +546,9 @@ var FieldValue = import_zod4.z.union([
|
|
512
546
|
UrbanAddressValue,
|
513
547
|
RuralAddressValue,
|
514
548
|
DataFieldValue,
|
515
|
-
GenericAddressValue
|
549
|
+
GenericAddressValue,
|
550
|
+
NameFieldValue,
|
551
|
+
NameFieldUpdateValue
|
516
552
|
]);
|
517
553
|
var FieldUpdateValue = import_zod4.z.union([
|
518
554
|
TextValue,
|
@@ -525,7 +561,8 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
525
561
|
UrbanAddressUpdateValue,
|
526
562
|
RuralAddressUpdateValue,
|
527
563
|
DataFieldValue,
|
528
|
-
GenericAddressUpdateValue
|
564
|
+
GenericAddressUpdateValue,
|
565
|
+
NameFieldUpdateValue
|
529
566
|
]);
|
530
567
|
|
531
568
|
// ../commons/src/events/FieldConfig.ts
|
@@ -536,18 +573,18 @@ var FieldReference = import_zod5.z.object({
|
|
536
573
|
$$field: FieldId
|
537
574
|
}).describe("Reference to a field by its ID");
|
538
575
|
var ParentReference = FieldReference.optional();
|
576
|
+
var ValidationConfig = import_zod5.z.object({
|
577
|
+
validator: Conditional,
|
578
|
+
message: TranslationConfig
|
579
|
+
});
|
539
580
|
var BaseField = import_zod5.z.object({
|
540
581
|
id: FieldId,
|
541
582
|
parent: ParentReference,
|
542
583
|
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
543
584
|
required: import_zod5.z.boolean().default(false).optional(),
|
585
|
+
secured: import_zod5.z.boolean().default(false).optional(),
|
544
586
|
placeholder: TranslationConfig.optional(),
|
545
|
-
validation: import_zod5.z.array(
|
546
|
-
import_zod5.z.object({
|
547
|
-
validator: Conditional,
|
548
|
-
message: TranslationConfig
|
549
|
-
})
|
550
|
-
).default([]).optional(),
|
587
|
+
validation: import_zod5.z.array(ValidationConfig).default([]).optional(),
|
551
588
|
label: TranslationConfig,
|
552
589
|
helperText: TranslationConfig.optional(),
|
553
590
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
@@ -702,6 +739,28 @@ var Select = BaseField.extend({
|
|
702
739
|
defaultValue: TextValue.optional(),
|
703
740
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
704
741
|
}).describe("Select input");
|
742
|
+
var NameField = BaseField.extend({
|
743
|
+
type: import_zod5.z.literal(FieldType.NAME),
|
744
|
+
defaultValue: import_zod5.z.object({
|
745
|
+
firstname: NonEmptyTextValue,
|
746
|
+
surname: NonEmptyTextValue
|
747
|
+
}).optional(),
|
748
|
+
configuration: import_zod5.z.object({
|
749
|
+
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
750
|
+
prefix: TranslationConfig.optional(),
|
751
|
+
postfix: TranslationConfig.optional(),
|
752
|
+
includeMiddlename: import_zod5.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
|
753
|
+
searchMode: import_zod5.z.boolean().optional()
|
754
|
+
}).optional()
|
755
|
+
}).describe("Name input field");
|
756
|
+
var PhoneField = BaseField.extend({
|
757
|
+
defaultValue: NonEmptyTextValue.optional(),
|
758
|
+
type: import_zod5.z.literal(FieldType.PHONE)
|
759
|
+
}).describe("Phone input field");
|
760
|
+
var IdField = BaseField.extend({
|
761
|
+
defaultValue: NonEmptyTextValue.optional(),
|
762
|
+
type: import_zod5.z.literal(FieldType.ID)
|
763
|
+
}).describe("ID input field");
|
705
764
|
var Checkbox = BaseField.extend({
|
706
765
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
707
766
|
defaultValue: CheckboxFieldValue.optional()
|
@@ -781,6 +840,9 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
781
840
|
BulletList,
|
782
841
|
PageHeader,
|
783
842
|
Select,
|
843
|
+
NameField,
|
844
|
+
PhoneField,
|
845
|
+
IdField,
|
784
846
|
Checkbox,
|
785
847
|
File,
|
786
848
|
Country,
|
@@ -914,6 +976,25 @@ var writeActions = ActionTypes.exclude([
|
|
914
976
|
ActionType.ASSIGN,
|
915
977
|
ActionType.UNASSIGN
|
916
978
|
]);
|
979
|
+
var workqueueActions = ActionTypes.exclude([
|
980
|
+
ActionType.CREATE,
|
981
|
+
ActionType.NOTIFY,
|
982
|
+
ActionType.DETECT_DUPLICATE,
|
983
|
+
ActionType.REJECT,
|
984
|
+
ActionType.MARKED_AS_DUPLICATE,
|
985
|
+
ActionType.ARCHIVE,
|
986
|
+
ActionType.REQUEST_CORRECTION,
|
987
|
+
ActionType.REJECT_CORRECTION,
|
988
|
+
ActionType.APPROVE_CORRECTION
|
989
|
+
]);
|
990
|
+
var META_ACTIONS = [
|
991
|
+
ActionType.ASSIGN,
|
992
|
+
ActionType.UNASSIGN,
|
993
|
+
ActionType.READ
|
994
|
+
];
|
995
|
+
function isMetaAction(actionType) {
|
996
|
+
return META_ACTIONS.includes(actionType);
|
997
|
+
}
|
917
998
|
|
918
999
|
// ../commons/src/events/FormConfig.ts
|
919
1000
|
var import_zod8 = require("zod");
|
@@ -1075,7 +1156,7 @@ var LanguageConfig = import_zod11.z.object({
|
|
1075
1156
|
});
|
1076
1157
|
|
1077
1158
|
// ../commons/src/events/EventConfig.ts
|
1078
|
-
var
|
1159
|
+
var import_zod20 = require("zod");
|
1079
1160
|
|
1080
1161
|
// ../commons/src/events/DeduplicationConfig.ts
|
1081
1162
|
var import_zod12 = require("zod");
|
@@ -1167,8 +1248,7 @@ var Field = BaseField2.extend({
|
|
1167
1248
|
value: TranslationConfig.describe(
|
1168
1249
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1169
1250
|
),
|
1170
|
-
label: TranslationConfig
|
1171
|
-
emptyValueMessage: TranslationConfig.optional()
|
1251
|
+
label: TranslationConfig
|
1172
1252
|
}).describe("Custom configured field");
|
1173
1253
|
var SummaryConfig = import_zod13.z.object({
|
1174
1254
|
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
@@ -1184,37 +1264,40 @@ var BaseField3 = import_zod14.z.object({
|
|
1184
1264
|
options: import_zod14.z.array(SelectOption).optional(),
|
1185
1265
|
searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
|
1186
1266
|
`
|
1187
|
-
This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
|
1267
|
+
This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
|
1188
1268
|
when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
|
1189
1269
|
|
1190
|
-
For example, a field config like { id: "child.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
|
1270
|
+
For example, a field config like { id: "child.name.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
|
1191
1271
|
|
1192
1272
|
A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
|
1193
1273
|
|
1194
|
-
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)",
|
1274
|
+
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)",
|
1195
1275
|
which is ambiguous.
|
1196
1276
|
|
1197
|
-
Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
|
1198
|
-
descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
|
1277
|
+
Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
|
1278
|
+
descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
|
1199
1279
|
label would be "Applicant Applicant's First Name", which is redundant and awkward.
|
1200
1280
|
|
1201
|
-
By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
|
1281
|
+
By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
|
1202
1282
|
in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
|
1203
1283
|
`
|
1204
1284
|
),
|
1205
1285
|
conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
|
1206
1286
|
`
|
1207
1287
|
In advanced search, we sometimes need to override the default field visibility conditionals.
|
1208
|
-
|
1209
|
-
For example, Informant fields in the declaration form may have conditional logic
|
1210
|
-
that hides them based on other field values. Since the advanced search form reuses
|
1288
|
+
|
1289
|
+
For example, Informant fields in the declaration form may have conditional logic
|
1290
|
+
that hides them based on other field values. Since the advanced search form reuses
|
1211
1291
|
the declaration form config, those same conditionals would apply by default.
|
1212
|
-
|
1292
|
+
|
1213
1293
|
However, in advanced search we often want to make all Informant fields searchable,
|
1214
|
-
regardless of their original visibility logic. To do this, we explicitly set their
|
1215
|
-
'conditionals' to an empty array ('[]') in the search config. This ensures they
|
1294
|
+
regardless of their original visibility logic. To do this, we explicitly set their
|
1295
|
+
'conditionals' to an empty array ('[]') in the search config. This ensures they
|
1216
1296
|
are always rendered in the advanced search form.
|
1217
1297
|
`
|
1298
|
+
),
|
1299
|
+
validations: import_zod14.z.array(ValidationConfig).default([]).optional().describe(
|
1300
|
+
`In advanced search, we sometimes need to override the default field validations.`
|
1218
1301
|
)
|
1219
1302
|
});
|
1220
1303
|
var SearchQueryParams = import_zod14.z.object({
|
@@ -1250,7 +1333,7 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1250
1333
|
var import_lodash = require("lodash");
|
1251
1334
|
|
1252
1335
|
// ../commons/src/events/ActionDocument.ts
|
1253
|
-
var
|
1336
|
+
var import_zod18 = require("zod");
|
1254
1337
|
var import_zod_openapi7 = require("zod-openapi");
|
1255
1338
|
|
1256
1339
|
// ../commons/src/uuid.ts
|
@@ -1264,120 +1347,546 @@ function getUUID() {
|
|
1264
1347
|
// ../commons/src/events/CreatedAtLocation.ts
|
1265
1348
|
var CreatedAtLocation = UUID.nullish();
|
1266
1349
|
|
1350
|
+
// ../commons/src/authentication.ts
|
1351
|
+
var import_jwt_decode = __toESM(require("jwt-decode"));
|
1352
|
+
var import_zod17 = require("zod");
|
1353
|
+
|
1354
|
+
// ../commons/src/scopes.ts
|
1355
|
+
var import_zod16 = require("zod");
|
1356
|
+
var SCOPES = {
|
1357
|
+
// TODO v1.8 legacy scopes
|
1358
|
+
NATLSYSADMIN: "natlsysadmin",
|
1359
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
1360
|
+
DECLARE: "declare",
|
1361
|
+
REGISTER: "register",
|
1362
|
+
VALIDATE: "validate",
|
1363
|
+
DEMO: "demo",
|
1364
|
+
CERTIFY: "certify",
|
1365
|
+
PERFORMANCE: "performance",
|
1366
|
+
SYSADMIN: "sysadmin",
|
1367
|
+
TEAMS: "teams",
|
1368
|
+
CONFIG: "config",
|
1369
|
+
// systems / integrations
|
1370
|
+
WEBHOOK: "webhook",
|
1371
|
+
NATIONALID: "nationalId",
|
1372
|
+
NOTIFICATION_API: "notification-api",
|
1373
|
+
RECORDSEARCH: "recordsearch",
|
1374
|
+
/**
|
1375
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
1376
|
+
*/
|
1377
|
+
RECORD_DECLARE: "record.declare-birth",
|
1378
|
+
// declare
|
1379
|
+
RECORD_IMPORT: "record.import",
|
1380
|
+
// declare
|
1381
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
1382
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
1383
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
1384
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
1385
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
1386
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
1387
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
1388
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
1389
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
1390
|
+
// validate
|
1391
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
1392
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
1393
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
1394
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
1395
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
1396
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
1397
|
+
// register
|
1398
|
+
RECORD_REGISTER: "record.register",
|
1399
|
+
// certify
|
1400
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
1401
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
1402
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
1403
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
1404
|
+
// v1.8
|
1405
|
+
/**
|
1406
|
+
* This scope is used to **print and **issue certified copies of a record
|
1407
|
+
* after it has been registered. Previously Registrars had this permission.
|
1408
|
+
*/
|
1409
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
1410
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
1411
|
+
// v1.8
|
1412
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
1413
|
+
// v1.8
|
1414
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
1415
|
+
// v1.8
|
1416
|
+
// correct
|
1417
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
1418
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
1419
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
1420
|
+
// v1.8
|
1421
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
1422
|
+
// v1.8
|
1423
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
1424
|
+
// v1.8
|
1425
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
1426
|
+
// v1.8
|
1427
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
1428
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
1429
|
+
// search
|
1430
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
1431
|
+
SEARCH_BIRTH: "search.birth",
|
1432
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
1433
|
+
SEARCH_DEATH: "search.death",
|
1434
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
1435
|
+
SEARCH_MARRIAGE: "search.marriage",
|
1436
|
+
// audit v1.8
|
1437
|
+
RECORD_READ: "record.read",
|
1438
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
1439
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
1440
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
1441
|
+
// profile
|
1442
|
+
PROFILE_UPDATE: "profile.update",
|
1443
|
+
//v1.8
|
1444
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
1445
|
+
// performance
|
1446
|
+
PERFORMANCE_READ: "performance.read",
|
1447
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
1448
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
1449
|
+
// organisation
|
1450
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
1451
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
1452
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
1453
|
+
// user
|
1454
|
+
USER_READ: "user.read:all",
|
1455
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
1456
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
1457
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
1458
|
+
//v1.8
|
1459
|
+
USER_CREATE: "user.create:all",
|
1460
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
1461
|
+
USER_UPDATE: "user.update:all",
|
1462
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
1463
|
+
// config
|
1464
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
1465
|
+
// data seeding
|
1466
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
1467
|
+
};
|
1468
|
+
var LegacyScopes = import_zod16.z.union([
|
1469
|
+
import_zod16.z.literal(SCOPES.NATLSYSADMIN),
|
1470
|
+
import_zod16.z.literal(SCOPES.BYPASSRATELIMIT),
|
1471
|
+
import_zod16.z.literal(SCOPES.DECLARE),
|
1472
|
+
import_zod16.z.literal(SCOPES.REGISTER),
|
1473
|
+
import_zod16.z.literal(SCOPES.VALIDATE),
|
1474
|
+
import_zod16.z.literal(SCOPES.DEMO),
|
1475
|
+
import_zod16.z.literal(SCOPES.CERTIFY),
|
1476
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE),
|
1477
|
+
import_zod16.z.literal(SCOPES.SYSADMIN),
|
1478
|
+
import_zod16.z.literal(SCOPES.TEAMS),
|
1479
|
+
import_zod16.z.literal(SCOPES.CONFIG)
|
1480
|
+
]);
|
1481
|
+
var IntegrationScopes = import_zod16.z.union([
|
1482
|
+
import_zod16.z.literal(SCOPES.WEBHOOK),
|
1483
|
+
import_zod16.z.literal(SCOPES.NATIONALID),
|
1484
|
+
import_zod16.z.literal(SCOPES.NOTIFICATION_API),
|
1485
|
+
import_zod16.z.literal(SCOPES.RECORDSEARCH)
|
1486
|
+
]);
|
1487
|
+
var DeclareScopes = import_zod16.z.union([
|
1488
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE),
|
1489
|
+
import_zod16.z.literal(SCOPES.RECORD_IMPORT),
|
1490
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
1491
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
1492
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
1493
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
1494
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
1495
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
1496
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
1497
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
|
1498
|
+
]);
|
1499
|
+
var UnassignScope = import_zod16.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
|
1500
|
+
var ValidateScopes = import_zod16.z.union([
|
1501
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
1502
|
+
import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
1503
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
1504
|
+
import_zod16.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
1505
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
1506
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
|
1507
|
+
]);
|
1508
|
+
var RegisterScope = import_zod16.z.literal(SCOPES.RECORD_REGISTER);
|
1509
|
+
var CertifyScopes = import_zod16.z.union([
|
1510
|
+
import_zod16.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
1511
|
+
import_zod16.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
1512
|
+
import_zod16.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
1513
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
1514
|
+
import_zod16.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
1515
|
+
import_zod16.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
1516
|
+
import_zod16.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
1517
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
|
1518
|
+
]);
|
1519
|
+
var CorrectionScopes = import_zod16.z.union([
|
1520
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
1521
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
1522
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
1523
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
1524
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
1525
|
+
import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
1526
|
+
import_zod16.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
1527
|
+
import_zod16.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
|
1528
|
+
]);
|
1529
|
+
var SearchScopes = import_zod16.z.union([
|
1530
|
+
import_zod16.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
1531
|
+
import_zod16.z.literal(SCOPES.SEARCH_BIRTH),
|
1532
|
+
import_zod16.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
1533
|
+
import_zod16.z.literal(SCOPES.SEARCH_DEATH),
|
1534
|
+
import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
1535
|
+
import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE)
|
1536
|
+
]);
|
1537
|
+
var AuditScopes = import_zod16.z.union([
|
1538
|
+
import_zod16.z.literal(SCOPES.RECORD_READ),
|
1539
|
+
import_zod16.z.literal(SCOPES.RECORD_READ_AUDIT),
|
1540
|
+
import_zod16.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
1541
|
+
import_zod16.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
|
1542
|
+
]);
|
1543
|
+
var ProfileScopes = import_zod16.z.union([
|
1544
|
+
import_zod16.z.literal(SCOPES.PROFILE_UPDATE),
|
1545
|
+
import_zod16.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
|
1546
|
+
]);
|
1547
|
+
var PerformanceScopes = import_zod16.z.union([
|
1548
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE_READ),
|
1549
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
1550
|
+
import_zod16.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
|
1551
|
+
]);
|
1552
|
+
var OrganisationScopes = import_zod16.z.union([
|
1553
|
+
import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
1554
|
+
import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
1555
|
+
import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
|
1556
|
+
]);
|
1557
|
+
var UserScopes = import_zod16.z.union([
|
1558
|
+
import_zod16.z.literal(SCOPES.USER_READ),
|
1559
|
+
import_zod16.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
1560
|
+
import_zod16.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
1561
|
+
import_zod16.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
1562
|
+
import_zod16.z.literal(SCOPES.USER_CREATE),
|
1563
|
+
import_zod16.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
1564
|
+
import_zod16.z.literal(SCOPES.USER_UPDATE),
|
1565
|
+
import_zod16.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
|
1566
|
+
]);
|
1567
|
+
var ConfigScope = import_zod16.z.literal(SCOPES.CONFIG_UPDATE_ALL);
|
1568
|
+
var DataSeedingScope = import_zod16.z.literal(SCOPES.USER_DATA_SEEDING);
|
1569
|
+
var LiteralScopes = import_zod16.z.union([
|
1570
|
+
LegacyScopes,
|
1571
|
+
IntegrationScopes,
|
1572
|
+
UnassignScope,
|
1573
|
+
DeclareScopes,
|
1574
|
+
ValidateScopes,
|
1575
|
+
RegisterScope,
|
1576
|
+
CertifyScopes,
|
1577
|
+
CorrectionScopes,
|
1578
|
+
SearchScopes,
|
1579
|
+
AuditScopes,
|
1580
|
+
ProfileScopes,
|
1581
|
+
PerformanceScopes,
|
1582
|
+
OrganisationScopes,
|
1583
|
+
UserScopes,
|
1584
|
+
ConfigScope,
|
1585
|
+
DataSeedingScope
|
1586
|
+
]);
|
1587
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
1588
|
+
var rawConfigurableScope = import_zod16.z.string().regex(rawConfigurableScopeRegex);
|
1589
|
+
var CreateUserScope = import_zod16.z.object({
|
1590
|
+
type: import_zod16.z.literal("user.create"),
|
1591
|
+
options: import_zod16.z.object({
|
1592
|
+
role: import_zod16.z.array(import_zod16.z.string())
|
1593
|
+
})
|
1594
|
+
});
|
1595
|
+
var EditUserScope = import_zod16.z.object({
|
1596
|
+
type: import_zod16.z.literal("user.edit"),
|
1597
|
+
options: import_zod16.z.object({
|
1598
|
+
role: import_zod16.z.array(import_zod16.z.string())
|
1599
|
+
})
|
1600
|
+
});
|
1601
|
+
var WorkqueueScope = import_zod16.z.object({
|
1602
|
+
type: import_zod16.z.literal("workqueue"),
|
1603
|
+
options: import_zod16.z.object({
|
1604
|
+
id: import_zod16.z.array(import_zod16.z.string())
|
1605
|
+
})
|
1606
|
+
});
|
1607
|
+
var NotifyRecordScope = import_zod16.z.object({
|
1608
|
+
type: import_zod16.z.literal("record.notify"),
|
1609
|
+
options: import_zod16.z.object({
|
1610
|
+
event: import_zod16.z.array(import_zod16.z.string())
|
1611
|
+
})
|
1612
|
+
});
|
1613
|
+
var ConfigurableScopes = import_zod16.z.discriminatedUnion("type", [
|
1614
|
+
CreateUserScope,
|
1615
|
+
EditUserScope,
|
1616
|
+
WorkqueueScope,
|
1617
|
+
NotifyRecordScope
|
1618
|
+
]);
|
1619
|
+
var scopes = Object.values(SCOPES);
|
1620
|
+
var ActionScopes = import_zod16.z.union([
|
1621
|
+
DeclareScopes,
|
1622
|
+
ValidateScopes,
|
1623
|
+
RegisterScope,
|
1624
|
+
CertifyScopes,
|
1625
|
+
CorrectionScopes
|
1626
|
+
]);
|
1627
|
+
|
1628
|
+
// ../commons/src/authentication.ts
|
1629
|
+
var DEFAULT_ROLES_DEFINITION = [
|
1630
|
+
{
|
1631
|
+
id: "FIELD_AGENT",
|
1632
|
+
label: {
|
1633
|
+
defaultMessage: "Field Agent",
|
1634
|
+
description: "Name for user role Field Agent",
|
1635
|
+
id: "userRole.fieldAgent"
|
1636
|
+
},
|
1637
|
+
scopes: [
|
1638
|
+
// new scopes
|
1639
|
+
SCOPES.RECORD_DECLARE_BIRTH,
|
1640
|
+
SCOPES.RECORD_DECLARE_DEATH,
|
1641
|
+
SCOPES.RECORD_DECLARE_MARRIAGE,
|
1642
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
1643
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
1644
|
+
SCOPES.SEARCH_BIRTH,
|
1645
|
+
SCOPES.SEARCH_DEATH,
|
1646
|
+
SCOPES.SEARCH_MARRIAGE
|
1647
|
+
]
|
1648
|
+
},
|
1649
|
+
{
|
1650
|
+
id: "REGISTRATION_AGENT",
|
1651
|
+
label: {
|
1652
|
+
defaultMessage: "Registration Agent",
|
1653
|
+
description: "Name for user role Registration Agent",
|
1654
|
+
id: "userRole.registrationAgent"
|
1655
|
+
},
|
1656
|
+
scopes: [
|
1657
|
+
SCOPES.PERFORMANCE,
|
1658
|
+
SCOPES.CERTIFY,
|
1659
|
+
SCOPES.RECORD_DECLARE_BIRTH,
|
1660
|
+
SCOPES.RECORD_DECLARE_DEATH,
|
1661
|
+
SCOPES.RECORD_DECLARE_MARRIAGE,
|
1662
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
1663
|
+
SCOPES.RECORD_SUBMIT_FOR_UPDATES,
|
1664
|
+
SCOPES.RECORD_DECLARATION_ARCHIVE,
|
1665
|
+
SCOPES.RECORD_DECLARATION_REINSTATE,
|
1666
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION,
|
1667
|
+
SCOPES.RECORD_REGISTRATION_PRINT,
|
1668
|
+
SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
|
1669
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
1670
|
+
SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
|
1671
|
+
SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
|
1672
|
+
SCOPES.RECORD_CREATE_COMMENTS,
|
1673
|
+
SCOPES.PERFORMANCE_READ,
|
1674
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1675
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1676
|
+
SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
|
1677
|
+
SCOPES.SEARCH_BIRTH,
|
1678
|
+
SCOPES.SEARCH_DEATH,
|
1679
|
+
SCOPES.SEARCH_MARRIAGE
|
1680
|
+
]
|
1681
|
+
},
|
1682
|
+
{
|
1683
|
+
id: "LOCAL_REGISTRAR",
|
1684
|
+
label: {
|
1685
|
+
defaultMessage: "Local Registrar",
|
1686
|
+
description: "Name for user role Local Registrar",
|
1687
|
+
id: "userRole.localRegistrar"
|
1688
|
+
},
|
1689
|
+
scopes: [
|
1690
|
+
SCOPES.PERFORMANCE,
|
1691
|
+
SCOPES.CERTIFY,
|
1692
|
+
SCOPES.RECORD_DECLARE_BIRTH,
|
1693
|
+
SCOPES.RECORD_DECLARE_DEATH,
|
1694
|
+
SCOPES.RECORD_DECLARE_MARRIAGE,
|
1695
|
+
SCOPES.RECORD_SUBMIT_FOR_UPDATES,
|
1696
|
+
SCOPES.RECORD_REVIEW_DUPLICATES,
|
1697
|
+
SCOPES.RECORD_DECLARATION_ARCHIVE,
|
1698
|
+
SCOPES.RECORD_DECLARATION_REINSTATE,
|
1699
|
+
SCOPES.RECORD_REGISTER,
|
1700
|
+
SCOPES.RECORD_REGISTRATION_CORRECT,
|
1701
|
+
SCOPES.RECORD_REGISTRATION_PRINT,
|
1702
|
+
SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
|
1703
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
1704
|
+
SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
|
1705
|
+
SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
|
1706
|
+
SCOPES.RECORD_CREATE_COMMENTS,
|
1707
|
+
SCOPES.PERFORMANCE_READ,
|
1708
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1709
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1710
|
+
SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
|
1711
|
+
SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
|
1712
|
+
SCOPES.SEARCH_BIRTH,
|
1713
|
+
SCOPES.SEARCH_DEATH,
|
1714
|
+
SCOPES.SEARCH_MARRIAGE
|
1715
|
+
]
|
1716
|
+
},
|
1717
|
+
{
|
1718
|
+
id: "LOCAL_SYSTEM_ADMIN",
|
1719
|
+
label: {
|
1720
|
+
defaultMessage: "Local System Admin",
|
1721
|
+
description: "Name for user role Local System Admin",
|
1722
|
+
id: "userRole.localSystemAdmin"
|
1723
|
+
},
|
1724
|
+
scopes: [
|
1725
|
+
SCOPES.SYSADMIN,
|
1726
|
+
SCOPES.USER_READ_MY_OFFICE,
|
1727
|
+
SCOPES.USER_CREATE_MY_JURISDICTION,
|
1728
|
+
SCOPES.USER_UPDATE_MY_JURISDICTION,
|
1729
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1730
|
+
SCOPES.PERFORMANCE_READ,
|
1731
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1732
|
+
SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
|
1733
|
+
// 'organisation.read-users' ?
|
1734
|
+
]
|
1735
|
+
},
|
1736
|
+
{
|
1737
|
+
id: "NATIONAL_SYSTEM_ADMIN",
|
1738
|
+
label: {
|
1739
|
+
defaultMessage: "National System Admin",
|
1740
|
+
description: "Name for user role National System Admin",
|
1741
|
+
id: "userRole.nationalSystemAdmin"
|
1742
|
+
},
|
1743
|
+
scopes: [
|
1744
|
+
SCOPES.SYSADMIN,
|
1745
|
+
SCOPES.NATLSYSADMIN,
|
1746
|
+
SCOPES.USER_CREATE,
|
1747
|
+
SCOPES.USER_READ,
|
1748
|
+
SCOPES.USER_UPDATE,
|
1749
|
+
SCOPES.ORGANISATION_READ_LOCATIONS,
|
1750
|
+
SCOPES.PERFORMANCE_READ,
|
1751
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1752
|
+
SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
|
1753
|
+
// 'organisation.read-users' ?
|
1754
|
+
]
|
1755
|
+
},
|
1756
|
+
{
|
1757
|
+
id: "PERFORMANCE_MANAGER",
|
1758
|
+
label: {
|
1759
|
+
defaultMessage: "Performance Manager",
|
1760
|
+
description: "Name for user role Performance Manager",
|
1761
|
+
id: "userRole.performanceManager"
|
1762
|
+
},
|
1763
|
+
scopes: [
|
1764
|
+
SCOPES.PERFORMANCE,
|
1765
|
+
SCOPES.PERFORMANCE_READ,
|
1766
|
+
SCOPES.PERFORMANCE_READ_DASHBOARDS,
|
1767
|
+
SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
|
1768
|
+
]
|
1769
|
+
}
|
1770
|
+
];
|
1771
|
+
var TokenUserType = import_zod17.z.enum(["user", "system"]);
|
1772
|
+
var TokenWithBearer = import_zod17.z.string().regex(/^Bearer\s/);
|
1773
|
+
|
1267
1774
|
// ../commons/src/events/ActionDocument.ts
|
1268
|
-
(0, import_zod_openapi7.extendZodWithOpenApi)(
|
1269
|
-
var ActionUpdate =
|
1270
|
-
var EventState =
|
1775
|
+
(0, import_zod_openapi7.extendZodWithOpenApi)(import_zod18.z);
|
1776
|
+
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1777
|
+
var EventState = import_zod18.z.record(import_zod18.z.string(), FieldValue);
|
1271
1778
|
var ActionStatus = {
|
1272
1779
|
Requested: "Requested",
|
1273
1780
|
Accepted: "Accepted",
|
1274
1781
|
Rejected: "Rejected"
|
1275
1782
|
};
|
1276
|
-
var ActionBase =
|
1277
|
-
id:
|
1278
|
-
transactionId:
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1783
|
+
var ActionBase = import_zod18.z.object({
|
1784
|
+
id: UUID,
|
1785
|
+
transactionId: import_zod18.z.string(),
|
1786
|
+
createdByUserType: TokenUserType,
|
1787
|
+
createdAt: import_zod18.z.string().datetime(),
|
1788
|
+
createdBy: import_zod18.z.string(),
|
1789
|
+
createdByRole: import_zod18.z.string(),
|
1790
|
+
createdBySignature: import_zod18.z.string().nullish().describe("Reference to signature of the user who created the action"),
|
1283
1791
|
createdAtLocation: CreatedAtLocation,
|
1284
1792
|
declaration: ActionUpdate,
|
1285
1793
|
annotation: ActionUpdate.optional().nullable(),
|
1286
|
-
status:
|
1794
|
+
status: import_zod18.z.enum([
|
1287
1795
|
ActionStatus.Requested,
|
1288
1796
|
ActionStatus.Accepted,
|
1289
1797
|
ActionStatus.Rejected
|
1290
1798
|
]),
|
1291
1799
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1292
|
-
originalActionId: UUID.optional().nullable()
|
1800
|
+
originalActionId: UUID.optional().nullable().describe(
|
1801
|
+
"Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
|
1802
|
+
)
|
1293
1803
|
});
|
1294
1804
|
var AssignedAction = ActionBase.merge(
|
1295
|
-
|
1296
|
-
type:
|
1297
|
-
assignedTo:
|
1805
|
+
import_zod18.z.object({
|
1806
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1807
|
+
assignedTo: import_zod18.z.string()
|
1298
1808
|
})
|
1299
1809
|
);
|
1300
1810
|
var UnassignedAction = ActionBase.merge(
|
1301
|
-
|
1302
|
-
type:
|
1303
|
-
assignedTo: import_zod16.z.literal(null)
|
1811
|
+
import_zod18.z.object({
|
1812
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN)
|
1304
1813
|
})
|
1305
1814
|
);
|
1306
1815
|
var RegisterAction = ActionBase.merge(
|
1307
|
-
|
1308
|
-
type:
|
1309
|
-
registrationNumber:
|
1816
|
+
import_zod18.z.object({
|
1817
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1818
|
+
registrationNumber: import_zod18.z.string().optional()
|
1310
1819
|
})
|
1311
1820
|
);
|
1312
1821
|
var DeclareAction = ActionBase.merge(
|
1313
|
-
|
1314
|
-
type:
|
1822
|
+
import_zod18.z.object({
|
1823
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1315
1824
|
})
|
1316
1825
|
);
|
1317
1826
|
var ValidateAction = ActionBase.merge(
|
1318
|
-
|
1319
|
-
type:
|
1827
|
+
import_zod18.z.object({
|
1828
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1320
1829
|
})
|
1321
1830
|
);
|
1322
|
-
var RejectionReason =
|
1323
|
-
message:
|
1324
|
-
isDuplicate:
|
1831
|
+
var RejectionReason = import_zod18.z.object({
|
1832
|
+
message: import_zod18.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
|
1833
|
+
isDuplicate: import_zod18.z.boolean().optional().describe("If a declaration is duplicated")
|
1325
1834
|
});
|
1326
1835
|
var RejectAction = ActionBase.merge(
|
1327
|
-
|
1328
|
-
type:
|
1836
|
+
import_zod18.z.object({
|
1837
|
+
type: import_zod18.z.literal(ActionType.REJECT),
|
1329
1838
|
reason: RejectionReason
|
1330
1839
|
})
|
1331
1840
|
);
|
1332
1841
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1333
|
-
|
1334
|
-
type:
|
1842
|
+
import_zod18.z.object({
|
1843
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1335
1844
|
})
|
1336
1845
|
);
|
1337
1846
|
var ArchiveAction = ActionBase.merge(
|
1338
|
-
|
1339
|
-
type:
|
1847
|
+
import_zod18.z.object({
|
1848
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE),
|
1340
1849
|
reason: RejectionReason
|
1341
1850
|
})
|
1342
1851
|
);
|
1343
1852
|
var CreatedAction = ActionBase.merge(
|
1344
|
-
|
1345
|
-
type:
|
1853
|
+
import_zod18.z.object({
|
1854
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1346
1855
|
})
|
1347
1856
|
);
|
1348
1857
|
var NotifiedAction = ActionBase.merge(
|
1349
|
-
|
1350
|
-
type:
|
1858
|
+
import_zod18.z.object({
|
1859
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1351
1860
|
})
|
1352
1861
|
);
|
1353
1862
|
var PrintCertificateAction = ActionBase.merge(
|
1354
|
-
|
1355
|
-
type:
|
1863
|
+
import_zod18.z.object({
|
1864
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1356
1865
|
})
|
1357
1866
|
);
|
1358
1867
|
var RequestedCorrectionAction = ActionBase.merge(
|
1359
|
-
|
1360
|
-
type:
|
1868
|
+
import_zod18.z.object({
|
1869
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1361
1870
|
})
|
1362
1871
|
);
|
1363
1872
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1364
|
-
|
1365
|
-
type:
|
1366
|
-
requestId:
|
1873
|
+
import_zod18.z.object({
|
1874
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1875
|
+
requestId: import_zod18.z.string()
|
1367
1876
|
})
|
1368
1877
|
);
|
1369
1878
|
var RejectedCorrectionAction = ActionBase.merge(
|
1370
|
-
|
1371
|
-
type:
|
1372
|
-
requestId:
|
1879
|
+
import_zod18.z.object({
|
1880
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1881
|
+
requestId: import_zod18.z.string()
|
1373
1882
|
})
|
1374
1883
|
);
|
1375
1884
|
var ReadAction = ActionBase.merge(
|
1376
|
-
|
1377
|
-
type:
|
1885
|
+
import_zod18.z.object({
|
1886
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1378
1887
|
})
|
1379
1888
|
);
|
1380
|
-
var ActionDocument =
|
1889
|
+
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1381
1890
|
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1382
1891
|
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1383
1892
|
RejectAction.openapi({ ref: "RejectAction" }),
|
@@ -1400,20 +1909,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
|
|
1400
1909
|
declaration: true,
|
1401
1910
|
annotation: true
|
1402
1911
|
}).merge(
|
1403
|
-
|
1404
|
-
type:
|
1405
|
-
status:
|
1912
|
+
import_zod18.z.object({
|
1913
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1914
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1406
1915
|
})
|
1407
1916
|
);
|
1408
|
-
var Action =
|
1409
|
-
var ResolvedUser =
|
1410
|
-
id:
|
1411
|
-
role:
|
1412
|
-
name:
|
1413
|
-
|
1414
|
-
use:
|
1415
|
-
given:
|
1416
|
-
family:
|
1917
|
+
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1918
|
+
var ResolvedUser = import_zod18.z.object({
|
1919
|
+
id: import_zod18.z.string(),
|
1920
|
+
role: import_zod18.z.string(),
|
1921
|
+
name: import_zod18.z.array(
|
1922
|
+
import_zod18.z.object({
|
1923
|
+
use: import_zod18.z.string(),
|
1924
|
+
given: import_zod18.z.array(import_zod18.z.string()),
|
1925
|
+
family: import_zod18.z.string()
|
1417
1926
|
})
|
1418
1927
|
)
|
1419
1928
|
});
|
@@ -1424,7 +1933,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1424
1933
|
var import_date_fns = require("date-fns");
|
1425
1934
|
|
1426
1935
|
// ../commons/src/events/FieldTypeMapping.ts
|
1427
|
-
var
|
1936
|
+
var import_zod19 = require("zod");
|
1428
1937
|
function mapFieldTypeToZod(type, required) {
|
1429
1938
|
let schema;
|
1430
1939
|
switch (type) {
|
@@ -1450,6 +1959,8 @@ function mapFieldTypeToZod(type, required) {
|
|
1450
1959
|
case FieldType.ADMINISTRATIVE_AREA:
|
1451
1960
|
case FieldType.FACILITY:
|
1452
1961
|
case FieldType.OFFICE:
|
1962
|
+
case FieldType.PHONE:
|
1963
|
+
case FieldType.ID:
|
1453
1964
|
schema = required ? NonEmptyTextValue : TextValue;
|
1454
1965
|
break;
|
1455
1966
|
case FieldType.NUMBER:
|
@@ -1471,6 +1982,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1471
1982
|
case FieldType.DATA:
|
1472
1983
|
schema = DataFieldValue;
|
1473
1984
|
break;
|
1985
|
+
case FieldType.NAME:
|
1986
|
+
schema = required ? NameFieldValue : NameFieldUpdateValue;
|
1987
|
+
break;
|
1474
1988
|
}
|
1475
1989
|
return required ? schema : schema.nullish();
|
1476
1990
|
}
|
@@ -1479,9 +1993,9 @@ function createValidationSchema(config) {
|
|
1479
1993
|
for (const field2 of config) {
|
1480
1994
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1481
1995
|
}
|
1482
|
-
return
|
1996
|
+
return import_zod19.z.object(shape);
|
1483
1997
|
}
|
1484
|
-
function
|
1998
|
+
function mapFieldTypeToEmptyValue(field2) {
|
1485
1999
|
switch (field2.type) {
|
1486
2000
|
case FieldType.DIVIDER:
|
1487
2001
|
case FieldType.TEXT:
|
@@ -1496,88 +2010,39 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1496
2010
|
case FieldType.ADMINISTRATIVE_AREA:
|
1497
2011
|
case FieldType.FACILITY:
|
1498
2012
|
case FieldType.OFFICE:
|
1499
|
-
return `${field2.id}-${field2.type}-${i}`;
|
1500
2013
|
case FieldType.NUMBER:
|
1501
|
-
return 19;
|
1502
2014
|
case FieldType.EMAIL:
|
1503
|
-
|
2015
|
+
case FieldType.DATE:
|
2016
|
+
case FieldType.CHECKBOX:
|
2017
|
+
case FieldType.DATE_RANGE:
|
2018
|
+
case FieldType.DATA:
|
2019
|
+
case FieldType.NAME:
|
2020
|
+
case FieldType.PHONE:
|
2021
|
+
case FieldType.ID:
|
2022
|
+
return null;
|
1504
2023
|
case FieldType.ADDRESS:
|
1505
2024
|
return {
|
1506
|
-
country:
|
2025
|
+
country: null,
|
1507
2026
|
addressType: AddressType.DOMESTIC,
|
1508
|
-
province:
|
1509
|
-
district:
|
2027
|
+
province: null,
|
2028
|
+
district: null,
|
1510
2029
|
urbanOrRural: "URBAN",
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
2030
|
+
// Default to urban needed for validation
|
2031
|
+
town: null,
|
2032
|
+
residentialArea: null,
|
2033
|
+
street: null,
|
2034
|
+
number: null,
|
2035
|
+
zipCode: null
|
1516
2036
|
};
|
1517
|
-
case FieldType.DATE:
|
1518
|
-
return "2021-01-01";
|
1519
|
-
case FieldType.DATE_RANGE:
|
1520
|
-
return ["2021-01-01", "2021-01-02"];
|
1521
|
-
case FieldType.CHECKBOX:
|
1522
|
-
return true;
|
1523
2037
|
case FieldType.SIGNATURE:
|
1524
2038
|
case FieldType.FILE:
|
1525
2039
|
return {
|
1526
|
-
filename: "
|
1527
|
-
originalFilename: "
|
1528
|
-
type: "
|
2040
|
+
filename: "",
|
2041
|
+
originalFilename: "",
|
2042
|
+
type: ""
|
1529
2043
|
};
|
1530
2044
|
case FieldType.FILE_WITH_OPTIONS:
|
1531
|
-
return
|
1532
|
-
case FieldType.DATA:
|
1533
|
-
return {};
|
1534
|
-
}
|
1535
|
-
}
|
1536
|
-
function mapFieldTypeToEmptyValue(field2) {
|
1537
|
-
switch (field2.type) {
|
1538
|
-
case FieldType.DIVIDER:
|
1539
|
-
case FieldType.TEXT:
|
1540
|
-
case FieldType.TEXTAREA:
|
1541
|
-
case FieldType.BULLET_LIST:
|
1542
|
-
case FieldType.PAGE_HEADER:
|
1543
|
-
case FieldType.LOCATION:
|
1544
|
-
case FieldType.SELECT:
|
1545
|
-
case FieldType.COUNTRY:
|
1546
|
-
case FieldType.RADIO_GROUP:
|
1547
|
-
case FieldType.PARAGRAPH:
|
1548
|
-
case FieldType.ADMINISTRATIVE_AREA:
|
1549
|
-
case FieldType.FACILITY:
|
1550
|
-
case FieldType.OFFICE:
|
1551
|
-
case FieldType.NUMBER:
|
1552
|
-
case FieldType.EMAIL:
|
1553
|
-
case FieldType.DATE:
|
1554
|
-
case FieldType.CHECKBOX:
|
1555
|
-
case FieldType.DATE_RANGE:
|
1556
|
-
case FieldType.DATA:
|
1557
|
-
return null;
|
1558
|
-
case FieldType.ADDRESS:
|
1559
|
-
return {
|
1560
|
-
country: null,
|
1561
|
-
addressType: AddressType.DOMESTIC,
|
1562
|
-
province: null,
|
1563
|
-
district: null,
|
1564
|
-
urbanOrRural: "URBAN",
|
1565
|
-
// Default to urban needed for validation
|
1566
|
-
town: null,
|
1567
|
-
residentialArea: null,
|
1568
|
-
street: null,
|
1569
|
-
number: null,
|
1570
|
-
zipCode: null
|
1571
|
-
};
|
1572
|
-
case FieldType.SIGNATURE:
|
1573
|
-
case FieldType.FILE:
|
1574
|
-
return {
|
1575
|
-
filename: "",
|
1576
|
-
originalFilename: "",
|
1577
|
-
type: ""
|
1578
|
-
};
|
1579
|
-
case FieldType.FILE_WITH_OPTIONS:
|
1580
|
-
return [];
|
2045
|
+
return [];
|
1581
2046
|
}
|
1582
2047
|
}
|
1583
2048
|
var isParagraphFieldType = (field2) => {
|
@@ -1598,6 +2063,15 @@ var isTextFieldType = (field2) => {
|
|
1598
2063
|
var isNumberFieldType = (field2) => {
|
1599
2064
|
return field2.config.type === FieldType.NUMBER;
|
1600
2065
|
};
|
2066
|
+
var isNameFieldType = (field2) => {
|
2067
|
+
return field2.config.type === FieldType.NAME;
|
2068
|
+
};
|
2069
|
+
var isPhoneFieldType = (field2) => {
|
2070
|
+
return field2.config.type === FieldType.PHONE;
|
2071
|
+
};
|
2072
|
+
var isIdFieldType = (field2) => {
|
2073
|
+
return field2.config.type === FieldType.ID;
|
2074
|
+
};
|
1601
2075
|
var isTextAreaFieldType = (field2) => {
|
1602
2076
|
return field2.config.type === FieldType.TEXTAREA;
|
1603
2077
|
};
|
@@ -1659,6 +2133,29 @@ var ajv = new import_ajv.default({
|
|
1659
2133
|
allowUnionTypes: true
|
1660
2134
|
});
|
1661
2135
|
(0, import_ajv_formats.default)(ajv);
|
2136
|
+
ajv.addKeyword({
|
2137
|
+
keyword: "daysFromNow",
|
2138
|
+
type: "string",
|
2139
|
+
schemaType: "object",
|
2140
|
+
$data: true,
|
2141
|
+
errors: true,
|
2142
|
+
validate(schema, data, _, dataContext) {
|
2143
|
+
if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
|
2144
|
+
throw new Error("Validation context must contain $now");
|
2145
|
+
}
|
2146
|
+
const { days, clause } = schema;
|
2147
|
+
if (typeof data !== "string") {
|
2148
|
+
return false;
|
2149
|
+
}
|
2150
|
+
const date = new Date(data);
|
2151
|
+
if (isNaN(date.getTime())) {
|
2152
|
+
return false;
|
2153
|
+
}
|
2154
|
+
const now = new Date(dataContext.rootData.$now);
|
2155
|
+
const offsetDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1e3);
|
2156
|
+
return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
|
2157
|
+
}
|
2158
|
+
});
|
1662
2159
|
function validate(schema, data) {
|
1663
2160
|
return ajv.validate(schema, data);
|
1664
2161
|
}
|
@@ -1724,7 +2221,7 @@ var errorMessages = {
|
|
1724
2221
|
id: "v2.error.invalidEmail"
|
1725
2222
|
},
|
1726
2223
|
requiredField: {
|
1727
|
-
defaultMessage: "Required
|
2224
|
+
defaultMessage: "Required",
|
1728
2225
|
description: "Error message when required field is missing",
|
1729
2226
|
id: "v2.error.required"
|
1730
2227
|
},
|
@@ -1732,6 +2229,11 @@ var errorMessages = {
|
|
1732
2229
|
defaultMessage: "Invalid input",
|
1733
2230
|
description: "Error message when generic field is invalid",
|
1734
2231
|
id: "v2.error.invalid"
|
2232
|
+
},
|
2233
|
+
unexpectedField: {
|
2234
|
+
defaultMessage: "Unexpected field",
|
2235
|
+
description: "Error message when field is not expected",
|
2236
|
+
id: "v2.error.unexpectedField"
|
1735
2237
|
}
|
1736
2238
|
};
|
1737
2239
|
function createIntlError(message) {
|
@@ -1827,6 +2329,45 @@ function runFieldValidations({
|
|
1827
2329
|
errors: [...fieldValidationResult, ...customValidationResults]
|
1828
2330
|
};
|
1829
2331
|
}
|
2332
|
+
function getValidatorsForField(fieldId, validations) {
|
2333
|
+
return validations.map(({ validator, message }) => {
|
2334
|
+
const jsonSchema = validator;
|
2335
|
+
const $form = jsonSchema.properties.$form;
|
2336
|
+
if ($form.properties?.[fieldId]?.type === "object") {
|
2337
|
+
return {
|
2338
|
+
message,
|
2339
|
+
validator: {
|
2340
|
+
...jsonSchema,
|
2341
|
+
properties: {
|
2342
|
+
$form: {
|
2343
|
+
type: "object",
|
2344
|
+
properties: $form.properties?.[fieldId]?.properties || {},
|
2345
|
+
required: $form.properties?.[fieldId]?.required || []
|
2346
|
+
}
|
2347
|
+
}
|
2348
|
+
}
|
2349
|
+
};
|
2350
|
+
}
|
2351
|
+
if (!$form.properties?.[fieldId]) {
|
2352
|
+
return null;
|
2353
|
+
}
|
2354
|
+
return {
|
2355
|
+
message,
|
2356
|
+
validator: {
|
2357
|
+
...jsonSchema,
|
2358
|
+
properties: {
|
2359
|
+
$form: {
|
2360
|
+
type: "object",
|
2361
|
+
properties: {
|
2362
|
+
[fieldId]: $form.properties?.[fieldId]
|
2363
|
+
},
|
2364
|
+
required: $form.required?.includes(fieldId) ? [fieldId] : []
|
2365
|
+
}
|
2366
|
+
}
|
2367
|
+
}
|
2368
|
+
};
|
2369
|
+
}).filter((x) => x !== null);
|
2370
|
+
}
|
1830
2371
|
|
1831
2372
|
// ../commons/src/utils.ts
|
1832
2373
|
function getOrThrow(x, message) {
|
@@ -1835,6 +2376,9 @@ function getOrThrow(x, message) {
|
|
1835
2376
|
}
|
1836
2377
|
return x;
|
1837
2378
|
}
|
2379
|
+
function joinValues(values, separator = " ") {
|
2380
|
+
return values.filter((value) => !!value).join(separator).trim();
|
2381
|
+
}
|
1838
2382
|
|
1839
2383
|
// ../commons/src/events/utils.ts
|
1840
2384
|
function isDeclarationActionConfig(action) {
|
@@ -1867,6 +2411,13 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1867
2411
|
function getAllAnnotationFields(config) {
|
1868
2412
|
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1869
2413
|
}
|
2414
|
+
function getAllUniqueFields(eventConfig) {
|
2415
|
+
return (0, import_lodash.uniqBy)(getDeclarationFields(eventConfig), (field2) => field2.id);
|
2416
|
+
}
|
2417
|
+
function getDeclarationFieldById(config, fieldId) {
|
2418
|
+
const field2 = getAllUniqueFields(config).find((f) => f.id === fieldId);
|
2419
|
+
return getOrThrow(field2, `Field with id ${fieldId} not found in event config`);
|
2420
|
+
}
|
1870
2421
|
var findRecordActionPages = (config, actionType) => {
|
1871
2422
|
const action = config.actions.find((a) => a.type === actionType);
|
1872
2423
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1927,6 +2478,7 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1927
2478
|
declaration: {},
|
1928
2479
|
annotation: {},
|
1929
2480
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2481
|
+
createdByUserType: TokenUserType.Enum.user,
|
1930
2482
|
createdBy: "@todo",
|
1931
2483
|
createdAtLocation: "00000000-0000-0000-0000-000000000000",
|
1932
2484
|
status: ActionStatus.Accepted,
|
@@ -1972,8 +2524,9 @@ function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
|
1972
2524
|
);
|
1973
2525
|
}
|
1974
2526
|
function deepMerge(currentDocument, actionDocument) {
|
2527
|
+
const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
|
1975
2528
|
return (0, import_lodash.mergeWith)(
|
1976
|
-
|
2529
|
+
(0, import_lodash.cloneDeep)(currentDocumentClone),
|
1977
2530
|
actionDocument,
|
1978
2531
|
(previousValue, incomingValue) => {
|
1979
2532
|
if (incomingValue === void 0) {
|
@@ -2021,12 +2574,18 @@ function getMixedPath(obj, path, defaultValue) {
|
|
2021
2574
|
const result = resolve(obj, parts);
|
2022
2575
|
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
2023
2576
|
}
|
2577
|
+
function getEventConfigById(eventConfigs, id) {
|
2578
|
+
const eventConfig = eventConfigs.find(
|
2579
|
+
(eventConfiguration) => eventConfiguration.id === id
|
2580
|
+
);
|
2581
|
+
return getOrThrow(eventConfig, `Event config for ${id} not found`);
|
2582
|
+
}
|
2024
2583
|
|
2025
2584
|
// ../commons/src/events/EventConfig.ts
|
2026
2585
|
var import_zod_openapi8 = require("zod-openapi");
|
2027
|
-
(0, import_zod_openapi8.extendZodWithOpenApi)(
|
2028
|
-
var EventConfig =
|
2029
|
-
id:
|
2586
|
+
(0, import_zod_openapi8.extendZodWithOpenApi)(import_zod20.z);
|
2587
|
+
var EventConfig = import_zod20.z.object({
|
2588
|
+
id: import_zod20.z.string().describe(
|
2030
2589
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
2031
2590
|
),
|
2032
2591
|
dateOfEvent: FieldReference.optional(),
|
@@ -2036,10 +2595,10 @@ var EventConfig = import_zod18.z.object({
|
|
2036
2595
|
),
|
2037
2596
|
summary: SummaryConfig,
|
2038
2597
|
label: TranslationConfig,
|
2039
|
-
actions:
|
2598
|
+
actions: import_zod20.z.array(ActionConfig),
|
2040
2599
|
declaration: DeclarationFormConfig,
|
2041
|
-
deduplication:
|
2042
|
-
advancedSearch:
|
2600
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
2601
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
2043
2602
|
}).superRefine((event2, ctx) => {
|
2044
2603
|
const allFields = findAllFields(event2);
|
2045
2604
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -2101,12 +2660,12 @@ var definePage = (page) => PageConfig.parse(page);
|
|
2101
2660
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
2102
2661
|
|
2103
2662
|
// ../commons/src/events/WorkqueueConfig.ts
|
2104
|
-
var
|
2663
|
+
var import_zod27 = require("zod");
|
2105
2664
|
|
2106
2665
|
// ../commons/src/events/serializers/user/serializer.ts
|
2107
|
-
var
|
2108
|
-
var SerializedUserField =
|
2109
|
-
$userField:
|
2666
|
+
var import_zod21 = require("zod");
|
2667
|
+
var SerializedUserField = import_zod21.z.object({
|
2668
|
+
$userField: import_zod21.z.enum([
|
2110
2669
|
"id",
|
2111
2670
|
"name",
|
2112
2671
|
"role",
|
@@ -2214,9 +2773,6 @@ function createEventConditionals() {
|
|
2214
2773
|
})
|
2215
2774
|
};
|
2216
2775
|
}
|
2217
|
-
function getDateFromNow(days) {
|
2218
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2219
|
-
}
|
2220
2776
|
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2221
2777
|
return {
|
2222
2778
|
type: "object",
|
@@ -2235,6 +2791,20 @@ function isFieldReference(value) {
|
|
2235
2791
|
return typeof value === "object" && value !== null && "$$field" in value;
|
2236
2792
|
}
|
2237
2793
|
function createFieldConditionals(fieldId) {
|
2794
|
+
const getDayRange = (days, clause) => ({
|
2795
|
+
type: "object",
|
2796
|
+
properties: {
|
2797
|
+
[fieldId]: {
|
2798
|
+
type: "string",
|
2799
|
+
format: "date",
|
2800
|
+
daysFromNow: {
|
2801
|
+
days,
|
2802
|
+
clause
|
2803
|
+
}
|
2804
|
+
}
|
2805
|
+
},
|
2806
|
+
required: [fieldId]
|
2807
|
+
});
|
2238
2808
|
const getDateRange = (date, clause) => ({
|
2239
2809
|
type: "object",
|
2240
2810
|
properties: {
|
@@ -2253,12 +2823,8 @@ function createFieldConditionals(fieldId) {
|
|
2253
2823
|
$$field: fieldId,
|
2254
2824
|
isAfter: () => ({
|
2255
2825
|
days: (days) => ({
|
2256
|
-
inPast: () => defineFormConditional(
|
2257
|
-
|
2258
|
-
),
|
2259
|
-
inFuture: () => defineFormConditional(
|
2260
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2261
|
-
)
|
2826
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
2827
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
2262
2828
|
}),
|
2263
2829
|
date: (date) => {
|
2264
2830
|
if (isFieldReference(date)) {
|
@@ -2273,16 +2839,12 @@ function createFieldConditionals(fieldId) {
|
|
2273
2839
|
}
|
2274
2840
|
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2275
2841
|
},
|
2276
|
-
now: () => defineFormConditional(getDateRange(
|
2842
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
2277
2843
|
}),
|
2278
2844
|
isBefore: () => ({
|
2279
2845
|
days: (days) => ({
|
2280
|
-
inPast: () => defineFormConditional(
|
2281
|
-
|
2282
|
-
),
|
2283
|
-
inFuture: () => defineFormConditional(
|
2284
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2285
|
-
)
|
2846
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
2847
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
2286
2848
|
}),
|
2287
2849
|
date: (date) => {
|
2288
2850
|
if (isFieldReference(date)) {
|
@@ -2297,7 +2859,7 @@ function createFieldConditionals(fieldId) {
|
|
2297
2859
|
}
|
2298
2860
|
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2299
2861
|
},
|
2300
|
-
now: () => defineFormConditional(getDateRange(
|
2862
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
2301
2863
|
}),
|
2302
2864
|
isEqualTo: (value) => {
|
2303
2865
|
if (isFieldReference(value)) {
|
@@ -2307,7 +2869,7 @@ function createFieldConditionals(fieldId) {
|
|
2307
2869
|
properties: {
|
2308
2870
|
[fieldId]: {
|
2309
2871
|
type: ["string", "boolean"],
|
2310
|
-
const: { $data:
|
2872
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
2311
2873
|
},
|
2312
2874
|
[comparedFieldId]: { type: ["string", "boolean"] }
|
2313
2875
|
},
|
@@ -2417,6 +2979,23 @@ function createFieldConditionals(fieldId) {
|
|
2417
2979
|
}
|
2418
2980
|
},
|
2419
2981
|
required: [fieldId]
|
2982
|
+
}),
|
2983
|
+
getId: () => ({ fieldId }),
|
2984
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2985
|
+
object: (options) => defineFormConditional({
|
2986
|
+
type: "object",
|
2987
|
+
properties: {
|
2988
|
+
[fieldId]: {
|
2989
|
+
type: "object",
|
2990
|
+
properties: Object.fromEntries(
|
2991
|
+
Object.entries(options).map(([key, value]) => {
|
2992
|
+
return [key, value.properties.$form.properties[key]];
|
2993
|
+
})
|
2994
|
+
),
|
2995
|
+
required: Object.keys(options)
|
2996
|
+
}
|
2997
|
+
},
|
2998
|
+
required: [fieldId]
|
2420
2999
|
})
|
2421
3000
|
};
|
2422
3001
|
}
|
@@ -2492,89 +3071,83 @@ var event = Object.assign(eventFn, {
|
|
2492
3071
|
});
|
2493
3072
|
|
2494
3073
|
// ../commons/src/events/WorkqueueColumnConfig.ts
|
2495
|
-
var
|
3074
|
+
var import_zod23 = require("zod");
|
2496
3075
|
|
2497
3076
|
// ../commons/src/events/EventMetadata.ts
|
2498
|
-
var
|
2499
|
-
var EventStatus =
|
2500
|
-
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
var
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
EventStatus.REGISTERED,
|
2515
|
-
EventStatus.CERTIFIED,
|
2516
|
-
EventStatus.REJECTED,
|
2517
|
-
EventStatus.ARCHIVED
|
2518
|
-
];
|
2519
|
-
var EventStatusEnum = import_zod20.z.enum(eventStatusValues);
|
2520
|
-
var CustomFlags = {
|
2521
|
-
CERTIFICATE_PRINTED: "certificate-printed"
|
3077
|
+
var import_zod22 = require("zod");
|
3078
|
+
var EventStatus = import_zod22.z.enum([
|
3079
|
+
"CREATED",
|
3080
|
+
"NOTIFIED",
|
3081
|
+
"DECLARED",
|
3082
|
+
"VALIDATED",
|
3083
|
+
"REGISTERED",
|
3084
|
+
"CERTIFIED",
|
3085
|
+
"REJECTED",
|
3086
|
+
"ARCHIVED"
|
3087
|
+
]);
|
3088
|
+
var InherentFlags = {
|
3089
|
+
PRINTED: "printed",
|
3090
|
+
INCOMPLETE: "incomplete",
|
3091
|
+
REJECTED: "rejected",
|
3092
|
+
CORRECTION_REQUESTED: "correction-requested"
|
2522
3093
|
};
|
2523
|
-
var Flag =
|
3094
|
+
var Flag = import_zod22.z.string().regex(
|
2524
3095
|
new RegExp(
|
2525
3096
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
2526
3097
|
ActionStatus
|
2527
3098
|
).join("|").toLowerCase()})$`
|
2528
3099
|
),
|
2529
3100
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2530
|
-
).or(
|
2531
|
-
var
|
2532
|
-
var
|
2533
|
-
|
2534
|
-
|
2535
|
-
createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
|
2536
|
-
createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
|
3101
|
+
).or(import_zod22.z.nativeEnum(InherentFlags));
|
3102
|
+
var ZodDate = import_zod22.z.string().date();
|
3103
|
+
var ActionCreationMetadata = import_zod22.z.object({
|
3104
|
+
createdAt: import_zod22.z.string().datetime().describe("The timestamp when the action request was created."),
|
3105
|
+
createdBy: import_zod22.z.string().describe("ID of the user who created the action request."),
|
2537
3106
|
createdAtLocation: CreatedAtLocation.describe(
|
2538
3107
|
"Location of the user who created the action request."
|
2539
3108
|
),
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
3109
|
+
createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
|
3110
|
+
acceptedAt: import_zod22.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
3111
|
+
createdByRole: import_zod22.z.string().describe("Role of the user at the time of action request creation."),
|
3112
|
+
createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the action request.")
|
2543
3113
|
});
|
2544
3114
|
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2545
|
-
registrationNumber:
|
3115
|
+
registrationNumber: import_zod22.z.string().describe(
|
2546
3116
|
"Registration number of the event. Always present for accepted registrations."
|
2547
3117
|
)
|
2548
3118
|
});
|
2549
|
-
var LegalStatuses =
|
2550
|
-
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2551
|
-
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
3119
|
+
var LegalStatuses = import_zod22.z.object({
|
3120
|
+
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
3121
|
+
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2552
3122
|
});
|
2553
|
-
var EventMetadata =
|
3123
|
+
var EventMetadata = import_zod22.z.object({
|
2554
3124
|
id: UUID,
|
2555
|
-
type:
|
2556
|
-
status:
|
3125
|
+
type: import_zod22.z.string().describe("The type of event, such as birth, death, or marriage."),
|
3126
|
+
status: EventStatus,
|
2557
3127
|
legalStatuses: LegalStatuses.describe(
|
2558
3128
|
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2559
3129
|
),
|
2560
|
-
createdAt:
|
3130
|
+
createdAt: import_zod22.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2561
3131
|
dateOfEvent: ZodDate.nullish(),
|
2562
|
-
createdBy:
|
2563
|
-
|
3132
|
+
createdBy: import_zod22.z.string().describe("ID of the user who created the event."),
|
3133
|
+
createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
|
3134
|
+
updatedByUserRole: import_zod22.z.string().describe("Role of the user who last changed the status."),
|
2564
3135
|
createdAtLocation: CreatedAtLocation.describe(
|
2565
3136
|
"Location of the user who created the event."
|
2566
3137
|
),
|
2567
|
-
createdBySignature:
|
3138
|
+
createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the event."),
|
2568
3139
|
updatedAtLocation: UUID.nullish().describe(
|
2569
|
-
"Location of the user who last
|
3140
|
+
"Location of the user who last changed the status."
|
3141
|
+
),
|
3142
|
+
updatedAt: import_zod22.z.string().datetime().describe(
|
3143
|
+
"Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
|
2570
3144
|
),
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
trackingId: import_zod20.z.string().describe(
|
3145
|
+
assignedTo: import_zod22.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
3146
|
+
updatedBy: import_zod22.z.string().nullish().describe("ID of the user who last changed the status."),
|
3147
|
+
trackingId: import_zod22.z.string().describe(
|
2575
3148
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
2576
3149
|
),
|
2577
|
-
flags:
|
3150
|
+
flags: import_zod22.z.array(Flag)
|
2578
3151
|
});
|
2579
3152
|
var EventMetadataKeysArray = [
|
2580
3153
|
"id",
|
@@ -2583,6 +3156,7 @@ var EventMetadataKeysArray = [
|
|
2583
3156
|
"createdAt",
|
2584
3157
|
"dateOfEvent",
|
2585
3158
|
"createdBy",
|
3159
|
+
"createdByUserType",
|
2586
3160
|
"updatedByUserRole",
|
2587
3161
|
"createdAtLocation",
|
2588
3162
|
"updatedAtLocation",
|
@@ -2593,7 +3167,7 @@ var EventMetadataKeysArray = [
|
|
2593
3167
|
"legalStatuses",
|
2594
3168
|
"flags"
|
2595
3169
|
];
|
2596
|
-
var EventMetadataKeys =
|
3170
|
+
var EventMetadataKeys = import_zod22.z.enum(EventMetadataKeysArray);
|
2597
3171
|
var eventMetadataLabelMap = {
|
2598
3172
|
"event.assignedTo": {
|
2599
3173
|
id: "event.assignedTo.label",
|
@@ -2605,6 +3179,11 @@ var eventMetadataLabelMap = {
|
|
2605
3179
|
defaultMessage: "Created",
|
2606
3180
|
description: "Created At"
|
2607
3181
|
},
|
3182
|
+
"event.createdByUserType": {
|
3183
|
+
id: "event.createdByUserType.label",
|
3184
|
+
defaultMessage: "createdByUserType",
|
3185
|
+
description: "createdByUserType:user or system"
|
3186
|
+
},
|
2608
3187
|
"event.dateOfEvent": {
|
2609
3188
|
id: "event.dateOfEvent.label",
|
2610
3189
|
defaultMessage: "Date of Event",
|
@@ -2670,13 +3249,14 @@ var eventMetadataLabelMap = {
|
|
2670
3249
|
// ../commons/src/events/WorkqueueColumnConfig.ts
|
2671
3250
|
var WorkqueueColumnKeysArray = [
|
2672
3251
|
...EventMetadataKeysArray,
|
2673
|
-
"title"
|
3252
|
+
"title",
|
3253
|
+
"outbox"
|
2674
3254
|
];
|
2675
|
-
var WorkqueueColumnKeys =
|
2676
|
-
var WorkqueueColumnValue =
|
3255
|
+
var WorkqueueColumnKeys = import_zod23.z.enum(WorkqueueColumnKeysArray);
|
3256
|
+
var WorkqueueColumnValue = import_zod23.z.object({
|
2677
3257
|
$event: WorkqueueColumnKeys
|
2678
3258
|
});
|
2679
|
-
var WorkqueueColumn =
|
3259
|
+
var WorkqueueColumn = import_zod23.z.object({
|
2680
3260
|
label: TranslationConfig,
|
2681
3261
|
value: WorkqueueColumnValue
|
2682
3262
|
});
|
@@ -2687,96 +3267,115 @@ function defineWorkqueuesColumns(workqueueColumns) {
|
|
2687
3267
|
}
|
2688
3268
|
|
2689
3269
|
// ../commons/src/events/CountryConfigQueryInput.ts
|
2690
|
-
var
|
3270
|
+
var import_zod25 = require("zod");
|
2691
3271
|
|
2692
3272
|
// ../commons/src/events/EventIndex.ts
|
2693
|
-
var
|
3273
|
+
var import_zod24 = require("zod");
|
2694
3274
|
var import_zod_openapi9 = require("zod-openapi");
|
2695
|
-
(0, import_zod_openapi9.extendZodWithOpenApi)(
|
3275
|
+
(0, import_zod_openapi9.extendZodWithOpenApi)(import_zod24.z);
|
2696
3276
|
var EventIndex = EventMetadata.extend({
|
2697
3277
|
declaration: EventState
|
2698
3278
|
}).openapi({
|
2699
3279
|
ref: "EventIndex"
|
2700
3280
|
});
|
2701
|
-
var EventSearchIndex =
|
2702
|
-
|
2703
|
-
type:
|
3281
|
+
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
3282
|
+
import_zod24.z.object({
|
3283
|
+
type: import_zod24.z.string()
|
2704
3284
|
// Ensures "type" (event-id) exists and is a string
|
2705
3285
|
})
|
2706
3286
|
).openapi({
|
2707
3287
|
ref: "EventSearchIndex"
|
2708
3288
|
});
|
2709
|
-
var Fuzzy =
|
3289
|
+
var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() }).openapi({
|
2710
3290
|
ref: "Fuzzy"
|
2711
3291
|
});
|
2712
|
-
var Exact =
|
3292
|
+
var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() }).openapi({
|
2713
3293
|
ref: "Exact"
|
2714
3294
|
});
|
2715
|
-
var
|
2716
|
-
type:
|
2717
|
-
|
3295
|
+
var ExactStatus = import_zod24.z.object({
|
3296
|
+
type: import_zod24.z.literal("exact"),
|
3297
|
+
term: EventStatus
|
2718
3298
|
}).openapi({
|
2719
|
-
ref: "
|
3299
|
+
ref: "ExactStatus"
|
2720
3300
|
});
|
2721
|
-
var
|
2722
|
-
type:
|
2723
|
-
|
3301
|
+
var AnyOf = import_zod24.z.object({
|
3302
|
+
type: import_zod24.z.literal("anyOf"),
|
3303
|
+
terms: import_zod24.z.array(import_zod24.z.string())
|
2724
3304
|
}).openapi({
|
2725
|
-
ref: "
|
3305
|
+
ref: "AnyOf"
|
2726
3306
|
});
|
2727
|
-
var AnyOfStatus =
|
2728
|
-
type:
|
2729
|
-
terms:
|
3307
|
+
var AnyOfStatus = import_zod24.z.object({
|
3308
|
+
type: import_zod24.z.literal("anyOf"),
|
3309
|
+
terms: import_zod24.z.array(EventStatus)
|
2730
3310
|
}).openapi({
|
2731
3311
|
ref: "AnyOfStatus"
|
2732
3312
|
});
|
2733
|
-
var Range =
|
2734
|
-
type:
|
2735
|
-
gte:
|
2736
|
-
lte:
|
3313
|
+
var Range = import_zod24.z.object({
|
3314
|
+
type: import_zod24.z.literal("range"),
|
3315
|
+
gte: import_zod24.z.string(),
|
3316
|
+
lte: import_zod24.z.string()
|
2737
3317
|
}).openapi({
|
2738
3318
|
ref: "Range"
|
2739
3319
|
});
|
2740
|
-
var
|
2741
|
-
|
3320
|
+
var ContainsFlags = import_zod24.z.object({
|
3321
|
+
anyOf: import_zod24.z.array(Flag).optional(),
|
3322
|
+
noneOf: import_zod24.z.array(Flag).optional()
|
3323
|
+
}).openapi({
|
3324
|
+
ref: "ContainsFlags"
|
2742
3325
|
});
|
2743
|
-
var Within =
|
3326
|
+
var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() }).openapi({
|
2744
3327
|
ref: "Within"
|
2745
3328
|
});
|
2746
|
-
var
|
3329
|
+
var RangeDate = Range.extend({
|
3330
|
+
gte: import_zod24.z.string().date().or(import_zod24.z.string().datetime()),
|
3331
|
+
lte: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
|
3332
|
+
}).openapi({
|
3333
|
+
ref: "RangeDate"
|
3334
|
+
});
|
3335
|
+
var ExactDate = Exact.extend({
|
3336
|
+
term: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
|
3337
|
+
}).openapi({
|
3338
|
+
ref: "ExactDate"
|
3339
|
+
});
|
3340
|
+
var DateCondition = import_zod24.z.union([ExactDate, RangeDate]).openapi({
|
2747
3341
|
ref: "DateCondition"
|
2748
3342
|
});
|
2749
|
-
var QueryInput =
|
2750
|
-
() =>
|
2751
|
-
|
2752
|
-
|
3343
|
+
var QueryInput = import_zod24.z.lazy(
|
3344
|
+
() => import_zod24.z.union([
|
3345
|
+
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
3346
|
+
import_zod24.z.record(import_zod24.z.string(), QueryInput)
|
2753
3347
|
])
|
2754
3348
|
).openapi({
|
2755
3349
|
ref: "QueryInput"
|
2756
3350
|
});
|
2757
|
-
var QueryExpression =
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
"legalStatus.REGISTERED.
|
2764
|
-
|
3351
|
+
var QueryExpression = import_zod24.z.object({
|
3352
|
+
id: import_zod24.z.optional(import_zod24.z.string()),
|
3353
|
+
eventType: import_zod24.z.string(),
|
3354
|
+
status: import_zod24.z.optional(import_zod24.z.union([AnyOfStatus, ExactStatus])),
|
3355
|
+
createdAt: import_zod24.z.optional(DateCondition),
|
3356
|
+
updatedAt: import_zod24.z.optional(DateCondition),
|
3357
|
+
"legalStatus.REGISTERED.createdAt": import_zod24.z.optional(DateCondition),
|
3358
|
+
"legalStatus.REGISTERED.createdAtLocation": import_zod24.z.optional(
|
3359
|
+
import_zod24.z.union([Within, Exact])
|
2765
3360
|
),
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
3361
|
+
"legalStatus.REGISTERED.registrationNumber": import_zod24.z.optional(Exact),
|
3362
|
+
createdAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
3363
|
+
updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
3364
|
+
assignedTo: import_zod24.z.optional(Exact),
|
3365
|
+
createdByUserType: TokenUserType,
|
3366
|
+
createdBy: import_zod24.z.optional(Exact),
|
3367
|
+
updatedBy: import_zod24.z.optional(Exact),
|
3368
|
+
trackingId: import_zod24.z.optional(Exact),
|
3369
|
+
flags: import_zod24.z.optional(ContainsFlags),
|
2773
3370
|
data: QueryInput
|
2774
|
-
}).partial().
|
3371
|
+
}).partial().refine((obj) => Object.values(obj).some((val) => val !== void 0), {
|
3372
|
+
message: "At least one query field must be specified."
|
3373
|
+
}).openapi({
|
2775
3374
|
ref: "QueryExpression"
|
2776
3375
|
});
|
2777
|
-
var QueryType =
|
2778
|
-
type:
|
2779
|
-
clauses:
|
3376
|
+
var QueryType = import_zod24.z.object({
|
3377
|
+
type: import_zod24.z.literal("and").or(import_zod24.z.literal("or")).openapi({ default: "and" }),
|
3378
|
+
clauses: import_zod24.z.preprocess(
|
2780
3379
|
(val) => {
|
2781
3380
|
if (typeof val === "string") {
|
2782
3381
|
return [JSON.parse(val)];
|
@@ -2786,22 +3385,13 @@ var QueryType = import_zod22.z.object({
|
|
2786
3385
|
}
|
2787
3386
|
return val;
|
2788
3387
|
},
|
2789
|
-
|
3388
|
+
import_zod24.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
|
2790
3389
|
default: [
|
2791
3390
|
{
|
2792
3391
|
eventType: TENNIS_CLUB_MEMBERSHIP,
|
2793
3392
|
status: {
|
2794
3393
|
type: "anyOf",
|
2795
|
-
terms:
|
2796
|
-
"CREATED",
|
2797
|
-
"NOTIFIED",
|
2798
|
-
"DECLARED",
|
2799
|
-
"VALIDATED",
|
2800
|
-
"REGISTERED",
|
2801
|
-
"CERTIFIED",
|
2802
|
-
"REJECTED",
|
2803
|
-
"ARCHIVED"
|
2804
|
-
]
|
3394
|
+
terms: EventStatus.options
|
2805
3395
|
},
|
2806
3396
|
updatedAt: {
|
2807
3397
|
type: "range",
|
@@ -2818,50 +3408,56 @@ var QueryType = import_zod22.z.object({
|
|
2818
3408
|
});
|
2819
3409
|
|
2820
3410
|
// ../commons/src/events/CountryConfigQueryInput.ts
|
2821
|
-
var SerializableExact =
|
2822
|
-
type:
|
2823
|
-
term:
|
3411
|
+
var SerializableExact = import_zod25.z.object({
|
3412
|
+
type: import_zod25.z.literal("exact"),
|
3413
|
+
term: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
|
2824
3414
|
});
|
2825
|
-
var SerializableWithin =
|
2826
|
-
type:
|
2827
|
-
location:
|
3415
|
+
var SerializableWithin = import_zod25.z.object({
|
3416
|
+
type: import_zod25.z.literal("within"),
|
3417
|
+
location: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
|
2828
3418
|
});
|
2829
|
-
var SerializedQueryExpression =
|
2830
|
-
eventType:
|
2831
|
-
status:
|
2832
|
-
createdAt:
|
2833
|
-
updatedAt:
|
2834
|
-
|
2835
|
-
|
3419
|
+
var SerializedQueryExpression = import_zod25.z.object({
|
3420
|
+
eventType: import_zod25.z.string(),
|
3421
|
+
status: import_zod25.z.optional(import_zod25.z.union([AnyOfStatus, ExactStatus])),
|
3422
|
+
createdAt: import_zod25.z.optional(DateCondition),
|
3423
|
+
updatedAt: import_zod25.z.optional(DateCondition),
|
3424
|
+
"legalStatus.REGISTERED.createdAt": import_zod25.z.optional(DateCondition),
|
3425
|
+
"legalStatus.REGISTERED.createdAtLocation": import_zod25.z.optional(
|
3426
|
+
import_zod25.z.union([Within, Exact])
|
3427
|
+
),
|
3428
|
+
"legalStatus.REGISTERED.registrationNumber": import_zod25.z.optional(Exact),
|
3429
|
+
createdAtLocation: import_zod25.z.optional(
|
3430
|
+
import_zod25.z.union([SerializableWithin, SerializableExact])
|
2836
3431
|
),
|
2837
|
-
updatedAtLocation:
|
2838
|
-
|
3432
|
+
updatedAtLocation: import_zod25.z.optional(
|
3433
|
+
import_zod25.z.union([SerializableWithin, SerializableExact])
|
2839
3434
|
),
|
2840
|
-
assignedTo:
|
2841
|
-
createdBy:
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
3435
|
+
assignedTo: import_zod25.z.optional(SerializableExact),
|
3436
|
+
createdBy: import_zod25.z.optional(SerializableExact),
|
3437
|
+
createdByUserType: TokenUserType,
|
3438
|
+
updatedBy: import_zod25.z.optional(SerializableExact),
|
3439
|
+
trackingId: import_zod25.z.optional(Exact),
|
3440
|
+
flags: import_zod25.z.optional(ContainsFlags),
|
2845
3441
|
data: QueryInput
|
2846
3442
|
}).partial();
|
2847
|
-
var Or2 =
|
2848
|
-
type:
|
2849
|
-
clauses:
|
3443
|
+
var Or2 = import_zod25.z.object({
|
3444
|
+
type: import_zod25.z.literal("or"),
|
3445
|
+
clauses: import_zod25.z.array(SerializedQueryExpression)
|
2850
3446
|
});
|
2851
|
-
var And2 =
|
2852
|
-
type:
|
2853
|
-
clauses:
|
3447
|
+
var And2 = import_zod25.z.object({
|
3448
|
+
type: import_zod25.z.literal("and"),
|
3449
|
+
clauses: import_zod25.z.array(SerializedQueryExpression)
|
2854
3450
|
});
|
2855
|
-
var CountryConfigQueryType =
|
2856
|
-
var CountryConfigQueryInputType =
|
3451
|
+
var CountryConfigQueryType = import_zod25.z.discriminatedUnion("type", [And2, Or2]);
|
3452
|
+
var CountryConfigQueryInputType = import_zod25.z.union([
|
2857
3453
|
SerializedQueryExpression,
|
2858
3454
|
And2,
|
2859
3455
|
Or2
|
2860
3456
|
]);
|
2861
3457
|
|
2862
3458
|
// ../commons/src/icons.ts
|
2863
|
-
var
|
2864
|
-
var AvailableIcons =
|
3459
|
+
var import_zod26 = require("zod");
|
3460
|
+
var AvailableIcons = import_zod26.z.enum([
|
2865
3461
|
"Archived",
|
2866
3462
|
"Assigned",
|
2867
3463
|
"Certified",
|
@@ -2899,7 +3495,6 @@ var AvailableIcons = import_zod24.z.enum([
|
|
2899
3495
|
"Copy",
|
2900
3496
|
"Database",
|
2901
3497
|
"DotsThreeVertical",
|
2902
|
-
"DownloadSimple",
|
2903
3498
|
"ArrowCounterClockwise",
|
2904
3499
|
"MagnifyingGlassMinus",
|
2905
3500
|
"MagnifyingGlassPlus",
|
@@ -2965,7 +3560,7 @@ var AvailableIcons = import_zod24.z.enum([
|
|
2965
3560
|
]);
|
2966
3561
|
|
2967
3562
|
// ../commons/src/events/WorkqueueConfig.ts
|
2968
|
-
var
|
3563
|
+
var mandatoryColumns = defineWorkqueuesColumns([
|
2969
3564
|
{
|
2970
3565
|
label: {
|
2971
3566
|
id: "workqueues.dateOfEvent",
|
@@ -2983,34 +3578,42 @@ var dateOfEventColumn = defineWorkqueuesColumns([
|
|
2983
3578
|
value: event.field("updatedAt")
|
2984
3579
|
}
|
2985
3580
|
]);
|
2986
|
-
var
|
2987
|
-
|
3581
|
+
var WorkqueueActionsWithDefault = import_zod27.z.enum([
|
3582
|
+
...workqueueActions.options,
|
3583
|
+
"DEFAULT"
|
3584
|
+
]);
|
3585
|
+
var WorkqueueConfig = import_zod27.z.object({
|
3586
|
+
slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
|
2988
3587
|
name: TranslationConfig.describe(
|
2989
3588
|
"Title of the workflow (both in navigation and on the page)"
|
2990
3589
|
),
|
2991
3590
|
query: CountryConfigQueryType,
|
2992
|
-
actions:
|
2993
|
-
|
2994
|
-
type:
|
2995
|
-
conditionals:
|
3591
|
+
actions: import_zod27.z.array(
|
3592
|
+
import_zod27.z.object({
|
3593
|
+
type: WorkqueueActionsWithDefault,
|
3594
|
+
conditionals: import_zod27.z.array(Conditional).optional()
|
2996
3595
|
})
|
2997
3596
|
),
|
2998
|
-
columns:
|
3597
|
+
columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
|
2999
3598
|
icon: AvailableIcons
|
3000
3599
|
}).describe("Configuration for workqueue.");
|
3001
|
-
var
|
3002
|
-
|
3600
|
+
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3601
|
+
query: true,
|
3602
|
+
columns: true
|
3603
|
+
});
|
3604
|
+
var WorkqueueConfigInput = import_zod27.z.object({
|
3605
|
+
slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
|
3003
3606
|
name: TranslationConfig.describe(
|
3004
3607
|
"Title of the workflow (both in navigation and on the page)"
|
3005
3608
|
),
|
3006
3609
|
query: CountryConfigQueryInputType,
|
3007
|
-
actions:
|
3008
|
-
|
3009
|
-
type:
|
3010
|
-
conditionals:
|
3610
|
+
actions: import_zod27.z.array(
|
3611
|
+
import_zod27.z.object({
|
3612
|
+
type: WorkqueueActionsWithDefault,
|
3613
|
+
conditionals: import_zod27.z.array(Conditional).optional()
|
3011
3614
|
})
|
3012
3615
|
),
|
3013
|
-
columns:
|
3616
|
+
columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3014
3617
|
icon: AvailableIcons
|
3015
3618
|
});
|
3016
3619
|
function defineWorkqueue(workqueueInput) {
|
@@ -3021,10 +3624,10 @@ function defineWorkqueue(workqueueInput) {
|
|
3021
3624
|
function defineWorkqueues(workqueues) {
|
3022
3625
|
return workqueues.map((workqueue) => defineWorkqueue(workqueue));
|
3023
3626
|
}
|
3024
|
-
var WorkqueueCountInput =
|
3025
|
-
|
3627
|
+
var WorkqueueCountInput = import_zod27.z.array(
|
3628
|
+
import_zod27.z.object({ slug: import_zod27.z.string(), query: QueryType })
|
3026
3629
|
);
|
3027
|
-
var WorkqueueCountOutput =
|
3630
|
+
var WorkqueueCountOutput = import_zod27.z.record(import_zod27.z.string(), import_zod27.z.number());
|
3028
3631
|
|
3029
3632
|
// ../commons/src/events/workqueueDefaultColumns.ts
|
3030
3633
|
var defaultWorkqueueColumns = [
|
@@ -3047,41 +3650,42 @@ var defaultWorkqueueColumns = [
|
|
3047
3650
|
];
|
3048
3651
|
|
3049
3652
|
// ../commons/src/events/Draft.ts
|
3050
|
-
var
|
3653
|
+
var import_zod29 = require("zod");
|
3051
3654
|
|
3052
3655
|
// ../commons/src/events/ActionInput.ts
|
3053
|
-
var
|
3656
|
+
var import_zod28 = require("zod");
|
3054
3657
|
var import_zod_openapi10 = require("zod-openapi");
|
3055
|
-
(0, import_zod_openapi10.extendZodWithOpenApi)(
|
3056
|
-
var BaseActionInput =
|
3658
|
+
(0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
|
3659
|
+
var BaseActionInput = import_zod28.z.object({
|
3057
3660
|
eventId: UUID,
|
3058
|
-
transactionId:
|
3661
|
+
transactionId: import_zod28.z.string(),
|
3059
3662
|
declaration: ActionUpdate.default({}),
|
3060
3663
|
annotation: ActionUpdate.optional(),
|
3061
3664
|
originalActionId: UUID.optional(),
|
3062
|
-
|
3665
|
+
// should not be part of base action.
|
3666
|
+
keepAssignment: import_zod28.z.boolean().optional()
|
3063
3667
|
});
|
3064
3668
|
var CreateActionInput = BaseActionInput.merge(
|
3065
|
-
|
3066
|
-
type:
|
3669
|
+
import_zod28.z.object({
|
3670
|
+
type: import_zod28.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
3067
3671
|
createdAtLocation: CreatedAtLocation
|
3068
3672
|
})
|
3069
3673
|
);
|
3070
3674
|
var RegisterActionInput = BaseActionInput.merge(
|
3071
|
-
|
3072
|
-
type:
|
3073
|
-
registrationNumber:
|
3675
|
+
import_zod28.z.object({
|
3676
|
+
type: import_zod28.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
3677
|
+
registrationNumber: import_zod28.z.string().optional()
|
3074
3678
|
})
|
3075
|
-
);
|
3679
|
+
).strict();
|
3076
3680
|
var ValidateActionInput = BaseActionInput.merge(
|
3077
|
-
|
3078
|
-
type:
|
3079
|
-
duplicates:
|
3681
|
+
import_zod28.z.object({
|
3682
|
+
type: import_zod28.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
3683
|
+
duplicates: import_zod28.z.array(import_zod28.z.string())
|
3080
3684
|
})
|
3081
3685
|
);
|
3082
3686
|
var NotifyActionInput = BaseActionInput.merge(
|
3083
|
-
|
3084
|
-
type:
|
3687
|
+
import_zod28.z.object({
|
3688
|
+
type: import_zod28.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
3085
3689
|
})
|
3086
3690
|
).openapi({
|
3087
3691
|
default: {
|
@@ -3093,68 +3697,68 @@ var NotifyActionInput = BaseActionInput.merge(
|
|
3093
3697
|
}
|
3094
3698
|
});
|
3095
3699
|
var DeclareActionInput = BaseActionInput.merge(
|
3096
|
-
|
3097
|
-
type:
|
3700
|
+
import_zod28.z.object({
|
3701
|
+
type: import_zod28.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
3098
3702
|
})
|
3099
3703
|
);
|
3100
3704
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
3101
|
-
|
3102
|
-
type:
|
3705
|
+
import_zod28.z.object({
|
3706
|
+
type: import_zod28.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
3103
3707
|
})
|
3104
3708
|
);
|
3105
3709
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
3106
|
-
|
3107
|
-
type:
|
3710
|
+
import_zod28.z.object({
|
3711
|
+
type: import_zod28.z.literal(ActionType.REJECT).default(ActionType.REJECT),
|
3108
3712
|
reason: RejectionReason
|
3109
3713
|
})
|
3110
3714
|
);
|
3111
3715
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
3112
|
-
|
3113
|
-
type:
|
3716
|
+
import_zod28.z.object({
|
3717
|
+
type: import_zod28.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
3114
3718
|
})
|
3115
3719
|
);
|
3116
3720
|
var ArchiveActionInput = BaseActionInput.merge(
|
3117
|
-
|
3118
|
-
type:
|
3721
|
+
import_zod28.z.object({
|
3722
|
+
type: import_zod28.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
|
3119
3723
|
reason: RejectionReason
|
3120
3724
|
})
|
3121
3725
|
);
|
3122
3726
|
var AssignActionInput = BaseActionInput.merge(
|
3123
|
-
|
3124
|
-
type:
|
3125
|
-
assignedTo:
|
3727
|
+
import_zod28.z.object({
|
3728
|
+
type: import_zod28.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
3729
|
+
assignedTo: import_zod28.z.string()
|
3126
3730
|
})
|
3127
3731
|
);
|
3128
3732
|
var UnassignActionInput = BaseActionInput.merge(
|
3129
|
-
|
3130
|
-
type:
|
3131
|
-
assignedTo:
|
3733
|
+
import_zod28.z.object({
|
3734
|
+
type: import_zod28.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
3735
|
+
assignedTo: import_zod28.z.literal(null).default(null)
|
3132
3736
|
})
|
3133
3737
|
);
|
3134
3738
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
3135
|
-
|
3136
|
-
type:
|
3739
|
+
import_zod28.z.object({
|
3740
|
+
type: import_zod28.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
3137
3741
|
})
|
3138
3742
|
);
|
3139
3743
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
3140
|
-
|
3141
|
-
requestId:
|
3142
|
-
type:
|
3744
|
+
import_zod28.z.object({
|
3745
|
+
requestId: import_zod28.z.string(),
|
3746
|
+
type: import_zod28.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
3143
3747
|
})
|
3144
3748
|
);
|
3145
3749
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
3146
|
-
|
3147
|
-
requestId:
|
3148
|
-
type:
|
3750
|
+
import_zod28.z.object({
|
3751
|
+
requestId: import_zod28.z.string(),
|
3752
|
+
type: import_zod28.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
3149
3753
|
})
|
3150
3754
|
);
|
3151
3755
|
var ReadActionInput = BaseActionInput.merge(
|
3152
|
-
|
3153
|
-
type:
|
3756
|
+
import_zod28.z.object({
|
3757
|
+
type: import_zod28.z.literal(ActionType.READ).default(ActionType.READ)
|
3154
3758
|
})
|
3155
3759
|
);
|
3156
|
-
var DeleteActionInput =
|
3157
|
-
var ActionInput =
|
3760
|
+
var DeleteActionInput = import_zod28.z.object({ eventId: UUID });
|
3761
|
+
var ActionInput = import_zod28.z.discriminatedUnion("type", [
|
3158
3762
|
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
3159
3763
|
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
3160
3764
|
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
@@ -3183,18 +3787,18 @@ var ActionInput = import_zod26.z.discriminatedUnion("type", [
|
|
3183
3787
|
});
|
3184
3788
|
|
3185
3789
|
// ../commons/src/events/Draft.ts
|
3186
|
-
var Draft =
|
3790
|
+
var Draft = import_zod29.z.object({
|
3187
3791
|
id: UUID,
|
3188
3792
|
eventId: UUID,
|
3189
|
-
transactionId:
|
3190
|
-
createdAt:
|
3793
|
+
transactionId: import_zod29.z.string(),
|
3794
|
+
createdAt: import_zod29.z.string().datetime(),
|
3191
3795
|
action: ActionBase.extend({
|
3192
3796
|
type: ActionTypes
|
3193
3797
|
}).omit({ id: true })
|
3194
3798
|
});
|
3195
3799
|
var DraftInput = BaseActionInput.extend({
|
3196
3800
|
type: ActionTypes,
|
3197
|
-
status:
|
3801
|
+
status: import_zod29.z.enum([
|
3198
3802
|
ActionStatus.Requested,
|
3199
3803
|
ActionStatus.Accepted,
|
3200
3804
|
ActionStatus.Rejected
|
@@ -3202,27 +3806,28 @@ var DraftInput = BaseActionInput.extend({
|
|
3202
3806
|
});
|
3203
3807
|
|
3204
3808
|
// ../commons/src/events/EventInput.ts
|
3205
|
-
var
|
3809
|
+
var import_zod30 = require("zod");
|
3206
3810
|
var import_uuid8 = require("uuid");
|
3207
|
-
var EventInput =
|
3208
|
-
transactionId:
|
3209
|
-
type:
|
3811
|
+
var EventInput = import_zod30.z.object({
|
3812
|
+
transactionId: import_zod30.z.string(),
|
3813
|
+
type: import_zod30.z.string()
|
3210
3814
|
}).openapi({ default: { transactionId: (0, import_uuid8.v4)(), type: "v2.birth" } });
|
3211
3815
|
|
3212
3816
|
// ../commons/src/events/EventDocument.ts
|
3213
|
-
var
|
3817
|
+
var import_zod31 = require("zod");
|
3214
3818
|
var import_zod_openapi11 = require("zod-openapi");
|
3215
|
-
(0, import_zod_openapi11.extendZodWithOpenApi)(
|
3216
|
-
var EventDocument =
|
3819
|
+
(0, import_zod_openapi11.extendZodWithOpenApi)(import_zod31.z);
|
3820
|
+
var EventDocument = import_zod31.z.object({
|
3217
3821
|
id: UUID,
|
3218
|
-
type:
|
3219
|
-
createdAt:
|
3220
|
-
updatedAt:
|
3221
|
-
actions:
|
3222
|
-
trackingId:
|
3822
|
+
type: import_zod31.z.string(),
|
3823
|
+
createdAt: import_zod31.z.string().datetime(),
|
3824
|
+
updatedAt: import_zod31.z.string().datetime(),
|
3825
|
+
actions: import_zod31.z.array(Action),
|
3826
|
+
trackingId: import_zod31.z.string()
|
3223
3827
|
}).openapi({ ref: "EventDocument" });
|
3224
3828
|
|
3225
3829
|
// ../commons/src/events/state/utils.ts
|
3830
|
+
var import_lodash2 = require("lodash");
|
3226
3831
|
function getActionRequests(actionType, actions) {
|
3227
3832
|
const filtered = actions.filter((action) => action.type === actionType);
|
3228
3833
|
const accept = filtered.find(
|
@@ -3253,6 +3858,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3253
3858
|
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
3254
3859
|
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
3255
3860
|
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
3861
|
+
createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
|
3256
3862
|
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
3257
3863
|
acceptedAt: acceptAction.createdAt,
|
3258
3864
|
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
@@ -3260,68 +3866,133 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
|
|
3260
3866
|
registrationNumber
|
3261
3867
|
};
|
3262
3868
|
}
|
3263
|
-
|
3869
|
+
var updateActions = ActionTypes.extract([
|
3870
|
+
ActionType.CREATE,
|
3871
|
+
ActionType.NOTIFY,
|
3872
|
+
ActionType.DECLARE,
|
3873
|
+
ActionType.VALIDATE,
|
3874
|
+
ActionType.REGISTER,
|
3875
|
+
ActionType.REJECT,
|
3876
|
+
ActionType.ARCHIVE,
|
3877
|
+
ActionType.PRINT_CERTIFICATE,
|
3878
|
+
ActionType.REQUEST_CORRECTION
|
3879
|
+
]);
|
3880
|
+
function getActionUpdateMetadata(actions) {
|
3264
3881
|
const createAction = getOrThrow(
|
3265
3882
|
actions.find((action) => action.type === ActionType.CREATE),
|
3266
3883
|
`Event has no ${ActionType.CREATE} action`
|
3267
3884
|
);
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3885
|
+
const metadataFields = [
|
3886
|
+
"createdAt",
|
3887
|
+
"createdBy",
|
3888
|
+
"createdByUserType",
|
3889
|
+
"createdAtLocation",
|
3890
|
+
"createdByRole"
|
3891
|
+
];
|
3892
|
+
return actions.filter(({ type }) => updateActions.safeParse(type).success).filter(({ status }) => status === ActionStatus.Accepted).reduce(
|
3893
|
+
(_, action) => {
|
3894
|
+
if (action.originalActionId) {
|
3895
|
+
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
3896
|
+
return (0, import_lodash2.pick)(originalAction, metadataFields);
|
3897
|
+
}
|
3898
|
+
return (0, import_lodash2.pick)(action, metadataFields);
|
3277
3899
|
},
|
3278
|
-
|
3279
|
-
createdAt: createAction.createdAt,
|
3280
|
-
createdBy: createAction.createdBy,
|
3281
|
-
createdAtLocation: createAction.createdAtLocation,
|
3282
|
-
createdByRole: createAction.createdByRole
|
3283
|
-
}
|
3900
|
+
(0, import_lodash2.pick)(createAction, metadataFields)
|
3284
3901
|
);
|
3285
3902
|
}
|
3286
3903
|
function getLegalStatuses(actions) {
|
3287
3904
|
return {
|
3288
|
-
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
3905
|
+
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
3289
3906
|
ActionType.DECLARE,
|
3290
3907
|
actions
|
3291
3908
|
),
|
3292
|
-
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
3909
|
+
[EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
|
3293
3910
|
ActionType.REGISTER,
|
3294
3911
|
actions
|
3295
3912
|
)
|
3296
3913
|
};
|
3297
3914
|
}
|
3298
3915
|
|
3299
|
-
// ../commons/src/events/state/
|
3300
|
-
function
|
3301
|
-
|
3302
|
-
(
|
3916
|
+
// ../commons/src/events/state/flags.ts
|
3917
|
+
function isCertificatePrinted(actions) {
|
3918
|
+
return actions.reduce((prev, { type }) => {
|
3919
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
3920
|
+
return true;
|
3921
|
+
}
|
3922
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
3923
|
+
return false;
|
3924
|
+
}
|
3925
|
+
return prev;
|
3926
|
+
}, false);
|
3927
|
+
}
|
3928
|
+
function isCorrectionRequested(actions) {
|
3929
|
+
return actions.reduce((prev, { type }) => {
|
3930
|
+
if (type === ActionType.REQUEST_CORRECTION) {
|
3931
|
+
return true;
|
3932
|
+
}
|
3933
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
3934
|
+
return false;
|
3935
|
+
}
|
3936
|
+
if (type === ActionType.REJECT_CORRECTION) {
|
3937
|
+
return false;
|
3938
|
+
}
|
3939
|
+
return prev;
|
3940
|
+
}, false);
|
3941
|
+
}
|
3942
|
+
function isDeclarationIncomplete(actions) {
|
3943
|
+
return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
|
3944
|
+
}
|
3945
|
+
function isRejected(actions) {
|
3946
|
+
return getStatusFromActions(actions) === EventStatus.enum.REJECTED;
|
3947
|
+
}
|
3948
|
+
function getFlagsFromActions(actions) {
|
3949
|
+
const sortedActions = actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
3950
|
+
const actionStatus = sortedActions.reduce(
|
3951
|
+
(actionStatuses, { type, status }) => ({
|
3952
|
+
...actionStatuses,
|
3953
|
+
[type]: status
|
3954
|
+
}),
|
3955
|
+
{}
|
3303
3956
|
);
|
3304
|
-
|
3305
|
-
|
3957
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
3958
|
+
const flag = joinValues([type, status], ":").toLowerCase();
|
3959
|
+
return flag;
|
3960
|
+
});
|
3961
|
+
if (isCertificatePrinted(sortedActions)) {
|
3962
|
+
flags.push(InherentFlags.PRINTED);
|
3963
|
+
}
|
3964
|
+
if (isCorrectionRequested(sortedActions)) {
|
3965
|
+
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
3306
3966
|
}
|
3307
|
-
|
3967
|
+
if (isDeclarationIncomplete(sortedActions)) {
|
3968
|
+
flags.push(InherentFlags.INCOMPLETE);
|
3969
|
+
}
|
3970
|
+
if (isRejected(sortedActions)) {
|
3971
|
+
flags.push(InherentFlags.REJECTED);
|
3972
|
+
}
|
3973
|
+
return flags;
|
3974
|
+
}
|
3975
|
+
|
3976
|
+
// ../commons/src/events/state/index.ts
|
3977
|
+
function getStatusFromActions(actions) {
|
3978
|
+
return actions.filter(({ status }) => status === ActionStatus.Accepted).reduce((status, action) => {
|
3308
3979
|
switch (action.type) {
|
3309
3980
|
case ActionType.CREATE:
|
3310
|
-
return EventStatus.CREATED;
|
3981
|
+
return EventStatus.enum.CREATED;
|
3311
3982
|
case ActionType.DECLARE:
|
3312
|
-
return EventStatus.DECLARED;
|
3983
|
+
return EventStatus.enum.DECLARED;
|
3313
3984
|
case ActionType.VALIDATE:
|
3314
|
-
return EventStatus.VALIDATED;
|
3985
|
+
return EventStatus.enum.VALIDATED;
|
3315
3986
|
case ActionType.REGISTER:
|
3316
|
-
return EventStatus.REGISTERED;
|
3987
|
+
return EventStatus.enum.REGISTERED;
|
3317
3988
|
case ActionType.REJECT:
|
3318
|
-
return EventStatus.REJECTED;
|
3989
|
+
return EventStatus.enum.REJECTED;
|
3319
3990
|
case ActionType.ARCHIVE:
|
3320
|
-
return EventStatus.ARCHIVED;
|
3991
|
+
return EventStatus.enum.ARCHIVED;
|
3321
3992
|
case ActionType.NOTIFY:
|
3322
|
-
return EventStatus.NOTIFIED;
|
3993
|
+
return EventStatus.enum.NOTIFIED;
|
3323
3994
|
case ActionType.PRINT_CERTIFICATE:
|
3324
|
-
return EventStatus.CERTIFIED;
|
3995
|
+
return EventStatus.enum.CERTIFIED;
|
3325
3996
|
case ActionType.ASSIGN:
|
3326
3997
|
case ActionType.UNASSIGN:
|
3327
3998
|
case ActionType.REQUEST_CORRECTION:
|
@@ -3332,39 +4003,7 @@ function getStatusFromActions(actions) {
|
|
3332
4003
|
default:
|
3333
4004
|
return status;
|
3334
4005
|
}
|
3335
|
-
}, EventStatus.CREATED);
|
3336
|
-
}
|
3337
|
-
function getFlagsFromActions(actions) {
|
3338
|
-
const sortedactions = actions.sort(
|
3339
|
-
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
3340
|
-
);
|
3341
|
-
const actionStatus = sortedactions.reduce(
|
3342
|
-
(actionStatuses, { type, status }) => ({
|
3343
|
-
...actionStatuses,
|
3344
|
-
[type]: status
|
3345
|
-
}),
|
3346
|
-
{}
|
3347
|
-
);
|
3348
|
-
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
3349
|
-
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
3350
|
-
return flag;
|
3351
|
-
});
|
3352
|
-
const isCertificatePrinted = sortedactions.reduce(
|
3353
|
-
(prev, { type }) => {
|
3354
|
-
if (type === ActionType.PRINT_CERTIFICATE) {
|
3355
|
-
return true;
|
3356
|
-
}
|
3357
|
-
if (type === ActionType.APPROVE_CORRECTION) {
|
3358
|
-
return false;
|
3359
|
-
}
|
3360
|
-
return prev;
|
3361
|
-
},
|
3362
|
-
false
|
3363
|
-
);
|
3364
|
-
if (isCertificatePrinted) {
|
3365
|
-
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
3366
|
-
}
|
3367
|
-
return flags;
|
4006
|
+
}, EventStatus.enum.CREATED);
|
3368
4007
|
}
|
3369
4008
|
function getAssignedUserFromActions(actions) {
|
3370
4009
|
return actions.reduce((user2, action) => {
|
@@ -3424,7 +4063,7 @@ function deepDropNulls(obj) {
|
|
3424
4063
|
return obj;
|
3425
4064
|
}
|
3426
4065
|
function isUndeclaredDraft(status) {
|
3427
|
-
return status === EventStatus.CREATED;
|
4066
|
+
return status === EventStatus.enum.CREATED;
|
3428
4067
|
}
|
3429
4068
|
function getAcceptedActions(event2) {
|
3430
4069
|
return event2.actions.filter(
|
@@ -3439,10 +4078,11 @@ function getCurrentEventState(event2, config) {
|
|
3439
4078
|
if (!creationAction) {
|
3440
4079
|
throw new Error(`Event ${event2.id} has no creation action`);
|
3441
4080
|
}
|
3442
|
-
const acceptedActions = getAcceptedActions(event2)
|
3443
|
-
|
3444
|
-
event2.actions
|
4081
|
+
const acceptedActions = getAcceptedActions(event2).sort(
|
4082
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
3445
4083
|
);
|
4084
|
+
const requestActionMetadata = getActionUpdateMetadata(event2.actions);
|
4085
|
+
const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
|
3446
4086
|
const declaration = aggregateActionDeclarations(acceptedActions);
|
3447
4087
|
let dateOfEvent;
|
3448
4088
|
if (config.dateOfEvent) {
|
@@ -3462,16 +4102,17 @@ function getCurrentEventState(event2, config) {
|
|
3462
4102
|
legalStatuses: getLegalStatuses(event2.actions),
|
3463
4103
|
createdAt: creationAction.createdAt,
|
3464
4104
|
createdBy: creationAction.createdBy,
|
4105
|
+
createdByUserType: creationAction.createdByUserType,
|
3465
4106
|
createdAtLocation: creationAction.createdAtLocation,
|
3466
4107
|
createdBySignature: creationAction.createdBySignature,
|
3467
|
-
updatedAt:
|
4108
|
+
updatedAt: acceptedActionMetadata.createdAt,
|
3468
4109
|
assignedTo: getAssignedUserFromActions(acceptedActions),
|
3469
4110
|
assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
|
3470
|
-
updatedBy:
|
3471
|
-
updatedAtLocation:
|
4111
|
+
updatedBy: requestActionMetadata.createdBy,
|
4112
|
+
updatedAtLocation: requestActionMetadata.createdAtLocation,
|
3472
4113
|
declaration,
|
3473
4114
|
trackingId: event2.trackingId,
|
3474
|
-
updatedByUserRole:
|
4115
|
+
updatedByUserRole: requestActionMetadata.createdByRole,
|
3475
4116
|
dateOfEvent,
|
3476
4117
|
flags: getFlagsFromActions(event2.actions)
|
3477
4118
|
});
|
@@ -3554,23 +4195,23 @@ function generateTransactionId() {
|
|
3554
4195
|
}
|
3555
4196
|
|
3556
4197
|
// ../commons/src/events/User.ts
|
3557
|
-
var
|
3558
|
-
var User =
|
3559
|
-
id:
|
3560
|
-
name:
|
3561
|
-
|
3562
|
-
use:
|
3563
|
-
given:
|
3564
|
-
family:
|
4198
|
+
var import_zod32 = require("zod");
|
4199
|
+
var User = import_zod32.z.object({
|
4200
|
+
id: import_zod32.z.string(),
|
4201
|
+
name: import_zod32.z.array(
|
4202
|
+
import_zod32.z.object({
|
4203
|
+
use: import_zod32.z.string(),
|
4204
|
+
given: import_zod32.z.array(import_zod32.z.string()),
|
4205
|
+
family: import_zod32.z.string()
|
3565
4206
|
})
|
3566
4207
|
),
|
3567
|
-
role:
|
3568
|
-
signatureFilename:
|
4208
|
+
role: import_zod32.z.string(),
|
4209
|
+
signatureFilename: import_zod32.z.string().optional()
|
3569
4210
|
});
|
3570
4211
|
|
3571
4212
|
// ../commons/src/events/test.utils.ts
|
3572
|
-
var
|
3573
|
-
var
|
4213
|
+
var import_lodash3 = require("lodash");
|
4214
|
+
var import_date_fns3 = require("date-fns");
|
3574
4215
|
|
3575
4216
|
// ../commons/src/field-config/field-configuration.ts
|
3576
4217
|
function createFieldConfig(fieldId, options) {
|
@@ -4250,7 +4891,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
|
|
4250
4891
|
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
4251
4892
|
title: {
|
4252
4893
|
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
4253
|
-
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
4894
|
+
defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration for {applicant.name.firstname}} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
|
4254
4895
|
description: "Title of the review page"
|
4255
4896
|
},
|
4256
4897
|
fields: [
|
@@ -4295,27 +4936,17 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4295
4936
|
},
|
4296
4937
|
fields: [
|
4297
4938
|
{
|
4298
|
-
id: "applicant.
|
4299
|
-
type: FieldType.
|
4939
|
+
id: "applicant.name",
|
4940
|
+
type: FieldType.NAME,
|
4300
4941
|
required: true,
|
4942
|
+
hideLabel: true,
|
4301
4943
|
conditionals: [],
|
4302
4944
|
label: {
|
4303
|
-
defaultMessage: "Applicant's
|
4945
|
+
defaultMessage: "Applicant's name",
|
4304
4946
|
description: "This is the label for the field",
|
4305
4947
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
|
4306
4948
|
}
|
4307
4949
|
},
|
4308
|
-
{
|
4309
|
-
id: "applicant.surname",
|
4310
|
-
type: FieldType.TEXT,
|
4311
|
-
required: true,
|
4312
|
-
conditionals: [],
|
4313
|
-
label: {
|
4314
|
-
defaultMessage: "Applicant's surname",
|
4315
|
-
description: "This is the label for the field",
|
4316
|
-
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.surname.label"
|
4317
|
-
}
|
4318
|
-
},
|
4319
4950
|
{
|
4320
4951
|
id: "applicant.email",
|
4321
4952
|
type: "EMAIL",
|
@@ -4399,6 +5030,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4399
5030
|
id: "applicant.address",
|
4400
5031
|
type: "ADDRESS",
|
4401
5032
|
required: true,
|
5033
|
+
secured: true,
|
4402
5034
|
conditionals: [],
|
4403
5035
|
label: {
|
4404
5036
|
defaultMessage: "Applicant's address",
|
@@ -4449,8 +5081,9 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4449
5081
|
}
|
4450
5082
|
},
|
4451
5083
|
{
|
4452
|
-
id: "recommender.
|
4453
|
-
type: FieldType.
|
5084
|
+
id: "recommender.name",
|
5085
|
+
type: FieldType.NAME,
|
5086
|
+
hideLabel: true,
|
4454
5087
|
required: true,
|
4455
5088
|
conditionals: [
|
4456
5089
|
{
|
@@ -4459,27 +5092,11 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
4459
5092
|
}
|
4460
5093
|
],
|
4461
5094
|
label: {
|
4462
|
-
defaultMessage: "Recommender's
|
5095
|
+
defaultMessage: "Recommender's name",
|
4463
5096
|
description: "This is the label for the field",
|
4464
5097
|
id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label"
|
4465
5098
|
}
|
4466
5099
|
},
|
4467
|
-
{
|
4468
|
-
id: "recommender.surname",
|
4469
|
-
type: FieldType.TEXT,
|
4470
|
-
required: true,
|
4471
|
-
conditionals: [
|
4472
|
-
{
|
4473
|
-
type: ConditionalType.SHOW,
|
4474
|
-
conditional: field("recommender.none").isFalsy()
|
4475
|
-
}
|
4476
|
-
],
|
4477
|
-
label: {
|
4478
|
-
defaultMessage: "Recommender's surname",
|
4479
|
-
description: "This is the label for the field",
|
4480
|
-
id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label"
|
4481
|
-
}
|
4482
|
-
},
|
4483
5100
|
{
|
4484
5101
|
id: "recommender.id",
|
4485
5102
|
type: FieldType.TEXT,
|
@@ -4510,7 +5127,7 @@ var statusOptions = [
|
|
4510
5127
|
}
|
4511
5128
|
},
|
4512
5129
|
{
|
4513
|
-
value: EventStatus.CREATED,
|
5130
|
+
value: EventStatus.enum.CREATED,
|
4514
5131
|
label: {
|
4515
5132
|
defaultMessage: "Draft",
|
4516
5133
|
description: "Option for form field: status of record",
|
@@ -4518,7 +5135,7 @@ var statusOptions = [
|
|
4518
5135
|
}
|
4519
5136
|
},
|
4520
5137
|
{
|
4521
|
-
value: EventStatus.NOTIFIED,
|
5138
|
+
value: EventStatus.enum.NOTIFIED,
|
4522
5139
|
label: {
|
4523
5140
|
defaultMessage: "Notified",
|
4524
5141
|
description: "Option for form field: status of record",
|
@@ -4526,7 +5143,7 @@ var statusOptions = [
|
|
4526
5143
|
}
|
4527
5144
|
},
|
4528
5145
|
{
|
4529
|
-
value: EventStatus.DECLARED,
|
5146
|
+
value: EventStatus.enum.DECLARED,
|
4530
5147
|
label: {
|
4531
5148
|
defaultMessage: "Declared",
|
4532
5149
|
description: "Option for form field: status of record",
|
@@ -4534,7 +5151,7 @@ var statusOptions = [
|
|
4534
5151
|
}
|
4535
5152
|
},
|
4536
5153
|
{
|
4537
|
-
value: EventStatus.VALIDATED,
|
5154
|
+
value: EventStatus.enum.VALIDATED,
|
4538
5155
|
label: {
|
4539
5156
|
defaultMessage: "Validated",
|
4540
5157
|
description: "Option for form field: status of record",
|
@@ -4542,7 +5159,7 @@ var statusOptions = [
|
|
4542
5159
|
}
|
4543
5160
|
},
|
4544
5161
|
{
|
4545
|
-
value: EventStatus.REGISTERED,
|
5162
|
+
value: EventStatus.enum.REGISTERED,
|
4546
5163
|
label: {
|
4547
5164
|
defaultMessage: "Registered",
|
4548
5165
|
description: "Option for form field: status of record",
|
@@ -4550,7 +5167,7 @@ var statusOptions = [
|
|
4550
5167
|
}
|
4551
5168
|
},
|
4552
5169
|
{
|
4553
|
-
value: EventStatus.CERTIFIED,
|
5170
|
+
value: EventStatus.enum.CERTIFIED,
|
4554
5171
|
label: {
|
4555
5172
|
defaultMessage: "Certified",
|
4556
5173
|
description: "Option for form field: status of record",
|
@@ -4558,7 +5175,7 @@ var statusOptions = [
|
|
4558
5175
|
}
|
4559
5176
|
},
|
4560
5177
|
{
|
4561
|
-
value: EventStatus.REJECTED,
|
5178
|
+
value: EventStatus.enum.REJECTED,
|
4562
5179
|
label: {
|
4563
5180
|
defaultMessage: "Rejected",
|
4564
5181
|
description: "Option for form field: status of record",
|
@@ -4566,7 +5183,7 @@ var statusOptions = [
|
|
4566
5183
|
}
|
4567
5184
|
},
|
4568
5185
|
{
|
4569
|
-
value: EventStatus.ARCHIVED,
|
5186
|
+
value: EventStatus.enum.ARCHIVED,
|
4570
5187
|
label: {
|
4571
5188
|
defaultMessage: "Archived",
|
4572
5189
|
description: "Option for form field: status of record",
|
@@ -4630,38 +5247,25 @@ var tennisClubMembershipEvent = defineConfig({
|
|
4630
5247
|
id: "v2.event.tennis-club-membership.label"
|
4631
5248
|
},
|
4632
5249
|
title: {
|
4633
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
5250
|
+
defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
|
4634
5251
|
description: "This is the title of the summary",
|
4635
5252
|
id: "v2.event.tennis-club-membership.title"
|
4636
5253
|
},
|
4637
5254
|
summary: {
|
4638
5255
|
fields: [
|
4639
5256
|
{
|
4640
|
-
|
5257
|
+
fieldId: "applicant.name",
|
4641
5258
|
label: {
|
4642
|
-
defaultMessage: "Applicant's
|
5259
|
+
defaultMessage: "Applicant's name",
|
4643
5260
|
description: "This is the label for the field",
|
4644
5261
|
id: "event.tennis-club-membership.summary.field.firstname.label"
|
4645
5262
|
},
|
4646
|
-
value: {
|
4647
|
-
defaultMessage: "{applicant.firstname}",
|
4648
|
-
description: "This is the value to show in the summary",
|
4649
|
-
id: "event.tennis-club-membership.summary.field.firstname"
|
4650
|
-
},
|
4651
5263
|
emptyValueMessage: {
|
4652
5264
|
defaultMessage: "First name is not provided",
|
4653
5265
|
description: "This is the message to show when the field is empty",
|
4654
5266
|
id: "event.tennis-club-membership.summary.field.firstname.empty"
|
4655
5267
|
}
|
4656
5268
|
},
|
4657
|
-
{
|
4658
|
-
fieldId: "applicant.surname",
|
4659
|
-
label: {
|
4660
|
-
defaultMessage: "Applicant's last name",
|
4661
|
-
description: "Label for surname",
|
4662
|
-
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
4663
|
-
}
|
4664
|
-
},
|
4665
5269
|
{
|
4666
5270
|
fieldId: "applicant.email"
|
4667
5271
|
}
|
@@ -4997,8 +5601,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
4997
5601
|
id: "v2.event.tennis-club-membership.search.applicants"
|
4998
5602
|
},
|
4999
5603
|
fields: [
|
5000
|
-
field("applicant.
|
5001
|
-
field("applicant.surname").fuzzy(),
|
5604
|
+
field("applicant.name").fuzzy(),
|
5002
5605
|
field("applicant.dob").range(),
|
5003
5606
|
field("applicant.email").exact()
|
5004
5607
|
]
|
@@ -5009,10 +5612,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
5009
5612
|
description: "Recommender details search field section title",
|
5010
5613
|
id: "v2.event.tennis-club-membership.search.recommender"
|
5011
5614
|
},
|
5012
|
-
fields: [
|
5013
|
-
field("recommender.firstname").fuzzy(),
|
5014
|
-
field("recommender.surname").fuzzy()
|
5015
|
-
]
|
5615
|
+
fields: [field("recommender.name").fuzzy()]
|
5016
5616
|
}
|
5017
5617
|
],
|
5018
5618
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
@@ -5027,21 +5627,21 @@ var footballClubMembershipEvent = defineConfig({
|
|
5027
5627
|
id: "event.football-club-membership.label"
|
5028
5628
|
},
|
5029
5629
|
title: {
|
5030
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
5630
|
+
defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
|
5031
5631
|
description: "This is the title of the summary",
|
5032
5632
|
id: "v2.event.football-club-membership.title"
|
5033
5633
|
},
|
5034
5634
|
summary: {
|
5035
5635
|
fields: [
|
5036
5636
|
{
|
5037
|
-
id: "applicant.firstname",
|
5637
|
+
id: "applicant.name.firstname",
|
5038
5638
|
label: {
|
5039
5639
|
defaultMessage: "Applicant's first name",
|
5040
5640
|
description: "This is the label for the field",
|
5041
5641
|
id: "event.football-club-membership.summary.field.firstname.label"
|
5042
5642
|
},
|
5043
5643
|
value: {
|
5044
|
-
defaultMessage: "{applicant.firstname}",
|
5644
|
+
defaultMessage: "{applicant.name.firstname}",
|
5045
5645
|
description: "This is the value to show in the summary",
|
5046
5646
|
id: "event.football-club-membership.summary.field.firstname"
|
5047
5647
|
},
|
@@ -5052,7 +5652,7 @@ var footballClubMembershipEvent = defineConfig({
|
|
5052
5652
|
}
|
5053
5653
|
},
|
5054
5654
|
{
|
5055
|
-
fieldId: "applicant.surname",
|
5655
|
+
fieldId: "applicant.name.surname",
|
5056
5656
|
label: {
|
5057
5657
|
defaultMessage: "Applicant's last name",
|
5058
5658
|
description: "Label for surname",
|
@@ -5394,8 +5994,7 @@ var footballClubMembershipEvent = defineConfig({
|
|
5394
5994
|
id: "v2.event.football-club-membership.search.applicants"
|
5395
5995
|
},
|
5396
5996
|
fields: [
|
5397
|
-
field("applicant.
|
5398
|
-
field("applicant.surname").fuzzy(),
|
5997
|
+
field("applicant.name").fuzzy(),
|
5399
5998
|
field("applicant.dob").range(),
|
5400
5999
|
field("applicant.email").exact()
|
5401
6000
|
]
|
@@ -5406,10 +6005,7 @@ var footballClubMembershipEvent = defineConfig({
|
|
5406
6005
|
description: "Recommender details search field section title",
|
5407
6006
|
id: "v2.event.football-club-membership.search.recommender"
|
5408
6007
|
},
|
5409
|
-
fields: [
|
5410
|
-
field("recommender.firstname").fuzzy(),
|
5411
|
-
field("recommender.surname").fuzzy()
|
5412
|
-
]
|
6008
|
+
fields: [field("recommender.name").fuzzy()]
|
5413
6009
|
}
|
5414
6010
|
],
|
5415
6011
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
@@ -5474,33 +6070,261 @@ var libraryMembershipEvent = defineConfig({
|
|
5474
6070
|
declaration: libraryMembershipForm
|
5475
6071
|
});
|
5476
6072
|
|
5477
|
-
// ../commons/src/
|
5478
|
-
|
5479
|
-
|
5480
|
-
|
5481
|
-
|
5482
|
-
|
6073
|
+
// ../commons/src/fixtures/v2-birth-event.ts
|
6074
|
+
var child = defineFormPage({
|
6075
|
+
id: "child",
|
6076
|
+
type: PageTypes.enum.FORM,
|
6077
|
+
title: {
|
6078
|
+
defaultMessage: "Child's details",
|
6079
|
+
description: "Form section title for Child",
|
6080
|
+
id: "v2.form.birth.child.title"
|
6081
|
+
},
|
6082
|
+
fields: [
|
6083
|
+
{
|
6084
|
+
id: "child.firstNames",
|
6085
|
+
type: FieldType.TEXT,
|
6086
|
+
required: true,
|
6087
|
+
configuration: { maxLength: 32 },
|
6088
|
+
hideLabel: true,
|
6089
|
+
label: {
|
6090
|
+
defaultMessage: "Child's first name",
|
6091
|
+
description: "This is the label for the field",
|
6092
|
+
id: "v2.event.birth.action.declare.form.section.child.field.name.label"
|
6093
|
+
}
|
6094
|
+
},
|
6095
|
+
{
|
6096
|
+
id: "child.familyName",
|
6097
|
+
type: FieldType.TEXT,
|
6098
|
+
required: true,
|
6099
|
+
configuration: { maxLength: 32 },
|
6100
|
+
hideLabel: true,
|
6101
|
+
label: {
|
6102
|
+
defaultMessage: "Child's last name",
|
6103
|
+
description: "This is the label for the field",
|
6104
|
+
id: "v2.event.birth.action.declare.form.section.child.field.name.label"
|
6105
|
+
}
|
6106
|
+
},
|
6107
|
+
{
|
6108
|
+
id: "child.DoB",
|
6109
|
+
type: "DATE",
|
6110
|
+
required: true,
|
6111
|
+
label: {
|
6112
|
+
defaultMessage: "Date of birth",
|
6113
|
+
description: "This is the label for the field",
|
6114
|
+
id: "v2.event.birth.action.declare.form.section.child.field.dob.label"
|
6115
|
+
}
|
6116
|
+
}
|
6117
|
+
]
|
6118
|
+
});
|
6119
|
+
var mother = defineFormPage({
|
6120
|
+
id: "mother",
|
6121
|
+
type: PageTypes.enum.FORM,
|
6122
|
+
title: {
|
6123
|
+
defaultMessage: "Mother's details",
|
6124
|
+
description: "Form section title for mothers details",
|
6125
|
+
id: "v2.form.section.mother.title"
|
6126
|
+
},
|
6127
|
+
fields: [
|
6128
|
+
{
|
6129
|
+
id: "mother.firstNames",
|
6130
|
+
configuration: { maxLength: 32 },
|
6131
|
+
type: FieldType.TEXT,
|
6132
|
+
required: true,
|
6133
|
+
label: {
|
6134
|
+
defaultMessage: "First name(s)",
|
6135
|
+
description: "This is the label for the field",
|
6136
|
+
id: `v2.event.birth.action.declare.form.section.person.field.firstname.label`
|
6137
|
+
}
|
6138
|
+
},
|
6139
|
+
{
|
6140
|
+
id: `mother.familyName`,
|
6141
|
+
configuration: { maxLength: 32 },
|
6142
|
+
type: FieldType.TEXT,
|
6143
|
+
required: true,
|
6144
|
+
label: {
|
6145
|
+
defaultMessage: "Last name",
|
6146
|
+
description: "This is the label for the field",
|
6147
|
+
id: `v2.event.birth.action.declare.form.section.person.field.surname.label`
|
6148
|
+
}
|
6149
|
+
},
|
6150
|
+
{
|
6151
|
+
id: `mother.DoB`,
|
6152
|
+
type: "DATE",
|
6153
|
+
required: true,
|
6154
|
+
label: {
|
6155
|
+
defaultMessage: "Date of birth",
|
6156
|
+
description: "This is the label for the field",
|
6157
|
+
id: `v2.event.birth.action.declare.form.section.person.field.dob.label`
|
6158
|
+
}
|
6159
|
+
},
|
6160
|
+
{
|
6161
|
+
id: "mother.identifier",
|
6162
|
+
type: FieldType.ID,
|
6163
|
+
required: true,
|
6164
|
+
label: {
|
6165
|
+
defaultMessage: "ID Number",
|
6166
|
+
description: "This is the label for the field",
|
6167
|
+
id: `v2.event.birth.action.declare.form.section.person.field.nid.label`
|
6168
|
+
}
|
6169
|
+
}
|
6170
|
+
]
|
6171
|
+
});
|
6172
|
+
var BIRTH_DECLARATION_FORM = defineDeclarationForm({
|
6173
|
+
label: {
|
6174
|
+
defaultMessage: "Birth decalration form",
|
6175
|
+
id: "v2.event.birth.action.declare.form.label",
|
6176
|
+
description: "This is what this form is referred as in the system"
|
6177
|
+
},
|
6178
|
+
pages: [child, mother]
|
6179
|
+
});
|
6180
|
+
var v2BirthEvent = defineConfig({
|
6181
|
+
id: BIRTH_EVENT,
|
6182
|
+
title: {
|
6183
|
+
defaultMessage: "{child.name.firstname} {child.name.surname}",
|
6184
|
+
description: "This is the title of the summary",
|
6185
|
+
id: "v2.event.birth.title"
|
6186
|
+
},
|
6187
|
+
label: {
|
6188
|
+
defaultMessage: "Birth",
|
6189
|
+
description: "This is what this event is referred as in the system",
|
6190
|
+
id: "v2.event.birth.label"
|
6191
|
+
},
|
6192
|
+
summary: {
|
6193
|
+
fields: []
|
6194
|
+
},
|
6195
|
+
actions: [],
|
6196
|
+
declaration: BIRTH_DECLARATION_FORM
|
6197
|
+
});
|
6198
|
+
|
6199
|
+
// ../commons/src/events/test.utils.ts
|
6200
|
+
var import_zod33 = require("zod");
|
6201
|
+
var TestUserRole = import_zod33.z.enum([
|
6202
|
+
"FIELD_AGENT",
|
6203
|
+
"LOCAL_REGISTRAR",
|
6204
|
+
"LOCAL_SYSTEM_ADMIN",
|
6205
|
+
"NATIONAL_REGISTRAR",
|
6206
|
+
"REGISTRATION_AGENT"
|
6207
|
+
]);
|
6208
|
+
function pickRandom(rng, items) {
|
6209
|
+
return items[Math.floor(rng() * items.length)];
|
6210
|
+
}
|
6211
|
+
function generateRandomName(rng) {
|
6212
|
+
const firstnames = [
|
6213
|
+
"Danny",
|
6214
|
+
"John",
|
6215
|
+
"Jane",
|
6216
|
+
"Emily",
|
6217
|
+
"Michael",
|
6218
|
+
"Sarah",
|
6219
|
+
"Chris",
|
6220
|
+
"Jessica",
|
6221
|
+
"Sara",
|
6222
|
+
"Sarachella",
|
6223
|
+
"Sarandera",
|
6224
|
+
"Zara"
|
6225
|
+
];
|
6226
|
+
const surnames = [
|
6227
|
+
"Doe",
|
6228
|
+
"Smith",
|
6229
|
+
"Johnson",
|
6230
|
+
"Brown",
|
6231
|
+
"Williams",
|
6232
|
+
"Jones",
|
6233
|
+
"Garcia",
|
6234
|
+
"Miller",
|
6235
|
+
"Saranen",
|
6236
|
+
"Sarajanen",
|
6237
|
+
"Sarthua",
|
6238
|
+
"Tsarakovski",
|
6239
|
+
"Salamander",
|
6240
|
+
"Zarathustra"
|
6241
|
+
];
|
6242
|
+
return {
|
6243
|
+
firstname: pickRandom(rng, firstnames),
|
6244
|
+
surname: pickRandom(rng, surnames)
|
6245
|
+
};
|
6246
|
+
}
|
6247
|
+
function mapFieldTypeToMockValue(field2, i, rng) {
|
6248
|
+
switch (field2.type) {
|
6249
|
+
case FieldType.DIVIDER:
|
6250
|
+
case FieldType.TEXT:
|
6251
|
+
case FieldType.TEXTAREA:
|
6252
|
+
case FieldType.BULLET_LIST:
|
6253
|
+
case FieldType.PAGE_HEADER:
|
6254
|
+
case FieldType.LOCATION:
|
6255
|
+
case FieldType.SELECT:
|
6256
|
+
case FieldType.COUNTRY:
|
6257
|
+
case FieldType.RADIO_GROUP:
|
6258
|
+
case FieldType.PARAGRAPH:
|
6259
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
6260
|
+
case FieldType.FACILITY:
|
6261
|
+
case FieldType.PHONE:
|
6262
|
+
case FieldType.ID:
|
6263
|
+
case FieldType.OFFICE:
|
6264
|
+
return `${field2.id}-${field2.type}-${i}`;
|
6265
|
+
case FieldType.NAME:
|
6266
|
+
return generateRandomName(rng);
|
6267
|
+
case FieldType.NUMBER:
|
6268
|
+
return 19;
|
6269
|
+
case FieldType.EMAIL:
|
6270
|
+
return "test@opencrvs.org";
|
6271
|
+
case FieldType.ADDRESS:
|
6272
|
+
return {
|
6273
|
+
country: "FAR",
|
6274
|
+
addressType: AddressType.DOMESTIC,
|
6275
|
+
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
6276
|
+
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
6277
|
+
urbanOrRural: "URBAN",
|
6278
|
+
town: "Example Town",
|
6279
|
+
residentialArea: "Example Residential Area",
|
6280
|
+
street: "Example Street",
|
6281
|
+
number: "55",
|
6282
|
+
zipCode: "123456"
|
6283
|
+
};
|
6284
|
+
case FieldType.DATE:
|
6285
|
+
return "2021-01-01";
|
6286
|
+
case FieldType.DATE_RANGE:
|
6287
|
+
return ["2021-01-01", "2021-01-02"];
|
6288
|
+
case FieldType.CHECKBOX:
|
6289
|
+
return true;
|
6290
|
+
case FieldType.SIGNATURE:
|
6291
|
+
case FieldType.FILE:
|
6292
|
+
return {
|
6293
|
+
filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
|
6294
|
+
originalFilename: "abcd.png",
|
6295
|
+
type: "image/png"
|
6296
|
+
};
|
6297
|
+
case FieldType.FILE_WITH_OPTIONS:
|
6298
|
+
case FieldType.DATA:
|
6299
|
+
return void 0;
|
6300
|
+
}
|
6301
|
+
}
|
6302
|
+
function fieldConfigsToActionPayload(fields, rng) {
|
6303
|
+
return fields.reduce(
|
6304
|
+
(acc, field2, i) => ({
|
6305
|
+
...acc,
|
6306
|
+
[field2.id]: mapFieldTypeToMockValue(field2, i, rng)
|
5483
6307
|
}),
|
5484
6308
|
{}
|
5485
6309
|
);
|
5486
6310
|
}
|
5487
|
-
function generateActionDeclarationInput(configuration, action) {
|
6311
|
+
function generateActionDeclarationInput(configuration, action, rng) {
|
5488
6312
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
5489
6313
|
if (parsed.success) {
|
5490
6314
|
const fields = getDeclarationFields(configuration);
|
5491
6315
|
const declarationConfig = getDeclaration(configuration);
|
5492
|
-
const declaration = fieldConfigsToActionPayload(fields);
|
6316
|
+
const declaration = fieldConfigsToActionPayload(fields, rng);
|
5493
6317
|
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
5494
6318
|
}
|
5495
6319
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
5496
6320
|
return {};
|
5497
6321
|
}
|
5498
|
-
function generateActionAnnotationInput(configuration, action) {
|
6322
|
+
function generateActionAnnotationInput(configuration, action, rng) {
|
5499
6323
|
const actionConfig = configuration.actions.find(
|
5500
6324
|
(ac) => ac.type === action
|
5501
6325
|
);
|
5502
6326
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
5503
|
-
const annotation = fieldConfigsToActionPayload(annotationFields);
|
6327
|
+
const annotation = fieldConfigsToActionPayload(annotationFields, rng);
|
5504
6328
|
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
5505
6329
|
findRecordActionPages(configuration, action),
|
5506
6330
|
annotation
|
@@ -5518,209 +6342,240 @@ function generateActionAnnotationInput(configuration, action) {
|
|
5518
6342
|
...visiblePageVerificationMap
|
5519
6343
|
};
|
5520
6344
|
}
|
5521
|
-
|
5522
|
-
|
5523
|
-
|
5524
|
-
type: input.type ?? TENNIS_CLUB_MEMBERSHIP
|
5525
|
-
}),
|
5526
|
-
patch: (id, input = {}) => ({
|
5527
|
-
transactionId: input.transactionId ?? getUUID(),
|
5528
|
-
type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
|
5529
|
-
id
|
5530
|
-
}),
|
5531
|
-
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
5532
|
-
{
|
5533
|
-
id: getUUID(),
|
5534
|
-
eventId,
|
5535
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
5536
|
-
transactionId: getUUID(),
|
5537
|
-
action: {
|
5538
|
-
transactionId: getUUID(),
|
5539
|
-
type: actionType,
|
5540
|
-
status: ActionStatus.Accepted,
|
5541
|
-
declaration: {
|
5542
|
-
"applicant.firstname": "Max",
|
5543
|
-
"applicant.surname": "McLaren",
|
5544
|
-
"applicant.dob": "2020-01-02",
|
5545
|
-
"recommender.none": true
|
5546
|
-
},
|
5547
|
-
annotation: {
|
5548
|
-
"correction.requester.relationship": "ANOTHER_AGENT",
|
5549
|
-
"correction.request.reason": "Child's name was incorrect"
|
5550
|
-
},
|
5551
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
5552
|
-
createdBy: "@todo",
|
5553
|
-
createdByRole: "@todo",
|
5554
|
-
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
|
5555
|
-
}
|
5556
|
-
},
|
5557
|
-
input
|
5558
|
-
),
|
5559
|
-
actions: {
|
5560
|
-
declare: (eventId, input = {}) => ({
|
5561
|
-
type: ActionType.DECLARE,
|
5562
|
-
transactionId: input.transactionId ?? getUUID(),
|
5563
|
-
declaration: input.declaration ?? generateActionDeclarationInput(
|
5564
|
-
tennisClubMembershipEvent,
|
5565
|
-
ActionType.DECLARE
|
5566
|
-
),
|
5567
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5568
|
-
tennisClubMembershipEvent,
|
5569
|
-
ActionType.DECLARE
|
5570
|
-
),
|
5571
|
-
eventId
|
5572
|
-
}),
|
5573
|
-
/**
|
5574
|
-
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
5575
|
-
*/
|
5576
|
-
notify: (eventId, input = {}) => {
|
5577
|
-
let declaration = input.declaration;
|
5578
|
-
if (!declaration) {
|
5579
|
-
const partialDeclaration = (0, import_lodash2.omitBy)(
|
5580
|
-
generateActionDeclarationInput(
|
5581
|
-
tennisClubMembershipEvent,
|
5582
|
-
ActionType.DECLARE
|
5583
|
-
),
|
5584
|
-
import_lodash2.isString
|
5585
|
-
);
|
5586
|
-
declaration = partialDeclaration;
|
5587
|
-
}
|
5588
|
-
return {
|
5589
|
-
type: ActionType.NOTIFY,
|
5590
|
-
transactionId: input.transactionId ?? getUUID(),
|
5591
|
-
declaration,
|
5592
|
-
eventId
|
5593
|
-
};
|
5594
|
-
},
|
5595
|
-
validate: (eventId, input = {}) => ({
|
5596
|
-
type: ActionType.VALIDATE,
|
5597
|
-
transactionId: input.transactionId ?? getUUID(),
|
5598
|
-
declaration: input.declaration ?? generateActionDeclarationInput(
|
5599
|
-
tennisClubMembershipEvent,
|
5600
|
-
ActionType.VALIDATE
|
5601
|
-
),
|
5602
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5603
|
-
tennisClubMembershipEvent,
|
5604
|
-
ActionType.VALIDATE
|
5605
|
-
),
|
5606
|
-
duplicates: [],
|
5607
|
-
eventId
|
5608
|
-
}),
|
5609
|
-
assign: (eventId, input = {}) => ({
|
5610
|
-
type: ActionType.ASSIGN,
|
5611
|
-
transactionId: input.transactionId ?? getUUID(),
|
5612
|
-
declaration: {},
|
5613
|
-
assignedTo: input.assignedTo ?? getUUID(),
|
5614
|
-
eventId
|
5615
|
-
}),
|
5616
|
-
unassign: (eventId, input = {}) => ({
|
5617
|
-
type: ActionType.UNASSIGN,
|
5618
|
-
transactionId: input.transactionId ?? getUUID(),
|
5619
|
-
declaration: {},
|
5620
|
-
assignedTo: null,
|
5621
|
-
eventId
|
5622
|
-
}),
|
5623
|
-
archive: (eventId, input = {}, isDuplicate) => ({
|
5624
|
-
type: ActionType.ARCHIVE,
|
5625
|
-
transactionId: input.transactionId ?? getUUID(),
|
5626
|
-
declaration: {},
|
5627
|
-
// @TODO: Check whether generator is needed?
|
5628
|
-
annotation: {},
|
5629
|
-
duplicates: [],
|
5630
|
-
eventId,
|
5631
|
-
reason: {
|
5632
|
-
message: `${ActionType.ARCHIVE}`,
|
5633
|
-
isDuplicate: isDuplicate ?? false
|
5634
|
-
}
|
5635
|
-
}),
|
5636
|
-
reject: (eventId, input = {}) => ({
|
5637
|
-
type: ActionType.REJECT,
|
6345
|
+
function eventPayloadGenerator(rng) {
|
6346
|
+
return {
|
6347
|
+
create: (input = {}) => ({
|
5638
6348
|
transactionId: input.transactionId ?? getUUID(),
|
5639
|
-
|
5640
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5641
|
-
tennisClubMembershipEvent,
|
5642
|
-
ActionType.REJECT
|
5643
|
-
),
|
5644
|
-
duplicates: [],
|
5645
|
-
eventId,
|
5646
|
-
reason: { message: `${ActionType.REJECT}` }
|
6349
|
+
type: input.type ?? TENNIS_CLUB_MEMBERSHIP
|
5647
6350
|
}),
|
5648
|
-
|
5649
|
-
type: ActionType.REGISTER,
|
6351
|
+
patch: (id, input = {}) => ({
|
5650
6352
|
transactionId: input.transactionId ?? getUUID(),
|
5651
|
-
|
5652
|
-
|
5653
|
-
ActionType.REGISTER
|
5654
|
-
),
|
5655
|
-
annotation: input.annotation ?? generateActionAnnotationInput(
|
5656
|
-
tennisClubMembershipEvent,
|
5657
|
-
ActionType.REGISTER
|
5658
|
-
),
|
5659
|
-
eventId
|
6353
|
+
type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
|
6354
|
+
id
|
5660
6355
|
}),
|
5661
|
-
|
5662
|
-
|
5663
|
-
|
5664
|
-
|
5665
|
-
|
5666
|
-
|
5667
|
-
|
5668
|
-
|
5669
|
-
|
5670
|
-
|
5671
|
-
|
5672
|
-
|
5673
|
-
|
6356
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash3.merge)(
|
6357
|
+
{
|
6358
|
+
id: getUUID(),
|
6359
|
+
eventId,
|
6360
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
6361
|
+
transactionId: getUUID(),
|
6362
|
+
action: {
|
6363
|
+
transactionId: getUUID(),
|
6364
|
+
type: actionType,
|
6365
|
+
status: ActionStatus.Accepted,
|
6366
|
+
declaration: {
|
6367
|
+
"applicant.name": {
|
6368
|
+
firstname: "Max",
|
6369
|
+
surname: "McLaren"
|
6370
|
+
},
|
6371
|
+
"applicant.dob": "2020-01-02",
|
6372
|
+
"recommender.none": true
|
6373
|
+
},
|
6374
|
+
annotation: {
|
6375
|
+
"correction.requester.relationship": "ANOTHER_AGENT",
|
6376
|
+
"correction.request.reason": "Child's name was incorrect"
|
6377
|
+
},
|
6378
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
6379
|
+
createdBy: "@todo",
|
6380
|
+
createdByUserType: TokenUserType.Enum.user,
|
6381
|
+
createdByRole: "@todo",
|
6382
|
+
createdAtLocation: "@todo"
|
6383
|
+
}
|
6384
|
+
},
|
6385
|
+
input
|
6386
|
+
),
|
6387
|
+
actions: {
|
6388
|
+
declare: (eventId, input = {}) => ({
|
6389
|
+
type: ActionType.DECLARE,
|
6390
|
+
transactionId: input.transactionId ?? getUUID(),
|
6391
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
6392
|
+
tennisClubMembershipEvent,
|
6393
|
+
ActionType.DECLARE,
|
6394
|
+
rng
|
6395
|
+
),
|
6396
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6397
|
+
tennisClubMembershipEvent,
|
6398
|
+
ActionType.DECLARE,
|
6399
|
+
rng
|
6400
|
+
),
|
6401
|
+
eventId,
|
6402
|
+
...input
|
6403
|
+
}),
|
6404
|
+
/**
|
6405
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
6406
|
+
*/
|
6407
|
+
notify: (eventId, input = {}) => {
|
6408
|
+
let declaration = input.declaration;
|
6409
|
+
if (!declaration) {
|
6410
|
+
const partialDeclaration = (0, import_lodash3.omitBy)(
|
6411
|
+
generateActionDeclarationInput(
|
6412
|
+
tennisClubMembershipEvent,
|
6413
|
+
ActionType.DECLARE,
|
6414
|
+
rng
|
6415
|
+
),
|
6416
|
+
import_lodash3.isString
|
6417
|
+
);
|
6418
|
+
declaration = partialDeclaration;
|
6419
|
+
}
|
6420
|
+
return {
|
6421
|
+
type: ActionType.NOTIFY,
|
6422
|
+
transactionId: input.transactionId ?? getUUID(),
|
6423
|
+
declaration,
|
6424
|
+
eventId,
|
6425
|
+
keepAssignment: input.keepAssignment
|
6426
|
+
};
|
6427
|
+
},
|
6428
|
+
validate: (eventId, input = {}) => ({
|
6429
|
+
type: ActionType.VALIDATE,
|
5674
6430
|
transactionId: input.transactionId ?? getUUID(),
|
5675
6431
|
declaration: input.declaration ?? generateActionDeclarationInput(
|
5676
6432
|
tennisClubMembershipEvent,
|
5677
|
-
ActionType.
|
6433
|
+
ActionType.VALIDATE,
|
6434
|
+
rng
|
5678
6435
|
),
|
5679
6436
|
annotation: input.annotation ?? generateActionAnnotationInput(
|
5680
6437
|
tennisClubMembershipEvent,
|
5681
|
-
ActionType.
|
6438
|
+
ActionType.VALIDATE,
|
6439
|
+
rng
|
5682
6440
|
),
|
6441
|
+
duplicates: [],
|
6442
|
+
eventId,
|
6443
|
+
...input
|
6444
|
+
}),
|
6445
|
+
assign: (eventId, input = {}) => ({
|
6446
|
+
type: ActionType.ASSIGN,
|
6447
|
+
transactionId: input.transactionId ?? getUUID(),
|
6448
|
+
declaration: {},
|
6449
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
6450
|
+
eventId
|
6451
|
+
}),
|
6452
|
+
unassign: (eventId, input = {}) => ({
|
6453
|
+
type: ActionType.UNASSIGN,
|
6454
|
+
transactionId: input.transactionId ?? getUUID(),
|
6455
|
+
declaration: {},
|
6456
|
+
assignedTo: null,
|
5683
6457
|
eventId
|
5684
6458
|
}),
|
5685
|
-
|
5686
|
-
type: ActionType.
|
6459
|
+
archive: (eventId, input = {}, isDuplicate) => ({
|
6460
|
+
type: ActionType.ARCHIVE,
|
5687
6461
|
transactionId: input.transactionId ?? getUUID(),
|
5688
6462
|
declaration: {},
|
6463
|
+
// @TODO: Check whether generator is needed?
|
6464
|
+
annotation: {},
|
6465
|
+
duplicates: [],
|
6466
|
+
eventId,
|
6467
|
+
reason: {
|
6468
|
+
message: `${ActionType.ARCHIVE}`,
|
6469
|
+
isDuplicate: isDuplicate ?? false
|
6470
|
+
},
|
6471
|
+
...input
|
6472
|
+
}),
|
6473
|
+
reject: (eventId, input = {}) => ({
|
6474
|
+
type: ActionType.REJECT,
|
6475
|
+
transactionId: input.transactionId ?? getUUID(),
|
6476
|
+
declaration: {},
|
6477
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6478
|
+
tennisClubMembershipEvent,
|
6479
|
+
ActionType.REJECT,
|
6480
|
+
rng
|
6481
|
+
),
|
6482
|
+
duplicates: [],
|
6483
|
+
eventId,
|
6484
|
+
reason: { message: `${ActionType.REJECT}` },
|
6485
|
+
...input
|
6486
|
+
}),
|
6487
|
+
register: (eventId, input = {}) => ({
|
6488
|
+
type: ActionType.REGISTER,
|
6489
|
+
transactionId: input.transactionId ?? getUUID(),
|
6490
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
6491
|
+
tennisClubMembershipEvent,
|
6492
|
+
ActionType.REGISTER,
|
6493
|
+
rng
|
6494
|
+
),
|
5689
6495
|
annotation: input.annotation ?? generateActionAnnotationInput(
|
5690
6496
|
tennisClubMembershipEvent,
|
5691
|
-
ActionType.
|
6497
|
+
ActionType.REGISTER,
|
6498
|
+
rng
|
5692
6499
|
),
|
5693
6500
|
eventId,
|
5694
|
-
|
6501
|
+
...input
|
5695
6502
|
}),
|
5696
|
-
|
5697
|
-
type: ActionType.
|
6503
|
+
printCertificate: (eventId, input = {}) => ({
|
6504
|
+
type: ActionType.PRINT_CERTIFICATE,
|
5698
6505
|
transactionId: input.transactionId ?? getUUID(),
|
5699
6506
|
declaration: {},
|
5700
6507
|
annotation: input.annotation ?? generateActionAnnotationInput(
|
5701
6508
|
tennisClubMembershipEvent,
|
5702
|
-
ActionType.
|
6509
|
+
ActionType.PRINT_CERTIFICATE,
|
6510
|
+
rng
|
5703
6511
|
),
|
5704
6512
|
eventId,
|
5705
|
-
|
5706
|
-
})
|
6513
|
+
...input
|
6514
|
+
}),
|
6515
|
+
correction: {
|
6516
|
+
request: (eventId, input = {}) => ({
|
6517
|
+
type: ActionType.REQUEST_CORRECTION,
|
6518
|
+
transactionId: input.transactionId ?? getUUID(),
|
6519
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
6520
|
+
tennisClubMembershipEvent,
|
6521
|
+
ActionType.REQUEST_CORRECTION,
|
6522
|
+
rng
|
6523
|
+
),
|
6524
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6525
|
+
tennisClubMembershipEvent,
|
6526
|
+
ActionType.REQUEST_CORRECTION,
|
6527
|
+
rng
|
6528
|
+
),
|
6529
|
+
eventId,
|
6530
|
+
keepAssignment: input.keepAssignment
|
6531
|
+
}),
|
6532
|
+
approve: (eventId, requestId, input = {}) => ({
|
6533
|
+
type: ActionType.APPROVE_CORRECTION,
|
6534
|
+
transactionId: input.transactionId ?? getUUID(),
|
6535
|
+
declaration: {},
|
6536
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6537
|
+
tennisClubMembershipEvent,
|
6538
|
+
ActionType.APPROVE_CORRECTION,
|
6539
|
+
rng
|
6540
|
+
),
|
6541
|
+
eventId,
|
6542
|
+
requestId,
|
6543
|
+
keepAssignment: input.keepAssignment
|
6544
|
+
}),
|
6545
|
+
reject: (eventId, requestId, input = {}) => ({
|
6546
|
+
type: ActionType.REJECT_CORRECTION,
|
6547
|
+
transactionId: input.transactionId ?? getUUID(),
|
6548
|
+
declaration: {},
|
6549
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
6550
|
+
tennisClubMembershipEvent,
|
6551
|
+
ActionType.REJECT_CORRECTION,
|
6552
|
+
rng
|
6553
|
+
),
|
6554
|
+
eventId,
|
6555
|
+
requestId,
|
6556
|
+
keepAssignment: input.keepAssignment
|
6557
|
+
})
|
6558
|
+
}
|
5707
6559
|
}
|
5708
|
-
}
|
5709
|
-
}
|
6560
|
+
};
|
6561
|
+
}
|
5710
6562
|
function generateActionDocument({
|
5711
6563
|
configuration,
|
5712
6564
|
action,
|
5713
|
-
|
6565
|
+
rng = () => 0.1,
|
6566
|
+
defaults = {},
|
6567
|
+
user: user2 = {}
|
5714
6568
|
}) {
|
5715
6569
|
const actionBase = {
|
5716
6570
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
5717
6571
|
// @TODO: This should be fixed in the future.
|
5718
6572
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
5719
|
-
createdBy: getUUID(),
|
5720
|
-
|
6573
|
+
createdBy: user2.id ?? getUUID(),
|
6574
|
+
createdByUserType: TokenUserType.Enum.user,
|
6575
|
+
createdByRole: TestUserRole.Enum.FIELD_AGENT,
|
5721
6576
|
id: getUUID(),
|
5722
|
-
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
5723
|
-
declaration: generateActionDeclarationInput(configuration, action),
|
6577
|
+
createdAtLocation: user2.primaryOfficeId ?? "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
6578
|
+
declaration: generateActionDeclarationInput(configuration, action, rng),
|
5724
6579
|
annotation: {},
|
5725
6580
|
status: ActionStatus.Accepted,
|
5726
6581
|
transactionId: getUUID(),
|
@@ -5734,7 +6589,7 @@ function generateActionDocument({
|
|
5734
6589
|
case ActionType.DECLARE:
|
5735
6590
|
return { ...actionBase, type: action };
|
5736
6591
|
case ActionType.UNASSIGN:
|
5737
|
-
return { ...actionBase, type: action
|
6592
|
+
return { ...actionBase, type: action };
|
5738
6593
|
case ActionType.ASSIGN:
|
5739
6594
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
5740
6595
|
case ActionType.VALIDATE:
|
@@ -5772,13 +6627,15 @@ function generateActionDocument({
|
|
5772
6627
|
}
|
5773
6628
|
function generateEventDocument({
|
5774
6629
|
configuration,
|
5775
|
-
actions
|
6630
|
+
actions,
|
6631
|
+
rng = () => 0.1,
|
6632
|
+
user: user2
|
5776
6633
|
}) {
|
5777
6634
|
return {
|
5778
6635
|
trackingId: getUUID(),
|
5779
6636
|
type: configuration.id,
|
5780
6637
|
actions: actions.map(
|
5781
|
-
(action) => generateActionDocument({ configuration, action })
|
6638
|
+
(action) => generateActionDocument({ configuration, action, rng, user: user2 })
|
5782
6639
|
),
|
5783
6640
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
5784
6641
|
// @TODO: This should be fixed in the future.
|
@@ -5789,10 +6646,16 @@ function generateEventDocument({
|
|
5789
6646
|
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
5790
6647
|
};
|
5791
6648
|
}
|
5792
|
-
function generateEventDraftDocument(
|
6649
|
+
function generateEventDraftDocument({
|
6650
|
+
eventId,
|
6651
|
+
actionType,
|
6652
|
+
rng = () => 0.1,
|
6653
|
+
declaration = {}
|
6654
|
+
}) {
|
5793
6655
|
const action = generateActionDocument({
|
5794
6656
|
configuration: tennisClubMembershipEvent,
|
5795
|
-
action: actionType
|
6657
|
+
action: actionType,
|
6658
|
+
rng
|
5796
6659
|
});
|
5797
6660
|
return {
|
5798
6661
|
id: getUUID(),
|
@@ -5808,51 +6671,29 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
5808
6671
|
eventId
|
5809
6672
|
};
|
5810
6673
|
}
|
5811
|
-
function pickRandom(rng, items) {
|
5812
|
-
return items[Math.floor(rng() * items.length)];
|
5813
|
-
}
|
5814
6674
|
function getRandomDatetime(rng, start, end) {
|
5815
6675
|
const range = end.getTime() - start.getTime();
|
5816
6676
|
const offset = Math.floor(rng() * range);
|
5817
6677
|
const randomDate = new Date(start.getTime() + offset);
|
5818
6678
|
return randomDate.toISOString();
|
5819
6679
|
}
|
6680
|
+
function getRandomDate(rng, start, end) {
|
6681
|
+
const datetime = getRandomDatetime(rng, new Date(start), new Date(end));
|
6682
|
+
return datetime.split("T")[0];
|
6683
|
+
}
|
5820
6684
|
function generateRandomApplicant(rng) {
|
5821
|
-
const
|
5822
|
-
|
5823
|
-
"John",
|
5824
|
-
"Jane",
|
5825
|
-
"Emily",
|
5826
|
-
"Michael",
|
5827
|
-
"Sarah",
|
5828
|
-
"Chris",
|
5829
|
-
"Jessica"
|
5830
|
-
];
|
5831
|
-
const surnames = [
|
5832
|
-
"Doe",
|
5833
|
-
"Smith",
|
5834
|
-
"Johnson",
|
5835
|
-
"Brown",
|
5836
|
-
"Williams",
|
5837
|
-
"Jones",
|
5838
|
-
"Garcia",
|
5839
|
-
"Miller"
|
5840
|
-
];
|
5841
|
-
const randomFirstName = pickRandom(rng, firstNames);
|
5842
|
-
const randomSurname = pickRandom(rng, surnames);
|
5843
|
-
const randomDob = getRandomDatetime(
|
5844
|
-
rng,
|
5845
|
-
/* @__PURE__ */ new Date("1990-01-01"),
|
5846
|
-
/* @__PURE__ */ new Date("2010-12-31")
|
5847
|
-
).split("T")[0];
|
6685
|
+
const { firstname, surname } = generateRandomName(rng);
|
6686
|
+
const randomDob = getRandomDate(rng, "1990-01-01", "2010-12-31");
|
5848
6687
|
return {
|
5849
6688
|
"recommender.none": true,
|
5850
|
-
"applicant.
|
5851
|
-
|
6689
|
+
"applicant.name": {
|
6690
|
+
firstname,
|
6691
|
+
surname
|
6692
|
+
},
|
5852
6693
|
"applicant.dob": randomDob
|
5853
6694
|
};
|
5854
6695
|
}
|
5855
|
-
function
|
6696
|
+
function createPrng(seed) {
|
5856
6697
|
const MODULUS = 2 ** 32;
|
5857
6698
|
const MULTIPLIER = 1664525;
|
5858
6699
|
const INCREMENT = 1013904223;
|
@@ -5862,7 +6703,7 @@ function createPseudoRandomNumberGenerator(seed) {
|
|
5862
6703
|
return state / MODULUS;
|
5863
6704
|
};
|
5864
6705
|
}
|
5865
|
-
function generateUuid(rng) {
|
6706
|
+
function generateUuid(rng = () => 0.1) {
|
5866
6707
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
5867
6708
|
const r = Math.floor(rng() * 16);
|
5868
6709
|
const v = c === "x" ? r : r & 3 | 8;
|
@@ -5874,11 +6715,16 @@ function generateTrackingId(rng) {
|
|
5874
6715
|
const trackingId = uuid.slice(0, 6).toUpperCase();
|
5875
6716
|
return trackingId;
|
5876
6717
|
}
|
6718
|
+
function generateRegistrationNumber(rng) {
|
6719
|
+
const uuid = generateUuid(rng).replace(/-/g, "");
|
6720
|
+
const registrationNumber = uuid.slice(0, 12).toUpperCase();
|
6721
|
+
return registrationNumber;
|
6722
|
+
}
|
5877
6723
|
function generateRandomSignature(rng) {
|
5878
6724
|
return `/random-bucket/${generateUuid(rng)}.png`;
|
5879
6725
|
}
|
5880
6726
|
var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
5881
|
-
const rng =
|
6727
|
+
const rng = createPrng(seed);
|
5882
6728
|
const createdAt = getRandomDatetime(
|
5883
6729
|
rng,
|
5884
6730
|
/* @__PURE__ */ new Date("2024-01-01"),
|
@@ -5887,13 +6733,14 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
5887
6733
|
return {
|
5888
6734
|
id: overrides.id ?? generateUuid(rng),
|
5889
6735
|
type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
|
5890
|
-
status: overrides.status ?? pickRandom(rng,
|
6736
|
+
status: overrides.status ?? pickRandom(rng, EventStatus.options),
|
5891
6737
|
createdAt: overrides.createdAt ?? createdAt,
|
6738
|
+
createdByUserType: overrides.createdByUserType ?? "user",
|
5892
6739
|
createdBy: overrides.createdBy ?? generateUuid(rng),
|
5893
6740
|
createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
|
5894
6741
|
updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
|
5895
6742
|
createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
|
5896
|
-
updatedAt: overrides.updatedAt ?? (0,
|
6743
|
+
updatedAt: overrides.updatedAt ?? (0, import_date_fns3.addDays)(new Date(createdAt), 1).toISOString(),
|
5897
6744
|
assignedTo: overrides.assignedTo ?? null,
|
5898
6745
|
updatedBy: overrides.updatedBy ?? generateUuid(rng),
|
5899
6746
|
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
@@ -5926,8 +6773,7 @@ var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
|
|
5926
6773
|
clauses: [{ eventType: tennisClubMembershipEvent.id }]
|
5927
6774
|
},
|
5928
6775
|
actions: [],
|
5929
|
-
icon: "Draft"
|
5930
|
-
columns: []
|
6776
|
+
icon: "Draft"
|
5931
6777
|
}
|
5932
6778
|
]);
|
5933
6779
|
|
@@ -5942,7 +6788,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
5942
6788
|
if (isTemplateVariable(value)) {
|
5943
6789
|
return false;
|
5944
6790
|
}
|
5945
|
-
if (typeof value === "object" &&
|
6791
|
+
if (typeof value === "object" && // @todo remove ts-ignore
|
6792
|
+
//@ts-ignore
|
6793
|
+
Object.values(value).some((val) => isTemplateVariable(val))) {
|
5946
6794
|
return false;
|
5947
6795
|
}
|
5948
6796
|
return true;
|
@@ -5964,235 +6812,7 @@ function isFieldConfigDefaultValue(value) {
|
|
5964
6812
|
}
|
5965
6813
|
|
5966
6814
|
// ../commons/src/events/scopes.ts
|
5967
|
-
var
|
5968
|
-
|
5969
|
-
// ../commons/src/scopes.ts
|
5970
|
-
var import_zod31 = require("zod");
|
5971
|
-
var SCOPES = {
|
5972
|
-
// TODO v1.8 legacy scopes
|
5973
|
-
NATLSYSADMIN: "natlsysadmin",
|
5974
|
-
BYPASSRATELIMIT: "bypassratelimit",
|
5975
|
-
DECLARE: "declare",
|
5976
|
-
REGISTER: "register",
|
5977
|
-
VALIDATE: "validate",
|
5978
|
-
DEMO: "demo",
|
5979
|
-
CERTIFY: "certify",
|
5980
|
-
PERFORMANCE: "performance",
|
5981
|
-
SYSADMIN: "sysadmin",
|
5982
|
-
TEAMS: "teams",
|
5983
|
-
CONFIG: "config",
|
5984
|
-
// systems / integrations
|
5985
|
-
WEBHOOK: "webhook",
|
5986
|
-
NATIONALID: "nationalId",
|
5987
|
-
NOTIFICATION_API: "notification-api",
|
5988
|
-
RECORDSEARCH: "recordsearch",
|
5989
|
-
/**
|
5990
|
-
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
5991
|
-
*/
|
5992
|
-
RECORD_DECLARE: "record.declare-birth",
|
5993
|
-
// declare
|
5994
|
-
RECORD_IMPORT: "record.import",
|
5995
|
-
// declare
|
5996
|
-
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
5997
|
-
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
5998
|
-
RECORD_DECLARE_DEATH: "record.declare-death",
|
5999
|
-
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
6000
|
-
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
6001
|
-
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
6002
|
-
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
6003
|
-
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
6004
|
-
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
6005
|
-
// validate
|
6006
|
-
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
6007
|
-
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
6008
|
-
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
6009
|
-
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
6010
|
-
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
6011
|
-
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
6012
|
-
// register
|
6013
|
-
RECORD_REGISTER: "record.register",
|
6014
|
-
// certify
|
6015
|
-
RECORD_EXPORT_RECORDS: "record.export-records",
|
6016
|
-
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
6017
|
-
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
6018
|
-
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
6019
|
-
// v1.8
|
6020
|
-
/**
|
6021
|
-
* This scope is used to **print and **issue certified copies of a record
|
6022
|
-
* after it has been registered. Previously Registrars had this permission.
|
6023
|
-
*/
|
6024
|
-
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
6025
|
-
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
6026
|
-
// v1.8
|
6027
|
-
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
6028
|
-
// v1.8
|
6029
|
-
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
6030
|
-
// v1.8
|
6031
|
-
// correct
|
6032
|
-
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
6033
|
-
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
6034
|
-
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
6035
|
-
// v1.8
|
6036
|
-
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
6037
|
-
// v1.8
|
6038
|
-
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
6039
|
-
// v1.8
|
6040
|
-
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
6041
|
-
// v1.8
|
6042
|
-
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
6043
|
-
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
6044
|
-
// search
|
6045
|
-
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
6046
|
-
SEARCH_BIRTH: "search.birth",
|
6047
|
-
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
6048
|
-
SEARCH_DEATH: "search.death",
|
6049
|
-
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
6050
|
-
SEARCH_MARRIAGE: "search.marriage",
|
6051
|
-
// audit v1.8
|
6052
|
-
RECORD_READ: "record.read",
|
6053
|
-
RECORD_READ_AUDIT: "record.read-audit",
|
6054
|
-
RECORD_READ_COMMENTS: "record.read-comments",
|
6055
|
-
RECORD_CREATE_COMMENTS: "record.create-comments",
|
6056
|
-
// profile
|
6057
|
-
PROFILE_UPDATE: "profile.update",
|
6058
|
-
//v1.8
|
6059
|
-
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
6060
|
-
// performance
|
6061
|
-
PERFORMANCE_READ: "performance.read",
|
6062
|
-
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
6063
|
-
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
6064
|
-
// organisation
|
6065
|
-
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
6066
|
-
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
6067
|
-
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
6068
|
-
// user
|
6069
|
-
USER_READ: "user.read:all",
|
6070
|
-
USER_READ_MY_OFFICE: "user.read:my-office",
|
6071
|
-
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
6072
|
-
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
6073
|
-
//v1.8
|
6074
|
-
USER_CREATE: "user.create:all",
|
6075
|
-
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
6076
|
-
USER_UPDATE: "user.update:all",
|
6077
|
-
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
6078
|
-
// config
|
6079
|
-
CONFIG_UPDATE_ALL: "config.update:all",
|
6080
|
-
// data seeding
|
6081
|
-
USER_DATA_SEEDING: "user.data-seeding"
|
6082
|
-
};
|
6083
|
-
var LiteralScopes = import_zod31.z.union([
|
6084
|
-
import_zod31.z.literal(SCOPES.NATLSYSADMIN),
|
6085
|
-
import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
|
6086
|
-
import_zod31.z.literal(SCOPES.DECLARE),
|
6087
|
-
import_zod31.z.literal(SCOPES.REGISTER),
|
6088
|
-
import_zod31.z.literal(SCOPES.VALIDATE),
|
6089
|
-
import_zod31.z.literal(SCOPES.DEMO),
|
6090
|
-
import_zod31.z.literal(SCOPES.CERTIFY),
|
6091
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE),
|
6092
|
-
import_zod31.z.literal(SCOPES.SYSADMIN),
|
6093
|
-
import_zod31.z.literal(SCOPES.TEAMS),
|
6094
|
-
import_zod31.z.literal(SCOPES.CONFIG),
|
6095
|
-
import_zod31.z.literal(SCOPES.WEBHOOK),
|
6096
|
-
import_zod31.z.literal(SCOPES.NATIONALID),
|
6097
|
-
import_zod31.z.literal(SCOPES.NOTIFICATION_API),
|
6098
|
-
import_zod31.z.literal(SCOPES.RECORDSEARCH),
|
6099
|
-
import_zod31.z.literal(SCOPES.RECORD_IMPORT),
|
6100
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
6101
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
6102
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
6103
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
6104
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
6105
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
6106
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
6107
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
6108
|
-
import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
6109
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
6110
|
-
import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
6111
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
6112
|
-
import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
6113
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
6114
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
6115
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTER),
|
6116
|
-
import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
6117
|
-
import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
6118
|
-
import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
6119
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
6120
|
-
import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
6121
|
-
import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
6122
|
-
import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
6123
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
6124
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
6125
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
6126
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
6127
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
6128
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
6129
|
-
import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
6130
|
-
import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
6131
|
-
import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
6132
|
-
import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
6133
|
-
import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
|
6134
|
-
import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
6135
|
-
import_zod31.z.literal(SCOPES.SEARCH_DEATH),
|
6136
|
-
import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
6137
|
-
import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
|
6138
|
-
import_zod31.z.literal(SCOPES.RECORD_READ),
|
6139
|
-
import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
|
6140
|
-
import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
6141
|
-
import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
6142
|
-
import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
|
6143
|
-
import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
6144
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
|
6145
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
6146
|
-
import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
6147
|
-
import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
6148
|
-
import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
6149
|
-
import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
6150
|
-
import_zod31.z.literal(SCOPES.USER_READ),
|
6151
|
-
import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
6152
|
-
import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
6153
|
-
import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
6154
|
-
import_zod31.z.literal(SCOPES.USER_CREATE),
|
6155
|
-
import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
6156
|
-
import_zod31.z.literal(SCOPES.USER_UPDATE),
|
6157
|
-
import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
6158
|
-
import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
6159
|
-
import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
|
6160
|
-
]);
|
6161
|
-
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
6162
|
-
var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
|
6163
|
-
var CreateUserScope = import_zod31.z.object({
|
6164
|
-
type: import_zod31.z.literal("user.create"),
|
6165
|
-
options: import_zod31.z.object({
|
6166
|
-
role: import_zod31.z.array(import_zod31.z.string())
|
6167
|
-
})
|
6168
|
-
});
|
6169
|
-
var EditUserScope = import_zod31.z.object({
|
6170
|
-
type: import_zod31.z.literal("user.edit"),
|
6171
|
-
options: import_zod31.z.object({
|
6172
|
-
role: import_zod31.z.array(import_zod31.z.string())
|
6173
|
-
})
|
6174
|
-
});
|
6175
|
-
var WorkqueueScope = import_zod31.z.object({
|
6176
|
-
type: import_zod31.z.literal("workqueue"),
|
6177
|
-
options: import_zod31.z.object({
|
6178
|
-
id: import_zod31.z.array(import_zod31.z.string())
|
6179
|
-
})
|
6180
|
-
});
|
6181
|
-
var NotifyRecordScope = import_zod31.z.object({
|
6182
|
-
type: import_zod31.z.literal("record.notify"),
|
6183
|
-
options: import_zod31.z.object({
|
6184
|
-
event: import_zod31.z.array(import_zod31.z.string())
|
6185
|
-
})
|
6186
|
-
});
|
6187
|
-
var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
|
6188
|
-
CreateUserScope,
|
6189
|
-
EditUserScope,
|
6190
|
-
WorkqueueScope,
|
6191
|
-
NotifyRecordScope
|
6192
|
-
]);
|
6193
|
-
var scopes = Object.values(SCOPES);
|
6194
|
-
|
6195
|
-
// ../commons/src/events/scopes.ts
|
6815
|
+
var import_lodash4 = require("lodash");
|
6196
6816
|
var CONFIG_GET_ALLOWED_SCOPES = [
|
6197
6817
|
SCOPES.RECORD_DECLARE,
|
6198
6818
|
SCOPES.RECORD_READ,
|
@@ -6269,30 +6889,20 @@ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
|
|
6269
6889
|
[ActionType.UNASSIGN]: [],
|
6270
6890
|
[ActionType.DETECT_DUPLICATE]: []
|
6271
6891
|
};
|
6892
|
+
var WRITE_ACTION_SCOPES = [
|
6893
|
+
...ACTION_ALLOWED_SCOPES[ActionType.DECLARE],
|
6894
|
+
...ACTION_ALLOWED_SCOPES[ActionType.VALIDATE],
|
6895
|
+
...ACTION_ALLOWED_SCOPES[ActionType.REGISTER],
|
6896
|
+
...ACTION_ALLOWED_SCOPES[ActionType.PRINT_CERTIFICATE]
|
6897
|
+
];
|
6272
6898
|
function hasAnyOfScopes(a, b) {
|
6273
|
-
return (0,
|
6274
|
-
}
|
6275
|
-
function filterUnallowedActions(actions, userScopes) {
|
6276
|
-
const allowedActions = actions.filter((action) => {
|
6277
|
-
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
6278
|
-
if (requiredScopes === null) {
|
6279
|
-
return true;
|
6280
|
-
}
|
6281
|
-
return hasAnyOfScopes(userScopes, requiredScopes);
|
6282
|
-
});
|
6283
|
-
const hasOtherAllowedActions = allowedActions.some(
|
6284
|
-
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
6285
|
-
);
|
6286
|
-
if (hasOtherAllowedActions) {
|
6287
|
-
return allowedActions;
|
6288
|
-
}
|
6289
|
-
return [ActionType.READ];
|
6899
|
+
return (0, import_lodash4.intersection)(a, b).length > 0;
|
6290
6900
|
}
|
6291
6901
|
|
6292
6902
|
// ../commons/src/events/serializers/user/deserializer.ts
|
6293
|
-
var
|
6903
|
+
var import_zod34 = require("zod");
|
6294
6904
|
var UserWithPrimaryOffice = User.extend({
|
6295
|
-
primaryOfficeId:
|
6905
|
+
primaryOfficeId: import_zod34.z.string()
|
6296
6906
|
});
|
6297
6907
|
function userDeserializer(serializedUserField, user2) {
|
6298
6908
|
if (typeof serializedUserField === "string") {
|
@@ -6312,6 +6922,7 @@ function deserializeQueryExpression(expression, user2) {
|
|
6312
6922
|
...expression.assignedTo,
|
6313
6923
|
term: userDeserializer(expression.assignedTo.term, user2)
|
6314
6924
|
},
|
6925
|
+
createdByUserType: expression.createdByUserType,
|
6315
6926
|
createdBy: expression.createdBy && {
|
6316
6927
|
...expression.createdBy,
|
6317
6928
|
term: userDeserializer(expression.createdBy.term, user2)
|
@@ -6347,6 +6958,56 @@ function deserializeQuery(query, user2) {
|
|
6347
6958
|
...query,
|
6348
6959
|
clauses: query.clauses.map(
|
6349
6960
|
(clause) => deserializeQueryExpression(clause, user2)
|
6961
|
+
// SAFETY: This cast should be safe because `query.clauses` has already been validated as non-empty by the Zod schema.
|
6962
|
+
// Without the cast, TypeScript cannot infer the tuple type required by the target interface.
|
6350
6963
|
)
|
6351
6964
|
};
|
6352
6965
|
}
|
6966
|
+
|
6967
|
+
// ../commons/src/events/state/availableActions.ts
|
6968
|
+
var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
6969
|
+
[EventStatus.enum.CREATED]: [
|
6970
|
+
ActionType.READ,
|
6971
|
+
ActionType.DECLARE,
|
6972
|
+
ActionType.NOTIFY,
|
6973
|
+
ActionType.DELETE
|
6974
|
+
],
|
6975
|
+
[EventStatus.enum.NOTIFIED]: [
|
6976
|
+
ActionType.READ,
|
6977
|
+
ActionType.DECLARE,
|
6978
|
+
ActionType.ARCHIVE,
|
6979
|
+
ActionType.REJECT
|
6980
|
+
],
|
6981
|
+
[EventStatus.enum.DECLARED]: [
|
6982
|
+
ActionType.READ,
|
6983
|
+
ActionType.VALIDATE,
|
6984
|
+
ActionType.ARCHIVE,
|
6985
|
+
ActionType.REJECT
|
6986
|
+
],
|
6987
|
+
[EventStatus.enum.VALIDATED]: [
|
6988
|
+
ActionType.READ,
|
6989
|
+
ActionType.REGISTER,
|
6990
|
+
ActionType.ARCHIVE,
|
6991
|
+
ActionType.REJECT
|
6992
|
+
],
|
6993
|
+
[EventStatus.enum.REJECTED]: [
|
6994
|
+
ActionType.READ,
|
6995
|
+
ActionType.DECLARE,
|
6996
|
+
ActionType.VALIDATE
|
6997
|
+
],
|
6998
|
+
[EventStatus.enum.REGISTERED]: [
|
6999
|
+
ActionType.READ,
|
7000
|
+
ActionType.PRINT_CERTIFICATE,
|
7001
|
+
ActionType.REQUEST_CORRECTION
|
7002
|
+
],
|
7003
|
+
[EventStatus.enum.CERTIFIED]: [
|
7004
|
+
ActionType.READ,
|
7005
|
+
ActionType.PRINT_CERTIFICATE,
|
7006
|
+
ActionType.REQUEST_CORRECTION
|
7007
|
+
],
|
7008
|
+
[EventStatus.enum.ARCHIVED]: [
|
7009
|
+
ActionType.READ,
|
7010
|
+
ActionType.ASSIGN,
|
7011
|
+
ActionType.UNASSIGN
|
7012
|
+
]
|
7013
|
+
};
|