@opencrvs/toolkit 1.8.0-rc.f8e4107 → 1.8.0-rc.f966df9
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 +8083 -4833
- package/dist/commons/conditionals/conditionals.d.ts +7 -69
- package/dist/commons/conditionals/validate.d.ts +4 -6
- package/dist/commons/events/ActionConfig.d.ts +90025 -1680
- package/dist/commons/events/ActionDocument.d.ts +643 -417
- package/dist/commons/events/ActionInput.d.ts +248 -240
- package/dist/commons/events/AdvancedSearchConfig.d.ts +274 -23
- package/dist/commons/events/CompositeFieldValue.d.ts +3 -0
- package/dist/commons/events/Draft.d.ts +38 -30
- package/dist/commons/events/EventConfig.d.ts +42787 -1385
- package/dist/commons/events/EventDocument.d.ts +413 -312
- package/dist/commons/events/EventIndex.d.ts +862 -155
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +271 -11
- package/dist/commons/events/FieldConfig.d.ts +3778 -769
- 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 +40417 -439
- package/dist/commons/events/PageConfig.d.ts +10077 -203
- package/dist/commons/events/SummaryConfig.d.ts +95 -39
- package/dist/commons/events/User.d.ts +5 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +1257 -19
- package/dist/commons/events/defineConfig.d.ts +7008 -81
- package/dist/commons/events/event.d.ts +27 -0
- package/dist/commons/events/field.d.ts +68 -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 +7 -44
- package/dist/commons/events/utils.d.ts +3551 -65
- package/dist/conditionals/index.js +35 -81
- package/dist/events/index.js +1691 -1021
- package/dist/scopes/index.d.ts +137 -1
- package/dist/scopes/index.js +147 -0
- 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,19 +78,26 @@ __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,
|
75
85
|
EmailField: () => EmailField,
|
76
86
|
EmailValue: () => EmailValue,
|
77
87
|
EnableConditional: () => EnableConditional,
|
78
|
-
EventConfig: () =>
|
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,
|
@@ -92,6 +108,7 @@ __export(events_exports, {
|
|
92
108
|
FileFieldValue: () => FileFieldValue,
|
93
109
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
94
110
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
111
|
+
Flag: () => Flag,
|
95
112
|
FormConfig: () => FormConfig,
|
96
113
|
FormPageConfig: () => FormPageConfig,
|
97
114
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
@@ -99,8 +116,10 @@ __export(events_exports, {
|
|
99
116
|
GeographicalArea: () => GeographicalArea,
|
100
117
|
ImageMimeType: () => ImageMimeType,
|
101
118
|
LanguageConfig: () => LanguageConfig,
|
119
|
+
LegalStatuses: () => LegalStatuses,
|
102
120
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
103
121
|
MimeType: () => MimeType,
|
122
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
104
123
|
NotifyActionInput: () => NotifyActionInput,
|
105
124
|
NumberFieldValue: () => NumberFieldValue,
|
106
125
|
PageConfig: () => PageConfig,
|
@@ -111,13 +130,14 @@ __export(events_exports, {
|
|
111
130
|
ReadActionInput: () => ReadActionInput,
|
112
131
|
RegisterAction: () => RegisterAction,
|
113
132
|
RegisterActionInput: () => RegisterActionInput,
|
133
|
+
RegistrationCreationMetadata: () => RegistrationCreationMetadata,
|
114
134
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
115
135
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
116
136
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
117
|
-
RequiredTextValue: () => RequiredTextValue,
|
118
137
|
ResolvedUser: () => ResolvedUser,
|
119
138
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
120
139
|
RuralAddressValue: () => RuralAddressValue,
|
140
|
+
SearchField: () => SearchField,
|
121
141
|
SelectOption: () => SelectOption,
|
122
142
|
ShowConditional: () => ShowConditional,
|
123
143
|
SummaryConfig: () => SummaryConfig,
|
@@ -130,12 +150,16 @@ __export(events_exports, {
|
|
130
150
|
VerificationActionConfig: () => VerificationActionConfig,
|
131
151
|
VerificationPageConfig: () => VerificationPageConfig,
|
132
152
|
WorkqueueConfig: () => WorkqueueConfig,
|
153
|
+
ZodDate: () => ZodDate,
|
133
154
|
alwaysTrue: () => alwaysTrue,
|
134
155
|
and: () => and,
|
135
156
|
annotationActions: () => annotationActions,
|
136
157
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
158
|
+
areConditionsMet: () => areConditionsMet,
|
137
159
|
compositeFieldTypes: () => compositeFieldTypes,
|
138
160
|
createEmptyDraft: () => createEmptyDraft,
|
161
|
+
createEventConditionals: () => createEventConditionals,
|
162
|
+
createFieldConditionals: () => createFieldConditionals,
|
139
163
|
createValidationSchema: () => createValidationSchema,
|
140
164
|
deepDropNulls: () => deepDropNulls,
|
141
165
|
deepMerge: () => deepMerge,
|
@@ -146,16 +170,18 @@ __export(events_exports, {
|
|
146
170
|
defineFormConditional: () => defineFormConditional,
|
147
171
|
defineFormPage: () => defineFormPage,
|
148
172
|
definePage: () => definePage,
|
173
|
+
defineWorkqueue: () => defineWorkqueue,
|
149
174
|
errorMessages: () => errorMessages,
|
150
175
|
event: () => event,
|
151
|
-
eventField: () => eventField,
|
152
176
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
153
177
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
154
178
|
eventQueryDataGenerator: () => eventQueryDataGenerator,
|
155
179
|
eventStatuses: () => eventStatuses,
|
156
180
|
field: () => field,
|
157
181
|
fieldTypes: () => fieldTypes,
|
182
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
158
183
|
findActiveDrafts: () => findActiveDrafts,
|
184
|
+
findAllFields: () => findAllFields,
|
159
185
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
160
186
|
findRecordActionPages: () => findRecordActionPages,
|
161
187
|
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
@@ -170,21 +196,26 @@ __export(events_exports, {
|
|
170
196
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
171
197
|
getActionReview: () => getActionReview,
|
172
198
|
getActionReviewFields: () => getActionReviewFields,
|
173
|
-
|
199
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
174
200
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
201
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
175
202
|
getCurrentEventState: () => getCurrentEventState,
|
176
203
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
177
204
|
getDeclaration: () => getDeclaration,
|
178
205
|
getDeclarationFields: () => getDeclarationFields,
|
179
206
|
getDeclarationPages: () => getDeclarationPages,
|
180
|
-
|
207
|
+
getMixedPath: () => getMixedPath,
|
208
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
209
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
181
210
|
isAddressFieldType: () => isAddressFieldType,
|
182
211
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
183
212
|
isBulletListFieldType: () => isBulletListFieldType,
|
184
213
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
214
|
+
isConditionMet: () => isConditionMet,
|
185
215
|
isCountryFieldType: () => isCountryFieldType,
|
186
216
|
isDataFieldType: () => isDataFieldType,
|
187
217
|
isDateFieldType: () => isDateFieldType,
|
218
|
+
isDateRangeFieldType: () => isDateRangeFieldType,
|
188
219
|
isDividerFieldType: () => isDividerFieldType,
|
189
220
|
isEmailFieldType: () => isEmailFieldType,
|
190
221
|
isFacilityFieldType: () => isFacilityFieldType,
|
@@ -216,13 +247,14 @@ __export(events_exports, {
|
|
216
247
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
217
248
|
never: () => never,
|
218
249
|
not: () => not,
|
250
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
219
251
|
omitHiddenFields: () => omitHiddenFields,
|
220
252
|
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
221
253
|
or: () => or,
|
254
|
+
runFieldValidations: () => runFieldValidations,
|
222
255
|
user: () => user,
|
223
256
|
validate: () => validate,
|
224
257
|
validateFieldInput: () => validateFieldInput,
|
225
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
226
258
|
writeActions: () => writeActions
|
227
259
|
});
|
228
260
|
module.exports = __toCommonJS(events_exports);
|
@@ -232,9 +264,12 @@ var import_zod9 = require("zod");
|
|
232
264
|
|
233
265
|
// ../commons/src/events/Conditional.ts
|
234
266
|
var import_zod = require("zod");
|
235
|
-
var
|
236
|
-
|
237
|
-
)
|
267
|
+
var import_zod_openapi = require("zod-openapi");
|
268
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod.z);
|
269
|
+
var Conditional = import_zod.z.custom((val) => typeof val === "object" && val !== null).openapi({
|
270
|
+
description: "JSON schema conditional configuration",
|
271
|
+
ref: "Conditional"
|
272
|
+
});
|
238
273
|
var ConditionalType = {
|
239
274
|
SHOW: "SHOW",
|
240
275
|
ENABLE: "ENABLE",
|
@@ -271,7 +306,10 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
|
271
306
|
EnableConditional,
|
272
307
|
// Field output can be shown / hidden on the review page
|
273
308
|
DisplayOnReviewConditional
|
274
|
-
])
|
309
|
+
]).openapi({
|
310
|
+
description: "Field conditional configuration",
|
311
|
+
ref: "FieldConditional"
|
312
|
+
});
|
275
313
|
|
276
314
|
// ../commons/src/events/PageConfig.ts
|
277
315
|
var import_zod6 = require("zod");
|
@@ -281,6 +319,8 @@ var import_zod5 = require("zod");
|
|
281
319
|
|
282
320
|
// ../commons/src/events/TranslationConfig.ts
|
283
321
|
var import_zod2 = require("zod");
|
322
|
+
var import_zod_openapi2 = require("zod-openapi");
|
323
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod2.z);
|
284
324
|
var TranslationConfig = import_zod2.z.object({
|
285
325
|
id: import_zod2.z.string().describe(
|
286
326
|
"The identifier of the translation referred in translation CSV files"
|
@@ -289,6 +329,9 @@ var TranslationConfig = import_zod2.z.object({
|
|
289
329
|
description: import_zod2.z.string().describe(
|
290
330
|
"Describe the translation for a translator to be able to identify it."
|
291
331
|
)
|
332
|
+
}).openapi({
|
333
|
+
description: "Translation configuration",
|
334
|
+
ref: "TranslationConfig"
|
292
335
|
});
|
293
336
|
|
294
337
|
// ../commons/src/events/FieldType.ts
|
@@ -299,12 +342,12 @@ var FieldType = {
|
|
299
342
|
TEXTAREA: "TEXTAREA",
|
300
343
|
EMAIL: "EMAIL",
|
301
344
|
DATE: "DATE",
|
345
|
+
DATE_RANGE: "DATE_RANGE",
|
302
346
|
PARAGRAPH: "PARAGRAPH",
|
303
347
|
PAGE_HEADER: "PAGE_HEADER",
|
304
348
|
RADIO_GROUP: "RADIO_GROUP",
|
305
349
|
FILE: "FILE",
|
306
350
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
307
|
-
HIDDEN: "HIDDEN",
|
308
351
|
BULLET_LIST: "BULLET_LIST",
|
309
352
|
CHECKBOX: "CHECKBOX",
|
310
353
|
SELECT: "SELECT",
|
@@ -319,6 +362,7 @@ var FieldType = {
|
|
319
362
|
};
|
320
363
|
var fieldTypes = Object.values(FieldType);
|
321
364
|
var compositeFieldTypes = [
|
365
|
+
FieldType.DATE_RANGE,
|
322
366
|
FieldType.ADDRESS,
|
323
367
|
FieldType.FILE_WITH_OPTIONS,
|
324
368
|
FieldType.FILE
|
@@ -409,8 +453,10 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
409
453
|
|
410
454
|
// ../commons/src/events/FieldValue.ts
|
411
455
|
var TextValue = import_zod4.z.string();
|
412
|
-
var
|
456
|
+
var NonEmptyTextValue = TextValue.min(1);
|
413
457
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
458
|
+
var DatetimeValue = import_zod4.z.string().datetime();
|
459
|
+
var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
|
414
460
|
var EmailValue = import_zod4.z.string().email();
|
415
461
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
416
462
|
var NumberFieldValue = import_zod4.z.number();
|
@@ -418,6 +464,7 @@ var DataFieldValue = import_zod4.z.undefined();
|
|
418
464
|
var FieldValue = import_zod4.z.union([
|
419
465
|
TextValue,
|
420
466
|
DateValue,
|
467
|
+
DateRangeFieldValue,
|
421
468
|
CheckboxFieldValue,
|
422
469
|
NumberFieldValue,
|
423
470
|
FileFieldValue,
|
@@ -430,6 +477,7 @@ var FieldValue = import_zod4.z.union([
|
|
430
477
|
var FieldUpdateValue = import_zod4.z.union([
|
431
478
|
TextValue,
|
432
479
|
DateValue,
|
480
|
+
DateRangeFieldValue,
|
433
481
|
CheckboxFieldValue,
|
434
482
|
NumberFieldValue,
|
435
483
|
FileFieldValue,
|
@@ -441,28 +489,24 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
441
489
|
]);
|
442
490
|
|
443
491
|
// ../commons/src/events/FieldConfig.ts
|
492
|
+
var import_zod_openapi3 = require("zod-openapi");
|
493
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
|
444
494
|
var FieldId = import_zod5.z.string();
|
445
|
-
var
|
446
|
-
|
447
|
-
|
448
|
-
});
|
495
|
+
var ParentReference = import_zod5.z.object({
|
496
|
+
_fieldId: FieldId.optional()
|
497
|
+
}).optional();
|
449
498
|
var BaseField = import_zod5.z.object({
|
450
499
|
id: FieldId,
|
451
500
|
defaultValue: import_zod5.z.union([
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
NumberFieldValue,
|
458
|
-
CheckboxFieldValue
|
459
|
-
]),
|
460
|
-
DependencyExpression
|
501
|
+
TextValue,
|
502
|
+
NonEmptyTextValue,
|
503
|
+
DateValue,
|
504
|
+
NumberFieldValue,
|
505
|
+
CheckboxFieldValue
|
461
506
|
]).optional(),
|
507
|
+
parent: ParentReference,
|
462
508
|
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
463
509
|
required: import_zod5.z.boolean().default(false).optional(),
|
464
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
465
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
466
510
|
placeholder: TranslationConfig.optional(),
|
467
511
|
validation: import_zod5.z.array(
|
468
512
|
import_zod5.z.object({
|
@@ -470,7 +514,6 @@ var BaseField = import_zod5.z.object({
|
|
470
514
|
message: TranslationConfig
|
471
515
|
})
|
472
516
|
).default([]).optional(),
|
473
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
474
517
|
label: TranslationConfig,
|
475
518
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
476
519
|
});
|
@@ -479,7 +522,7 @@ var Divider = BaseField.extend({
|
|
479
522
|
});
|
480
523
|
var TextField = BaseField.extend({
|
481
524
|
type: import_zod5.z.literal(FieldType.TEXT),
|
482
|
-
defaultValue:
|
525
|
+
defaultValue: NonEmptyTextValue.optional(),
|
483
526
|
configuration: import_zod5.z.object({
|
484
527
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
485
528
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -489,7 +532,7 @@ var TextField = BaseField.extend({
|
|
489
532
|
}).describe("Text input");
|
490
533
|
var NumberField = BaseField.extend({
|
491
534
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
492
|
-
defaultValue:
|
535
|
+
defaultValue: NumberFieldValue.optional(),
|
493
536
|
configuration: import_zod5.z.object({
|
494
537
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
495
538
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -499,7 +542,7 @@ var NumberField = BaseField.extend({
|
|
499
542
|
}).describe("Number input");
|
500
543
|
var TextAreaField = BaseField.extend({
|
501
544
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
502
|
-
defaultValue:
|
545
|
+
defaultValue: NonEmptyTextValue.optional(),
|
503
546
|
configuration: import_zod5.z.object({
|
504
547
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
505
548
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -533,17 +576,28 @@ var EmailField = BaseField.extend({
|
|
533
576
|
configuration: import_zod5.z.object({
|
534
577
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
535
578
|
}).default({ maxLength: 10 }).optional(),
|
536
|
-
defaultValue:
|
579
|
+
defaultValue: NonEmptyTextValue.optional()
|
537
580
|
});
|
538
581
|
var DateField = BaseField.extend({
|
539
582
|
type: import_zod5.z.literal(FieldType.DATE),
|
540
|
-
defaultValue:
|
583
|
+
defaultValue: DateValue.optional(),
|
541
584
|
configuration: import_zod5.z.object({
|
542
585
|
notice: TranslationConfig.describe(
|
543
586
|
"Text to display above the date input"
|
544
587
|
).optional()
|
545
588
|
}).optional()
|
546
589
|
}).describe("A single date input (dd-mm-YYYY)");
|
590
|
+
var DateRangeField = BaseField.extend({
|
591
|
+
type: import_zod5.z.literal(FieldType.DATE_RANGE),
|
592
|
+
defaultValue: DateRangeFieldValue.optional(),
|
593
|
+
configuration: import_zod5.z.object({
|
594
|
+
notice: TranslationConfig.describe(
|
595
|
+
"Text to display above the date input"
|
596
|
+
).optional()
|
597
|
+
}).optional()
|
598
|
+
}).describe(
|
599
|
+
"A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
|
600
|
+
);
|
547
601
|
var HtmlFontVariant = import_zod5.z.enum([
|
548
602
|
"reg12",
|
549
603
|
"reg14",
|
@@ -556,7 +610,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
556
610
|
]);
|
557
611
|
var Paragraph = BaseField.extend({
|
558
612
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
559
|
-
defaultValue:
|
613
|
+
defaultValue: NonEmptyTextValue.optional(),
|
560
614
|
configuration: import_zod5.z.object({
|
561
615
|
styles: import_zod5.z.object({
|
562
616
|
fontVariant: HtmlFontVariant.optional()
|
@@ -565,7 +619,7 @@ var Paragraph = BaseField.extend({
|
|
565
619
|
}).describe("A read-only HTML <p> paragraph");
|
566
620
|
var PageHeader = BaseField.extend({
|
567
621
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
568
|
-
defaultValue:
|
622
|
+
defaultValue: NonEmptyTextValue.optional()
|
569
623
|
}).describe("A read-only header component for form pages");
|
570
624
|
var File = BaseField.extend({
|
571
625
|
type: import_zod5.z.literal(FieldType.FILE),
|
@@ -576,7 +630,8 @@ var File = BaseField.extend({
|
|
576
630
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
577
631
|
"Whether the file upload button should take the full width of the container or not"
|
578
632
|
)
|
579
|
-
}).optional()
|
633
|
+
}).optional(),
|
634
|
+
fileName: TranslationConfig.optional()
|
580
635
|
}).default({
|
581
636
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
582
637
|
})
|
@@ -587,7 +642,7 @@ var SelectOption = import_zod5.z.object({
|
|
587
642
|
});
|
588
643
|
var RadioGroup = BaseField.extend({
|
589
644
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
590
|
-
defaultValue:
|
645
|
+
defaultValue: TextValue.optional(),
|
591
646
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
592
647
|
configuration: import_zod5.z.object({
|
593
648
|
styles: import_zod5.z.object({
|
@@ -597,7 +652,7 @@ var RadioGroup = BaseField.extend({
|
|
597
652
|
}).describe("Grouped radio options");
|
598
653
|
var BulletList = BaseField.extend({
|
599
654
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
600
|
-
defaultValue:
|
655
|
+
defaultValue: TextValue.optional(),
|
601
656
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
602
657
|
configuration: import_zod5.z.object({
|
603
658
|
styles: import_zod5.z.object({
|
@@ -607,16 +662,16 @@ var BulletList = BaseField.extend({
|
|
607
662
|
}).describe("A list of bullet points");
|
608
663
|
var Select = BaseField.extend({
|
609
664
|
type: import_zod5.z.literal(FieldType.SELECT),
|
610
|
-
defaultValue:
|
665
|
+
defaultValue: TextValue.optional(),
|
611
666
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
612
667
|
}).describe("Select input");
|
613
668
|
var Checkbox = BaseField.extend({
|
614
669
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
615
|
-
defaultValue:
|
670
|
+
defaultValue: CheckboxFieldValue.optional()
|
616
671
|
}).describe("Boolean checkbox field");
|
617
672
|
var Country = BaseField.extend({
|
618
673
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
619
|
-
defaultValue:
|
674
|
+
defaultValue: NonEmptyTextValue.optional()
|
620
675
|
}).describe("Country select field");
|
621
676
|
var AdministrativeAreas = import_zod5.z.enum([
|
622
677
|
"ADMIN_STRUCTURE",
|
@@ -631,12 +686,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
|
|
631
686
|
}).describe("Administrative area options");
|
632
687
|
var AdministrativeArea = BaseField.extend({
|
633
688
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
634
|
-
defaultValue:
|
689
|
+
defaultValue: NonEmptyTextValue.optional(),
|
635
690
|
configuration: AdministrativeAreaConfiguration
|
636
691
|
}).describe("Administrative area input field e.g. facility, office");
|
637
692
|
var Location = BaseField.extend({
|
638
693
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
639
|
-
defaultValue:
|
694
|
+
defaultValue: NonEmptyTextValue.optional()
|
640
695
|
}).describe("Input field for a location");
|
641
696
|
var FileUploadWithOptions = BaseField.extend({
|
642
697
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
@@ -650,11 +705,11 @@ var FileUploadWithOptions = BaseField.extend({
|
|
650
705
|
});
|
651
706
|
var Facility = BaseField.extend({
|
652
707
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
653
|
-
defaultValue:
|
708
|
+
defaultValue: NonEmptyTextValue.optional()
|
654
709
|
}).describe("Input field for a facility");
|
655
710
|
var Office = BaseField.extend({
|
656
711
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
657
|
-
defaultValue:
|
712
|
+
defaultValue: NonEmptyTextValue.optional()
|
658
713
|
}).describe("Input field for an office");
|
659
714
|
var Address = BaseField.extend({
|
660
715
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
@@ -663,7 +718,7 @@ var Address = BaseField.extend({
|
|
663
718
|
var DataEntry = import_zod5.z.union([
|
664
719
|
import_zod5.z.object({
|
665
720
|
label: TranslationConfig,
|
666
|
-
value: import_zod5.z.string()
|
721
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
667
722
|
}),
|
668
723
|
import_zod5.z.object({
|
669
724
|
fieldId: import_zod5.z.string()
|
@@ -682,6 +737,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
682
737
|
NumberField,
|
683
738
|
TextAreaField,
|
684
739
|
DateField,
|
740
|
+
DateRangeField,
|
685
741
|
Paragraph,
|
686
742
|
RadioGroup,
|
687
743
|
BulletList,
|
@@ -699,10 +755,14 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
699
755
|
EmailField,
|
700
756
|
FileUploadWithOptions,
|
701
757
|
DataField
|
702
|
-
|
703
|
-
|
758
|
+
]).openapi({
|
759
|
+
description: "Form field configuration",
|
760
|
+
ref: "FieldConfig"
|
761
|
+
});
|
704
762
|
|
705
763
|
// ../commons/src/events/PageConfig.ts
|
764
|
+
var import_zod_openapi4 = require("zod-openapi");
|
765
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
|
706
766
|
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
707
767
|
var PageConfigBase = import_zod6.z.object({
|
708
768
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
@@ -711,6 +771,9 @@ var PageConfigBase = import_zod6.z.object({
|
|
711
771
|
conditional: Conditional.optional().describe(
|
712
772
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
713
773
|
)
|
774
|
+
}).openapi({
|
775
|
+
description: "Form page configuration",
|
776
|
+
ref: "FormPageConfig"
|
714
777
|
});
|
715
778
|
var FormPageConfig = PageConfigBase.extend({
|
716
779
|
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
@@ -724,7 +787,10 @@ var VerificationActionConfig = import_zod6.z.object({
|
|
724
787
|
body: TranslationConfig
|
725
788
|
})
|
726
789
|
})
|
727
|
-
}).describe("Actions available on the verification page")
|
790
|
+
}).describe("Actions available on the verification page").openapi({
|
791
|
+
description: "Verification action configuration",
|
792
|
+
ref: "VerificationActionConfig"
|
793
|
+
});
|
728
794
|
var VerificationPageConfig = FormPageConfig.extend({
|
729
795
|
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
730
796
|
actions: VerificationActionConfig
|
@@ -824,6 +890,8 @@ var ActionFormConfig = import_zod8.z.object({
|
|
824
890
|
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
825
891
|
|
826
892
|
// ../commons/src/events/ActionConfig.ts
|
893
|
+
var import_zod_openapi5 = require("zod-openapi");
|
894
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
|
827
895
|
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
828
896
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
829
897
|
ShowConditional,
|
@@ -901,18 +969,24 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
|
|
901
969
|
})
|
902
970
|
);
|
903
971
|
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
972
|
+
/*
|
973
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
974
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
975
|
+
*/
|
976
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
977
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
978
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
979
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
980
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
981
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
982
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
983
|
+
PrintCertificateActionConfig.openapi({
|
984
|
+
ref: "PrintCertificateActionConfig"
|
985
|
+
}),
|
986
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
987
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
988
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
989
|
+
]).openapi({ ref: "ActionConfig" });
|
916
990
|
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
917
991
|
DeclareConfig,
|
918
992
|
ValidateConfig,
|
@@ -960,6 +1034,8 @@ var import_zod17 = require("zod");
|
|
960
1034
|
|
961
1035
|
// ../commons/src/events/DeduplicationConfig.ts
|
962
1036
|
var import_zod12 = require("zod");
|
1037
|
+
var import_zod_openapi6 = require("zod-openapi");
|
1038
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
|
963
1039
|
var FieldReference = import_zod12.z.string();
|
964
1040
|
var Matcher = import_zod12.z.object({
|
965
1041
|
fieldId: import_zod12.z.string(),
|
@@ -1020,7 +1096,9 @@ var Clause = import_zod12.z.lazy(
|
|
1020
1096
|
DateRangeMatcher,
|
1021
1097
|
DateDistanceMatcher
|
1022
1098
|
])
|
1023
|
-
)
|
1099
|
+
).openapi({
|
1100
|
+
ref: "Clause"
|
1101
|
+
});
|
1024
1102
|
var DeduplicationConfig = import_zod12.z.object({
|
1025
1103
|
id: import_zod12.z.string(),
|
1026
1104
|
label: TranslationConfig,
|
@@ -1029,686 +1107,214 @@ var DeduplicationConfig = import_zod12.z.object({
|
|
1029
1107
|
|
1030
1108
|
// ../commons/src/events/SummaryConfig.ts
|
1031
1109
|
var import_zod13 = require("zod");
|
1032
|
-
var
|
1110
|
+
var BaseField2 = import_zod13.z.object({
|
1111
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1112
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1113
|
+
});
|
1114
|
+
var ReferenceField = BaseField2.extend({
|
1115
|
+
fieldId: import_zod13.z.string(),
|
1116
|
+
label: TranslationConfig.optional().describe(
|
1117
|
+
"By default, the configured field's label is used. This can be overridden by providing a custom label."
|
1118
|
+
)
|
1119
|
+
}).describe("Field directly referencing event data with field id");
|
1120
|
+
var Field = BaseField2.extend({
|
1033
1121
|
id: import_zod13.z.string().describe("Id of summary field"),
|
1034
1122
|
value: TranslationConfig.describe(
|
1035
1123
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1036
1124
|
),
|
1037
1125
|
label: TranslationConfig,
|
1038
1126
|
emptyValueMessage: TranslationConfig.optional()
|
1039
|
-
});
|
1040
|
-
var Title = import_zod13.z.object({
|
1041
|
-
id: import_zod13.z.string(),
|
1042
|
-
label: TranslationConfig.describe("Title content"),
|
1043
|
-
emptyValueMessage: TranslationConfig.optional()
|
1044
|
-
});
|
1127
|
+
}).describe("Custom configured field");
|
1045
1128
|
var SummaryConfig = import_zod13.z.object({
|
1046
|
-
|
1047
|
-
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
1129
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
1048
1130
|
}).describe("Configuration for summary in event.");
|
1049
1131
|
|
1050
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1051
|
-
var import_zod15 = require("zod");
|
1052
|
-
|
1053
|
-
// ../commons/src/events/EventMetadata.ts
|
1054
|
-
var import_zod14 = require("zod");
|
1055
|
-
var EventStatus = {
|
1056
|
-
CREATED: "CREATED",
|
1057
|
-
NOTIFIED: "NOTIFIED",
|
1058
|
-
DECLARED: "DECLARED",
|
1059
|
-
VALIDATED: "VALIDATED",
|
1060
|
-
REGISTERED: "REGISTERED",
|
1061
|
-
CERTIFIED: "CERTIFIED",
|
1062
|
-
REJECTED: "REJECTED",
|
1063
|
-
ARCHIVED: "ARCHIVED"
|
1064
|
-
};
|
1065
|
-
var eventStatuses = Object.values(EventStatus);
|
1066
|
-
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1067
|
-
var EventMetadata = import_zod14.z.object({
|
1068
|
-
id: import_zod14.z.string(),
|
1069
|
-
type: import_zod14.z.string(),
|
1070
|
-
status: EventStatuses,
|
1071
|
-
createdAt: import_zod14.z.string().datetime(),
|
1072
|
-
createdBy: import_zod14.z.string(),
|
1073
|
-
createdAtLocation: import_zod14.z.string(),
|
1074
|
-
updatedAtLocation: import_zod14.z.string(),
|
1075
|
-
updatedAt: import_zod14.z.string().datetime(),
|
1076
|
-
assignedTo: import_zod14.z.string().nullish(),
|
1077
|
-
updatedBy: import_zod14.z.string(),
|
1078
|
-
trackingId: import_zod14.z.string(),
|
1079
|
-
registrationNumber: import_zod14.z.string().nullish()
|
1080
|
-
});
|
1081
|
-
var eventMetadataLabelMap = {
|
1082
|
-
"event.assignedTo": {
|
1083
|
-
id: "event.assignedTo.label",
|
1084
|
-
defaultMessage: "Assigned To",
|
1085
|
-
description: "Assigned To"
|
1086
|
-
},
|
1087
|
-
"event.createdAt": {
|
1088
|
-
id: "event.createdAt.label",
|
1089
|
-
defaultMessage: "Created",
|
1090
|
-
description: "Created At"
|
1091
|
-
},
|
1092
|
-
"event.createdAtLocation": {
|
1093
|
-
id: "event.createdAtLocation.label",
|
1094
|
-
defaultMessage: "Location",
|
1095
|
-
description: "Created At Location"
|
1096
|
-
},
|
1097
|
-
"event.updatedAtLocation": {
|
1098
|
-
id: "event.updatedAtLocation.label",
|
1099
|
-
defaultMessage: "Location",
|
1100
|
-
description: "Updated At"
|
1101
|
-
},
|
1102
|
-
"event.createdBy": {
|
1103
|
-
id: "event.createdBy.label",
|
1104
|
-
defaultMessage: "Created By",
|
1105
|
-
description: "Created By"
|
1106
|
-
},
|
1107
|
-
"event.id": {
|
1108
|
-
id: "event.id.label",
|
1109
|
-
defaultMessage: "ID",
|
1110
|
-
description: "ID"
|
1111
|
-
},
|
1112
|
-
"event.updatedAt": {
|
1113
|
-
id: "event.modifiedAt.label",
|
1114
|
-
defaultMessage: "Updated",
|
1115
|
-
description: "Modified At"
|
1116
|
-
},
|
1117
|
-
"event.status": {
|
1118
|
-
id: "event.status.label",
|
1119
|
-
defaultMessage: "Status",
|
1120
|
-
description: "Status"
|
1121
|
-
},
|
1122
|
-
"event.type": {
|
1123
|
-
id: "event.type.label",
|
1124
|
-
defaultMessage: "Type",
|
1125
|
-
description: "Type"
|
1126
|
-
},
|
1127
|
-
"event.updatedBy": {
|
1128
|
-
id: "event.updatedBy.label",
|
1129
|
-
defaultMessage: "Updated By",
|
1130
|
-
description: "Updated By"
|
1131
|
-
},
|
1132
|
-
"event.trackingId": {
|
1133
|
-
id: "event.trackingId.label",
|
1134
|
-
defaultMessage: "Tracking ID",
|
1135
|
-
description: "Tracking ID"
|
1136
|
-
},
|
1137
|
-
"event.registrationNumber": {
|
1138
|
-
id: "event.registrationNumber.label",
|
1139
|
-
defaultMessage: "Registration Number",
|
1140
|
-
description: "Registration Number"
|
1141
|
-
}
|
1142
|
-
};
|
1143
|
-
|
1144
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1145
|
-
var WorkqueueConfig = import_zod15.z.object({
|
1146
|
-
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1147
|
-
filters: import_zod15.z.array(
|
1148
|
-
import_zod15.z.object({
|
1149
|
-
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1150
|
-
})
|
1151
|
-
).describe("Filters to be applied to workqueue.")
|
1152
|
-
}).describe("Configuration for workqueue.");
|
1153
|
-
|
1154
1132
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1155
|
-
var
|
1156
|
-
var
|
1157
|
-
var
|
1158
|
-
|
1159
|
-
|
1160
|
-
type: FieldType2.describe("Determines the type of field")
|
1133
|
+
var import_zod14 = require("zod");
|
1134
|
+
var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
|
1135
|
+
var BaseField3 = import_zod14.z.object({
|
1136
|
+
config: import_zod14.z.object({
|
1137
|
+
type: MatchType.describe("Determines the type of field")
|
1161
1138
|
}),
|
1162
|
-
options:
|
1139
|
+
options: import_zod14.z.array(SelectOption).optional()
|
1140
|
+
});
|
1141
|
+
var FieldConfigSchema = BaseField3.extend({
|
1142
|
+
fieldId: import_zod14.z.string(),
|
1143
|
+
fieldType: import_zod14.z.literal("field")
|
1163
1144
|
});
|
1164
|
-
var
|
1145
|
+
var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
|
1146
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1147
|
+
fieldId: EventFieldId,
|
1148
|
+
fieldType: import_zod14.z.literal("event")
|
1149
|
+
});
|
1150
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1151
|
+
FieldConfigSchema,
|
1152
|
+
EventFieldConfigSchema
|
1153
|
+
]);
|
1154
|
+
var AdvancedSearchConfig = import_zod14.z.object({
|
1165
1155
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1166
|
-
fields:
|
1156
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1167
1157
|
});
|
1168
1158
|
|
1169
|
-
// ../commons/src/utils.ts
|
1159
|
+
// ../commons/src/events/utils.ts
|
1170
1160
|
var import_lodash = require("lodash");
|
1171
|
-
function getOrThrow(x, message) {
|
1172
|
-
if (x === void 0 || x === null) {
|
1173
|
-
throw new Error(message);
|
1174
|
-
}
|
1175
|
-
return x;
|
1176
|
-
}
|
1177
|
-
var findAllFields = (config) => {
|
1178
|
-
return (0, import_lodash.flattenDeep)([
|
1179
|
-
...getDeclarationFields(config),
|
1180
|
-
...getAllAnnotationFields(config)
|
1181
|
-
]);
|
1182
|
-
};
|
1183
|
-
var metadataFields = ["trackingId", "status"];
|
1184
|
-
|
1185
|
-
// ../commons/src/events/EventConfig.ts
|
1186
|
-
var EventConfig2 = import_zod17.z.object({
|
1187
|
-
id: import_zod17.z.string().describe(
|
1188
|
-
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1189
|
-
),
|
1190
|
-
summary: SummaryConfig,
|
1191
|
-
label: TranslationConfig,
|
1192
|
-
actions: import_zod17.z.array(ActionConfig),
|
1193
|
-
declaration: DeclarationFormConfig,
|
1194
|
-
workqueues: import_zod17.z.array(WorkqueueConfig),
|
1195
|
-
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1196
|
-
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1197
|
-
}).superRefine((event2, ctx) => {
|
1198
|
-
const allFields = findAllFields(event2);
|
1199
|
-
const fieldIds = allFields.map((field2) => field2.id);
|
1200
|
-
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1201
|
-
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
1202
|
-
);
|
1203
|
-
const advancedSearchFieldsSet = new Set(advancedSearchFields);
|
1204
|
-
if (advancedSearchFieldsSet.size !== advancedSearchFields.length) {
|
1205
|
-
ctx.addIssue({
|
1206
|
-
code: "custom",
|
1207
|
-
message: "Advanced search field ids must be unique",
|
1208
|
-
path: ["advancedSearch"]
|
1209
|
-
});
|
1210
|
-
}
|
1211
|
-
const invalidFields = event2.advancedSearch.flatMap(
|
1212
|
-
(section) => (
|
1213
|
-
// Check if the fieldId is not in the fieldIds array
|
1214
|
-
// and also not in the metadataFields array
|
1215
|
-
section.fields.filter(
|
1216
|
-
(field2) => !(fieldIds.includes(field2.fieldId) || Boolean(metadataFields.find((f) => f === field2.fieldId)))
|
1217
|
-
)
|
1218
|
-
)
|
1219
|
-
);
|
1220
|
-
if (invalidFields.length > 0) {
|
1221
|
-
ctx.addIssue({
|
1222
|
-
code: "custom",
|
1223
|
-
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1224
|
-
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1225
|
-
path: ["advancedSearch"]
|
1226
|
-
});
|
1227
|
-
}
|
1228
|
-
});
|
1229
|
-
|
1230
|
-
// ../commons/src/events/EventConfigInput.ts
|
1231
|
-
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1232
|
-
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1233
|
-
var definePage = (page) => PageConfig.parse(page);
|
1234
|
-
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1235
|
-
|
1236
|
-
// ../commons/src/events/Draft.ts
|
1237
|
-
var import_zod20 = require("zod");
|
1238
1161
|
|
1239
1162
|
// ../commons/src/events/ActionDocument.ts
|
1240
|
-
var
|
1241
|
-
var
|
1163
|
+
var import_zod15 = require("zod");
|
1164
|
+
var import_zod_openapi7 = require("zod-openapi");
|
1165
|
+
(0, import_zod_openapi7.extendZodWithOpenApi)(import_zod15.z);
|
1166
|
+
var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
|
1167
|
+
var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
|
1242
1168
|
var ActionStatus = {
|
1243
1169
|
Requested: "Requested",
|
1244
1170
|
Accepted: "Accepted",
|
1245
1171
|
Rejected: "Rejected"
|
1246
1172
|
};
|
1247
|
-
var ActionBase =
|
1248
|
-
id:
|
1249
|
-
|
1250
|
-
|
1173
|
+
var ActionBase = import_zod15.z.object({
|
1174
|
+
id: import_zod15.z.string(),
|
1175
|
+
transactionId: import_zod15.z.string(),
|
1176
|
+
createdAt: import_zod15.z.string().datetime(),
|
1177
|
+
createdBy: import_zod15.z.string(),
|
1178
|
+
createdByRole: import_zod15.z.string(),
|
1251
1179
|
declaration: ActionUpdate,
|
1252
1180
|
annotation: ActionUpdate.optional(),
|
1253
|
-
createdAtLocation:
|
1254
|
-
|
1255
|
-
status: import_zod18.z.enum([
|
1181
|
+
createdAtLocation: import_zod15.z.string(),
|
1182
|
+
status: import_zod15.z.enum([
|
1256
1183
|
ActionStatus.Requested,
|
1257
1184
|
ActionStatus.Accepted,
|
1258
1185
|
ActionStatus.Rejected
|
1259
1186
|
]),
|
1260
1187
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1261
|
-
originalActionId:
|
1188
|
+
originalActionId: import_zod15.z.string().optional()
|
1262
1189
|
});
|
1263
1190
|
var AssignedAction = ActionBase.merge(
|
1264
|
-
|
1265
|
-
type:
|
1266
|
-
assignedTo:
|
1191
|
+
import_zod15.z.object({
|
1192
|
+
type: import_zod15.z.literal(ActionType.ASSIGN),
|
1193
|
+
assignedTo: import_zod15.z.string()
|
1267
1194
|
})
|
1268
1195
|
);
|
1269
1196
|
var UnassignedAction = ActionBase.merge(
|
1270
|
-
|
1271
|
-
type:
|
1272
|
-
assignedTo:
|
1197
|
+
import_zod15.z.object({
|
1198
|
+
type: import_zod15.z.literal(ActionType.UNASSIGN),
|
1199
|
+
assignedTo: import_zod15.z.literal(null)
|
1273
1200
|
})
|
1274
1201
|
);
|
1275
1202
|
var RegisterAction = ActionBase.merge(
|
1276
|
-
|
1277
|
-
type:
|
1278
|
-
registrationNumber:
|
1203
|
+
import_zod15.z.object({
|
1204
|
+
type: import_zod15.z.literal(ActionType.REGISTER),
|
1205
|
+
registrationNumber: import_zod15.z.string().optional()
|
1279
1206
|
})
|
1280
1207
|
);
|
1281
1208
|
var DeclareAction = ActionBase.merge(
|
1282
|
-
|
1283
|
-
type:
|
1209
|
+
import_zod15.z.object({
|
1210
|
+
type: import_zod15.z.literal(ActionType.DECLARE)
|
1284
1211
|
})
|
1285
1212
|
);
|
1286
1213
|
var ValidateAction = ActionBase.merge(
|
1287
|
-
|
1288
|
-
type:
|
1214
|
+
import_zod15.z.object({
|
1215
|
+
type: import_zod15.z.literal(ActionType.VALIDATE)
|
1289
1216
|
})
|
1290
1217
|
);
|
1291
1218
|
var RejectAction = ActionBase.merge(
|
1292
|
-
|
1293
|
-
type:
|
1219
|
+
import_zod15.z.object({
|
1220
|
+
type: import_zod15.z.literal(ActionType.REJECT)
|
1294
1221
|
})
|
1295
1222
|
);
|
1296
1223
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1297
|
-
|
1298
|
-
type:
|
1224
|
+
import_zod15.z.object({
|
1225
|
+
type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1299
1226
|
})
|
1300
1227
|
);
|
1301
1228
|
var ArchiveAction = ActionBase.merge(
|
1302
|
-
|
1303
|
-
type:
|
1229
|
+
import_zod15.z.object({
|
1230
|
+
type: import_zod15.z.literal(ActionType.ARCHIVE)
|
1304
1231
|
})
|
1305
1232
|
);
|
1306
1233
|
var CreatedAction = ActionBase.merge(
|
1307
|
-
|
1308
|
-
type:
|
1234
|
+
import_zod15.z.object({
|
1235
|
+
type: import_zod15.z.literal(ActionType.CREATE)
|
1309
1236
|
})
|
1310
1237
|
);
|
1311
1238
|
var NotifiedAction = ActionBase.merge(
|
1312
|
-
|
1313
|
-
type:
|
1239
|
+
import_zod15.z.object({
|
1240
|
+
type: import_zod15.z.literal(ActionType.NOTIFY)
|
1314
1241
|
})
|
1315
1242
|
);
|
1316
1243
|
var PrintCertificateAction = ActionBase.merge(
|
1317
|
-
|
1318
|
-
type:
|
1244
|
+
import_zod15.z.object({
|
1245
|
+
type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
|
1319
1246
|
})
|
1320
1247
|
);
|
1321
1248
|
var RequestedCorrectionAction = ActionBase.merge(
|
1322
|
-
|
1323
|
-
type:
|
1249
|
+
import_zod15.z.object({
|
1250
|
+
type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
|
1324
1251
|
})
|
1325
1252
|
);
|
1326
1253
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1327
|
-
|
1328
|
-
type:
|
1329
|
-
requestId:
|
1254
|
+
import_zod15.z.object({
|
1255
|
+
type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
|
1256
|
+
requestId: import_zod15.z.string()
|
1330
1257
|
})
|
1331
1258
|
);
|
1332
1259
|
var RejectedCorrectionAction = ActionBase.merge(
|
1333
|
-
|
1334
|
-
type:
|
1335
|
-
requestId:
|
1260
|
+
import_zod15.z.object({
|
1261
|
+
type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
|
1262
|
+
requestId: import_zod15.z.string()
|
1336
1263
|
})
|
1337
1264
|
);
|
1338
1265
|
var ReadAction = ActionBase.merge(
|
1339
|
-
|
1340
|
-
type:
|
1266
|
+
import_zod15.z.object({
|
1267
|
+
type: import_zod15.z.literal(ActionType.READ)
|
1341
1268
|
})
|
1342
1269
|
);
|
1343
|
-
var ActionDocument =
|
1344
|
-
CreatedAction,
|
1345
|
-
ValidateAction,
|
1346
|
-
RejectAction,
|
1347
|
-
MarkAsDuplicateAction,
|
1348
|
-
ArchiveAction,
|
1349
|
-
NotifiedAction,
|
1350
|
-
RegisterAction,
|
1351
|
-
DeclareAction,
|
1352
|
-
AssignedAction,
|
1353
|
-
RequestedCorrectionAction,
|
1354
|
-
ApprovedCorrectionAction,
|
1355
|
-
RejectedCorrectionAction,
|
1356
|
-
UnassignedAction,
|
1357
|
-
PrintCertificateAction,
|
1358
|
-
ReadAction
|
1359
|
-
])
|
1270
|
+
var ActionDocument = import_zod15.z.discriminatedUnion("type", [
|
1271
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1272
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1273
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1274
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1275
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1276
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1277
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1278
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1279
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1280
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1281
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1282
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1283
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1284
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1285
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1286
|
+
]).openapi({
|
1287
|
+
ref: "ActionDocument"
|
1288
|
+
});
|
1360
1289
|
var AsyncRejectActionDocument = ActionBase.omit({
|
1361
1290
|
declaration: true,
|
1362
|
-
annotation: true
|
1363
|
-
createdBy: true,
|
1364
|
-
createdAtLocation: true
|
1291
|
+
annotation: true
|
1365
1292
|
}).merge(
|
1366
|
-
|
1367
|
-
type:
|
1368
|
-
status:
|
1293
|
+
import_zod15.z.object({
|
1294
|
+
type: import_zod15.z.enum(ConfirmableActions),
|
1295
|
+
status: import_zod15.z.literal(ActionStatus.Rejected)
|
1369
1296
|
})
|
1370
1297
|
);
|
1371
|
-
var Action =
|
1372
|
-
var ResolvedUser =
|
1373
|
-
id:
|
1374
|
-
role:
|
1375
|
-
name:
|
1376
|
-
|
1377
|
-
use:
|
1378
|
-
given:
|
1379
|
-
family:
|
1298
|
+
var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1299
|
+
var ResolvedUser = import_zod15.z.object({
|
1300
|
+
id: import_zod15.z.string(),
|
1301
|
+
role: import_zod15.z.string(),
|
1302
|
+
name: import_zod15.z.array(
|
1303
|
+
import_zod15.z.object({
|
1304
|
+
use: import_zod15.z.string(),
|
1305
|
+
given: import_zod15.z.array(import_zod15.z.string()),
|
1306
|
+
family: import_zod15.z.string()
|
1380
1307
|
})
|
1381
1308
|
)
|
1382
1309
|
});
|
1383
1310
|
|
1384
|
-
// ../commons/src/
|
1385
|
-
var
|
1386
|
-
var
|
1387
|
-
|
1388
|
-
transactionId: import_zod19.z.string(),
|
1389
|
-
declaration: ActionUpdate.default({}),
|
1390
|
-
annotation: ActionUpdate.optional(),
|
1391
|
-
originalActionId: import_zod19.z.string().optional(),
|
1392
|
-
keepAssignment: import_zod19.z.boolean().optional()
|
1393
|
-
});
|
1394
|
-
var CreateActionInput = BaseActionInput.merge(
|
1395
|
-
import_zod19.z.object({
|
1396
|
-
type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1397
|
-
createdAtLocation: import_zod19.z.string()
|
1398
|
-
})
|
1399
|
-
);
|
1400
|
-
var RegisterActionInput = BaseActionInput.merge(
|
1401
|
-
import_zod19.z.object({
|
1402
|
-
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1403
|
-
registrationNumber: import_zod19.z.string().optional()
|
1404
|
-
})
|
1405
|
-
);
|
1406
|
-
var ValidateActionInput = BaseActionInput.merge(
|
1407
|
-
import_zod19.z.object({
|
1408
|
-
type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1409
|
-
duplicates: import_zod19.z.array(import_zod19.z.string())
|
1410
|
-
})
|
1411
|
-
);
|
1412
|
-
var NotifyActionInput = BaseActionInput.merge(
|
1413
|
-
import_zod19.z.object({
|
1414
|
-
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1415
|
-
})
|
1416
|
-
);
|
1417
|
-
var DeclareActionInput = BaseActionInput.merge(
|
1418
|
-
import_zod19.z.object({
|
1419
|
-
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1420
|
-
})
|
1421
|
-
);
|
1422
|
-
var PrintCertificateActionInput = BaseActionInput.merge(
|
1423
|
-
import_zod19.z.object({
|
1424
|
-
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1425
|
-
})
|
1426
|
-
);
|
1427
|
-
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1428
|
-
import_zod19.z.object({
|
1429
|
-
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1430
|
-
})
|
1431
|
-
);
|
1432
|
-
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1433
|
-
import_zod19.z.object({
|
1434
|
-
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1435
|
-
})
|
1436
|
-
);
|
1437
|
-
var ArchiveActionInput = BaseActionInput.merge(
|
1438
|
-
import_zod19.z.object({
|
1439
|
-
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1440
|
-
})
|
1441
|
-
);
|
1442
|
-
var AssignActionInput = BaseActionInput.merge(
|
1443
|
-
import_zod19.z.object({
|
1444
|
-
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1445
|
-
assignedTo: import_zod19.z.string()
|
1446
|
-
})
|
1447
|
-
);
|
1448
|
-
var UnassignActionInput = BaseActionInput.merge(
|
1449
|
-
import_zod19.z.object({
|
1450
|
-
type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
1451
|
-
assignedTo: import_zod19.z.literal(null).default(null)
|
1452
|
-
})
|
1453
|
-
);
|
1454
|
-
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1455
|
-
import_zod19.z.object({
|
1456
|
-
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1457
|
-
})
|
1458
|
-
);
|
1459
|
-
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1460
|
-
import_zod19.z.object({
|
1461
|
-
requestId: import_zod19.z.string(),
|
1462
|
-
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1463
|
-
})
|
1464
|
-
);
|
1465
|
-
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1466
|
-
import_zod19.z.object({
|
1467
|
-
requestId: import_zod19.z.string(),
|
1468
|
-
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1469
|
-
})
|
1470
|
-
);
|
1471
|
-
var ReadActionInput = BaseActionInput.merge(
|
1472
|
-
import_zod19.z.object({
|
1473
|
-
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
1474
|
-
})
|
1475
|
-
);
|
1476
|
-
var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
1477
|
-
CreateActionInput,
|
1478
|
-
ValidateActionInput,
|
1479
|
-
RegisterActionInput,
|
1480
|
-
NotifyActionInput,
|
1481
|
-
DeclareActionInput,
|
1482
|
-
RejectDeclarationActionInput,
|
1483
|
-
MarkedAsDuplicateActionInput,
|
1484
|
-
ArchiveActionInput,
|
1485
|
-
AssignActionInput,
|
1486
|
-
UnassignActionInput,
|
1487
|
-
PrintCertificateActionInput,
|
1488
|
-
RequestCorrectionActionInput,
|
1489
|
-
RejectCorrectionActionInput,
|
1490
|
-
ApproveCorrectionActionInput,
|
1491
|
-
ReadActionInput
|
1492
|
-
]);
|
1493
|
-
|
1494
|
-
// ../commons/src/events/Draft.ts
|
1495
|
-
var Draft = import_zod20.z.object({
|
1496
|
-
id: import_zod20.z.string(),
|
1497
|
-
eventId: import_zod20.z.string(),
|
1498
|
-
transactionId: import_zod20.z.string(),
|
1499
|
-
createdAt: import_zod20.z.string().datetime(),
|
1500
|
-
action: ActionBase.extend({
|
1501
|
-
type: ActionTypes
|
1502
|
-
}).omit({ id: true })
|
1503
|
-
});
|
1504
|
-
var DraftInput = BaseActionInput.extend({
|
1505
|
-
type: ActionTypes
|
1506
|
-
});
|
1507
|
-
|
1508
|
-
// ../commons/src/events/EventInput.ts
|
1509
|
-
var import_zod21 = require("zod");
|
1510
|
-
var EventInput = import_zod21.z.object({
|
1511
|
-
transactionId: import_zod21.z.string(),
|
1512
|
-
type: import_zod21.z.string()
|
1513
|
-
});
|
1514
|
-
|
1515
|
-
// ../commons/src/events/EventDocument.ts
|
1516
|
-
var import_zod22 = require("zod");
|
1517
|
-
var EventDocument = import_zod22.z.object({
|
1518
|
-
id: import_zod22.z.string(),
|
1519
|
-
type: import_zod22.z.string(),
|
1520
|
-
createdAt: import_zod22.z.string().datetime(),
|
1521
|
-
updatedAt: import_zod22.z.string().datetime(),
|
1522
|
-
actions: import_zod22.z.array(Action),
|
1523
|
-
trackingId: import_zod22.z.string()
|
1524
|
-
});
|
1525
|
-
|
1526
|
-
// ../commons/src/events/EventIndex.ts
|
1527
|
-
var import_zod23 = require("zod");
|
1528
|
-
var EventIndex = EventMetadata.extend({
|
1529
|
-
declaration: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any())
|
1530
|
-
});
|
1531
|
-
var EventSearchIndex = import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any()).and(
|
1532
|
-
import_zod23.z.object({
|
1533
|
-
type: import_zod23.z.string()
|
1534
|
-
// Ensures "type" (event-id) exists and is a string
|
1535
|
-
})
|
1536
|
-
);
|
1537
|
-
var Fuzzy = import_zod23.z.object({ type: import_zod23.z.literal("fuzzy"), term: import_zod23.z.string() });
|
1538
|
-
var Exact = import_zod23.z.object({ type: import_zod23.z.literal("exact"), term: import_zod23.z.string() });
|
1539
|
-
var AnyOf = import_zod23.z.object({
|
1540
|
-
type: import_zod23.z.literal("anyOf"),
|
1541
|
-
terms: import_zod23.z.array(import_zod23.z.string())
|
1542
|
-
});
|
1543
|
-
var Range = import_zod23.z.object({
|
1544
|
-
type: import_zod23.z.literal("range"),
|
1545
|
-
gte: import_zod23.z.string(),
|
1546
|
-
lte: import_zod23.z.string()
|
1547
|
-
});
|
1548
|
-
var Within = import_zod23.z.object({ type: import_zod23.z.literal("within"), location: import_zod23.z.string() });
|
1549
|
-
var DateCondition = import_zod23.z.union([Exact, Range]);
|
1550
|
-
var QueryInput = import_zod23.z.lazy(
|
1551
|
-
() => import_zod23.z.union([
|
1552
|
-
import_zod23.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
1553
|
-
import_zod23.z.record(import_zod23.z.string(), QueryInput)
|
1554
|
-
])
|
1555
|
-
);
|
1556
|
-
var QueryExpression = import_zod23.z.object({
|
1557
|
-
type: import_zod23.z.literal("and"),
|
1558
|
-
eventType: import_zod23.z.string(),
|
1559
|
-
searchType: import_zod23.z.optional(import_zod23.z.union([AnyOf, Exact])),
|
1560
|
-
status: import_zod23.z.optional(import_zod23.z.union([AnyOf, Exact])),
|
1561
|
-
createdAt: import_zod23.z.optional(DateCondition),
|
1562
|
-
updatedAt: import_zod23.z.optional(DateCondition),
|
1563
|
-
createAtLocation: import_zod23.z.optional(import_zod23.z.union([Within, Exact])),
|
1564
|
-
updatedAtLocation: import_zod23.z.optional(import_zod23.z.union([Within, Exact])),
|
1565
|
-
createdBy: import_zod23.z.optional(Exact),
|
1566
|
-
updatedBy: import_zod23.z.optional(Exact),
|
1567
|
-
trackingId: import_zod23.z.optional(Exact),
|
1568
|
-
data: QueryInput
|
1569
|
-
}).partial();
|
1570
|
-
var Or2 = import_zod23.z.object({
|
1571
|
-
type: import_zod23.z.literal("or"),
|
1572
|
-
clauses: import_zod23.z.array(QueryExpression)
|
1573
|
-
});
|
1574
|
-
var QueryType = import_zod23.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
1575
|
-
|
1576
|
-
// ../commons/src/events/utils.ts
|
1577
|
-
var import_lodash2 = require("lodash");
|
1578
|
-
|
1579
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1580
|
-
var import_zod25 = require("zod");
|
1581
|
-
|
1582
|
-
// ../commons/src/workqueues/defaultColumns.ts
|
1583
|
-
var import_zod24 = require("zod");
|
1584
|
-
var WorkQueueColumnConfig = import_zod24.z.object({
|
1585
|
-
id: import_zod24.z.string(),
|
1586
|
-
label: TranslationConfig
|
1587
|
-
});
|
1588
|
-
var defaultColumns = {
|
1589
|
-
event: {
|
1590
|
-
id: "event",
|
1591
|
-
label: {
|
1592
|
-
defaultMessage: "Event",
|
1593
|
-
description: "This is the label for the workqueue column",
|
1594
|
-
id: "workqueue.default.column.event"
|
1595
|
-
}
|
1596
|
-
},
|
1597
|
-
status: {
|
1598
|
-
id: "status",
|
1599
|
-
label: {
|
1600
|
-
defaultMessage: "Status",
|
1601
|
-
description: "This is the label for the workqueue column",
|
1602
|
-
id: "workqueue.default.column.status"
|
1603
|
-
}
|
1604
|
-
},
|
1605
|
-
createdAt: {
|
1606
|
-
id: "createdAt",
|
1607
|
-
label: {
|
1608
|
-
defaultMessage: "Created",
|
1609
|
-
description: "This is the label for the workqueue column",
|
1610
|
-
id: "workqueue.default.column.createdAt"
|
1611
|
-
}
|
1612
|
-
},
|
1613
|
-
modifiedAt: {
|
1614
|
-
id: "modifiedAt",
|
1615
|
-
label: {
|
1616
|
-
defaultMessage: "Modified",
|
1617
|
-
description: "This is the label for the workqueue column",
|
1618
|
-
id: "workqueue.default.column.modifiedAt"
|
1619
|
-
}
|
1620
|
-
}
|
1621
|
-
};
|
1622
|
-
var DefaultColumnKeys = import_zod24.z.enum(
|
1623
|
-
Object.keys(defaultColumns)
|
1624
|
-
);
|
1625
|
-
|
1626
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1627
|
-
var rootWorkqueueConfig = import_zod25.z.object({
|
1628
|
-
id: import_zod25.z.string(),
|
1629
|
-
title: TranslationConfig,
|
1630
|
-
columns: import_zod25.z.array(WorkQueueColumnConfig),
|
1631
|
-
defaultColumns: import_zod25.z.array(DefaultColumnKeys)
|
1632
|
-
});
|
1633
|
-
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1634
|
-
|
1635
|
-
// ../commons/src/workqueues/all.ts
|
1636
|
-
var allWorkqueue = defineWorkqueue({
|
1637
|
-
id: "all",
|
1638
|
-
title: {
|
1639
|
-
defaultMessage: "All events",
|
1640
|
-
description: "This is the label for the workqueue",
|
1641
|
-
id: "workqueue.all.label"
|
1642
|
-
},
|
1643
|
-
columns: [
|
1644
|
-
{
|
1645
|
-
id: "title",
|
1646
|
-
label: {
|
1647
|
-
defaultMessage: "Title",
|
1648
|
-
description: "This is the label for the workqueue column",
|
1649
|
-
id: "workqueue.all.column.title"
|
1650
|
-
}
|
1651
|
-
}
|
1652
|
-
],
|
1653
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1654
|
-
});
|
1655
|
-
|
1656
|
-
// ../commons/src/workqueues/readyForReview.ts
|
1657
|
-
var inReviewWorkqueue = defineWorkqueue({
|
1658
|
-
id: "ready-for-review",
|
1659
|
-
title: {
|
1660
|
-
defaultMessage: "Ready for review",
|
1661
|
-
description: "Label for in review workqueue",
|
1662
|
-
id: "event.workqueue.in-review.label"
|
1663
|
-
},
|
1664
|
-
columns: [
|
1665
|
-
{
|
1666
|
-
id: "title",
|
1667
|
-
label: {
|
1668
|
-
defaultMessage: "Title",
|
1669
|
-
description: "This is the label for the workqueue column",
|
1670
|
-
id: "workqueue.in-reveiw.column.title"
|
1671
|
-
}
|
1672
|
-
}
|
1673
|
-
],
|
1674
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1675
|
-
});
|
1676
|
-
|
1677
|
-
// ../commons/src/workqueues/readyToPrint.ts
|
1678
|
-
var registeredWorkqueue = defineWorkqueue({
|
1679
|
-
id: "registered",
|
1680
|
-
title: {
|
1681
|
-
defaultMessage: "Ready to print",
|
1682
|
-
description: "Label for registered workqueue",
|
1683
|
-
id: "event.workqueue.registered.label"
|
1684
|
-
},
|
1685
|
-
columns: [
|
1686
|
-
{
|
1687
|
-
id: "title",
|
1688
|
-
label: {
|
1689
|
-
defaultMessage: "Title",
|
1690
|
-
description: "This is the label for the workqueue column",
|
1691
|
-
id: "workqueue.registered.column.title"
|
1692
|
-
}
|
1693
|
-
}
|
1694
|
-
],
|
1695
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1696
|
-
});
|
1697
|
-
|
1698
|
-
// ../commons/src/workqueues/index.ts
|
1699
|
-
var workqueues = {
|
1700
|
-
all: allWorkqueue,
|
1701
|
-
registered: registeredWorkqueue,
|
1702
|
-
inReview: inReviewWorkqueue
|
1703
|
-
};
|
1704
|
-
|
1705
|
-
// ../commons/src/conditionals/validate.ts
|
1706
|
-
var import_ajv = __toESM(require("ajv"));
|
1707
|
-
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1708
|
-
var import_date_fns = require("date-fns");
|
1311
|
+
// ../commons/src/conditionals/validate.ts
|
1312
|
+
var import_ajv = __toESM(require("ajv"));
|
1313
|
+
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1314
|
+
var import_date_fns = require("date-fns");
|
1709
1315
|
|
1710
1316
|
// ../commons/src/events/FieldTypeMapping.ts
|
1711
|
-
var
|
1317
|
+
var import_zod16 = require("zod");
|
1712
1318
|
function mapFieldTypeToZod(type, required) {
|
1713
1319
|
let schema;
|
1714
1320
|
switch (type) {
|
@@ -1718,6 +1324,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1718
1324
|
case FieldType.EMAIL:
|
1719
1325
|
schema = EmailValue;
|
1720
1326
|
break;
|
1327
|
+
case FieldType.DATE_RANGE:
|
1328
|
+
schema = DateRangeFieldValue;
|
1329
|
+
break;
|
1721
1330
|
case FieldType.TEXT:
|
1722
1331
|
case FieldType.TEXTAREA:
|
1723
1332
|
case FieldType.DIVIDER:
|
@@ -1732,8 +1341,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1732
1341
|
case FieldType.FACILITY:
|
1733
1342
|
case FieldType.OFFICE:
|
1734
1343
|
case FieldType.SIGNATURE:
|
1735
|
-
|
1736
|
-
schema = required ? RequiredTextValue : TextValue;
|
1344
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1737
1345
|
break;
|
1738
1346
|
case FieldType.NUMBER:
|
1739
1347
|
schema = NumberFieldValue;
|
@@ -1761,7 +1369,7 @@ function createValidationSchema(config) {
|
|
1761
1369
|
for (const field2 of config) {
|
1762
1370
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1763
1371
|
}
|
1764
|
-
return
|
1372
|
+
return import_zod16.z.object(shape);
|
1765
1373
|
}
|
1766
1374
|
function mapFieldTypeToMockValue(field2, i) {
|
1767
1375
|
switch (field2.type) {
|
@@ -1799,6 +1407,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1799
1407
|
};
|
1800
1408
|
case FieldType.DATE:
|
1801
1409
|
return "2021-01-01";
|
1410
|
+
case FieldType.DATE_RANGE:
|
1411
|
+
return ["2021-01-01", "2021-01-02"];
|
1802
1412
|
case FieldType.CHECKBOX:
|
1803
1413
|
return true;
|
1804
1414
|
case FieldType.FILE:
|
@@ -1833,6 +1443,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1833
1443
|
case FieldType.EMAIL:
|
1834
1444
|
case FieldType.DATE:
|
1835
1445
|
case FieldType.CHECKBOX:
|
1446
|
+
case FieldType.DATE_RANGE:
|
1836
1447
|
case FieldType.DATA:
|
1837
1448
|
return null;
|
1838
1449
|
case FieldType.ADDRESS:
|
@@ -1865,6 +1476,9 @@ var isParagraphFieldType = (field2) => {
|
|
1865
1476
|
var isDateFieldType = (field2) => {
|
1866
1477
|
return field2.config.type === FieldType.DATE;
|
1867
1478
|
};
|
1479
|
+
var isDateRangeFieldType = (field2) => {
|
1480
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1481
|
+
};
|
1868
1482
|
var isPageHeaderFieldType = (field2) => {
|
1869
1483
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1870
1484
|
};
|
@@ -1935,12 +1549,23 @@ var ajv = new import_ajv.default({
|
|
1935
1549
|
function validate(schema, data) {
|
1936
1550
|
return ajv.validate(schema, data);
|
1937
1551
|
}
|
1552
|
+
function isConditionMet(conditional, values) {
|
1553
|
+
return validate(conditional, {
|
1554
|
+
$form: values,
|
1555
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1556
|
+
});
|
1557
|
+
}
|
1938
1558
|
function getConditionalActionsForField(field2, values) {
|
1939
1559
|
if (!field2.conditionals) {
|
1940
1560
|
return [];
|
1941
1561
|
}
|
1942
1562
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1943
1563
|
}
|
1564
|
+
function areConditionsMet(conditions, values) {
|
1565
|
+
return conditions.every(
|
1566
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1567
|
+
);
|
1568
|
+
}
|
1944
1569
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1945
1570
|
const hasRule = (field2.conditionals ?? []).some(
|
1946
1571
|
(conditional) => conditional.type === conditionalType
|
@@ -1959,6 +1584,10 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1959
1584
|
function isFieldVisible(field2, form) {
|
1960
1585
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1961
1586
|
}
|
1587
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1588
|
+
const fieldValue = form[field2.id];
|
1589
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1590
|
+
}
|
1962
1591
|
function isFieldEnabled(field2, form) {
|
1963
1592
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1964
1593
|
}
|
@@ -2063,6 +1692,11 @@ function runFieldValidations({
|
|
2063
1692
|
field: field2,
|
2064
1693
|
values
|
2065
1694
|
}) {
|
1695
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1696
|
+
return {
|
1697
|
+
errors: []
|
1698
|
+
};
|
1699
|
+
}
|
2066
1700
|
const conditionalParameters = {
|
2067
1701
|
$form: values,
|
2068
1702
|
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
@@ -2080,29 +1714,6 @@ function runFieldValidations({
|
|
2080
1714
|
errors: [...fieldValidationResult, ...customValidationResults]
|
2081
1715
|
};
|
2082
1716
|
}
|
2083
|
-
function getFieldValidationErrors({
|
2084
|
-
field: field2,
|
2085
|
-
values
|
2086
|
-
}) {
|
2087
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
2088
|
-
if (values[field2.id]) {
|
2089
|
-
return {
|
2090
|
-
errors: [
|
2091
|
-
{
|
2092
|
-
message: errorMessages.hiddenField
|
2093
|
-
}
|
2094
|
-
]
|
2095
|
-
};
|
2096
|
-
}
|
2097
|
-
return {
|
2098
|
-
errors: []
|
2099
|
-
};
|
2100
|
-
}
|
2101
|
-
return runFieldValidations({
|
2102
|
-
field: field2,
|
2103
|
-
values
|
2104
|
-
});
|
2105
|
-
}
|
2106
1717
|
|
2107
1718
|
// ../commons/src/uuid.ts
|
2108
1719
|
var import_uuid = require("uuid");
|
@@ -2110,8 +1721,15 @@ function getUUID() {
|
|
2110
1721
|
return (0, import_uuid.v4)();
|
2111
1722
|
}
|
2112
1723
|
|
1724
|
+
// ../commons/src/utils.ts
|
1725
|
+
function getOrThrow(x, message) {
|
1726
|
+
if (x === void 0 || x === null) {
|
1727
|
+
throw new Error(message);
|
1728
|
+
}
|
1729
|
+
return x;
|
1730
|
+
}
|
1731
|
+
|
2113
1732
|
// ../commons/src/events/utils.ts
|
2114
|
-
var import_date_fns2 = require("date-fns");
|
2115
1733
|
function isDeclarationActionConfig(action) {
|
2116
1734
|
return DeclarationActions.safeParse(action.type).success;
|
2117
1735
|
}
|
@@ -2139,9 +1757,9 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
2139
1757
|
}
|
2140
1758
|
return [];
|
2141
1759
|
};
|
2142
|
-
|
2143
|
-
return (0,
|
2144
|
-
}
|
1760
|
+
function getAllAnnotationFields(config) {
|
1761
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1762
|
+
}
|
2145
1763
|
var findRecordActionPages = (config, actionType) => {
|
2146
1764
|
const action = config.actions.find((a) => a.type === actionType);
|
2147
1765
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -2164,34 +1782,22 @@ function getActionReview(configuration, actionType) {
|
|
2164
1782
|
function getActionReviewFields(configuration, actionType) {
|
2165
1783
|
return getActionReview(configuration, actionType).fields;
|
2166
1784
|
}
|
2167
|
-
function validateWorkqueueConfig(workqueueConfigs) {
|
2168
|
-
workqueueConfigs.map((workqueue) => {
|
2169
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
2170
|
-
(wq) => wq.id === workqueue.id
|
2171
|
-
);
|
2172
|
-
if (!rootWorkqueue) {
|
2173
|
-
throw new Error(
|
2174
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
2175
|
-
);
|
2176
|
-
}
|
2177
|
-
});
|
2178
|
-
}
|
2179
1785
|
function isPageVisible(page, formValues) {
|
2180
1786
|
if (!page.conditional) {
|
2181
1787
|
return true;
|
2182
1788
|
}
|
2183
|
-
return
|
2184
|
-
$form: formValues,
|
2185
|
-
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
2186
|
-
});
|
1789
|
+
return isConditionMet(page.conditional, formValues);
|
2187
1790
|
}
|
2188
|
-
function omitHiddenFields(fields, values) {
|
2189
|
-
return (0,
|
2190
|
-
|
2191
|
-
|
1791
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1792
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1793
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1794
|
+
return false;
|
1795
|
+
}
|
1796
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1797
|
+
if (!fieldConfigs.length) {
|
2192
1798
|
return true;
|
2193
1799
|
}
|
2194
|
-
return !isFieldVisible(
|
1800
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
2195
1801
|
});
|
2196
1802
|
}
|
2197
1803
|
function omitHiddenPaginatedFields(formConfig, declaration) {
|
@@ -2215,25 +1821,61 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
2215
1821
|
annotation: {},
|
2216
1822
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2217
1823
|
createdBy: "@todo",
|
2218
|
-
createdAtLocation: "@todo"
|
1824
|
+
createdAtLocation: "@todo",
|
1825
|
+
status: ActionStatus.Accepted,
|
1826
|
+
transactionId: "@todo",
|
1827
|
+
createdByRole: "@todo"
|
2219
1828
|
}
|
2220
1829
|
};
|
2221
1830
|
}
|
2222
1831
|
function isVerificationPage(page) {
|
2223
1832
|
return page.type === PageTypes.enum.VERIFICATION;
|
2224
1833
|
}
|
1834
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1835
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1836
|
+
}
|
1837
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1838
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1839
|
+
return [
|
1840
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1841
|
+
...getVisibleVerificationPageIds(
|
1842
|
+
actionConfig.additionalDetailsForm,
|
1843
|
+
annotation
|
1844
|
+
)
|
1845
|
+
];
|
1846
|
+
}
|
1847
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1848
|
+
return getVisibleVerificationPageIds(
|
1849
|
+
actionConfig.printForm.pages,
|
1850
|
+
annotation
|
1851
|
+
);
|
1852
|
+
}
|
1853
|
+
return [];
|
1854
|
+
}
|
1855
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1856
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1857
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1858
|
+
actionConfig,
|
1859
|
+
annotation
|
1860
|
+
);
|
1861
|
+
return omitHiddenFields(
|
1862
|
+
annotationFields,
|
1863
|
+
{ ...declaration, ...annotation },
|
1864
|
+
visibleVerificationPageIds
|
1865
|
+
);
|
1866
|
+
}
|
2225
1867
|
function deepMerge(currentDocument, actionDocument) {
|
2226
|
-
return (0,
|
1868
|
+
return (0, import_lodash.mergeWith)(
|
2227
1869
|
currentDocument,
|
2228
1870
|
actionDocument,
|
2229
1871
|
(previousValue, incomingValue) => {
|
2230
1872
|
if (incomingValue === void 0) {
|
2231
1873
|
return previousValue;
|
2232
1874
|
}
|
2233
|
-
if ((0,
|
1875
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
2234
1876
|
return incomingValue;
|
2235
1877
|
}
|
2236
|
-
if ((0,
|
1878
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
2237
1879
|
return void 0;
|
2238
1880
|
}
|
2239
1881
|
return incomingValue;
|
@@ -2248,201 +1890,341 @@ function findLastAssignmentAction(actions) {
|
|
2248
1890
|
function isWriteAction(actionType) {
|
2249
1891
|
return writeActions.safeParse(actionType).success;
|
2250
1892
|
}
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
return EventStatus.CREATED;
|
2263
|
-
}
|
2264
|
-
if (action.type === ActionType.DECLARE) {
|
2265
|
-
return EventStatus.DECLARED;
|
2266
|
-
}
|
2267
|
-
if (action.type === ActionType.VALIDATE) {
|
2268
|
-
return EventStatus.VALIDATED;
|
2269
|
-
}
|
2270
|
-
if (action.type === ActionType.REGISTER) {
|
2271
|
-
return EventStatus.REGISTERED;
|
2272
|
-
}
|
2273
|
-
if (action.type === ActionType.REJECT) {
|
2274
|
-
return EventStatus.REJECTED;
|
2275
|
-
}
|
2276
|
-
if (action.type === ActionType.ARCHIVE) {
|
2277
|
-
return EventStatus.ARCHIVED;
|
2278
|
-
}
|
2279
|
-
if (action.type === ActionType.NOTIFY) {
|
2280
|
-
return EventStatus.NOTIFIED;
|
2281
|
-
}
|
2282
|
-
return status;
|
2283
|
-
}, EventStatus.CREATED);
|
2284
|
-
}
|
2285
|
-
function getAssignedUserFromActions(actions) {
|
2286
|
-
return actions.reduce((user2, action) => {
|
2287
|
-
if (action.type === ActionType.ASSIGN) {
|
2288
|
-
return action.assignedTo;
|
2289
|
-
}
|
2290
|
-
if (action.type === ActionType.UNASSIGN) {
|
2291
|
-
return null;
|
2292
|
-
}
|
2293
|
-
return user2;
|
2294
|
-
}, null);
|
2295
|
-
}
|
2296
|
-
function aggregateActionDeclarations(actions) {
|
2297
|
-
const excludedActions = [
|
2298
|
-
ActionType.REQUEST_CORRECTION,
|
2299
|
-
ActionType.PRINT_CERTIFICATE
|
2300
|
-
];
|
2301
|
-
return actions.reduce((status, action) => {
|
2302
|
-
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2303
|
-
return status;
|
1893
|
+
var findAllFields = (config) => {
|
1894
|
+
return (0, import_lodash.flattenDeep)([
|
1895
|
+
...getDeclarationFields(config),
|
1896
|
+
...getAllAnnotationFields(config)
|
1897
|
+
]);
|
1898
|
+
};
|
1899
|
+
function getMixedPath(obj, path, defaultValue) {
|
1900
|
+
const parts = path.split(".");
|
1901
|
+
const resolve = (current, segments) => {
|
1902
|
+
if (current == null || segments.length === 0) {
|
1903
|
+
return current;
|
2304
1904
|
}
|
2305
|
-
|
2306
|
-
const
|
2307
|
-
if (
|
2308
|
-
|
1905
|
+
for (let i = segments.length; i > 0; i--) {
|
1906
|
+
const compoundKey = segments.slice(0, i).join(".");
|
1907
|
+
if ((0, import_lodash.has)(current, compoundKey)) {
|
1908
|
+
const next = (0, import_lodash.get)(current, compoundKey);
|
1909
|
+
return resolve(next, segments.slice(i));
|
2309
1910
|
}
|
2310
|
-
return deepMerge(status, requestAction.declaration);
|
2311
1911
|
}
|
2312
|
-
return
|
2313
|
-
}
|
2314
|
-
|
2315
|
-
|
2316
|
-
if (Array.isArray(obj)) {
|
2317
|
-
return obj.map(deepDropNulls);
|
2318
|
-
}
|
2319
|
-
if (obj !== null && typeof obj === "object") {
|
2320
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2321
|
-
const cleanedValue = deepDropNulls(value);
|
2322
|
-
if (cleanedValue !== null) {
|
2323
|
-
;
|
2324
|
-
acc[key] = cleanedValue;
|
2325
|
-
}
|
2326
|
-
return acc;
|
2327
|
-
}, {});
|
2328
|
-
}
|
2329
|
-
return obj;
|
2330
|
-
}
|
2331
|
-
function isUndeclaredDraft(status) {
|
2332
|
-
return status === EventStatus.CREATED;
|
2333
|
-
}
|
2334
|
-
function getAcceptedActions(event2) {
|
2335
|
-
return event2.actions.filter(
|
2336
|
-
(a) => a.status === ActionStatus.Accepted
|
2337
|
-
);
|
1912
|
+
return void 0;
|
1913
|
+
};
|
1914
|
+
const result = resolve(obj, parts);
|
1915
|
+
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
2338
1916
|
}
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
1917
|
+
|
1918
|
+
// ../commons/src/events/EventConfig.ts
|
1919
|
+
var import_zod_openapi8 = require("zod-openapi");
|
1920
|
+
(0, import_zod_openapi8.extendZodWithOpenApi)(import_zod17.z);
|
1921
|
+
var EventConfig = import_zod17.z.object({
|
1922
|
+
id: import_zod17.z.string().describe(
|
1923
|
+
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1924
|
+
),
|
1925
|
+
dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
|
1926
|
+
title: TranslationConfig,
|
1927
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1928
|
+
"This is a fallback title if actual title resolves to empty string"
|
1929
|
+
),
|
1930
|
+
summary: SummaryConfig,
|
1931
|
+
label: TranslationConfig,
|
1932
|
+
actions: import_zod17.z.array(ActionConfig),
|
1933
|
+
declaration: DeclarationFormConfig,
|
1934
|
+
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1935
|
+
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1936
|
+
}).superRefine((event2, ctx) => {
|
1937
|
+
const allFields = findAllFields(event2);
|
1938
|
+
const fieldIds = allFields.map((field2) => field2.id);
|
1939
|
+
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1940
|
+
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
2342
1941
|
);
|
2343
|
-
|
2344
|
-
|
1942
|
+
const advancedSearchFieldsSet = new Set(advancedSearchFields);
|
1943
|
+
if (advancedSearchFieldsSet.size !== advancedSearchFields.length) {
|
1944
|
+
ctx.addIssue({
|
1945
|
+
code: "custom",
|
1946
|
+
message: "Advanced search field ids must be unique",
|
1947
|
+
path: ["advancedSearch"]
|
1948
|
+
});
|
2345
1949
|
}
|
2346
|
-
const
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2362
|
-
updatedAt: latestAction.createdAt,
|
2363
|
-
assignedTo: getAssignedUserFromActions(activeActions),
|
2364
|
-
updatedBy: latestAction.createdBy,
|
2365
|
-
declaration: aggregateActionDeclarations(activeActions),
|
2366
|
-
trackingId: event2.trackingId,
|
2367
|
-
registrationNumber
|
2368
|
-
});
|
2369
|
-
}
|
2370
|
-
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2371
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2372
|
-
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2373
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2374
|
-
return [
|
2375
|
-
action,
|
2376
|
-
{
|
2377
|
-
...action,
|
2378
|
-
type: ActionType.APPROVE_CORRECTION
|
2379
|
-
}
|
2380
|
-
];
|
2381
|
-
}
|
2382
|
-
return [action];
|
2383
|
-
});
|
2384
|
-
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2385
|
-
const withDrafts = {
|
2386
|
-
...event2,
|
2387
|
-
actions: actionWithDrafts
|
2388
|
-
};
|
2389
|
-
return getCurrentEventState(withDrafts);
|
2390
|
-
}
|
2391
|
-
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2392
|
-
const indexedAt = eventIndex.updatedAt;
|
2393
|
-
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2394
|
-
if (activeDrafts.length === 0) {
|
2395
|
-
return eventIndex;
|
1950
|
+
const invalidFields = event2.advancedSearch.flatMap(
|
1951
|
+
(section) => (
|
1952
|
+
// Check if the fieldId is not in the fieldIds array
|
1953
|
+
// and also not in the metadataFields array
|
1954
|
+
section.fields.filter(
|
1955
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
1956
|
+
)
|
1957
|
+
)
|
1958
|
+
);
|
1959
|
+
if (invalidFields.length > 0) {
|
1960
|
+
ctx.addIssue({
|
1961
|
+
code: "custom",
|
1962
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1963
|
+
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1964
|
+
path: ["advancedSearch"]
|
1965
|
+
});
|
2396
1966
|
}
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
1967
|
+
if (event2.dateOfEvent) {
|
1968
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
1969
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
1970
|
+
);
|
1971
|
+
if (!eventDateFieldId) {
|
1972
|
+
ctx.addIssue({
|
1973
|
+
code: "custom",
|
1974
|
+
message: `Date of event field id must match a field id in fields array.
|
1975
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
1976
|
+
path: ["dateOfEvent"]
|
1977
|
+
});
|
1978
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
1979
|
+
ctx.addIssue({
|
1980
|
+
code: "custom",
|
1981
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
1982
|
+
path: ["dateOfEvent.fieldType"]
|
1983
|
+
});
|
2402
1984
|
}
|
2403
|
-
}
|
2404
|
-
}
|
2405
|
-
|
2406
|
-
|
2407
|
-
const annotation = actions.reduce((ann, action) => {
|
2408
|
-
return deepMerge(ann, action.annotation ?? {});
|
2409
|
-
}, {});
|
2410
|
-
return deepDropNulls(annotation);
|
2411
|
-
}
|
2412
|
-
function getActionAnnotation({
|
2413
|
-
event: event2,
|
2414
|
-
actionType,
|
2415
|
-
drafts
|
2416
|
-
}) {
|
2417
|
-
const activeActions = getAcceptedActions(event2);
|
2418
|
-
const action = activeActions.find(
|
2419
|
-
(activeAction) => actionType === activeAction.type
|
2420
|
-
);
|
2421
|
-
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2422
|
-
const sorted = [
|
2423
|
-
...action ? [action] : [],
|
2424
|
-
...eventDrafts.map((draft) => draft.action)
|
2425
|
-
].sort();
|
2426
|
-
const annotation = sorted.reduce((ann, sortedAction) => {
|
2427
|
-
return deepMerge(ann, sortedAction.annotation ?? {});
|
2428
|
-
}, {});
|
2429
|
-
return deepDropNulls(annotation);
|
2430
|
-
}
|
1985
|
+
}
|
1986
|
+
}).openapi({
|
1987
|
+
ref: "EventConfig"
|
1988
|
+
});
|
2431
1989
|
|
2432
|
-
// ../commons/src/events/
|
2433
|
-
var
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
};
|
1990
|
+
// ../commons/src/events/EventConfigInput.ts
|
1991
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1992
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1993
|
+
var definePage = (page) => PageConfig.parse(page);
|
1994
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
2438
1995
|
|
2439
|
-
// ../commons/src/events/
|
2440
|
-
|
2441
|
-
return getUUID();
|
2442
|
-
}
|
1996
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1997
|
+
var import_zod20 = require("zod");
|
2443
1998
|
|
2444
|
-
// ../commons/src/events/
|
2445
|
-
var
|
1999
|
+
// ../commons/src/events/EventIndex.ts
|
2000
|
+
var import_zod19 = require("zod");
|
2001
|
+
|
2002
|
+
// ../commons/src/events/EventMetadata.ts
|
2003
|
+
var import_zod18 = require("zod");
|
2004
|
+
var EventStatus = {
|
2005
|
+
CREATED: "CREATED",
|
2006
|
+
NOTIFIED: "NOTIFIED",
|
2007
|
+
DECLARED: "DECLARED",
|
2008
|
+
VALIDATED: "VALIDATED",
|
2009
|
+
REGISTERED: "REGISTERED",
|
2010
|
+
CERTIFIED: "CERTIFIED",
|
2011
|
+
REJECTED: "REJECTED",
|
2012
|
+
ARCHIVED: "ARCHIVED"
|
2013
|
+
};
|
2014
|
+
var eventStatusValues = [
|
2015
|
+
EventStatus.CREATED,
|
2016
|
+
EventStatus.NOTIFIED,
|
2017
|
+
EventStatus.DECLARED,
|
2018
|
+
EventStatus.VALIDATED,
|
2019
|
+
EventStatus.REGISTERED,
|
2020
|
+
EventStatus.CERTIFIED,
|
2021
|
+
EventStatus.REJECTED,
|
2022
|
+
EventStatus.ARCHIVED
|
2023
|
+
];
|
2024
|
+
var EventStatusEnum = import_zod18.z.enum(eventStatusValues);
|
2025
|
+
var CustomFlags = {
|
2026
|
+
CERTIFICATE_PRINTED: "certificate-printed"
|
2027
|
+
};
|
2028
|
+
var Flag = import_zod18.z.string().regex(
|
2029
|
+
new RegExp(
|
2030
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
|
2031
|
+
),
|
2032
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2033
|
+
).or(import_zod18.z.nativeEnum(CustomFlags));
|
2034
|
+
var eventStatuses = Object.values(EventStatus);
|
2035
|
+
var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
|
2036
|
+
var ZodDate = import_zod18.z.string().date();
|
2037
|
+
var ActionCreationMetadata = import_zod18.z.object({
|
2038
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
|
2039
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
|
2040
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
|
2041
|
+
acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
2042
|
+
createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
|
2043
|
+
});
|
2044
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2045
|
+
registrationNumber: import_zod18.z.string().describe(
|
2046
|
+
"Registration number of the event. Always present for accepted registrations."
|
2047
|
+
)
|
2048
|
+
});
|
2049
|
+
var LegalStatuses = import_zod18.z.object({
|
2050
|
+
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2051
|
+
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2052
|
+
});
|
2053
|
+
var EventMetadata = import_zod18.z.object({
|
2054
|
+
id: import_zod18.z.string(),
|
2055
|
+
type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
|
2056
|
+
status: EventStatuses,
|
2057
|
+
legalStatuses: LegalStatuses.describe(
|
2058
|
+
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2059
|
+
),
|
2060
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2061
|
+
dateOfEvent: ZodDate.nullish(),
|
2062
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
|
2063
|
+
updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
|
2064
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
|
2065
|
+
updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
|
2066
|
+
updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
|
2067
|
+
assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
2068
|
+
updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
|
2069
|
+
trackingId: import_zod18.z.string().describe(
|
2070
|
+
"System-generated tracking ID used by informants or registrars to look up the event."
|
2071
|
+
),
|
2072
|
+
flags: import_zod18.z.array(Flag)
|
2073
|
+
});
|
2074
|
+
var EventMetadataKeys = import_zod18.z.enum([
|
2075
|
+
"id",
|
2076
|
+
"type",
|
2077
|
+
"status",
|
2078
|
+
"createdAt",
|
2079
|
+
"dateOfEvent",
|
2080
|
+
"createdBy",
|
2081
|
+
"updatedByUserRole",
|
2082
|
+
"createdAtLocation",
|
2083
|
+
"updatedAtLocation",
|
2084
|
+
"updatedAt",
|
2085
|
+
"assignedTo",
|
2086
|
+
"updatedBy",
|
2087
|
+
"trackingId",
|
2088
|
+
"legalStatuses",
|
2089
|
+
"flags"
|
2090
|
+
]);
|
2091
|
+
var EventMetadataParameter = import_zod18.z.object({
|
2092
|
+
// @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
|
2093
|
+
$event: EventMetadataKeys
|
2094
|
+
});
|
2095
|
+
var eventMetadataLabelMap = {
|
2096
|
+
"event.assignedTo": {
|
2097
|
+
id: "event.assignedTo.label",
|
2098
|
+
defaultMessage: "Assigned To",
|
2099
|
+
description: "Assigned To"
|
2100
|
+
},
|
2101
|
+
"event.createdAt": {
|
2102
|
+
id: "event.createdAt.label",
|
2103
|
+
defaultMessage: "Created",
|
2104
|
+
description: "Created At"
|
2105
|
+
},
|
2106
|
+
"event.dateOfEvent": {
|
2107
|
+
id: "event.dateOfEvent.label",
|
2108
|
+
defaultMessage: "Date of Event",
|
2109
|
+
description: "Date of Event"
|
2110
|
+
},
|
2111
|
+
"event.createdAtLocation": {
|
2112
|
+
id: "event.createdAtLocation.label",
|
2113
|
+
defaultMessage: "Location",
|
2114
|
+
description: "Created At Location"
|
2115
|
+
},
|
2116
|
+
"event.updatedAtLocation": {
|
2117
|
+
id: "event.updatedAtLocation.label",
|
2118
|
+
defaultMessage: "Location",
|
2119
|
+
description: "Updated At Location"
|
2120
|
+
},
|
2121
|
+
"event.createdBy": {
|
2122
|
+
id: "event.createdBy.label",
|
2123
|
+
defaultMessage: "Created By",
|
2124
|
+
description: "Created By"
|
2125
|
+
},
|
2126
|
+
"event.updatedByUserRole": {
|
2127
|
+
id: "event.updatedByUserRole.label",
|
2128
|
+
defaultMessage: "Updated By Role",
|
2129
|
+
description: "Updated By Role"
|
2130
|
+
},
|
2131
|
+
"event.id": {
|
2132
|
+
id: "event.id.label",
|
2133
|
+
defaultMessage: "ID",
|
2134
|
+
description: "ID"
|
2135
|
+
},
|
2136
|
+
"event.updatedAt": {
|
2137
|
+
id: "event.modifiedAt.label",
|
2138
|
+
defaultMessage: "Updated",
|
2139
|
+
description: "Modified At"
|
2140
|
+
},
|
2141
|
+
"event.status": {
|
2142
|
+
id: "event.status.label",
|
2143
|
+
defaultMessage: "Status",
|
2144
|
+
description: "Status"
|
2145
|
+
},
|
2146
|
+
"event.type": {
|
2147
|
+
id: "event.type.label",
|
2148
|
+
defaultMessage: "Type",
|
2149
|
+
description: "Type"
|
2150
|
+
},
|
2151
|
+
"event.updatedBy": {
|
2152
|
+
id: "event.updatedBy.label",
|
2153
|
+
defaultMessage: "Updated By",
|
2154
|
+
description: "Updated By"
|
2155
|
+
},
|
2156
|
+
"event.trackingId": {
|
2157
|
+
id: "event.trackingId.label",
|
2158
|
+
defaultMessage: "Tracking ID",
|
2159
|
+
description: "Tracking ID"
|
2160
|
+
},
|
2161
|
+
"event.flags": {
|
2162
|
+
id: "event.flags.label",
|
2163
|
+
defaultMessage: "Flags",
|
2164
|
+
description: "Flags"
|
2165
|
+
}
|
2166
|
+
};
|
2167
|
+
|
2168
|
+
// ../commons/src/events/EventIndex.ts
|
2169
|
+
var EventIndex = EventMetadata.extend({
|
2170
|
+
declaration: EventState
|
2171
|
+
});
|
2172
|
+
var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
|
2173
|
+
import_zod19.z.object({
|
2174
|
+
type: import_zod19.z.string()
|
2175
|
+
// Ensures "type" (event-id) exists and is a string
|
2176
|
+
})
|
2177
|
+
);
|
2178
|
+
var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
|
2179
|
+
var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
|
2180
|
+
var AnyOf = import_zod19.z.object({
|
2181
|
+
type: import_zod19.z.literal("anyOf"),
|
2182
|
+
terms: import_zod19.z.array(import_zod19.z.string())
|
2183
|
+
});
|
2184
|
+
var ExactStatus = import_zod19.z.object({
|
2185
|
+
type: import_zod19.z.literal("exact"),
|
2186
|
+
term: EventStatusEnum
|
2187
|
+
});
|
2188
|
+
var AnyOfStatus = import_zod19.z.object({
|
2189
|
+
type: import_zod19.z.literal("anyOf"),
|
2190
|
+
terms: import_zod19.z.array(EventStatusEnum)
|
2191
|
+
});
|
2192
|
+
var Range = import_zod19.z.object({
|
2193
|
+
type: import_zod19.z.literal("range"),
|
2194
|
+
gte: import_zod19.z.string(),
|
2195
|
+
lte: import_zod19.z.string()
|
2196
|
+
});
|
2197
|
+
var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
|
2198
|
+
var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
|
2199
|
+
var DateCondition = import_zod19.z.union([Exact, Range]);
|
2200
|
+
var QueryInput = import_zod19.z.lazy(
|
2201
|
+
() => import_zod19.z.union([
|
2202
|
+
import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
2203
|
+
import_zod19.z.record(import_zod19.z.string(), QueryInput)
|
2204
|
+
])
|
2205
|
+
);
|
2206
|
+
var QueryExpression = import_zod19.z.object({
|
2207
|
+
eventType: import_zod19.z.string(),
|
2208
|
+
status: import_zod19.z.optional(import_zod19.z.union([AnyOfStatus, ExactStatus])),
|
2209
|
+
createdAt: import_zod19.z.optional(DateCondition),
|
2210
|
+
updatedAt: import_zod19.z.optional(DateCondition),
|
2211
|
+
createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2212
|
+
updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2213
|
+
createdBy: import_zod19.z.optional(Exact),
|
2214
|
+
updatedBy: import_zod19.z.optional(Exact),
|
2215
|
+
trackingId: import_zod19.z.optional(Exact),
|
2216
|
+
flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
|
2217
|
+
data: QueryInput
|
2218
|
+
}).partial();
|
2219
|
+
var Or2 = import_zod19.z.object({
|
2220
|
+
type: import_zod19.z.literal("or"),
|
2221
|
+
clauses: import_zod19.z.array(QueryExpression)
|
2222
|
+
});
|
2223
|
+
var And2 = import_zod19.z.object({
|
2224
|
+
type: import_zod19.z.literal("and"),
|
2225
|
+
clauses: import_zod19.z.array(QueryExpression)
|
2226
|
+
});
|
2227
|
+
var QueryType = import_zod19.z.discriminatedUnion("type", [Or2, And2]);
|
2446
2228
|
|
2447
2229
|
// ../commons/src/conditionals/conditionals.ts
|
2448
2230
|
function defineConditional(schema) {
|
@@ -2506,32 +2288,38 @@ var user = {
|
|
2506
2288
|
required: ["$user"]
|
2507
2289
|
})
|
2508
2290
|
};
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2291
|
+
function createEventConditionals() {
|
2292
|
+
return {
|
2293
|
+
/**
|
2294
|
+
* Checks if the event contains a specific action type.
|
2295
|
+
* @param action - The action type to check for.
|
2296
|
+
*/
|
2297
|
+
hasAction: (action) => defineConditional({
|
2298
|
+
type: "object",
|
2299
|
+
properties: {
|
2300
|
+
$event: {
|
2301
|
+
type: "object",
|
2302
|
+
properties: {
|
2303
|
+
actions: {
|
2304
|
+
type: "array",
|
2305
|
+
contains: {
|
2306
|
+
type: "object",
|
2307
|
+
properties: {
|
2308
|
+
type: {
|
2309
|
+
const: action
|
2310
|
+
}
|
2311
|
+
},
|
2312
|
+
required: ["type"]
|
2313
|
+
}
|
2526
2314
|
}
|
2527
|
-
}
|
2528
|
-
|
2529
|
-
|
2530
|
-
}
|
2531
|
-
|
2532
|
-
|
2533
|
-
}
|
2534
|
-
}
|
2315
|
+
},
|
2316
|
+
required: ["actions"]
|
2317
|
+
}
|
2318
|
+
},
|
2319
|
+
required: ["$event"]
|
2320
|
+
})
|
2321
|
+
};
|
2322
|
+
}
|
2535
2323
|
function getDateFromNow(days) {
|
2536
2324
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2537
2325
|
}
|
@@ -2552,7 +2340,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
|
2552
2340
|
function isFieldReference(value) {
|
2553
2341
|
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2554
2342
|
}
|
2555
|
-
function
|
2343
|
+
function createFieldConditionals(fieldId) {
|
2556
2344
|
const getDateRange = (date, clause) => ({
|
2557
2345
|
type: "object",
|
2558
2346
|
properties: {
|
@@ -2565,10 +2353,6 @@ function field(fieldId) {
|
|
2565
2353
|
required: [fieldId]
|
2566
2354
|
});
|
2567
2355
|
return {
|
2568
|
-
/**
|
2569
|
-
* @private Internal property used for field reference tracking.
|
2570
|
-
*/
|
2571
|
-
_fieldId: fieldId,
|
2572
2356
|
isAfter: () => ({
|
2573
2357
|
days: (days) => ({
|
2574
2358
|
inPast: () => defineFormConditional(
|
@@ -2725,65 +2509,610 @@ function field(fieldId) {
|
|
2725
2509
|
},
|
2726
2510
|
required: [fieldId]
|
2727
2511
|
}),
|
2728
|
-
isBetween: (min, max) => defineFormConditional({
|
2729
|
-
type: "object",
|
2730
|
-
properties: {
|
2731
|
-
[fieldId]: {
|
2732
|
-
type: "number",
|
2733
|
-
minimum: min,
|
2734
|
-
maximum: max
|
2512
|
+
isBetween: (min, max) => defineFormConditional({
|
2513
|
+
type: "object",
|
2514
|
+
properties: {
|
2515
|
+
[fieldId]: {
|
2516
|
+
type: "number",
|
2517
|
+
minimum: min,
|
2518
|
+
maximum: max
|
2519
|
+
}
|
2520
|
+
},
|
2521
|
+
required: [fieldId]
|
2522
|
+
}),
|
2523
|
+
getId: () => ({ fieldId })
|
2524
|
+
};
|
2525
|
+
}
|
2526
|
+
|
2527
|
+
// ../commons/src/event-config/event-configuration.ts
|
2528
|
+
function createEventFieldConfig(fieldId, options) {
|
2529
|
+
return {
|
2530
|
+
fieldId,
|
2531
|
+
options,
|
2532
|
+
config: { type: "exact" },
|
2533
|
+
fieldType: "event"
|
2534
|
+
};
|
2535
|
+
}
|
2536
|
+
|
2537
|
+
// ../commons/src/events/event.ts
|
2538
|
+
function eventFn(fieldId, options) {
|
2539
|
+
return createEventFieldConfig(fieldId, options);
|
2540
|
+
}
|
2541
|
+
var event = Object.assign(eventFn, {
|
2542
|
+
...createEventConditionals(),
|
2543
|
+
field(field2) {
|
2544
|
+
return {
|
2545
|
+
$event: field2
|
2546
|
+
};
|
2547
|
+
}
|
2548
|
+
});
|
2549
|
+
|
2550
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
2551
|
+
var WorkqueueConfig = import_zod20.z.object({
|
2552
|
+
slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
|
2553
|
+
name: TranslationConfig.describe(
|
2554
|
+
"Title of the workflow (both in navigation and on the page)"
|
2555
|
+
),
|
2556
|
+
query: QueryType,
|
2557
|
+
actions: import_zod20.z.array(
|
2558
|
+
import_zod20.z.object({
|
2559
|
+
type: import_zod20.z.string(),
|
2560
|
+
conditionals: import_zod20.z.array(Conditional).optional()
|
2561
|
+
})
|
2562
|
+
),
|
2563
|
+
columns: import_zod20.z.array(
|
2564
|
+
import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
|
2565
|
+
).default([
|
2566
|
+
{
|
2567
|
+
label: {
|
2568
|
+
id: "workqueues.dateOfEvent",
|
2569
|
+
defaultMessage: "Date of Event",
|
2570
|
+
description: "Label for workqueue column: dateOfEvent"
|
2571
|
+
},
|
2572
|
+
value: event.field("dateOfEvent")
|
2573
|
+
}
|
2574
|
+
])
|
2575
|
+
}).describe("Configuration for workqueue.");
|
2576
|
+
function defineWorkqueue(workqueues) {
|
2577
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
2578
|
+
}
|
2579
|
+
|
2580
|
+
// ../commons/src/events/Draft.ts
|
2581
|
+
var import_zod22 = require("zod");
|
2582
|
+
|
2583
|
+
// ../commons/src/events/ActionInput.ts
|
2584
|
+
var import_zod21 = require("zod");
|
2585
|
+
var import_zod_openapi9 = require("zod-openapi");
|
2586
|
+
(0, import_zod_openapi9.extendZodWithOpenApi)(import_zod21.z);
|
2587
|
+
var BaseActionInput = import_zod21.z.object({
|
2588
|
+
eventId: import_zod21.z.string(),
|
2589
|
+
transactionId: import_zod21.z.string(),
|
2590
|
+
declaration: ActionUpdate.default({}),
|
2591
|
+
annotation: ActionUpdate.optional(),
|
2592
|
+
originalActionId: import_zod21.z.string().optional(),
|
2593
|
+
keepAssignment: import_zod21.z.boolean().optional()
|
2594
|
+
});
|
2595
|
+
var CreateActionInput = BaseActionInput.merge(
|
2596
|
+
import_zod21.z.object({
|
2597
|
+
type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2598
|
+
createdAtLocation: import_zod21.z.string()
|
2599
|
+
})
|
2600
|
+
);
|
2601
|
+
var RegisterActionInput = BaseActionInput.merge(
|
2602
|
+
import_zod21.z.object({
|
2603
|
+
type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2604
|
+
registrationNumber: import_zod21.z.string().optional()
|
2605
|
+
})
|
2606
|
+
);
|
2607
|
+
var ValidateActionInput = BaseActionInput.merge(
|
2608
|
+
import_zod21.z.object({
|
2609
|
+
type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2610
|
+
duplicates: import_zod21.z.array(import_zod21.z.string())
|
2611
|
+
})
|
2612
|
+
);
|
2613
|
+
var NotifyActionInput = BaseActionInput.merge(
|
2614
|
+
import_zod21.z.object({
|
2615
|
+
type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2616
|
+
})
|
2617
|
+
);
|
2618
|
+
var DeclareActionInput = BaseActionInput.merge(
|
2619
|
+
import_zod21.z.object({
|
2620
|
+
type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2621
|
+
})
|
2622
|
+
);
|
2623
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
2624
|
+
import_zod21.z.object({
|
2625
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2626
|
+
})
|
2627
|
+
);
|
2628
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2629
|
+
import_zod21.z.object({
|
2630
|
+
type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2631
|
+
})
|
2632
|
+
);
|
2633
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2634
|
+
import_zod21.z.object({
|
2635
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2636
|
+
})
|
2637
|
+
);
|
2638
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2639
|
+
import_zod21.z.object({
|
2640
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2641
|
+
})
|
2642
|
+
);
|
2643
|
+
var AssignActionInput = BaseActionInput.merge(
|
2644
|
+
import_zod21.z.object({
|
2645
|
+
type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2646
|
+
assignedTo: import_zod21.z.string()
|
2647
|
+
})
|
2648
|
+
);
|
2649
|
+
var UnassignActionInput = BaseActionInput.merge(
|
2650
|
+
import_zod21.z.object({
|
2651
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2652
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
2653
|
+
})
|
2654
|
+
);
|
2655
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2656
|
+
import_zod21.z.object({
|
2657
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2658
|
+
})
|
2659
|
+
);
|
2660
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2661
|
+
import_zod21.z.object({
|
2662
|
+
requestId: import_zod21.z.string(),
|
2663
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2664
|
+
})
|
2665
|
+
);
|
2666
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2667
|
+
import_zod21.z.object({
|
2668
|
+
requestId: import_zod21.z.string(),
|
2669
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2670
|
+
})
|
2671
|
+
);
|
2672
|
+
var ReadActionInput = BaseActionInput.merge(
|
2673
|
+
import_zod21.z.object({
|
2674
|
+
type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
|
2675
|
+
})
|
2676
|
+
);
|
2677
|
+
var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
|
2678
|
+
var ActionInput = import_zod21.z.discriminatedUnion("type", [
|
2679
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2680
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2681
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2682
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2683
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2684
|
+
RejectDeclarationActionInput.openapi({
|
2685
|
+
ref: "RejectDeclarationActionInput"
|
2686
|
+
}),
|
2687
|
+
MarkedAsDuplicateActionInput.openapi({
|
2688
|
+
ref: "MarkedAsDuplicateActionInput"
|
2689
|
+
}),
|
2690
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2691
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2692
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2693
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2694
|
+
RequestCorrectionActionInput.openapi({
|
2695
|
+
ref: "RequestCorrectionActionInput"
|
2696
|
+
}),
|
2697
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2698
|
+
ApproveCorrectionActionInput.openapi({
|
2699
|
+
ref: "ApproveCorrectionActionInput"
|
2700
|
+
}),
|
2701
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2702
|
+
]).openapi({
|
2703
|
+
ref: "ActionInput"
|
2704
|
+
});
|
2705
|
+
|
2706
|
+
// ../commons/src/events/Draft.ts
|
2707
|
+
var Draft = import_zod22.z.object({
|
2708
|
+
id: import_zod22.z.string(),
|
2709
|
+
eventId: import_zod22.z.string(),
|
2710
|
+
transactionId: import_zod22.z.string(),
|
2711
|
+
createdAt: import_zod22.z.string().datetime(),
|
2712
|
+
action: ActionBase.extend({
|
2713
|
+
type: ActionTypes
|
2714
|
+
}).omit({ id: true })
|
2715
|
+
});
|
2716
|
+
var DraftInput = BaseActionInput.extend({
|
2717
|
+
type: ActionTypes,
|
2718
|
+
status: import_zod22.z.enum([
|
2719
|
+
ActionStatus.Requested,
|
2720
|
+
ActionStatus.Accepted,
|
2721
|
+
ActionStatus.Rejected
|
2722
|
+
])
|
2723
|
+
});
|
2724
|
+
|
2725
|
+
// ../commons/src/events/EventInput.ts
|
2726
|
+
var import_zod23 = require("zod");
|
2727
|
+
var EventInput = import_zod23.z.object({
|
2728
|
+
transactionId: import_zod23.z.string(),
|
2729
|
+
type: import_zod23.z.string(),
|
2730
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
|
2731
|
+
});
|
2732
|
+
|
2733
|
+
// ../commons/src/events/EventDocument.ts
|
2734
|
+
var import_zod24 = require("zod");
|
2735
|
+
var import_zod_openapi10 = require("zod-openapi");
|
2736
|
+
(0, import_zod_openapi10.extendZodWithOpenApi)(import_zod24.z);
|
2737
|
+
var EventDocument = import_zod24.z.object({
|
2738
|
+
id: import_zod24.z.string(),
|
2739
|
+
type: import_zod24.z.string(),
|
2740
|
+
dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
|
2741
|
+
createdAt: import_zod24.z.string().datetime(),
|
2742
|
+
updatedAt: import_zod24.z.string().datetime(),
|
2743
|
+
actions: import_zod24.z.array(Action),
|
2744
|
+
trackingId: import_zod24.z.string()
|
2745
|
+
}).openapi({ ref: "EventDocument" });
|
2746
|
+
|
2747
|
+
// ../commons/src/events/state/utils.ts
|
2748
|
+
function getActionRequests(actionType, actions) {
|
2749
|
+
const filtered = actions.filter((action) => action.type === actionType);
|
2750
|
+
const accept = filtered.find(
|
2751
|
+
(action) => action.status === ActionStatus.Accepted
|
2752
|
+
);
|
2753
|
+
const request = filtered.find(
|
2754
|
+
(action) => action.status === ActionStatus.Requested
|
2755
|
+
);
|
2756
|
+
const reject = filtered.find(
|
2757
|
+
(action) => action.status === ActionStatus.Rejected
|
2758
|
+
);
|
2759
|
+
return {
|
2760
|
+
reject,
|
2761
|
+
accept,
|
2762
|
+
request
|
2763
|
+
};
|
2764
|
+
}
|
2765
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
2766
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
2767
|
+
actionType,
|
2768
|
+
actions
|
2769
|
+
);
|
2770
|
+
if (!acceptAction) {
|
2771
|
+
return null;
|
2772
|
+
}
|
2773
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
2774
|
+
return {
|
2775
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
2776
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
2777
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
2778
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
2779
|
+
acceptedAt: acceptAction.createdAt,
|
2780
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
2781
|
+
registrationNumber
|
2782
|
+
};
|
2783
|
+
}
|
2784
|
+
function getDeclarationActionUpdateMetadata(actions) {
|
2785
|
+
const createAction = getOrThrow(
|
2786
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
2787
|
+
`Event has no ${ActionType.CREATE} action`
|
2788
|
+
);
|
2789
|
+
return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
|
2790
|
+
(metadata, actionType) => {
|
2791
|
+
const { accept, request } = getActionRequests(actionType, actions);
|
2792
|
+
return {
|
2793
|
+
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
2794
|
+
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
2795
|
+
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
2796
|
+
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
2797
|
+
};
|
2798
|
+
},
|
2799
|
+
{
|
2800
|
+
createdAt: createAction.createdAt,
|
2801
|
+
createdBy: createAction.createdBy,
|
2802
|
+
createdAtLocation: createAction.createdAtLocation,
|
2803
|
+
createdByRole: createAction.createdByRole
|
2804
|
+
}
|
2805
|
+
);
|
2806
|
+
}
|
2807
|
+
function getLegalStatuses(actions) {
|
2808
|
+
return {
|
2809
|
+
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
2810
|
+
ActionType.DECLARE,
|
2811
|
+
actions
|
2812
|
+
),
|
2813
|
+
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
2814
|
+
ActionType.REGISTER,
|
2815
|
+
actions
|
2816
|
+
)
|
2817
|
+
};
|
2818
|
+
}
|
2819
|
+
|
2820
|
+
// ../commons/src/events/state/index.ts
|
2821
|
+
function getStatusFromActions(actions) {
|
2822
|
+
const hasRejectedAction = actions.some(
|
2823
|
+
(a) => a.status === ActionStatus.Rejected
|
2824
|
+
);
|
2825
|
+
if (hasRejectedAction) {
|
2826
|
+
return EventStatus.REJECTED;
|
2827
|
+
}
|
2828
|
+
return actions.reduce((status, action) => {
|
2829
|
+
switch (action.type) {
|
2830
|
+
case ActionType.CREATE:
|
2831
|
+
return EventStatus.CREATED;
|
2832
|
+
case ActionType.DECLARE:
|
2833
|
+
return EventStatus.DECLARED;
|
2834
|
+
case ActionType.VALIDATE:
|
2835
|
+
return EventStatus.VALIDATED;
|
2836
|
+
case ActionType.REGISTER:
|
2837
|
+
return EventStatus.REGISTERED;
|
2838
|
+
case ActionType.REJECT:
|
2839
|
+
return EventStatus.REJECTED;
|
2840
|
+
case ActionType.ARCHIVE:
|
2841
|
+
return EventStatus.ARCHIVED;
|
2842
|
+
case ActionType.NOTIFY:
|
2843
|
+
return EventStatus.NOTIFIED;
|
2844
|
+
case ActionType.PRINT_CERTIFICATE:
|
2845
|
+
return EventStatus.CERTIFIED;
|
2846
|
+
case ActionType.ASSIGN:
|
2847
|
+
case ActionType.UNASSIGN:
|
2848
|
+
case ActionType.REQUEST_CORRECTION:
|
2849
|
+
case ActionType.APPROVE_CORRECTION:
|
2850
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2851
|
+
case ActionType.REJECT_CORRECTION:
|
2852
|
+
case ActionType.READ:
|
2853
|
+
default:
|
2854
|
+
return status;
|
2855
|
+
}
|
2856
|
+
}, EventStatus.CREATED);
|
2857
|
+
}
|
2858
|
+
function getFlagsFromActions(actions) {
|
2859
|
+
const sortedactions = actions.sort(
|
2860
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
2861
|
+
);
|
2862
|
+
const actionStatus = sortedactions.reduce(
|
2863
|
+
(actionStatuses, { type, status }) => ({
|
2864
|
+
...actionStatuses,
|
2865
|
+
[type]: status
|
2866
|
+
}),
|
2867
|
+
{}
|
2868
|
+
);
|
2869
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
2870
|
+
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
2871
|
+
return flag;
|
2872
|
+
});
|
2873
|
+
const isCertificatePrinted = sortedactions.reduce(
|
2874
|
+
(prev, { type }) => {
|
2875
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
2876
|
+
return true;
|
2877
|
+
}
|
2878
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
2879
|
+
return false;
|
2880
|
+
}
|
2881
|
+
return prev;
|
2882
|
+
},
|
2883
|
+
false
|
2884
|
+
);
|
2885
|
+
if (isCertificatePrinted) {
|
2886
|
+
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
2887
|
+
}
|
2888
|
+
return flags;
|
2889
|
+
}
|
2890
|
+
function getAssignedUserFromActions(actions) {
|
2891
|
+
return actions.reduce((user2, action) => {
|
2892
|
+
if (action.type === ActionType.ASSIGN) {
|
2893
|
+
return action.assignedTo;
|
2894
|
+
}
|
2895
|
+
if (action.type === ActionType.UNASSIGN) {
|
2896
|
+
return null;
|
2897
|
+
}
|
2898
|
+
return user2;
|
2899
|
+
}, null);
|
2900
|
+
}
|
2901
|
+
function aggregateActionDeclarations(actions) {
|
2902
|
+
const excludedActions = [
|
2903
|
+
ActionType.REQUEST_CORRECTION,
|
2904
|
+
ActionType.PRINT_CERTIFICATE
|
2905
|
+
];
|
2906
|
+
return actions.reduce((status, action) => {
|
2907
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2908
|
+
return status;
|
2909
|
+
}
|
2910
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2911
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2912
|
+
if (!requestAction) {
|
2913
|
+
return status;
|
2914
|
+
}
|
2915
|
+
return deepMerge(status, requestAction.declaration);
|
2916
|
+
}
|
2917
|
+
return deepMerge(status, action.declaration);
|
2918
|
+
}, {});
|
2919
|
+
}
|
2920
|
+
function deepDropNulls(obj) {
|
2921
|
+
if (Array.isArray(obj)) {
|
2922
|
+
return obj.map(deepDropNulls);
|
2923
|
+
}
|
2924
|
+
if (obj !== null && typeof obj === "object") {
|
2925
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2926
|
+
const cleanedValue = deepDropNulls(value);
|
2927
|
+
if (cleanedValue !== null) {
|
2928
|
+
;
|
2929
|
+
acc[key] = cleanedValue;
|
2930
|
+
}
|
2931
|
+
return acc;
|
2932
|
+
}, {});
|
2933
|
+
}
|
2934
|
+
return obj;
|
2935
|
+
}
|
2936
|
+
function isUndeclaredDraft(status) {
|
2937
|
+
return status === EventStatus.CREATED;
|
2938
|
+
}
|
2939
|
+
function getAcceptedActions(event2) {
|
2940
|
+
return event2.actions.filter(
|
2941
|
+
(a) => a.status === ActionStatus.Accepted
|
2942
|
+
);
|
2943
|
+
}
|
2944
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
2945
|
+
function getCurrentEventState(event2) {
|
2946
|
+
const creationAction = event2.actions.find(
|
2947
|
+
(action) => action.type === ActionType.CREATE
|
2948
|
+
);
|
2949
|
+
if (!creationAction) {
|
2950
|
+
throw new Error(`Event ${event2.id} has no creation action`);
|
2951
|
+
}
|
2952
|
+
const acceptedActions = getAcceptedActions(event2);
|
2953
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
2954
|
+
event2.actions
|
2955
|
+
);
|
2956
|
+
const declaration = aggregateActionDeclarations(acceptedActions);
|
2957
|
+
const dateOfEvent = ZodDate.safeParse(
|
2958
|
+
event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
|
2959
|
+
).data ?? null;
|
2960
|
+
return deepDropNulls({
|
2961
|
+
id: event2.id,
|
2962
|
+
type: event2.type,
|
2963
|
+
status: getStatusFromActions(event2.actions),
|
2964
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
2965
|
+
createdAt: creationAction.createdAt,
|
2966
|
+
createdBy: creationAction.createdBy,
|
2967
|
+
createdAtLocation: creationAction.createdAtLocation,
|
2968
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
2969
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
2970
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
2971
|
+
updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
|
2972
|
+
declaration,
|
2973
|
+
trackingId: event2.trackingId,
|
2974
|
+
// @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
|
2975
|
+
updatedByUserRole: declarationUpdateMetadata.createdByRole,
|
2976
|
+
dateOfEvent,
|
2977
|
+
flags: getFlagsFromActions(event2.actions)
|
2978
|
+
});
|
2979
|
+
}
|
2980
|
+
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2981
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2982
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2983
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2984
|
+
return [
|
2985
|
+
action,
|
2986
|
+
{
|
2987
|
+
...action,
|
2988
|
+
type: ActionType.APPROVE_CORRECTION
|
2735
2989
|
}
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2990
|
+
];
|
2991
|
+
}
|
2992
|
+
return [action];
|
2993
|
+
});
|
2994
|
+
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2995
|
+
const withDrafts = {
|
2996
|
+
...event2,
|
2997
|
+
actions: actionWithDrafts
|
2998
|
+
};
|
2999
|
+
return getCurrentEventState(withDrafts);
|
3000
|
+
}
|
3001
|
+
function applyDraftsToEventIndex(eventIndex, drafts) {
|
3002
|
+
const indexedAt = eventIndex.updatedAt;
|
3003
|
+
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
3004
|
+
if (activeDrafts.length === 0) {
|
3005
|
+
return eventIndex;
|
3006
|
+
}
|
3007
|
+
return {
|
3008
|
+
...eventIndex,
|
3009
|
+
declaration: {
|
3010
|
+
...eventIndex.declaration,
|
3011
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
3012
|
+
}
|
3013
|
+
};
|
3014
|
+
}
|
3015
|
+
function getAnnotationFromDrafts(drafts) {
|
3016
|
+
const actions = drafts.map((draft) => draft.action);
|
3017
|
+
const annotation = actions.reduce((ann, action) => {
|
3018
|
+
return deepMerge(ann, action.annotation ?? {});
|
3019
|
+
}, {});
|
3020
|
+
return deepDropNulls(annotation);
|
3021
|
+
}
|
3022
|
+
function getActionAnnotation({
|
3023
|
+
event: event2,
|
3024
|
+
actionType,
|
3025
|
+
drafts = []
|
3026
|
+
}) {
|
3027
|
+
const activeActions = getAcceptedActions(event2);
|
3028
|
+
const action = activeActions.find(
|
3029
|
+
(activeAction) => actionType === activeAction.type
|
3030
|
+
);
|
3031
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
3032
|
+
const sorted = [
|
3033
|
+
...action ? [action] : [],
|
3034
|
+
...eventDrafts.map((draft) => draft.action)
|
3035
|
+
].sort();
|
3036
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
3037
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
3038
|
+
}, {});
|
3039
|
+
return deepDropNulls(annotation);
|
3040
|
+
}
|
3041
|
+
|
3042
|
+
// ../commons/src/events/defineConfig.ts
|
3043
|
+
var defineConfig = (config) => {
|
3044
|
+
const input = EventConfig.parse(config);
|
3045
|
+
return input;
|
3046
|
+
};
|
3047
|
+
|
3048
|
+
// ../commons/src/events/transactions.ts
|
3049
|
+
function generateTransactionId() {
|
3050
|
+
return getUUID();
|
3051
|
+
}
|
3052
|
+
|
3053
|
+
// ../commons/src/events/test.utils.ts
|
3054
|
+
var import_lodash2 = require("lodash");
|
3055
|
+
|
3056
|
+
// ../commons/src/field-config/field-configuration.ts
|
3057
|
+
function createFieldConfigs(fieldId) {
|
3058
|
+
const baseField = {
|
3059
|
+
fieldId,
|
3060
|
+
fieldType: "field"
|
3061
|
+
};
|
3062
|
+
return {
|
2739
3063
|
/**
|
2740
3064
|
* Creates a range configuration for the specified field.
|
2741
3065
|
*
|
2742
|
-
* @returns An object containing the field ID and a configuration object with a type of '
|
3066
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2743
3067
|
*
|
2744
3068
|
* @example field('age').range()
|
2745
3069
|
* // {
|
2746
3070
|
* // fieldId: 'age',
|
2747
|
-
* // config: { type: '
|
3071
|
+
* // config: { type: 'range' }
|
2748
3072
|
* // }
|
2749
3073
|
*/
|
2750
3074
|
range: () => ({
|
2751
|
-
|
2752
|
-
config: { type: "
|
3075
|
+
...baseField,
|
3076
|
+
config: { type: "range" }
|
2753
3077
|
}),
|
2754
3078
|
/**
|
2755
3079
|
* Creates a configuration for exact matching of the specified field.
|
2756
|
-
* @returns An object containing the field ID and a configuration object with a type of '
|
3080
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2757
3081
|
* @example field('dob').exact()
|
2758
3082
|
* // {
|
2759
3083
|
* // fieldId: 'dob',
|
2760
|
-
* // config: { type: '
|
3084
|
+
* // config: { type: 'exact' }
|
2761
3085
|
* // }
|
2762
3086
|
*/
|
2763
3087
|
exact: () => ({
|
2764
|
-
|
2765
|
-
config: { type: "
|
3088
|
+
...baseField,
|
3089
|
+
config: { type: "exact" }
|
2766
3090
|
}),
|
2767
3091
|
/**
|
2768
3092
|
* Creates a configuration for fuzzy matching of the specified field.
|
2769
|
-
* @returns An object containing the field ID and a configuration object with a type of '
|
3093
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2770
3094
|
* @example field('name').fuzzy()
|
2771
3095
|
* // {
|
2772
3096
|
* // fieldId: 'name',
|
2773
|
-
* // config: { type: '
|
3097
|
+
* // config: { type: 'fuzzy' }
|
2774
3098
|
* // }
|
2775
3099
|
*/
|
2776
3100
|
fuzzy: () => ({
|
2777
|
-
|
2778
|
-
config: { type: "
|
3101
|
+
...baseField,
|
3102
|
+
config: { type: "fuzzy" }
|
2779
3103
|
})
|
2780
3104
|
};
|
2781
3105
|
}
|
2782
|
-
|
3106
|
+
|
3107
|
+
// ../commons/src/events/field.ts
|
3108
|
+
function field(fieldId) {
|
2783
3109
|
return {
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
3110
|
+
/**
|
3111
|
+
* @private Internal property used for field reference tracking.
|
3112
|
+
*/
|
3113
|
+
_fieldId: fieldId,
|
3114
|
+
...createFieldConditionals(fieldId),
|
3115
|
+
...createFieldConfigs(fieldId)
|
2787
3116
|
};
|
2788
3117
|
}
|
2789
3118
|
|
@@ -3703,20 +4032,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3703
4032
|
description: "This is what this event is referred as in the system",
|
3704
4033
|
id: "event.tennis-club-membership.label"
|
3705
4034
|
},
|
4035
|
+
title: {
|
4036
|
+
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
4037
|
+
description: "This is the title of the summary",
|
4038
|
+
id: "v2.event.tennis-club-membership.title"
|
4039
|
+
},
|
3706
4040
|
summary: {
|
3707
|
-
title: {
|
3708
|
-
id: "event.tennis-club-membership.summary.title",
|
3709
|
-
label: {
|
3710
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3711
|
-
description: "This is the title of the summary",
|
3712
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3713
|
-
},
|
3714
|
-
emptyValueMessage: {
|
3715
|
-
defaultMessage: "Membership application",
|
3716
|
-
description: "This is the message shown when the applicant name is missing",
|
3717
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3718
|
-
}
|
3719
|
-
},
|
3720
4041
|
fields: [
|
3721
4042
|
{
|
3722
4043
|
id: "applicant.firstname",
|
@@ -3737,47 +4058,18 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3737
4058
|
}
|
3738
4059
|
},
|
3739
4060
|
{
|
3740
|
-
|
4061
|
+
fieldId: "applicant.surname",
|
3741
4062
|
label: {
|
3742
4063
|
defaultMessage: "Applicant's last name",
|
3743
|
-
description: "
|
3744
|
-
id: "event.tennis-club-membership.summary.field.surname.label"
|
3745
|
-
},
|
3746
|
-
value: {
|
3747
|
-
defaultMessage: "{applicant.surname}",
|
3748
|
-
description: "This is the value to show in the summary",
|
3749
|
-
id: "event.tennis-club-membership.summary.field.surname"
|
3750
|
-
},
|
3751
|
-
emptyValueMessage: {
|
3752
|
-
defaultMessage: "Last name is not provided",
|
3753
|
-
description: "This is the message to show when the field is empty",
|
3754
|
-
id: "event.tennis-club-membership.summary.field.surname.empty"
|
4064
|
+
description: "Label for surname",
|
4065
|
+
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
3755
4066
|
}
|
4067
|
+
},
|
4068
|
+
{
|
4069
|
+
fieldId: "applicant.email"
|
3756
4070
|
}
|
3757
4071
|
]
|
3758
4072
|
},
|
3759
|
-
workqueues: [
|
3760
|
-
{
|
3761
|
-
id: "all",
|
3762
|
-
filters: []
|
3763
|
-
},
|
3764
|
-
{
|
3765
|
-
id: "ready-for-review",
|
3766
|
-
filters: [
|
3767
|
-
{
|
3768
|
-
status: ["DECLARED"]
|
3769
|
-
}
|
3770
|
-
]
|
3771
|
-
},
|
3772
|
-
{
|
3773
|
-
id: "registered",
|
3774
|
-
filters: [
|
3775
|
-
{
|
3776
|
-
status: ["REGISTERED"]
|
3777
|
-
}
|
3778
|
-
]
|
3779
|
-
}
|
3780
|
-
],
|
3781
4073
|
actions: [
|
3782
4074
|
{
|
3783
4075
|
type: ActionType.DECLARE,
|
@@ -4118,10 +4410,10 @@ function generateActionAnnotationInput(configuration, action) {
|
|
4118
4410
|
);
|
4119
4411
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4120
4412
|
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4121
|
-
const visibleVerificationPageIds =
|
4122
|
-
configuration,
|
4123
|
-
|
4124
|
-
)
|
4413
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4414
|
+
findRecordActionPages(configuration, action),
|
4415
|
+
annotation
|
4416
|
+
);
|
4125
4417
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
4126
4418
|
(acc, pageId) => ({
|
4127
4419
|
...acc,
|
@@ -4145,13 +4437,14 @@ var eventPayloadGenerator = {
|
|
4145
4437
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4146
4438
|
id
|
4147
4439
|
}),
|
4148
|
-
draft: ({ eventId, actionType }, input = {}) => (0,
|
4440
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
4149
4441
|
{
|
4150
4442
|
id: getUUID(),
|
4151
4443
|
eventId,
|
4152
4444
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4153
4445
|
transactionId: getUUID(),
|
4154
4446
|
action: {
|
4447
|
+
transactionId: getUUID(),
|
4155
4448
|
type: actionType,
|
4156
4449
|
status: ActionStatus.Accepted,
|
4157
4450
|
declaration: {
|
@@ -4166,8 +4459,8 @@ var eventPayloadGenerator = {
|
|
4166
4459
|
},
|
4167
4460
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4168
4461
|
createdBy: "@todo",
|
4169
|
-
|
4170
|
-
|
4462
|
+
createdByRole: "@todo",
|
4463
|
+
createdAtLocation: "@todo"
|
4171
4464
|
}
|
4172
4465
|
},
|
4173
4466
|
input
|
@@ -4192,12 +4485,12 @@ var eventPayloadGenerator = {
|
|
4192
4485
|
notify: (eventId, input = {}) => {
|
4193
4486
|
let declaration = input.declaration;
|
4194
4487
|
if (!declaration) {
|
4195
|
-
const partialDeclaration = (0,
|
4488
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4196
4489
|
generateActionDeclarationInput(
|
4197
4490
|
tennisClubMembershipEvent,
|
4198
4491
|
ActionType.DECLARE
|
4199
4492
|
),
|
4200
|
-
|
4493
|
+
import_lodash2.isString
|
4201
4494
|
);
|
4202
4495
|
declaration = partialDeclaration;
|
4203
4496
|
}
|
@@ -4328,13 +4621,14 @@ function generateActionDocument({
|
|
4328
4621
|
// @TODO: This should be fixed in the future.
|
4329
4622
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4330
4623
|
createdBy: getUUID(),
|
4624
|
+
createdByRole: "FIELD_AGENT",
|
4331
4625
|
id: getUUID(),
|
4332
|
-
createdAtLocation: "
|
4333
|
-
updatedAtLocation: "TODO",
|
4626
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4334
4627
|
declaration: generateActionDeclarationInput(configuration, action),
|
4335
4628
|
annotation: {},
|
4336
|
-
|
4337
|
-
|
4629
|
+
status: ActionStatus.Accepted,
|
4630
|
+
transactionId: getUUID(),
|
4631
|
+
...defaults
|
4338
4632
|
};
|
4339
4633
|
switch (action) {
|
4340
4634
|
case ActionType.READ:
|
@@ -4392,7 +4686,8 @@ function generateEventDocument({
|
|
4392
4686
|
id: getUUID(),
|
4393
4687
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4394
4688
|
// @TODO: This should be fixed in the future.
|
4395
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4689
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4690
|
+
dateOfEvent: configuration.dateOfEvent
|
4396
4691
|
};
|
4397
4692
|
}
|
4398
4693
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4414,10 +4709,64 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4414
4709
|
eventId
|
4415
4710
|
};
|
4416
4711
|
}
|
4712
|
+
function getEventStatus() {
|
4713
|
+
const statuses = [
|
4714
|
+
EventStatus.CREATED,
|
4715
|
+
EventStatus.REGISTERED,
|
4716
|
+
EventStatus.DECLARED
|
4717
|
+
];
|
4718
|
+
const randomIndex = Math.floor(Math.random() * 3);
|
4719
|
+
return statuses[randomIndex];
|
4720
|
+
}
|
4721
|
+
function getTrackingId() {
|
4722
|
+
const uuid = getUUID().replace(/-/g, "");
|
4723
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4724
|
+
return trackingId;
|
4725
|
+
}
|
4726
|
+
function getRandomApplicant() {
|
4727
|
+
const firstNames = [
|
4728
|
+
"Danny",
|
4729
|
+
"John",
|
4730
|
+
"Jane",
|
4731
|
+
"Emily",
|
4732
|
+
"Michael",
|
4733
|
+
"Sarah",
|
4734
|
+
"Chris",
|
4735
|
+
"Jessica"
|
4736
|
+
];
|
4737
|
+
const surnames = [
|
4738
|
+
"Doe",
|
4739
|
+
"Smith",
|
4740
|
+
"Johnson",
|
4741
|
+
"Brown",
|
4742
|
+
"Williams",
|
4743
|
+
"Jones",
|
4744
|
+
"Garcia",
|
4745
|
+
"Miller"
|
4746
|
+
];
|
4747
|
+
function getRandomDate(start, end) {
|
4748
|
+
const randomDate = new Date(
|
4749
|
+
start.getTime() + Math.random() * (end.getTime() - start.getTime())
|
4750
|
+
);
|
4751
|
+
return randomDate.toISOString().split("T")[0];
|
4752
|
+
}
|
4753
|
+
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
4754
|
+
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
|
4755
|
+
const randomDob = getRandomDate(
|
4756
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
4757
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
4758
|
+
);
|
4759
|
+
return {
|
4760
|
+
"recommender.none": true,
|
4761
|
+
"applicant.firstname": randomFirstName,
|
4762
|
+
"applicant.surname": randomSurname,
|
4763
|
+
"applicant.dob": randomDob
|
4764
|
+
};
|
4765
|
+
}
|
4417
4766
|
var eventQueryDataGenerator = (overrides = {}) => ({
|
4418
4767
|
id: overrides.id ?? getUUID(),
|
4419
|
-
type: overrides.type ?? "
|
4420
|
-
status: overrides.status ??
|
4768
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4769
|
+
status: overrides.status ?? getEventStatus(),
|
4421
4770
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4422
4771
|
createdBy: overrides.createdBy ?? getUUID(),
|
4423
4772
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
@@ -4425,13 +4774,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4425
4774
|
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4426
4775
|
assignedTo: overrides.assignedTo ?? null,
|
4427
4776
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
},
|
4434
|
-
trackingId: overrides.trackingId ?? "M3F8YQ"
|
4777
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4778
|
+
flags: [],
|
4779
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
4780
|
+
declaration: overrides.declaration ?? getRandomApplicant(),
|
4781
|
+
trackingId: overrides.trackingId ?? getTrackingId()
|
4435
4782
|
});
|
4436
4783
|
var generateTranslationConfig = (message) => ({
|
4437
4784
|
defaultMessage: message,
|
@@ -4470,3 +4817,326 @@ function isFieldConfigDefaultValue(value) {
|
|
4470
4817
|
}
|
4471
4818
|
return false;
|
4472
4819
|
}
|
4820
|
+
|
4821
|
+
// ../commons/src/events/scopes.ts
|
4822
|
+
var import_lodash3 = require("lodash");
|
4823
|
+
|
4824
|
+
// ../commons/src/scopes.ts
|
4825
|
+
var import_zod25 = require("zod");
|
4826
|
+
var SCOPES = {
|
4827
|
+
// TODO v1.8 legacy scopes
|
4828
|
+
NATLSYSADMIN: "natlsysadmin",
|
4829
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
4830
|
+
DECLARE: "declare",
|
4831
|
+
REGISTER: "register",
|
4832
|
+
VALIDATE: "validate",
|
4833
|
+
DEMO: "demo",
|
4834
|
+
CERTIFY: "certify",
|
4835
|
+
PERFORMANCE: "performance",
|
4836
|
+
SYSADMIN: "sysadmin",
|
4837
|
+
TEAMS: "teams",
|
4838
|
+
CONFIG: "config",
|
4839
|
+
// systems / integrations
|
4840
|
+
WEBHOOK: "webhook",
|
4841
|
+
NATIONALID: "nationalId",
|
4842
|
+
NOTIFICATION_API: "notification-api",
|
4843
|
+
RECORDSEARCH: "recordsearch",
|
4844
|
+
/**
|
4845
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4846
|
+
*/
|
4847
|
+
RECORD_DECLARE: "record.declare-birth",
|
4848
|
+
// declare
|
4849
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4850
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4851
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
4852
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4853
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4854
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4855
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4856
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4857
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4858
|
+
// validate
|
4859
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4860
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4861
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4862
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4863
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4864
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4865
|
+
// register
|
4866
|
+
RECORD_REGISTER: "record.register",
|
4867
|
+
// certify
|
4868
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
4869
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4870
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4871
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4872
|
+
// v1.8
|
4873
|
+
/**
|
4874
|
+
* This scope is used to **print and **issue certified copies of a record
|
4875
|
+
* after it has been registered. Previously Registrars had this permission.
|
4876
|
+
*/
|
4877
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4878
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4879
|
+
// v1.8
|
4880
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4881
|
+
// v1.8
|
4882
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4883
|
+
// v1.8
|
4884
|
+
// correct
|
4885
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4886
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4887
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4888
|
+
// v1.8
|
4889
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4890
|
+
// v1.8
|
4891
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4892
|
+
// v1.8
|
4893
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4894
|
+
// v1.8
|
4895
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4896
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4897
|
+
// search
|
4898
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4899
|
+
SEARCH_BIRTH: "search.birth",
|
4900
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4901
|
+
SEARCH_DEATH: "search.death",
|
4902
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4903
|
+
SEARCH_MARRIAGE: "search.marriage",
|
4904
|
+
// audit v1.8
|
4905
|
+
RECORD_READ: "record.read",
|
4906
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
4907
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
4908
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4909
|
+
// profile
|
4910
|
+
PROFILE_UPDATE: "profile.update",
|
4911
|
+
//v1.8
|
4912
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4913
|
+
// performance
|
4914
|
+
PERFORMANCE_READ: "performance.read",
|
4915
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4916
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4917
|
+
// organisation
|
4918
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4919
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4920
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4921
|
+
// user
|
4922
|
+
USER_READ: "user.read:all",
|
4923
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
4924
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4925
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4926
|
+
//v1.8
|
4927
|
+
USER_CREATE: "user.create:all",
|
4928
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4929
|
+
USER_UPDATE: "user.update:all",
|
4930
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4931
|
+
// config
|
4932
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
4933
|
+
// data seeding
|
4934
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
4935
|
+
};
|
4936
|
+
var LiteralScopes = import_zod25.z.union([
|
4937
|
+
import_zod25.z.literal(SCOPES.NATLSYSADMIN),
|
4938
|
+
import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
|
4939
|
+
import_zod25.z.literal(SCOPES.DECLARE),
|
4940
|
+
import_zod25.z.literal(SCOPES.REGISTER),
|
4941
|
+
import_zod25.z.literal(SCOPES.VALIDATE),
|
4942
|
+
import_zod25.z.literal(SCOPES.DEMO),
|
4943
|
+
import_zod25.z.literal(SCOPES.CERTIFY),
|
4944
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE),
|
4945
|
+
import_zod25.z.literal(SCOPES.SYSADMIN),
|
4946
|
+
import_zod25.z.literal(SCOPES.TEAMS),
|
4947
|
+
import_zod25.z.literal(SCOPES.CONFIG),
|
4948
|
+
import_zod25.z.literal(SCOPES.WEBHOOK),
|
4949
|
+
import_zod25.z.literal(SCOPES.NATIONALID),
|
4950
|
+
import_zod25.z.literal(SCOPES.NOTIFICATION_API),
|
4951
|
+
import_zod25.z.literal(SCOPES.RECORDSEARCH),
|
4952
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
4953
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
4954
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
4955
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
4956
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
4957
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
4958
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
4959
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
4960
|
+
import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
4961
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
4962
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
4963
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
4964
|
+
import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
4965
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
4966
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
4967
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTER),
|
4968
|
+
import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
4969
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
4970
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
4971
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
4972
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
4973
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
4974
|
+
import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
4975
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
4976
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
4977
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
4978
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
4979
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
4980
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
4981
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
4982
|
+
import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
4983
|
+
import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
4984
|
+
import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
4985
|
+
import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
|
4986
|
+
import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
4987
|
+
import_zod25.z.literal(SCOPES.SEARCH_DEATH),
|
4988
|
+
import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
4989
|
+
import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
|
4990
|
+
import_zod25.z.literal(SCOPES.RECORD_READ),
|
4991
|
+
import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
|
4992
|
+
import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
4993
|
+
import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
4994
|
+
import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
|
4995
|
+
import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
4996
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
|
4997
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
4998
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
4999
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
5000
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
5001
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
5002
|
+
import_zod25.z.literal(SCOPES.USER_READ),
|
5003
|
+
import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
5004
|
+
import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
5005
|
+
import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
5006
|
+
import_zod25.z.literal(SCOPES.USER_CREATE),
|
5007
|
+
import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
5008
|
+
import_zod25.z.literal(SCOPES.USER_UPDATE),
|
5009
|
+
import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
5010
|
+
import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
5011
|
+
import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
|
5012
|
+
]);
|
5013
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w-]+(?:\|[\w-]+)*)(:?,[\w-]+=[\w-]+(?:\|[\w-]+)*)*)\]$/;
|
5014
|
+
var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
|
5015
|
+
var CreateUserScope = import_zod25.z.object({
|
5016
|
+
type: import_zod25.z.literal("user.create"),
|
5017
|
+
options: import_zod25.z.object({
|
5018
|
+
role: import_zod25.z.array(import_zod25.z.string())
|
5019
|
+
})
|
5020
|
+
});
|
5021
|
+
var EditUserScope = import_zod25.z.object({
|
5022
|
+
type: import_zod25.z.literal("user.edit"),
|
5023
|
+
options: import_zod25.z.object({
|
5024
|
+
role: import_zod25.z.array(import_zod25.z.string())
|
5025
|
+
})
|
5026
|
+
});
|
5027
|
+
var WorkqueueScope = import_zod25.z.object({
|
5028
|
+
type: import_zod25.z.literal("workqueue"),
|
5029
|
+
options: import_zod25.z.object({
|
5030
|
+
id: import_zod25.z.array(import_zod25.z.string())
|
5031
|
+
})
|
5032
|
+
});
|
5033
|
+
var NotifyEventScope = import_zod25.z.object({
|
5034
|
+
type: import_zod25.z.literal("notify.event"),
|
5035
|
+
options: import_zod25.z.object({
|
5036
|
+
event: import_zod25.z.array(import_zod25.z.string())
|
5037
|
+
})
|
5038
|
+
});
|
5039
|
+
var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
|
5040
|
+
CreateUserScope,
|
5041
|
+
EditUserScope,
|
5042
|
+
WorkqueueScope,
|
5043
|
+
NotifyEventScope
|
5044
|
+
]);
|
5045
|
+
var scopes = Object.values(SCOPES);
|
5046
|
+
|
5047
|
+
// ../commons/src/events/scopes.ts
|
5048
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
5049
|
+
SCOPES.RECORD_DECLARE,
|
5050
|
+
SCOPES.RECORD_READ,
|
5051
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5052
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5053
|
+
SCOPES.RECORD_REGISTER,
|
5054
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
5055
|
+
SCOPES.CONFIG,
|
5056
|
+
SCOPES.CONFIG_UPDATE_ALL
|
5057
|
+
];
|
5058
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
5059
|
+
SCOPES.SEARCH_BIRTH,
|
5060
|
+
SCOPES.SEARCH_DEATH,
|
5061
|
+
SCOPES.SEARCH_MARRIAGE,
|
5062
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
5063
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
5064
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
5065
|
+
];
|
5066
|
+
var ACTION_ALLOWED_SCOPES = {
|
5067
|
+
[ActionType.READ]: [
|
5068
|
+
SCOPES.RECORD_DECLARE,
|
5069
|
+
SCOPES.RECORD_READ,
|
5070
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5071
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5072
|
+
SCOPES.RECORD_REGISTER,
|
5073
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
5074
|
+
],
|
5075
|
+
[ActionType.CREATE]: [
|
5076
|
+
SCOPES.RECORD_DECLARE,
|
5077
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5078
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
5079
|
+
],
|
5080
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
5081
|
+
[ActionType.DECLARE]: [
|
5082
|
+
SCOPES.RECORD_DECLARE,
|
5083
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5084
|
+
SCOPES.RECORD_REGISTER
|
5085
|
+
],
|
5086
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
5087
|
+
[ActionType.VALIDATE]: [
|
5088
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5089
|
+
SCOPES.RECORD_REGISTER
|
5090
|
+
],
|
5091
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
5092
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
5093
|
+
[ActionType.REQUEST_CORRECTION]: [
|
5094
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
5095
|
+
],
|
5096
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5097
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5098
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5099
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5100
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
5101
|
+
[ActionType.ASSIGN]: null,
|
5102
|
+
[ActionType.UNASSIGN]: null,
|
5103
|
+
[ActionType.DETECT_DUPLICATE]: []
|
5104
|
+
};
|
5105
|
+
var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
|
5106
|
+
[ActionType.READ]: [],
|
5107
|
+
[ActionType.CREATE]: ["notify.event"],
|
5108
|
+
[ActionType.NOTIFY]: ["notify.event"],
|
5109
|
+
[ActionType.DECLARE]: [],
|
5110
|
+
[ActionType.DELETE]: [],
|
5111
|
+
[ActionType.VALIDATE]: [],
|
5112
|
+
[ActionType.REGISTER]: [],
|
5113
|
+
[ActionType.PRINT_CERTIFICATE]: [],
|
5114
|
+
[ActionType.REQUEST_CORRECTION]: [],
|
5115
|
+
[ActionType.REJECT_CORRECTION]: [],
|
5116
|
+
[ActionType.APPROVE_CORRECTION]: [],
|
5117
|
+
[ActionType.MARKED_AS_DUPLICATE]: [],
|
5118
|
+
[ActionType.ARCHIVE]: [],
|
5119
|
+
[ActionType.REJECT]: [],
|
5120
|
+
[ActionType.ASSIGN]: [],
|
5121
|
+
[ActionType.UNASSIGN]: [],
|
5122
|
+
[ActionType.DETECT_DUPLICATE]: []
|
5123
|
+
};
|
5124
|
+
function hasAnyOfScopes(a, b) {
|
5125
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
5126
|
+
}
|
5127
|
+
function filterUnallowedActions(actions, userScopes) {
|
5128
|
+
const allowedActions = actions.filter((action) => {
|
5129
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
5130
|
+
if (requiredScopes === null) {
|
5131
|
+
return true;
|
5132
|
+
}
|
5133
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
5134
|
+
});
|
5135
|
+
const hasOtherAllowedActions = allowedActions.some(
|
5136
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
5137
|
+
);
|
5138
|
+
if (hasOtherAllowedActions) {
|
5139
|
+
return allowedActions;
|
5140
|
+
}
|
5141
|
+
return [ActionType.READ];
|
5142
|
+
}
|