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