@opencrvs/toolkit 1.8.0-rc.fb0e687 → 1.8.0-rc.fb0f34f
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 +10680 -4260
- package/dist/commons/conditionals/conditionals.d.ts +9 -6
- package/dist/commons/conditionals/validate.d.ts +5 -11
- package/dist/commons/events/ActionConfig.d.ts +97080 -1720
- package/dist/commons/events/ActionDocument.d.ts +645 -308
- package/dist/commons/events/ActionInput.d.ts +341 -243
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +957 -22
- package/dist/commons/events/CompositeFieldValue.d.ts +3 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +3 -0
- package/dist/commons/events/Draft.d.ts +41 -25
- package/dist/commons/events/EventConfig.d.ts +46322 -1345
- package/dist/commons/events/EventDocument.d.ts +415 -229
- package/dist/commons/events/EventIndex.d.ts +1738 -16
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +277 -14
- package/dist/commons/events/FieldConfig.d.ts +4280 -754
- package/dist/commons/events/FieldType.d.ts +3 -3
- package/dist/commons/events/FieldTypeMapping.d.ts +11 -4
- package/dist/commons/events/FieldValue.d.ts +7 -4
- package/dist/commons/events/FormConfig.d.ts +43591 -439
- package/dist/commons/events/PageConfig.d.ts +10860 -204
- package/dist/commons/events/SummaryConfig.d.ts +95 -39
- package/dist/commons/events/TemplateConfig.d.ts +4 -4
- package/dist/commons/events/User.d.ts +5 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +1549 -19
- package/dist/commons/events/defineConfig.d.ts +7223 -40
- package/dist/commons/events/event.d.ts +54 -0
- package/dist/commons/events/field.d.ts +82 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/scopes.d.ts +45 -0
- package/dist/commons/events/test.utils.d.ts +11 -48
- package/dist/commons/events/utils.d.ts +3678 -72
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +36 -33
- package/dist/events/index.js +2089 -1005
- package/dist/scopes/index.d.ts +158 -1
- package/dist/scopes/index.js +152 -1
- package/package.json +3 -2
package/dist/events/index.js
CHANGED
@@ -30,11 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
30
30
|
// src/events/index.ts
|
31
31
|
var events_exports = {};
|
32
32
|
__export(events_exports, {
|
33
|
+
ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
|
34
|
+
ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
|
33
35
|
Action: () => Action,
|
34
36
|
ActionBase: () => ActionBase,
|
35
37
|
ActionConditional: () => ActionConditional,
|
36
38
|
ActionConfig: () => ActionConfig,
|
37
39
|
ActionConfigBase: () => ActionConfigBase,
|
40
|
+
ActionCreationMetadata: () => ActionCreationMetadata,
|
38
41
|
ActionDocument: () => ActionDocument,
|
39
42
|
ActionFormConfig: () => ActionFormConfig,
|
40
43
|
ActionInput: () => ActionInput,
|
@@ -52,6 +55,8 @@ __export(events_exports, {
|
|
52
55
|
AssignActionInput: () => AssignActionInput,
|
53
56
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
54
57
|
BaseActionInput: () => BaseActionInput,
|
58
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
59
|
+
CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
|
55
60
|
CertificateConfig: () => CertificateConfig,
|
56
61
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
57
62
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
@@ -59,9 +64,13 @@ __export(events_exports, {
|
|
59
64
|
Conditional: () => Conditional,
|
60
65
|
ConditionalType: () => ConditionalType,
|
61
66
|
ConfirmableActions: () => ConfirmableActions,
|
67
|
+
CustomFlags: () => CustomFlags,
|
68
|
+
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
62
69
|
DataEntry: () => DataEntry,
|
63
70
|
DataFieldValue: () => DataFieldValue,
|
71
|
+
DateRangeFieldValue: () => DateRangeFieldValue,
|
64
72
|
DateValue: () => DateValue,
|
73
|
+
DatetimeValue: () => DatetimeValue,
|
65
74
|
DeclarationActionConfig: () => DeclarationActionConfig,
|
66
75
|
DeclarationActions: () => DeclarationActions,
|
67
76
|
DeclarationFormConfig: () => DeclarationFormConfig,
|
@@ -69,6 +78,7 @@ __export(events_exports, {
|
|
69
78
|
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
70
79
|
DeclareActionInput: () => DeclareActionInput,
|
71
80
|
DeduplicationConfig: () => DeduplicationConfig,
|
81
|
+
DeleteActionInput: () => DeleteActionInput,
|
72
82
|
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
73
83
|
Draft: () => Draft,
|
74
84
|
DraftInput: () => DraftInput,
|
@@ -77,20 +87,28 @@ __export(events_exports, {
|
|
77
87
|
EnableConditional: () => EnableConditional,
|
78
88
|
EventConfig: () => EventConfig,
|
79
89
|
EventDocument: () => EventDocument,
|
90
|
+
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
91
|
+
EventFieldId: () => EventFieldId,
|
80
92
|
EventIndex: () => EventIndex,
|
81
93
|
EventInput: () => EventInput,
|
82
94
|
EventMetadata: () => EventMetadata,
|
95
|
+
EventMetadataKeys: () => EventMetadataKeys,
|
96
|
+
EventMetadataParameter: () => EventMetadataParameter,
|
83
97
|
EventSearchIndex: () => EventSearchIndex,
|
98
|
+
EventState: () => EventState,
|
84
99
|
EventStatus: () => EventStatus,
|
100
|
+
EventStatusEnum: () => EventStatusEnum,
|
85
101
|
EventStatuses: () => EventStatuses,
|
86
102
|
FieldConditional: () => FieldConditional,
|
87
103
|
FieldConfig: () => FieldConfig,
|
104
|
+
FieldConfigSchema: () => FieldConfigSchema,
|
88
105
|
FieldType: () => FieldType,
|
89
106
|
FieldUpdateValue: () => FieldUpdateValue,
|
90
107
|
FieldValue: () => FieldValue,
|
91
108
|
FileFieldValue: () => FileFieldValue,
|
92
109
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
93
110
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
111
|
+
Flag: () => Flag,
|
94
112
|
FormConfig: () => FormConfig,
|
95
113
|
FormPageConfig: () => FormPageConfig,
|
96
114
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
@@ -98,23 +116,30 @@ __export(events_exports, {
|
|
98
116
|
GeographicalArea: () => GeographicalArea,
|
99
117
|
ImageMimeType: () => ImageMimeType,
|
100
118
|
LanguageConfig: () => LanguageConfig,
|
119
|
+
LegalStatuses: () => LegalStatuses,
|
101
120
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
102
121
|
MimeType: () => MimeType,
|
122
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
103
123
|
NotifyActionInput: () => NotifyActionInput,
|
104
124
|
NumberFieldValue: () => NumberFieldValue,
|
105
125
|
PageConfig: () => PageConfig,
|
106
126
|
PageTypes: () => PageTypes,
|
107
127
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
128
|
+
QueryInput: () => QueryInput,
|
129
|
+
QueryType: () => QueryType,
|
108
130
|
ReadActionInput: () => ReadActionInput,
|
109
131
|
RegisterAction: () => RegisterAction,
|
110
132
|
RegisterActionInput: () => RegisterActionInput,
|
133
|
+
RegistrationCreationMetadata: () => RegistrationCreationMetadata,
|
111
134
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
112
135
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
113
136
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
114
|
-
RequiredTextValue: () => RequiredTextValue,
|
115
137
|
ResolvedUser: () => ResolvedUser,
|
116
138
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
117
139
|
RuralAddressValue: () => RuralAddressValue,
|
140
|
+
SearchField: () => SearchField,
|
141
|
+
SearchQueryParams: () => SearchQueryParams,
|
142
|
+
SelectOption: () => SelectOption,
|
118
143
|
ShowConditional: () => ShowConditional,
|
119
144
|
SummaryConfig: () => SummaryConfig,
|
120
145
|
TextValue: () => TextValue,
|
@@ -126,12 +151,16 @@ __export(events_exports, {
|
|
126
151
|
VerificationActionConfig: () => VerificationActionConfig,
|
127
152
|
VerificationPageConfig: () => VerificationPageConfig,
|
128
153
|
WorkqueueConfig: () => WorkqueueConfig,
|
154
|
+
ZodDate: () => ZodDate,
|
129
155
|
alwaysTrue: () => alwaysTrue,
|
130
156
|
and: () => and,
|
131
157
|
annotationActions: () => annotationActions,
|
132
158
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
159
|
+
areConditionsMet: () => areConditionsMet,
|
133
160
|
compositeFieldTypes: () => compositeFieldTypes,
|
134
161
|
createEmptyDraft: () => createEmptyDraft,
|
162
|
+
createEventConditionals: () => createEventConditionals,
|
163
|
+
createFieldConditionals: () => createFieldConditionals,
|
135
164
|
createValidationSchema: () => createValidationSchema,
|
136
165
|
deepDropNulls: () => deepDropNulls,
|
137
166
|
deepMerge: () => deepMerge,
|
@@ -142,6 +171,7 @@ __export(events_exports, {
|
|
142
171
|
defineFormConditional: () => defineFormConditional,
|
143
172
|
defineFormPage: () => defineFormPage,
|
144
173
|
definePage: () => definePage,
|
174
|
+
defineWorkqueue: () => defineWorkqueue,
|
145
175
|
errorMessages: () => errorMessages,
|
146
176
|
event: () => event,
|
147
177
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -150,12 +180,14 @@ __export(events_exports, {
|
|
150
180
|
eventStatuses: () => eventStatuses,
|
151
181
|
field: () => field,
|
152
182
|
fieldTypes: () => fieldTypes,
|
183
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
153
184
|
findActiveDrafts: () => findActiveDrafts,
|
154
185
|
findAllFields: () => findAllFields,
|
186
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
155
187
|
findRecordActionPages: () => findRecordActionPages,
|
188
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
189
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
156
190
|
generateActionDocument: () => generateActionDocument,
|
157
|
-
generateActionInput: () => generateActionInput,
|
158
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
159
191
|
generateEventDocument: () => generateEventDocument,
|
160
192
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
161
193
|
generateTransactionId: () => generateTransactionId,
|
@@ -165,22 +197,27 @@ __export(events_exports, {
|
|
165
197
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
166
198
|
getActionReview: () => getActionReview,
|
167
199
|
getActionReviewFields: () => getActionReviewFields,
|
168
|
-
|
200
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
169
201
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
202
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
170
203
|
getCurrentEventState: () => getCurrentEventState,
|
171
204
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
172
205
|
getDeclaration: () => getDeclaration,
|
173
206
|
getDeclarationFields: () => getDeclarationFields,
|
174
207
|
getDeclarationPages: () => getDeclarationPages,
|
175
|
-
|
176
|
-
|
208
|
+
getMixedPath: () => getMixedPath,
|
209
|
+
getRandomDatetime: () => getRandomDatetime,
|
210
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
211
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
177
212
|
isAddressFieldType: () => isAddressFieldType,
|
178
213
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
179
214
|
isBulletListFieldType: () => isBulletListFieldType,
|
180
215
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
216
|
+
isConditionMet: () => isConditionMet,
|
181
217
|
isCountryFieldType: () => isCountryFieldType,
|
182
218
|
isDataFieldType: () => isDataFieldType,
|
183
219
|
isDateFieldType: () => isDateFieldType,
|
220
|
+
isDateRangeFieldType: () => isDateRangeFieldType,
|
184
221
|
isDividerFieldType: () => isDividerFieldType,
|
185
222
|
isEmailFieldType: () => isEmailFieldType,
|
186
223
|
isFacilityFieldType: () => isFacilityFieldType,
|
@@ -206,17 +243,21 @@ __export(events_exports, {
|
|
206
243
|
isTextFieldType: () => isTextFieldType,
|
207
244
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
208
245
|
isVerificationPage: () => isVerificationPage,
|
246
|
+
isWriteAction: () => isWriteAction,
|
209
247
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
210
248
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
211
249
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
212
250
|
never: () => never,
|
213
251
|
not: () => not,
|
252
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
253
|
+
omitHiddenFields: () => omitHiddenFields,
|
254
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
214
255
|
or: () => or,
|
215
|
-
|
256
|
+
runFieldValidations: () => runFieldValidations,
|
216
257
|
user: () => user,
|
217
258
|
validate: () => validate,
|
218
259
|
validateFieldInput: () => validateFieldInput,
|
219
|
-
|
260
|
+
writeActions: () => writeActions
|
220
261
|
});
|
221
262
|
module.exports = __toCommonJS(events_exports);
|
222
263
|
|
@@ -225,9 +266,12 @@ var import_zod9 = require("zod");
|
|
225
266
|
|
226
267
|
// ../commons/src/events/Conditional.ts
|
227
268
|
var import_zod = require("zod");
|
228
|
-
var
|
229
|
-
|
230
|
-
)
|
269
|
+
var import_zod_openapi = require("zod-openapi");
|
270
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod.z);
|
271
|
+
var Conditional = import_zod.z.custom((val) => typeof val === "object" && val !== null).openapi({
|
272
|
+
description: "JSON schema conditional configuration",
|
273
|
+
ref: "Conditional"
|
274
|
+
});
|
231
275
|
var ConditionalType = {
|
232
276
|
SHOW: "SHOW",
|
233
277
|
ENABLE: "ENABLE",
|
@@ -264,7 +308,10 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
|
264
308
|
EnableConditional,
|
265
309
|
// Field output can be shown / hidden on the review page
|
266
310
|
DisplayOnReviewConditional
|
267
|
-
])
|
311
|
+
]).openapi({
|
312
|
+
description: "Field conditional configuration",
|
313
|
+
ref: "FieldConditional"
|
314
|
+
});
|
268
315
|
|
269
316
|
// ../commons/src/events/PageConfig.ts
|
270
317
|
var import_zod6 = require("zod");
|
@@ -274,6 +321,8 @@ var import_zod5 = require("zod");
|
|
274
321
|
|
275
322
|
// ../commons/src/events/TranslationConfig.ts
|
276
323
|
var import_zod2 = require("zod");
|
324
|
+
var import_zod_openapi2 = require("zod-openapi");
|
325
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod2.z);
|
277
326
|
var TranslationConfig = import_zod2.z.object({
|
278
327
|
id: import_zod2.z.string().describe(
|
279
328
|
"The identifier of the translation referred in translation CSV files"
|
@@ -282,6 +331,9 @@ var TranslationConfig = import_zod2.z.object({
|
|
282
331
|
description: import_zod2.z.string().describe(
|
283
332
|
"Describe the translation for a translator to be able to identify it."
|
284
333
|
)
|
334
|
+
}).openapi({
|
335
|
+
description: "Translation configuration",
|
336
|
+
ref: "TranslationConfig"
|
285
337
|
});
|
286
338
|
|
287
339
|
// ../commons/src/events/FieldType.ts
|
@@ -292,12 +344,12 @@ var FieldType = {
|
|
292
344
|
TEXTAREA: "TEXTAREA",
|
293
345
|
EMAIL: "EMAIL",
|
294
346
|
DATE: "DATE",
|
347
|
+
DATE_RANGE: "DATE_RANGE",
|
295
348
|
PARAGRAPH: "PARAGRAPH",
|
296
349
|
PAGE_HEADER: "PAGE_HEADER",
|
297
350
|
RADIO_GROUP: "RADIO_GROUP",
|
298
351
|
FILE: "FILE",
|
299
352
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
300
|
-
HIDDEN: "HIDDEN",
|
301
353
|
BULLET_LIST: "BULLET_LIST",
|
302
354
|
CHECKBOX: "CHECKBOX",
|
303
355
|
SELECT: "SELECT",
|
@@ -312,6 +364,7 @@ var FieldType = {
|
|
312
364
|
};
|
313
365
|
var fieldTypes = Object.values(FieldType);
|
314
366
|
var compositeFieldTypes = [
|
367
|
+
FieldType.DATE_RANGE,
|
315
368
|
FieldType.ADDRESS,
|
316
369
|
FieldType.FILE_WITH_OPTIONS,
|
317
370
|
FieldType.FILE
|
@@ -402,8 +455,10 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
402
455
|
|
403
456
|
// ../commons/src/events/FieldValue.ts
|
404
457
|
var TextValue = import_zod4.z.string();
|
405
|
-
var
|
458
|
+
var NonEmptyTextValue = TextValue.min(1);
|
406
459
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
460
|
+
var DatetimeValue = import_zod4.z.string().datetime();
|
461
|
+
var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
|
407
462
|
var EmailValue = import_zod4.z.string().email();
|
408
463
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
409
464
|
var NumberFieldValue = import_zod4.z.number();
|
@@ -411,6 +466,7 @@ var DataFieldValue = import_zod4.z.undefined();
|
|
411
466
|
var FieldValue = import_zod4.z.union([
|
412
467
|
TextValue,
|
413
468
|
DateValue,
|
469
|
+
DateRangeFieldValue,
|
414
470
|
CheckboxFieldValue,
|
415
471
|
NumberFieldValue,
|
416
472
|
FileFieldValue,
|
@@ -423,6 +479,7 @@ var FieldValue = import_zod4.z.union([
|
|
423
479
|
var FieldUpdateValue = import_zod4.z.union([
|
424
480
|
TextValue,
|
425
481
|
DateValue,
|
482
|
+
DateRangeFieldValue,
|
426
483
|
CheckboxFieldValue,
|
427
484
|
NumberFieldValue,
|
428
485
|
FileFieldValue,
|
@@ -434,28 +491,24 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
434
491
|
]);
|
435
492
|
|
436
493
|
// ../commons/src/events/FieldConfig.ts
|
494
|
+
var import_zod_openapi3 = require("zod-openapi");
|
495
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
|
437
496
|
var FieldId = import_zod5.z.string();
|
438
|
-
var
|
439
|
-
|
440
|
-
|
441
|
-
});
|
497
|
+
var ParentReference = import_zod5.z.object({
|
498
|
+
_fieldId: FieldId.optional()
|
499
|
+
}).optional();
|
442
500
|
var BaseField = import_zod5.z.object({
|
443
501
|
id: FieldId,
|
444
502
|
defaultValue: import_zod5.z.union([
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
NumberFieldValue,
|
451
|
-
CheckboxFieldValue
|
452
|
-
]),
|
453
|
-
DependencyExpression
|
503
|
+
TextValue,
|
504
|
+
NonEmptyTextValue,
|
505
|
+
DateValue,
|
506
|
+
NumberFieldValue,
|
507
|
+
CheckboxFieldValue
|
454
508
|
]).optional(),
|
509
|
+
parent: ParentReference,
|
455
510
|
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
456
511
|
required: import_zod5.z.boolean().default(false).optional(),
|
457
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
458
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
459
512
|
placeholder: TranslationConfig.optional(),
|
460
513
|
validation: import_zod5.z.array(
|
461
514
|
import_zod5.z.object({
|
@@ -463,8 +516,8 @@ var BaseField = import_zod5.z.object({
|
|
463
516
|
message: TranslationConfig
|
464
517
|
})
|
465
518
|
).default([]).optional(),
|
466
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
467
519
|
label: TranslationConfig,
|
520
|
+
helperText: TranslationConfig.optional(),
|
468
521
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
469
522
|
});
|
470
523
|
var Divider = BaseField.extend({
|
@@ -472,7 +525,7 @@ var Divider = BaseField.extend({
|
|
472
525
|
});
|
473
526
|
var TextField = BaseField.extend({
|
474
527
|
type: import_zod5.z.literal(FieldType.TEXT),
|
475
|
-
defaultValue:
|
528
|
+
defaultValue: NonEmptyTextValue.optional(),
|
476
529
|
configuration: import_zod5.z.object({
|
477
530
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
478
531
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -482,7 +535,7 @@ var TextField = BaseField.extend({
|
|
482
535
|
}).describe("Text input");
|
483
536
|
var NumberField = BaseField.extend({
|
484
537
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
485
|
-
defaultValue:
|
538
|
+
defaultValue: NumberFieldValue.optional(),
|
486
539
|
configuration: import_zod5.z.object({
|
487
540
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
488
541
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -492,7 +545,7 @@ var NumberField = BaseField.extend({
|
|
492
545
|
}).describe("Number input");
|
493
546
|
var TextAreaField = BaseField.extend({
|
494
547
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
495
|
-
defaultValue:
|
548
|
+
defaultValue: NonEmptyTextValue.optional(),
|
496
549
|
configuration: import_zod5.z.object({
|
497
550
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
498
551
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -526,17 +579,28 @@ var EmailField = BaseField.extend({
|
|
526
579
|
configuration: import_zod5.z.object({
|
527
580
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
528
581
|
}).default({ maxLength: 10 }).optional(),
|
529
|
-
defaultValue:
|
582
|
+
defaultValue: NonEmptyTextValue.optional()
|
530
583
|
});
|
531
584
|
var DateField = BaseField.extend({
|
532
585
|
type: import_zod5.z.literal(FieldType.DATE),
|
533
|
-
defaultValue:
|
586
|
+
defaultValue: DateValue.optional(),
|
534
587
|
configuration: import_zod5.z.object({
|
535
588
|
notice: TranslationConfig.describe(
|
536
589
|
"Text to display above the date input"
|
537
590
|
).optional()
|
538
591
|
}).optional()
|
539
592
|
}).describe("A single date input (dd-mm-YYYY)");
|
593
|
+
var DateRangeField = BaseField.extend({
|
594
|
+
type: import_zod5.z.literal(FieldType.DATE_RANGE),
|
595
|
+
defaultValue: DateRangeFieldValue.optional(),
|
596
|
+
configuration: import_zod5.z.object({
|
597
|
+
notice: TranslationConfig.describe(
|
598
|
+
"Text to display above the date input"
|
599
|
+
).optional()
|
600
|
+
}).optional()
|
601
|
+
}).describe(
|
602
|
+
"A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
|
603
|
+
);
|
540
604
|
var HtmlFontVariant = import_zod5.z.enum([
|
541
605
|
"reg12",
|
542
606
|
"reg14",
|
@@ -549,7 +613,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
549
613
|
]);
|
550
614
|
var Paragraph = BaseField.extend({
|
551
615
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
552
|
-
defaultValue:
|
616
|
+
defaultValue: NonEmptyTextValue.optional(),
|
553
617
|
configuration: import_zod5.z.object({
|
554
618
|
styles: import_zod5.z.object({
|
555
619
|
fontVariant: HtmlFontVariant.optional()
|
@@ -558,7 +622,7 @@ var Paragraph = BaseField.extend({
|
|
558
622
|
}).describe("A read-only HTML <p> paragraph");
|
559
623
|
var PageHeader = BaseField.extend({
|
560
624
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
561
|
-
defaultValue:
|
625
|
+
defaultValue: NonEmptyTextValue.optional()
|
562
626
|
}).describe("A read-only header component for form pages");
|
563
627
|
var File = BaseField.extend({
|
564
628
|
type: import_zod5.z.literal(FieldType.FILE),
|
@@ -569,7 +633,8 @@ var File = BaseField.extend({
|
|
569
633
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
570
634
|
"Whether the file upload button should take the full width of the container or not"
|
571
635
|
)
|
572
|
-
}).optional()
|
636
|
+
}).optional(),
|
637
|
+
fileName: TranslationConfig.optional()
|
573
638
|
}).default({
|
574
639
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
575
640
|
})
|
@@ -580,7 +645,7 @@ var SelectOption = import_zod5.z.object({
|
|
580
645
|
});
|
581
646
|
var RadioGroup = BaseField.extend({
|
582
647
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
583
|
-
defaultValue:
|
648
|
+
defaultValue: TextValue.optional(),
|
584
649
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
585
650
|
configuration: import_zod5.z.object({
|
586
651
|
styles: import_zod5.z.object({
|
@@ -590,7 +655,7 @@ var RadioGroup = BaseField.extend({
|
|
590
655
|
}).describe("Grouped radio options");
|
591
656
|
var BulletList = BaseField.extend({
|
592
657
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
593
|
-
defaultValue:
|
658
|
+
defaultValue: TextValue.optional(),
|
594
659
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
595
660
|
configuration: import_zod5.z.object({
|
596
661
|
styles: import_zod5.z.object({
|
@@ -600,16 +665,16 @@ var BulletList = BaseField.extend({
|
|
600
665
|
}).describe("A list of bullet points");
|
601
666
|
var Select = BaseField.extend({
|
602
667
|
type: import_zod5.z.literal(FieldType.SELECT),
|
603
|
-
defaultValue:
|
668
|
+
defaultValue: TextValue.optional(),
|
604
669
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
605
670
|
}).describe("Select input");
|
606
671
|
var Checkbox = BaseField.extend({
|
607
672
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
608
|
-
defaultValue:
|
673
|
+
defaultValue: CheckboxFieldValue.optional()
|
609
674
|
}).describe("Boolean checkbox field");
|
610
675
|
var Country = BaseField.extend({
|
611
676
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
612
|
-
defaultValue:
|
677
|
+
defaultValue: NonEmptyTextValue.optional()
|
613
678
|
}).describe("Country select field");
|
614
679
|
var AdministrativeAreas = import_zod5.z.enum([
|
615
680
|
"ADMIN_STRUCTURE",
|
@@ -624,12 +689,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
|
|
624
689
|
}).describe("Administrative area options");
|
625
690
|
var AdministrativeArea = BaseField.extend({
|
626
691
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
627
|
-
defaultValue:
|
692
|
+
defaultValue: NonEmptyTextValue.optional(),
|
628
693
|
configuration: AdministrativeAreaConfiguration
|
629
694
|
}).describe("Administrative area input field e.g. facility, office");
|
630
695
|
var Location = BaseField.extend({
|
631
696
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
632
|
-
defaultValue:
|
697
|
+
defaultValue: NonEmptyTextValue.optional()
|
633
698
|
}).describe("Input field for a location");
|
634
699
|
var FileUploadWithOptions = BaseField.extend({
|
635
700
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
@@ -643,11 +708,11 @@ var FileUploadWithOptions = BaseField.extend({
|
|
643
708
|
});
|
644
709
|
var Facility = BaseField.extend({
|
645
710
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
646
|
-
defaultValue:
|
711
|
+
defaultValue: NonEmptyTextValue.optional()
|
647
712
|
}).describe("Input field for a facility");
|
648
713
|
var Office = BaseField.extend({
|
649
714
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
650
|
-
defaultValue:
|
715
|
+
defaultValue: NonEmptyTextValue.optional()
|
651
716
|
}).describe("Input field for an office");
|
652
717
|
var Address = BaseField.extend({
|
653
718
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
@@ -656,7 +721,7 @@ var Address = BaseField.extend({
|
|
656
721
|
var DataEntry = import_zod5.z.union([
|
657
722
|
import_zod5.z.object({
|
658
723
|
label: TranslationConfig,
|
659
|
-
value: import_zod5.z.string()
|
724
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
660
725
|
}),
|
661
726
|
import_zod5.z.object({
|
662
727
|
fieldId: import_zod5.z.string()
|
@@ -675,6 +740,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
675
740
|
NumberField,
|
676
741
|
TextAreaField,
|
677
742
|
DateField,
|
743
|
+
DateRangeField,
|
678
744
|
Paragraph,
|
679
745
|
RadioGroup,
|
680
746
|
BulletList,
|
@@ -692,10 +758,14 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
692
758
|
EmailField,
|
693
759
|
FileUploadWithOptions,
|
694
760
|
DataField
|
695
|
-
|
696
|
-
|
761
|
+
]).openapi({
|
762
|
+
description: "Form field configuration",
|
763
|
+
ref: "FieldConfig"
|
764
|
+
});
|
697
765
|
|
698
766
|
// ../commons/src/events/PageConfig.ts
|
767
|
+
var import_zod_openapi4 = require("zod-openapi");
|
768
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
|
699
769
|
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
700
770
|
var PageConfigBase = import_zod6.z.object({
|
701
771
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
@@ -704,6 +774,9 @@ var PageConfigBase = import_zod6.z.object({
|
|
704
774
|
conditional: Conditional.optional().describe(
|
705
775
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
706
776
|
)
|
777
|
+
}).openapi({
|
778
|
+
description: "Form page configuration",
|
779
|
+
ref: "FormPageConfig"
|
707
780
|
});
|
708
781
|
var FormPageConfig = PageConfigBase.extend({
|
709
782
|
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
@@ -717,7 +790,10 @@ var VerificationActionConfig = import_zod6.z.object({
|
|
717
790
|
body: TranslationConfig
|
718
791
|
})
|
719
792
|
})
|
720
|
-
}).describe("Actions available on the verification page")
|
793
|
+
}).describe("Actions available on the verification page").openapi({
|
794
|
+
description: "Verification action configuration",
|
795
|
+
ref: "VerificationActionConfig"
|
796
|
+
});
|
721
797
|
var VerificationPageConfig = FormPageConfig.extend({
|
722
798
|
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
723
799
|
actions: VerificationActionConfig
|
@@ -797,6 +873,12 @@ var DeclarationUpdateActions = ActionTypes.extract(
|
|
797
873
|
declarationUpdateActionValues
|
798
874
|
);
|
799
875
|
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
876
|
+
var writeActions = ActionTypes.exclude([
|
877
|
+
ActionType.CREATE,
|
878
|
+
ActionType.READ,
|
879
|
+
ActionType.ASSIGN,
|
880
|
+
ActionType.UNASSIGN
|
881
|
+
]);
|
800
882
|
|
801
883
|
// ../commons/src/events/FormConfig.ts
|
802
884
|
var import_zod8 = require("zod");
|
@@ -811,6 +893,8 @@ var ActionFormConfig = import_zod8.z.object({
|
|
811
893
|
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
812
894
|
|
813
895
|
// ../commons/src/events/ActionConfig.ts
|
896
|
+
var import_zod_openapi5 = require("zod-openapi");
|
897
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
|
814
898
|
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
815
899
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
816
900
|
ShowConditional,
|
@@ -888,18 +972,24 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
|
|
888
972
|
})
|
889
973
|
);
|
890
974
|
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
975
|
+
/*
|
976
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
977
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
978
|
+
*/
|
979
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
980
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
981
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
982
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
983
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
984
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
985
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
986
|
+
PrintCertificateActionConfig.openapi({
|
987
|
+
ref: "PrintCertificateActionConfig"
|
988
|
+
}),
|
989
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
990
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
991
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
992
|
+
]).openapi({ ref: "ActionConfig" });
|
903
993
|
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
904
994
|
DeclareConfig,
|
905
995
|
ValidateConfig,
|
@@ -943,10 +1033,12 @@ var LanguageConfig = import_zod11.z.object({
|
|
943
1033
|
});
|
944
1034
|
|
945
1035
|
// ../commons/src/events/EventConfig.ts
|
946
|
-
var
|
1036
|
+
var import_zod18 = require("zod");
|
947
1037
|
|
948
1038
|
// ../commons/src/events/DeduplicationConfig.ts
|
949
1039
|
var import_zod12 = require("zod");
|
1040
|
+
var import_zod_openapi6 = require("zod-openapi");
|
1041
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
|
950
1042
|
var FieldReference = import_zod12.z.string();
|
951
1043
|
var Matcher = import_zod12.z.object({
|
952
1044
|
fieldId: import_zod12.z.string(),
|
@@ -1007,7 +1099,9 @@ var Clause = import_zod12.z.lazy(
|
|
1007
1099
|
DateRangeMatcher,
|
1008
1100
|
DateDistanceMatcher
|
1009
1101
|
])
|
1010
|
-
)
|
1102
|
+
).openapi({
|
1103
|
+
ref: "Clause"
|
1104
|
+
});
|
1011
1105
|
var DeduplicationConfig = import_zod12.z.object({
|
1012
1106
|
id: import_zod12.z.string(),
|
1013
1107
|
label: TranslationConfig,
|
@@ -1016,272 +1110,267 @@ var DeduplicationConfig = import_zod12.z.object({
|
|
1016
1110
|
|
1017
1111
|
// ../commons/src/events/SummaryConfig.ts
|
1018
1112
|
var import_zod13 = require("zod");
|
1019
|
-
var
|
1113
|
+
var BaseField2 = import_zod13.z.object({
|
1114
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1115
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1116
|
+
});
|
1117
|
+
var ReferenceField = BaseField2.extend({
|
1118
|
+
fieldId: import_zod13.z.string(),
|
1119
|
+
label: TranslationConfig.optional().describe(
|
1120
|
+
"By default, the configured field's label is used. This can be overridden by providing a custom label."
|
1121
|
+
)
|
1122
|
+
}).describe("Field directly referencing event data with field id");
|
1123
|
+
var Field = BaseField2.extend({
|
1020
1124
|
id: import_zod13.z.string().describe("Id of summary field"),
|
1021
1125
|
value: TranslationConfig.describe(
|
1022
1126
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1023
1127
|
),
|
1024
1128
|
label: TranslationConfig,
|
1025
1129
|
emptyValueMessage: TranslationConfig.optional()
|
1026
|
-
});
|
1027
|
-
var Title = import_zod13.z.object({
|
1028
|
-
id: import_zod13.z.string(),
|
1029
|
-
label: TranslationConfig.describe("Title content"),
|
1030
|
-
emptyValueMessage: TranslationConfig.optional()
|
1031
|
-
});
|
1130
|
+
}).describe("Custom configured field");
|
1032
1131
|
var SummaryConfig = import_zod13.z.object({
|
1033
|
-
|
1034
|
-
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
1132
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
1035
1133
|
}).describe("Configuration for summary in event.");
|
1036
1134
|
|
1037
|
-
// ../commons/src/events/
|
1038
|
-
var import_zod15 = require("zod");
|
1039
|
-
|
1040
|
-
// ../commons/src/events/EventMetadata.ts
|
1135
|
+
// ../commons/src/events/AdvancedSearchConfig.ts
|
1041
1136
|
var import_zod14 = require("zod");
|
1042
|
-
var
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
var eventStatuses = Object.values(EventStatus);
|
1053
|
-
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1054
|
-
var EventMetadata = import_zod14.z.object({
|
1055
|
-
id: import_zod14.z.string(),
|
1056
|
-
type: import_zod14.z.string(),
|
1057
|
-
status: EventStatuses,
|
1058
|
-
createdAt: import_zod14.z.string().datetime(),
|
1059
|
-
createdBy: import_zod14.z.string(),
|
1060
|
-
createdAtLocation: import_zod14.z.string(),
|
1061
|
-
modifiedAt: import_zod14.z.string().datetime(),
|
1062
|
-
assignedTo: import_zod14.z.string().nullish(),
|
1063
|
-
updatedBy: import_zod14.z.string(),
|
1064
|
-
trackingId: import_zod14.z.string(),
|
1065
|
-
registrationNumber: import_zod14.z.string().nullish()
|
1066
|
-
});
|
1067
|
-
var eventMetadataLabelMap = {
|
1068
|
-
"event.assignedTo": {
|
1069
|
-
id: "event.assignedTo.label",
|
1070
|
-
defaultMessage: "Assigned To",
|
1071
|
-
description: "Assigned To"
|
1072
|
-
},
|
1073
|
-
"event.createdAt": {
|
1074
|
-
id: "event.createdAt.label",
|
1075
|
-
defaultMessage: "Created",
|
1076
|
-
description: "Created At"
|
1077
|
-
},
|
1078
|
-
"event.createdAtLocation": {
|
1079
|
-
id: "event.createdAtLocation.label",
|
1080
|
-
defaultMessage: "Location",
|
1081
|
-
description: "Created At Location"
|
1082
|
-
},
|
1083
|
-
"event.createdBy": {
|
1084
|
-
id: "event.createdBy.label",
|
1085
|
-
defaultMessage: "Created By",
|
1086
|
-
description: "Created By"
|
1087
|
-
},
|
1088
|
-
"event.id": {
|
1089
|
-
id: "event.id.label",
|
1090
|
-
defaultMessage: "ID",
|
1091
|
-
description: "ID"
|
1092
|
-
},
|
1093
|
-
"event.modifiedAt": {
|
1094
|
-
id: "event.modifiedAt.label",
|
1095
|
-
defaultMessage: "Updated",
|
1096
|
-
description: "Modified At"
|
1097
|
-
},
|
1098
|
-
"event.status": {
|
1099
|
-
id: "event.status.label",
|
1100
|
-
defaultMessage: "Status",
|
1101
|
-
description: "Status"
|
1102
|
-
},
|
1103
|
-
"event.type": {
|
1104
|
-
id: "event.type.label",
|
1105
|
-
defaultMessage: "Type",
|
1106
|
-
description: "Type"
|
1107
|
-
},
|
1108
|
-
"event.updatedBy": {
|
1109
|
-
id: "event.updatedBy.label",
|
1110
|
-
defaultMessage: "Updated By",
|
1111
|
-
description: "Updated By"
|
1112
|
-
},
|
1113
|
-
"event.trackingId": {
|
1114
|
-
id: "event.trackingId.label",
|
1115
|
-
defaultMessage: "Tracking ID",
|
1116
|
-
description: "Tracking ID"
|
1117
|
-
},
|
1118
|
-
"event.registrationNumber": {
|
1119
|
-
id: "event.registrationNumber.label",
|
1120
|
-
defaultMessage: "Registration Number",
|
1121
|
-
description: "Registration Number"
|
1122
|
-
}
|
1123
|
-
};
|
1137
|
+
var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
|
1138
|
+
var BaseField3 = import_zod14.z.object({
|
1139
|
+
config: import_zod14.z.object({
|
1140
|
+
type: MatchType.describe("Determines the type of field")
|
1141
|
+
}),
|
1142
|
+
options: import_zod14.z.array(SelectOption).optional(),
|
1143
|
+
searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
|
1144
|
+
`
|
1145
|
+
This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
|
1146
|
+
when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
|
1124
1147
|
|
1125
|
-
|
1126
|
-
var WorkqueueConfig = import_zod15.z.object({
|
1127
|
-
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1128
|
-
filters: import_zod15.z.array(
|
1129
|
-
import_zod15.z.object({
|
1130
|
-
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1131
|
-
})
|
1132
|
-
).describe("Filters to be applied to workqueue.")
|
1133
|
-
}).describe("Configuration for workqueue.");
|
1148
|
+
For example, a field config like { id: "child.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
|
1134
1149
|
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1150
|
+
A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
|
1151
|
+
|
1152
|
+
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)",
|
1153
|
+
which is ambiguous.
|
1154
|
+
|
1155
|
+
Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
|
1156
|
+
descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
|
1157
|
+
label would be "Applicant Applicant's First Name", which is redundant and awkward.
|
1158
|
+
|
1159
|
+
By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
|
1160
|
+
in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
|
1161
|
+
`
|
1162
|
+
),
|
1163
|
+
conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
|
1164
|
+
`
|
1165
|
+
In advanced search, we sometimes need to override the default field visibility conditionals.
|
1166
|
+
|
1167
|
+
For example, Informant fields in the declaration form may have conditional logic
|
1168
|
+
that hides them based on other field values. Since the advanced search form reuses
|
1169
|
+
the declaration form config, those same conditionals would apply by default.
|
1170
|
+
|
1171
|
+
However, in advanced search we often want to make all Informant fields searchable,
|
1172
|
+
regardless of their original visibility logic. To do this, we explicitly set their
|
1173
|
+
'conditionals' to an empty array ('[]') in the search config. This ensures they
|
1174
|
+
are always rendered in the advanced search form.
|
1175
|
+
`
|
1176
|
+
)
|
1177
|
+
});
|
1178
|
+
var SearchQueryParams = import_zod14.z.object({
|
1179
|
+
eventType: import_zod14.z.string().optional().describe(
|
1180
|
+
"Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
|
1181
|
+
)
|
1182
|
+
}).catchall(FieldValue);
|
1183
|
+
var FieldConfigSchema = BaseField3.extend({
|
1184
|
+
fieldId: import_zod14.z.string(),
|
1185
|
+
fieldType: import_zod14.z.literal("field")
|
1186
|
+
});
|
1187
|
+
var EventFieldId = import_zod14.z.enum([
|
1188
|
+
"trackingId",
|
1189
|
+
"status",
|
1190
|
+
"legalStatus.REGISTERED.createdAt",
|
1191
|
+
"legalStatus.REGISTERED.createdAtLocation",
|
1192
|
+
"updatedAt"
|
1193
|
+
]);
|
1194
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1195
|
+
fieldId: EventFieldId,
|
1196
|
+
fieldType: import_zod14.z.literal("event")
|
1197
|
+
});
|
1198
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1199
|
+
FieldConfigSchema,
|
1200
|
+
EventFieldConfigSchema
|
1201
|
+
]);
|
1202
|
+
var AdvancedSearchConfig = import_zod14.z.object({
|
1138
1203
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1139
|
-
fields:
|
1140
|
-
import_zod16.z.object({
|
1141
|
-
fieldId: import_zod16.z.string(),
|
1142
|
-
config: import_zod16.z.object({
|
1143
|
-
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1144
|
-
}).optional().describe("Configuration options for the field")
|
1145
|
-
})
|
1146
|
-
).optional().default([]).describe("Advanced search fields.")
|
1204
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1147
1205
|
});
|
1148
1206
|
|
1149
1207
|
// ../commons/src/events/utils.ts
|
1150
1208
|
var import_lodash = require("lodash");
|
1151
1209
|
|
1152
|
-
// ../commons/src/
|
1153
|
-
var
|
1210
|
+
// ../commons/src/events/ActionDocument.ts
|
1211
|
+
var import_zod16 = require("zod");
|
1212
|
+
var import_zod_openapi7 = require("zod-openapi");
|
1154
1213
|
|
1155
|
-
// ../commons/src/
|
1156
|
-
var
|
1157
|
-
var
|
1158
|
-
|
1159
|
-
label: TranslationConfig
|
1160
|
-
});
|
1161
|
-
var defaultColumns = {
|
1162
|
-
event: {
|
1163
|
-
id: "event",
|
1164
|
-
label: {
|
1165
|
-
defaultMessage: "Event",
|
1166
|
-
description: "This is the label for the workqueue column",
|
1167
|
-
id: "workqueue.default.column.event"
|
1168
|
-
}
|
1169
|
-
},
|
1170
|
-
status: {
|
1171
|
-
id: "status",
|
1172
|
-
label: {
|
1173
|
-
defaultMessage: "Status",
|
1174
|
-
description: "This is the label for the workqueue column",
|
1175
|
-
id: "workqueue.default.column.status"
|
1176
|
-
}
|
1177
|
-
},
|
1178
|
-
createdAt: {
|
1179
|
-
id: "createdAt",
|
1180
|
-
label: {
|
1181
|
-
defaultMessage: "Created",
|
1182
|
-
description: "This is the label for the workqueue column",
|
1183
|
-
id: "workqueue.default.column.createdAt"
|
1184
|
-
}
|
1185
|
-
},
|
1186
|
-
modifiedAt: {
|
1187
|
-
id: "modifiedAt",
|
1188
|
-
label: {
|
1189
|
-
defaultMessage: "Modified",
|
1190
|
-
description: "This is the label for the workqueue column",
|
1191
|
-
id: "workqueue.default.column.modifiedAt"
|
1192
|
-
}
|
1193
|
-
}
|
1194
|
-
};
|
1195
|
-
var DefaultColumnKeys = import_zod17.z.enum(
|
1196
|
-
Object.keys(defaultColumns)
|
1214
|
+
// ../commons/src/events/CreatedAtLocation.ts
|
1215
|
+
var import_zod15 = require("zod");
|
1216
|
+
var CreatedAtLocation = import_zod15.z.string().nullish().describe(
|
1217
|
+
"Location of the user who created the action. This is null for system users."
|
1197
1218
|
);
|
1198
1219
|
|
1199
|
-
// ../commons/src/
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
}
|
1225
|
-
],
|
1226
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1220
|
+
// ../commons/src/events/ActionDocument.ts
|
1221
|
+
(0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
|
1222
|
+
var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
|
1223
|
+
var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
|
1224
|
+
var ActionStatus = {
|
1225
|
+
Requested: "Requested",
|
1226
|
+
Accepted: "Accepted",
|
1227
|
+
Rejected: "Rejected"
|
1228
|
+
};
|
1229
|
+
var ActionBase = import_zod16.z.object({
|
1230
|
+
id: import_zod16.z.string(),
|
1231
|
+
transactionId: import_zod16.z.string(),
|
1232
|
+
createdAt: import_zod16.z.string().datetime(),
|
1233
|
+
createdBy: import_zod16.z.string(),
|
1234
|
+
createdByRole: import_zod16.z.string(),
|
1235
|
+
createdAtLocation: CreatedAtLocation,
|
1236
|
+
declaration: ActionUpdate,
|
1237
|
+
annotation: ActionUpdate.optional(),
|
1238
|
+
status: import_zod16.z.enum([
|
1239
|
+
ActionStatus.Requested,
|
1240
|
+
ActionStatus.Accepted,
|
1241
|
+
ActionStatus.Rejected
|
1242
|
+
]),
|
1243
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1244
|
+
originalActionId: import_zod16.z.string().optional()
|
1227
1245
|
});
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1246
|
+
var AssignedAction = ActionBase.merge(
|
1247
|
+
import_zod16.z.object({
|
1248
|
+
type: import_zod16.z.literal(ActionType.ASSIGN),
|
1249
|
+
assignedTo: import_zod16.z.string()
|
1250
|
+
})
|
1251
|
+
);
|
1252
|
+
var UnassignedAction = ActionBase.merge(
|
1253
|
+
import_zod16.z.object({
|
1254
|
+
type: import_zod16.z.literal(ActionType.UNASSIGN),
|
1255
|
+
assignedTo: import_zod16.z.literal(null)
|
1256
|
+
})
|
1257
|
+
);
|
1258
|
+
var RegisterAction = ActionBase.merge(
|
1259
|
+
import_zod16.z.object({
|
1260
|
+
type: import_zod16.z.literal(ActionType.REGISTER),
|
1261
|
+
registrationNumber: import_zod16.z.string().optional()
|
1262
|
+
})
|
1263
|
+
);
|
1264
|
+
var DeclareAction = ActionBase.merge(
|
1265
|
+
import_zod16.z.object({
|
1266
|
+
type: import_zod16.z.literal(ActionType.DECLARE)
|
1267
|
+
})
|
1268
|
+
);
|
1269
|
+
var ValidateAction = ActionBase.merge(
|
1270
|
+
import_zod16.z.object({
|
1271
|
+
type: import_zod16.z.literal(ActionType.VALIDATE)
|
1272
|
+
})
|
1273
|
+
);
|
1274
|
+
var RejectAction = ActionBase.merge(
|
1275
|
+
import_zod16.z.object({
|
1276
|
+
type: import_zod16.z.literal(ActionType.REJECT)
|
1277
|
+
})
|
1278
|
+
);
|
1279
|
+
var MarkAsDuplicateAction = ActionBase.merge(
|
1280
|
+
import_zod16.z.object({
|
1281
|
+
type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1282
|
+
})
|
1283
|
+
);
|
1284
|
+
var ArchiveAction = ActionBase.merge(
|
1285
|
+
import_zod16.z.object({
|
1286
|
+
type: import_zod16.z.literal(ActionType.ARCHIVE)
|
1287
|
+
})
|
1288
|
+
);
|
1289
|
+
var CreatedAction = ActionBase.merge(
|
1290
|
+
import_zod16.z.object({
|
1291
|
+
type: import_zod16.z.literal(ActionType.CREATE)
|
1292
|
+
})
|
1293
|
+
);
|
1294
|
+
var NotifiedAction = ActionBase.merge(
|
1295
|
+
import_zod16.z.object({
|
1296
|
+
type: import_zod16.z.literal(ActionType.NOTIFY)
|
1297
|
+
})
|
1298
|
+
);
|
1299
|
+
var PrintCertificateAction = ActionBase.merge(
|
1300
|
+
import_zod16.z.object({
|
1301
|
+
type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
|
1302
|
+
})
|
1303
|
+
);
|
1304
|
+
var RequestedCorrectionAction = ActionBase.merge(
|
1305
|
+
import_zod16.z.object({
|
1306
|
+
type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
|
1307
|
+
})
|
1308
|
+
);
|
1309
|
+
var ApprovedCorrectionAction = ActionBase.merge(
|
1310
|
+
import_zod16.z.object({
|
1311
|
+
type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
|
1312
|
+
requestId: import_zod16.z.string()
|
1313
|
+
})
|
1314
|
+
);
|
1315
|
+
var RejectedCorrectionAction = ActionBase.merge(
|
1316
|
+
import_zod16.z.object({
|
1317
|
+
type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
|
1318
|
+
requestId: import_zod16.z.string()
|
1319
|
+
})
|
1320
|
+
);
|
1321
|
+
var ReadAction = ActionBase.merge(
|
1322
|
+
import_zod16.z.object({
|
1323
|
+
type: import_zod16.z.literal(ActionType.READ)
|
1324
|
+
})
|
1325
|
+
);
|
1326
|
+
var ActionDocument = import_zod16.z.discriminatedUnion("type", [
|
1327
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1328
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1329
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1330
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1331
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1332
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1333
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1334
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1335
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1336
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1337
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1338
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1339
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1340
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1341
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1342
|
+
]).openapi({
|
1343
|
+
ref: "ActionDocument"
|
1248
1344
|
});
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1345
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1346
|
+
declaration: true,
|
1347
|
+
annotation: true
|
1348
|
+
}).merge(
|
1349
|
+
import_zod16.z.object({
|
1350
|
+
type: import_zod16.z.enum(ConfirmableActions),
|
1351
|
+
status: import_zod16.z.literal(ActionStatus.Rejected)
|
1352
|
+
})
|
1353
|
+
);
|
1354
|
+
var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1355
|
+
var ResolvedUser = import_zod16.z.object({
|
1356
|
+
id: import_zod16.z.string(),
|
1357
|
+
role: import_zod16.z.string(),
|
1358
|
+
name: import_zod16.z.array(
|
1359
|
+
import_zod16.z.object({
|
1360
|
+
use: import_zod16.z.string(),
|
1361
|
+
given: import_zod16.z.array(import_zod16.z.string()),
|
1362
|
+
family: import_zod16.z.string()
|
1363
|
+
})
|
1364
|
+
)
|
1269
1365
|
});
|
1270
1366
|
|
1271
|
-
// ../commons/src/workqueues/index.ts
|
1272
|
-
var workqueues = {
|
1273
|
-
all: allWorkqueue,
|
1274
|
-
registered: registeredWorkqueue,
|
1275
|
-
inReview: inReviewWorkqueue
|
1276
|
-
};
|
1277
|
-
|
1278
1367
|
// ../commons/src/conditionals/validate.ts
|
1279
1368
|
var import_ajv = __toESM(require("ajv"));
|
1280
1369
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1281
1370
|
var import_date_fns = require("date-fns");
|
1282
1371
|
|
1283
1372
|
// ../commons/src/events/FieldTypeMapping.ts
|
1284
|
-
var
|
1373
|
+
var import_zod17 = require("zod");
|
1285
1374
|
function mapFieldTypeToZod(type, required) {
|
1286
1375
|
let schema;
|
1287
1376
|
switch (type) {
|
@@ -1291,6 +1380,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1291
1380
|
case FieldType.EMAIL:
|
1292
1381
|
schema = EmailValue;
|
1293
1382
|
break;
|
1383
|
+
case FieldType.DATE_RANGE:
|
1384
|
+
schema = DateRangeFieldValue;
|
1385
|
+
break;
|
1294
1386
|
case FieldType.TEXT:
|
1295
1387
|
case FieldType.TEXTAREA:
|
1296
1388
|
case FieldType.DIVIDER:
|
@@ -1305,8 +1397,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1305
1397
|
case FieldType.FACILITY:
|
1306
1398
|
case FieldType.OFFICE:
|
1307
1399
|
case FieldType.SIGNATURE:
|
1308
|
-
|
1309
|
-
schema = required ? RequiredTextValue : TextValue;
|
1400
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1310
1401
|
break;
|
1311
1402
|
case FieldType.NUMBER:
|
1312
1403
|
schema = NumberFieldValue;
|
@@ -1334,7 +1425,7 @@ function createValidationSchema(config) {
|
|
1334
1425
|
for (const field2 of config) {
|
1335
1426
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1336
1427
|
}
|
1337
|
-
return
|
1428
|
+
return import_zod17.z.object(shape);
|
1338
1429
|
}
|
1339
1430
|
function mapFieldTypeToMockValue(field2, i) {
|
1340
1431
|
switch (field2.type) {
|
@@ -1372,6 +1463,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1372
1463
|
};
|
1373
1464
|
case FieldType.DATE:
|
1374
1465
|
return "2021-01-01";
|
1466
|
+
case FieldType.DATE_RANGE:
|
1467
|
+
return ["2021-01-01", "2021-01-02"];
|
1375
1468
|
case FieldType.CHECKBOX:
|
1376
1469
|
return true;
|
1377
1470
|
case FieldType.FILE:
|
@@ -1406,6 +1499,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1406
1499
|
case FieldType.EMAIL:
|
1407
1500
|
case FieldType.DATE:
|
1408
1501
|
case FieldType.CHECKBOX:
|
1502
|
+
case FieldType.DATE_RANGE:
|
1409
1503
|
case FieldType.DATA:
|
1410
1504
|
return null;
|
1411
1505
|
case FieldType.ADDRESS:
|
@@ -1438,6 +1532,9 @@ var isParagraphFieldType = (field2) => {
|
|
1438
1532
|
var isDateFieldType = (field2) => {
|
1439
1533
|
return field2.config.type === FieldType.DATE;
|
1440
1534
|
};
|
1535
|
+
var isDateRangeFieldType = (field2) => {
|
1536
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1537
|
+
};
|
1441
1538
|
var isPageHeaderFieldType = (field2) => {
|
1442
1539
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1443
1540
|
};
|
@@ -1508,12 +1605,23 @@ var ajv = new import_ajv.default({
|
|
1508
1605
|
function validate(schema, data) {
|
1509
1606
|
return ajv.validate(schema, data);
|
1510
1607
|
}
|
1608
|
+
function isConditionMet(conditional, values) {
|
1609
|
+
return validate(conditional, {
|
1610
|
+
$form: values,
|
1611
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1612
|
+
});
|
1613
|
+
}
|
1511
1614
|
function getConditionalActionsForField(field2, values) {
|
1512
1615
|
if (!field2.conditionals) {
|
1513
1616
|
return [];
|
1514
1617
|
}
|
1515
1618
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1516
1619
|
}
|
1620
|
+
function areConditionsMet(conditions, values) {
|
1621
|
+
return conditions.every(
|
1622
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1623
|
+
);
|
1624
|
+
}
|
1517
1625
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1518
1626
|
const hasRule = (field2.conditionals ?? []).some(
|
1519
1627
|
(conditional) => conditional.type === conditionalType
|
@@ -1532,6 +1640,10 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1532
1640
|
function isFieldVisible(field2, form) {
|
1533
1641
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1534
1642
|
}
|
1643
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1644
|
+
const fieldValue = form[field2.id];
|
1645
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1646
|
+
}
|
1535
1647
|
function isFieldEnabled(field2, form) {
|
1536
1648
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1537
1649
|
}
|
@@ -1632,28 +1744,19 @@ function validateFieldInput({
|
|
1632
1744
|
);
|
1633
1745
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1634
1746
|
}
|
1635
|
-
function
|
1747
|
+
function runFieldValidations({
|
1636
1748
|
field: field2,
|
1637
1749
|
values
|
1638
1750
|
}) {
|
1639
|
-
|
1640
|
-
$form: values,
|
1641
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1642
|
-
};
|
1643
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1644
|
-
if (values[field2.id]) {
|
1645
|
-
return {
|
1646
|
-
errors: [
|
1647
|
-
{
|
1648
|
-
message: errorMessages.hiddenField
|
1649
|
-
}
|
1650
|
-
]
|
1651
|
-
};
|
1652
|
-
}
|
1751
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1653
1752
|
return {
|
1654
1753
|
errors: []
|
1655
1754
|
};
|
1656
1755
|
}
|
1756
|
+
const conditionalParameters = {
|
1757
|
+
$form: values,
|
1758
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1759
|
+
};
|
1657
1760
|
const fieldValidationResult = validateFieldInput({
|
1658
1761
|
field: field2,
|
1659
1762
|
value: values[field2.id]
|
@@ -1674,9 +1777,6 @@ function getUUID() {
|
|
1674
1777
|
return (0, import_uuid.v4)();
|
1675
1778
|
}
|
1676
1779
|
|
1677
|
-
// ../commons/src/events/utils.ts
|
1678
|
-
var import_date_fns2 = require("date-fns");
|
1679
|
-
|
1680
1780
|
// ../commons/src/utils.ts
|
1681
1781
|
function getOrThrow(x, message) {
|
1682
1782
|
if (x === void 0 || x === null) {
|
@@ -1713,15 +1813,9 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1713
1813
|
}
|
1714
1814
|
return [];
|
1715
1815
|
};
|
1716
|
-
|
1816
|
+
function getAllAnnotationFields(config) {
|
1717
1817
|
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1718
|
-
}
|
1719
|
-
var findAllFields = (config) => {
|
1720
|
-
return (0, import_lodash.flattenDeep)([
|
1721
|
-
...getDeclarationFields(config),
|
1722
|
-
...getAllAnnotationFields(config)
|
1723
|
-
]);
|
1724
|
-
};
|
1818
|
+
}
|
1725
1819
|
var findRecordActionPages = (config, actionType) => {
|
1726
1820
|
const action = config.actions.find((a) => a.type === actionType);
|
1727
1821
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1744,48 +1838,28 @@ function getActionReview(configuration, actionType) {
|
|
1744
1838
|
function getActionReviewFields(configuration, actionType) {
|
1745
1839
|
return getActionReview(configuration, actionType).fields;
|
1746
1840
|
}
|
1747
|
-
function validateWorkqueueConfig(workqueueConfigs) {
|
1748
|
-
workqueueConfigs.map((workqueue) => {
|
1749
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1750
|
-
(wq) => wq.id === workqueue.id
|
1751
|
-
);
|
1752
|
-
if (!rootWorkqueue) {
|
1753
|
-
throw new Error(
|
1754
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1755
|
-
);
|
1756
|
-
}
|
1757
|
-
});
|
1758
|
-
}
|
1759
1841
|
function isPageVisible(page, formValues) {
|
1760
1842
|
if (!page.conditional) {
|
1761
1843
|
return true;
|
1762
1844
|
}
|
1763
|
-
return
|
1764
|
-
$form: formValues,
|
1765
|
-
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1766
|
-
});
|
1767
|
-
}
|
1768
|
-
var getVisiblePagesFormFields = (formConfig, formData) => {
|
1769
|
-
return formConfig.pages.filter((p) => isPageVisible(p, formData)).flatMap((p) => p.fields);
|
1770
|
-
};
|
1771
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1772
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1773
|
-
return false;
|
1774
|
-
}
|
1775
|
-
return !form[field2.id];
|
1845
|
+
return isConditionMet(page.conditional, formValues);
|
1776
1846
|
}
|
1777
|
-
function
|
1778
|
-
return (0, import_lodash.omitBy)(
|
1779
|
-
|
1780
|
-
|
1781
|
-
return true;
|
1847
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1848
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1849
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1850
|
+
return false;
|
1782
1851
|
}
|
1783
|
-
|
1852
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1853
|
+
if (!fieldConfigs.length) {
|
1784
1854
|
return true;
|
1785
1855
|
}
|
1786
|
-
return !isFieldVisible(
|
1856
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1787
1857
|
});
|
1788
1858
|
}
|
1859
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1860
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1861
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1862
|
+
}
|
1789
1863
|
function findActiveDrafts(event2, drafts) {
|
1790
1864
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1791
1865
|
const lastAction = actions[actions.length - 1];
|
@@ -1803,13 +1877,49 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1803
1877
|
annotation: {},
|
1804
1878
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1805
1879
|
createdBy: "@todo",
|
1806
|
-
createdAtLocation: "@todo"
|
1880
|
+
createdAtLocation: "@todo",
|
1881
|
+
status: ActionStatus.Accepted,
|
1882
|
+
transactionId: "@todo",
|
1883
|
+
createdByRole: "@todo"
|
1807
1884
|
}
|
1808
1885
|
};
|
1809
1886
|
}
|
1810
1887
|
function isVerificationPage(page) {
|
1811
1888
|
return page.type === PageTypes.enum.VERIFICATION;
|
1812
1889
|
}
|
1890
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1891
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1892
|
+
}
|
1893
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1894
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1895
|
+
return [
|
1896
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1897
|
+
...getVisibleVerificationPageIds(
|
1898
|
+
actionConfig.additionalDetailsForm,
|
1899
|
+
annotation
|
1900
|
+
)
|
1901
|
+
];
|
1902
|
+
}
|
1903
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1904
|
+
return getVisibleVerificationPageIds(
|
1905
|
+
actionConfig.printForm.pages,
|
1906
|
+
annotation
|
1907
|
+
);
|
1908
|
+
}
|
1909
|
+
return [];
|
1910
|
+
}
|
1911
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1912
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1913
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1914
|
+
actionConfig,
|
1915
|
+
annotation
|
1916
|
+
);
|
1917
|
+
return omitHiddenFields(
|
1918
|
+
annotationFields,
|
1919
|
+
{ ...declaration, ...annotation },
|
1920
|
+
visibleVerificationPageIds
|
1921
|
+
);
|
1922
|
+
}
|
1813
1923
|
function deepMerge(currentDocument, actionDocument) {
|
1814
1924
|
return (0, import_lodash.mergeWith)(
|
1815
1925
|
currentDocument,
|
@@ -1828,19 +1938,57 @@ function deepMerge(currentDocument, actionDocument) {
|
|
1828
1938
|
}
|
1829
1939
|
);
|
1830
1940
|
}
|
1941
|
+
function findLastAssignmentAction(actions) {
|
1942
|
+
return actions.filter(
|
1943
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1944
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1945
|
+
}
|
1946
|
+
function isWriteAction(actionType) {
|
1947
|
+
return writeActions.safeParse(actionType).success;
|
1948
|
+
}
|
1949
|
+
var findAllFields = (config) => {
|
1950
|
+
return (0, import_lodash.flattenDeep)([
|
1951
|
+
...getDeclarationFields(config),
|
1952
|
+
...getAllAnnotationFields(config)
|
1953
|
+
]);
|
1954
|
+
};
|
1955
|
+
function getMixedPath(obj, path, defaultValue) {
|
1956
|
+
const parts = path.split(".");
|
1957
|
+
const resolve = (current, segments) => {
|
1958
|
+
if (current == null || segments.length === 0) {
|
1959
|
+
return current;
|
1960
|
+
}
|
1961
|
+
for (let i = segments.length; i > 0; i--) {
|
1962
|
+
const compoundKey = segments.slice(0, i).join(".");
|
1963
|
+
if ((0, import_lodash.has)(current, compoundKey)) {
|
1964
|
+
const next = (0, import_lodash.get)(current, compoundKey);
|
1965
|
+
return resolve(next, segments.slice(i));
|
1966
|
+
}
|
1967
|
+
}
|
1968
|
+
return void 0;
|
1969
|
+
};
|
1970
|
+
const result = resolve(obj, parts);
|
1971
|
+
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
1972
|
+
}
|
1831
1973
|
|
1832
1974
|
// ../commons/src/events/EventConfig.ts
|
1833
|
-
var
|
1834
|
-
|
1975
|
+
var import_zod_openapi8 = require("zod-openapi");
|
1976
|
+
(0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
|
1977
|
+
var EventConfig = import_zod18.z.object({
|
1978
|
+
id: import_zod18.z.string().describe(
|
1835
1979
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1836
1980
|
),
|
1981
|
+
dateOfEvent: import_zod18.z.object({ fieldId: import_zod18.z.string() }).optional(),
|
1982
|
+
title: TranslationConfig,
|
1983
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1984
|
+
"This is a fallback title if actual title resolves to empty string"
|
1985
|
+
),
|
1837
1986
|
summary: SummaryConfig,
|
1838
1987
|
label: TranslationConfig,
|
1839
|
-
actions:
|
1988
|
+
actions: import_zod18.z.array(ActionConfig),
|
1840
1989
|
declaration: DeclarationFormConfig,
|
1841
|
-
|
1842
|
-
|
1843
|
-
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1990
|
+
deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
|
1991
|
+
advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
|
1844
1992
|
}).superRefine((event2, ctx) => {
|
1845
1993
|
const allFields = findAllFields(event2);
|
1846
1994
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1856,16 +2004,43 @@ var EventConfig = import_zod20.z.object({
|
|
1856
2004
|
});
|
1857
2005
|
}
|
1858
2006
|
const invalidFields = event2.advancedSearch.flatMap(
|
1859
|
-
(section) =>
|
2007
|
+
(section) => (
|
2008
|
+
// Check if the fieldId is not in the fieldIds array
|
2009
|
+
// and also not in the metadataFields array
|
2010
|
+
section.fields.filter(
|
2011
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
2012
|
+
)
|
2013
|
+
)
|
1860
2014
|
);
|
1861
2015
|
if (invalidFields.length > 0) {
|
1862
2016
|
ctx.addIssue({
|
1863
2017
|
code: "custom",
|
1864
|
-
message: `Advanced search id must match a field id
|
2018
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1865
2019
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1866
2020
|
path: ["advancedSearch"]
|
1867
2021
|
});
|
1868
2022
|
}
|
2023
|
+
if (event2.dateOfEvent) {
|
2024
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
2025
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
2026
|
+
);
|
2027
|
+
if (!eventDateFieldId) {
|
2028
|
+
ctx.addIssue({
|
2029
|
+
code: "custom",
|
2030
|
+
message: `Date of event field id must match a field id in fields array.
|
2031
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
2032
|
+
path: ["dateOfEvent"]
|
2033
|
+
});
|
2034
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
2035
|
+
ctx.addIssue({
|
2036
|
+
code: "custom",
|
2037
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
2038
|
+
path: ["dateOfEvent.fieldType"]
|
2039
|
+
});
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
}).openapi({
|
2043
|
+
ref: "EventConfig"
|
1869
2044
|
});
|
1870
2045
|
|
1871
2046
|
// ../commons/src/events/EventConfigInput.ts
|
@@ -1874,496 +2049,242 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
|
1874
2049
|
var definePage = (page) => PageConfig.parse(page);
|
1875
2050
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1876
2051
|
|
1877
|
-
// ../commons/src/events/
|
1878
|
-
var import_zod23 = require("zod");
|
1879
|
-
|
1880
|
-
// ../commons/src/events/ActionDocument.ts
|
2052
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1881
2053
|
var import_zod21 = require("zod");
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
2054
|
+
|
2055
|
+
// ../commons/src/events/EventIndex.ts
|
2056
|
+
var import_zod20 = require("zod");
|
2057
|
+
|
2058
|
+
// ../commons/src/events/EventMetadata.ts
|
2059
|
+
var import_zod19 = require("zod");
|
2060
|
+
var EventStatus = {
|
2061
|
+
CREATED: "CREATED",
|
2062
|
+
NOTIFIED: "NOTIFIED",
|
2063
|
+
DECLARED: "DECLARED",
|
2064
|
+
VALIDATED: "VALIDATED",
|
2065
|
+
REGISTERED: "REGISTERED",
|
2066
|
+
CERTIFIED: "CERTIFIED",
|
2067
|
+
REJECTED: "REJECTED",
|
2068
|
+
ARCHIVED: "ARCHIVED"
|
1887
2069
|
};
|
1888
|
-
var
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
2070
|
+
var eventStatusValues = [
|
2071
|
+
EventStatus.CREATED,
|
2072
|
+
EventStatus.NOTIFIED,
|
2073
|
+
EventStatus.DECLARED,
|
2074
|
+
EventStatus.VALIDATED,
|
2075
|
+
EventStatus.REGISTERED,
|
2076
|
+
EventStatus.CERTIFIED,
|
2077
|
+
EventStatus.REJECTED,
|
2078
|
+
EventStatus.ARCHIVED
|
2079
|
+
];
|
2080
|
+
var EventStatusEnum = import_zod19.z.enum(eventStatusValues);
|
2081
|
+
var CustomFlags = {
|
2082
|
+
CERTIFICATE_PRINTED: "certificate-printed"
|
2083
|
+
};
|
2084
|
+
var Flag = import_zod19.z.string().regex(
|
2085
|
+
new RegExp(
|
2086
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
|
2087
|
+
),
|
2088
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2089
|
+
).or(import_zod19.z.nativeEnum(CustomFlags));
|
2090
|
+
var eventStatuses = Object.values(EventStatus);
|
2091
|
+
var EventStatuses = import_zod19.z.nativeEnum(EventStatus);
|
2092
|
+
var ZodDate = import_zod19.z.string().date();
|
2093
|
+
var ActionCreationMetadata = import_zod19.z.object({
|
2094
|
+
createdAt: import_zod19.z.string().datetime().describe("The timestamp when the action request was created."),
|
2095
|
+
createdBy: import_zod19.z.string().describe("ID of the user who created the action request."),
|
2096
|
+
createdAtLocation: CreatedAtLocation,
|
2097
|
+
acceptedAt: import_zod19.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
2098
|
+
createdByRole: import_zod19.z.string().describe("Role of the user at the time of action request creation.")
|
1902
2099
|
});
|
1903
|
-
var
|
1904
|
-
|
1905
|
-
|
1906
|
-
assignedTo: import_zod21.z.string()
|
1907
|
-
})
|
1908
|
-
);
|
1909
|
-
var UnassignedAction = ActionBase.merge(
|
1910
|
-
import_zod21.z.object({
|
1911
|
-
type: import_zod21.z.literal(ActionType.UNASSIGN)
|
1912
|
-
})
|
1913
|
-
);
|
1914
|
-
var RegisterAction = ActionBase.merge(
|
1915
|
-
import_zod21.z.object({
|
1916
|
-
type: import_zod21.z.literal(ActionType.REGISTER),
|
1917
|
-
registrationNumber: import_zod21.z.string().optional()
|
1918
|
-
})
|
1919
|
-
);
|
1920
|
-
var DeclareAction = ActionBase.merge(
|
1921
|
-
import_zod21.z.object({
|
1922
|
-
type: import_zod21.z.literal(ActionType.DECLARE)
|
1923
|
-
})
|
1924
|
-
);
|
1925
|
-
var ValidateAction = ActionBase.merge(
|
1926
|
-
import_zod21.z.object({
|
1927
|
-
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1928
|
-
})
|
1929
|
-
);
|
1930
|
-
var RejectAction = ActionBase.merge(
|
1931
|
-
import_zod21.z.object({
|
1932
|
-
type: import_zod21.z.literal(ActionType.REJECT)
|
1933
|
-
})
|
1934
|
-
);
|
1935
|
-
var MarkAsDuplicateAction = ActionBase.merge(
|
1936
|
-
import_zod21.z.object({
|
1937
|
-
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1938
|
-
})
|
1939
|
-
);
|
1940
|
-
var ArchiveAction = ActionBase.merge(
|
1941
|
-
import_zod21.z.object({
|
1942
|
-
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1943
|
-
})
|
1944
|
-
);
|
1945
|
-
var CreatedAction = ActionBase.merge(
|
1946
|
-
import_zod21.z.object({
|
1947
|
-
type: import_zod21.z.literal(ActionType.CREATE)
|
1948
|
-
})
|
1949
|
-
);
|
1950
|
-
var NotifiedAction = ActionBase.merge(
|
1951
|
-
import_zod21.z.object({
|
1952
|
-
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1953
|
-
})
|
1954
|
-
);
|
1955
|
-
var PrintCertificateAction = ActionBase.merge(
|
1956
|
-
import_zod21.z.object({
|
1957
|
-
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1958
|
-
})
|
1959
|
-
);
|
1960
|
-
var RequestedCorrectionAction = ActionBase.merge(
|
1961
|
-
import_zod21.z.object({
|
1962
|
-
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1963
|
-
})
|
1964
|
-
);
|
1965
|
-
var ApprovedCorrectionAction = ActionBase.merge(
|
1966
|
-
import_zod21.z.object({
|
1967
|
-
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1968
|
-
requestId: import_zod21.z.string()
|
1969
|
-
})
|
1970
|
-
);
|
1971
|
-
var RejectedCorrectionAction = ActionBase.merge(
|
1972
|
-
import_zod21.z.object({
|
1973
|
-
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1974
|
-
requestId: import_zod21.z.string()
|
1975
|
-
})
|
1976
|
-
);
|
1977
|
-
var ReadAction = ActionBase.merge(
|
1978
|
-
import_zod21.z.object({
|
1979
|
-
type: import_zod21.z.literal(ActionType.READ)
|
1980
|
-
})
|
1981
|
-
);
|
1982
|
-
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1983
|
-
CreatedAction,
|
1984
|
-
ValidateAction,
|
1985
|
-
RejectAction,
|
1986
|
-
MarkAsDuplicateAction,
|
1987
|
-
ArchiveAction,
|
1988
|
-
NotifiedAction,
|
1989
|
-
RegisterAction,
|
1990
|
-
DeclareAction,
|
1991
|
-
AssignedAction,
|
1992
|
-
RequestedCorrectionAction,
|
1993
|
-
ApprovedCorrectionAction,
|
1994
|
-
RejectedCorrectionAction,
|
1995
|
-
UnassignedAction,
|
1996
|
-
PrintCertificateAction,
|
1997
|
-
ReadAction
|
1998
|
-
]);
|
1999
|
-
var AsyncRejectActionDocument = ActionBase.omit({
|
2000
|
-
declaration: true,
|
2001
|
-
annotation: true,
|
2002
|
-
createdBy: true,
|
2003
|
-
createdAtLocation: true
|
2004
|
-
}).merge(
|
2005
|
-
import_zod21.z.object({
|
2006
|
-
type: import_zod21.z.enum(ConfirmableActions),
|
2007
|
-
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2008
|
-
})
|
2009
|
-
);
|
2010
|
-
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2011
|
-
var ResolvedUser = import_zod21.z.object({
|
2012
|
-
id: import_zod21.z.string(),
|
2013
|
-
role: import_zod21.z.string(),
|
2014
|
-
name: import_zod21.z.array(
|
2015
|
-
import_zod21.z.object({
|
2016
|
-
use: import_zod21.z.string(),
|
2017
|
-
given: import_zod21.z.array(import_zod21.z.string()),
|
2018
|
-
family: import_zod21.z.string()
|
2019
|
-
})
|
2100
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2101
|
+
registrationNumber: import_zod19.z.string().describe(
|
2102
|
+
"Registration number of the event. Always present for accepted registrations."
|
2020
2103
|
)
|
2021
2104
|
});
|
2105
|
+
var LegalStatuses = import_zod19.z.object({
|
2106
|
+
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2107
|
+
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2108
|
+
});
|
2109
|
+
var EventMetadata = import_zod19.z.object({
|
2110
|
+
id: import_zod19.z.string(),
|
2111
|
+
type: import_zod19.z.string().describe("The type of event, such as birth, death, or marriage."),
|
2112
|
+
status: EventStatuses,
|
2113
|
+
legalStatuses: LegalStatuses.describe(
|
2114
|
+
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2115
|
+
),
|
2116
|
+
createdAt: import_zod19.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2117
|
+
dateOfEvent: ZodDate.nullish(),
|
2118
|
+
createdBy: import_zod19.z.string().describe("ID of the user who created the event."),
|
2119
|
+
updatedByUserRole: import_zod19.z.string().describe("Role of the user who last updated the declaration."),
|
2120
|
+
createdAtLocation: CreatedAtLocation,
|
2121
|
+
updatedAtLocation: import_zod19.z.string().nullish().describe("Location of the user who last updated the declaration."),
|
2122
|
+
updatedAt: import_zod19.z.string().datetime().describe("Timestamp of the most recent declaration update."),
|
2123
|
+
assignedTo: import_zod19.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
2124
|
+
updatedBy: import_zod19.z.string().nullish().describe("ID of the user who last updated the declaration."),
|
2125
|
+
trackingId: import_zod19.z.string().describe(
|
2126
|
+
"System-generated tracking ID used by informants or registrars to look up the event."
|
2127
|
+
),
|
2128
|
+
flags: import_zod19.z.array(Flag)
|
2129
|
+
});
|
2130
|
+
var EventMetadataKeys = import_zod19.z.enum([
|
2131
|
+
"id",
|
2132
|
+
"type",
|
2133
|
+
"status",
|
2134
|
+
"createdAt",
|
2135
|
+
"dateOfEvent",
|
2136
|
+
"createdBy",
|
2137
|
+
"updatedByUserRole",
|
2138
|
+
"createdAtLocation",
|
2139
|
+
"updatedAtLocation",
|
2140
|
+
"updatedAt",
|
2141
|
+
"assignedTo",
|
2142
|
+
"updatedBy",
|
2143
|
+
"trackingId",
|
2144
|
+
"legalStatuses",
|
2145
|
+
"flags"
|
2146
|
+
]);
|
2147
|
+
var EventMetadataParameter = import_zod19.z.object({
|
2148
|
+
// @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
|
2149
|
+
$event: EventMetadataKeys
|
2150
|
+
});
|
2151
|
+
var eventMetadataLabelMap = {
|
2152
|
+
"event.assignedTo": {
|
2153
|
+
id: "event.assignedTo.label",
|
2154
|
+
defaultMessage: "Assigned To",
|
2155
|
+
description: "Assigned To"
|
2156
|
+
},
|
2157
|
+
"event.createdAt": {
|
2158
|
+
id: "event.createdAt.label",
|
2159
|
+
defaultMessage: "Created",
|
2160
|
+
description: "Created At"
|
2161
|
+
},
|
2162
|
+
"event.dateOfEvent": {
|
2163
|
+
id: "event.dateOfEvent.label",
|
2164
|
+
defaultMessage: "Date of Event",
|
2165
|
+
description: "Date of Event"
|
2166
|
+
},
|
2167
|
+
"event.createdAtLocation": {
|
2168
|
+
id: "event.createdAtLocation.label",
|
2169
|
+
defaultMessage: "Location",
|
2170
|
+
description: "Created At Location"
|
2171
|
+
},
|
2172
|
+
"event.updatedAtLocation": {
|
2173
|
+
id: "event.updatedAtLocation.label",
|
2174
|
+
defaultMessage: "Location",
|
2175
|
+
description: "Updated At Location"
|
2176
|
+
},
|
2177
|
+
"event.createdBy": {
|
2178
|
+
id: "event.createdBy.label",
|
2179
|
+
defaultMessage: "Created By",
|
2180
|
+
description: "Created By"
|
2181
|
+
},
|
2182
|
+
"event.updatedByUserRole": {
|
2183
|
+
id: "event.updatedByUserRole.label",
|
2184
|
+
defaultMessage: "Updated By Role",
|
2185
|
+
description: "Updated By Role"
|
2186
|
+
},
|
2187
|
+
"event.id": {
|
2188
|
+
id: "event.id.label",
|
2189
|
+
defaultMessage: "ID",
|
2190
|
+
description: "ID"
|
2191
|
+
},
|
2192
|
+
"event.updatedAt": {
|
2193
|
+
id: "event.modifiedAt.label",
|
2194
|
+
defaultMessage: "Updated",
|
2195
|
+
description: "Modified At"
|
2196
|
+
},
|
2197
|
+
"event.status": {
|
2198
|
+
id: "event.status.label",
|
2199
|
+
defaultMessage: "Status",
|
2200
|
+
description: "Status"
|
2201
|
+
},
|
2202
|
+
"event.type": {
|
2203
|
+
id: "event.type.label",
|
2204
|
+
defaultMessage: "Type",
|
2205
|
+
description: "Type"
|
2206
|
+
},
|
2207
|
+
"event.updatedBy": {
|
2208
|
+
id: "event.updatedBy.label",
|
2209
|
+
defaultMessage: "Updated By",
|
2210
|
+
description: "Updated By"
|
2211
|
+
},
|
2212
|
+
"event.trackingId": {
|
2213
|
+
id: "event.trackingId.label",
|
2214
|
+
defaultMessage: "Tracking ID",
|
2215
|
+
description: "Tracking ID"
|
2216
|
+
},
|
2217
|
+
"event.flags": {
|
2218
|
+
id: "event.flags.label",
|
2219
|
+
defaultMessage: "Flags",
|
2220
|
+
description: "Flags"
|
2221
|
+
}
|
2222
|
+
};
|
2022
2223
|
|
2023
|
-
// ../commons/src/events/
|
2024
|
-
var
|
2025
|
-
|
2026
|
-
eventId: import_zod22.z.string(),
|
2027
|
-
transactionId: import_zod22.z.string(),
|
2028
|
-
declaration: ActionUpdate.default({}),
|
2029
|
-
annotation: ActionUpdate.optional(),
|
2030
|
-
originalActionId: import_zod22.z.string().optional()
|
2224
|
+
// ../commons/src/events/EventIndex.ts
|
2225
|
+
var EventIndex = EventMetadata.extend({
|
2226
|
+
declaration: EventState
|
2031
2227
|
});
|
2032
|
-
var
|
2033
|
-
|
2034
|
-
type:
|
2035
|
-
|
2036
|
-
})
|
2037
|
-
);
|
2038
|
-
var RegisterActionInput = BaseActionInput.merge(
|
2039
|
-
import_zod22.z.object({
|
2040
|
-
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2041
|
-
registrationNumber: import_zod22.z.string().optional()
|
2042
|
-
})
|
2043
|
-
);
|
2044
|
-
var ValidateActionInput = BaseActionInput.merge(
|
2045
|
-
import_zod22.z.object({
|
2046
|
-
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2047
|
-
duplicates: import_zod22.z.array(import_zod22.z.string())
|
2048
|
-
})
|
2049
|
-
);
|
2050
|
-
var NotifyActionInput = BaseActionInput.merge(
|
2051
|
-
import_zod22.z.object({
|
2052
|
-
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2053
|
-
})
|
2054
|
-
);
|
2055
|
-
var DeclareActionInput = BaseActionInput.merge(
|
2056
|
-
import_zod22.z.object({
|
2057
|
-
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2228
|
+
var EventSearchIndex = import_zod20.z.record(import_zod20.z.string(), import_zod20.z.any()).and(
|
2229
|
+
import_zod20.z.object({
|
2230
|
+
type: import_zod20.z.string()
|
2231
|
+
// Ensures "type" (event-id) exists and is a string
|
2058
2232
|
})
|
2059
2233
|
);
|
2060
|
-
var
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2234
|
+
var Fuzzy = import_zod20.z.object({ type: import_zod20.z.literal("fuzzy"), term: import_zod20.z.string() });
|
2235
|
+
var Exact = import_zod20.z.object({ type: import_zod20.z.literal("exact"), term: import_zod20.z.string() });
|
2236
|
+
var AnyOf = import_zod20.z.object({
|
2237
|
+
type: import_zod20.z.literal("anyOf"),
|
2238
|
+
terms: import_zod20.z.array(import_zod20.z.string())
|
2239
|
+
});
|
2240
|
+
var ExactStatus = import_zod20.z.object({
|
2241
|
+
type: import_zod20.z.literal("exact"),
|
2242
|
+
term: EventStatusEnum
|
2243
|
+
});
|
2244
|
+
var AnyOfStatus = import_zod20.z.object({
|
2245
|
+
type: import_zod20.z.literal("anyOf"),
|
2246
|
+
terms: import_zod20.z.array(EventStatusEnum)
|
2247
|
+
});
|
2248
|
+
var Range = import_zod20.z.object({
|
2249
|
+
type: import_zod20.z.literal("range"),
|
2250
|
+
gte: import_zod20.z.string(),
|
2251
|
+
lte: import_zod20.z.string()
|
2252
|
+
});
|
2253
|
+
var Not = import_zod20.z.object({ type: import_zod20.z.literal("not"), term: import_zod20.z.string() });
|
2254
|
+
var Within = import_zod20.z.object({ type: import_zod20.z.literal("within"), location: import_zod20.z.string() });
|
2255
|
+
var DateCondition = import_zod20.z.union([Exact, Range]);
|
2256
|
+
var QueryInput = import_zod20.z.lazy(
|
2257
|
+
() => import_zod20.z.union([
|
2258
|
+
import_zod20.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
2259
|
+
import_zod20.z.record(import_zod20.z.string(), QueryInput)
|
2260
|
+
])
|
2064
2261
|
);
|
2065
|
-
var
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
)
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
)
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
)
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
);
|
2086
|
-
var UnassignActionInput = BaseActionInput.merge(
|
2087
|
-
import_zod22.z.object({
|
2088
|
-
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2089
|
-
assignedTo: import_zod22.z.literal(null).default(null)
|
2090
|
-
})
|
2091
|
-
);
|
2092
|
-
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2093
|
-
import_zod22.z.object({
|
2094
|
-
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2095
|
-
})
|
2096
|
-
);
|
2097
|
-
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2098
|
-
import_zod22.z.object({
|
2099
|
-
requestId: import_zod22.z.string(),
|
2100
|
-
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2101
|
-
})
|
2102
|
-
);
|
2103
|
-
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2104
|
-
import_zod22.z.object({
|
2105
|
-
requestId: import_zod22.z.string(),
|
2106
|
-
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2107
|
-
})
|
2108
|
-
);
|
2109
|
-
var ReadActionInput = BaseActionInput.merge(
|
2110
|
-
import_zod22.z.object({
|
2111
|
-
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2112
|
-
})
|
2113
|
-
);
|
2114
|
-
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2115
|
-
CreateActionInput,
|
2116
|
-
ValidateActionInput,
|
2117
|
-
RegisterActionInput,
|
2118
|
-
NotifyActionInput,
|
2119
|
-
DeclareActionInput,
|
2120
|
-
RejectDeclarationActionInput,
|
2121
|
-
MarkedAsDuplicateActionInput,
|
2122
|
-
ArchiveActionInput,
|
2123
|
-
AssignActionInput,
|
2124
|
-
UnassignActionInput,
|
2125
|
-
PrintCertificateActionInput,
|
2126
|
-
RequestCorrectionActionInput,
|
2127
|
-
RejectCorrectionActionInput,
|
2128
|
-
ApproveCorrectionActionInput,
|
2129
|
-
ReadActionInput
|
2130
|
-
]);
|
2131
|
-
|
2132
|
-
// ../commons/src/events/Draft.ts
|
2133
|
-
var Draft = import_zod23.z.object({
|
2134
|
-
id: import_zod23.z.string(),
|
2135
|
-
eventId: import_zod23.z.string(),
|
2136
|
-
transactionId: import_zod23.z.string(),
|
2137
|
-
createdAt: import_zod23.z.string().datetime(),
|
2138
|
-
action: ActionBase.extend({
|
2139
|
-
type: ActionTypes
|
2140
|
-
}).omit({ id: true })
|
2141
|
-
});
|
2142
|
-
var DraftInput = BaseActionInput.extend({
|
2143
|
-
type: ActionTypes
|
2144
|
-
});
|
2145
|
-
|
2146
|
-
// ../commons/src/events/EventInput.ts
|
2147
|
-
var import_zod24 = require("zod");
|
2148
|
-
var EventInput = import_zod24.z.object({
|
2149
|
-
transactionId: import_zod24.z.string(),
|
2150
|
-
type: import_zod24.z.string()
|
2151
|
-
});
|
2152
|
-
|
2153
|
-
// ../commons/src/events/EventDocument.ts
|
2154
|
-
var import_zod25 = require("zod");
|
2155
|
-
var EventDocument = import_zod25.z.object({
|
2156
|
-
id: import_zod25.z.string(),
|
2157
|
-
type: import_zod25.z.string(),
|
2158
|
-
createdAt: import_zod25.z.string().datetime(),
|
2159
|
-
updatedAt: import_zod25.z.string().datetime(),
|
2160
|
-
actions: import_zod25.z.array(Action),
|
2161
|
-
trackingId: import_zod25.z.string()
|
2262
|
+
var QueryExpression = import_zod20.z.object({
|
2263
|
+
eventType: import_zod20.z.string(),
|
2264
|
+
status: import_zod20.z.optional(import_zod20.z.union([AnyOfStatus, ExactStatus])),
|
2265
|
+
createdAt: import_zod20.z.optional(DateCondition),
|
2266
|
+
updatedAt: import_zod20.z.optional(DateCondition),
|
2267
|
+
"legalStatus.REGISTERED.createdAt": import_zod20.z.optional(DateCondition),
|
2268
|
+
"legalStatus.REGISTERED.createdAtLocation": import_zod20.z.optional(
|
2269
|
+
import_zod20.z.union([Within, Exact])
|
2270
|
+
),
|
2271
|
+
createAtLocation: import_zod20.z.optional(import_zod20.z.union([Within, Exact])),
|
2272
|
+
updatedAtLocation: import_zod20.z.optional(import_zod20.z.union([Within, Exact])),
|
2273
|
+
createdBy: import_zod20.z.optional(Exact),
|
2274
|
+
updatedBy: import_zod20.z.optional(Exact),
|
2275
|
+
trackingId: import_zod20.z.optional(Exact),
|
2276
|
+
flags: import_zod20.z.optional(import_zod20.z.array(import_zod20.z.union([AnyOf, Not]))),
|
2277
|
+
data: QueryInput
|
2278
|
+
}).partial();
|
2279
|
+
var Or2 = import_zod20.z.object({
|
2280
|
+
type: import_zod20.z.literal("or"),
|
2281
|
+
clauses: import_zod20.z.array(QueryExpression)
|
2162
2282
|
});
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
var EventIndex = EventMetadata.extend({
|
2167
|
-
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2283
|
+
var And2 = import_zod20.z.object({
|
2284
|
+
type: import_zod20.z.literal("and"),
|
2285
|
+
clauses: import_zod20.z.array(QueryExpression)
|
2168
2286
|
});
|
2169
|
-
var
|
2170
|
-
import_zod26.z.object({
|
2171
|
-
type: import_zod26.z.string()
|
2172
|
-
// Ensures "type" (event-id) exists and is a string
|
2173
|
-
})
|
2174
|
-
);
|
2175
|
-
|
2176
|
-
// ../commons/src/events/state/index.ts
|
2177
|
-
function getStatusFromActions(actions) {
|
2178
|
-
const hasRejectedAction = actions.some(
|
2179
|
-
(a) => a.status === ActionStatus.Rejected
|
2180
|
-
);
|
2181
|
-
if (hasRejectedAction) {
|
2182
|
-
return EventStatus.REJECTED;
|
2183
|
-
}
|
2184
|
-
return actions.reduce((status, action) => {
|
2185
|
-
if (action.type === ActionType.CREATE) {
|
2186
|
-
return EventStatus.CREATED;
|
2187
|
-
}
|
2188
|
-
if (action.type === ActionType.DECLARE) {
|
2189
|
-
return EventStatus.DECLARED;
|
2190
|
-
}
|
2191
|
-
if (action.type === ActionType.VALIDATE) {
|
2192
|
-
return EventStatus.VALIDATED;
|
2193
|
-
}
|
2194
|
-
if (action.type === ActionType.REGISTER) {
|
2195
|
-
return EventStatus.REGISTERED;
|
2196
|
-
}
|
2197
|
-
if (action.type === ActionType.REJECT) {
|
2198
|
-
return EventStatus.REJECTED;
|
2199
|
-
}
|
2200
|
-
if (action.type === ActionType.ARCHIVE) {
|
2201
|
-
return EventStatus.ARCHIVED;
|
2202
|
-
}
|
2203
|
-
if (action.type === ActionType.NOTIFY) {
|
2204
|
-
return EventStatus.NOTIFIED;
|
2205
|
-
}
|
2206
|
-
return status;
|
2207
|
-
}, EventStatus.CREATED);
|
2208
|
-
}
|
2209
|
-
function getAssignedUserFromActions(actions) {
|
2210
|
-
return actions.reduce((user2, action) => {
|
2211
|
-
if (action.type === ActionType.ASSIGN) {
|
2212
|
-
return action.assignedTo;
|
2213
|
-
}
|
2214
|
-
if (action.type === ActionType.UNASSIGN) {
|
2215
|
-
return null;
|
2216
|
-
}
|
2217
|
-
return user2;
|
2218
|
-
}, null);
|
2219
|
-
}
|
2220
|
-
function aggregateActionDeclarations(actions) {
|
2221
|
-
const excludedActions = [
|
2222
|
-
ActionType.REQUEST_CORRECTION,
|
2223
|
-
ActionType.PRINT_CERTIFICATE
|
2224
|
-
];
|
2225
|
-
return actions.reduce((status, action) => {
|
2226
|
-
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2227
|
-
return status;
|
2228
|
-
}
|
2229
|
-
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2230
|
-
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2231
|
-
if (!requestAction) {
|
2232
|
-
return status;
|
2233
|
-
}
|
2234
|
-
return deepMerge(status, requestAction.declaration);
|
2235
|
-
}
|
2236
|
-
return deepMerge(status, action.declaration);
|
2237
|
-
}, {});
|
2238
|
-
}
|
2239
|
-
function deepDropNulls(obj) {
|
2240
|
-
if (Array.isArray(obj)) {
|
2241
|
-
return obj;
|
2242
|
-
}
|
2243
|
-
if (obj !== null && typeof obj === "object") {
|
2244
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2245
|
-
const cleanedValue = deepDropNulls(value);
|
2246
|
-
if (cleanedValue !== null) {
|
2247
|
-
;
|
2248
|
-
acc[key] = cleanedValue;
|
2249
|
-
}
|
2250
|
-
return acc;
|
2251
|
-
}, {});
|
2252
|
-
}
|
2253
|
-
return obj;
|
2254
|
-
}
|
2255
|
-
function isUndeclaredDraft(status) {
|
2256
|
-
return status === EventStatus.CREATED;
|
2257
|
-
}
|
2258
|
-
function getAcceptedActions(event2) {
|
2259
|
-
return event2.actions.filter(
|
2260
|
-
(a) => a.status === ActionStatus.Accepted
|
2261
|
-
);
|
2262
|
-
}
|
2263
|
-
function getCurrentEventState(event2) {
|
2264
|
-
const creationAction = event2.actions.find(
|
2265
|
-
(action) => action.type === ActionType.CREATE
|
2266
|
-
);
|
2267
|
-
if (!creationAction) {
|
2268
|
-
throw new Error(`Event ${event2.id} has no creation action`);
|
2269
|
-
}
|
2270
|
-
const activeActions = getAcceptedActions(event2);
|
2271
|
-
const latestAction = activeActions[activeActions.length - 1];
|
2272
|
-
const registrationAction = activeActions.find(
|
2273
|
-
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2274
|
-
);
|
2275
|
-
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2276
|
-
return deepDropNulls({
|
2277
|
-
id: event2.id,
|
2278
|
-
type: event2.type,
|
2279
|
-
status: getStatusFromActions(event2.actions),
|
2280
|
-
createdAt: event2.createdAt,
|
2281
|
-
createdBy: creationAction.createdBy,
|
2282
|
-
createdAtLocation: creationAction.createdAtLocation,
|
2283
|
-
modifiedAt: latestAction.createdAt,
|
2284
|
-
assignedTo: getAssignedUserFromActions(activeActions),
|
2285
|
-
updatedBy: latestAction.createdBy,
|
2286
|
-
declaration: aggregateActionDeclarations(activeActions),
|
2287
|
-
trackingId: event2.trackingId,
|
2288
|
-
registrationNumber
|
2289
|
-
});
|
2290
|
-
}
|
2291
|
-
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2292
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2293
|
-
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2294
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2295
|
-
return [
|
2296
|
-
action,
|
2297
|
-
{
|
2298
|
-
...action,
|
2299
|
-
type: ActionType.APPROVE_CORRECTION
|
2300
|
-
}
|
2301
|
-
];
|
2302
|
-
}
|
2303
|
-
return [action];
|
2304
|
-
});
|
2305
|
-
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2306
|
-
const withDrafts = {
|
2307
|
-
...event2,
|
2308
|
-
actions: actionWithDrafts
|
2309
|
-
};
|
2310
|
-
return getCurrentEventState(withDrafts);
|
2311
|
-
}
|
2312
|
-
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2313
|
-
const indexedAt = eventIndex.modifiedAt;
|
2314
|
-
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2315
|
-
if (activeDrafts.length === 0) {
|
2316
|
-
return eventIndex;
|
2317
|
-
}
|
2318
|
-
return {
|
2319
|
-
...eventIndex,
|
2320
|
-
declaration: {
|
2321
|
-
...eventIndex.declaration,
|
2322
|
-
...activeDrafts[activeDrafts.length - 1].declaration
|
2323
|
-
}
|
2324
|
-
};
|
2325
|
-
}
|
2326
|
-
function getAnnotationFromDrafts(drafts) {
|
2327
|
-
const actions = drafts.map((draft) => draft.action);
|
2328
|
-
const annotation = actions.reduce((ann, action) => {
|
2329
|
-
return deepMerge(ann, action.annotation ?? {});
|
2330
|
-
}, {});
|
2331
|
-
return deepDropNulls(annotation);
|
2332
|
-
}
|
2333
|
-
function getActionAnnotation({
|
2334
|
-
event: event2,
|
2335
|
-
actionType,
|
2336
|
-
drafts
|
2337
|
-
}) {
|
2338
|
-
const activeActions = getAcceptedActions(event2);
|
2339
|
-
const action = activeActions.find(
|
2340
|
-
(activeAction) => actionType === activeAction.type
|
2341
|
-
);
|
2342
|
-
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2343
|
-
const sorted = [
|
2344
|
-
...action ? [action] : [],
|
2345
|
-
...eventDrafts.map((draft) => draft.action)
|
2346
|
-
].sort();
|
2347
|
-
const annotation = sorted.reduce((ann, sortedAction) => {
|
2348
|
-
return deepMerge(ann, sortedAction.annotation ?? {});
|
2349
|
-
}, {});
|
2350
|
-
return deepDropNulls(annotation);
|
2351
|
-
}
|
2352
|
-
|
2353
|
-
// ../commons/src/events/defineConfig.ts
|
2354
|
-
var defineConfig = (config) => {
|
2355
|
-
validateWorkqueueConfig(config.workqueues);
|
2356
|
-
const input = EventConfig.parse(config);
|
2357
|
-
return input;
|
2358
|
-
};
|
2359
|
-
|
2360
|
-
// ../commons/src/events/transactions.ts
|
2361
|
-
function generateTransactionId() {
|
2362
|
-
return getUUID();
|
2363
|
-
}
|
2364
|
-
|
2365
|
-
// ../commons/src/events/test.utils.ts
|
2366
|
-
var import_lodash2 = require("lodash");
|
2287
|
+
var QueryType = import_zod20.z.discriminatedUnion("type", [Or2, And2]);
|
2367
2288
|
|
2368
2289
|
// ../commons/src/conditionals/conditionals.ts
|
2369
2290
|
function defineConditional(schema) {
|
@@ -2427,32 +2348,38 @@ var user = {
|
|
2427
2348
|
required: ["$user"]
|
2428
2349
|
})
|
2429
2350
|
};
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2351
|
+
function createEventConditionals() {
|
2352
|
+
return {
|
2353
|
+
/**
|
2354
|
+
* Checks if the event contains a specific action type.
|
2355
|
+
* @param action - The action type to check for.
|
2356
|
+
*/
|
2357
|
+
hasAction: (action) => defineConditional({
|
2358
|
+
type: "object",
|
2359
|
+
properties: {
|
2360
|
+
$event: {
|
2361
|
+
type: "object",
|
2362
|
+
properties: {
|
2363
|
+
actions: {
|
2364
|
+
type: "array",
|
2365
|
+
contains: {
|
2366
|
+
type: "object",
|
2367
|
+
properties: {
|
2368
|
+
type: {
|
2369
|
+
const: action
|
2370
|
+
}
|
2371
|
+
},
|
2372
|
+
required: ["type"]
|
2373
|
+
}
|
2447
2374
|
}
|
2448
|
-
}
|
2449
|
-
|
2450
|
-
|
2451
|
-
}
|
2452
|
-
|
2453
|
-
|
2454
|
-
}
|
2455
|
-
}
|
2375
|
+
},
|
2376
|
+
required: ["actions"]
|
2377
|
+
}
|
2378
|
+
},
|
2379
|
+
required: ["$event"]
|
2380
|
+
})
|
2381
|
+
};
|
2382
|
+
}
|
2456
2383
|
function getDateFromNow(days) {
|
2457
2384
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2458
2385
|
}
|
@@ -2473,7 +2400,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
|
2473
2400
|
function isFieldReference(value) {
|
2474
2401
|
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2475
2402
|
}
|
2476
|
-
function
|
2403
|
+
function createFieldConditionals(fieldId) {
|
2477
2404
|
const getDateRange = (date, clause) => ({
|
2478
2405
|
type: "object",
|
2479
2406
|
properties: {
|
@@ -2486,10 +2413,6 @@ function field(fieldId) {
|
|
2486
2413
|
required: [fieldId]
|
2487
2414
|
});
|
2488
2415
|
return {
|
2489
|
-
/**
|
2490
|
-
* @private Internal property used for field reference tracking.
|
2491
|
-
*/
|
2492
|
-
_fieldId: fieldId,
|
2493
2416
|
isAfter: () => ({
|
2494
2417
|
days: (days) => ({
|
2495
2418
|
inPast: () => defineFormConditional(
|
@@ -2632,35 +2555,646 @@ function field(fieldId) {
|
|
2632
2555
|
required: [fieldId]
|
2633
2556
|
}),
|
2634
2557
|
/**
|
2635
|
-
* Checks if the field value matches a given regular expression pattern.
|
2636
|
-
* @param pattern - The regular expression pattern to match the field value against.
|
2637
|
-
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2558
|
+
* Checks if the field value matches a given regular expression pattern.
|
2559
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2560
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2561
|
+
*/
|
2562
|
+
matches: (pattern) => defineFormConditional({
|
2563
|
+
type: "object",
|
2564
|
+
properties: {
|
2565
|
+
[fieldId]: {
|
2566
|
+
type: "string",
|
2567
|
+
pattern
|
2568
|
+
}
|
2569
|
+
},
|
2570
|
+
required: [fieldId]
|
2571
|
+
}),
|
2572
|
+
isBetween: (min, max) => defineFormConditional({
|
2573
|
+
type: "object",
|
2574
|
+
properties: {
|
2575
|
+
[fieldId]: {
|
2576
|
+
type: "number",
|
2577
|
+
minimum: min,
|
2578
|
+
maximum: max
|
2579
|
+
}
|
2580
|
+
},
|
2581
|
+
required: [fieldId]
|
2582
|
+
}),
|
2583
|
+
getId: () => ({ fieldId })
|
2584
|
+
};
|
2585
|
+
}
|
2586
|
+
|
2587
|
+
// ../commons/src/searchConfigs.ts
|
2588
|
+
function createSearchConfig(baseField) {
|
2589
|
+
return {
|
2590
|
+
/**
|
2591
|
+
* Creates a range configuration for the specified field.
|
2592
|
+
*
|
2593
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2594
|
+
*
|
2595
|
+
* @example event('legalStatus.REGISTERED.createdAt').range()
|
2596
|
+
* // {
|
2597
|
+
* // ...
|
2598
|
+
* // config: { type: 'range' }
|
2599
|
+
* // }
|
2600
|
+
*/
|
2601
|
+
range: () => ({
|
2602
|
+
...baseField,
|
2603
|
+
config: { type: "range" }
|
2604
|
+
}),
|
2605
|
+
/**
|
2606
|
+
* Creates a configuration for exact matching of the specified field.
|
2607
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2608
|
+
* @example field('dob').exact()
|
2609
|
+
* // {
|
2610
|
+
* // ...
|
2611
|
+
* // config: { type: 'exact' }
|
2612
|
+
* // }
|
2613
|
+
*/
|
2614
|
+
exact: () => ({
|
2615
|
+
...baseField,
|
2616
|
+
config: { type: "exact" }
|
2617
|
+
}),
|
2618
|
+
/**
|
2619
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
2620
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2621
|
+
* @example field('name').fuzzy()
|
2622
|
+
* // {
|
2623
|
+
* // ...
|
2624
|
+
* // config: { type: 'fuzzy' }
|
2625
|
+
* // }
|
2626
|
+
*/
|
2627
|
+
fuzzy: () => ({
|
2628
|
+
...baseField,
|
2629
|
+
config: { type: "fuzzy" }
|
2630
|
+
})
|
2631
|
+
};
|
2632
|
+
}
|
2633
|
+
|
2634
|
+
// ../commons/src/event-config/event-configuration.ts
|
2635
|
+
function createEventFieldConfig(fieldId, options) {
|
2636
|
+
const baseField = {
|
2637
|
+
fieldId,
|
2638
|
+
options,
|
2639
|
+
fieldType: "event"
|
2640
|
+
};
|
2641
|
+
return createSearchConfig(baseField);
|
2642
|
+
}
|
2643
|
+
|
2644
|
+
// ../commons/src/events/event.ts
|
2645
|
+
function eventFn(fieldId, options) {
|
2646
|
+
return createEventFieldConfig(fieldId, options);
|
2647
|
+
}
|
2648
|
+
var event = Object.assign(eventFn, {
|
2649
|
+
...createEventConditionals(),
|
2650
|
+
field(field2) {
|
2651
|
+
return {
|
2652
|
+
$event: field2
|
2653
|
+
};
|
2654
|
+
}
|
2655
|
+
});
|
2656
|
+
|
2657
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
2658
|
+
var WorkqueueConfig = import_zod21.z.object({
|
2659
|
+
slug: import_zod21.z.string().describe("Determines the url of the workqueue."),
|
2660
|
+
name: TranslationConfig.describe(
|
2661
|
+
"Title of the workflow (both in navigation and on the page)"
|
2662
|
+
),
|
2663
|
+
query: QueryType,
|
2664
|
+
actions: import_zod21.z.array(
|
2665
|
+
import_zod21.z.object({
|
2666
|
+
type: import_zod21.z.string(),
|
2667
|
+
conditionals: import_zod21.z.array(Conditional).optional()
|
2668
|
+
})
|
2669
|
+
),
|
2670
|
+
columns: import_zod21.z.array(
|
2671
|
+
import_zod21.z.object({ label: TranslationConfig, value: EventMetadataParameter })
|
2672
|
+
).default([
|
2673
|
+
{
|
2674
|
+
label: {
|
2675
|
+
id: "workqueues.dateOfEvent",
|
2676
|
+
defaultMessage: "Date of Event",
|
2677
|
+
description: "Label for workqueue column: dateOfEvent"
|
2678
|
+
},
|
2679
|
+
value: event.field("dateOfEvent")
|
2680
|
+
}
|
2681
|
+
])
|
2682
|
+
}).describe("Configuration for workqueue.");
|
2683
|
+
function defineWorkqueue(workqueues) {
|
2684
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
2685
|
+
}
|
2686
|
+
|
2687
|
+
// ../commons/src/events/Draft.ts
|
2688
|
+
var import_zod23 = require("zod");
|
2689
|
+
|
2690
|
+
// ../commons/src/events/ActionInput.ts
|
2691
|
+
var import_zod22 = require("zod");
|
2692
|
+
var import_zod_openapi9 = require("zod-openapi");
|
2693
|
+
var import_uuid3 = require("uuid");
|
2694
|
+
(0, import_zod_openapi9.extendZodWithOpenApi)(import_zod22.z);
|
2695
|
+
var BaseActionInput = import_zod22.z.object({
|
2696
|
+
eventId: import_zod22.z.string(),
|
2697
|
+
transactionId: import_zod22.z.string(),
|
2698
|
+
declaration: ActionUpdate.default({}),
|
2699
|
+
annotation: ActionUpdate.optional(),
|
2700
|
+
originalActionId: import_zod22.z.string().optional(),
|
2701
|
+
keepAssignment: import_zod22.z.boolean().optional()
|
2702
|
+
});
|
2703
|
+
var CreateActionInput = BaseActionInput.merge(
|
2704
|
+
import_zod22.z.object({
|
2705
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2706
|
+
createdAtLocation: CreatedAtLocation
|
2707
|
+
})
|
2708
|
+
);
|
2709
|
+
var RegisterActionInput = BaseActionInput.merge(
|
2710
|
+
import_zod22.z.object({
|
2711
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2712
|
+
registrationNumber: import_zod22.z.string().optional()
|
2713
|
+
})
|
2714
|
+
);
|
2715
|
+
var ValidateActionInput = BaseActionInput.merge(
|
2716
|
+
import_zod22.z.object({
|
2717
|
+
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2718
|
+
duplicates: import_zod22.z.array(import_zod22.z.string())
|
2719
|
+
})
|
2720
|
+
);
|
2721
|
+
var NotifyActionInput = BaseActionInput.merge(
|
2722
|
+
import_zod22.z.object({
|
2723
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2724
|
+
})
|
2725
|
+
).openapi({
|
2726
|
+
default: {
|
2727
|
+
eventId: "<event-id-here>",
|
2728
|
+
transactionId: (0, import_uuid3.v4)(),
|
2729
|
+
declaration: {},
|
2730
|
+
annotation: {},
|
2731
|
+
type: ActionType.NOTIFY
|
2732
|
+
}
|
2733
|
+
});
|
2734
|
+
var DeclareActionInput = BaseActionInput.merge(
|
2735
|
+
import_zod22.z.object({
|
2736
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2737
|
+
})
|
2738
|
+
);
|
2739
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
2740
|
+
import_zod22.z.object({
|
2741
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2742
|
+
})
|
2743
|
+
);
|
2744
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2745
|
+
import_zod22.z.object({
|
2746
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2747
|
+
})
|
2748
|
+
);
|
2749
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2750
|
+
import_zod22.z.object({
|
2751
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2752
|
+
})
|
2753
|
+
);
|
2754
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2755
|
+
import_zod22.z.object({
|
2756
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2757
|
+
})
|
2758
|
+
);
|
2759
|
+
var AssignActionInput = BaseActionInput.merge(
|
2760
|
+
import_zod22.z.object({
|
2761
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2762
|
+
assignedTo: import_zod22.z.string()
|
2763
|
+
})
|
2764
|
+
);
|
2765
|
+
var UnassignActionInput = BaseActionInput.merge(
|
2766
|
+
import_zod22.z.object({
|
2767
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2768
|
+
assignedTo: import_zod22.z.literal(null).default(null)
|
2769
|
+
})
|
2770
|
+
);
|
2771
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2772
|
+
import_zod22.z.object({
|
2773
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2774
|
+
})
|
2775
|
+
);
|
2776
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2777
|
+
import_zod22.z.object({
|
2778
|
+
requestId: import_zod22.z.string(),
|
2779
|
+
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2780
|
+
})
|
2781
|
+
);
|
2782
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2783
|
+
import_zod22.z.object({
|
2784
|
+
requestId: import_zod22.z.string(),
|
2785
|
+
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2786
|
+
})
|
2787
|
+
);
|
2788
|
+
var ReadActionInput = BaseActionInput.merge(
|
2789
|
+
import_zod22.z.object({
|
2790
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2791
|
+
})
|
2792
|
+
);
|
2793
|
+
var DeleteActionInput = import_zod22.z.object({ eventId: import_zod22.z.string() });
|
2794
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2795
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2796
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2797
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2798
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2799
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2800
|
+
RejectDeclarationActionInput.openapi({
|
2801
|
+
ref: "RejectDeclarationActionInput"
|
2802
|
+
}),
|
2803
|
+
MarkedAsDuplicateActionInput.openapi({
|
2804
|
+
ref: "MarkedAsDuplicateActionInput"
|
2805
|
+
}),
|
2806
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2807
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2808
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2809
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2810
|
+
RequestCorrectionActionInput.openapi({
|
2811
|
+
ref: "RequestCorrectionActionInput"
|
2812
|
+
}),
|
2813
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2814
|
+
ApproveCorrectionActionInput.openapi({
|
2815
|
+
ref: "ApproveCorrectionActionInput"
|
2816
|
+
}),
|
2817
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2818
|
+
]).openapi({
|
2819
|
+
ref: "ActionInput"
|
2820
|
+
});
|
2821
|
+
|
2822
|
+
// ../commons/src/events/Draft.ts
|
2823
|
+
var Draft = import_zod23.z.object({
|
2824
|
+
id: import_zod23.z.string(),
|
2825
|
+
eventId: import_zod23.z.string(),
|
2826
|
+
transactionId: import_zod23.z.string(),
|
2827
|
+
createdAt: import_zod23.z.string().datetime(),
|
2828
|
+
action: ActionBase.extend({
|
2829
|
+
type: ActionTypes
|
2830
|
+
}).omit({ id: true })
|
2831
|
+
});
|
2832
|
+
var DraftInput = BaseActionInput.extend({
|
2833
|
+
type: ActionTypes,
|
2834
|
+
status: import_zod23.z.enum([
|
2835
|
+
ActionStatus.Requested,
|
2836
|
+
ActionStatus.Accepted,
|
2837
|
+
ActionStatus.Rejected
|
2838
|
+
])
|
2839
|
+
});
|
2840
|
+
|
2841
|
+
// ../commons/src/events/EventInput.ts
|
2842
|
+
var import_zod24 = require("zod");
|
2843
|
+
var import_uuid4 = require("uuid");
|
2844
|
+
var EventInput = import_zod24.z.object({
|
2845
|
+
transactionId: import_zod24.z.string(),
|
2846
|
+
type: import_zod24.z.string(),
|
2847
|
+
dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional()
|
2848
|
+
}).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
|
2849
|
+
|
2850
|
+
// ../commons/src/events/EventDocument.ts
|
2851
|
+
var import_zod25 = require("zod");
|
2852
|
+
var import_zod_openapi10 = require("zod-openapi");
|
2853
|
+
(0, import_zod_openapi10.extendZodWithOpenApi)(import_zod25.z);
|
2854
|
+
var EventDocument = import_zod25.z.object({
|
2855
|
+
id: import_zod25.z.string(),
|
2856
|
+
type: import_zod25.z.string(),
|
2857
|
+
dateOfEvent: import_zod25.z.object({ fieldId: import_zod25.z.string() }).optional(),
|
2858
|
+
createdAt: import_zod25.z.string().datetime(),
|
2859
|
+
updatedAt: import_zod25.z.string().datetime(),
|
2860
|
+
actions: import_zod25.z.array(Action),
|
2861
|
+
trackingId: import_zod25.z.string()
|
2862
|
+
}).openapi({ ref: "EventDocument" });
|
2863
|
+
|
2864
|
+
// ../commons/src/events/state/utils.ts
|
2865
|
+
function getActionRequests(actionType, actions) {
|
2866
|
+
const filtered = actions.filter((action) => action.type === actionType);
|
2867
|
+
const accept = filtered.find(
|
2868
|
+
(action) => action.status === ActionStatus.Accepted
|
2869
|
+
);
|
2870
|
+
const request = filtered.find(
|
2871
|
+
(action) => action.status === ActionStatus.Requested
|
2872
|
+
);
|
2873
|
+
const reject = filtered.find(
|
2874
|
+
(action) => action.status === ActionStatus.Rejected
|
2875
|
+
);
|
2876
|
+
return {
|
2877
|
+
reject,
|
2878
|
+
accept,
|
2879
|
+
request
|
2880
|
+
};
|
2881
|
+
}
|
2882
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
2883
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
2884
|
+
actionType,
|
2885
|
+
actions
|
2886
|
+
);
|
2887
|
+
if (!acceptAction) {
|
2888
|
+
return null;
|
2889
|
+
}
|
2890
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
2891
|
+
return {
|
2892
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
2893
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
2894
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
2895
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
2896
|
+
acceptedAt: acceptAction.createdAt,
|
2897
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
2898
|
+
registrationNumber
|
2899
|
+
};
|
2900
|
+
}
|
2901
|
+
function getDeclarationActionUpdateMetadata(actions) {
|
2902
|
+
const createAction = getOrThrow(
|
2903
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
2904
|
+
`Event has no ${ActionType.CREATE} action`
|
2905
|
+
);
|
2906
|
+
return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
|
2907
|
+
(metadata, actionType) => {
|
2908
|
+
const { accept, request } = getActionRequests(actionType, actions);
|
2909
|
+
return {
|
2910
|
+
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
2911
|
+
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
2912
|
+
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
2913
|
+
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
2914
|
+
};
|
2915
|
+
},
|
2916
|
+
{
|
2917
|
+
createdAt: createAction.createdAt,
|
2918
|
+
createdBy: createAction.createdBy,
|
2919
|
+
createdAtLocation: createAction.createdAtLocation,
|
2920
|
+
createdByRole: createAction.createdByRole
|
2921
|
+
}
|
2922
|
+
);
|
2923
|
+
}
|
2924
|
+
function getLegalStatuses(actions) {
|
2925
|
+
return {
|
2926
|
+
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
2927
|
+
ActionType.DECLARE,
|
2928
|
+
actions
|
2929
|
+
),
|
2930
|
+
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
2931
|
+
ActionType.REGISTER,
|
2932
|
+
actions
|
2933
|
+
)
|
2934
|
+
};
|
2935
|
+
}
|
2936
|
+
|
2937
|
+
// ../commons/src/events/state/index.ts
|
2938
|
+
function getStatusFromActions(actions) {
|
2939
|
+
const hasRejectedAction = actions.some(
|
2940
|
+
(a) => a.status === ActionStatus.Rejected
|
2941
|
+
);
|
2942
|
+
if (hasRejectedAction) {
|
2943
|
+
return EventStatus.REJECTED;
|
2944
|
+
}
|
2945
|
+
return actions.reduce((status, action) => {
|
2946
|
+
switch (action.type) {
|
2947
|
+
case ActionType.CREATE:
|
2948
|
+
return EventStatus.CREATED;
|
2949
|
+
case ActionType.DECLARE:
|
2950
|
+
return EventStatus.DECLARED;
|
2951
|
+
case ActionType.VALIDATE:
|
2952
|
+
return EventStatus.VALIDATED;
|
2953
|
+
case ActionType.REGISTER:
|
2954
|
+
return EventStatus.REGISTERED;
|
2955
|
+
case ActionType.REJECT:
|
2956
|
+
return EventStatus.REJECTED;
|
2957
|
+
case ActionType.ARCHIVE:
|
2958
|
+
return EventStatus.ARCHIVED;
|
2959
|
+
case ActionType.NOTIFY:
|
2960
|
+
return EventStatus.NOTIFIED;
|
2961
|
+
case ActionType.PRINT_CERTIFICATE:
|
2962
|
+
return EventStatus.CERTIFIED;
|
2963
|
+
case ActionType.ASSIGN:
|
2964
|
+
case ActionType.UNASSIGN:
|
2965
|
+
case ActionType.REQUEST_CORRECTION:
|
2966
|
+
case ActionType.APPROVE_CORRECTION:
|
2967
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2968
|
+
case ActionType.REJECT_CORRECTION:
|
2969
|
+
case ActionType.READ:
|
2970
|
+
default:
|
2971
|
+
return status;
|
2972
|
+
}
|
2973
|
+
}, EventStatus.CREATED);
|
2974
|
+
}
|
2975
|
+
function getFlagsFromActions(actions) {
|
2976
|
+
const sortedactions = actions.sort(
|
2977
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
2978
|
+
);
|
2979
|
+
const actionStatus = sortedactions.reduce(
|
2980
|
+
(actionStatuses, { type, status }) => ({
|
2981
|
+
...actionStatuses,
|
2982
|
+
[type]: status
|
2983
|
+
}),
|
2984
|
+
{}
|
2985
|
+
);
|
2986
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
2987
|
+
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
2988
|
+
return flag;
|
2989
|
+
});
|
2990
|
+
const isCertificatePrinted = sortedactions.reduce(
|
2991
|
+
(prev, { type }) => {
|
2992
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
2993
|
+
return true;
|
2994
|
+
}
|
2995
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
2996
|
+
return false;
|
2997
|
+
}
|
2998
|
+
return prev;
|
2999
|
+
},
|
3000
|
+
false
|
3001
|
+
);
|
3002
|
+
if (isCertificatePrinted) {
|
3003
|
+
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
3004
|
+
}
|
3005
|
+
return flags;
|
3006
|
+
}
|
3007
|
+
function getAssignedUserFromActions(actions) {
|
3008
|
+
return actions.reduce((user2, action) => {
|
3009
|
+
if (action.type === ActionType.ASSIGN) {
|
3010
|
+
return action.assignedTo;
|
3011
|
+
}
|
3012
|
+
if (action.type === ActionType.UNASSIGN) {
|
3013
|
+
return null;
|
3014
|
+
}
|
3015
|
+
return user2;
|
3016
|
+
}, null);
|
3017
|
+
}
|
3018
|
+
function aggregateActionDeclarations(actions) {
|
3019
|
+
const excludedActions = [
|
3020
|
+
ActionType.REQUEST_CORRECTION,
|
3021
|
+
ActionType.PRINT_CERTIFICATE
|
3022
|
+
];
|
3023
|
+
return actions.reduce((status, action) => {
|
3024
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
3025
|
+
return status;
|
3026
|
+
}
|
3027
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
3028
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
3029
|
+
if (!requestAction) {
|
3030
|
+
return status;
|
3031
|
+
}
|
3032
|
+
return deepMerge(status, requestAction.declaration);
|
3033
|
+
}
|
3034
|
+
return deepMerge(status, action.declaration);
|
3035
|
+
}, {});
|
3036
|
+
}
|
3037
|
+
function deepDropNulls(obj) {
|
3038
|
+
if (Array.isArray(obj)) {
|
3039
|
+
return obj.map(deepDropNulls);
|
3040
|
+
}
|
3041
|
+
if (obj !== null && typeof obj === "object") {
|
3042
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
3043
|
+
const cleanedValue = deepDropNulls(value);
|
3044
|
+
if (cleanedValue !== null) {
|
3045
|
+
;
|
3046
|
+
acc[key] = cleanedValue;
|
3047
|
+
}
|
3048
|
+
return acc;
|
3049
|
+
}, {});
|
3050
|
+
}
|
3051
|
+
return obj;
|
3052
|
+
}
|
3053
|
+
function isUndeclaredDraft(status) {
|
3054
|
+
return status === EventStatus.CREATED;
|
3055
|
+
}
|
3056
|
+
function getAcceptedActions(event2) {
|
3057
|
+
return event2.actions.filter(
|
3058
|
+
(a) => a.status === ActionStatus.Accepted
|
3059
|
+
);
|
3060
|
+
}
|
3061
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
3062
|
+
function getCurrentEventState(event2) {
|
3063
|
+
const creationAction = event2.actions.find(
|
3064
|
+
(action) => action.type === ActionType.CREATE
|
3065
|
+
);
|
3066
|
+
if (!creationAction) {
|
3067
|
+
throw new Error(`Event ${event2.id} has no creation action`);
|
3068
|
+
}
|
3069
|
+
const acceptedActions = getAcceptedActions(event2);
|
3070
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
3071
|
+
event2.actions
|
3072
|
+
);
|
3073
|
+
const declaration = aggregateActionDeclarations(acceptedActions);
|
3074
|
+
const dateOfEvent = ZodDate.safeParse(
|
3075
|
+
event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
|
3076
|
+
).data ?? null;
|
3077
|
+
return deepDropNulls({
|
3078
|
+
id: event2.id,
|
3079
|
+
type: event2.type,
|
3080
|
+
status: getStatusFromActions(event2.actions),
|
3081
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
3082
|
+
createdAt: creationAction.createdAt,
|
3083
|
+
createdBy: creationAction.createdBy,
|
3084
|
+
createdAtLocation: creationAction.createdAtLocation,
|
3085
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
3086
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
3087
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
3088
|
+
updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
|
3089
|
+
declaration,
|
3090
|
+
trackingId: event2.trackingId,
|
3091
|
+
// @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
|
3092
|
+
updatedByUserRole: declarationUpdateMetadata.createdByRole,
|
3093
|
+
dateOfEvent,
|
3094
|
+
flags: getFlagsFromActions(event2.actions)
|
3095
|
+
});
|
3096
|
+
}
|
3097
|
+
function getCurrentEventStateWithDrafts(event2, drafts) {
|
3098
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
3099
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
3100
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
3101
|
+
return [
|
3102
|
+
action,
|
3103
|
+
{
|
3104
|
+
...action,
|
3105
|
+
type: ActionType.APPROVE_CORRECTION
|
3106
|
+
}
|
3107
|
+
];
|
3108
|
+
}
|
3109
|
+
return [action];
|
3110
|
+
});
|
3111
|
+
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
3112
|
+
const withDrafts = {
|
3113
|
+
...event2,
|
3114
|
+
actions: actionWithDrafts
|
3115
|
+
};
|
3116
|
+
return getCurrentEventState(withDrafts);
|
3117
|
+
}
|
3118
|
+
function applyDraftsToEventIndex(eventIndex, drafts) {
|
3119
|
+
const indexedAt = eventIndex.updatedAt;
|
3120
|
+
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
3121
|
+
if (activeDrafts.length === 0) {
|
3122
|
+
return eventIndex;
|
3123
|
+
}
|
3124
|
+
return {
|
3125
|
+
...eventIndex,
|
3126
|
+
declaration: {
|
3127
|
+
...eventIndex.declaration,
|
3128
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
3129
|
+
}
|
3130
|
+
};
|
3131
|
+
}
|
3132
|
+
function getAnnotationFromDrafts(drafts) {
|
3133
|
+
const actions = drafts.map((draft) => draft.action);
|
3134
|
+
const annotation = actions.reduce((ann, action) => {
|
3135
|
+
return deepMerge(ann, action.annotation ?? {});
|
3136
|
+
}, {});
|
3137
|
+
return deepDropNulls(annotation);
|
3138
|
+
}
|
3139
|
+
function getActionAnnotation({
|
3140
|
+
event: event2,
|
3141
|
+
actionType,
|
3142
|
+
drafts = []
|
3143
|
+
}) {
|
3144
|
+
const activeActions = getAcceptedActions(event2);
|
3145
|
+
const action = activeActions.find(
|
3146
|
+
(activeAction) => actionType === activeAction.type
|
3147
|
+
);
|
3148
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
3149
|
+
const sorted = [
|
3150
|
+
...action ? [action] : [],
|
3151
|
+
...eventDrafts.map((draft) => draft.action)
|
3152
|
+
].sort();
|
3153
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
3154
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
3155
|
+
}, {});
|
3156
|
+
return deepDropNulls(annotation);
|
3157
|
+
}
|
3158
|
+
|
3159
|
+
// ../commons/src/events/defineConfig.ts
|
3160
|
+
var defineConfig = (config) => {
|
3161
|
+
const input = EventConfig.parse(config);
|
3162
|
+
return input;
|
3163
|
+
};
|
3164
|
+
|
3165
|
+
// ../commons/src/events/transactions.ts
|
3166
|
+
function generateTransactionId() {
|
3167
|
+
return getUUID();
|
3168
|
+
}
|
3169
|
+
|
3170
|
+
// ../commons/src/events/test.utils.ts
|
3171
|
+
var import_lodash2 = require("lodash");
|
3172
|
+
var import_addDays = __toESM(require("date-fns/addDays"));
|
3173
|
+
|
3174
|
+
// ../commons/src/field-config/field-configuration.ts
|
3175
|
+
function createFieldConfig(fieldId, options) {
|
3176
|
+
const baseField = {
|
3177
|
+
fieldId,
|
3178
|
+
fieldType: "field",
|
3179
|
+
...options
|
3180
|
+
};
|
3181
|
+
return createSearchConfig(baseField);
|
3182
|
+
}
|
3183
|
+
|
3184
|
+
// ../commons/src/events/field.ts
|
3185
|
+
function field(fieldId, options = {}) {
|
3186
|
+
return {
|
3187
|
+
/**
|
3188
|
+
* @private Internal property used for field reference tracking.
|
2638
3189
|
*/
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
[fieldId]: {
|
2643
|
-
type: "string",
|
2644
|
-
pattern
|
2645
|
-
}
|
2646
|
-
},
|
2647
|
-
required: [fieldId]
|
2648
|
-
}),
|
2649
|
-
isBetween: (min, max) => defineFormConditional({
|
2650
|
-
type: "object",
|
2651
|
-
properties: {
|
2652
|
-
[fieldId]: {
|
2653
|
-
type: "number",
|
2654
|
-
minimum: min,
|
2655
|
-
maximum: max
|
2656
|
-
}
|
2657
|
-
},
|
2658
|
-
required: [fieldId]
|
2659
|
-
})
|
3190
|
+
_fieldId: fieldId,
|
3191
|
+
...createFieldConditionals(fieldId),
|
3192
|
+
...createFieldConfig(fieldId, options)
|
2660
3193
|
};
|
2661
3194
|
}
|
2662
3195
|
|
2663
3196
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
3197
|
+
var import_date_fns2 = require("date-fns");
|
2664
3198
|
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2665
3199
|
label: {
|
2666
3200
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
@@ -3398,9 +3932,8 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3398
3932
|
},
|
3399
3933
|
{
|
3400
3934
|
id: "applicant.dob",
|
3401
|
-
type:
|
3935
|
+
type: FieldType.DATE,
|
3402
3936
|
required: true,
|
3403
|
-
conditionals: [],
|
3404
3937
|
validation: [
|
3405
3938
|
{
|
3406
3939
|
message: {
|
@@ -3411,12 +3944,50 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3411
3944
|
validator: field("applicant.dob").isBefore().now()
|
3412
3945
|
}
|
3413
3946
|
],
|
3947
|
+
conditionals: [
|
3948
|
+
{
|
3949
|
+
type: ConditionalType.SHOW,
|
3950
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3951
|
+
}
|
3952
|
+
],
|
3414
3953
|
label: {
|
3415
3954
|
defaultMessage: "Applicant's date of birth",
|
3416
3955
|
description: "This is the label for the field",
|
3417
3956
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3418
3957
|
}
|
3419
3958
|
},
|
3959
|
+
{
|
3960
|
+
id: "applicant.dobUnknown",
|
3961
|
+
type: FieldType.CHECKBOX,
|
3962
|
+
required: false,
|
3963
|
+
label: {
|
3964
|
+
defaultMessage: "Exact date of birth unknown",
|
3965
|
+
description: "This is the label for the field",
|
3966
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3967
|
+
},
|
3968
|
+
conditionals: [
|
3969
|
+
{
|
3970
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3971
|
+
conditional: never()
|
3972
|
+
}
|
3973
|
+
]
|
3974
|
+
},
|
3975
|
+
{
|
3976
|
+
id: "applicant.age",
|
3977
|
+
type: FieldType.NUMBER,
|
3978
|
+
required: true,
|
3979
|
+
label: {
|
3980
|
+
defaultMessage: "Age of tennis-member",
|
3981
|
+
description: "This is the label for the field",
|
3982
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3983
|
+
},
|
3984
|
+
conditionals: [
|
3985
|
+
{
|
3986
|
+
type: ConditionalType.SHOW,
|
3987
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3988
|
+
}
|
3989
|
+
]
|
3990
|
+
},
|
3420
3991
|
{
|
3421
3992
|
id: "applicant.image",
|
3422
3993
|
type: FieldType.FILE,
|
@@ -3532,6 +4103,114 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3532
4103
|
}
|
3533
4104
|
]
|
3534
4105
|
});
|
4106
|
+
var statusOptions = [
|
4107
|
+
{
|
4108
|
+
value: "ALL",
|
4109
|
+
label: {
|
4110
|
+
defaultMessage: "Any status",
|
4111
|
+
description: "Option for form field: status of record",
|
4112
|
+
id: "v2.advancedSearch.form.recordStatusAny"
|
4113
|
+
}
|
4114
|
+
},
|
4115
|
+
{
|
4116
|
+
value: EventStatus.CREATED,
|
4117
|
+
label: {
|
4118
|
+
defaultMessage: "Draft",
|
4119
|
+
description: "Option for form field: status of record",
|
4120
|
+
id: "v2.advancedSearch.form.recordStatusCreated"
|
4121
|
+
}
|
4122
|
+
},
|
4123
|
+
{
|
4124
|
+
value: EventStatus.NOTIFIED,
|
4125
|
+
label: {
|
4126
|
+
defaultMessage: "Notified",
|
4127
|
+
description: "Option for form field: status of record",
|
4128
|
+
id: "v2.advancedSearch.form.recordStatusNotified"
|
4129
|
+
}
|
4130
|
+
},
|
4131
|
+
{
|
4132
|
+
value: EventStatus.DECLARED,
|
4133
|
+
label: {
|
4134
|
+
defaultMessage: "Declared",
|
4135
|
+
description: "Option for form field: status of record",
|
4136
|
+
id: "v2.advancedSearch.form.recordStatusDeclared"
|
4137
|
+
}
|
4138
|
+
},
|
4139
|
+
{
|
4140
|
+
value: EventStatus.VALIDATED,
|
4141
|
+
label: {
|
4142
|
+
defaultMessage: "Validated",
|
4143
|
+
description: "Option for form field: status of record",
|
4144
|
+
id: "v2.advancedSearch.form.recordStatusValidated"
|
4145
|
+
}
|
4146
|
+
},
|
4147
|
+
{
|
4148
|
+
value: EventStatus.REGISTERED,
|
4149
|
+
label: {
|
4150
|
+
defaultMessage: "Registered",
|
4151
|
+
description: "Option for form field: status of record",
|
4152
|
+
id: "v2.advancedSearch.form.recordStatusRegistered"
|
4153
|
+
}
|
4154
|
+
},
|
4155
|
+
{
|
4156
|
+
value: EventStatus.CERTIFIED,
|
4157
|
+
label: {
|
4158
|
+
defaultMessage: "Certified",
|
4159
|
+
description: "Option for form field: status of record",
|
4160
|
+
id: "v2.advancedSearch.form.recordStatusCertified"
|
4161
|
+
}
|
4162
|
+
},
|
4163
|
+
{
|
4164
|
+
value: EventStatus.REJECTED,
|
4165
|
+
label: {
|
4166
|
+
defaultMessage: "Rejected",
|
4167
|
+
description: "Option for form field: status of record",
|
4168
|
+
id: "v2.advancedSearch.form.recordStatusRejected"
|
4169
|
+
}
|
4170
|
+
},
|
4171
|
+
{
|
4172
|
+
value: EventStatus.ARCHIVED,
|
4173
|
+
label: {
|
4174
|
+
defaultMessage: "Archived",
|
4175
|
+
description: "Option for form field: status of record",
|
4176
|
+
id: "v2.advancedSearch.form.recordStatusArchived"
|
4177
|
+
}
|
4178
|
+
}
|
4179
|
+
];
|
4180
|
+
var timePeriodOptions = [
|
4181
|
+
{
|
4182
|
+
label: {
|
4183
|
+
defaultMessage: "Last 7 days",
|
4184
|
+
description: "Label for option of time period select: last 7 days",
|
4185
|
+
id: "form.section.label.timePeriodLast7Days"
|
4186
|
+
},
|
4187
|
+
value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
|
4188
|
+
},
|
4189
|
+
{
|
4190
|
+
label: {
|
4191
|
+
defaultMessage: "Last 30 days",
|
4192
|
+
description: "Label for option of time period select: last 30 days",
|
4193
|
+
id: "form.section.label.timePeriodLast30Days"
|
4194
|
+
},
|
4195
|
+
value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
|
4196
|
+
},
|
4197
|
+
{
|
4198
|
+
label: {
|
4199
|
+
defaultMessage: "Last 90 days",
|
4200
|
+
description: "Label for option of time period select: last 90 days",
|
4201
|
+
id: "form.section.label.timePeriodLast90Days"
|
4202
|
+
},
|
4203
|
+
value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
|
4204
|
+
},
|
4205
|
+
{
|
4206
|
+
label: {
|
4207
|
+
defaultMessage: "Last year",
|
4208
|
+
description: "Label for option of time period select: last year",
|
4209
|
+
id: "form.section.label.timePeriodLastYear"
|
4210
|
+
},
|
4211
|
+
value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
|
4212
|
+
}
|
4213
|
+
];
|
3535
4214
|
var tennisClubMembershipEvent = defineConfig({
|
3536
4215
|
id: "TENNIS_CLUB_MEMBERSHIP",
|
3537
4216
|
label: {
|
@@ -3539,20 +4218,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3539
4218
|
description: "This is what this event is referred as in the system",
|
3540
4219
|
id: "event.tennis-club-membership.label"
|
3541
4220
|
},
|
4221
|
+
title: {
|
4222
|
+
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
4223
|
+
description: "This is the title of the summary",
|
4224
|
+
id: "v2.event.tennis-club-membership.title"
|
4225
|
+
},
|
3542
4226
|
summary: {
|
3543
|
-
title: {
|
3544
|
-
id: "event.tennis-club-membership.summary.title",
|
3545
|
-
label: {
|
3546
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3547
|
-
description: "This is the title of the summary",
|
3548
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3549
|
-
},
|
3550
|
-
emptyValueMessage: {
|
3551
|
-
defaultMessage: "Membership application",
|
3552
|
-
description: "This is the message shown when the applicant name is missing",
|
3553
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3554
|
-
}
|
3555
|
-
},
|
3556
4227
|
fields: [
|
3557
4228
|
{
|
3558
4229
|
id: "applicant.firstname",
|
@@ -3573,47 +4244,18 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3573
4244
|
}
|
3574
4245
|
},
|
3575
4246
|
{
|
3576
|
-
|
4247
|
+
fieldId: "applicant.surname",
|
3577
4248
|
label: {
|
3578
4249
|
defaultMessage: "Applicant's last name",
|
3579
|
-
description: "
|
3580
|
-
id: "event.tennis-club-membership.summary.field.surname.label"
|
3581
|
-
},
|
3582
|
-
value: {
|
3583
|
-
defaultMessage: "{applicant.surname}",
|
3584
|
-
description: "This is the value to show in the summary",
|
3585
|
-
id: "event.tennis-club-membership.summary.field.surname"
|
3586
|
-
},
|
3587
|
-
emptyValueMessage: {
|
3588
|
-
defaultMessage: "Last name is not provided",
|
3589
|
-
description: "This is the message to show when the field is empty",
|
3590
|
-
id: "event.tennis-club-membership.summary.field.surname.empty"
|
4250
|
+
description: "Label for surname",
|
4251
|
+
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
3591
4252
|
}
|
4253
|
+
},
|
4254
|
+
{
|
4255
|
+
fieldId: "applicant.email"
|
3592
4256
|
}
|
3593
4257
|
]
|
3594
4258
|
},
|
3595
|
-
workqueues: [
|
3596
|
-
{
|
3597
|
-
id: "all",
|
3598
|
-
filters: []
|
3599
|
-
},
|
3600
|
-
{
|
3601
|
-
id: "ready-for-review",
|
3602
|
-
filters: [
|
3603
|
-
{
|
3604
|
-
status: ["DECLARED"]
|
3605
|
-
}
|
3606
|
-
]
|
3607
|
-
},
|
3608
|
-
{
|
3609
|
-
id: "registered",
|
3610
|
-
filters: [
|
3611
|
-
{
|
3612
|
-
status: ["REGISTERED"]
|
3613
|
-
}
|
3614
|
-
]
|
3615
|
-
}
|
3616
|
-
],
|
3617
4259
|
actions: [
|
3618
4260
|
{
|
3619
4261
|
type: ActionType.DECLARE,
|
@@ -3917,14 +4559,39 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3917
4559
|
advancedSearch: [
|
3918
4560
|
{
|
3919
4561
|
title: {
|
3920
|
-
defaultMessage: "
|
3921
|
-
description: "
|
3922
|
-
id: "v2.
|
4562
|
+
defaultMessage: "Registration details",
|
4563
|
+
description: "The title of Registration details accordion",
|
4564
|
+
id: "v2.advancedSearch.form.registrationDetails"
|
3923
4565
|
},
|
3924
4566
|
fields: [
|
3925
|
-
|
3926
|
-
|
3927
|
-
|
4567
|
+
event("legalStatus.REGISTERED.createdAtLocation").exact(),
|
4568
|
+
event("legalStatus.REGISTERED.createdAt").range(),
|
4569
|
+
event("status", statusOptions).exact(),
|
4570
|
+
event("updatedAt", timePeriodOptions).range()
|
4571
|
+
]
|
4572
|
+
},
|
4573
|
+
{
|
4574
|
+
title: {
|
4575
|
+
defaultMessage: "Applicant's details",
|
4576
|
+
description: "Applicant details search field section title",
|
4577
|
+
id: "v2.event.tennis-club-membership.search.applicants"
|
4578
|
+
},
|
4579
|
+
fields: [
|
4580
|
+
field("applicant.firstname").fuzzy(),
|
4581
|
+
field("applicant.surname").fuzzy(),
|
4582
|
+
field("applicant.dob").range(),
|
4583
|
+
field("applicant.email").exact()
|
4584
|
+
]
|
4585
|
+
},
|
4586
|
+
{
|
4587
|
+
title: {
|
4588
|
+
defaultMessage: "Recommender's details",
|
4589
|
+
description: "Recommender details search field section title",
|
4590
|
+
id: "v2.event.tennis-club-membership.search.recommender"
|
4591
|
+
},
|
4592
|
+
fields: [
|
4593
|
+
field("recommender.firstname").fuzzy(),
|
4594
|
+
field("recommender.surname").fuzzy()
|
3928
4595
|
]
|
3929
4596
|
}
|
3930
4597
|
],
|
@@ -3932,7 +4599,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3932
4599
|
});
|
3933
4600
|
|
3934
4601
|
// ../commons/src/events/test.utils.ts
|
3935
|
-
function
|
4602
|
+
function fieldConfigsToActionPayload(fields) {
|
3936
4603
|
return fields.reduce(
|
3937
4604
|
(acc, field2, i) => ({
|
3938
4605
|
...acc,
|
@@ -3941,26 +4608,27 @@ function fieldConfigsToActionAnnotation(fields) {
|
|
3941
4608
|
{}
|
3942
4609
|
);
|
3943
4610
|
}
|
3944
|
-
function
|
4611
|
+
function generateActionDeclarationInput(configuration, action) {
|
3945
4612
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
3946
4613
|
if (parsed.success) {
|
3947
4614
|
const fields = getDeclarationFields(configuration);
|
3948
|
-
const
|
3949
|
-
|
4615
|
+
const declarationConfig = getDeclaration(configuration);
|
4616
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4617
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
3950
4618
|
}
|
3951
4619
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
3952
4620
|
return {};
|
3953
4621
|
}
|
3954
|
-
function
|
4622
|
+
function generateActionAnnotationInput(configuration, action) {
|
3955
4623
|
const actionConfig = configuration.actions.find(
|
3956
4624
|
(ac) => ac.type === action
|
3957
4625
|
);
|
3958
4626
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3959
|
-
const annotation =
|
3960
|
-
const visibleVerificationPageIds =
|
3961
|
-
configuration,
|
3962
|
-
|
3963
|
-
)
|
4627
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4628
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4629
|
+
findRecordActionPages(configuration, action),
|
4630
|
+
annotation
|
4631
|
+
);
|
3964
4632
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3965
4633
|
(acc, pageId) => ({
|
3966
4634
|
...acc,
|
@@ -3968,7 +4636,7 @@ function generateActionMetadataInput(configuration, action) {
|
|
3968
4636
|
}),
|
3969
4637
|
{}
|
3970
4638
|
);
|
3971
|
-
const fieldBasedPayload =
|
4639
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
3972
4640
|
return {
|
3973
4641
|
...fieldBasedPayload,
|
3974
4642
|
...visiblePageVerificationMap
|
@@ -3991,6 +4659,7 @@ var eventPayloadGenerator = {
|
|
3991
4659
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3992
4660
|
transactionId: getUUID(),
|
3993
4661
|
action: {
|
4662
|
+
transactionId: getUUID(),
|
3994
4663
|
type: actionType,
|
3995
4664
|
status: ActionStatus.Accepted,
|
3996
4665
|
declaration: {
|
@@ -4005,6 +4674,7 @@ var eventPayloadGenerator = {
|
|
4005
4674
|
},
|
4006
4675
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4007
4676
|
createdBy: "@todo",
|
4677
|
+
createdByRole: "@todo",
|
4008
4678
|
createdAtLocation: "@todo"
|
4009
4679
|
}
|
4010
4680
|
},
|
@@ -4014,8 +4684,11 @@ var eventPayloadGenerator = {
|
|
4014
4684
|
declare: (eventId, input = {}) => ({
|
4015
4685
|
type: ActionType.DECLARE,
|
4016
4686
|
transactionId: input.transactionId ?? getUUID(),
|
4017
|
-
declaration: input.declaration ??
|
4018
|
-
|
4687
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4688
|
+
tennisClubMembershipEvent,
|
4689
|
+
ActionType.DECLARE
|
4690
|
+
),
|
4691
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4019
4692
|
tennisClubMembershipEvent,
|
4020
4693
|
ActionType.DECLARE
|
4021
4694
|
),
|
@@ -4028,7 +4701,10 @@ var eventPayloadGenerator = {
|
|
4028
4701
|
let declaration = input.declaration;
|
4029
4702
|
if (!declaration) {
|
4030
4703
|
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4031
|
-
|
4704
|
+
generateActionDeclarationInput(
|
4705
|
+
tennisClubMembershipEvent,
|
4706
|
+
ActionType.DECLARE
|
4707
|
+
),
|
4032
4708
|
import_lodash2.isString
|
4033
4709
|
);
|
4034
4710
|
declaration = partialDeclaration;
|
@@ -4043,8 +4719,11 @@ var eventPayloadGenerator = {
|
|
4043
4719
|
validate: (eventId, input = {}) => ({
|
4044
4720
|
type: ActionType.VALIDATE,
|
4045
4721
|
transactionId: input.transactionId ?? getUUID(),
|
4046
|
-
declaration: input.declaration ??
|
4047
|
-
|
4722
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4723
|
+
tennisClubMembershipEvent,
|
4724
|
+
ActionType.VALIDATE
|
4725
|
+
),
|
4726
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4048
4727
|
tennisClubMembershipEvent,
|
4049
4728
|
ActionType.VALIDATE
|
4050
4729
|
),
|
@@ -4078,7 +4757,7 @@ var eventPayloadGenerator = {
|
|
4078
4757
|
type: ActionType.REJECT,
|
4079
4758
|
transactionId: input.transactionId ?? getUUID(),
|
4080
4759
|
declaration: {},
|
4081
|
-
annotation: input.annotation ??
|
4760
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4082
4761
|
tennisClubMembershipEvent,
|
4083
4762
|
ActionType.REJECT
|
4084
4763
|
),
|
@@ -4088,8 +4767,11 @@ var eventPayloadGenerator = {
|
|
4088
4767
|
register: (eventId, input = {}) => ({
|
4089
4768
|
type: ActionType.REGISTER,
|
4090
4769
|
transactionId: input.transactionId ?? getUUID(),
|
4091
|
-
declaration: input.declaration ??
|
4092
|
-
|
4770
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4771
|
+
tennisClubMembershipEvent,
|
4772
|
+
ActionType.REGISTER
|
4773
|
+
),
|
4774
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4093
4775
|
tennisClubMembershipEvent,
|
4094
4776
|
ActionType.REGISTER
|
4095
4777
|
),
|
@@ -4099,7 +4781,7 @@ var eventPayloadGenerator = {
|
|
4099
4781
|
type: ActionType.PRINT_CERTIFICATE,
|
4100
4782
|
transactionId: input.transactionId ?? getUUID(),
|
4101
4783
|
declaration: {},
|
4102
|
-
annotation: input.annotation ??
|
4784
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4103
4785
|
tennisClubMembershipEvent,
|
4104
4786
|
ActionType.PRINT_CERTIFICATE
|
4105
4787
|
),
|
@@ -4109,11 +4791,11 @@ var eventPayloadGenerator = {
|
|
4109
4791
|
request: (eventId, input = {}) => ({
|
4110
4792
|
type: ActionType.REQUEST_CORRECTION,
|
4111
4793
|
transactionId: input.transactionId ?? getUUID(),
|
4112
|
-
declaration: input.declaration ??
|
4794
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4113
4795
|
tennisClubMembershipEvent,
|
4114
4796
|
ActionType.REQUEST_CORRECTION
|
4115
4797
|
),
|
4116
|
-
annotation: input.annotation ??
|
4798
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4117
4799
|
tennisClubMembershipEvent,
|
4118
4800
|
ActionType.REQUEST_CORRECTION
|
4119
4801
|
),
|
@@ -4123,7 +4805,7 @@ var eventPayloadGenerator = {
|
|
4123
4805
|
type: ActionType.APPROVE_CORRECTION,
|
4124
4806
|
transactionId: input.transactionId ?? getUUID(),
|
4125
4807
|
declaration: {},
|
4126
|
-
annotation: input.annotation ??
|
4808
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4127
4809
|
tennisClubMembershipEvent,
|
4128
4810
|
ActionType.APPROVE_CORRECTION
|
4129
4811
|
),
|
@@ -4134,7 +4816,7 @@ var eventPayloadGenerator = {
|
|
4134
4816
|
type: ActionType.REJECT_CORRECTION,
|
4135
4817
|
transactionId: input.transactionId ?? getUUID(),
|
4136
4818
|
declaration: {},
|
4137
|
-
annotation: input.annotation ??
|
4819
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4138
4820
|
tennisClubMembershipEvent,
|
4139
4821
|
ActionType.REJECT_CORRECTION
|
4140
4822
|
),
|
@@ -4154,12 +4836,14 @@ function generateActionDocument({
|
|
4154
4836
|
// @TODO: This should be fixed in the future.
|
4155
4837
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4156
4838
|
createdBy: getUUID(),
|
4839
|
+
createdByRole: "FIELD_AGENT",
|
4157
4840
|
id: getUUID(),
|
4158
|
-
createdAtLocation: "
|
4159
|
-
declaration:
|
4841
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4842
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4160
4843
|
annotation: {},
|
4161
|
-
|
4162
|
-
|
4844
|
+
status: ActionStatus.Accepted,
|
4845
|
+
transactionId: getUUID(),
|
4846
|
+
...defaults
|
4163
4847
|
};
|
4164
4848
|
switch (action) {
|
4165
4849
|
case ActionType.READ:
|
@@ -4169,7 +4853,7 @@ function generateActionDocument({
|
|
4169
4853
|
case ActionType.DECLARE:
|
4170
4854
|
return { ...actionBase, type: action };
|
4171
4855
|
case ActionType.UNASSIGN:
|
4172
|
-
return { ...actionBase, type: action };
|
4856
|
+
return { ...actionBase, type: action, assignedTo: null };
|
4173
4857
|
case ActionType.ASSIGN:
|
4174
4858
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
4175
4859
|
case ActionType.VALIDATE:
|
@@ -4217,7 +4901,8 @@ function generateEventDocument({
|
|
4217
4901
|
id: getUUID(),
|
4218
4902
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4219
4903
|
// @TODO: This should be fixed in the future.
|
4220
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4904
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4905
|
+
dateOfEvent: configuration.dateOfEvent
|
4221
4906
|
};
|
4222
4907
|
}
|
4223
4908
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4239,24 +4924,97 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4239
4924
|
eventId
|
4240
4925
|
};
|
4241
4926
|
}
|
4242
|
-
|
4243
|
-
|
4244
|
-
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4248
|
-
|
4249
|
-
|
4250
|
-
|
4251
|
-
|
4252
|
-
|
4927
|
+
function pickRandom(rng, items) {
|
4928
|
+
return items[Math.floor(rng() * items.length)];
|
4929
|
+
}
|
4930
|
+
function getRandomDatetime(rng, start, end) {
|
4931
|
+
const range = end.getTime() - start.getTime();
|
4932
|
+
const offset = Math.floor(rng() * range);
|
4933
|
+
const randomDate = new Date(start.getTime() + offset);
|
4934
|
+
return randomDate.toISOString();
|
4935
|
+
}
|
4936
|
+
function generateRandomApplicant(rng) {
|
4937
|
+
const firstNames = [
|
4938
|
+
"Danny",
|
4939
|
+
"John",
|
4940
|
+
"Jane",
|
4941
|
+
"Emily",
|
4942
|
+
"Michael",
|
4943
|
+
"Sarah",
|
4944
|
+
"Chris",
|
4945
|
+
"Jessica"
|
4946
|
+
];
|
4947
|
+
const surnames = [
|
4948
|
+
"Doe",
|
4949
|
+
"Smith",
|
4950
|
+
"Johnson",
|
4951
|
+
"Brown",
|
4952
|
+
"Williams",
|
4953
|
+
"Jones",
|
4954
|
+
"Garcia",
|
4955
|
+
"Miller"
|
4956
|
+
];
|
4957
|
+
const randomFirstName = pickRandom(rng, firstNames);
|
4958
|
+
const randomSurname = pickRandom(rng, surnames);
|
4959
|
+
const randomDob = getRandomDatetime(
|
4960
|
+
rng,
|
4961
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
4962
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
4963
|
+
).split("T")[0];
|
4964
|
+
return {
|
4253
4965
|
"recommender.none": true,
|
4254
|
-
"applicant.firstname":
|
4255
|
-
"applicant.surname":
|
4256
|
-
"applicant.dob":
|
4257
|
-
}
|
4258
|
-
|
4259
|
-
|
4966
|
+
"applicant.firstname": randomFirstName,
|
4967
|
+
"applicant.surname": randomSurname,
|
4968
|
+
"applicant.dob": randomDob
|
4969
|
+
};
|
4970
|
+
}
|
4971
|
+
function createPseudoRandomNumberGenerator(seed) {
|
4972
|
+
const MODULUS = 2 ** 32;
|
4973
|
+
const MULTIPLIER = 1664525;
|
4974
|
+
const INCREMENT = 1013904223;
|
4975
|
+
let state = seed >>> 0;
|
4976
|
+
return () => {
|
4977
|
+
state = (MULTIPLIER * state + INCREMENT) % MODULUS;
|
4978
|
+
return state / MODULUS;
|
4979
|
+
};
|
4980
|
+
}
|
4981
|
+
function generateUuid(rng) {
|
4982
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
4983
|
+
const r = Math.floor(rng() * 16);
|
4984
|
+
const v = c === "x" ? r : r & 3 | 8;
|
4985
|
+
return v.toString(16);
|
4986
|
+
});
|
4987
|
+
}
|
4988
|
+
function generateTrackingId(rng) {
|
4989
|
+
const uuid = generateUuid(rng).replace(/-/g, "");
|
4990
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4991
|
+
return trackingId;
|
4992
|
+
}
|
4993
|
+
var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
4994
|
+
const rng = createPseudoRandomNumberGenerator(seed);
|
4995
|
+
const createdAt = getRandomDatetime(
|
4996
|
+
rng,
|
4997
|
+
/* @__PURE__ */ new Date("2024-01-01"),
|
4998
|
+
/* @__PURE__ */ new Date("2024-12-31")
|
4999
|
+
);
|
5000
|
+
return {
|
5001
|
+
id: overrides.id ?? generateUuid(rng),
|
5002
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
5003
|
+
status: overrides.status ?? pickRandom(rng, eventStatuses),
|
5004
|
+
createdAt: overrides.createdAt ?? createdAt,
|
5005
|
+
createdBy: overrides.createdBy ?? generateUuid(rng),
|
5006
|
+
createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
|
5007
|
+
updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
|
5008
|
+
updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
|
5009
|
+
assignedTo: overrides.assignedTo ?? null,
|
5010
|
+
updatedBy: overrides.updatedBy ?? generateUuid(rng),
|
5011
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
5012
|
+
flags: [],
|
5013
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
5014
|
+
declaration: overrides.declaration ?? generateRandomApplicant(rng),
|
5015
|
+
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
5016
|
+
};
|
5017
|
+
};
|
4260
5018
|
var generateTranslationConfig = (message) => ({
|
4261
5019
|
defaultMessage: message,
|
4262
5020
|
description: "Description for ${message}",
|
@@ -4294,3 +5052,329 @@ function isFieldConfigDefaultValue(value) {
|
|
4294
5052
|
}
|
4295
5053
|
return false;
|
4296
5054
|
}
|
5055
|
+
|
5056
|
+
// ../commons/src/events/scopes.ts
|
5057
|
+
var import_lodash3 = require("lodash");
|
5058
|
+
|
5059
|
+
// ../commons/src/scopes.ts
|
5060
|
+
var import_zod26 = require("zod");
|
5061
|
+
var SCOPES = {
|
5062
|
+
// TODO v1.8 legacy scopes
|
5063
|
+
NATLSYSADMIN: "natlsysadmin",
|
5064
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
5065
|
+
DECLARE: "declare",
|
5066
|
+
REGISTER: "register",
|
5067
|
+
VALIDATE: "validate",
|
5068
|
+
DEMO: "demo",
|
5069
|
+
CERTIFY: "certify",
|
5070
|
+
PERFORMANCE: "performance",
|
5071
|
+
SYSADMIN: "sysadmin",
|
5072
|
+
TEAMS: "teams",
|
5073
|
+
CONFIG: "config",
|
5074
|
+
// systems / integrations
|
5075
|
+
WEBHOOK: "webhook",
|
5076
|
+
NATIONALID: "nationalId",
|
5077
|
+
NOTIFICATION_API: "notification-api",
|
5078
|
+
RECORDSEARCH: "recordsearch",
|
5079
|
+
/**
|
5080
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
5081
|
+
*/
|
5082
|
+
RECORD_DECLARE: "record.declare-birth",
|
5083
|
+
// declare
|
5084
|
+
RECORD_IMPORT: "record.import",
|
5085
|
+
// declare
|
5086
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
5087
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
5088
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
5089
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
5090
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
5091
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
5092
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
5093
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
5094
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
5095
|
+
// validate
|
5096
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
5097
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
5098
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
5099
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
5100
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
5101
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
5102
|
+
// register
|
5103
|
+
RECORD_REGISTER: "record.register",
|
5104
|
+
// certify
|
5105
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
5106
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
5107
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
5108
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
5109
|
+
// v1.8
|
5110
|
+
/**
|
5111
|
+
* This scope is used to **print and **issue certified copies of a record
|
5112
|
+
* after it has been registered. Previously Registrars had this permission.
|
5113
|
+
*/
|
5114
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
5115
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
5116
|
+
// v1.8
|
5117
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
5118
|
+
// v1.8
|
5119
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
5120
|
+
// v1.8
|
5121
|
+
// correct
|
5122
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
5123
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
5124
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
5125
|
+
// v1.8
|
5126
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
5127
|
+
// v1.8
|
5128
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
5129
|
+
// v1.8
|
5130
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
5131
|
+
// v1.8
|
5132
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
5133
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
5134
|
+
// search
|
5135
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
5136
|
+
SEARCH_BIRTH: "search.birth",
|
5137
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
5138
|
+
SEARCH_DEATH: "search.death",
|
5139
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
5140
|
+
SEARCH_MARRIAGE: "search.marriage",
|
5141
|
+
// audit v1.8
|
5142
|
+
RECORD_READ: "record.read",
|
5143
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
5144
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
5145
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
5146
|
+
// profile
|
5147
|
+
PROFILE_UPDATE: "profile.update",
|
5148
|
+
//v1.8
|
5149
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
5150
|
+
// performance
|
5151
|
+
PERFORMANCE_READ: "performance.read",
|
5152
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
5153
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
5154
|
+
// organisation
|
5155
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
5156
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
5157
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
5158
|
+
// user
|
5159
|
+
USER_READ: "user.read:all",
|
5160
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
5161
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
5162
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
5163
|
+
//v1.8
|
5164
|
+
USER_CREATE: "user.create:all",
|
5165
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
5166
|
+
USER_UPDATE: "user.update:all",
|
5167
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
5168
|
+
// config
|
5169
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
5170
|
+
// data seeding
|
5171
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
5172
|
+
};
|
5173
|
+
var LiteralScopes = import_zod26.z.union([
|
5174
|
+
import_zod26.z.literal(SCOPES.NATLSYSADMIN),
|
5175
|
+
import_zod26.z.literal(SCOPES.BYPASSRATELIMIT),
|
5176
|
+
import_zod26.z.literal(SCOPES.DECLARE),
|
5177
|
+
import_zod26.z.literal(SCOPES.REGISTER),
|
5178
|
+
import_zod26.z.literal(SCOPES.VALIDATE),
|
5179
|
+
import_zod26.z.literal(SCOPES.DEMO),
|
5180
|
+
import_zod26.z.literal(SCOPES.CERTIFY),
|
5181
|
+
import_zod26.z.literal(SCOPES.PERFORMANCE),
|
5182
|
+
import_zod26.z.literal(SCOPES.SYSADMIN),
|
5183
|
+
import_zod26.z.literal(SCOPES.TEAMS),
|
5184
|
+
import_zod26.z.literal(SCOPES.CONFIG),
|
5185
|
+
import_zod26.z.literal(SCOPES.WEBHOOK),
|
5186
|
+
import_zod26.z.literal(SCOPES.NATIONALID),
|
5187
|
+
import_zod26.z.literal(SCOPES.NOTIFICATION_API),
|
5188
|
+
import_zod26.z.literal(SCOPES.RECORDSEARCH),
|
5189
|
+
import_zod26.z.literal(SCOPES.RECORD_IMPORT),
|
5190
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
5191
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
5192
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
5193
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
5194
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
5195
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
5196
|
+
import_zod26.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
5197
|
+
import_zod26.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
5198
|
+
import_zod26.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
5199
|
+
import_zod26.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
5200
|
+
import_zod26.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
5201
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
5202
|
+
import_zod26.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
5203
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
5204
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
5205
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTER),
|
5206
|
+
import_zod26.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
5207
|
+
import_zod26.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
5208
|
+
import_zod26.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
5209
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
5210
|
+
import_zod26.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
5211
|
+
import_zod26.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
5212
|
+
import_zod26.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
5213
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
5214
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
5215
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
5216
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
5217
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
5218
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
5219
|
+
import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
5220
|
+
import_zod26.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
5221
|
+
import_zod26.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
5222
|
+
import_zod26.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
5223
|
+
import_zod26.z.literal(SCOPES.SEARCH_BIRTH),
|
5224
|
+
import_zod26.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
5225
|
+
import_zod26.z.literal(SCOPES.SEARCH_DEATH),
|
5226
|
+
import_zod26.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
5227
|
+
import_zod26.z.literal(SCOPES.SEARCH_MARRIAGE),
|
5228
|
+
import_zod26.z.literal(SCOPES.RECORD_READ),
|
5229
|
+
import_zod26.z.literal(SCOPES.RECORD_READ_AUDIT),
|
5230
|
+
import_zod26.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
5231
|
+
import_zod26.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
5232
|
+
import_zod26.z.literal(SCOPES.PROFILE_UPDATE),
|
5233
|
+
import_zod26.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
5234
|
+
import_zod26.z.literal(SCOPES.PERFORMANCE_READ),
|
5235
|
+
import_zod26.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
5236
|
+
import_zod26.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
5237
|
+
import_zod26.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
5238
|
+
import_zod26.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
5239
|
+
import_zod26.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
5240
|
+
import_zod26.z.literal(SCOPES.USER_READ),
|
5241
|
+
import_zod26.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
5242
|
+
import_zod26.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
5243
|
+
import_zod26.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
5244
|
+
import_zod26.z.literal(SCOPES.USER_CREATE),
|
5245
|
+
import_zod26.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
5246
|
+
import_zod26.z.literal(SCOPES.USER_UPDATE),
|
5247
|
+
import_zod26.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
5248
|
+
import_zod26.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
5249
|
+
import_zod26.z.literal(SCOPES.USER_DATA_SEEDING)
|
5250
|
+
]);
|
5251
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
5252
|
+
var rawConfigurableScope = import_zod26.z.string().regex(rawConfigurableScopeRegex);
|
5253
|
+
var CreateUserScope = import_zod26.z.object({
|
5254
|
+
type: import_zod26.z.literal("user.create"),
|
5255
|
+
options: import_zod26.z.object({
|
5256
|
+
role: import_zod26.z.array(import_zod26.z.string())
|
5257
|
+
})
|
5258
|
+
});
|
5259
|
+
var EditUserScope = import_zod26.z.object({
|
5260
|
+
type: import_zod26.z.literal("user.edit"),
|
5261
|
+
options: import_zod26.z.object({
|
5262
|
+
role: import_zod26.z.array(import_zod26.z.string())
|
5263
|
+
})
|
5264
|
+
});
|
5265
|
+
var WorkqueueScope = import_zod26.z.object({
|
5266
|
+
type: import_zod26.z.literal("workqueue"),
|
5267
|
+
options: import_zod26.z.object({
|
5268
|
+
id: import_zod26.z.array(import_zod26.z.string())
|
5269
|
+
})
|
5270
|
+
});
|
5271
|
+
var NotifyRecordScope = import_zod26.z.object({
|
5272
|
+
type: import_zod26.z.literal("record.notify"),
|
5273
|
+
options: import_zod26.z.object({
|
5274
|
+
event: import_zod26.z.array(import_zod26.z.string())
|
5275
|
+
})
|
5276
|
+
});
|
5277
|
+
var ConfigurableScopes = import_zod26.z.discriminatedUnion("type", [
|
5278
|
+
CreateUserScope,
|
5279
|
+
EditUserScope,
|
5280
|
+
WorkqueueScope,
|
5281
|
+
NotifyRecordScope
|
5282
|
+
]);
|
5283
|
+
var scopes = Object.values(SCOPES);
|
5284
|
+
|
5285
|
+
// ../commons/src/events/scopes.ts
|
5286
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
5287
|
+
SCOPES.RECORD_DECLARE,
|
5288
|
+
SCOPES.RECORD_READ,
|
5289
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5290
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5291
|
+
SCOPES.RECORD_REGISTER,
|
5292
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
5293
|
+
SCOPES.CONFIG,
|
5294
|
+
SCOPES.CONFIG_UPDATE_ALL
|
5295
|
+
];
|
5296
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
5297
|
+
SCOPES.SEARCH_BIRTH,
|
5298
|
+
SCOPES.SEARCH_DEATH,
|
5299
|
+
SCOPES.SEARCH_MARRIAGE,
|
5300
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
5301
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
5302
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
5303
|
+
];
|
5304
|
+
var ACTION_ALLOWED_SCOPES = {
|
5305
|
+
[ActionType.READ]: [
|
5306
|
+
SCOPES.RECORD_DECLARE,
|
5307
|
+
SCOPES.RECORD_READ,
|
5308
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5309
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5310
|
+
SCOPES.RECORD_REGISTER,
|
5311
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
5312
|
+
],
|
5313
|
+
[ActionType.CREATE]: [
|
5314
|
+
SCOPES.RECORD_DECLARE,
|
5315
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5316
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
5317
|
+
],
|
5318
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
5319
|
+
[ActionType.DECLARE]: [
|
5320
|
+
SCOPES.RECORD_DECLARE,
|
5321
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5322
|
+
SCOPES.RECORD_REGISTER
|
5323
|
+
],
|
5324
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
5325
|
+
[ActionType.VALIDATE]: [
|
5326
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5327
|
+
SCOPES.RECORD_REGISTER
|
5328
|
+
],
|
5329
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
5330
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
5331
|
+
[ActionType.REQUEST_CORRECTION]: [
|
5332
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
5333
|
+
],
|
5334
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5335
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5336
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5337
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5338
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
5339
|
+
[ActionType.ASSIGN]: null,
|
5340
|
+
[ActionType.UNASSIGN]: null,
|
5341
|
+
[ActionType.DETECT_DUPLICATE]: []
|
5342
|
+
};
|
5343
|
+
var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
|
5344
|
+
[ActionType.READ]: [],
|
5345
|
+
[ActionType.CREATE]: ["record.notify"],
|
5346
|
+
[ActionType.NOTIFY]: ["record.notify"],
|
5347
|
+
[ActionType.DECLARE]: [],
|
5348
|
+
[ActionType.DELETE]: [],
|
5349
|
+
[ActionType.VALIDATE]: [],
|
5350
|
+
[ActionType.REGISTER]: [],
|
5351
|
+
[ActionType.PRINT_CERTIFICATE]: [],
|
5352
|
+
[ActionType.REQUEST_CORRECTION]: [],
|
5353
|
+
[ActionType.REJECT_CORRECTION]: [],
|
5354
|
+
[ActionType.APPROVE_CORRECTION]: [],
|
5355
|
+
[ActionType.MARKED_AS_DUPLICATE]: [],
|
5356
|
+
[ActionType.ARCHIVE]: [],
|
5357
|
+
[ActionType.REJECT]: [],
|
5358
|
+
[ActionType.ASSIGN]: [],
|
5359
|
+
[ActionType.UNASSIGN]: [],
|
5360
|
+
[ActionType.DETECT_DUPLICATE]: []
|
5361
|
+
};
|
5362
|
+
function hasAnyOfScopes(a, b) {
|
5363
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
5364
|
+
}
|
5365
|
+
function filterUnallowedActions(actions, userScopes) {
|
5366
|
+
const allowedActions = actions.filter((action) => {
|
5367
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
5368
|
+
if (requiredScopes === null) {
|
5369
|
+
return true;
|
5370
|
+
}
|
5371
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
5372
|
+
});
|
5373
|
+
const hasOtherAllowedActions = allowedActions.some(
|
5374
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
5375
|
+
);
|
5376
|
+
if (hasOtherAllowedActions) {
|
5377
|
+
return allowedActions;
|
5378
|
+
}
|
5379
|
+
return [ActionType.READ];
|
5380
|
+
}
|