@opencrvs/toolkit 1.8.0-rc.f8e4107 → 1.8.0-rc.f97f8f2
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 +8418 -4827
- package/dist/commons/conditionals/conditionals.d.ts +9 -70
- 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/CountryConfigQueryInput.d.ts +1506 -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 +948 -155
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +274 -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 +31 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +42 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +2834 -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 +6 -0
- package/dist/commons/events/scopes.d.ts +26 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +7 -44
- package/dist/commons/events/utils.d.ts +3551 -65
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/conditionals/index.js +54 -83
- package/dist/events/index.js +2044 -1072
- package/dist/scopes/index.d.ts +105 -1
- package/dist/scopes/index.js +140 -0
- package/package.json +3 -2
package/dist/events/index.js
CHANGED
@@ -30,11 +30,13 @@ 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_SCOPES: () => ACTION_ALLOWED_SCOPES,
|
33
34
|
Action: () => Action,
|
34
35
|
ActionBase: () => ActionBase,
|
35
36
|
ActionConditional: () => ActionConditional,
|
36
37
|
ActionConfig: () => ActionConfig,
|
37
38
|
ActionConfigBase: () => ActionConfigBase,
|
39
|
+
ActionCreationMetadata: () => ActionCreationMetadata,
|
38
40
|
ActionDocument: () => ActionDocument,
|
39
41
|
ActionFormConfig: () => ActionFormConfig,
|
40
42
|
ActionInput: () => ActionInput,
|
@@ -52,6 +54,8 @@ __export(events_exports, {
|
|
52
54
|
AssignActionInput: () => AssignActionInput,
|
53
55
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
54
56
|
BaseActionInput: () => BaseActionInput,
|
57
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
58
|
+
CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
|
55
59
|
CertificateConfig: () => CertificateConfig,
|
56
60
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
57
61
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
@@ -59,9 +63,13 @@ __export(events_exports, {
|
|
59
63
|
Conditional: () => Conditional,
|
60
64
|
ConditionalType: () => ConditionalType,
|
61
65
|
ConfirmableActions: () => ConfirmableActions,
|
66
|
+
CustomFlags: () => CustomFlags,
|
67
|
+
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
62
68
|
DataEntry: () => DataEntry,
|
63
69
|
DataFieldValue: () => DataFieldValue,
|
70
|
+
DateRangeFieldValue: () => DateRangeFieldValue,
|
64
71
|
DateValue: () => DateValue,
|
72
|
+
DatetimeValue: () => DatetimeValue,
|
65
73
|
DeclarationActionConfig: () => DeclarationActionConfig,
|
66
74
|
DeclarationActions: () => DeclarationActions,
|
67
75
|
DeclarationFormConfig: () => DeclarationFormConfig,
|
@@ -69,19 +77,26 @@ __export(events_exports, {
|
|
69
77
|
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
70
78
|
DeclareActionInput: () => DeclareActionInput,
|
71
79
|
DeduplicationConfig: () => DeduplicationConfig,
|
80
|
+
DeleteActionInput: () => DeleteActionInput,
|
72
81
|
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
73
82
|
Draft: () => Draft,
|
74
83
|
DraftInput: () => DraftInput,
|
75
84
|
EmailField: () => EmailField,
|
76
85
|
EmailValue: () => EmailValue,
|
77
86
|
EnableConditional: () => EnableConditional,
|
78
|
-
EventConfig: () =>
|
87
|
+
EventConfig: () => EventConfig,
|
79
88
|
EventDocument: () => EventDocument,
|
89
|
+
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
90
|
+
EventFieldId: () => EventFieldId,
|
80
91
|
EventIndex: () => EventIndex,
|
81
92
|
EventInput: () => EventInput,
|
82
93
|
EventMetadata: () => EventMetadata,
|
94
|
+
EventMetadataKeys: () => EventMetadataKeys,
|
95
|
+
EventMetadataParameter: () => EventMetadataParameter,
|
83
96
|
EventSearchIndex: () => EventSearchIndex,
|
97
|
+
EventState: () => EventState,
|
84
98
|
EventStatus: () => EventStatus,
|
99
|
+
EventStatusEnum: () => EventStatusEnum,
|
85
100
|
EventStatuses: () => EventStatuses,
|
86
101
|
FieldConditional: () => FieldConditional,
|
87
102
|
FieldConfig: () => FieldConfig,
|
@@ -92,6 +107,7 @@ __export(events_exports, {
|
|
92
107
|
FileFieldValue: () => FileFieldValue,
|
93
108
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
94
109
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
110
|
+
Flag: () => Flag,
|
95
111
|
FormConfig: () => FormConfig,
|
96
112
|
FormPageConfig: () => FormPageConfig,
|
97
113
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
@@ -99,25 +115,29 @@ __export(events_exports, {
|
|
99
115
|
GeographicalArea: () => GeographicalArea,
|
100
116
|
ImageMimeType: () => ImageMimeType,
|
101
117
|
LanguageConfig: () => LanguageConfig,
|
118
|
+
LegalStatuses: () => LegalStatuses,
|
102
119
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
103
120
|
MimeType: () => MimeType,
|
121
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
104
122
|
NotifyActionInput: () => NotifyActionInput,
|
105
123
|
NumberFieldValue: () => NumberFieldValue,
|
106
124
|
PageConfig: () => PageConfig,
|
107
125
|
PageTypes: () => PageTypes,
|
108
126
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
109
|
-
|
127
|
+
QueryExpression: () => QueryExpression,
|
128
|
+
QueryInput: () => QueryInput2,
|
110
129
|
QueryType: () => QueryType,
|
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,
|
@@ -126,19 +146,29 @@ __export(events_exports, {
|
|
126
146
|
UnassignActionInput: () => UnassignActionInput,
|
127
147
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
128
148
|
UrbanAddressValue: () => UrbanAddressValue,
|
149
|
+
User: () => User,
|
129
150
|
ValidateActionInput: () => ValidateActionInput,
|
130
151
|
VerificationActionConfig: () => VerificationActionConfig,
|
131
152
|
VerificationPageConfig: () => VerificationPageConfig,
|
153
|
+
WorkqueueColumn: () => WorkqueueColumn,
|
132
154
|
WorkqueueConfig: () => WorkqueueConfig,
|
155
|
+
WorkqueueCountInput: () => WorkqueueCountInput,
|
156
|
+
WorkqueueCountOutput: () => WorkqueueCountOutput,
|
157
|
+
ZodDate: () => ZodDate,
|
133
158
|
alwaysTrue: () => alwaysTrue,
|
134
159
|
and: () => and,
|
135
160
|
annotationActions: () => annotationActions,
|
136
161
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
162
|
+
areConditionsMet: () => areConditionsMet,
|
137
163
|
compositeFieldTypes: () => compositeFieldTypes,
|
138
164
|
createEmptyDraft: () => createEmptyDraft,
|
165
|
+
createEventConditionals: () => createEventConditionals,
|
166
|
+
createFieldConditionals: () => createFieldConditionals,
|
139
167
|
createValidationSchema: () => createValidationSchema,
|
140
168
|
deepDropNulls: () => deepDropNulls,
|
141
169
|
deepMerge: () => deepMerge,
|
170
|
+
defaultThirdColumn: () => defaultThirdColumn,
|
171
|
+
defaultWorkqueueColumns: () => defaultWorkqueueColumns,
|
142
172
|
defineActionForm: () => defineActionForm,
|
143
173
|
defineConditional: () => defineConditional,
|
144
174
|
defineConfig: () => defineConfig,
|
@@ -146,16 +176,20 @@ __export(events_exports, {
|
|
146
176
|
defineFormConditional: () => defineFormConditional,
|
147
177
|
defineFormPage: () => defineFormPage,
|
148
178
|
definePage: () => definePage,
|
179
|
+
defineWorkqueue: () => defineWorkqueue,
|
180
|
+
defineWorkqueueColumns: () => defineWorkqueueColumns,
|
181
|
+
deserializeQuery: () => deserializeQuery,
|
149
182
|
errorMessages: () => errorMessages,
|
150
183
|
event: () => event,
|
151
|
-
eventField: () => eventField,
|
152
184
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
153
185
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
154
186
|
eventQueryDataGenerator: () => eventQueryDataGenerator,
|
155
187
|
eventStatuses: () => eventStatuses,
|
156
188
|
field: () => field,
|
157
189
|
fieldTypes: () => fieldTypes,
|
190
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
158
191
|
findActiveDrafts: () => findActiveDrafts,
|
192
|
+
findAllFields: () => findAllFields,
|
159
193
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
160
194
|
findRecordActionPages: () => findRecordActionPages,
|
161
195
|
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
@@ -170,21 +204,26 @@ __export(events_exports, {
|
|
170
204
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
171
205
|
getActionReview: () => getActionReview,
|
172
206
|
getActionReviewFields: () => getActionReviewFields,
|
173
|
-
|
207
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
174
208
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
209
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
175
210
|
getCurrentEventState: () => getCurrentEventState,
|
176
211
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
177
212
|
getDeclaration: () => getDeclaration,
|
178
213
|
getDeclarationFields: () => getDeclarationFields,
|
179
214
|
getDeclarationPages: () => getDeclarationPages,
|
180
|
-
|
215
|
+
getMixedPath: () => getMixedPath,
|
216
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
217
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
181
218
|
isAddressFieldType: () => isAddressFieldType,
|
182
219
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
183
220
|
isBulletListFieldType: () => isBulletListFieldType,
|
184
221
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
222
|
+
isConditionMet: () => isConditionMet,
|
185
223
|
isCountryFieldType: () => isCountryFieldType,
|
186
224
|
isDataFieldType: () => isDataFieldType,
|
187
225
|
isDateFieldType: () => isDateFieldType,
|
226
|
+
isDateRangeFieldType: () => isDateRangeFieldType,
|
188
227
|
isDividerFieldType: () => isDividerFieldType,
|
189
228
|
isEmailFieldType: () => isEmailFieldType,
|
190
229
|
isFacilityFieldType: () => isFacilityFieldType,
|
@@ -216,13 +255,14 @@ __export(events_exports, {
|
|
216
255
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
217
256
|
never: () => never,
|
218
257
|
not: () => not,
|
258
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
219
259
|
omitHiddenFields: () => omitHiddenFields,
|
220
260
|
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
221
261
|
or: () => or,
|
262
|
+
runFieldValidations: () => runFieldValidations,
|
222
263
|
user: () => user,
|
223
264
|
validate: () => validate,
|
224
265
|
validateFieldInput: () => validateFieldInput,
|
225
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
226
266
|
writeActions: () => writeActions
|
227
267
|
});
|
228
268
|
module.exports = __toCommonJS(events_exports);
|
@@ -299,12 +339,12 @@ var FieldType = {
|
|
299
339
|
TEXTAREA: "TEXTAREA",
|
300
340
|
EMAIL: "EMAIL",
|
301
341
|
DATE: "DATE",
|
342
|
+
DATE_RANGE: "DATE_RANGE",
|
302
343
|
PARAGRAPH: "PARAGRAPH",
|
303
344
|
PAGE_HEADER: "PAGE_HEADER",
|
304
345
|
RADIO_GROUP: "RADIO_GROUP",
|
305
346
|
FILE: "FILE",
|
306
347
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
307
|
-
HIDDEN: "HIDDEN",
|
308
348
|
BULLET_LIST: "BULLET_LIST",
|
309
349
|
CHECKBOX: "CHECKBOX",
|
310
350
|
SELECT: "SELECT",
|
@@ -319,6 +359,7 @@ var FieldType = {
|
|
319
359
|
};
|
320
360
|
var fieldTypes = Object.values(FieldType);
|
321
361
|
var compositeFieldTypes = [
|
362
|
+
FieldType.DATE_RANGE,
|
322
363
|
FieldType.ADDRESS,
|
323
364
|
FieldType.FILE_WITH_OPTIONS,
|
324
365
|
FieldType.FILE
|
@@ -409,8 +450,10 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
409
450
|
|
410
451
|
// ../commons/src/events/FieldValue.ts
|
411
452
|
var TextValue = import_zod4.z.string();
|
412
|
-
var
|
453
|
+
var NonEmptyTextValue = TextValue.min(1);
|
413
454
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
455
|
+
var DatetimeValue = import_zod4.z.string().datetime();
|
456
|
+
var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
|
414
457
|
var EmailValue = import_zod4.z.string().email();
|
415
458
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
416
459
|
var NumberFieldValue = import_zod4.z.number();
|
@@ -418,6 +461,7 @@ var DataFieldValue = import_zod4.z.undefined();
|
|
418
461
|
var FieldValue = import_zod4.z.union([
|
419
462
|
TextValue,
|
420
463
|
DateValue,
|
464
|
+
DateRangeFieldValue,
|
421
465
|
CheckboxFieldValue,
|
422
466
|
NumberFieldValue,
|
423
467
|
FileFieldValue,
|
@@ -430,6 +474,7 @@ var FieldValue = import_zod4.z.union([
|
|
430
474
|
var FieldUpdateValue = import_zod4.z.union([
|
431
475
|
TextValue,
|
432
476
|
DateValue,
|
477
|
+
DateRangeFieldValue,
|
433
478
|
CheckboxFieldValue,
|
434
479
|
NumberFieldValue,
|
435
480
|
FileFieldValue,
|
@@ -442,27 +487,21 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
442
487
|
|
443
488
|
// ../commons/src/events/FieldConfig.ts
|
444
489
|
var FieldId = import_zod5.z.string();
|
445
|
-
var
|
446
|
-
|
447
|
-
|
448
|
-
});
|
490
|
+
var ParentReference = import_zod5.z.object({
|
491
|
+
_fieldId: FieldId.optional()
|
492
|
+
}).optional();
|
449
493
|
var BaseField = import_zod5.z.object({
|
450
494
|
id: FieldId,
|
451
495
|
defaultValue: import_zod5.z.union([
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
NumberFieldValue,
|
458
|
-
CheckboxFieldValue
|
459
|
-
]),
|
460
|
-
DependencyExpression
|
496
|
+
TextValue,
|
497
|
+
NonEmptyTextValue,
|
498
|
+
DateValue,
|
499
|
+
NumberFieldValue,
|
500
|
+
CheckboxFieldValue
|
461
501
|
]).optional(),
|
502
|
+
parent: ParentReference,
|
462
503
|
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
463
504
|
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
505
|
placeholder: TranslationConfig.optional(),
|
467
506
|
validation: import_zod5.z.array(
|
468
507
|
import_zod5.z.object({
|
@@ -470,7 +509,6 @@ var BaseField = import_zod5.z.object({
|
|
470
509
|
message: TranslationConfig
|
471
510
|
})
|
472
511
|
).default([]).optional(),
|
473
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
474
512
|
label: TranslationConfig,
|
475
513
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
476
514
|
});
|
@@ -479,7 +517,7 @@ var Divider = BaseField.extend({
|
|
479
517
|
});
|
480
518
|
var TextField = BaseField.extend({
|
481
519
|
type: import_zod5.z.literal(FieldType.TEXT),
|
482
|
-
defaultValue:
|
520
|
+
defaultValue: NonEmptyTextValue.optional(),
|
483
521
|
configuration: import_zod5.z.object({
|
484
522
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
485
523
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -489,7 +527,7 @@ var TextField = BaseField.extend({
|
|
489
527
|
}).describe("Text input");
|
490
528
|
var NumberField = BaseField.extend({
|
491
529
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
492
|
-
defaultValue:
|
530
|
+
defaultValue: NumberFieldValue.optional(),
|
493
531
|
configuration: import_zod5.z.object({
|
494
532
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
495
533
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -499,7 +537,7 @@ var NumberField = BaseField.extend({
|
|
499
537
|
}).describe("Number input");
|
500
538
|
var TextAreaField = BaseField.extend({
|
501
539
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
502
|
-
defaultValue:
|
540
|
+
defaultValue: NonEmptyTextValue.optional(),
|
503
541
|
configuration: import_zod5.z.object({
|
504
542
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
505
543
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -533,17 +571,28 @@ var EmailField = BaseField.extend({
|
|
533
571
|
configuration: import_zod5.z.object({
|
534
572
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
535
573
|
}).default({ maxLength: 10 }).optional(),
|
536
|
-
defaultValue:
|
574
|
+
defaultValue: NonEmptyTextValue.optional()
|
537
575
|
});
|
538
576
|
var DateField = BaseField.extend({
|
539
577
|
type: import_zod5.z.literal(FieldType.DATE),
|
540
|
-
defaultValue:
|
578
|
+
defaultValue: DateValue.optional(),
|
541
579
|
configuration: import_zod5.z.object({
|
542
580
|
notice: TranslationConfig.describe(
|
543
581
|
"Text to display above the date input"
|
544
582
|
).optional()
|
545
583
|
}).optional()
|
546
584
|
}).describe("A single date input (dd-mm-YYYY)");
|
585
|
+
var DateRangeField = BaseField.extend({
|
586
|
+
type: import_zod5.z.literal(FieldType.DATE_RANGE),
|
587
|
+
defaultValue: DateRangeFieldValue.optional(),
|
588
|
+
configuration: import_zod5.z.object({
|
589
|
+
notice: TranslationConfig.describe(
|
590
|
+
"Text to display above the date input"
|
591
|
+
).optional()
|
592
|
+
}).optional()
|
593
|
+
}).describe(
|
594
|
+
"A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
|
595
|
+
);
|
547
596
|
var HtmlFontVariant = import_zod5.z.enum([
|
548
597
|
"reg12",
|
549
598
|
"reg14",
|
@@ -556,7 +605,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
556
605
|
]);
|
557
606
|
var Paragraph = BaseField.extend({
|
558
607
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
559
|
-
defaultValue:
|
608
|
+
defaultValue: NonEmptyTextValue.optional(),
|
560
609
|
configuration: import_zod5.z.object({
|
561
610
|
styles: import_zod5.z.object({
|
562
611
|
fontVariant: HtmlFontVariant.optional()
|
@@ -565,7 +614,7 @@ var Paragraph = BaseField.extend({
|
|
565
614
|
}).describe("A read-only HTML <p> paragraph");
|
566
615
|
var PageHeader = BaseField.extend({
|
567
616
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
568
|
-
defaultValue:
|
617
|
+
defaultValue: NonEmptyTextValue.optional()
|
569
618
|
}).describe("A read-only header component for form pages");
|
570
619
|
var File = BaseField.extend({
|
571
620
|
type: import_zod5.z.literal(FieldType.FILE),
|
@@ -576,7 +625,8 @@ var File = BaseField.extend({
|
|
576
625
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
577
626
|
"Whether the file upload button should take the full width of the container or not"
|
578
627
|
)
|
579
|
-
}).optional()
|
628
|
+
}).optional(),
|
629
|
+
fileName: TranslationConfig.optional()
|
580
630
|
}).default({
|
581
631
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
582
632
|
})
|
@@ -587,7 +637,7 @@ var SelectOption = import_zod5.z.object({
|
|
587
637
|
});
|
588
638
|
var RadioGroup = BaseField.extend({
|
589
639
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
590
|
-
defaultValue:
|
640
|
+
defaultValue: TextValue.optional(),
|
591
641
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
592
642
|
configuration: import_zod5.z.object({
|
593
643
|
styles: import_zod5.z.object({
|
@@ -597,7 +647,7 @@ var RadioGroup = BaseField.extend({
|
|
597
647
|
}).describe("Grouped radio options");
|
598
648
|
var BulletList = BaseField.extend({
|
599
649
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
600
|
-
defaultValue:
|
650
|
+
defaultValue: TextValue.optional(),
|
601
651
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
602
652
|
configuration: import_zod5.z.object({
|
603
653
|
styles: import_zod5.z.object({
|
@@ -607,16 +657,16 @@ var BulletList = BaseField.extend({
|
|
607
657
|
}).describe("A list of bullet points");
|
608
658
|
var Select = BaseField.extend({
|
609
659
|
type: import_zod5.z.literal(FieldType.SELECT),
|
610
|
-
defaultValue:
|
660
|
+
defaultValue: TextValue.optional(),
|
611
661
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
612
662
|
}).describe("Select input");
|
613
663
|
var Checkbox = BaseField.extend({
|
614
664
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
615
|
-
defaultValue:
|
665
|
+
defaultValue: CheckboxFieldValue.optional()
|
616
666
|
}).describe("Boolean checkbox field");
|
617
667
|
var Country = BaseField.extend({
|
618
668
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
619
|
-
defaultValue:
|
669
|
+
defaultValue: NonEmptyTextValue.optional()
|
620
670
|
}).describe("Country select field");
|
621
671
|
var AdministrativeAreas = import_zod5.z.enum([
|
622
672
|
"ADMIN_STRUCTURE",
|
@@ -631,12 +681,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
|
|
631
681
|
}).describe("Administrative area options");
|
632
682
|
var AdministrativeArea = BaseField.extend({
|
633
683
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
634
|
-
defaultValue:
|
684
|
+
defaultValue: NonEmptyTextValue.optional(),
|
635
685
|
configuration: AdministrativeAreaConfiguration
|
636
686
|
}).describe("Administrative area input field e.g. facility, office");
|
637
687
|
var Location = BaseField.extend({
|
638
688
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
639
|
-
defaultValue:
|
689
|
+
defaultValue: NonEmptyTextValue.optional()
|
640
690
|
}).describe("Input field for a location");
|
641
691
|
var FileUploadWithOptions = BaseField.extend({
|
642
692
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
@@ -650,11 +700,11 @@ var FileUploadWithOptions = BaseField.extend({
|
|
650
700
|
});
|
651
701
|
var Facility = BaseField.extend({
|
652
702
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
653
|
-
defaultValue:
|
703
|
+
defaultValue: NonEmptyTextValue.optional()
|
654
704
|
}).describe("Input field for a facility");
|
655
705
|
var Office = BaseField.extend({
|
656
706
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
657
|
-
defaultValue:
|
707
|
+
defaultValue: NonEmptyTextValue.optional()
|
658
708
|
}).describe("Input field for an office");
|
659
709
|
var Address = BaseField.extend({
|
660
710
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
@@ -663,7 +713,7 @@ var Address = BaseField.extend({
|
|
663
713
|
var DataEntry = import_zod5.z.union([
|
664
714
|
import_zod5.z.object({
|
665
715
|
label: TranslationConfig,
|
666
|
-
value: import_zod5.z.string()
|
716
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
667
717
|
}),
|
668
718
|
import_zod5.z.object({
|
669
719
|
fieldId: import_zod5.z.string()
|
@@ -682,6 +732,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
682
732
|
NumberField,
|
683
733
|
TextAreaField,
|
684
734
|
DateField,
|
735
|
+
DateRangeField,
|
685
736
|
Paragraph,
|
686
737
|
RadioGroup,
|
687
738
|
BulletList,
|
@@ -699,7 +750,6 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
699
750
|
EmailField,
|
700
751
|
FileUploadWithOptions,
|
701
752
|
DataField
|
702
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
703
753
|
]);
|
704
754
|
|
705
755
|
// ../commons/src/events/PageConfig.ts
|
@@ -824,6 +874,8 @@ var ActionFormConfig = import_zod8.z.object({
|
|
824
874
|
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
825
875
|
|
826
876
|
// ../commons/src/events/ActionConfig.ts
|
877
|
+
var import_zod_openapi = require("zod-openapi");
|
878
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
|
827
879
|
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
828
880
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
829
881
|
ShowConditional,
|
@@ -901,18 +953,24 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
|
|
901
953
|
})
|
902
954
|
);
|
903
955
|
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
956
|
+
/*
|
957
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
958
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
959
|
+
*/
|
960
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
961
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
962
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
963
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
964
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
965
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
966
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
967
|
+
PrintCertificateActionConfig.openapi({
|
968
|
+
ref: "PrintCertificateActionConfig"
|
969
|
+
}),
|
970
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
971
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
972
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
973
|
+
]).openapi({ ref: "ActionConfig" });
|
916
974
|
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
917
975
|
DeclareConfig,
|
918
976
|
ValidateConfig,
|
@@ -960,6 +1018,8 @@ var import_zod17 = require("zod");
|
|
960
1018
|
|
961
1019
|
// ../commons/src/events/DeduplicationConfig.ts
|
962
1020
|
var import_zod12 = require("zod");
|
1021
|
+
var import_zod_openapi2 = require("zod-openapi");
|
1022
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
|
963
1023
|
var FieldReference = import_zod12.z.string();
|
964
1024
|
var Matcher = import_zod12.z.object({
|
965
1025
|
fieldId: import_zod12.z.string(),
|
@@ -1020,7 +1080,9 @@ var Clause = import_zod12.z.lazy(
|
|
1020
1080
|
DateRangeMatcher,
|
1021
1081
|
DateDistanceMatcher
|
1022
1082
|
])
|
1023
|
-
)
|
1083
|
+
).openapi({
|
1084
|
+
ref: "Clause"
|
1085
|
+
});
|
1024
1086
|
var DeduplicationConfig = import_zod12.z.object({
|
1025
1087
|
id: import_zod12.z.string(),
|
1026
1088
|
label: TranslationConfig,
|
@@ -1029,686 +1091,214 @@ var DeduplicationConfig = import_zod12.z.object({
|
|
1029
1091
|
|
1030
1092
|
// ../commons/src/events/SummaryConfig.ts
|
1031
1093
|
var import_zod13 = require("zod");
|
1032
|
-
var
|
1094
|
+
var BaseField2 = import_zod13.z.object({
|
1095
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1096
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1097
|
+
});
|
1098
|
+
var ReferenceField = BaseField2.extend({
|
1099
|
+
fieldId: import_zod13.z.string(),
|
1100
|
+
label: TranslationConfig.optional().describe(
|
1101
|
+
"By default, the configured field's label is used. This can be overridden by providing a custom label."
|
1102
|
+
)
|
1103
|
+
}).describe("Field directly referencing event data with field id");
|
1104
|
+
var Field = BaseField2.extend({
|
1033
1105
|
id: import_zod13.z.string().describe("Id of summary field"),
|
1034
1106
|
value: TranslationConfig.describe(
|
1035
1107
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1036
1108
|
),
|
1037
1109
|
label: TranslationConfig,
|
1038
1110
|
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
|
-
});
|
1111
|
+
}).describe("Custom configured field");
|
1045
1112
|
var SummaryConfig = import_zod13.z.object({
|
1046
|
-
|
1047
|
-
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
1113
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
1048
1114
|
}).describe("Configuration for summary in event.");
|
1049
1115
|
|
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
1116
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1155
|
-
var
|
1156
|
-
var
|
1157
|
-
var
|
1158
|
-
|
1159
|
-
|
1160
|
-
type: FieldType2.describe("Determines the type of field")
|
1117
|
+
var import_zod14 = require("zod");
|
1118
|
+
var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
|
1119
|
+
var BaseField3 = import_zod14.z.object({
|
1120
|
+
config: import_zod14.z.object({
|
1121
|
+
type: MatchType.describe("Determines the type of field")
|
1161
1122
|
}),
|
1162
|
-
options:
|
1123
|
+
options: import_zod14.z.array(SelectOption).optional()
|
1163
1124
|
});
|
1164
|
-
var
|
1125
|
+
var FieldConfigSchema = BaseField3.extend({
|
1126
|
+
fieldId: import_zod14.z.string(),
|
1127
|
+
fieldType: import_zod14.z.literal("field")
|
1128
|
+
});
|
1129
|
+
var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
|
1130
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1131
|
+
fieldId: EventFieldId,
|
1132
|
+
fieldType: import_zod14.z.literal("event")
|
1133
|
+
});
|
1134
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1135
|
+
FieldConfigSchema,
|
1136
|
+
EventFieldConfigSchema
|
1137
|
+
]);
|
1138
|
+
var AdvancedSearchConfig = import_zod14.z.object({
|
1165
1139
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1166
|
-
fields:
|
1140
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1167
1141
|
});
|
1168
1142
|
|
1169
|
-
// ../commons/src/utils.ts
|
1143
|
+
// ../commons/src/events/utils.ts
|
1170
1144
|
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
1145
|
|
1239
1146
|
// ../commons/src/events/ActionDocument.ts
|
1240
|
-
var
|
1241
|
-
var
|
1147
|
+
var import_zod15 = require("zod");
|
1148
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1149
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
|
1150
|
+
var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
|
1151
|
+
var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
|
1242
1152
|
var ActionStatus = {
|
1243
1153
|
Requested: "Requested",
|
1244
1154
|
Accepted: "Accepted",
|
1245
1155
|
Rejected: "Rejected"
|
1246
1156
|
};
|
1247
|
-
var ActionBase =
|
1248
|
-
id:
|
1249
|
-
|
1250
|
-
|
1157
|
+
var ActionBase = import_zod15.z.object({
|
1158
|
+
id: import_zod15.z.string(),
|
1159
|
+
transactionId: import_zod15.z.string(),
|
1160
|
+
createdAt: import_zod15.z.string().datetime(),
|
1161
|
+
createdBy: import_zod15.z.string(),
|
1162
|
+
createdByRole: import_zod15.z.string(),
|
1251
1163
|
declaration: ActionUpdate,
|
1252
1164
|
annotation: ActionUpdate.optional(),
|
1253
|
-
createdAtLocation:
|
1254
|
-
|
1255
|
-
status: import_zod18.z.enum([
|
1165
|
+
createdAtLocation: import_zod15.z.string(),
|
1166
|
+
status: import_zod15.z.enum([
|
1256
1167
|
ActionStatus.Requested,
|
1257
1168
|
ActionStatus.Accepted,
|
1258
1169
|
ActionStatus.Rejected
|
1259
1170
|
]),
|
1260
1171
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1261
|
-
originalActionId:
|
1172
|
+
originalActionId: import_zod15.z.string().optional()
|
1262
1173
|
});
|
1263
1174
|
var AssignedAction = ActionBase.merge(
|
1264
|
-
|
1265
|
-
type:
|
1266
|
-
assignedTo:
|
1175
|
+
import_zod15.z.object({
|
1176
|
+
type: import_zod15.z.literal(ActionType.ASSIGN),
|
1177
|
+
assignedTo: import_zod15.z.string()
|
1267
1178
|
})
|
1268
1179
|
);
|
1269
1180
|
var UnassignedAction = ActionBase.merge(
|
1270
|
-
|
1271
|
-
type:
|
1272
|
-
assignedTo:
|
1181
|
+
import_zod15.z.object({
|
1182
|
+
type: import_zod15.z.literal(ActionType.UNASSIGN),
|
1183
|
+
assignedTo: import_zod15.z.literal(null)
|
1273
1184
|
})
|
1274
1185
|
);
|
1275
1186
|
var RegisterAction = ActionBase.merge(
|
1276
|
-
|
1277
|
-
type:
|
1278
|
-
registrationNumber:
|
1187
|
+
import_zod15.z.object({
|
1188
|
+
type: import_zod15.z.literal(ActionType.REGISTER),
|
1189
|
+
registrationNumber: import_zod15.z.string().optional()
|
1279
1190
|
})
|
1280
1191
|
);
|
1281
1192
|
var DeclareAction = ActionBase.merge(
|
1282
|
-
|
1283
|
-
type:
|
1193
|
+
import_zod15.z.object({
|
1194
|
+
type: import_zod15.z.literal(ActionType.DECLARE)
|
1284
1195
|
})
|
1285
1196
|
);
|
1286
1197
|
var ValidateAction = ActionBase.merge(
|
1287
|
-
|
1288
|
-
type:
|
1198
|
+
import_zod15.z.object({
|
1199
|
+
type: import_zod15.z.literal(ActionType.VALIDATE)
|
1289
1200
|
})
|
1290
1201
|
);
|
1291
1202
|
var RejectAction = ActionBase.merge(
|
1292
|
-
|
1293
|
-
type:
|
1203
|
+
import_zod15.z.object({
|
1204
|
+
type: import_zod15.z.literal(ActionType.REJECT)
|
1294
1205
|
})
|
1295
1206
|
);
|
1296
1207
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1297
|
-
|
1298
|
-
type:
|
1208
|
+
import_zod15.z.object({
|
1209
|
+
type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1299
1210
|
})
|
1300
1211
|
);
|
1301
1212
|
var ArchiveAction = ActionBase.merge(
|
1302
|
-
|
1303
|
-
type:
|
1213
|
+
import_zod15.z.object({
|
1214
|
+
type: import_zod15.z.literal(ActionType.ARCHIVE)
|
1304
1215
|
})
|
1305
1216
|
);
|
1306
1217
|
var CreatedAction = ActionBase.merge(
|
1307
|
-
|
1308
|
-
type:
|
1218
|
+
import_zod15.z.object({
|
1219
|
+
type: import_zod15.z.literal(ActionType.CREATE)
|
1309
1220
|
})
|
1310
1221
|
);
|
1311
1222
|
var NotifiedAction = ActionBase.merge(
|
1312
|
-
|
1313
|
-
type:
|
1223
|
+
import_zod15.z.object({
|
1224
|
+
type: import_zod15.z.literal(ActionType.NOTIFY)
|
1314
1225
|
})
|
1315
1226
|
);
|
1316
1227
|
var PrintCertificateAction = ActionBase.merge(
|
1317
|
-
|
1318
|
-
type:
|
1228
|
+
import_zod15.z.object({
|
1229
|
+
type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
|
1319
1230
|
})
|
1320
1231
|
);
|
1321
1232
|
var RequestedCorrectionAction = ActionBase.merge(
|
1322
|
-
|
1323
|
-
type:
|
1233
|
+
import_zod15.z.object({
|
1234
|
+
type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
|
1324
1235
|
})
|
1325
1236
|
);
|
1326
1237
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1327
|
-
|
1328
|
-
type:
|
1329
|
-
requestId:
|
1238
|
+
import_zod15.z.object({
|
1239
|
+
type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
|
1240
|
+
requestId: import_zod15.z.string()
|
1330
1241
|
})
|
1331
1242
|
);
|
1332
1243
|
var RejectedCorrectionAction = ActionBase.merge(
|
1333
|
-
|
1334
|
-
type:
|
1335
|
-
requestId:
|
1244
|
+
import_zod15.z.object({
|
1245
|
+
type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
|
1246
|
+
requestId: import_zod15.z.string()
|
1336
1247
|
})
|
1337
1248
|
);
|
1338
1249
|
var ReadAction = ActionBase.merge(
|
1339
|
-
|
1340
|
-
type:
|
1250
|
+
import_zod15.z.object({
|
1251
|
+
type: import_zod15.z.literal(ActionType.READ)
|
1341
1252
|
})
|
1342
1253
|
);
|
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
|
-
])
|
1254
|
+
var ActionDocument = import_zod15.z.discriminatedUnion("type", [
|
1255
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1256
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1257
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1258
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1259
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1260
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1261
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1262
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1263
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1264
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1265
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1266
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1267
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1268
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1269
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1270
|
+
]).openapi({
|
1271
|
+
ref: "ActionDocument"
|
1272
|
+
});
|
1360
1273
|
var AsyncRejectActionDocument = ActionBase.omit({
|
1361
1274
|
declaration: true,
|
1362
|
-
annotation: true
|
1363
|
-
createdBy: true,
|
1364
|
-
createdAtLocation: true
|
1275
|
+
annotation: true
|
1365
1276
|
}).merge(
|
1366
|
-
|
1367
|
-
type:
|
1368
|
-
status:
|
1277
|
+
import_zod15.z.object({
|
1278
|
+
type: import_zod15.z.enum(ConfirmableActions),
|
1279
|
+
status: import_zod15.z.literal(ActionStatus.Rejected)
|
1369
1280
|
})
|
1370
1281
|
);
|
1371
|
-
var Action =
|
1372
|
-
var ResolvedUser =
|
1373
|
-
id:
|
1374
|
-
role:
|
1375
|
-
name:
|
1376
|
-
|
1377
|
-
use:
|
1378
|
-
given:
|
1379
|
-
family:
|
1282
|
+
var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1283
|
+
var ResolvedUser = import_zod15.z.object({
|
1284
|
+
id: import_zod15.z.string(),
|
1285
|
+
role: import_zod15.z.string(),
|
1286
|
+
name: import_zod15.z.array(
|
1287
|
+
import_zod15.z.object({
|
1288
|
+
use: import_zod15.z.string(),
|
1289
|
+
given: import_zod15.z.array(import_zod15.z.string()),
|
1290
|
+
family: import_zod15.z.string()
|
1380
1291
|
})
|
1381
1292
|
)
|
1382
1293
|
});
|
1383
1294
|
|
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");
|
1295
|
+
// ../commons/src/conditionals/validate.ts
|
1296
|
+
var import_ajv = __toESM(require("ajv"));
|
1297
|
+
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1298
|
+
var import_date_fns = require("date-fns");
|
1709
1299
|
|
1710
1300
|
// ../commons/src/events/FieldTypeMapping.ts
|
1711
|
-
var
|
1301
|
+
var import_zod16 = require("zod");
|
1712
1302
|
function mapFieldTypeToZod(type, required) {
|
1713
1303
|
let schema;
|
1714
1304
|
switch (type) {
|
@@ -1718,6 +1308,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1718
1308
|
case FieldType.EMAIL:
|
1719
1309
|
schema = EmailValue;
|
1720
1310
|
break;
|
1311
|
+
case FieldType.DATE_RANGE:
|
1312
|
+
schema = DateRangeFieldValue;
|
1313
|
+
break;
|
1721
1314
|
case FieldType.TEXT:
|
1722
1315
|
case FieldType.TEXTAREA:
|
1723
1316
|
case FieldType.DIVIDER:
|
@@ -1732,8 +1325,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1732
1325
|
case FieldType.FACILITY:
|
1733
1326
|
case FieldType.OFFICE:
|
1734
1327
|
case FieldType.SIGNATURE:
|
1735
|
-
|
1736
|
-
schema = required ? RequiredTextValue : TextValue;
|
1328
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1737
1329
|
break;
|
1738
1330
|
case FieldType.NUMBER:
|
1739
1331
|
schema = NumberFieldValue;
|
@@ -1761,7 +1353,7 @@ function createValidationSchema(config) {
|
|
1761
1353
|
for (const field2 of config) {
|
1762
1354
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1763
1355
|
}
|
1764
|
-
return
|
1356
|
+
return import_zod16.z.object(shape);
|
1765
1357
|
}
|
1766
1358
|
function mapFieldTypeToMockValue(field2, i) {
|
1767
1359
|
switch (field2.type) {
|
@@ -1799,6 +1391,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1799
1391
|
};
|
1800
1392
|
case FieldType.DATE:
|
1801
1393
|
return "2021-01-01";
|
1394
|
+
case FieldType.DATE_RANGE:
|
1395
|
+
return ["2021-01-01", "2021-01-02"];
|
1802
1396
|
case FieldType.CHECKBOX:
|
1803
1397
|
return true;
|
1804
1398
|
case FieldType.FILE:
|
@@ -1833,6 +1427,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1833
1427
|
case FieldType.EMAIL:
|
1834
1428
|
case FieldType.DATE:
|
1835
1429
|
case FieldType.CHECKBOX:
|
1430
|
+
case FieldType.DATE_RANGE:
|
1836
1431
|
case FieldType.DATA:
|
1837
1432
|
return null;
|
1838
1433
|
case FieldType.ADDRESS:
|
@@ -1865,6 +1460,9 @@ var isParagraphFieldType = (field2) => {
|
|
1865
1460
|
var isDateFieldType = (field2) => {
|
1866
1461
|
return field2.config.type === FieldType.DATE;
|
1867
1462
|
};
|
1463
|
+
var isDateRangeFieldType = (field2) => {
|
1464
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1465
|
+
};
|
1868
1466
|
var isPageHeaderFieldType = (field2) => {
|
1869
1467
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1870
1468
|
};
|
@@ -1935,12 +1533,23 @@ var ajv = new import_ajv.default({
|
|
1935
1533
|
function validate(schema, data) {
|
1936
1534
|
return ajv.validate(schema, data);
|
1937
1535
|
}
|
1536
|
+
function isConditionMet(conditional, values) {
|
1537
|
+
return validate(conditional, {
|
1538
|
+
$form: values,
|
1539
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1540
|
+
});
|
1541
|
+
}
|
1938
1542
|
function getConditionalActionsForField(field2, values) {
|
1939
1543
|
if (!field2.conditionals) {
|
1940
1544
|
return [];
|
1941
1545
|
}
|
1942
1546
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1943
1547
|
}
|
1548
|
+
function areConditionsMet(conditions, values) {
|
1549
|
+
return conditions.every(
|
1550
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1551
|
+
);
|
1552
|
+
}
|
1944
1553
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1945
1554
|
const hasRule = (field2.conditionals ?? []).some(
|
1946
1555
|
(conditional) => conditional.type === conditionalType
|
@@ -1959,6 +1568,10 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1959
1568
|
function isFieldVisible(field2, form) {
|
1960
1569
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1961
1570
|
}
|
1571
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1572
|
+
const fieldValue = form[field2.id];
|
1573
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1574
|
+
}
|
1962
1575
|
function isFieldEnabled(field2, form) {
|
1963
1576
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1964
1577
|
}
|
@@ -2063,6 +1676,11 @@ function runFieldValidations({
|
|
2063
1676
|
field: field2,
|
2064
1677
|
values
|
2065
1678
|
}) {
|
1679
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1680
|
+
return {
|
1681
|
+
errors: []
|
1682
|
+
};
|
1683
|
+
}
|
2066
1684
|
const conditionalParameters = {
|
2067
1685
|
$form: values,
|
2068
1686
|
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
@@ -2080,29 +1698,6 @@ function runFieldValidations({
|
|
2080
1698
|
errors: [...fieldValidationResult, ...customValidationResults]
|
2081
1699
|
};
|
2082
1700
|
}
|
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
1701
|
|
2107
1702
|
// ../commons/src/uuid.ts
|
2108
1703
|
var import_uuid = require("uuid");
|
@@ -2110,8 +1705,15 @@ function getUUID() {
|
|
2110
1705
|
return (0, import_uuid.v4)();
|
2111
1706
|
}
|
2112
1707
|
|
1708
|
+
// ../commons/src/utils.ts
|
1709
|
+
function getOrThrow(x, message) {
|
1710
|
+
if (x === void 0 || x === null) {
|
1711
|
+
throw new Error(message);
|
1712
|
+
}
|
1713
|
+
return x;
|
1714
|
+
}
|
1715
|
+
|
2113
1716
|
// ../commons/src/events/utils.ts
|
2114
|
-
var import_date_fns2 = require("date-fns");
|
2115
1717
|
function isDeclarationActionConfig(action) {
|
2116
1718
|
return DeclarationActions.safeParse(action.type).success;
|
2117
1719
|
}
|
@@ -2139,9 +1741,9 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
2139
1741
|
}
|
2140
1742
|
return [];
|
2141
1743
|
};
|
2142
|
-
|
2143
|
-
return (0,
|
2144
|
-
}
|
1744
|
+
function getAllAnnotationFields(config) {
|
1745
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1746
|
+
}
|
2145
1747
|
var findRecordActionPages = (config, actionType) => {
|
2146
1748
|
const action = config.actions.find((a) => a.type === actionType);
|
2147
1749
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -2164,34 +1766,22 @@ function getActionReview(configuration, actionType) {
|
|
2164
1766
|
function getActionReviewFields(configuration, actionType) {
|
2165
1767
|
return getActionReview(configuration, actionType).fields;
|
2166
1768
|
}
|
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
1769
|
function isPageVisible(page, formValues) {
|
2180
1770
|
if (!page.conditional) {
|
2181
1771
|
return true;
|
2182
1772
|
}
|
2183
|
-
return
|
2184
|
-
$form: formValues,
|
2185
|
-
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
2186
|
-
});
|
1773
|
+
return isConditionMet(page.conditional, formValues);
|
2187
1774
|
}
|
2188
|
-
function omitHiddenFields(fields, values) {
|
2189
|
-
return (0,
|
2190
|
-
|
2191
|
-
|
1775
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1776
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1777
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1778
|
+
return false;
|
1779
|
+
}
|
1780
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1781
|
+
if (!fieldConfigs.length) {
|
2192
1782
|
return true;
|
2193
1783
|
}
|
2194
|
-
return !isFieldVisible(
|
1784
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
2195
1785
|
});
|
2196
1786
|
}
|
2197
1787
|
function omitHiddenPaginatedFields(formConfig, declaration) {
|
@@ -2215,25 +1805,61 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
2215
1805
|
annotation: {},
|
2216
1806
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
2217
1807
|
createdBy: "@todo",
|
2218
|
-
createdAtLocation: "@todo"
|
1808
|
+
createdAtLocation: "@todo",
|
1809
|
+
status: ActionStatus.Accepted,
|
1810
|
+
transactionId: "@todo",
|
1811
|
+
createdByRole: "@todo"
|
2219
1812
|
}
|
2220
1813
|
};
|
2221
1814
|
}
|
2222
1815
|
function isVerificationPage(page) {
|
2223
1816
|
return page.type === PageTypes.enum.VERIFICATION;
|
2224
1817
|
}
|
1818
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1819
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1820
|
+
}
|
1821
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1822
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1823
|
+
return [
|
1824
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1825
|
+
...getVisibleVerificationPageIds(
|
1826
|
+
actionConfig.additionalDetailsForm,
|
1827
|
+
annotation
|
1828
|
+
)
|
1829
|
+
];
|
1830
|
+
}
|
1831
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1832
|
+
return getVisibleVerificationPageIds(
|
1833
|
+
actionConfig.printForm.pages,
|
1834
|
+
annotation
|
1835
|
+
);
|
1836
|
+
}
|
1837
|
+
return [];
|
1838
|
+
}
|
1839
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1840
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1841
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1842
|
+
actionConfig,
|
1843
|
+
annotation
|
1844
|
+
);
|
1845
|
+
return omitHiddenFields(
|
1846
|
+
annotationFields,
|
1847
|
+
{ ...declaration, ...annotation },
|
1848
|
+
visibleVerificationPageIds
|
1849
|
+
);
|
1850
|
+
}
|
2225
1851
|
function deepMerge(currentDocument, actionDocument) {
|
2226
|
-
return (0,
|
1852
|
+
return (0, import_lodash.mergeWith)(
|
2227
1853
|
currentDocument,
|
2228
1854
|
actionDocument,
|
2229
1855
|
(previousValue, incomingValue) => {
|
2230
1856
|
if (incomingValue === void 0) {
|
2231
1857
|
return previousValue;
|
2232
1858
|
}
|
2233
|
-
if ((0,
|
1859
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
2234
1860
|
return incomingValue;
|
2235
1861
|
}
|
2236
|
-
if ((0,
|
1862
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
2237
1863
|
return void 0;
|
2238
1864
|
}
|
2239
1865
|
return incomingValue;
|
@@ -2248,201 +1874,128 @@ function findLastAssignmentAction(actions) {
|
|
2248
1874
|
function isWriteAction(actionType) {
|
2249
1875
|
return writeActions.safeParse(actionType).success;
|
2250
1876
|
}
|
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;
|
1877
|
+
var findAllFields = (config) => {
|
1878
|
+
return (0, import_lodash.flattenDeep)([
|
1879
|
+
...getDeclarationFields(config),
|
1880
|
+
...getAllAnnotationFields(config)
|
1881
|
+
]);
|
1882
|
+
};
|
1883
|
+
function getMixedPath(obj, path, defaultValue) {
|
1884
|
+
const parts = path.split(".");
|
1885
|
+
const resolve = (current, segments) => {
|
1886
|
+
if (current == null || segments.length === 0) {
|
1887
|
+
return current;
|
2304
1888
|
}
|
2305
|
-
|
2306
|
-
const
|
2307
|
-
if (
|
2308
|
-
|
1889
|
+
for (let i = segments.length; i > 0; i--) {
|
1890
|
+
const compoundKey = segments.slice(0, i).join(".");
|
1891
|
+
if ((0, import_lodash.has)(current, compoundKey)) {
|
1892
|
+
const next = (0, import_lodash.get)(current, compoundKey);
|
1893
|
+
return resolve(next, segments.slice(i));
|
2309
1894
|
}
|
2310
|
-
return deepMerge(status, requestAction.declaration);
|
2311
1895
|
}
|
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
|
-
);
|
1896
|
+
return void 0;
|
1897
|
+
};
|
1898
|
+
const result = resolve(obj, parts);
|
1899
|
+
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
2338
1900
|
}
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
1901
|
+
|
1902
|
+
// ../commons/src/events/EventConfig.ts
|
1903
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1904
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
|
1905
|
+
var EventConfig = import_zod17.z.object({
|
1906
|
+
id: import_zod17.z.string().describe(
|
1907
|
+
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1908
|
+
),
|
1909
|
+
dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
|
1910
|
+
title: TranslationConfig,
|
1911
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1912
|
+
"This is a fallback title if actual title resolves to empty string"
|
1913
|
+
),
|
1914
|
+
summary: SummaryConfig,
|
1915
|
+
label: TranslationConfig,
|
1916
|
+
actions: import_zod17.z.array(ActionConfig),
|
1917
|
+
declaration: DeclarationFormConfig,
|
1918
|
+
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1919
|
+
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1920
|
+
}).superRefine((event2, ctx) => {
|
1921
|
+
const allFields = findAllFields(event2);
|
1922
|
+
const fieldIds = allFields.map((field2) => field2.id);
|
1923
|
+
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1924
|
+
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
2342
1925
|
);
|
2343
|
-
|
2344
|
-
|
1926
|
+
const advancedSearchFieldsSet = new Set(advancedSearchFields);
|
1927
|
+
if (advancedSearchFieldsSet.size !== advancedSearchFields.length) {
|
1928
|
+
ctx.addIssue({
|
1929
|
+
code: "custom",
|
1930
|
+
message: "Advanced search field ids must be unique",
|
1931
|
+
path: ["advancedSearch"]
|
1932
|
+
});
|
2345
1933
|
}
|
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;
|
1934
|
+
const invalidFields = event2.advancedSearch.flatMap(
|
1935
|
+
(section) => (
|
1936
|
+
// Check if the fieldId is not in the fieldIds array
|
1937
|
+
// and also not in the metadataFields array
|
1938
|
+
section.fields.filter(
|
1939
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
1940
|
+
)
|
1941
|
+
)
|
1942
|
+
);
|
1943
|
+
if (invalidFields.length > 0) {
|
1944
|
+
ctx.addIssue({
|
1945
|
+
code: "custom",
|
1946
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1947
|
+
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1948
|
+
path: ["advancedSearch"]
|
1949
|
+
});
|
2396
1950
|
}
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
1951
|
+
if (event2.dateOfEvent) {
|
1952
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
1953
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
1954
|
+
);
|
1955
|
+
if (!eventDateFieldId) {
|
1956
|
+
ctx.addIssue({
|
1957
|
+
code: "custom",
|
1958
|
+
message: `Date of event field id must match a field id in fields array.
|
1959
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
1960
|
+
path: ["dateOfEvent"]
|
1961
|
+
});
|
1962
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
1963
|
+
ctx.addIssue({
|
1964
|
+
code: "custom",
|
1965
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
1966
|
+
path: ["dateOfEvent.fieldType"]
|
1967
|
+
});
|
2402
1968
|
}
|
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
|
-
}
|
1969
|
+
}
|
1970
|
+
}).openapi({
|
1971
|
+
ref: "EventConfig"
|
1972
|
+
});
|
2431
1973
|
|
2432
|
-
// ../commons/src/events/
|
2433
|
-
var
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
};
|
1974
|
+
// ../commons/src/events/EventConfigInput.ts
|
1975
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1976
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1977
|
+
var definePage = (page) => PageConfig.parse(page);
|
1978
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
2438
1979
|
|
2439
|
-
// ../commons/src/events/
|
2440
|
-
|
2441
|
-
return getUUID();
|
2442
|
-
}
|
1980
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1981
|
+
var import_zod24 = require("zod");
|
2443
1982
|
|
2444
|
-
// ../commons/src/events/
|
2445
|
-
var
|
1983
|
+
// ../commons/src/events/serializers/user/serializer.ts
|
1984
|
+
var import_zod18 = require("zod");
|
1985
|
+
var SerializedUserField = import_zod18.z.object({
|
1986
|
+
$userField: import_zod18.z.enum([
|
1987
|
+
"id",
|
1988
|
+
"name",
|
1989
|
+
"role",
|
1990
|
+
"signatureFilename",
|
1991
|
+
"primaryOfficeId"
|
1992
|
+
])
|
1993
|
+
});
|
1994
|
+
function userSerializer(userField) {
|
1995
|
+
return {
|
1996
|
+
$userField: userField
|
1997
|
+
};
|
1998
|
+
}
|
2446
1999
|
|
2447
2000
|
// ../commons/src/conditionals/conditionals.ts
|
2448
2001
|
function defineConditional(schema) {
|
@@ -2485,7 +2038,7 @@ function not(condition) {
|
|
2485
2038
|
function never() {
|
2486
2039
|
return not(alwaysTrue());
|
2487
2040
|
}
|
2488
|
-
var user = {
|
2041
|
+
var user = Object.assign(userSerializer, {
|
2489
2042
|
hasScope: (scope) => defineConditional({
|
2490
2043
|
type: "object",
|
2491
2044
|
properties: {
|
@@ -2505,33 +2058,39 @@ var user = {
|
|
2505
2058
|
},
|
2506
2059
|
required: ["$user"]
|
2507
2060
|
})
|
2508
|
-
};
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2061
|
+
});
|
2062
|
+
function createEventConditionals() {
|
2063
|
+
return {
|
2064
|
+
/**
|
2065
|
+
* Checks if the event contains a specific action type.
|
2066
|
+
* @param action - The action type to check for.
|
2067
|
+
*/
|
2068
|
+
hasAction: (action) => defineConditional({
|
2069
|
+
type: "object",
|
2070
|
+
properties: {
|
2071
|
+
$event: {
|
2072
|
+
type: "object",
|
2073
|
+
properties: {
|
2074
|
+
actions: {
|
2075
|
+
type: "array",
|
2076
|
+
contains: {
|
2077
|
+
type: "object",
|
2078
|
+
properties: {
|
2079
|
+
type: {
|
2080
|
+
const: action
|
2081
|
+
}
|
2082
|
+
},
|
2083
|
+
required: ["type"]
|
2084
|
+
}
|
2526
2085
|
}
|
2527
|
-
}
|
2528
|
-
|
2529
|
-
|
2530
|
-
}
|
2531
|
-
|
2532
|
-
|
2533
|
-
}
|
2534
|
-
}
|
2086
|
+
},
|
2087
|
+
required: ["actions"]
|
2088
|
+
}
|
2089
|
+
},
|
2090
|
+
required: ["$event"]
|
2091
|
+
})
|
2092
|
+
};
|
2093
|
+
}
|
2535
2094
|
function getDateFromNow(days) {
|
2536
2095
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2537
2096
|
}
|
@@ -2552,7 +2111,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
|
2552
2111
|
function isFieldReference(value) {
|
2553
2112
|
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2554
2113
|
}
|
2555
|
-
function
|
2114
|
+
function createFieldConditionals(fieldId) {
|
2556
2115
|
const getDateRange = (date, clause) => ({
|
2557
2116
|
type: "object",
|
2558
2117
|
properties: {
|
@@ -2565,10 +2124,6 @@ function field(fieldId) {
|
|
2565
2124
|
required: [fieldId]
|
2566
2125
|
});
|
2567
2126
|
return {
|
2568
|
-
/**
|
2569
|
-
* @private Internal property used for field reference tracking.
|
2570
|
-
*/
|
2571
|
-
_fieldId: fieldId,
|
2572
2127
|
isAfter: () => ({
|
2573
2128
|
days: (days) => ({
|
2574
2129
|
inPast: () => defineFormConditional(
|
@@ -2671,119 +2226,1141 @@ function field(fieldId) {
|
|
2671
2226
|
required: [fieldId]
|
2672
2227
|
},
|
2673
2228
|
{
|
2674
|
-
not: {
|
2675
|
-
required: [fieldId]
|
2676
|
-
}
|
2677
|
-
}
|
2678
|
-
]
|
2679
|
-
}),
|
2680
|
-
isUndefined: () => defineFormConditional({
|
2681
|
-
type: "object",
|
2682
|
-
properties: {
|
2683
|
-
[fieldId]: {
|
2684
|
-
type: "string",
|
2685
|
-
enum: ["undefined"]
|
2686
|
-
}
|
2687
|
-
},
|
2688
|
-
not: {
|
2689
|
-
required: [fieldId]
|
2690
|
-
}
|
2691
|
-
}),
|
2692
|
-
inArray: (values) => defineFormConditional({
|
2693
|
-
type: "object",
|
2694
|
-
properties: {
|
2695
|
-
[fieldId]: {
|
2696
|
-
type: "string",
|
2697
|
-
enum: values
|
2698
|
-
}
|
2699
|
-
},
|
2700
|
-
required: [fieldId]
|
2701
|
-
}),
|
2702
|
-
isValidEnglishName: () => defineFormConditional({
|
2703
|
-
type: "object",
|
2704
|
-
properties: {
|
2705
|
-
[fieldId]: {
|
2706
|
-
type: "string",
|
2707
|
-
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
2708
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2709
|
-
}
|
2710
|
-
},
|
2711
|
-
required: [fieldId]
|
2712
|
-
}),
|
2713
|
-
/**
|
2714
|
-
* Checks if the field value matches a given regular expression pattern.
|
2715
|
-
* @param pattern - The regular expression pattern to match the field value against.
|
2716
|
-
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2717
|
-
*/
|
2718
|
-
matches: (pattern) => defineFormConditional({
|
2719
|
-
type: "object",
|
2720
|
-
properties: {
|
2721
|
-
[fieldId]: {
|
2722
|
-
type: "string",
|
2723
|
-
pattern
|
2724
|
-
}
|
2725
|
-
},
|
2726
|
-
required: [fieldId]
|
2727
|
-
}),
|
2728
|
-
isBetween: (min, max) => defineFormConditional({
|
2729
|
-
type: "object",
|
2730
|
-
properties: {
|
2731
|
-
[fieldId]: {
|
2732
|
-
type: "number",
|
2733
|
-
minimum: min,
|
2734
|
-
maximum: max
|
2229
|
+
not: {
|
2230
|
+
required: [fieldId]
|
2231
|
+
}
|
2232
|
+
}
|
2233
|
+
]
|
2234
|
+
}),
|
2235
|
+
isUndefined: () => defineFormConditional({
|
2236
|
+
type: "object",
|
2237
|
+
properties: {
|
2238
|
+
[fieldId]: {
|
2239
|
+
type: "string",
|
2240
|
+
enum: ["undefined"]
|
2241
|
+
}
|
2242
|
+
},
|
2243
|
+
not: {
|
2244
|
+
required: [fieldId]
|
2245
|
+
}
|
2246
|
+
}),
|
2247
|
+
inArray: (values) => defineFormConditional({
|
2248
|
+
type: "object",
|
2249
|
+
properties: {
|
2250
|
+
[fieldId]: {
|
2251
|
+
type: "string",
|
2252
|
+
enum: values
|
2253
|
+
}
|
2254
|
+
},
|
2255
|
+
required: [fieldId]
|
2256
|
+
}),
|
2257
|
+
isValidEnglishName: () => defineFormConditional({
|
2258
|
+
type: "object",
|
2259
|
+
properties: {
|
2260
|
+
[fieldId]: {
|
2261
|
+
type: "string",
|
2262
|
+
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
2263
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2264
|
+
}
|
2265
|
+
},
|
2266
|
+
required: [fieldId]
|
2267
|
+
}),
|
2268
|
+
/**
|
2269
|
+
* Checks if the field value matches a given regular expression pattern.
|
2270
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2271
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2272
|
+
*/
|
2273
|
+
matches: (pattern) => defineFormConditional({
|
2274
|
+
type: "object",
|
2275
|
+
properties: {
|
2276
|
+
[fieldId]: {
|
2277
|
+
type: "string",
|
2278
|
+
pattern
|
2279
|
+
}
|
2280
|
+
},
|
2281
|
+
required: [fieldId]
|
2282
|
+
}),
|
2283
|
+
isBetween: (min, max) => defineFormConditional({
|
2284
|
+
type: "object",
|
2285
|
+
properties: {
|
2286
|
+
[fieldId]: {
|
2287
|
+
type: "number",
|
2288
|
+
minimum: min,
|
2289
|
+
maximum: max
|
2290
|
+
}
|
2291
|
+
},
|
2292
|
+
required: [fieldId]
|
2293
|
+
}),
|
2294
|
+
getId: () => ({ fieldId })
|
2295
|
+
};
|
2296
|
+
}
|
2297
|
+
|
2298
|
+
// ../commons/src/event-config/event-configuration.ts
|
2299
|
+
function createEventFieldConfig(fieldId, options) {
|
2300
|
+
return {
|
2301
|
+
fieldId,
|
2302
|
+
options,
|
2303
|
+
config: { type: "exact" },
|
2304
|
+
fieldType: "event"
|
2305
|
+
};
|
2306
|
+
}
|
2307
|
+
|
2308
|
+
// ../commons/src/events/event.ts
|
2309
|
+
function eventFn(fieldId, options) {
|
2310
|
+
return createEventFieldConfig(fieldId, options);
|
2311
|
+
}
|
2312
|
+
var event = Object.assign(eventFn, {
|
2313
|
+
...createEventConditionals(),
|
2314
|
+
field(field2) {
|
2315
|
+
return {
|
2316
|
+
$event: field2
|
2317
|
+
};
|
2318
|
+
}
|
2319
|
+
});
|
2320
|
+
|
2321
|
+
// ../commons/src/events/WorkqueueColumnConfig.ts
|
2322
|
+
var import_zod20 = require("zod");
|
2323
|
+
|
2324
|
+
// ../commons/src/events/EventMetadata.ts
|
2325
|
+
var import_zod19 = require("zod");
|
2326
|
+
var EventStatus = {
|
2327
|
+
CREATED: "CREATED",
|
2328
|
+
NOTIFIED: "NOTIFIED",
|
2329
|
+
DECLARED: "DECLARED",
|
2330
|
+
VALIDATED: "VALIDATED",
|
2331
|
+
REGISTERED: "REGISTERED",
|
2332
|
+
CERTIFIED: "CERTIFIED",
|
2333
|
+
REJECTED: "REJECTED",
|
2334
|
+
ARCHIVED: "ARCHIVED"
|
2335
|
+
};
|
2336
|
+
var eventStatusValues = [
|
2337
|
+
EventStatus.CREATED,
|
2338
|
+
EventStatus.NOTIFIED,
|
2339
|
+
EventStatus.DECLARED,
|
2340
|
+
EventStatus.VALIDATED,
|
2341
|
+
EventStatus.REGISTERED,
|
2342
|
+
EventStatus.CERTIFIED,
|
2343
|
+
EventStatus.REJECTED,
|
2344
|
+
EventStatus.ARCHIVED
|
2345
|
+
];
|
2346
|
+
var EventStatusEnum = import_zod19.z.enum(eventStatusValues);
|
2347
|
+
var CustomFlags = {
|
2348
|
+
CERTIFICATE_PRINTED: "certificate-printed"
|
2349
|
+
};
|
2350
|
+
var Flag = import_zod19.z.string().regex(
|
2351
|
+
new RegExp(
|
2352
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
|
2353
|
+
),
|
2354
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
2355
|
+
).or(import_zod19.z.nativeEnum(CustomFlags));
|
2356
|
+
var eventStatuses = Object.values(EventStatus);
|
2357
|
+
var EventStatuses = import_zod19.z.nativeEnum(EventStatus);
|
2358
|
+
var ZodDate = import_zod19.z.string().date();
|
2359
|
+
var ActionCreationMetadata = import_zod19.z.object({
|
2360
|
+
createdAt: import_zod19.z.string().datetime().describe("The timestamp when the action request was created."),
|
2361
|
+
createdBy: import_zod19.z.string().describe("ID of the user who created the action request."),
|
2362
|
+
createdAtLocation: import_zod19.z.string().describe("Location of the user who created the action request."),
|
2363
|
+
acceptedAt: import_zod19.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
2364
|
+
createdByRole: import_zod19.z.string().describe("Role of the user at the time of action request creation.")
|
2365
|
+
});
|
2366
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2367
|
+
registrationNumber: import_zod19.z.string().describe(
|
2368
|
+
"Registration number of the event. Always present for accepted registrations."
|
2369
|
+
)
|
2370
|
+
});
|
2371
|
+
var LegalStatuses = import_zod19.z.object({
|
2372
|
+
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2373
|
+
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2374
|
+
});
|
2375
|
+
var EventMetadata = import_zod19.z.object({
|
2376
|
+
id: import_zod19.z.string(),
|
2377
|
+
title: import_zod19.z.string(),
|
2378
|
+
type: import_zod19.z.string().describe("The type of event, such as birth, death, or marriage."),
|
2379
|
+
status: EventStatuses,
|
2380
|
+
legalStatuses: LegalStatuses.describe(
|
2381
|
+
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2382
|
+
),
|
2383
|
+
createdAt: import_zod19.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2384
|
+
dateOfEvent: ZodDate.nullish(),
|
2385
|
+
createdBy: import_zod19.z.string().describe("ID of the user who created the event."),
|
2386
|
+
updatedByUserRole: import_zod19.z.string().describe("Role of the user who last updated the declaration."),
|
2387
|
+
createdAtLocation: import_zod19.z.string().describe("Location of the user who created the event."),
|
2388
|
+
updatedAtLocation: import_zod19.z.string().nullish().describe("Location of the user who last updated the declaration."),
|
2389
|
+
updatedAt: import_zod19.z.string().datetime().describe("Timestamp of the most recent declaration update."),
|
2390
|
+
assignedTo: import_zod19.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
2391
|
+
updatedBy: import_zod19.z.string().nullish().describe("ID of the user who last updated the declaration."),
|
2392
|
+
trackingId: import_zod19.z.string().describe(
|
2393
|
+
"System-generated tracking ID used by informants or registrars to look up the event."
|
2394
|
+
),
|
2395
|
+
flags: import_zod19.z.array(Flag)
|
2396
|
+
});
|
2397
|
+
var EventMetadataKeys = import_zod19.z.enum([
|
2398
|
+
"id",
|
2399
|
+
"title",
|
2400
|
+
"type",
|
2401
|
+
"status",
|
2402
|
+
"createdAt",
|
2403
|
+
"dateOfEvent",
|
2404
|
+
"createdBy",
|
2405
|
+
"updatedByUserRole",
|
2406
|
+
"createdAtLocation",
|
2407
|
+
"updatedAtLocation",
|
2408
|
+
"updatedAt",
|
2409
|
+
"assignedTo",
|
2410
|
+
"updatedBy",
|
2411
|
+
"trackingId",
|
2412
|
+
"legalStatuses",
|
2413
|
+
"flags"
|
2414
|
+
]);
|
2415
|
+
var EventMetadataParameter = import_zod19.z.object({
|
2416
|
+
// @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
|
2417
|
+
$event: EventMetadataKeys
|
2418
|
+
});
|
2419
|
+
var eventMetadataLabelMap = {
|
2420
|
+
"event.assignedTo": {
|
2421
|
+
id: "event.assignedTo.label",
|
2422
|
+
defaultMessage: "Assigned To",
|
2423
|
+
description: "Assigned To"
|
2424
|
+
},
|
2425
|
+
"event.title": {
|
2426
|
+
id: "event.title.label",
|
2427
|
+
defaultMessage: "Title",
|
2428
|
+
description: "Title"
|
2429
|
+
},
|
2430
|
+
"event.createdAt": {
|
2431
|
+
id: "event.createdAt.label",
|
2432
|
+
defaultMessage: "Created",
|
2433
|
+
description: "Created At"
|
2434
|
+
},
|
2435
|
+
"event.dateOfEvent": {
|
2436
|
+
id: "event.dateOfEvent.label",
|
2437
|
+
defaultMessage: "Date of Event",
|
2438
|
+
description: "Date of Event"
|
2439
|
+
},
|
2440
|
+
"event.createdAtLocation": {
|
2441
|
+
id: "event.createdAtLocation.label",
|
2442
|
+
defaultMessage: "Location",
|
2443
|
+
description: "Created At Location"
|
2444
|
+
},
|
2445
|
+
"event.updatedAtLocation": {
|
2446
|
+
id: "event.updatedAtLocation.label",
|
2447
|
+
defaultMessage: "Location",
|
2448
|
+
description: "Updated At Location"
|
2449
|
+
},
|
2450
|
+
"event.createdBy": {
|
2451
|
+
id: "event.createdBy.label",
|
2452
|
+
defaultMessage: "Created By",
|
2453
|
+
description: "Created By"
|
2454
|
+
},
|
2455
|
+
"event.updatedByUserRole": {
|
2456
|
+
id: "event.updatedByUserRole.label",
|
2457
|
+
defaultMessage: "Updated By Role",
|
2458
|
+
description: "Updated By Role"
|
2459
|
+
},
|
2460
|
+
"event.id": {
|
2461
|
+
id: "event.id.label",
|
2462
|
+
defaultMessage: "ID",
|
2463
|
+
description: "ID"
|
2464
|
+
},
|
2465
|
+
"event.updatedAt": {
|
2466
|
+
id: "event.modifiedAt.label",
|
2467
|
+
defaultMessage: "Updated",
|
2468
|
+
description: "Modified At"
|
2469
|
+
},
|
2470
|
+
"event.status": {
|
2471
|
+
id: "event.status.label",
|
2472
|
+
defaultMessage: "Status",
|
2473
|
+
description: "Status"
|
2474
|
+
},
|
2475
|
+
"event.type": {
|
2476
|
+
id: "event.type.label",
|
2477
|
+
defaultMessage: "Type",
|
2478
|
+
description: "Type"
|
2479
|
+
},
|
2480
|
+
"event.updatedBy": {
|
2481
|
+
id: "event.updatedBy.label",
|
2482
|
+
defaultMessage: "Updated By",
|
2483
|
+
description: "Updated By"
|
2484
|
+
},
|
2485
|
+
"event.trackingId": {
|
2486
|
+
id: "event.trackingId.label",
|
2487
|
+
defaultMessage: "Tracking ID",
|
2488
|
+
description: "Tracking ID"
|
2489
|
+
},
|
2490
|
+
"event.flags": {
|
2491
|
+
id: "event.flags.label",
|
2492
|
+
defaultMessage: "Flags",
|
2493
|
+
description: "Flags"
|
2494
|
+
}
|
2495
|
+
};
|
2496
|
+
|
2497
|
+
// ../commons/src/events/WorkqueueColumnConfig.ts
|
2498
|
+
var WorkqueueColumn = import_zod20.z.object({
|
2499
|
+
label: TranslationConfig,
|
2500
|
+
value: EventMetadataParameter
|
2501
|
+
});
|
2502
|
+
function defineWorkqueueColumns(workqueueColumns) {
|
2503
|
+
return workqueueColumns.map(
|
2504
|
+
(workqueueColumn) => WorkqueueColumn.parse(workqueueColumn)
|
2505
|
+
);
|
2506
|
+
}
|
2507
|
+
|
2508
|
+
// ../commons/src/events/CountryConfigQueryInput.ts
|
2509
|
+
var import_zod21 = require("zod");
|
2510
|
+
var Fuzzy = import_zod21.z.object({ type: import_zod21.z.literal("fuzzy"), term: import_zod21.z.string() });
|
2511
|
+
var Exact = import_zod21.z.object({ type: import_zod21.z.literal("exact"), term: import_zod21.z.string() });
|
2512
|
+
var AnyOf = import_zod21.z.object({
|
2513
|
+
type: import_zod21.z.literal("anyOf"),
|
2514
|
+
terms: import_zod21.z.array(import_zod21.z.string())
|
2515
|
+
});
|
2516
|
+
var AnyOfStatus = import_zod21.z.object({
|
2517
|
+
type: import_zod21.z.literal("anyOf"),
|
2518
|
+
terms: import_zod21.z.array(EventStatusEnum)
|
2519
|
+
});
|
2520
|
+
var SerializableExact = import_zod21.z.object({
|
2521
|
+
type: import_zod21.z.literal("exact"),
|
2522
|
+
term: import_zod21.z.union([import_zod21.z.string(), SerializedUserField])
|
2523
|
+
});
|
2524
|
+
var ExactStatus = import_zod21.z.object({
|
2525
|
+
type: import_zod21.z.literal("exact"),
|
2526
|
+
term: EventStatusEnum
|
2527
|
+
});
|
2528
|
+
var Range = import_zod21.z.object({
|
2529
|
+
type: import_zod21.z.literal("range"),
|
2530
|
+
gte: import_zod21.z.string(),
|
2531
|
+
lte: import_zod21.z.string()
|
2532
|
+
});
|
2533
|
+
var Not = import_zod21.z.object({ type: import_zod21.z.literal("not"), term: import_zod21.z.string() });
|
2534
|
+
var Within = import_zod21.z.object({ type: import_zod21.z.literal("within"), location: import_zod21.z.string() });
|
2535
|
+
var SerializableWithin = import_zod21.z.object({
|
2536
|
+
type: import_zod21.z.literal("within"),
|
2537
|
+
location: import_zod21.z.union([import_zod21.z.string(), SerializedUserField])
|
2538
|
+
});
|
2539
|
+
var DateCondition = import_zod21.z.union([Exact, Range]);
|
2540
|
+
var QueryInput = import_zod21.z.lazy(
|
2541
|
+
() => import_zod21.z.union([
|
2542
|
+
import_zod21.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
2543
|
+
import_zod21.z.record(import_zod21.z.string(), QueryInput)
|
2544
|
+
])
|
2545
|
+
);
|
2546
|
+
var SerializedQueryExpression = import_zod21.z.object({
|
2547
|
+
title: import_zod21.z.string(),
|
2548
|
+
eventType: import_zod21.z.string(),
|
2549
|
+
status: import_zod21.z.optional(import_zod21.z.union([AnyOfStatus, ExactStatus])),
|
2550
|
+
createdAt: import_zod21.z.optional(DateCondition),
|
2551
|
+
updatedAt: import_zod21.z.optional(DateCondition),
|
2552
|
+
createdAtLocation: import_zod21.z.optional(
|
2553
|
+
import_zod21.z.union([SerializableWithin, SerializableExact])
|
2554
|
+
),
|
2555
|
+
updatedAtLocation: import_zod21.z.optional(
|
2556
|
+
import_zod21.z.union([SerializableWithin, SerializableExact])
|
2557
|
+
),
|
2558
|
+
assignedTo: import_zod21.z.optional(SerializableExact),
|
2559
|
+
createdBy: import_zod21.z.optional(SerializableExact),
|
2560
|
+
updatedBy: import_zod21.z.optional(SerializableExact),
|
2561
|
+
trackingId: import_zod21.z.optional(Exact),
|
2562
|
+
flags: import_zod21.z.optional(import_zod21.z.array(import_zod21.z.union([AnyOf, Not]))),
|
2563
|
+
data: QueryInput
|
2564
|
+
}).partial();
|
2565
|
+
var Or2 = import_zod21.z.object({
|
2566
|
+
type: import_zod21.z.literal("or"),
|
2567
|
+
clauses: import_zod21.z.array(SerializedQueryExpression)
|
2568
|
+
});
|
2569
|
+
var And2 = import_zod21.z.object({
|
2570
|
+
type: import_zod21.z.literal("and"),
|
2571
|
+
clauses: import_zod21.z.array(SerializedQueryExpression)
|
2572
|
+
});
|
2573
|
+
var CountryConfigQueryType = import_zod21.z.discriminatedUnion("type", [And2, Or2]);
|
2574
|
+
|
2575
|
+
// ../commons/src/icons.ts
|
2576
|
+
var import_zod22 = require("zod");
|
2577
|
+
var AvailableIcons = import_zod22.z.enum([
|
2578
|
+
"Archived",
|
2579
|
+
"Assigned",
|
2580
|
+
"Certified",
|
2581
|
+
"Close",
|
2582
|
+
"Collapse",
|
2583
|
+
"Draft",
|
2584
|
+
"DuplicateYellow",
|
2585
|
+
"Expand",
|
2586
|
+
"ExternalValidate",
|
2587
|
+
"FilledCheck",
|
2588
|
+
"InReview",
|
2589
|
+
"Offline",
|
2590
|
+
"Registered",
|
2591
|
+
"RequiresUpdates",
|
2592
|
+
"Sent",
|
2593
|
+
"Validated",
|
2594
|
+
"WaitingApproval",
|
2595
|
+
"ChartActivity",
|
2596
|
+
"Activity",
|
2597
|
+
"Archive",
|
2598
|
+
"ArchiveTray",
|
2599
|
+
"ArrowLeft",
|
2600
|
+
"ArrowRight",
|
2601
|
+
"Buildings",
|
2602
|
+
"Circle",
|
2603
|
+
"CaretDown",
|
2604
|
+
"CaretLeft",
|
2605
|
+
"CaretRight",
|
2606
|
+
"ChartBar",
|
2607
|
+
"ChartLine",
|
2608
|
+
"ChatCircle",
|
2609
|
+
"CheckSquare",
|
2610
|
+
"Compass",
|
2611
|
+
"Check",
|
2612
|
+
"Copy",
|
2613
|
+
"Database",
|
2614
|
+
"DotsThreeVertical",
|
2615
|
+
"DownloadSimple",
|
2616
|
+
"ArrowCounterClockwise",
|
2617
|
+
"MagnifyingGlassMinus",
|
2618
|
+
"MagnifyingGlassPlus",
|
2619
|
+
"Export",
|
2620
|
+
"Eye",
|
2621
|
+
"EyeSlash",
|
2622
|
+
"Envelope",
|
2623
|
+
"File",
|
2624
|
+
"FileSearch",
|
2625
|
+
"FileMinus",
|
2626
|
+
"FilePlus",
|
2627
|
+
"FileText",
|
2628
|
+
"FileX",
|
2629
|
+
"Handshake",
|
2630
|
+
"Gear",
|
2631
|
+
"GitBranch",
|
2632
|
+
"IdentificationCard",
|
2633
|
+
"List",
|
2634
|
+
"ListBullets",
|
2635
|
+
"Lock",
|
2636
|
+
"MagnifyingGlass",
|
2637
|
+
"MapPin",
|
2638
|
+
"Medal",
|
2639
|
+
"NotePencil",
|
2640
|
+
"Paperclip",
|
2641
|
+
"PaperPlaneTilt",
|
2642
|
+
"Pen",
|
2643
|
+
"Pencil",
|
2644
|
+
"PencilSimpleLine",
|
2645
|
+
"Phone",
|
2646
|
+
"Plus",
|
2647
|
+
"Printer",
|
2648
|
+
"SignOut",
|
2649
|
+
"Star",
|
2650
|
+
"Target",
|
2651
|
+
"TextT",
|
2652
|
+
"Trash",
|
2653
|
+
"UploadSimple",
|
2654
|
+
"User",
|
2655
|
+
"UserPlus",
|
2656
|
+
"Users",
|
2657
|
+
"WarningCircle",
|
2658
|
+
"X",
|
2659
|
+
"CircleWavyCheck",
|
2660
|
+
"CircleWavyQuestion",
|
2661
|
+
"ArchiveBox",
|
2662
|
+
"ArrowCircleDown",
|
2663
|
+
"FileArrowUp",
|
2664
|
+
"FileDotted",
|
2665
|
+
"Files",
|
2666
|
+
"PencilLine",
|
2667
|
+
"PencilCircle",
|
2668
|
+
"UserCircle",
|
2669
|
+
"Clock",
|
2670
|
+
"QrCode",
|
2671
|
+
"Webcam",
|
2672
|
+
"Sun",
|
2673
|
+
"DeviceTabletCamera",
|
2674
|
+
"Globe",
|
2675
|
+
"Fingerprint",
|
2676
|
+
"PushPin",
|
2677
|
+
"Timer"
|
2678
|
+
]);
|
2679
|
+
|
2680
|
+
// ../commons/src/events/EventIndex.ts
|
2681
|
+
var import_zod23 = require("zod");
|
2682
|
+
var EventIndex = EventMetadata.extend({
|
2683
|
+
declaration: EventState
|
2684
|
+
});
|
2685
|
+
var EventSearchIndex = import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any()).and(
|
2686
|
+
import_zod23.z.object({
|
2687
|
+
type: import_zod23.z.string()
|
2688
|
+
// Ensures "type" (event-id) exists and is a string
|
2689
|
+
})
|
2690
|
+
);
|
2691
|
+
var Fuzzy2 = import_zod23.z.object({ type: import_zod23.z.literal("fuzzy"), term: import_zod23.z.string() });
|
2692
|
+
var Exact2 = import_zod23.z.object({ type: import_zod23.z.literal("exact"), term: import_zod23.z.string() });
|
2693
|
+
var AnyOf2 = import_zod23.z.object({
|
2694
|
+
type: import_zod23.z.literal("anyOf"),
|
2695
|
+
terms: import_zod23.z.array(import_zod23.z.string())
|
2696
|
+
});
|
2697
|
+
var ExactStatus2 = import_zod23.z.object({
|
2698
|
+
type: import_zod23.z.literal("exact"),
|
2699
|
+
term: EventStatusEnum
|
2700
|
+
});
|
2701
|
+
var AnyOfStatus2 = import_zod23.z.object({
|
2702
|
+
type: import_zod23.z.literal("anyOf"),
|
2703
|
+
terms: import_zod23.z.array(EventStatusEnum)
|
2704
|
+
});
|
2705
|
+
var Range2 = import_zod23.z.object({
|
2706
|
+
type: import_zod23.z.literal("range"),
|
2707
|
+
gte: import_zod23.z.string(),
|
2708
|
+
lte: import_zod23.z.string()
|
2709
|
+
});
|
2710
|
+
var Not2 = import_zod23.z.object({ type: import_zod23.z.literal("not"), term: import_zod23.z.string() });
|
2711
|
+
var Within2 = import_zod23.z.object({ type: import_zod23.z.literal("within"), location: import_zod23.z.string() });
|
2712
|
+
var DateCondition2 = import_zod23.z.union([Exact2, Range2]);
|
2713
|
+
var QueryInput2 = import_zod23.z.lazy(
|
2714
|
+
() => import_zod23.z.union([
|
2715
|
+
import_zod23.z.discriminatedUnion("type", [Fuzzy2, Exact2, Range2, Within2, AnyOf2, Not2]),
|
2716
|
+
import_zod23.z.record(import_zod23.z.string(), QueryInput2)
|
2717
|
+
])
|
2718
|
+
);
|
2719
|
+
var QueryExpression = import_zod23.z.object({
|
2720
|
+
title: import_zod23.z.string(),
|
2721
|
+
eventType: import_zod23.z.string(),
|
2722
|
+
status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus2, ExactStatus2])),
|
2723
|
+
createdAt: import_zod23.z.optional(DateCondition2),
|
2724
|
+
updatedAt: import_zod23.z.optional(DateCondition2),
|
2725
|
+
createdAtLocation: import_zod23.z.optional(import_zod23.z.union([Within2, Exact2])),
|
2726
|
+
updatedAtLocation: import_zod23.z.optional(import_zod23.z.union([Within2, Exact2])),
|
2727
|
+
assignedTo: import_zod23.z.optional(Exact2),
|
2728
|
+
createdBy: import_zod23.z.optional(Exact2),
|
2729
|
+
updatedBy: import_zod23.z.optional(Exact2),
|
2730
|
+
trackingId: import_zod23.z.optional(Exact2),
|
2731
|
+
flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf2, Not2]))),
|
2732
|
+
data: QueryInput2
|
2733
|
+
}).partial();
|
2734
|
+
var Or3 = import_zod23.z.object({
|
2735
|
+
type: import_zod23.z.literal("or"),
|
2736
|
+
clauses: import_zod23.z.array(QueryExpression)
|
2737
|
+
});
|
2738
|
+
var And3 = import_zod23.z.object({
|
2739
|
+
type: import_zod23.z.literal("and"),
|
2740
|
+
clauses: import_zod23.z.array(QueryExpression)
|
2741
|
+
});
|
2742
|
+
var QueryType = import_zod23.z.discriminatedUnion("type", [Or3, And3]);
|
2743
|
+
|
2744
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
2745
|
+
var defaultThirdColumn = defineWorkqueueColumns([
|
2746
|
+
{
|
2747
|
+
label: {
|
2748
|
+
id: "workqueues.dateOfEvent",
|
2749
|
+
defaultMessage: "Date of Event",
|
2750
|
+
description: "Label for workqueue column: dateOfEvent"
|
2751
|
+
},
|
2752
|
+
value: event.field("dateOfEvent")
|
2753
|
+
}
|
2754
|
+
]);
|
2755
|
+
var WorkqueueConfig = import_zod24.z.object({
|
2756
|
+
slug: import_zod24.z.string().describe("Determines the url of the workqueue."),
|
2757
|
+
name: TranslationConfig.describe(
|
2758
|
+
"Title of the workflow (both in navigation and on the page)"
|
2759
|
+
),
|
2760
|
+
query: CountryConfigQueryType,
|
2761
|
+
actions: import_zod24.z.array(
|
2762
|
+
import_zod24.z.object({
|
2763
|
+
type: import_zod24.z.string(),
|
2764
|
+
conditionals: import_zod24.z.array(Conditional).optional()
|
2765
|
+
})
|
2766
|
+
),
|
2767
|
+
columns: import_zod24.z.array(WorkqueueColumn).default(defaultThirdColumn),
|
2768
|
+
icon: AvailableIcons
|
2769
|
+
}).describe("Configuration for workqueue.");
|
2770
|
+
function defineWorkqueue(workqueues) {
|
2771
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
2772
|
+
}
|
2773
|
+
var WorkqueueCountInput = import_zod24.z.array(
|
2774
|
+
import_zod24.z.object({ slug: import_zod24.z.string(), query: QueryType })
|
2775
|
+
);
|
2776
|
+
var WorkqueueCountOutput = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.number());
|
2777
|
+
|
2778
|
+
// ../commons/src/events/workqueueDefaultColumns.ts
|
2779
|
+
var defaultWorkqueueColumns = [
|
2780
|
+
{
|
2781
|
+
label: {
|
2782
|
+
defaultMessage: "Title",
|
2783
|
+
description: "This is the label for the workqueue column",
|
2784
|
+
id: "workqueue.in-reveiw.column.title"
|
2785
|
+
},
|
2786
|
+
value: event.field("title")
|
2787
|
+
},
|
2788
|
+
{
|
2789
|
+
label: {
|
2790
|
+
defaultMessage: "Event",
|
2791
|
+
description: "This is the label for the workqueue column",
|
2792
|
+
id: "workqueue.default.column.event"
|
2793
|
+
},
|
2794
|
+
value: event.field("type")
|
2795
|
+
},
|
2796
|
+
{
|
2797
|
+
label: {
|
2798
|
+
defaultMessage: "Last updated",
|
2799
|
+
description: "This is the label for the workqueue column",
|
2800
|
+
id: "workqueue.default.column.modifiedAt"
|
2801
|
+
},
|
2802
|
+
value: event.field("updatedAt")
|
2803
|
+
}
|
2804
|
+
];
|
2805
|
+
|
2806
|
+
// ../commons/src/events/Draft.ts
|
2807
|
+
var import_zod26 = require("zod");
|
2808
|
+
|
2809
|
+
// ../commons/src/events/ActionInput.ts
|
2810
|
+
var import_zod25 = require("zod");
|
2811
|
+
var import_zod_openapi5 = require("zod-openapi");
|
2812
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod25.z);
|
2813
|
+
var BaseActionInput = import_zod25.z.object({
|
2814
|
+
eventId: import_zod25.z.string(),
|
2815
|
+
transactionId: import_zod25.z.string(),
|
2816
|
+
declaration: ActionUpdate.default({}),
|
2817
|
+
annotation: ActionUpdate.optional(),
|
2818
|
+
originalActionId: import_zod25.z.string().optional(),
|
2819
|
+
keepAssignment: import_zod25.z.boolean().optional()
|
2820
|
+
});
|
2821
|
+
var CreateActionInput = BaseActionInput.merge(
|
2822
|
+
import_zod25.z.object({
|
2823
|
+
type: import_zod25.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2824
|
+
createdAtLocation: import_zod25.z.string()
|
2825
|
+
})
|
2826
|
+
);
|
2827
|
+
var RegisterActionInput = BaseActionInput.merge(
|
2828
|
+
import_zod25.z.object({
|
2829
|
+
type: import_zod25.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2830
|
+
registrationNumber: import_zod25.z.string().optional()
|
2831
|
+
})
|
2832
|
+
);
|
2833
|
+
var ValidateActionInput = BaseActionInput.merge(
|
2834
|
+
import_zod25.z.object({
|
2835
|
+
type: import_zod25.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2836
|
+
duplicates: import_zod25.z.array(import_zod25.z.string())
|
2837
|
+
})
|
2838
|
+
);
|
2839
|
+
var NotifyActionInput = BaseActionInput.merge(
|
2840
|
+
import_zod25.z.object({
|
2841
|
+
type: import_zod25.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2842
|
+
})
|
2843
|
+
);
|
2844
|
+
var DeclareActionInput = BaseActionInput.merge(
|
2845
|
+
import_zod25.z.object({
|
2846
|
+
type: import_zod25.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2847
|
+
})
|
2848
|
+
);
|
2849
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
2850
|
+
import_zod25.z.object({
|
2851
|
+
type: import_zod25.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2852
|
+
})
|
2853
|
+
);
|
2854
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2855
|
+
import_zod25.z.object({
|
2856
|
+
type: import_zod25.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2857
|
+
})
|
2858
|
+
);
|
2859
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2860
|
+
import_zod25.z.object({
|
2861
|
+
type: import_zod25.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2862
|
+
})
|
2863
|
+
);
|
2864
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2865
|
+
import_zod25.z.object({
|
2866
|
+
type: import_zod25.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2867
|
+
})
|
2868
|
+
);
|
2869
|
+
var AssignActionInput = BaseActionInput.merge(
|
2870
|
+
import_zod25.z.object({
|
2871
|
+
type: import_zod25.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2872
|
+
assignedTo: import_zod25.z.string()
|
2873
|
+
})
|
2874
|
+
);
|
2875
|
+
var UnassignActionInput = BaseActionInput.merge(
|
2876
|
+
import_zod25.z.object({
|
2877
|
+
type: import_zod25.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2878
|
+
assignedTo: import_zod25.z.literal(null).default(null)
|
2879
|
+
})
|
2880
|
+
);
|
2881
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2882
|
+
import_zod25.z.object({
|
2883
|
+
type: import_zod25.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2884
|
+
})
|
2885
|
+
);
|
2886
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2887
|
+
import_zod25.z.object({
|
2888
|
+
requestId: import_zod25.z.string(),
|
2889
|
+
type: import_zod25.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2890
|
+
})
|
2891
|
+
);
|
2892
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2893
|
+
import_zod25.z.object({
|
2894
|
+
requestId: import_zod25.z.string(),
|
2895
|
+
type: import_zod25.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2896
|
+
})
|
2897
|
+
);
|
2898
|
+
var ReadActionInput = BaseActionInput.merge(
|
2899
|
+
import_zod25.z.object({
|
2900
|
+
type: import_zod25.z.literal(ActionType.READ).default(ActionType.READ)
|
2901
|
+
})
|
2902
|
+
);
|
2903
|
+
var DeleteActionInput = import_zod25.z.object({ eventId: import_zod25.z.string() });
|
2904
|
+
var ActionInput = import_zod25.z.discriminatedUnion("type", [
|
2905
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2906
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2907
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2908
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2909
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2910
|
+
RejectDeclarationActionInput.openapi({
|
2911
|
+
ref: "RejectDeclarationActionInput"
|
2912
|
+
}),
|
2913
|
+
MarkedAsDuplicateActionInput.openapi({
|
2914
|
+
ref: "MarkedAsDuplicateActionInput"
|
2915
|
+
}),
|
2916
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2917
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2918
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2919
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2920
|
+
RequestCorrectionActionInput.openapi({
|
2921
|
+
ref: "RequestCorrectionActionInput"
|
2922
|
+
}),
|
2923
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2924
|
+
ApproveCorrectionActionInput.openapi({
|
2925
|
+
ref: "ApproveCorrectionActionInput"
|
2926
|
+
}),
|
2927
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2928
|
+
]).openapi({
|
2929
|
+
ref: "ActionInput"
|
2930
|
+
});
|
2931
|
+
|
2932
|
+
// ../commons/src/events/Draft.ts
|
2933
|
+
var Draft = import_zod26.z.object({
|
2934
|
+
id: import_zod26.z.string(),
|
2935
|
+
eventId: import_zod26.z.string(),
|
2936
|
+
transactionId: import_zod26.z.string(),
|
2937
|
+
createdAt: import_zod26.z.string().datetime(),
|
2938
|
+
action: ActionBase.extend({
|
2939
|
+
type: ActionTypes
|
2940
|
+
}).omit({ id: true })
|
2941
|
+
});
|
2942
|
+
var DraftInput = BaseActionInput.extend({
|
2943
|
+
type: ActionTypes,
|
2944
|
+
status: import_zod26.z.enum([
|
2945
|
+
ActionStatus.Requested,
|
2946
|
+
ActionStatus.Accepted,
|
2947
|
+
ActionStatus.Rejected
|
2948
|
+
])
|
2949
|
+
});
|
2950
|
+
|
2951
|
+
// ../commons/src/events/EventInput.ts
|
2952
|
+
var import_zod27 = require("zod");
|
2953
|
+
var EventInput = import_zod27.z.object({
|
2954
|
+
transactionId: import_zod27.z.string(),
|
2955
|
+
type: import_zod27.z.string(),
|
2956
|
+
dateOfEvent: import_zod27.z.object({ fieldId: import_zod27.z.string() }).optional()
|
2957
|
+
});
|
2958
|
+
|
2959
|
+
// ../commons/src/events/EventDocument.ts
|
2960
|
+
var import_zod28 = require("zod");
|
2961
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2962
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod28.z);
|
2963
|
+
var EventDocument = import_zod28.z.object({
|
2964
|
+
id: import_zod28.z.string(),
|
2965
|
+
type: import_zod28.z.string(),
|
2966
|
+
dateOfEvent: import_zod28.z.object({ fieldId: import_zod28.z.string() }).optional(),
|
2967
|
+
createdAt: import_zod28.z.string().datetime(),
|
2968
|
+
updatedAt: import_zod28.z.string().datetime(),
|
2969
|
+
actions: import_zod28.z.array(Action),
|
2970
|
+
trackingId: import_zod28.z.string()
|
2971
|
+
}).openapi({ ref: "EventDocument" });
|
2972
|
+
|
2973
|
+
// ../commons/src/events/state/utils.ts
|
2974
|
+
function getActionRequests(actionType, actions) {
|
2975
|
+
const filtered = actions.filter((action) => action.type === actionType);
|
2976
|
+
const accept = filtered.find(
|
2977
|
+
(action) => action.status === ActionStatus.Accepted
|
2978
|
+
);
|
2979
|
+
const request = filtered.find(
|
2980
|
+
(action) => action.status === ActionStatus.Requested
|
2981
|
+
);
|
2982
|
+
const reject = filtered.find(
|
2983
|
+
(action) => action.status === ActionStatus.Rejected
|
2984
|
+
);
|
2985
|
+
return {
|
2986
|
+
reject,
|
2987
|
+
accept,
|
2988
|
+
request
|
2989
|
+
};
|
2990
|
+
}
|
2991
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
2992
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
2993
|
+
actionType,
|
2994
|
+
actions
|
2995
|
+
);
|
2996
|
+
if (!acceptAction) {
|
2997
|
+
return null;
|
2998
|
+
}
|
2999
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
3000
|
+
return {
|
3001
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
3002
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
3003
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
3004
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
3005
|
+
acceptedAt: acceptAction.createdAt,
|
3006
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
3007
|
+
registrationNumber
|
3008
|
+
};
|
3009
|
+
}
|
3010
|
+
function getDeclarationActionUpdateMetadata(actions) {
|
3011
|
+
const createAction = getOrThrow(
|
3012
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
3013
|
+
`Event has no ${ActionType.CREATE} action`
|
3014
|
+
);
|
3015
|
+
return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
|
3016
|
+
(metadata, actionType) => {
|
3017
|
+
const { accept, request } = getActionRequests(actionType, actions);
|
3018
|
+
return {
|
3019
|
+
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
3020
|
+
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
3021
|
+
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
3022
|
+
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
3023
|
+
};
|
3024
|
+
},
|
3025
|
+
{
|
3026
|
+
createdAt: createAction.createdAt,
|
3027
|
+
createdBy: createAction.createdBy,
|
3028
|
+
createdAtLocation: createAction.createdAtLocation,
|
3029
|
+
createdByRole: createAction.createdByRole
|
3030
|
+
}
|
3031
|
+
);
|
3032
|
+
}
|
3033
|
+
function getLegalStatuses(actions) {
|
3034
|
+
return {
|
3035
|
+
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
3036
|
+
ActionType.DECLARE,
|
3037
|
+
actions
|
3038
|
+
),
|
3039
|
+
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
3040
|
+
ActionType.REGISTER,
|
3041
|
+
actions
|
3042
|
+
)
|
3043
|
+
};
|
3044
|
+
}
|
3045
|
+
|
3046
|
+
// ../commons/src/events/state/index.ts
|
3047
|
+
function getStatusFromActions(actions) {
|
3048
|
+
const hasRejectedAction = actions.some(
|
3049
|
+
(a) => a.status === ActionStatus.Rejected
|
3050
|
+
);
|
3051
|
+
if (hasRejectedAction) {
|
3052
|
+
return EventStatus.REJECTED;
|
3053
|
+
}
|
3054
|
+
return actions.reduce((status, action) => {
|
3055
|
+
switch (action.type) {
|
3056
|
+
case ActionType.CREATE:
|
3057
|
+
return EventStatus.CREATED;
|
3058
|
+
case ActionType.DECLARE:
|
3059
|
+
return EventStatus.DECLARED;
|
3060
|
+
case ActionType.VALIDATE:
|
3061
|
+
return EventStatus.VALIDATED;
|
3062
|
+
case ActionType.REGISTER:
|
3063
|
+
return EventStatus.REGISTERED;
|
3064
|
+
case ActionType.REJECT:
|
3065
|
+
return EventStatus.REJECTED;
|
3066
|
+
case ActionType.ARCHIVE:
|
3067
|
+
return EventStatus.ARCHIVED;
|
3068
|
+
case ActionType.NOTIFY:
|
3069
|
+
return EventStatus.NOTIFIED;
|
3070
|
+
case ActionType.PRINT_CERTIFICATE:
|
3071
|
+
return EventStatus.CERTIFIED;
|
3072
|
+
case ActionType.ASSIGN:
|
3073
|
+
case ActionType.UNASSIGN:
|
3074
|
+
case ActionType.REQUEST_CORRECTION:
|
3075
|
+
case ActionType.APPROVE_CORRECTION:
|
3076
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
3077
|
+
case ActionType.REJECT_CORRECTION:
|
3078
|
+
case ActionType.READ:
|
3079
|
+
default:
|
3080
|
+
return status;
|
3081
|
+
}
|
3082
|
+
}, EventStatus.CREATED);
|
3083
|
+
}
|
3084
|
+
function getFlagsFromActions(actions) {
|
3085
|
+
const sortedactions = actions.sort(
|
3086
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
3087
|
+
);
|
3088
|
+
const actionStatus = sortedactions.reduce(
|
3089
|
+
(actionStatuses, { type, status }) => ({
|
3090
|
+
...actionStatuses,
|
3091
|
+
[type]: status
|
3092
|
+
}),
|
3093
|
+
{}
|
3094
|
+
);
|
3095
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
3096
|
+
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
3097
|
+
return flag;
|
3098
|
+
});
|
3099
|
+
const isCertificatePrinted = sortedactions.reduce(
|
3100
|
+
(prev, { type }) => {
|
3101
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
3102
|
+
return true;
|
3103
|
+
}
|
3104
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
3105
|
+
return false;
|
3106
|
+
}
|
3107
|
+
return prev;
|
3108
|
+
},
|
3109
|
+
false
|
3110
|
+
);
|
3111
|
+
if (isCertificatePrinted) {
|
3112
|
+
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
3113
|
+
}
|
3114
|
+
return flags;
|
3115
|
+
}
|
3116
|
+
function getAssignedUserFromActions(actions) {
|
3117
|
+
return actions.reduce((user2, action) => {
|
3118
|
+
if (action.type === ActionType.ASSIGN) {
|
3119
|
+
return action.assignedTo;
|
3120
|
+
}
|
3121
|
+
if (action.type === ActionType.UNASSIGN) {
|
3122
|
+
return null;
|
3123
|
+
}
|
3124
|
+
return user2;
|
3125
|
+
}, null);
|
3126
|
+
}
|
3127
|
+
function aggregateActionDeclarations(actions) {
|
3128
|
+
const excludedActions = [
|
3129
|
+
ActionType.REQUEST_CORRECTION,
|
3130
|
+
ActionType.PRINT_CERTIFICATE
|
3131
|
+
];
|
3132
|
+
return actions.reduce((status, action) => {
|
3133
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
3134
|
+
return status;
|
3135
|
+
}
|
3136
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
3137
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
3138
|
+
if (!requestAction) {
|
3139
|
+
return status;
|
3140
|
+
}
|
3141
|
+
return deepMerge(status, requestAction.declaration);
|
3142
|
+
}
|
3143
|
+
return deepMerge(status, action.declaration);
|
3144
|
+
}, {});
|
3145
|
+
}
|
3146
|
+
function deepDropNulls(obj) {
|
3147
|
+
if (Array.isArray(obj)) {
|
3148
|
+
return obj.map(deepDropNulls);
|
3149
|
+
}
|
3150
|
+
if (obj !== null && typeof obj === "object") {
|
3151
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
3152
|
+
const cleanedValue = deepDropNulls(value);
|
3153
|
+
if (cleanedValue !== null) {
|
3154
|
+
;
|
3155
|
+
acc[key] = cleanedValue;
|
3156
|
+
}
|
3157
|
+
return acc;
|
3158
|
+
}, {});
|
3159
|
+
}
|
3160
|
+
return obj;
|
3161
|
+
}
|
3162
|
+
function isUndeclaredDraft(status) {
|
3163
|
+
return status === EventStatus.CREATED;
|
3164
|
+
}
|
3165
|
+
function getAcceptedActions(event2) {
|
3166
|
+
return event2.actions.filter(
|
3167
|
+
(a) => a.status === ActionStatus.Accepted
|
3168
|
+
);
|
3169
|
+
}
|
3170
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
3171
|
+
function getCurrentEventState(event2) {
|
3172
|
+
const creationAction = event2.actions.find(
|
3173
|
+
(action) => action.type === ActionType.CREATE
|
3174
|
+
);
|
3175
|
+
if (!creationAction) {
|
3176
|
+
throw new Error(`Event ${event2.id} has no creation action`);
|
3177
|
+
}
|
3178
|
+
const acceptedActions = getAcceptedActions(event2);
|
3179
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
3180
|
+
event2.actions
|
3181
|
+
);
|
3182
|
+
const declaration = aggregateActionDeclarations(acceptedActions);
|
3183
|
+
let dateOfEvent;
|
3184
|
+
if (event2.dateOfEvent) {
|
3185
|
+
const parsedDate = ZodDate.safeParse(declaration[event2.dateOfEvent.fieldId]);
|
3186
|
+
if (parsedDate.success) {
|
3187
|
+
dateOfEvent = parsedDate.data;
|
3188
|
+
}
|
3189
|
+
} else {
|
3190
|
+
dateOfEvent = event2[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
|
3191
|
+
}
|
3192
|
+
return deepDropNulls({
|
3193
|
+
id: event2.id,
|
3194
|
+
type: event2.type,
|
3195
|
+
title: "ToDo",
|
3196
|
+
status: getStatusFromActions(event2.actions),
|
3197
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
3198
|
+
createdAt: creationAction.createdAt,
|
3199
|
+
createdBy: creationAction.createdBy,
|
3200
|
+
createdAtLocation: creationAction.createdAtLocation,
|
3201
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
3202
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
3203
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
3204
|
+
updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
|
3205
|
+
declaration,
|
3206
|
+
trackingId: event2.trackingId,
|
3207
|
+
// @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
|
3208
|
+
updatedByUserRole: declarationUpdateMetadata.createdByRole,
|
3209
|
+
dateOfEvent,
|
3210
|
+
flags: getFlagsFromActions(event2.actions)
|
3211
|
+
});
|
3212
|
+
}
|
3213
|
+
function getCurrentEventStateWithDrafts(event2, drafts) {
|
3214
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
3215
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
3216
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
3217
|
+
return [
|
3218
|
+
action,
|
3219
|
+
{
|
3220
|
+
...action,
|
3221
|
+
type: ActionType.APPROVE_CORRECTION
|
2735
3222
|
}
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
3223
|
+
];
|
3224
|
+
}
|
3225
|
+
return [action];
|
3226
|
+
});
|
3227
|
+
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
3228
|
+
const withDrafts = {
|
3229
|
+
...event2,
|
3230
|
+
actions: actionWithDrafts
|
3231
|
+
};
|
3232
|
+
return getCurrentEventState(withDrafts);
|
3233
|
+
}
|
3234
|
+
function applyDraftsToEventIndex(eventIndex, drafts) {
|
3235
|
+
const indexedAt = eventIndex.updatedAt;
|
3236
|
+
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
3237
|
+
if (activeDrafts.length === 0) {
|
3238
|
+
return eventIndex;
|
3239
|
+
}
|
3240
|
+
return {
|
3241
|
+
...eventIndex,
|
3242
|
+
declaration: {
|
3243
|
+
...eventIndex.declaration,
|
3244
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
3245
|
+
}
|
3246
|
+
};
|
3247
|
+
}
|
3248
|
+
function getAnnotationFromDrafts(drafts) {
|
3249
|
+
const actions = drafts.map((draft) => draft.action);
|
3250
|
+
const annotation = actions.reduce((ann, action) => {
|
3251
|
+
return deepMerge(ann, action.annotation ?? {});
|
3252
|
+
}, {});
|
3253
|
+
return deepDropNulls(annotation);
|
3254
|
+
}
|
3255
|
+
function getActionAnnotation({
|
3256
|
+
event: event2,
|
3257
|
+
actionType,
|
3258
|
+
drafts = []
|
3259
|
+
}) {
|
3260
|
+
const activeActions = getAcceptedActions(event2);
|
3261
|
+
const action = activeActions.find(
|
3262
|
+
(activeAction) => actionType === activeAction.type
|
3263
|
+
);
|
3264
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
3265
|
+
const sorted = [
|
3266
|
+
...action ? [action] : [],
|
3267
|
+
...eventDrafts.map((draft) => draft.action)
|
3268
|
+
].sort();
|
3269
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
3270
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
3271
|
+
}, {});
|
3272
|
+
return deepDropNulls(annotation);
|
3273
|
+
}
|
3274
|
+
|
3275
|
+
// ../commons/src/events/defineConfig.ts
|
3276
|
+
var defineConfig = (config) => {
|
3277
|
+
const input = EventConfig.parse(config);
|
3278
|
+
return input;
|
3279
|
+
};
|
3280
|
+
|
3281
|
+
// ../commons/src/events/transactions.ts
|
3282
|
+
function generateTransactionId() {
|
3283
|
+
return getUUID();
|
3284
|
+
}
|
3285
|
+
|
3286
|
+
// ../commons/src/events/User.ts
|
3287
|
+
var import_zod29 = require("zod");
|
3288
|
+
var User = import_zod29.z.object({
|
3289
|
+
id: import_zod29.z.string(),
|
3290
|
+
name: import_zod29.z.array(
|
3291
|
+
import_zod29.z.object({
|
3292
|
+
use: import_zod29.z.string(),
|
3293
|
+
given: import_zod29.z.array(import_zod29.z.string()),
|
3294
|
+
family: import_zod29.z.string()
|
3295
|
+
})
|
3296
|
+
),
|
3297
|
+
role: import_zod29.z.string(),
|
3298
|
+
signatureFilename: import_zod29.z.string().optional()
|
3299
|
+
});
|
3300
|
+
|
3301
|
+
// ../commons/src/events/test.utils.ts
|
3302
|
+
var import_lodash2 = require("lodash");
|
3303
|
+
|
3304
|
+
// ../commons/src/field-config/field-configuration.ts
|
3305
|
+
function createFieldConfigs(fieldId) {
|
3306
|
+
const baseField = {
|
3307
|
+
fieldId,
|
3308
|
+
fieldType: "field"
|
3309
|
+
};
|
3310
|
+
return {
|
2739
3311
|
/**
|
2740
3312
|
* Creates a range configuration for the specified field.
|
2741
3313
|
*
|
2742
|
-
* @returns An object containing the field ID and a configuration object with a type of '
|
3314
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2743
3315
|
*
|
2744
3316
|
* @example field('age').range()
|
2745
3317
|
* // {
|
2746
3318
|
* // fieldId: 'age',
|
2747
|
-
* // config: { type: '
|
3319
|
+
* // config: { type: 'range' }
|
2748
3320
|
* // }
|
2749
3321
|
*/
|
2750
3322
|
range: () => ({
|
2751
|
-
|
2752
|
-
config: { type: "
|
3323
|
+
...baseField,
|
3324
|
+
config: { type: "range" }
|
2753
3325
|
}),
|
2754
3326
|
/**
|
2755
3327
|
* 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 '
|
3328
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2757
3329
|
* @example field('dob').exact()
|
2758
3330
|
* // {
|
2759
3331
|
* // fieldId: 'dob',
|
2760
|
-
* // config: { type: '
|
3332
|
+
* // config: { type: 'exact' }
|
2761
3333
|
* // }
|
2762
3334
|
*/
|
2763
3335
|
exact: () => ({
|
2764
|
-
|
2765
|
-
config: { type: "
|
3336
|
+
...baseField,
|
3337
|
+
config: { type: "exact" }
|
2766
3338
|
}),
|
2767
3339
|
/**
|
2768
3340
|
* 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 '
|
3341
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
2770
3342
|
* @example field('name').fuzzy()
|
2771
3343
|
* // {
|
2772
3344
|
* // fieldId: 'name',
|
2773
|
-
* // config: { type: '
|
3345
|
+
* // config: { type: 'fuzzy' }
|
2774
3346
|
* // }
|
2775
3347
|
*/
|
2776
3348
|
fuzzy: () => ({
|
2777
|
-
|
2778
|
-
config: { type: "
|
3349
|
+
...baseField,
|
3350
|
+
config: { type: "fuzzy" }
|
2779
3351
|
})
|
2780
3352
|
};
|
2781
3353
|
}
|
2782
|
-
|
3354
|
+
|
3355
|
+
// ../commons/src/events/field.ts
|
3356
|
+
function field(fieldId) {
|
2783
3357
|
return {
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
3358
|
+
/**
|
3359
|
+
* @private Internal property used for field reference tracking.
|
3360
|
+
*/
|
3361
|
+
_fieldId: fieldId,
|
3362
|
+
...createFieldConditionals(fieldId),
|
3363
|
+
...createFieldConfigs(fieldId)
|
2787
3364
|
};
|
2788
3365
|
}
|
2789
3366
|
|
@@ -3703,20 +4280,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3703
4280
|
description: "This is what this event is referred as in the system",
|
3704
4281
|
id: "event.tennis-club-membership.label"
|
3705
4282
|
},
|
4283
|
+
title: {
|
4284
|
+
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
4285
|
+
description: "This is the title of the summary",
|
4286
|
+
id: "v2.event.tennis-club-membership.title"
|
4287
|
+
},
|
3706
4288
|
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
4289
|
fields: [
|
3721
4290
|
{
|
3722
4291
|
id: "applicant.firstname",
|
@@ -3737,47 +4306,18 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3737
4306
|
}
|
3738
4307
|
},
|
3739
4308
|
{
|
3740
|
-
|
4309
|
+
fieldId: "applicant.surname",
|
3741
4310
|
label: {
|
3742
4311
|
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"
|
4312
|
+
description: "Label for surname",
|
4313
|
+
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
3755
4314
|
}
|
4315
|
+
},
|
4316
|
+
{
|
4317
|
+
fieldId: "applicant.email"
|
3756
4318
|
}
|
3757
4319
|
]
|
3758
4320
|
},
|
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
4321
|
actions: [
|
3782
4322
|
{
|
3783
4323
|
type: ActionType.DECLARE,
|
@@ -4090,6 +4630,22 @@ var tennisClubMembershipEvent = defineConfig({
|
|
4090
4630
|
],
|
4091
4631
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
4092
4632
|
});
|
4633
|
+
var WorkqueueFixture = defineWorkqueue([
|
4634
|
+
{
|
4635
|
+
slug: "in-progress",
|
4636
|
+
name: {
|
4637
|
+
id: "workqueues.inProgress.title",
|
4638
|
+
defaultMessage: "In progress",
|
4639
|
+
description: "Title of in progress workqueue"
|
4640
|
+
},
|
4641
|
+
query: {
|
4642
|
+
type: "and",
|
4643
|
+
clauses: [{ eventType: tennisClubMembershipEvent.id }]
|
4644
|
+
},
|
4645
|
+
actions: [],
|
4646
|
+
icon: "Draft"
|
4647
|
+
}
|
4648
|
+
]);
|
4093
4649
|
|
4094
4650
|
// ../commons/src/events/test.utils.ts
|
4095
4651
|
function fieldConfigsToActionPayload(fields) {
|
@@ -4118,10 +4674,10 @@ function generateActionAnnotationInput(configuration, action) {
|
|
4118
4674
|
);
|
4119
4675
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4120
4676
|
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4121
|
-
const visibleVerificationPageIds =
|
4122
|
-
configuration,
|
4123
|
-
|
4124
|
-
)
|
4677
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4678
|
+
findRecordActionPages(configuration, action),
|
4679
|
+
annotation
|
4680
|
+
);
|
4125
4681
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
4126
4682
|
(acc, pageId) => ({
|
4127
4683
|
...acc,
|
@@ -4145,13 +4701,14 @@ var eventPayloadGenerator = {
|
|
4145
4701
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4146
4702
|
id
|
4147
4703
|
}),
|
4148
|
-
draft: ({ eventId, actionType }, input = {}) => (0,
|
4704
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
4149
4705
|
{
|
4150
4706
|
id: getUUID(),
|
4151
4707
|
eventId,
|
4152
4708
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4153
4709
|
transactionId: getUUID(),
|
4154
4710
|
action: {
|
4711
|
+
transactionId: getUUID(),
|
4155
4712
|
type: actionType,
|
4156
4713
|
status: ActionStatus.Accepted,
|
4157
4714
|
declaration: {
|
@@ -4166,8 +4723,8 @@ var eventPayloadGenerator = {
|
|
4166
4723
|
},
|
4167
4724
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4168
4725
|
createdBy: "@todo",
|
4169
|
-
|
4170
|
-
|
4726
|
+
createdByRole: "@todo",
|
4727
|
+
createdAtLocation: "@todo"
|
4171
4728
|
}
|
4172
4729
|
},
|
4173
4730
|
input
|
@@ -4192,12 +4749,12 @@ var eventPayloadGenerator = {
|
|
4192
4749
|
notify: (eventId, input = {}) => {
|
4193
4750
|
let declaration = input.declaration;
|
4194
4751
|
if (!declaration) {
|
4195
|
-
const partialDeclaration = (0,
|
4752
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4196
4753
|
generateActionDeclarationInput(
|
4197
4754
|
tennisClubMembershipEvent,
|
4198
4755
|
ActionType.DECLARE
|
4199
4756
|
),
|
4200
|
-
|
4757
|
+
import_lodash2.isString
|
4201
4758
|
);
|
4202
4759
|
declaration = partialDeclaration;
|
4203
4760
|
}
|
@@ -4328,13 +4885,14 @@ function generateActionDocument({
|
|
4328
4885
|
// @TODO: This should be fixed in the future.
|
4329
4886
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4330
4887
|
createdBy: getUUID(),
|
4888
|
+
createdByRole: "FIELD_AGENT",
|
4331
4889
|
id: getUUID(),
|
4332
|
-
createdAtLocation: "
|
4333
|
-
updatedAtLocation: "TODO",
|
4890
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4334
4891
|
declaration: generateActionDeclarationInput(configuration, action),
|
4335
4892
|
annotation: {},
|
4336
|
-
|
4337
|
-
|
4893
|
+
status: ActionStatus.Accepted,
|
4894
|
+
transactionId: getUUID(),
|
4895
|
+
...defaults
|
4338
4896
|
};
|
4339
4897
|
switch (action) {
|
4340
4898
|
case ActionType.READ:
|
@@ -4392,7 +4950,8 @@ function generateEventDocument({
|
|
4392
4950
|
id: getUUID(),
|
4393
4951
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4394
4952
|
// @TODO: This should be fixed in the future.
|
4395
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4953
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4954
|
+
dateOfEvent: configuration.dateOfEvent
|
4396
4955
|
};
|
4397
4956
|
}
|
4398
4957
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4414,10 +4973,65 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4414
4973
|
eventId
|
4415
4974
|
};
|
4416
4975
|
}
|
4976
|
+
function getEventStatus() {
|
4977
|
+
const statuses = [
|
4978
|
+
EventStatus.CREATED,
|
4979
|
+
EventStatus.REGISTERED,
|
4980
|
+
EventStatus.DECLARED
|
4981
|
+
];
|
4982
|
+
const randomIndex = Math.floor(Math.random() * 3);
|
4983
|
+
return statuses[randomIndex];
|
4984
|
+
}
|
4985
|
+
function getTrackingId() {
|
4986
|
+
const uuid = getUUID().replace(/-/g, "");
|
4987
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4988
|
+
return trackingId;
|
4989
|
+
}
|
4990
|
+
function getRandomApplicant() {
|
4991
|
+
const firstNames = [
|
4992
|
+
"Danny",
|
4993
|
+
"John",
|
4994
|
+
"Jane",
|
4995
|
+
"Emily",
|
4996
|
+
"Michael",
|
4997
|
+
"Sarah",
|
4998
|
+
"Chris",
|
4999
|
+
"Jessica"
|
5000
|
+
];
|
5001
|
+
const surnames = [
|
5002
|
+
"Doe",
|
5003
|
+
"Smith",
|
5004
|
+
"Johnson",
|
5005
|
+
"Brown",
|
5006
|
+
"Williams",
|
5007
|
+
"Jones",
|
5008
|
+
"Garcia",
|
5009
|
+
"Miller"
|
5010
|
+
];
|
5011
|
+
function getRandomDate(start, end) {
|
5012
|
+
const randomDate = new Date(
|
5013
|
+
start.getTime() + Math.random() * (end.getTime() - start.getTime())
|
5014
|
+
);
|
5015
|
+
return randomDate.toISOString().split("T")[0];
|
5016
|
+
}
|
5017
|
+
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
5018
|
+
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
|
5019
|
+
const randomDob = getRandomDate(
|
5020
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
5021
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
5022
|
+
);
|
5023
|
+
return {
|
5024
|
+
"recommender.none": true,
|
5025
|
+
"applicant.firstname": randomFirstName,
|
5026
|
+
"applicant.surname": randomSurname,
|
5027
|
+
"applicant.dob": randomDob
|
5028
|
+
};
|
5029
|
+
}
|
4417
5030
|
var eventQueryDataGenerator = (overrides = {}) => ({
|
4418
5031
|
id: overrides.id ?? getUUID(),
|
4419
|
-
|
4420
|
-
|
5032
|
+
title: overrides.title ?? "Danny Doe",
|
5033
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
5034
|
+
status: overrides.status ?? getEventStatus(),
|
4421
5035
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4422
5036
|
createdBy: overrides.createdBy ?? getUUID(),
|
4423
5037
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
@@ -4425,13 +5039,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4425
5039
|
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4426
5040
|
assignedTo: overrides.assignedTo ?? null,
|
4427
5041
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
},
|
4434
|
-
trackingId: overrides.trackingId ?? "M3F8YQ"
|
5042
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
5043
|
+
flags: [],
|
5044
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
5045
|
+
declaration: overrides.declaration ?? getRandomApplicant(),
|
5046
|
+
trackingId: overrides.trackingId ?? getTrackingId()
|
4435
5047
|
});
|
4436
5048
|
var generateTranslationConfig = (message) => ({
|
4437
5049
|
defaultMessage: message,
|
@@ -4470,3 +5082,363 @@ function isFieldConfigDefaultValue(value) {
|
|
4470
5082
|
}
|
4471
5083
|
return false;
|
4472
5084
|
}
|
5085
|
+
|
5086
|
+
// ../commons/src/events/scopes.ts
|
5087
|
+
var import_lodash3 = require("lodash");
|
5088
|
+
|
5089
|
+
// ../commons/src/scopes.ts
|
5090
|
+
var import_zod30 = require("zod");
|
5091
|
+
var SCOPES = {
|
5092
|
+
// TODO v1.8 legacy scopes
|
5093
|
+
NATLSYSADMIN: "natlsysadmin",
|
5094
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
5095
|
+
DECLARE: "declare",
|
5096
|
+
REGISTER: "register",
|
5097
|
+
VALIDATE: "validate",
|
5098
|
+
DEMO: "demo",
|
5099
|
+
CERTIFY: "certify",
|
5100
|
+
PERFORMANCE: "performance",
|
5101
|
+
SYSADMIN: "sysadmin",
|
5102
|
+
TEAMS: "teams",
|
5103
|
+
CONFIG: "config",
|
5104
|
+
// systems / integrations
|
5105
|
+
WEBHOOK: "webhook",
|
5106
|
+
NATIONALID: "nationalId",
|
5107
|
+
NOTIFICATION_API: "notification-api",
|
5108
|
+
RECORDSEARCH: "recordsearch",
|
5109
|
+
/**
|
5110
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
5111
|
+
*/
|
5112
|
+
RECORD_DECLARE: "record.declare-birth",
|
5113
|
+
// declare
|
5114
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
5115
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
5116
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
5117
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
5118
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
5119
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
5120
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
5121
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
5122
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
5123
|
+
// validate
|
5124
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
5125
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
5126
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
5127
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
5128
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
5129
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
5130
|
+
// register
|
5131
|
+
RECORD_REGISTER: "record.register",
|
5132
|
+
// certify
|
5133
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
5134
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
5135
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
5136
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
5137
|
+
// v1.8
|
5138
|
+
/**
|
5139
|
+
* This scope is used to **print and **issue certified copies of a record
|
5140
|
+
* after it has been registered. Previously Registrars had this permission.
|
5141
|
+
*/
|
5142
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
5143
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
5144
|
+
// v1.8
|
5145
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
5146
|
+
// v1.8
|
5147
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
5148
|
+
// v1.8
|
5149
|
+
// correct
|
5150
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
5151
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
5152
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
5153
|
+
// v1.8
|
5154
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
5155
|
+
// v1.8
|
5156
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
5157
|
+
// v1.8
|
5158
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
5159
|
+
// v1.8
|
5160
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
5161
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
5162
|
+
// search
|
5163
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
5164
|
+
SEARCH_BIRTH: "search.birth",
|
5165
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
5166
|
+
SEARCH_DEATH: "search.death",
|
5167
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
5168
|
+
SEARCH_MARRIAGE: "search.marriage",
|
5169
|
+
// audit v1.8
|
5170
|
+
RECORD_READ: "record.read",
|
5171
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
5172
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
5173
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
5174
|
+
// profile
|
5175
|
+
PROFILE_UPDATE: "profile.update",
|
5176
|
+
//v1.8
|
5177
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
5178
|
+
// performance
|
5179
|
+
PERFORMANCE_READ: "performance.read",
|
5180
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
5181
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
5182
|
+
// organisation
|
5183
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
5184
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
5185
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
5186
|
+
// user
|
5187
|
+
USER_READ: "user.read:all",
|
5188
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
5189
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
5190
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
5191
|
+
//v1.8
|
5192
|
+
USER_CREATE: "user.create:all",
|
5193
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
5194
|
+
USER_UPDATE: "user.update:all",
|
5195
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
5196
|
+
// config
|
5197
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
5198
|
+
// data seeding
|
5199
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
5200
|
+
};
|
5201
|
+
var LiteralScopes = import_zod30.z.union([
|
5202
|
+
import_zod30.z.literal(SCOPES.NATLSYSADMIN),
|
5203
|
+
import_zod30.z.literal(SCOPES.BYPASSRATELIMIT),
|
5204
|
+
import_zod30.z.literal(SCOPES.DECLARE),
|
5205
|
+
import_zod30.z.literal(SCOPES.REGISTER),
|
5206
|
+
import_zod30.z.literal(SCOPES.VALIDATE),
|
5207
|
+
import_zod30.z.literal(SCOPES.DEMO),
|
5208
|
+
import_zod30.z.literal(SCOPES.CERTIFY),
|
5209
|
+
import_zod30.z.literal(SCOPES.PERFORMANCE),
|
5210
|
+
import_zod30.z.literal(SCOPES.SYSADMIN),
|
5211
|
+
import_zod30.z.literal(SCOPES.TEAMS),
|
5212
|
+
import_zod30.z.literal(SCOPES.CONFIG),
|
5213
|
+
import_zod30.z.literal(SCOPES.WEBHOOK),
|
5214
|
+
import_zod30.z.literal(SCOPES.NATIONALID),
|
5215
|
+
import_zod30.z.literal(SCOPES.NOTIFICATION_API),
|
5216
|
+
import_zod30.z.literal(SCOPES.RECORDSEARCH),
|
5217
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
5218
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
5219
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
5220
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
5221
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
5222
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
5223
|
+
import_zod30.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
5224
|
+
import_zod30.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
5225
|
+
import_zod30.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
5226
|
+
import_zod30.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
5227
|
+
import_zod30.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
5228
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
5229
|
+
import_zod30.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
5230
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
5231
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
5232
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTER),
|
5233
|
+
import_zod30.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
5234
|
+
import_zod30.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
5235
|
+
import_zod30.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
5236
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
5237
|
+
import_zod30.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
5238
|
+
import_zod30.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
5239
|
+
import_zod30.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
5240
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
5241
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
5242
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
5243
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
5244
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
5245
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
5246
|
+
import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
5247
|
+
import_zod30.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
5248
|
+
import_zod30.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
5249
|
+
import_zod30.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
5250
|
+
import_zod30.z.literal(SCOPES.SEARCH_BIRTH),
|
5251
|
+
import_zod30.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
5252
|
+
import_zod30.z.literal(SCOPES.SEARCH_DEATH),
|
5253
|
+
import_zod30.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
5254
|
+
import_zod30.z.literal(SCOPES.SEARCH_MARRIAGE),
|
5255
|
+
import_zod30.z.literal(SCOPES.RECORD_READ),
|
5256
|
+
import_zod30.z.literal(SCOPES.RECORD_READ_AUDIT),
|
5257
|
+
import_zod30.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
5258
|
+
import_zod30.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
5259
|
+
import_zod30.z.literal(SCOPES.PROFILE_UPDATE),
|
5260
|
+
import_zod30.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
5261
|
+
import_zod30.z.literal(SCOPES.PERFORMANCE_READ),
|
5262
|
+
import_zod30.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
5263
|
+
import_zod30.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
5264
|
+
import_zod30.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
5265
|
+
import_zod30.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
5266
|
+
import_zod30.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
5267
|
+
import_zod30.z.literal(SCOPES.USER_READ),
|
5268
|
+
import_zod30.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
5269
|
+
import_zod30.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
5270
|
+
import_zod30.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
5271
|
+
import_zod30.z.literal(SCOPES.USER_CREATE),
|
5272
|
+
import_zod30.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
5273
|
+
import_zod30.z.literal(SCOPES.USER_UPDATE),
|
5274
|
+
import_zod30.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
5275
|
+
import_zod30.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
5276
|
+
import_zod30.z.literal(SCOPES.USER_DATA_SEEDING)
|
5277
|
+
]);
|
5278
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w-]+(?:\|[\w-]+)*)(:?,[\w-]+=[\w-]+(?:\|[\w-]+)*)*)\]$/;
|
5279
|
+
var rawConfigurableScope = import_zod30.z.string().regex(rawConfigurableScopeRegex);
|
5280
|
+
var CreateUserScope = import_zod30.z.object({
|
5281
|
+
type: import_zod30.z.literal("user.create"),
|
5282
|
+
options: import_zod30.z.object({
|
5283
|
+
role: import_zod30.z.array(import_zod30.z.string())
|
5284
|
+
})
|
5285
|
+
});
|
5286
|
+
var EditUserScope = import_zod30.z.object({
|
5287
|
+
type: import_zod30.z.literal("user.edit"),
|
5288
|
+
options: import_zod30.z.object({
|
5289
|
+
role: import_zod30.z.array(import_zod30.z.string())
|
5290
|
+
})
|
5291
|
+
});
|
5292
|
+
var WorkqueueScope = import_zod30.z.object({
|
5293
|
+
type: import_zod30.z.literal("workqueue"),
|
5294
|
+
options: import_zod30.z.object({
|
5295
|
+
id: import_zod30.z.array(import_zod30.z.string())
|
5296
|
+
})
|
5297
|
+
});
|
5298
|
+
var ConfigurableScopes = import_zod30.z.discriminatedUnion("type", [
|
5299
|
+
CreateUserScope,
|
5300
|
+
EditUserScope,
|
5301
|
+
WorkqueueScope
|
5302
|
+
]);
|
5303
|
+
var scopes = Object.values(SCOPES);
|
5304
|
+
|
5305
|
+
// ../commons/src/events/scopes.ts
|
5306
|
+
function hasAnyOfScopes(a, b) {
|
5307
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
5308
|
+
}
|
5309
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
5310
|
+
SCOPES.RECORD_DECLARE,
|
5311
|
+
SCOPES.RECORD_READ,
|
5312
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5313
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5314
|
+
SCOPES.RECORD_REGISTER,
|
5315
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
5316
|
+
SCOPES.CONFIG,
|
5317
|
+
SCOPES.CONFIG_UPDATE_ALL
|
5318
|
+
];
|
5319
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
5320
|
+
SCOPES.SEARCH_BIRTH,
|
5321
|
+
SCOPES.SEARCH_DEATH,
|
5322
|
+
SCOPES.SEARCH_MARRIAGE,
|
5323
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
5324
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
5325
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
5326
|
+
];
|
5327
|
+
var ACTION_ALLOWED_SCOPES = {
|
5328
|
+
[ActionType.READ]: [
|
5329
|
+
SCOPES.RECORD_DECLARE,
|
5330
|
+
SCOPES.RECORD_READ,
|
5331
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5332
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5333
|
+
SCOPES.RECORD_REGISTER,
|
5334
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
5335
|
+
],
|
5336
|
+
[ActionType.CREATE]: [
|
5337
|
+
SCOPES.RECORD_DECLARE,
|
5338
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5339
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
5340
|
+
],
|
5341
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
5342
|
+
[ActionType.DECLARE]: [
|
5343
|
+
SCOPES.RECORD_DECLARE,
|
5344
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5345
|
+
SCOPES.RECORD_REGISTER
|
5346
|
+
],
|
5347
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
5348
|
+
[ActionType.VALIDATE]: [
|
5349
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5350
|
+
SCOPES.RECORD_REGISTER
|
5351
|
+
],
|
5352
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
5353
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
5354
|
+
[ActionType.REQUEST_CORRECTION]: [
|
5355
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
5356
|
+
],
|
5357
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5358
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5359
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5360
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5361
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
5362
|
+
[ActionType.ASSIGN]: null,
|
5363
|
+
[ActionType.UNASSIGN]: null,
|
5364
|
+
[ActionType.DETECT_DUPLICATE]: []
|
5365
|
+
};
|
5366
|
+
function filterUnallowedActions(actions, userScopes) {
|
5367
|
+
const allowedActions = actions.filter((action) => {
|
5368
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
5369
|
+
if (requiredScopes === null) {
|
5370
|
+
return true;
|
5371
|
+
}
|
5372
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
5373
|
+
});
|
5374
|
+
const hasOtherAllowedActions = allowedActions.some(
|
5375
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
5376
|
+
);
|
5377
|
+
if (hasOtherAllowedActions) {
|
5378
|
+
return allowedActions;
|
5379
|
+
}
|
5380
|
+
return [ActionType.READ];
|
5381
|
+
}
|
5382
|
+
|
5383
|
+
// ../commons/src/events/serializers/user/deserializer.ts
|
5384
|
+
var import_zod31 = require("zod");
|
5385
|
+
var UserWithPrimaryOffice = User.extend({
|
5386
|
+
primaryOfficeId: import_zod31.z.string()
|
5387
|
+
});
|
5388
|
+
function userDeserializer(serializedUserField, user2) {
|
5389
|
+
if (typeof serializedUserField === "string") {
|
5390
|
+
return serializedUserField;
|
5391
|
+
}
|
5392
|
+
if (serializedUserField.$userField === "id") {
|
5393
|
+
return user2[serializedUserField.$userField];
|
5394
|
+
}
|
5395
|
+
if (serializedUserField.$userField === "primaryOfficeId") {
|
5396
|
+
return user2[serializedUserField.$userField];
|
5397
|
+
}
|
5398
|
+
return "ToDo";
|
5399
|
+
}
|
5400
|
+
function deserializeQueryExpression(expression, user2) {
|
5401
|
+
return {
|
5402
|
+
...expression,
|
5403
|
+
assignedTo: expression.assignedTo && {
|
5404
|
+
...expression.assignedTo,
|
5405
|
+
term: userDeserializer(expression.assignedTo.term, user2)
|
5406
|
+
},
|
5407
|
+
createdBy: expression.createdBy && {
|
5408
|
+
...expression.createdBy,
|
5409
|
+
term: userDeserializer(expression.createdBy.term, user2)
|
5410
|
+
},
|
5411
|
+
updatedBy: expression.updatedBy && {
|
5412
|
+
...expression.updatedBy,
|
5413
|
+
term: userDeserializer(expression.updatedBy.term, user2)
|
5414
|
+
},
|
5415
|
+
createdAtLocation: expression.createdAtLocation && (expression.createdAtLocation.type === "within" ? {
|
5416
|
+
...expression.createdAtLocation,
|
5417
|
+
location: userDeserializer(
|
5418
|
+
expression.createdAtLocation.location,
|
5419
|
+
user2
|
5420
|
+
)
|
5421
|
+
} : {
|
5422
|
+
...expression.createdAtLocation,
|
5423
|
+
term: userDeserializer(expression.createdAtLocation.term, user2)
|
5424
|
+
}),
|
5425
|
+
updatedAtLocation: expression.updatedAtLocation && (expression.updatedAtLocation.type === "within" ? {
|
5426
|
+
...expression.updatedAtLocation,
|
5427
|
+
location: userDeserializer(
|
5428
|
+
expression.updatedAtLocation.location,
|
5429
|
+
user2
|
5430
|
+
)
|
5431
|
+
} : {
|
5432
|
+
...expression.updatedAtLocation,
|
5433
|
+
term: userDeserializer(expression.updatedAtLocation.term, user2)
|
5434
|
+
})
|
5435
|
+
};
|
5436
|
+
}
|
5437
|
+
function deserializeQuery(query, user2) {
|
5438
|
+
return {
|
5439
|
+
...query,
|
5440
|
+
clauses: query.clauses.map(
|
5441
|
+
(clause) => deserializeQueryExpression(clause, user2)
|
5442
|
+
)
|
5443
|
+
};
|
5444
|
+
}
|