@opencrvs/toolkit 1.8.0-rc.fbcec4c → 1.8.0-rc.fbe4a79
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 +7703 -4211
- package/dist/commons/conditionals/conditionals.d.ts +9 -6
- package/dist/commons/conditionals/validate.d.ts +5 -11
- package/dist/commons/events/ActionConfig.d.ts +90025 -1680
- package/dist/commons/events/ActionDocument.d.ts +544 -207
- package/dist/commons/events/ActionInput.d.ts +338 -240
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +369 -25
- package/dist/commons/events/Draft.d.ts +36 -20
- package/dist/commons/events/EventConfig.d.ts +42812 -1344
- package/dist/commons/events/EventDocument.d.ts +339 -156
- package/dist/commons/events/EventIndex.d.ts +1346 -16
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +273 -14
- package/dist/commons/events/FieldConfig.d.ts +3733 -724
- 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 +1 -1
- package/dist/commons/events/WorkqueueConfig.d.ts +1135 -19
- package/dist/commons/events/defineConfig.d.ts +6971 -40
- package/dist/commons/events/event.d.ts +27 -0
- package/dist/commons/events/field.d.ts +68 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/scopes.d.ts +26 -0
- package/dist/commons/events/test.utils.d.ts +8 -45
- package/dist/commons/events/utils.d.ts +3562 -71
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +36 -33
- package/dist/events/index.js +1713 -1047
- 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,6 +77,7 @@ __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,
|
@@ -77,20 +86,27 @@ __export(events_exports, {
|
|
77
86
|
EnableConditional: () => EnableConditional,
|
78
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,
|
85
99
|
EventStatuses: () => EventStatuses,
|
86
100
|
FieldConditional: () => FieldConditional,
|
87
101
|
FieldConfig: () => FieldConfig,
|
102
|
+
FieldConfigSchema: () => FieldConfigSchema,
|
88
103
|
FieldType: () => FieldType,
|
89
104
|
FieldUpdateValue: () => FieldUpdateValue,
|
90
105
|
FieldValue: () => FieldValue,
|
91
106
|
FileFieldValue: () => FileFieldValue,
|
92
107
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
93
108
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
109
|
+
Flag: () => Flag,
|
94
110
|
FormConfig: () => FormConfig,
|
95
111
|
FormPageConfig: () => FormPageConfig,
|
96
112
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
@@ -98,23 +114,29 @@ __export(events_exports, {
|
|
98
114
|
GeographicalArea: () => GeographicalArea,
|
99
115
|
ImageMimeType: () => ImageMimeType,
|
100
116
|
LanguageConfig: () => LanguageConfig,
|
117
|
+
LegalStatuses: () => LegalStatuses,
|
101
118
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
102
119
|
MimeType: () => MimeType,
|
120
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
103
121
|
NotifyActionInput: () => NotifyActionInput,
|
104
122
|
NumberFieldValue: () => NumberFieldValue,
|
105
123
|
PageConfig: () => PageConfig,
|
106
124
|
PageTypes: () => PageTypes,
|
107
125
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
126
|
+
QueryInput: () => QueryInput,
|
127
|
+
QueryType: () => QueryType,
|
108
128
|
ReadActionInput: () => ReadActionInput,
|
109
129
|
RegisterAction: () => RegisterAction,
|
110
130
|
RegisterActionInput: () => RegisterActionInput,
|
131
|
+
RegistrationCreationMetadata: () => RegistrationCreationMetadata,
|
111
132
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
112
133
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
113
134
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
114
|
-
RequiredTextValue: () => RequiredTextValue,
|
115
135
|
ResolvedUser: () => ResolvedUser,
|
116
136
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
117
137
|
RuralAddressValue: () => RuralAddressValue,
|
138
|
+
SearchField: () => SearchField,
|
139
|
+
SelectOption: () => SelectOption,
|
118
140
|
ShowConditional: () => ShowConditional,
|
119
141
|
SummaryConfig: () => SummaryConfig,
|
120
142
|
TextValue: () => TextValue,
|
@@ -126,12 +148,16 @@ __export(events_exports, {
|
|
126
148
|
VerificationActionConfig: () => VerificationActionConfig,
|
127
149
|
VerificationPageConfig: () => VerificationPageConfig,
|
128
150
|
WorkqueueConfig: () => WorkqueueConfig,
|
151
|
+
ZodDate: () => ZodDate,
|
129
152
|
alwaysTrue: () => alwaysTrue,
|
130
153
|
and: () => and,
|
131
154
|
annotationActions: () => annotationActions,
|
132
155
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
156
|
+
areConditionsMet: () => areConditionsMet,
|
133
157
|
compositeFieldTypes: () => compositeFieldTypes,
|
134
158
|
createEmptyDraft: () => createEmptyDraft,
|
159
|
+
createEventConditionals: () => createEventConditionals,
|
160
|
+
createFieldConditionals: () => createFieldConditionals,
|
135
161
|
createValidationSchema: () => createValidationSchema,
|
136
162
|
deepDropNulls: () => deepDropNulls,
|
137
163
|
deepMerge: () => deepMerge,
|
@@ -142,6 +168,7 @@ __export(events_exports, {
|
|
142
168
|
defineFormConditional: () => defineFormConditional,
|
143
169
|
defineFormPage: () => defineFormPage,
|
144
170
|
definePage: () => definePage,
|
171
|
+
defineWorkqueue: () => defineWorkqueue,
|
145
172
|
errorMessages: () => errorMessages,
|
146
173
|
event: () => event,
|
147
174
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -150,12 +177,14 @@ __export(events_exports, {
|
|
150
177
|
eventStatuses: () => eventStatuses,
|
151
178
|
field: () => field,
|
152
179
|
fieldTypes: () => fieldTypes,
|
180
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
153
181
|
findActiveDrafts: () => findActiveDrafts,
|
154
182
|
findAllFields: () => findAllFields,
|
183
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
155
184
|
findRecordActionPages: () => findRecordActionPages,
|
185
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
186
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
156
187
|
generateActionDocument: () => generateActionDocument,
|
157
|
-
generateActionInput: () => generateActionInput,
|
158
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
159
188
|
generateEventDocument: () => generateEventDocument,
|
160
189
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
161
190
|
generateTransactionId: () => generateTransactionId,
|
@@ -165,22 +194,26 @@ __export(events_exports, {
|
|
165
194
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
166
195
|
getActionReview: () => getActionReview,
|
167
196
|
getActionReviewFields: () => getActionReviewFields,
|
168
|
-
|
197
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
169
198
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
199
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
170
200
|
getCurrentEventState: () => getCurrentEventState,
|
171
201
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
172
202
|
getDeclaration: () => getDeclaration,
|
173
203
|
getDeclarationFields: () => getDeclarationFields,
|
174
204
|
getDeclarationPages: () => getDeclarationPages,
|
175
|
-
|
176
|
-
|
205
|
+
getMixedPath: () => getMixedPath,
|
206
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
207
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
177
208
|
isAddressFieldType: () => isAddressFieldType,
|
178
209
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
179
210
|
isBulletListFieldType: () => isBulletListFieldType,
|
180
211
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
212
|
+
isConditionMet: () => isConditionMet,
|
181
213
|
isCountryFieldType: () => isCountryFieldType,
|
182
214
|
isDataFieldType: () => isDataFieldType,
|
183
215
|
isDateFieldType: () => isDateFieldType,
|
216
|
+
isDateRangeFieldType: () => isDateRangeFieldType,
|
184
217
|
isDividerFieldType: () => isDividerFieldType,
|
185
218
|
isEmailFieldType: () => isEmailFieldType,
|
186
219
|
isFacilityFieldType: () => isFacilityFieldType,
|
@@ -206,17 +239,21 @@ __export(events_exports, {
|
|
206
239
|
isTextFieldType: () => isTextFieldType,
|
207
240
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
208
241
|
isVerificationPage: () => isVerificationPage,
|
242
|
+
isWriteAction: () => isWriteAction,
|
209
243
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
210
244
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
211
245
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
212
246
|
never: () => never,
|
213
247
|
not: () => not,
|
248
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
249
|
+
omitHiddenFields: () => omitHiddenFields,
|
250
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
214
251
|
or: () => or,
|
215
|
-
|
252
|
+
runFieldValidations: () => runFieldValidations,
|
216
253
|
user: () => user,
|
217
254
|
validate: () => validate,
|
218
255
|
validateFieldInput: () => validateFieldInput,
|
219
|
-
|
256
|
+
writeActions: () => writeActions
|
220
257
|
});
|
221
258
|
module.exports = __toCommonJS(events_exports);
|
222
259
|
|
@@ -292,12 +329,12 @@ var FieldType = {
|
|
292
329
|
TEXTAREA: "TEXTAREA",
|
293
330
|
EMAIL: "EMAIL",
|
294
331
|
DATE: "DATE",
|
332
|
+
DATE_RANGE: "DATE_RANGE",
|
295
333
|
PARAGRAPH: "PARAGRAPH",
|
296
334
|
PAGE_HEADER: "PAGE_HEADER",
|
297
335
|
RADIO_GROUP: "RADIO_GROUP",
|
298
336
|
FILE: "FILE",
|
299
337
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
300
|
-
HIDDEN: "HIDDEN",
|
301
338
|
BULLET_LIST: "BULLET_LIST",
|
302
339
|
CHECKBOX: "CHECKBOX",
|
303
340
|
SELECT: "SELECT",
|
@@ -312,6 +349,7 @@ var FieldType = {
|
|
312
349
|
};
|
313
350
|
var fieldTypes = Object.values(FieldType);
|
314
351
|
var compositeFieldTypes = [
|
352
|
+
FieldType.DATE_RANGE,
|
315
353
|
FieldType.ADDRESS,
|
316
354
|
FieldType.FILE_WITH_OPTIONS,
|
317
355
|
FieldType.FILE
|
@@ -402,8 +440,10 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
402
440
|
|
403
441
|
// ../commons/src/events/FieldValue.ts
|
404
442
|
var TextValue = import_zod4.z.string();
|
405
|
-
var
|
443
|
+
var NonEmptyTextValue = TextValue.min(1);
|
406
444
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
445
|
+
var DatetimeValue = import_zod4.z.string().datetime();
|
446
|
+
var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
|
407
447
|
var EmailValue = import_zod4.z.string().email();
|
408
448
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
409
449
|
var NumberFieldValue = import_zod4.z.number();
|
@@ -411,6 +451,7 @@ var DataFieldValue = import_zod4.z.undefined();
|
|
411
451
|
var FieldValue = import_zod4.z.union([
|
412
452
|
TextValue,
|
413
453
|
DateValue,
|
454
|
+
DateRangeFieldValue,
|
414
455
|
CheckboxFieldValue,
|
415
456
|
NumberFieldValue,
|
416
457
|
FileFieldValue,
|
@@ -423,6 +464,7 @@ var FieldValue = import_zod4.z.union([
|
|
423
464
|
var FieldUpdateValue = import_zod4.z.union([
|
424
465
|
TextValue,
|
425
466
|
DateValue,
|
467
|
+
DateRangeFieldValue,
|
426
468
|
CheckboxFieldValue,
|
427
469
|
NumberFieldValue,
|
428
470
|
FileFieldValue,
|
@@ -435,27 +477,21 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
435
477
|
|
436
478
|
// ../commons/src/events/FieldConfig.ts
|
437
479
|
var FieldId = import_zod5.z.string();
|
438
|
-
var
|
439
|
-
|
440
|
-
|
441
|
-
});
|
480
|
+
var ParentReference = import_zod5.z.object({
|
481
|
+
_fieldId: FieldId.optional()
|
482
|
+
}).optional();
|
442
483
|
var BaseField = import_zod5.z.object({
|
443
484
|
id: FieldId,
|
444
485
|
defaultValue: import_zod5.z.union([
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
NumberFieldValue,
|
451
|
-
CheckboxFieldValue
|
452
|
-
]),
|
453
|
-
DependencyExpression
|
486
|
+
TextValue,
|
487
|
+
NonEmptyTextValue,
|
488
|
+
DateValue,
|
489
|
+
NumberFieldValue,
|
490
|
+
CheckboxFieldValue
|
454
491
|
]).optional(),
|
492
|
+
parent: ParentReference,
|
455
493
|
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
456
494
|
required: import_zod5.z.boolean().default(false).optional(),
|
457
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
458
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
459
495
|
placeholder: TranslationConfig.optional(),
|
460
496
|
validation: import_zod5.z.array(
|
461
497
|
import_zod5.z.object({
|
@@ -463,7 +499,6 @@ var BaseField = import_zod5.z.object({
|
|
463
499
|
message: TranslationConfig
|
464
500
|
})
|
465
501
|
).default([]).optional(),
|
466
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
467
502
|
label: TranslationConfig,
|
468
503
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
469
504
|
});
|
@@ -472,7 +507,7 @@ var Divider = BaseField.extend({
|
|
472
507
|
});
|
473
508
|
var TextField = BaseField.extend({
|
474
509
|
type: import_zod5.z.literal(FieldType.TEXT),
|
475
|
-
defaultValue:
|
510
|
+
defaultValue: NonEmptyTextValue.optional(),
|
476
511
|
configuration: import_zod5.z.object({
|
477
512
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
478
513
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -482,7 +517,7 @@ var TextField = BaseField.extend({
|
|
482
517
|
}).describe("Text input");
|
483
518
|
var NumberField = BaseField.extend({
|
484
519
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
485
|
-
defaultValue:
|
520
|
+
defaultValue: NumberFieldValue.optional(),
|
486
521
|
configuration: import_zod5.z.object({
|
487
522
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
488
523
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -492,7 +527,7 @@ var NumberField = BaseField.extend({
|
|
492
527
|
}).describe("Number input");
|
493
528
|
var TextAreaField = BaseField.extend({
|
494
529
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
495
|
-
defaultValue:
|
530
|
+
defaultValue: NonEmptyTextValue.optional(),
|
496
531
|
configuration: import_zod5.z.object({
|
497
532
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
498
533
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -526,17 +561,28 @@ var EmailField = BaseField.extend({
|
|
526
561
|
configuration: import_zod5.z.object({
|
527
562
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
528
563
|
}).default({ maxLength: 10 }).optional(),
|
529
|
-
defaultValue:
|
564
|
+
defaultValue: NonEmptyTextValue.optional()
|
530
565
|
});
|
531
566
|
var DateField = BaseField.extend({
|
532
567
|
type: import_zod5.z.literal(FieldType.DATE),
|
533
|
-
defaultValue:
|
568
|
+
defaultValue: DateValue.optional(),
|
534
569
|
configuration: import_zod5.z.object({
|
535
570
|
notice: TranslationConfig.describe(
|
536
571
|
"Text to display above the date input"
|
537
572
|
).optional()
|
538
573
|
}).optional()
|
539
574
|
}).describe("A single date input (dd-mm-YYYY)");
|
575
|
+
var DateRangeField = BaseField.extend({
|
576
|
+
type: import_zod5.z.literal(FieldType.DATE_RANGE),
|
577
|
+
defaultValue: DateRangeFieldValue.optional(),
|
578
|
+
configuration: import_zod5.z.object({
|
579
|
+
notice: TranslationConfig.describe(
|
580
|
+
"Text to display above the date input"
|
581
|
+
).optional()
|
582
|
+
}).optional()
|
583
|
+
}).describe(
|
584
|
+
"A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
|
585
|
+
);
|
540
586
|
var HtmlFontVariant = import_zod5.z.enum([
|
541
587
|
"reg12",
|
542
588
|
"reg14",
|
@@ -549,7 +595,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
549
595
|
]);
|
550
596
|
var Paragraph = BaseField.extend({
|
551
597
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
552
|
-
defaultValue:
|
598
|
+
defaultValue: NonEmptyTextValue.optional(),
|
553
599
|
configuration: import_zod5.z.object({
|
554
600
|
styles: import_zod5.z.object({
|
555
601
|
fontVariant: HtmlFontVariant.optional()
|
@@ -558,7 +604,7 @@ var Paragraph = BaseField.extend({
|
|
558
604
|
}).describe("A read-only HTML <p> paragraph");
|
559
605
|
var PageHeader = BaseField.extend({
|
560
606
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
561
|
-
defaultValue:
|
607
|
+
defaultValue: NonEmptyTextValue.optional()
|
562
608
|
}).describe("A read-only header component for form pages");
|
563
609
|
var File = BaseField.extend({
|
564
610
|
type: import_zod5.z.literal(FieldType.FILE),
|
@@ -569,7 +615,8 @@ var File = BaseField.extend({
|
|
569
615
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
570
616
|
"Whether the file upload button should take the full width of the container or not"
|
571
617
|
)
|
572
|
-
}).optional()
|
618
|
+
}).optional(),
|
619
|
+
fileName: TranslationConfig.optional()
|
573
620
|
}).default({
|
574
621
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
575
622
|
})
|
@@ -580,7 +627,7 @@ var SelectOption = import_zod5.z.object({
|
|
580
627
|
});
|
581
628
|
var RadioGroup = BaseField.extend({
|
582
629
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
583
|
-
defaultValue:
|
630
|
+
defaultValue: TextValue.optional(),
|
584
631
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
585
632
|
configuration: import_zod5.z.object({
|
586
633
|
styles: import_zod5.z.object({
|
@@ -590,7 +637,7 @@ var RadioGroup = BaseField.extend({
|
|
590
637
|
}).describe("Grouped radio options");
|
591
638
|
var BulletList = BaseField.extend({
|
592
639
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
593
|
-
defaultValue:
|
640
|
+
defaultValue: TextValue.optional(),
|
594
641
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
595
642
|
configuration: import_zod5.z.object({
|
596
643
|
styles: import_zod5.z.object({
|
@@ -600,16 +647,16 @@ var BulletList = BaseField.extend({
|
|
600
647
|
}).describe("A list of bullet points");
|
601
648
|
var Select = BaseField.extend({
|
602
649
|
type: import_zod5.z.literal(FieldType.SELECT),
|
603
|
-
defaultValue:
|
650
|
+
defaultValue: TextValue.optional(),
|
604
651
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
605
652
|
}).describe("Select input");
|
606
653
|
var Checkbox = BaseField.extend({
|
607
654
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
608
|
-
defaultValue:
|
655
|
+
defaultValue: CheckboxFieldValue.optional()
|
609
656
|
}).describe("Boolean checkbox field");
|
610
657
|
var Country = BaseField.extend({
|
611
658
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
612
|
-
defaultValue:
|
659
|
+
defaultValue: NonEmptyTextValue.optional()
|
613
660
|
}).describe("Country select field");
|
614
661
|
var AdministrativeAreas = import_zod5.z.enum([
|
615
662
|
"ADMIN_STRUCTURE",
|
@@ -624,12 +671,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
|
|
624
671
|
}).describe("Administrative area options");
|
625
672
|
var AdministrativeArea = BaseField.extend({
|
626
673
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
627
|
-
defaultValue:
|
674
|
+
defaultValue: NonEmptyTextValue.optional(),
|
628
675
|
configuration: AdministrativeAreaConfiguration
|
629
676
|
}).describe("Administrative area input field e.g. facility, office");
|
630
677
|
var Location = BaseField.extend({
|
631
678
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
632
|
-
defaultValue:
|
679
|
+
defaultValue: NonEmptyTextValue.optional()
|
633
680
|
}).describe("Input field for a location");
|
634
681
|
var FileUploadWithOptions = BaseField.extend({
|
635
682
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
@@ -643,11 +690,11 @@ var FileUploadWithOptions = BaseField.extend({
|
|
643
690
|
});
|
644
691
|
var Facility = BaseField.extend({
|
645
692
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
646
|
-
defaultValue:
|
693
|
+
defaultValue: NonEmptyTextValue.optional()
|
647
694
|
}).describe("Input field for a facility");
|
648
695
|
var Office = BaseField.extend({
|
649
696
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
650
|
-
defaultValue:
|
697
|
+
defaultValue: NonEmptyTextValue.optional()
|
651
698
|
}).describe("Input field for an office");
|
652
699
|
var Address = BaseField.extend({
|
653
700
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
@@ -656,7 +703,7 @@ var Address = BaseField.extend({
|
|
656
703
|
var DataEntry = import_zod5.z.union([
|
657
704
|
import_zod5.z.object({
|
658
705
|
label: TranslationConfig,
|
659
|
-
value: import_zod5.z.string()
|
706
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
660
707
|
}),
|
661
708
|
import_zod5.z.object({
|
662
709
|
fieldId: import_zod5.z.string()
|
@@ -675,6 +722,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
675
722
|
NumberField,
|
676
723
|
TextAreaField,
|
677
724
|
DateField,
|
725
|
+
DateRangeField,
|
678
726
|
Paragraph,
|
679
727
|
RadioGroup,
|
680
728
|
BulletList,
|
@@ -692,7 +740,6 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
692
740
|
EmailField,
|
693
741
|
FileUploadWithOptions,
|
694
742
|
DataField
|
695
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
696
743
|
]);
|
697
744
|
|
698
745
|
// ../commons/src/events/PageConfig.ts
|
@@ -797,6 +844,12 @@ var DeclarationUpdateActions = ActionTypes.extract(
|
|
797
844
|
declarationUpdateActionValues
|
798
845
|
);
|
799
846
|
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
847
|
+
var writeActions = ActionTypes.exclude([
|
848
|
+
ActionType.CREATE,
|
849
|
+
ActionType.READ,
|
850
|
+
ActionType.ASSIGN,
|
851
|
+
ActionType.UNASSIGN
|
852
|
+
]);
|
800
853
|
|
801
854
|
// ../commons/src/events/FormConfig.ts
|
802
855
|
var import_zod8 = require("zod");
|
@@ -811,6 +864,8 @@ var ActionFormConfig = import_zod8.z.object({
|
|
811
864
|
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
812
865
|
|
813
866
|
// ../commons/src/events/ActionConfig.ts
|
867
|
+
var import_zod_openapi = require("zod-openapi");
|
868
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
|
814
869
|
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
815
870
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
816
871
|
ShowConditional,
|
@@ -888,18 +943,24 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
|
|
888
943
|
})
|
889
944
|
);
|
890
945
|
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
946
|
+
/*
|
947
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
948
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
949
|
+
*/
|
950
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
951
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
952
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
953
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
954
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
955
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
956
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
957
|
+
PrintCertificateActionConfig.openapi({
|
958
|
+
ref: "PrintCertificateActionConfig"
|
959
|
+
}),
|
960
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
961
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
962
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
963
|
+
]).openapi({ ref: "ActionConfig" });
|
903
964
|
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
904
965
|
DeclareConfig,
|
905
966
|
ValidateConfig,
|
@@ -943,10 +1004,12 @@ var LanguageConfig = import_zod11.z.object({
|
|
943
1004
|
});
|
944
1005
|
|
945
1006
|
// ../commons/src/events/EventConfig.ts
|
946
|
-
var
|
1007
|
+
var import_zod17 = require("zod");
|
947
1008
|
|
948
1009
|
// ../commons/src/events/DeduplicationConfig.ts
|
949
1010
|
var import_zod12 = require("zod");
|
1011
|
+
var import_zod_openapi2 = require("zod-openapi");
|
1012
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
|
950
1013
|
var FieldReference = import_zod12.z.string();
|
951
1014
|
var Matcher = import_zod12.z.object({
|
952
1015
|
fieldId: import_zod12.z.string(),
|
@@ -1007,7 +1070,9 @@ var Clause = import_zod12.z.lazy(
|
|
1007
1070
|
DateRangeMatcher,
|
1008
1071
|
DateDistanceMatcher
|
1009
1072
|
])
|
1010
|
-
)
|
1073
|
+
).openapi({
|
1074
|
+
ref: "Clause"
|
1075
|
+
});
|
1011
1076
|
var DeduplicationConfig = import_zod12.z.object({
|
1012
1077
|
id: import_zod12.z.string(),
|
1013
1078
|
label: TranslationConfig,
|
@@ -1016,278 +1081,214 @@ var DeduplicationConfig = import_zod12.z.object({
|
|
1016
1081
|
|
1017
1082
|
// ../commons/src/events/SummaryConfig.ts
|
1018
1083
|
var import_zod13 = require("zod");
|
1019
|
-
var
|
1084
|
+
var BaseField2 = import_zod13.z.object({
|
1085
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1086
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1087
|
+
});
|
1088
|
+
var ReferenceField = BaseField2.extend({
|
1089
|
+
fieldId: import_zod13.z.string(),
|
1090
|
+
label: TranslationConfig.optional().describe(
|
1091
|
+
"By default, the configured field's label is used. This can be overridden by providing a custom label."
|
1092
|
+
)
|
1093
|
+
}).describe("Field directly referencing event data with field id");
|
1094
|
+
var Field = BaseField2.extend({
|
1020
1095
|
id: import_zod13.z.string().describe("Id of summary field"),
|
1021
1096
|
value: TranslationConfig.describe(
|
1022
1097
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
1023
1098
|
),
|
1024
1099
|
label: TranslationConfig,
|
1025
1100
|
emptyValueMessage: TranslationConfig.optional()
|
1026
|
-
});
|
1027
|
-
var Title = import_zod13.z.object({
|
1028
|
-
id: import_zod13.z.string(),
|
1029
|
-
label: TranslationConfig.describe("Title content"),
|
1030
|
-
emptyValueMessage: TranslationConfig.optional()
|
1031
|
-
});
|
1101
|
+
}).describe("Custom configured field");
|
1032
1102
|
var SummaryConfig = import_zod13.z.object({
|
1033
|
-
|
1034
|
-
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
1103
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
1035
1104
|
}).describe("Configuration for summary in event.");
|
1036
1105
|
|
1037
|
-
// ../commons/src/events/
|
1038
|
-
var import_zod15 = require("zod");
|
1039
|
-
|
1040
|
-
// ../commons/src/events/EventMetadata.ts
|
1106
|
+
// ../commons/src/events/AdvancedSearchConfig.ts
|
1041
1107
|
var import_zod14 = require("zod");
|
1042
|
-
var
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
CERTIFIED: "CERTIFIED",
|
1049
|
-
REJECTED: "REJECTED",
|
1050
|
-
ARCHIVED: "ARCHIVED"
|
1051
|
-
};
|
1052
|
-
var eventStatuses = Object.values(EventStatus);
|
1053
|
-
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1054
|
-
var EventMetadata = import_zod14.z.object({
|
1055
|
-
id: import_zod14.z.string(),
|
1056
|
-
type: import_zod14.z.string(),
|
1057
|
-
status: EventStatuses,
|
1058
|
-
createdAt: import_zod14.z.string().datetime(),
|
1059
|
-
createdBy: import_zod14.z.string(),
|
1060
|
-
createdAtLocation: import_zod14.z.string(),
|
1061
|
-
updatedAtLocation: import_zod14.z.string(),
|
1062
|
-
modifiedAt: import_zod14.z.string().datetime(),
|
1063
|
-
assignedTo: import_zod14.z.string().nullish(),
|
1064
|
-
updatedBy: import_zod14.z.string(),
|
1065
|
-
trackingId: import_zod14.z.string(),
|
1066
|
-
registrationNumber: import_zod14.z.string().nullish()
|
1108
|
+
var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
|
1109
|
+
var BaseField3 = import_zod14.z.object({
|
1110
|
+
config: import_zod14.z.object({
|
1111
|
+
type: MatchType.describe("Determines the type of field")
|
1112
|
+
}),
|
1113
|
+
options: import_zod14.z.array(SelectOption).optional()
|
1067
1114
|
});
|
1068
|
-
var
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
description: "Created At Location"
|
1083
|
-
},
|
1084
|
-
"event.updatedAtLocation": {
|
1085
|
-
id: "event.updatedAtLocation.label",
|
1086
|
-
defaultMessage: "Location",
|
1087
|
-
description: "Updated At Location"
|
1088
|
-
},
|
1089
|
-
"event.createdBy": {
|
1090
|
-
id: "event.createdBy.label",
|
1091
|
-
defaultMessage: "Created By",
|
1092
|
-
description: "Created By"
|
1093
|
-
},
|
1094
|
-
"event.id": {
|
1095
|
-
id: "event.id.label",
|
1096
|
-
defaultMessage: "ID",
|
1097
|
-
description: "ID"
|
1098
|
-
},
|
1099
|
-
"event.modifiedAt": {
|
1100
|
-
id: "event.modifiedAt.label",
|
1101
|
-
defaultMessage: "Updated",
|
1102
|
-
description: "Modified At"
|
1103
|
-
},
|
1104
|
-
"event.status": {
|
1105
|
-
id: "event.status.label",
|
1106
|
-
defaultMessage: "Status",
|
1107
|
-
description: "Status"
|
1108
|
-
},
|
1109
|
-
"event.type": {
|
1110
|
-
id: "event.type.label",
|
1111
|
-
defaultMessage: "Type",
|
1112
|
-
description: "Type"
|
1113
|
-
},
|
1114
|
-
"event.updatedBy": {
|
1115
|
-
id: "event.updatedBy.label",
|
1116
|
-
defaultMessage: "Updated By",
|
1117
|
-
description: "Updated By"
|
1118
|
-
},
|
1119
|
-
"event.trackingId": {
|
1120
|
-
id: "event.trackingId.label",
|
1121
|
-
defaultMessage: "Tracking ID",
|
1122
|
-
description: "Tracking ID"
|
1123
|
-
},
|
1124
|
-
"event.registrationNumber": {
|
1125
|
-
id: "event.registrationNumber.label",
|
1126
|
-
defaultMessage: "Registration Number",
|
1127
|
-
description: "Registration Number"
|
1128
|
-
}
|
1129
|
-
};
|
1130
|
-
|
1131
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1132
|
-
var WorkqueueConfig = import_zod15.z.object({
|
1133
|
-
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1134
|
-
filters: import_zod15.z.array(
|
1135
|
-
import_zod15.z.object({
|
1136
|
-
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1137
|
-
})
|
1138
|
-
).describe("Filters to be applied to workqueue.")
|
1139
|
-
}).describe("Configuration for workqueue.");
|
1140
|
-
|
1141
|
-
// ../commons/src/events/AdvancedSearchConfig.ts
|
1142
|
-
var import_zod16 = require("zod");
|
1143
|
-
var AdvancedSearchConfig = import_zod16.z.object({
|
1115
|
+
var FieldConfigSchema = BaseField3.extend({
|
1116
|
+
fieldId: import_zod14.z.string(),
|
1117
|
+
fieldType: import_zod14.z.literal("field")
|
1118
|
+
});
|
1119
|
+
var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
|
1120
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1121
|
+
fieldId: EventFieldId,
|
1122
|
+
fieldType: import_zod14.z.literal("event")
|
1123
|
+
});
|
1124
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1125
|
+
FieldConfigSchema,
|
1126
|
+
EventFieldConfigSchema
|
1127
|
+
]);
|
1128
|
+
var AdvancedSearchConfig = import_zod14.z.object({
|
1144
1129
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1145
|
-
fields:
|
1146
|
-
import_zod16.z.object({
|
1147
|
-
fieldId: import_zod16.z.string(),
|
1148
|
-
config: import_zod16.z.object({
|
1149
|
-
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1150
|
-
}).optional().describe("Configuration options for the field")
|
1151
|
-
})
|
1152
|
-
).optional().default([]).describe("Advanced search fields.")
|
1130
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1153
1131
|
});
|
1154
1132
|
|
1155
1133
|
// ../commons/src/events/utils.ts
|
1156
1134
|
var import_lodash = require("lodash");
|
1157
1135
|
|
1158
|
-
// ../commons/src/
|
1159
|
-
var
|
1160
|
-
|
1161
|
-
|
1162
|
-
var
|
1163
|
-
var
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
event: {
|
1169
|
-
id: "event",
|
1170
|
-
label: {
|
1171
|
-
defaultMessage: "Event",
|
1172
|
-
description: "This is the label for the workqueue column",
|
1173
|
-
id: "workqueue.default.column.event"
|
1174
|
-
}
|
1175
|
-
},
|
1176
|
-
status: {
|
1177
|
-
id: "status",
|
1178
|
-
label: {
|
1179
|
-
defaultMessage: "Status",
|
1180
|
-
description: "This is the label for the workqueue column",
|
1181
|
-
id: "workqueue.default.column.status"
|
1182
|
-
}
|
1183
|
-
},
|
1184
|
-
createdAt: {
|
1185
|
-
id: "createdAt",
|
1186
|
-
label: {
|
1187
|
-
defaultMessage: "Created",
|
1188
|
-
description: "This is the label for the workqueue column",
|
1189
|
-
id: "workqueue.default.column.createdAt"
|
1190
|
-
}
|
1191
|
-
},
|
1192
|
-
modifiedAt: {
|
1193
|
-
id: "modifiedAt",
|
1194
|
-
label: {
|
1195
|
-
defaultMessage: "Modified",
|
1196
|
-
description: "This is the label for the workqueue column",
|
1197
|
-
id: "workqueue.default.column.modifiedAt"
|
1198
|
-
}
|
1199
|
-
}
|
1136
|
+
// ../commons/src/events/ActionDocument.ts
|
1137
|
+
var import_zod15 = require("zod");
|
1138
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1139
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
|
1140
|
+
var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
|
1141
|
+
var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
|
1142
|
+
var ActionStatus = {
|
1143
|
+
Requested: "Requested",
|
1144
|
+
Accepted: "Accepted",
|
1145
|
+
Rejected: "Rejected"
|
1200
1146
|
};
|
1201
|
-
var
|
1202
|
-
|
1203
|
-
)
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
title: {
|
1218
|
-
defaultMessage: "All events",
|
1219
|
-
description: "This is the label for the workqueue",
|
1220
|
-
id: "workqueue.all.label"
|
1221
|
-
},
|
1222
|
-
columns: [
|
1223
|
-
{
|
1224
|
-
id: "title",
|
1225
|
-
label: {
|
1226
|
-
defaultMessage: "Title",
|
1227
|
-
description: "This is the label for the workqueue column",
|
1228
|
-
id: "workqueue.all.column.title"
|
1229
|
-
}
|
1230
|
-
}
|
1231
|
-
],
|
1232
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1147
|
+
var ActionBase = import_zod15.z.object({
|
1148
|
+
id: import_zod15.z.string(),
|
1149
|
+
transactionId: import_zod15.z.string(),
|
1150
|
+
createdAt: import_zod15.z.string().datetime(),
|
1151
|
+
createdBy: import_zod15.z.string(),
|
1152
|
+
createdByRole: import_zod15.z.string(),
|
1153
|
+
declaration: ActionUpdate,
|
1154
|
+
annotation: ActionUpdate.optional(),
|
1155
|
+
createdAtLocation: import_zod15.z.string(),
|
1156
|
+
status: import_zod15.z.enum([
|
1157
|
+
ActionStatus.Requested,
|
1158
|
+
ActionStatus.Accepted,
|
1159
|
+
ActionStatus.Rejected
|
1160
|
+
]),
|
1161
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1162
|
+
originalActionId: import_zod15.z.string().optional()
|
1233
1163
|
});
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1164
|
+
var AssignedAction = ActionBase.merge(
|
1165
|
+
import_zod15.z.object({
|
1166
|
+
type: import_zod15.z.literal(ActionType.ASSIGN),
|
1167
|
+
assignedTo: import_zod15.z.string()
|
1168
|
+
})
|
1169
|
+
);
|
1170
|
+
var UnassignedAction = ActionBase.merge(
|
1171
|
+
import_zod15.z.object({
|
1172
|
+
type: import_zod15.z.literal(ActionType.UNASSIGN),
|
1173
|
+
assignedTo: import_zod15.z.literal(null)
|
1174
|
+
})
|
1175
|
+
);
|
1176
|
+
var RegisterAction = ActionBase.merge(
|
1177
|
+
import_zod15.z.object({
|
1178
|
+
type: import_zod15.z.literal(ActionType.REGISTER),
|
1179
|
+
registrationNumber: import_zod15.z.string().optional()
|
1180
|
+
})
|
1181
|
+
);
|
1182
|
+
var DeclareAction = ActionBase.merge(
|
1183
|
+
import_zod15.z.object({
|
1184
|
+
type: import_zod15.z.literal(ActionType.DECLARE)
|
1185
|
+
})
|
1186
|
+
);
|
1187
|
+
var ValidateAction = ActionBase.merge(
|
1188
|
+
import_zod15.z.object({
|
1189
|
+
type: import_zod15.z.literal(ActionType.VALIDATE)
|
1190
|
+
})
|
1191
|
+
);
|
1192
|
+
var RejectAction = ActionBase.merge(
|
1193
|
+
import_zod15.z.object({
|
1194
|
+
type: import_zod15.z.literal(ActionType.REJECT)
|
1195
|
+
})
|
1196
|
+
);
|
1197
|
+
var MarkAsDuplicateAction = ActionBase.merge(
|
1198
|
+
import_zod15.z.object({
|
1199
|
+
type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1200
|
+
})
|
1201
|
+
);
|
1202
|
+
var ArchiveAction = ActionBase.merge(
|
1203
|
+
import_zod15.z.object({
|
1204
|
+
type: import_zod15.z.literal(ActionType.ARCHIVE)
|
1205
|
+
})
|
1206
|
+
);
|
1207
|
+
var CreatedAction = ActionBase.merge(
|
1208
|
+
import_zod15.z.object({
|
1209
|
+
type: import_zod15.z.literal(ActionType.CREATE)
|
1210
|
+
})
|
1211
|
+
);
|
1212
|
+
var NotifiedAction = ActionBase.merge(
|
1213
|
+
import_zod15.z.object({
|
1214
|
+
type: import_zod15.z.literal(ActionType.NOTIFY)
|
1215
|
+
})
|
1216
|
+
);
|
1217
|
+
var PrintCertificateAction = ActionBase.merge(
|
1218
|
+
import_zod15.z.object({
|
1219
|
+
type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
|
1220
|
+
})
|
1221
|
+
);
|
1222
|
+
var RequestedCorrectionAction = ActionBase.merge(
|
1223
|
+
import_zod15.z.object({
|
1224
|
+
type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
|
1225
|
+
})
|
1226
|
+
);
|
1227
|
+
var ApprovedCorrectionAction = ActionBase.merge(
|
1228
|
+
import_zod15.z.object({
|
1229
|
+
type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
|
1230
|
+
requestId: import_zod15.z.string()
|
1231
|
+
})
|
1232
|
+
);
|
1233
|
+
var RejectedCorrectionAction = ActionBase.merge(
|
1234
|
+
import_zod15.z.object({
|
1235
|
+
type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
|
1236
|
+
requestId: import_zod15.z.string()
|
1237
|
+
})
|
1238
|
+
);
|
1239
|
+
var ReadAction = ActionBase.merge(
|
1240
|
+
import_zod15.z.object({
|
1241
|
+
type: import_zod15.z.literal(ActionType.READ)
|
1242
|
+
})
|
1243
|
+
);
|
1244
|
+
var ActionDocument = import_zod15.z.discriminatedUnion("type", [
|
1245
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1246
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1247
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1248
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1249
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1250
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1251
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1252
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1253
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1254
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1255
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1256
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1257
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1258
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1259
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1260
|
+
]).openapi({
|
1261
|
+
ref: "ActionDocument"
|
1254
1262
|
});
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1263
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1264
|
+
declaration: true,
|
1265
|
+
annotation: true
|
1266
|
+
}).merge(
|
1267
|
+
import_zod15.z.object({
|
1268
|
+
type: import_zod15.z.enum(ConfirmableActions),
|
1269
|
+
status: import_zod15.z.literal(ActionStatus.Rejected)
|
1270
|
+
})
|
1271
|
+
);
|
1272
|
+
var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1273
|
+
var ResolvedUser = import_zod15.z.object({
|
1274
|
+
id: import_zod15.z.string(),
|
1275
|
+
role: import_zod15.z.string(),
|
1276
|
+
name: import_zod15.z.array(
|
1277
|
+
import_zod15.z.object({
|
1278
|
+
use: import_zod15.z.string(),
|
1279
|
+
given: import_zod15.z.array(import_zod15.z.string()),
|
1280
|
+
family: import_zod15.z.string()
|
1281
|
+
})
|
1282
|
+
)
|
1275
1283
|
});
|
1276
1284
|
|
1277
|
-
// ../commons/src/workqueues/index.ts
|
1278
|
-
var workqueues = {
|
1279
|
-
all: allWorkqueue,
|
1280
|
-
registered: registeredWorkqueue,
|
1281
|
-
inReview: inReviewWorkqueue
|
1282
|
-
};
|
1283
|
-
|
1284
1285
|
// ../commons/src/conditionals/validate.ts
|
1285
1286
|
var import_ajv = __toESM(require("ajv"));
|
1286
1287
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1287
1288
|
var import_date_fns = require("date-fns");
|
1288
1289
|
|
1289
1290
|
// ../commons/src/events/FieldTypeMapping.ts
|
1290
|
-
var
|
1291
|
+
var import_zod16 = require("zod");
|
1291
1292
|
function mapFieldTypeToZod(type, required) {
|
1292
1293
|
let schema;
|
1293
1294
|
switch (type) {
|
@@ -1297,6 +1298,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1297
1298
|
case FieldType.EMAIL:
|
1298
1299
|
schema = EmailValue;
|
1299
1300
|
break;
|
1301
|
+
case FieldType.DATE_RANGE:
|
1302
|
+
schema = DateRangeFieldValue;
|
1303
|
+
break;
|
1300
1304
|
case FieldType.TEXT:
|
1301
1305
|
case FieldType.TEXTAREA:
|
1302
1306
|
case FieldType.DIVIDER:
|
@@ -1311,8 +1315,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1311
1315
|
case FieldType.FACILITY:
|
1312
1316
|
case FieldType.OFFICE:
|
1313
1317
|
case FieldType.SIGNATURE:
|
1314
|
-
|
1315
|
-
schema = required ? RequiredTextValue : TextValue;
|
1318
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1316
1319
|
break;
|
1317
1320
|
case FieldType.NUMBER:
|
1318
1321
|
schema = NumberFieldValue;
|
@@ -1340,7 +1343,7 @@ function createValidationSchema(config) {
|
|
1340
1343
|
for (const field2 of config) {
|
1341
1344
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1342
1345
|
}
|
1343
|
-
return
|
1346
|
+
return import_zod16.z.object(shape);
|
1344
1347
|
}
|
1345
1348
|
function mapFieldTypeToMockValue(field2, i) {
|
1346
1349
|
switch (field2.type) {
|
@@ -1378,6 +1381,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1378
1381
|
};
|
1379
1382
|
case FieldType.DATE:
|
1380
1383
|
return "2021-01-01";
|
1384
|
+
case FieldType.DATE_RANGE:
|
1385
|
+
return ["2021-01-01", "2021-01-02"];
|
1381
1386
|
case FieldType.CHECKBOX:
|
1382
1387
|
return true;
|
1383
1388
|
case FieldType.FILE:
|
@@ -1412,6 +1417,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1412
1417
|
case FieldType.EMAIL:
|
1413
1418
|
case FieldType.DATE:
|
1414
1419
|
case FieldType.CHECKBOX:
|
1420
|
+
case FieldType.DATE_RANGE:
|
1415
1421
|
case FieldType.DATA:
|
1416
1422
|
return null;
|
1417
1423
|
case FieldType.ADDRESS:
|
@@ -1444,6 +1450,9 @@ var isParagraphFieldType = (field2) => {
|
|
1444
1450
|
var isDateFieldType = (field2) => {
|
1445
1451
|
return field2.config.type === FieldType.DATE;
|
1446
1452
|
};
|
1453
|
+
var isDateRangeFieldType = (field2) => {
|
1454
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1455
|
+
};
|
1447
1456
|
var isPageHeaderFieldType = (field2) => {
|
1448
1457
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1449
1458
|
};
|
@@ -1514,12 +1523,23 @@ var ajv = new import_ajv.default({
|
|
1514
1523
|
function validate(schema, data) {
|
1515
1524
|
return ajv.validate(schema, data);
|
1516
1525
|
}
|
1526
|
+
function isConditionMet(conditional, values) {
|
1527
|
+
return validate(conditional, {
|
1528
|
+
$form: values,
|
1529
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1530
|
+
});
|
1531
|
+
}
|
1517
1532
|
function getConditionalActionsForField(field2, values) {
|
1518
1533
|
if (!field2.conditionals) {
|
1519
1534
|
return [];
|
1520
1535
|
}
|
1521
1536
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1522
1537
|
}
|
1538
|
+
function areConditionsMet(conditions, values) {
|
1539
|
+
return conditions.every(
|
1540
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1541
|
+
);
|
1542
|
+
}
|
1523
1543
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1524
1544
|
const hasRule = (field2.conditionals ?? []).some(
|
1525
1545
|
(conditional) => conditional.type === conditionalType
|
@@ -1538,6 +1558,10 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1538
1558
|
function isFieldVisible(field2, form) {
|
1539
1559
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1540
1560
|
}
|
1561
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1562
|
+
const fieldValue = form[field2.id];
|
1563
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1564
|
+
}
|
1541
1565
|
function isFieldEnabled(field2, form) {
|
1542
1566
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1543
1567
|
}
|
@@ -1638,28 +1662,19 @@ function validateFieldInput({
|
|
1638
1662
|
);
|
1639
1663
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1640
1664
|
}
|
1641
|
-
function
|
1665
|
+
function runFieldValidations({
|
1642
1666
|
field: field2,
|
1643
1667
|
values
|
1644
1668
|
}) {
|
1645
|
-
|
1646
|
-
$form: values,
|
1647
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1648
|
-
};
|
1649
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1650
|
-
if (values[field2.id]) {
|
1651
|
-
return {
|
1652
|
-
errors: [
|
1653
|
-
{
|
1654
|
-
message: errorMessages.hiddenField
|
1655
|
-
}
|
1656
|
-
]
|
1657
|
-
};
|
1658
|
-
}
|
1669
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1659
1670
|
return {
|
1660
1671
|
errors: []
|
1661
1672
|
};
|
1662
1673
|
}
|
1674
|
+
const conditionalParameters = {
|
1675
|
+
$form: values,
|
1676
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1677
|
+
};
|
1663
1678
|
const fieldValidationResult = validateFieldInput({
|
1664
1679
|
field: field2,
|
1665
1680
|
value: values[field2.id]
|
@@ -1680,9 +1695,6 @@ function getUUID() {
|
|
1680
1695
|
return (0, import_uuid.v4)();
|
1681
1696
|
}
|
1682
1697
|
|
1683
|
-
// ../commons/src/events/utils.ts
|
1684
|
-
var import_date_fns2 = require("date-fns");
|
1685
|
-
|
1686
1698
|
// ../commons/src/utils.ts
|
1687
1699
|
function getOrThrow(x, message) {
|
1688
1700
|
if (x === void 0 || x === null) {
|
@@ -1719,15 +1731,9 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1719
1731
|
}
|
1720
1732
|
return [];
|
1721
1733
|
};
|
1722
|
-
|
1734
|
+
function getAllAnnotationFields(config) {
|
1723
1735
|
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1724
|
-
}
|
1725
|
-
var findAllFields = (config) => {
|
1726
|
-
return (0, import_lodash.flattenDeep)([
|
1727
|
-
...getDeclarationFields(config),
|
1728
|
-
...getAllAnnotationFields(config)
|
1729
|
-
]);
|
1730
|
-
};
|
1736
|
+
}
|
1731
1737
|
var findRecordActionPages = (config, actionType) => {
|
1732
1738
|
const action = config.actions.find((a) => a.type === actionType);
|
1733
1739
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1750,48 +1756,28 @@ function getActionReview(configuration, actionType) {
|
|
1750
1756
|
function getActionReviewFields(configuration, actionType) {
|
1751
1757
|
return getActionReview(configuration, actionType).fields;
|
1752
1758
|
}
|
1753
|
-
function validateWorkqueueConfig(workqueueConfigs) {
|
1754
|
-
workqueueConfigs.map((workqueue) => {
|
1755
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1756
|
-
(wq) => wq.id === workqueue.id
|
1757
|
-
);
|
1758
|
-
if (!rootWorkqueue) {
|
1759
|
-
throw new Error(
|
1760
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1761
|
-
);
|
1762
|
-
}
|
1763
|
-
});
|
1764
|
-
}
|
1765
1759
|
function isPageVisible(page, formValues) {
|
1766
1760
|
if (!page.conditional) {
|
1767
1761
|
return true;
|
1768
1762
|
}
|
1769
|
-
return
|
1770
|
-
$form: formValues,
|
1771
|
-
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1772
|
-
});
|
1773
|
-
}
|
1774
|
-
var getVisiblePagesFormFields = (formConfig, formData) => {
|
1775
|
-
return formConfig.pages.filter((p) => isPageVisible(p, formData)).flatMap((p) => p.fields);
|
1776
|
-
};
|
1777
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1778
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1779
|
-
return false;
|
1780
|
-
}
|
1781
|
-
return !form[field2.id];
|
1763
|
+
return isConditionMet(page.conditional, formValues);
|
1782
1764
|
}
|
1783
|
-
function
|
1784
|
-
return (0, import_lodash.omitBy)(
|
1785
|
-
|
1786
|
-
|
1787
|
-
return true;
|
1765
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1766
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1767
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1768
|
+
return false;
|
1788
1769
|
}
|
1789
|
-
|
1770
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1771
|
+
if (!fieldConfigs.length) {
|
1790
1772
|
return true;
|
1791
1773
|
}
|
1792
|
-
return !isFieldVisible(
|
1774
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1793
1775
|
});
|
1794
1776
|
}
|
1777
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1778
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1779
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1780
|
+
}
|
1795
1781
|
function findActiveDrafts(event2, drafts) {
|
1796
1782
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1797
1783
|
const lastAction = actions[actions.length - 1];
|
@@ -1809,13 +1795,49 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1809
1795
|
annotation: {},
|
1810
1796
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1811
1797
|
createdBy: "@todo",
|
1812
|
-
createdAtLocation: "@todo"
|
1798
|
+
createdAtLocation: "@todo",
|
1799
|
+
status: ActionStatus.Accepted,
|
1800
|
+
transactionId: "@todo",
|
1801
|
+
createdByRole: "@todo"
|
1813
1802
|
}
|
1814
1803
|
};
|
1815
1804
|
}
|
1816
1805
|
function isVerificationPage(page) {
|
1817
1806
|
return page.type === PageTypes.enum.VERIFICATION;
|
1818
1807
|
}
|
1808
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1809
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1810
|
+
}
|
1811
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1812
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1813
|
+
return [
|
1814
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1815
|
+
...getVisibleVerificationPageIds(
|
1816
|
+
actionConfig.additionalDetailsForm,
|
1817
|
+
annotation
|
1818
|
+
)
|
1819
|
+
];
|
1820
|
+
}
|
1821
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1822
|
+
return getVisibleVerificationPageIds(
|
1823
|
+
actionConfig.printForm.pages,
|
1824
|
+
annotation
|
1825
|
+
);
|
1826
|
+
}
|
1827
|
+
return [];
|
1828
|
+
}
|
1829
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1830
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1831
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1832
|
+
actionConfig,
|
1833
|
+
annotation
|
1834
|
+
);
|
1835
|
+
return omitHiddenFields(
|
1836
|
+
annotationFields,
|
1837
|
+
{ ...declaration, ...annotation },
|
1838
|
+
visibleVerificationPageIds
|
1839
|
+
);
|
1840
|
+
}
|
1819
1841
|
function deepMerge(currentDocument, actionDocument) {
|
1820
1842
|
return (0, import_lodash.mergeWith)(
|
1821
1843
|
currentDocument,
|
@@ -1834,19 +1856,57 @@ function deepMerge(currentDocument, actionDocument) {
|
|
1834
1856
|
}
|
1835
1857
|
);
|
1836
1858
|
}
|
1859
|
+
function findLastAssignmentAction(actions) {
|
1860
|
+
return actions.filter(
|
1861
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1862
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1863
|
+
}
|
1864
|
+
function isWriteAction(actionType) {
|
1865
|
+
return writeActions.safeParse(actionType).success;
|
1866
|
+
}
|
1867
|
+
var findAllFields = (config) => {
|
1868
|
+
return (0, import_lodash.flattenDeep)([
|
1869
|
+
...getDeclarationFields(config),
|
1870
|
+
...getAllAnnotationFields(config)
|
1871
|
+
]);
|
1872
|
+
};
|
1873
|
+
function getMixedPath(obj, path, defaultValue) {
|
1874
|
+
const parts = path.split(".");
|
1875
|
+
const resolve = (current, segments) => {
|
1876
|
+
if (current == null || segments.length === 0) {
|
1877
|
+
return current;
|
1878
|
+
}
|
1879
|
+
for (let i = segments.length; i > 0; i--) {
|
1880
|
+
const compoundKey = segments.slice(0, i).join(".");
|
1881
|
+
if ((0, import_lodash.has)(current, compoundKey)) {
|
1882
|
+
const next = (0, import_lodash.get)(current, compoundKey);
|
1883
|
+
return resolve(next, segments.slice(i));
|
1884
|
+
}
|
1885
|
+
}
|
1886
|
+
return void 0;
|
1887
|
+
};
|
1888
|
+
const result = resolve(obj, parts);
|
1889
|
+
return (0, import_lodash.isNil)(result) ? defaultValue : result;
|
1890
|
+
}
|
1837
1891
|
|
1838
1892
|
// ../commons/src/events/EventConfig.ts
|
1839
|
-
var
|
1840
|
-
|
1893
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1894
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
|
1895
|
+
var EventConfig = import_zod17.z.object({
|
1896
|
+
id: import_zod17.z.string().describe(
|
1841
1897
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1842
1898
|
),
|
1899
|
+
dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
|
1900
|
+
title: TranslationConfig,
|
1901
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1902
|
+
"This is a fallback title if actual title resolves to empty string"
|
1903
|
+
),
|
1843
1904
|
summary: SummaryConfig,
|
1844
1905
|
label: TranslationConfig,
|
1845
|
-
actions:
|
1906
|
+
actions: import_zod17.z.array(ActionConfig),
|
1846
1907
|
declaration: DeclarationFormConfig,
|
1847
|
-
|
1848
|
-
|
1849
|
-
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1908
|
+
deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
|
1909
|
+
advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
|
1850
1910
|
}).superRefine((event2, ctx) => {
|
1851
1911
|
const allFields = findAllFields(event2);
|
1852
1912
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1862,16 +1922,43 @@ var EventConfig = import_zod20.z.object({
|
|
1862
1922
|
});
|
1863
1923
|
}
|
1864
1924
|
const invalidFields = event2.advancedSearch.flatMap(
|
1865
|
-
(section) =>
|
1925
|
+
(section) => (
|
1926
|
+
// Check if the fieldId is not in the fieldIds array
|
1927
|
+
// and also not in the metadataFields array
|
1928
|
+
section.fields.filter(
|
1929
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
1930
|
+
)
|
1931
|
+
)
|
1866
1932
|
);
|
1867
1933
|
if (invalidFields.length > 0) {
|
1868
1934
|
ctx.addIssue({
|
1869
1935
|
code: "custom",
|
1870
|
-
message: `Advanced search id must match a field id
|
1936
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1871
1937
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1872
1938
|
path: ["advancedSearch"]
|
1873
1939
|
});
|
1874
1940
|
}
|
1941
|
+
if (event2.dateOfEvent) {
|
1942
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
1943
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
1944
|
+
);
|
1945
|
+
if (!eventDateFieldId) {
|
1946
|
+
ctx.addIssue({
|
1947
|
+
code: "custom",
|
1948
|
+
message: `Date of event field id must match a field id in fields array.
|
1949
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
1950
|
+
path: ["dateOfEvent"]
|
1951
|
+
});
|
1952
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
1953
|
+
ctx.addIssue({
|
1954
|
+
code: "custom",
|
1955
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
1956
|
+
path: ["dateOfEvent.fieldType"]
|
1957
|
+
});
|
1958
|
+
}
|
1959
|
+
}
|
1960
|
+
}).openapi({
|
1961
|
+
ref: "EventConfig"
|
1875
1962
|
});
|
1876
1963
|
|
1877
1964
|
// ../commons/src/events/EventConfigInput.ts
|
@@ -1880,498 +1967,216 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
|
1880
1967
|
var definePage = (page) => PageConfig.parse(page);
|
1881
1968
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1882
1969
|
|
1883
|
-
// ../commons/src/events/
|
1884
|
-
var
|
1970
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1971
|
+
var import_zod20 = require("zod");
|
1885
1972
|
|
1886
|
-
// ../commons/src/events/
|
1887
|
-
var
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1973
|
+
// ../commons/src/events/EventIndex.ts
|
1974
|
+
var import_zod19 = require("zod");
|
1975
|
+
|
1976
|
+
// ../commons/src/events/EventMetadata.ts
|
1977
|
+
var import_zod18 = require("zod");
|
1978
|
+
var EventStatus = {
|
1979
|
+
CREATED: "CREATED",
|
1980
|
+
NOTIFIED: "NOTIFIED",
|
1981
|
+
DECLARED: "DECLARED",
|
1982
|
+
VALIDATED: "VALIDATED",
|
1983
|
+
REGISTERED: "REGISTERED",
|
1984
|
+
CERTIFIED: "CERTIFIED",
|
1985
|
+
REJECTED: "REJECTED",
|
1986
|
+
ARCHIVED: "ARCHIVED"
|
1893
1987
|
};
|
1894
|
-
var
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1988
|
+
var CustomFlags = {
|
1989
|
+
CERTIFICATE_PRINTED: "certificate-printed"
|
1990
|
+
};
|
1991
|
+
var Flag = import_zod18.z.string().regex(
|
1992
|
+
new RegExp(
|
1993
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
|
1994
|
+
),
|
1995
|
+
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
1996
|
+
).or(import_zod18.z.nativeEnum(CustomFlags));
|
1997
|
+
var eventStatuses = Object.values(EventStatus);
|
1998
|
+
var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
|
1999
|
+
var ZodDate = import_zod18.z.string().date();
|
2000
|
+
var ActionCreationMetadata = import_zod18.z.object({
|
2001
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
|
2002
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
|
2003
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
|
2004
|
+
acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
|
2005
|
+
createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
|
1908
2006
|
});
|
1909
|
-
var
|
1910
|
-
|
1911
|
-
|
1912
|
-
assignedTo: import_zod21.z.string()
|
1913
|
-
})
|
1914
|
-
);
|
1915
|
-
var UnassignedAction = ActionBase.merge(
|
1916
|
-
import_zod21.z.object({
|
1917
|
-
type: import_zod21.z.literal(ActionType.UNASSIGN)
|
1918
|
-
})
|
1919
|
-
);
|
1920
|
-
var RegisterAction = ActionBase.merge(
|
1921
|
-
import_zod21.z.object({
|
1922
|
-
type: import_zod21.z.literal(ActionType.REGISTER),
|
1923
|
-
registrationNumber: import_zod21.z.string().optional()
|
1924
|
-
})
|
1925
|
-
);
|
1926
|
-
var DeclareAction = ActionBase.merge(
|
1927
|
-
import_zod21.z.object({
|
1928
|
-
type: import_zod21.z.literal(ActionType.DECLARE)
|
1929
|
-
})
|
1930
|
-
);
|
1931
|
-
var ValidateAction = ActionBase.merge(
|
1932
|
-
import_zod21.z.object({
|
1933
|
-
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1934
|
-
})
|
1935
|
-
);
|
1936
|
-
var RejectAction = ActionBase.merge(
|
1937
|
-
import_zod21.z.object({
|
1938
|
-
type: import_zod21.z.literal(ActionType.REJECT)
|
1939
|
-
})
|
1940
|
-
);
|
1941
|
-
var MarkAsDuplicateAction = ActionBase.merge(
|
1942
|
-
import_zod21.z.object({
|
1943
|
-
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1944
|
-
})
|
1945
|
-
);
|
1946
|
-
var ArchiveAction = ActionBase.merge(
|
1947
|
-
import_zod21.z.object({
|
1948
|
-
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1949
|
-
})
|
1950
|
-
);
|
1951
|
-
var CreatedAction = ActionBase.merge(
|
1952
|
-
import_zod21.z.object({
|
1953
|
-
type: import_zod21.z.literal(ActionType.CREATE)
|
1954
|
-
})
|
1955
|
-
);
|
1956
|
-
var NotifiedAction = ActionBase.merge(
|
1957
|
-
import_zod21.z.object({
|
1958
|
-
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1959
|
-
})
|
1960
|
-
);
|
1961
|
-
var PrintCertificateAction = ActionBase.merge(
|
1962
|
-
import_zod21.z.object({
|
1963
|
-
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1964
|
-
})
|
1965
|
-
);
|
1966
|
-
var RequestedCorrectionAction = ActionBase.merge(
|
1967
|
-
import_zod21.z.object({
|
1968
|
-
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1969
|
-
})
|
1970
|
-
);
|
1971
|
-
var ApprovedCorrectionAction = ActionBase.merge(
|
1972
|
-
import_zod21.z.object({
|
1973
|
-
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1974
|
-
requestId: import_zod21.z.string()
|
1975
|
-
})
|
1976
|
-
);
|
1977
|
-
var RejectedCorrectionAction = ActionBase.merge(
|
1978
|
-
import_zod21.z.object({
|
1979
|
-
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1980
|
-
requestId: import_zod21.z.string()
|
1981
|
-
})
|
1982
|
-
);
|
1983
|
-
var ReadAction = ActionBase.merge(
|
1984
|
-
import_zod21.z.object({
|
1985
|
-
type: import_zod21.z.literal(ActionType.READ)
|
1986
|
-
})
|
1987
|
-
);
|
1988
|
-
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1989
|
-
CreatedAction,
|
1990
|
-
ValidateAction,
|
1991
|
-
RejectAction,
|
1992
|
-
MarkAsDuplicateAction,
|
1993
|
-
ArchiveAction,
|
1994
|
-
NotifiedAction,
|
1995
|
-
RegisterAction,
|
1996
|
-
DeclareAction,
|
1997
|
-
AssignedAction,
|
1998
|
-
RequestedCorrectionAction,
|
1999
|
-
ApprovedCorrectionAction,
|
2000
|
-
RejectedCorrectionAction,
|
2001
|
-
UnassignedAction,
|
2002
|
-
PrintCertificateAction,
|
2003
|
-
ReadAction
|
2004
|
-
]);
|
2005
|
-
var AsyncRejectActionDocument = ActionBase.omit({
|
2006
|
-
declaration: true,
|
2007
|
-
annotation: true,
|
2008
|
-
createdBy: true,
|
2009
|
-
createdAtLocation: true
|
2010
|
-
}).merge(
|
2011
|
-
import_zod21.z.object({
|
2012
|
-
type: import_zod21.z.enum(ConfirmableActions),
|
2013
|
-
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2014
|
-
})
|
2015
|
-
);
|
2016
|
-
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2017
|
-
var ResolvedUser = import_zod21.z.object({
|
2018
|
-
id: import_zod21.z.string(),
|
2019
|
-
role: import_zod21.z.string(),
|
2020
|
-
name: import_zod21.z.array(
|
2021
|
-
import_zod21.z.object({
|
2022
|
-
use: import_zod21.z.string(),
|
2023
|
-
given: import_zod21.z.array(import_zod21.z.string()),
|
2024
|
-
family: import_zod21.z.string()
|
2025
|
-
})
|
2007
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2008
|
+
registrationNumber: import_zod18.z.string().describe(
|
2009
|
+
"Registration number of the event. Always present for accepted registrations."
|
2026
2010
|
)
|
2027
2011
|
});
|
2012
|
+
var LegalStatuses = import_zod18.z.object({
|
2013
|
+
[EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
|
2014
|
+
[EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
|
2015
|
+
});
|
2016
|
+
var EventMetadata = import_zod18.z.object({
|
2017
|
+
id: import_zod18.z.string(),
|
2018
|
+
type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
|
2019
|
+
status: EventStatuses,
|
2020
|
+
legalStatuses: LegalStatuses.describe(
|
2021
|
+
"Metadata related to the legal registration of the event, such as who registered it and when."
|
2022
|
+
),
|
2023
|
+
createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
|
2024
|
+
dateOfEvent: ZodDate.nullish(),
|
2025
|
+
createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
|
2026
|
+
updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
|
2027
|
+
createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
|
2028
|
+
updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
|
2029
|
+
updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
|
2030
|
+
assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
|
2031
|
+
updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
|
2032
|
+
trackingId: import_zod18.z.string().describe(
|
2033
|
+
"System-generated tracking ID used by informants or registrars to look up the event."
|
2034
|
+
),
|
2035
|
+
flags: import_zod18.z.array(Flag)
|
2036
|
+
});
|
2037
|
+
var EventMetadataKeys = import_zod18.z.enum([
|
2038
|
+
"id",
|
2039
|
+
"type",
|
2040
|
+
"status",
|
2041
|
+
"createdAt",
|
2042
|
+
"dateOfEvent",
|
2043
|
+
"createdBy",
|
2044
|
+
"updatedByUserRole",
|
2045
|
+
"createdAtLocation",
|
2046
|
+
"updatedAtLocation",
|
2047
|
+
"updatedAt",
|
2048
|
+
"assignedTo",
|
2049
|
+
"updatedBy",
|
2050
|
+
"trackingId",
|
2051
|
+
"legalStatuses",
|
2052
|
+
"flags"
|
2053
|
+
]);
|
2054
|
+
var EventMetadataParameter = import_zod18.z.object({
|
2055
|
+
// @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
|
2056
|
+
$event: EventMetadataKeys
|
2057
|
+
});
|
2058
|
+
var eventMetadataLabelMap = {
|
2059
|
+
"event.assignedTo": {
|
2060
|
+
id: "event.assignedTo.label",
|
2061
|
+
defaultMessage: "Assigned To",
|
2062
|
+
description: "Assigned To"
|
2063
|
+
},
|
2064
|
+
"event.createdAt": {
|
2065
|
+
id: "event.createdAt.label",
|
2066
|
+
defaultMessage: "Created",
|
2067
|
+
description: "Created At"
|
2068
|
+
},
|
2069
|
+
"event.dateOfEvent": {
|
2070
|
+
id: "event.dateOfEvent.label",
|
2071
|
+
defaultMessage: "Date of Event",
|
2072
|
+
description: "Date of Event"
|
2073
|
+
},
|
2074
|
+
"event.createdAtLocation": {
|
2075
|
+
id: "event.createdAtLocation.label",
|
2076
|
+
defaultMessage: "Location",
|
2077
|
+
description: "Created At Location"
|
2078
|
+
},
|
2079
|
+
"event.updatedAtLocation": {
|
2080
|
+
id: "event.updatedAtLocation.label",
|
2081
|
+
defaultMessage: "Location",
|
2082
|
+
description: "Updated At Location"
|
2083
|
+
},
|
2084
|
+
"event.createdBy": {
|
2085
|
+
id: "event.createdBy.label",
|
2086
|
+
defaultMessage: "Created By",
|
2087
|
+
description: "Created By"
|
2088
|
+
},
|
2089
|
+
"event.updatedByUserRole": {
|
2090
|
+
id: "event.updatedByUserRole.label",
|
2091
|
+
defaultMessage: "Updated By Role",
|
2092
|
+
description: "Updated By Role"
|
2093
|
+
},
|
2094
|
+
"event.id": {
|
2095
|
+
id: "event.id.label",
|
2096
|
+
defaultMessage: "ID",
|
2097
|
+
description: "ID"
|
2098
|
+
},
|
2099
|
+
"event.updatedAt": {
|
2100
|
+
id: "event.modifiedAt.label",
|
2101
|
+
defaultMessage: "Updated",
|
2102
|
+
description: "Modified At"
|
2103
|
+
},
|
2104
|
+
"event.status": {
|
2105
|
+
id: "event.status.label",
|
2106
|
+
defaultMessage: "Status",
|
2107
|
+
description: "Status"
|
2108
|
+
},
|
2109
|
+
"event.type": {
|
2110
|
+
id: "event.type.label",
|
2111
|
+
defaultMessage: "Type",
|
2112
|
+
description: "Type"
|
2113
|
+
},
|
2114
|
+
"event.updatedBy": {
|
2115
|
+
id: "event.updatedBy.label",
|
2116
|
+
defaultMessage: "Updated By",
|
2117
|
+
description: "Updated By"
|
2118
|
+
},
|
2119
|
+
"event.trackingId": {
|
2120
|
+
id: "event.trackingId.label",
|
2121
|
+
defaultMessage: "Tracking ID",
|
2122
|
+
description: "Tracking ID"
|
2123
|
+
},
|
2124
|
+
"event.flags": {
|
2125
|
+
id: "event.flags.label",
|
2126
|
+
defaultMessage: "Flags",
|
2127
|
+
description: "Flags"
|
2128
|
+
}
|
2129
|
+
};
|
2028
2130
|
|
2029
|
-
// ../commons/src/events/
|
2030
|
-
var
|
2031
|
-
|
2032
|
-
eventId: import_zod22.z.string(),
|
2033
|
-
transactionId: import_zod22.z.string(),
|
2034
|
-
declaration: ActionUpdate.default({}),
|
2035
|
-
annotation: ActionUpdate.optional(),
|
2036
|
-
originalActionId: import_zod22.z.string().optional()
|
2131
|
+
// ../commons/src/events/EventIndex.ts
|
2132
|
+
var EventIndex = EventMetadata.extend({
|
2133
|
+
declaration: EventState
|
2037
2134
|
});
|
2038
|
-
var
|
2039
|
-
|
2040
|
-
type:
|
2041
|
-
|
2042
|
-
})
|
2043
|
-
);
|
2044
|
-
var RegisterActionInput = BaseActionInput.merge(
|
2045
|
-
import_zod22.z.object({
|
2046
|
-
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2047
|
-
registrationNumber: import_zod22.z.string().optional()
|
2048
|
-
})
|
2049
|
-
);
|
2050
|
-
var ValidateActionInput = BaseActionInput.merge(
|
2051
|
-
import_zod22.z.object({
|
2052
|
-
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2053
|
-
duplicates: import_zod22.z.array(import_zod22.z.string())
|
2054
|
-
})
|
2055
|
-
);
|
2056
|
-
var NotifyActionInput = BaseActionInput.merge(
|
2057
|
-
import_zod22.z.object({
|
2058
|
-
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2059
|
-
})
|
2060
|
-
);
|
2061
|
-
var DeclareActionInput = BaseActionInput.merge(
|
2062
|
-
import_zod22.z.object({
|
2063
|
-
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2064
|
-
})
|
2065
|
-
);
|
2066
|
-
var PrintCertificateActionInput = BaseActionInput.merge(
|
2067
|
-
import_zod22.z.object({
|
2068
|
-
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2069
|
-
})
|
2070
|
-
);
|
2071
|
-
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2072
|
-
import_zod22.z.object({
|
2073
|
-
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2074
|
-
})
|
2075
|
-
);
|
2076
|
-
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2077
|
-
import_zod22.z.object({
|
2078
|
-
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2079
|
-
})
|
2080
|
-
);
|
2081
|
-
var ArchiveActionInput = BaseActionInput.merge(
|
2082
|
-
import_zod22.z.object({
|
2083
|
-
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2084
|
-
})
|
2085
|
-
);
|
2086
|
-
var AssignActionInput = BaseActionInput.merge(
|
2087
|
-
import_zod22.z.object({
|
2088
|
-
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2089
|
-
assignedTo: import_zod22.z.string()
|
2135
|
+
var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
|
2136
|
+
import_zod19.z.object({
|
2137
|
+
type: import_zod19.z.string()
|
2138
|
+
// Ensures "type" (event-id) exists and is a string
|
2090
2139
|
})
|
2091
2140
|
);
|
2092
|
-
var
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2141
|
+
var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
|
2142
|
+
var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
|
2143
|
+
var AnyOf = import_zod19.z.object({
|
2144
|
+
type: import_zod19.z.literal("anyOf"),
|
2145
|
+
terms: import_zod19.z.array(import_zod19.z.string())
|
2146
|
+
});
|
2147
|
+
var Range = import_zod19.z.object({
|
2148
|
+
type: import_zod19.z.literal("range"),
|
2149
|
+
gte: import_zod19.z.string(),
|
2150
|
+
lte: import_zod19.z.string()
|
2151
|
+
});
|
2152
|
+
var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
|
2153
|
+
var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
|
2154
|
+
var DateCondition = import_zod19.z.union([Exact, Range]);
|
2155
|
+
var QueryInput = import_zod19.z.lazy(
|
2156
|
+
() => import_zod19.z.union([
|
2157
|
+
import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
|
2158
|
+
import_zod19.z.record(import_zod19.z.string(), QueryInput)
|
2159
|
+
])
|
2097
2160
|
);
|
2098
|
-
var
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
)
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
)
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
)
|
2115
|
-
var ReadActionInput = BaseActionInput.merge(
|
2116
|
-
import_zod22.z.object({
|
2117
|
-
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2118
|
-
})
|
2119
|
-
);
|
2120
|
-
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2121
|
-
CreateActionInput,
|
2122
|
-
ValidateActionInput,
|
2123
|
-
RegisterActionInput,
|
2124
|
-
NotifyActionInput,
|
2125
|
-
DeclareActionInput,
|
2126
|
-
RejectDeclarationActionInput,
|
2127
|
-
MarkedAsDuplicateActionInput,
|
2128
|
-
ArchiveActionInput,
|
2129
|
-
AssignActionInput,
|
2130
|
-
UnassignActionInput,
|
2131
|
-
PrintCertificateActionInput,
|
2132
|
-
RequestCorrectionActionInput,
|
2133
|
-
RejectCorrectionActionInput,
|
2134
|
-
ApproveCorrectionActionInput,
|
2135
|
-
ReadActionInput
|
2136
|
-
]);
|
2137
|
-
|
2138
|
-
// ../commons/src/events/Draft.ts
|
2139
|
-
var Draft = import_zod23.z.object({
|
2140
|
-
id: import_zod23.z.string(),
|
2141
|
-
eventId: import_zod23.z.string(),
|
2142
|
-
transactionId: import_zod23.z.string(),
|
2143
|
-
createdAt: import_zod23.z.string().datetime(),
|
2144
|
-
action: ActionBase.extend({
|
2145
|
-
type: ActionTypes
|
2146
|
-
}).omit({ id: true })
|
2147
|
-
});
|
2148
|
-
var DraftInput = BaseActionInput.extend({
|
2149
|
-
type: ActionTypes
|
2150
|
-
});
|
2151
|
-
|
2152
|
-
// ../commons/src/events/EventInput.ts
|
2153
|
-
var import_zod24 = require("zod");
|
2154
|
-
var EventInput = import_zod24.z.object({
|
2155
|
-
transactionId: import_zod24.z.string(),
|
2156
|
-
type: import_zod24.z.string()
|
2157
|
-
});
|
2158
|
-
|
2159
|
-
// ../commons/src/events/EventDocument.ts
|
2160
|
-
var import_zod25 = require("zod");
|
2161
|
-
var EventDocument = import_zod25.z.object({
|
2162
|
-
id: import_zod25.z.string(),
|
2163
|
-
type: import_zod25.z.string(),
|
2164
|
-
createdAt: import_zod25.z.string().datetime(),
|
2165
|
-
updatedAt: import_zod25.z.string().datetime(),
|
2166
|
-
updatedAtLocation: import_zod25.z.string(),
|
2167
|
-
actions: import_zod25.z.array(Action),
|
2168
|
-
trackingId: import_zod25.z.string()
|
2169
|
-
});
|
2170
|
-
|
2171
|
-
// ../commons/src/events/EventIndex.ts
|
2172
|
-
var import_zod26 = require("zod");
|
2173
|
-
var EventIndex = EventMetadata.extend({
|
2174
|
-
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2161
|
+
var QueryExpression = import_zod19.z.object({
|
2162
|
+
type: import_zod19.z.literal("and"),
|
2163
|
+
eventType: import_zod19.z.string(),
|
2164
|
+
status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
|
2165
|
+
createdAt: import_zod19.z.optional(DateCondition),
|
2166
|
+
updatedAt: import_zod19.z.optional(DateCondition),
|
2167
|
+
createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2168
|
+
updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
|
2169
|
+
createdBy: import_zod19.z.optional(Exact),
|
2170
|
+
updatedBy: import_zod19.z.optional(Exact),
|
2171
|
+
trackingId: import_zod19.z.optional(Exact),
|
2172
|
+
flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
|
2173
|
+
data: QueryInput
|
2174
|
+
}).partial();
|
2175
|
+
var Or2 = import_zod19.z.object({
|
2176
|
+
type: import_zod19.z.literal("or"),
|
2177
|
+
clauses: import_zod19.z.array(QueryExpression)
|
2175
2178
|
});
|
2176
|
-
var
|
2177
|
-
import_zod26.z.object({
|
2178
|
-
type: import_zod26.z.string()
|
2179
|
-
// Ensures "type" (event-id) exists and is a string
|
2180
|
-
})
|
2181
|
-
);
|
2182
|
-
|
2183
|
-
// ../commons/src/events/state/index.ts
|
2184
|
-
function getStatusFromActions(actions) {
|
2185
|
-
const hasRejectedAction = actions.some(
|
2186
|
-
(a) => a.status === ActionStatus.Rejected
|
2187
|
-
);
|
2188
|
-
if (hasRejectedAction) {
|
2189
|
-
return EventStatus.REJECTED;
|
2190
|
-
}
|
2191
|
-
return actions.reduce((status, action) => {
|
2192
|
-
if (action.type === ActionType.CREATE) {
|
2193
|
-
return EventStatus.CREATED;
|
2194
|
-
}
|
2195
|
-
if (action.type === ActionType.DECLARE) {
|
2196
|
-
return EventStatus.DECLARED;
|
2197
|
-
}
|
2198
|
-
if (action.type === ActionType.VALIDATE) {
|
2199
|
-
return EventStatus.VALIDATED;
|
2200
|
-
}
|
2201
|
-
if (action.type === ActionType.REGISTER) {
|
2202
|
-
return EventStatus.REGISTERED;
|
2203
|
-
}
|
2204
|
-
if (action.type === ActionType.REJECT) {
|
2205
|
-
return EventStatus.REJECTED;
|
2206
|
-
}
|
2207
|
-
if (action.type === ActionType.ARCHIVE) {
|
2208
|
-
return EventStatus.ARCHIVED;
|
2209
|
-
}
|
2210
|
-
if (action.type === ActionType.NOTIFY) {
|
2211
|
-
return EventStatus.NOTIFIED;
|
2212
|
-
}
|
2213
|
-
return status;
|
2214
|
-
}, EventStatus.CREATED);
|
2215
|
-
}
|
2216
|
-
function getAssignedUserFromActions(actions) {
|
2217
|
-
return actions.reduce((user2, action) => {
|
2218
|
-
if (action.type === ActionType.ASSIGN) {
|
2219
|
-
return action.assignedTo;
|
2220
|
-
}
|
2221
|
-
if (action.type === ActionType.UNASSIGN) {
|
2222
|
-
return null;
|
2223
|
-
}
|
2224
|
-
return user2;
|
2225
|
-
}, null);
|
2226
|
-
}
|
2227
|
-
function aggregateActionDeclarations(actions) {
|
2228
|
-
const excludedActions = [
|
2229
|
-
ActionType.REQUEST_CORRECTION,
|
2230
|
-
ActionType.PRINT_CERTIFICATE
|
2231
|
-
];
|
2232
|
-
return actions.reduce((status, action) => {
|
2233
|
-
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2234
|
-
return status;
|
2235
|
-
}
|
2236
|
-
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2237
|
-
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2238
|
-
if (!requestAction) {
|
2239
|
-
return status;
|
2240
|
-
}
|
2241
|
-
return deepMerge(status, requestAction.declaration);
|
2242
|
-
}
|
2243
|
-
return deepMerge(status, action.declaration);
|
2244
|
-
}, {});
|
2245
|
-
}
|
2246
|
-
function deepDropNulls(obj) {
|
2247
|
-
if (Array.isArray(obj)) {
|
2248
|
-
return obj;
|
2249
|
-
}
|
2250
|
-
if (obj !== null && typeof obj === "object") {
|
2251
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2252
|
-
const cleanedValue = deepDropNulls(value);
|
2253
|
-
if (cleanedValue !== null) {
|
2254
|
-
;
|
2255
|
-
acc[key] = cleanedValue;
|
2256
|
-
}
|
2257
|
-
return acc;
|
2258
|
-
}, {});
|
2259
|
-
}
|
2260
|
-
return obj;
|
2261
|
-
}
|
2262
|
-
function isUndeclaredDraft(status) {
|
2263
|
-
return status === EventStatus.CREATED;
|
2264
|
-
}
|
2265
|
-
function getAcceptedActions(event2) {
|
2266
|
-
return event2.actions.filter(
|
2267
|
-
(a) => a.status === ActionStatus.Accepted
|
2268
|
-
);
|
2269
|
-
}
|
2270
|
-
function getCurrentEventState(event2) {
|
2271
|
-
const creationAction = event2.actions.find(
|
2272
|
-
(action) => action.type === ActionType.CREATE
|
2273
|
-
);
|
2274
|
-
if (!creationAction) {
|
2275
|
-
throw new Error(`Event ${event2.id} has no creation action`);
|
2276
|
-
}
|
2277
|
-
const activeActions = getAcceptedActions(event2);
|
2278
|
-
const latestAction = activeActions[activeActions.length - 1];
|
2279
|
-
const registrationAction = activeActions.find(
|
2280
|
-
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2281
|
-
);
|
2282
|
-
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2283
|
-
return deepDropNulls({
|
2284
|
-
id: event2.id,
|
2285
|
-
type: event2.type,
|
2286
|
-
status: getStatusFromActions(event2.actions),
|
2287
|
-
createdAt: event2.createdAt,
|
2288
|
-
createdBy: creationAction.createdBy,
|
2289
|
-
createdAtLocation: creationAction.createdAtLocation,
|
2290
|
-
modifiedAt: latestAction.createdAt,
|
2291
|
-
assignedTo: getAssignedUserFromActions(activeActions),
|
2292
|
-
updatedBy: latestAction.createdBy,
|
2293
|
-
updatedAtLocation: event2.updatedAtLocation,
|
2294
|
-
declaration: aggregateActionDeclarations(activeActions),
|
2295
|
-
trackingId: event2.trackingId,
|
2296
|
-
registrationNumber
|
2297
|
-
});
|
2298
|
-
}
|
2299
|
-
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2300
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2301
|
-
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2302
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2303
|
-
return [
|
2304
|
-
action,
|
2305
|
-
{
|
2306
|
-
...action,
|
2307
|
-
type: ActionType.APPROVE_CORRECTION
|
2308
|
-
}
|
2309
|
-
];
|
2310
|
-
}
|
2311
|
-
return [action];
|
2312
|
-
});
|
2313
|
-
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2314
|
-
const withDrafts = {
|
2315
|
-
...event2,
|
2316
|
-
actions: actionWithDrafts
|
2317
|
-
};
|
2318
|
-
return getCurrentEventState(withDrafts);
|
2319
|
-
}
|
2320
|
-
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2321
|
-
const indexedAt = eventIndex.modifiedAt;
|
2322
|
-
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2323
|
-
if (activeDrafts.length === 0) {
|
2324
|
-
return eventIndex;
|
2325
|
-
}
|
2326
|
-
return {
|
2327
|
-
...eventIndex,
|
2328
|
-
declaration: {
|
2329
|
-
...eventIndex.declaration,
|
2330
|
-
...activeDrafts[activeDrafts.length - 1].declaration
|
2331
|
-
}
|
2332
|
-
};
|
2333
|
-
}
|
2334
|
-
function getAnnotationFromDrafts(drafts) {
|
2335
|
-
const actions = drafts.map((draft) => draft.action);
|
2336
|
-
const annotation = actions.reduce((ann, action) => {
|
2337
|
-
return deepMerge(ann, action.annotation ?? {});
|
2338
|
-
}, {});
|
2339
|
-
return deepDropNulls(annotation);
|
2340
|
-
}
|
2341
|
-
function getActionAnnotation({
|
2342
|
-
event: event2,
|
2343
|
-
actionType,
|
2344
|
-
drafts
|
2345
|
-
}) {
|
2346
|
-
const activeActions = getAcceptedActions(event2);
|
2347
|
-
const action = activeActions.find(
|
2348
|
-
(activeAction) => actionType === activeAction.type
|
2349
|
-
);
|
2350
|
-
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2351
|
-
const sorted = [
|
2352
|
-
...action ? [action] : [],
|
2353
|
-
...eventDrafts.map((draft) => draft.action)
|
2354
|
-
].sort();
|
2355
|
-
const annotation = sorted.reduce((ann, sortedAction) => {
|
2356
|
-
return deepMerge(ann, sortedAction.annotation ?? {});
|
2357
|
-
}, {});
|
2358
|
-
return deepDropNulls(annotation);
|
2359
|
-
}
|
2360
|
-
|
2361
|
-
// ../commons/src/events/defineConfig.ts
|
2362
|
-
var defineConfig = (config) => {
|
2363
|
-
validateWorkqueueConfig(config.workqueues);
|
2364
|
-
const input = EventConfig.parse(config);
|
2365
|
-
return input;
|
2366
|
-
};
|
2367
|
-
|
2368
|
-
// ../commons/src/events/transactions.ts
|
2369
|
-
function generateTransactionId() {
|
2370
|
-
return getUUID();
|
2371
|
-
}
|
2372
|
-
|
2373
|
-
// ../commons/src/events/test.utils.ts
|
2374
|
-
var import_lodash2 = require("lodash");
|
2179
|
+
var QueryType = import_zod19.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
2375
2180
|
|
2376
2181
|
// ../commons/src/conditionals/conditionals.ts
|
2377
2182
|
function defineConditional(schema) {
|
@@ -2435,32 +2240,38 @@ var user = {
|
|
2435
2240
|
required: ["$user"]
|
2436
2241
|
})
|
2437
2242
|
};
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2243
|
+
function createEventConditionals() {
|
2244
|
+
return {
|
2245
|
+
/**
|
2246
|
+
* Checks if the event contains a specific action type.
|
2247
|
+
* @param action - The action type to check for.
|
2248
|
+
*/
|
2249
|
+
hasAction: (action) => defineConditional({
|
2250
|
+
type: "object",
|
2251
|
+
properties: {
|
2252
|
+
$event: {
|
2253
|
+
type: "object",
|
2254
|
+
properties: {
|
2255
|
+
actions: {
|
2256
|
+
type: "array",
|
2257
|
+
contains: {
|
2258
|
+
type: "object",
|
2259
|
+
properties: {
|
2260
|
+
type: {
|
2261
|
+
const: action
|
2262
|
+
}
|
2263
|
+
},
|
2264
|
+
required: ["type"]
|
2265
|
+
}
|
2455
2266
|
}
|
2456
|
-
}
|
2457
|
-
|
2458
|
-
|
2459
|
-
}
|
2460
|
-
|
2461
|
-
|
2462
|
-
}
|
2463
|
-
}
|
2267
|
+
},
|
2268
|
+
required: ["actions"]
|
2269
|
+
}
|
2270
|
+
},
|
2271
|
+
required: ["$event"]
|
2272
|
+
})
|
2273
|
+
};
|
2274
|
+
}
|
2464
2275
|
function getDateFromNow(days) {
|
2465
2276
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2466
2277
|
}
|
@@ -2481,7 +2292,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
|
2481
2292
|
function isFieldReference(value) {
|
2482
2293
|
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2483
2294
|
}
|
2484
|
-
function
|
2295
|
+
function createFieldConditionals(fieldId) {
|
2485
2296
|
const getDateRange = (date, clause) => ({
|
2486
2297
|
type: "object",
|
2487
2298
|
properties: {
|
@@ -2494,10 +2305,6 @@ function field(fieldId) {
|
|
2494
2305
|
required: [fieldId]
|
2495
2306
|
});
|
2496
2307
|
return {
|
2497
|
-
/**
|
2498
|
-
* @private Internal property used for field reference tracking.
|
2499
|
-
*/
|
2500
|
-
_fieldId: fieldId,
|
2501
2308
|
isAfter: () => ({
|
2502
2309
|
days: (days) => ({
|
2503
2310
|
inPast: () => defineFormConditional(
|
@@ -2576,98 +2383,691 @@ function field(fieldId) {
|
|
2576
2383
|
});
|
2577
2384
|
},
|
2578
2385
|
/**
|
2579
|
-
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2580
|
-
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
2581
|
-
* @returns whether the field is falsy (undefined, false, null, empty string)
|
2386
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2387
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
2388
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
2389
|
+
*
|
2390
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2391
|
+
*
|
2392
|
+
*/
|
2393
|
+
isFalsy: () => defineFormConditional({
|
2394
|
+
type: "object",
|
2395
|
+
properties: {
|
2396
|
+
[fieldId]: {
|
2397
|
+
anyOf: [
|
2398
|
+
{ const: "undefined" },
|
2399
|
+
{ const: false },
|
2400
|
+
{ const: null },
|
2401
|
+
{ const: "" }
|
2402
|
+
]
|
2403
|
+
}
|
2404
|
+
},
|
2405
|
+
anyOf: [
|
2406
|
+
{
|
2407
|
+
required: [fieldId]
|
2408
|
+
},
|
2409
|
+
{
|
2410
|
+
not: {
|
2411
|
+
required: [fieldId]
|
2412
|
+
}
|
2413
|
+
}
|
2414
|
+
]
|
2415
|
+
}),
|
2416
|
+
isUndefined: () => defineFormConditional({
|
2417
|
+
type: "object",
|
2418
|
+
properties: {
|
2419
|
+
[fieldId]: {
|
2420
|
+
type: "string",
|
2421
|
+
enum: ["undefined"]
|
2422
|
+
}
|
2423
|
+
},
|
2424
|
+
not: {
|
2425
|
+
required: [fieldId]
|
2426
|
+
}
|
2427
|
+
}),
|
2428
|
+
inArray: (values) => defineFormConditional({
|
2429
|
+
type: "object",
|
2430
|
+
properties: {
|
2431
|
+
[fieldId]: {
|
2432
|
+
type: "string",
|
2433
|
+
enum: values
|
2434
|
+
}
|
2435
|
+
},
|
2436
|
+
required: [fieldId]
|
2437
|
+
}),
|
2438
|
+
isValidEnglishName: () => defineFormConditional({
|
2439
|
+
type: "object",
|
2440
|
+
properties: {
|
2441
|
+
[fieldId]: {
|
2442
|
+
type: "string",
|
2443
|
+
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'._-]*)*$",
|
2444
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2445
|
+
}
|
2446
|
+
},
|
2447
|
+
required: [fieldId]
|
2448
|
+
}),
|
2449
|
+
/**
|
2450
|
+
* Checks if the field value matches a given regular expression pattern.
|
2451
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2452
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2453
|
+
*/
|
2454
|
+
matches: (pattern) => defineFormConditional({
|
2455
|
+
type: "object",
|
2456
|
+
properties: {
|
2457
|
+
[fieldId]: {
|
2458
|
+
type: "string",
|
2459
|
+
pattern
|
2460
|
+
}
|
2461
|
+
},
|
2462
|
+
required: [fieldId]
|
2463
|
+
}),
|
2464
|
+
isBetween: (min, max) => defineFormConditional({
|
2465
|
+
type: "object",
|
2466
|
+
properties: {
|
2467
|
+
[fieldId]: {
|
2468
|
+
type: "number",
|
2469
|
+
minimum: min,
|
2470
|
+
maximum: max
|
2471
|
+
}
|
2472
|
+
},
|
2473
|
+
required: [fieldId]
|
2474
|
+
}),
|
2475
|
+
getId: () => ({ fieldId })
|
2476
|
+
};
|
2477
|
+
}
|
2478
|
+
|
2479
|
+
// ../commons/src/event-config/event-configuration.ts
|
2480
|
+
function createEventFieldConfig(fieldId, options) {
|
2481
|
+
return {
|
2482
|
+
fieldId,
|
2483
|
+
options,
|
2484
|
+
config: { type: "exact" },
|
2485
|
+
fieldType: "event"
|
2486
|
+
};
|
2487
|
+
}
|
2488
|
+
|
2489
|
+
// ../commons/src/events/event.ts
|
2490
|
+
function eventFn(fieldId, options) {
|
2491
|
+
return createEventFieldConfig(fieldId, options);
|
2492
|
+
}
|
2493
|
+
var event = Object.assign(eventFn, {
|
2494
|
+
...createEventConditionals(),
|
2495
|
+
field(field2) {
|
2496
|
+
return {
|
2497
|
+
$event: field2
|
2498
|
+
};
|
2499
|
+
}
|
2500
|
+
});
|
2501
|
+
|
2502
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
2503
|
+
var WorkqueueConfig = import_zod20.z.object({
|
2504
|
+
slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
|
2505
|
+
name: TranslationConfig.describe(
|
2506
|
+
"Title of the workflow (both in navigation and on the page)"
|
2507
|
+
),
|
2508
|
+
query: QueryType,
|
2509
|
+
actions: import_zod20.z.array(
|
2510
|
+
import_zod20.z.object({
|
2511
|
+
type: import_zod20.z.string(),
|
2512
|
+
conditionals: import_zod20.z.array(Conditional).optional()
|
2513
|
+
})
|
2514
|
+
),
|
2515
|
+
columns: import_zod20.z.array(
|
2516
|
+
import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
|
2517
|
+
).default([
|
2518
|
+
{
|
2519
|
+
label: {
|
2520
|
+
id: "workqueues.dateOfEvent",
|
2521
|
+
defaultMessage: "Date of Event",
|
2522
|
+
description: "Label for workqueue column: dateOfEvent"
|
2523
|
+
},
|
2524
|
+
value: event.field("dateOfEvent")
|
2525
|
+
}
|
2526
|
+
])
|
2527
|
+
}).describe("Configuration for workqueue.");
|
2528
|
+
function defineWorkqueue(workqueues) {
|
2529
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
2530
|
+
}
|
2531
|
+
|
2532
|
+
// ../commons/src/events/Draft.ts
|
2533
|
+
var import_zod22 = require("zod");
|
2534
|
+
|
2535
|
+
// ../commons/src/events/ActionInput.ts
|
2536
|
+
var import_zod21 = require("zod");
|
2537
|
+
var import_zod_openapi5 = require("zod-openapi");
|
2538
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
|
2539
|
+
var BaseActionInput = import_zod21.z.object({
|
2540
|
+
eventId: import_zod21.z.string(),
|
2541
|
+
transactionId: import_zod21.z.string(),
|
2542
|
+
declaration: ActionUpdate.default({}),
|
2543
|
+
annotation: ActionUpdate.optional(),
|
2544
|
+
originalActionId: import_zod21.z.string().optional(),
|
2545
|
+
keepAssignment: import_zod21.z.boolean().optional()
|
2546
|
+
});
|
2547
|
+
var CreateActionInput = BaseActionInput.merge(
|
2548
|
+
import_zod21.z.object({
|
2549
|
+
type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2550
|
+
createdAtLocation: import_zod21.z.string()
|
2551
|
+
})
|
2552
|
+
);
|
2553
|
+
var RegisterActionInput = BaseActionInput.merge(
|
2554
|
+
import_zod21.z.object({
|
2555
|
+
type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2556
|
+
registrationNumber: import_zod21.z.string().optional()
|
2557
|
+
})
|
2558
|
+
);
|
2559
|
+
var ValidateActionInput = BaseActionInput.merge(
|
2560
|
+
import_zod21.z.object({
|
2561
|
+
type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2562
|
+
duplicates: import_zod21.z.array(import_zod21.z.string())
|
2563
|
+
})
|
2564
|
+
);
|
2565
|
+
var NotifyActionInput = BaseActionInput.merge(
|
2566
|
+
import_zod21.z.object({
|
2567
|
+
type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2568
|
+
})
|
2569
|
+
);
|
2570
|
+
var DeclareActionInput = BaseActionInput.merge(
|
2571
|
+
import_zod21.z.object({
|
2572
|
+
type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2573
|
+
})
|
2574
|
+
);
|
2575
|
+
var PrintCertificateActionInput = BaseActionInput.merge(
|
2576
|
+
import_zod21.z.object({
|
2577
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2578
|
+
})
|
2579
|
+
);
|
2580
|
+
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2581
|
+
import_zod21.z.object({
|
2582
|
+
type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2583
|
+
})
|
2584
|
+
);
|
2585
|
+
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2586
|
+
import_zod21.z.object({
|
2587
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2588
|
+
})
|
2589
|
+
);
|
2590
|
+
var ArchiveActionInput = BaseActionInput.merge(
|
2591
|
+
import_zod21.z.object({
|
2592
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2593
|
+
})
|
2594
|
+
);
|
2595
|
+
var AssignActionInput = BaseActionInput.merge(
|
2596
|
+
import_zod21.z.object({
|
2597
|
+
type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2598
|
+
assignedTo: import_zod21.z.string()
|
2599
|
+
})
|
2600
|
+
);
|
2601
|
+
var UnassignActionInput = BaseActionInput.merge(
|
2602
|
+
import_zod21.z.object({
|
2603
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2604
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
2605
|
+
})
|
2606
|
+
);
|
2607
|
+
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2608
|
+
import_zod21.z.object({
|
2609
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2610
|
+
})
|
2611
|
+
);
|
2612
|
+
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2613
|
+
import_zod21.z.object({
|
2614
|
+
requestId: import_zod21.z.string(),
|
2615
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2616
|
+
})
|
2617
|
+
);
|
2618
|
+
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2619
|
+
import_zod21.z.object({
|
2620
|
+
requestId: import_zod21.z.string(),
|
2621
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2622
|
+
})
|
2623
|
+
);
|
2624
|
+
var ReadActionInput = BaseActionInput.merge(
|
2625
|
+
import_zod21.z.object({
|
2626
|
+
type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
|
2627
|
+
})
|
2628
|
+
);
|
2629
|
+
var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
|
2630
|
+
var ActionInput = import_zod21.z.discriminatedUnion("type", [
|
2631
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2632
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2633
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2634
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2635
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2636
|
+
RejectDeclarationActionInput.openapi({
|
2637
|
+
ref: "RejectDeclarationActionInput"
|
2638
|
+
}),
|
2639
|
+
MarkedAsDuplicateActionInput.openapi({
|
2640
|
+
ref: "MarkedAsDuplicateActionInput"
|
2641
|
+
}),
|
2642
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2643
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2644
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2645
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2646
|
+
RequestCorrectionActionInput.openapi({
|
2647
|
+
ref: "RequestCorrectionActionInput"
|
2648
|
+
}),
|
2649
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2650
|
+
ApproveCorrectionActionInput.openapi({
|
2651
|
+
ref: "ApproveCorrectionActionInput"
|
2652
|
+
}),
|
2653
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2654
|
+
]).openapi({
|
2655
|
+
ref: "ActionInput"
|
2656
|
+
});
|
2657
|
+
|
2658
|
+
// ../commons/src/events/Draft.ts
|
2659
|
+
var Draft = import_zod22.z.object({
|
2660
|
+
id: import_zod22.z.string(),
|
2661
|
+
eventId: import_zod22.z.string(),
|
2662
|
+
transactionId: import_zod22.z.string(),
|
2663
|
+
createdAt: import_zod22.z.string().datetime(),
|
2664
|
+
action: ActionBase.extend({
|
2665
|
+
type: ActionTypes
|
2666
|
+
}).omit({ id: true })
|
2667
|
+
});
|
2668
|
+
var DraftInput = BaseActionInput.extend({
|
2669
|
+
type: ActionTypes,
|
2670
|
+
status: import_zod22.z.enum([
|
2671
|
+
ActionStatus.Requested,
|
2672
|
+
ActionStatus.Accepted,
|
2673
|
+
ActionStatus.Rejected
|
2674
|
+
])
|
2675
|
+
});
|
2676
|
+
|
2677
|
+
// ../commons/src/events/EventInput.ts
|
2678
|
+
var import_zod23 = require("zod");
|
2679
|
+
var EventInput = import_zod23.z.object({
|
2680
|
+
transactionId: import_zod23.z.string(),
|
2681
|
+
type: import_zod23.z.string(),
|
2682
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
|
2683
|
+
});
|
2684
|
+
|
2685
|
+
// ../commons/src/events/EventDocument.ts
|
2686
|
+
var import_zod24 = require("zod");
|
2687
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2688
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
|
2689
|
+
var EventDocument = import_zod24.z.object({
|
2690
|
+
id: import_zod24.z.string(),
|
2691
|
+
type: import_zod24.z.string(),
|
2692
|
+
dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
|
2693
|
+
createdAt: import_zod24.z.string().datetime(),
|
2694
|
+
updatedAt: import_zod24.z.string().datetime(),
|
2695
|
+
actions: import_zod24.z.array(Action),
|
2696
|
+
trackingId: import_zod24.z.string()
|
2697
|
+
}).openapi({ ref: "EventDocument" });
|
2698
|
+
|
2699
|
+
// ../commons/src/events/state/utils.ts
|
2700
|
+
function getActionRequests(actionType, actions) {
|
2701
|
+
const filtered = actions.filter((action) => action.type === actionType);
|
2702
|
+
const accept = filtered.find(
|
2703
|
+
(action) => action.status === ActionStatus.Accepted
|
2704
|
+
);
|
2705
|
+
const request = filtered.find(
|
2706
|
+
(action) => action.status === ActionStatus.Requested
|
2707
|
+
);
|
2708
|
+
const reject = filtered.find(
|
2709
|
+
(action) => action.status === ActionStatus.Rejected
|
2710
|
+
);
|
2711
|
+
return {
|
2712
|
+
reject,
|
2713
|
+
accept,
|
2714
|
+
request
|
2715
|
+
};
|
2716
|
+
}
|
2717
|
+
function getDeclarationActionCreationMetadata(actionType, actions) {
|
2718
|
+
const { accept: acceptAction, request: requestAction } = getActionRequests(
|
2719
|
+
actionType,
|
2720
|
+
actions
|
2721
|
+
);
|
2722
|
+
if (!acceptAction) {
|
2723
|
+
return null;
|
2724
|
+
}
|
2725
|
+
const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
|
2726
|
+
return {
|
2727
|
+
// When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
|
2728
|
+
createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
|
2729
|
+
createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
|
2730
|
+
createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
|
2731
|
+
acceptedAt: acceptAction.createdAt,
|
2732
|
+
createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
|
2733
|
+
registrationNumber
|
2734
|
+
};
|
2735
|
+
}
|
2736
|
+
function getDeclarationActionUpdateMetadata(actions) {
|
2737
|
+
const createAction = getOrThrow(
|
2738
|
+
actions.find((action) => action.type === ActionType.CREATE),
|
2739
|
+
`Event has no ${ActionType.CREATE} action`
|
2740
|
+
);
|
2741
|
+
return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
|
2742
|
+
(metadata, actionType) => {
|
2743
|
+
const { accept, request } = getActionRequests(actionType, actions);
|
2744
|
+
return {
|
2745
|
+
createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
|
2746
|
+
createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
|
2747
|
+
createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
|
2748
|
+
createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
|
2749
|
+
};
|
2750
|
+
},
|
2751
|
+
{
|
2752
|
+
createdAt: createAction.createdAt,
|
2753
|
+
createdBy: createAction.createdBy,
|
2754
|
+
createdAtLocation: createAction.createdAtLocation,
|
2755
|
+
createdByRole: createAction.createdByRole
|
2756
|
+
}
|
2757
|
+
);
|
2758
|
+
}
|
2759
|
+
function getLegalStatuses(actions) {
|
2760
|
+
return {
|
2761
|
+
[EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
|
2762
|
+
ActionType.DECLARE,
|
2763
|
+
actions
|
2764
|
+
),
|
2765
|
+
[EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
|
2766
|
+
ActionType.REGISTER,
|
2767
|
+
actions
|
2768
|
+
)
|
2769
|
+
};
|
2770
|
+
}
|
2771
|
+
|
2772
|
+
// ../commons/src/events/state/index.ts
|
2773
|
+
function getStatusFromActions(actions) {
|
2774
|
+
const hasRejectedAction = actions.some(
|
2775
|
+
(a) => a.status === ActionStatus.Rejected
|
2776
|
+
);
|
2777
|
+
if (hasRejectedAction) {
|
2778
|
+
return EventStatus.REJECTED;
|
2779
|
+
}
|
2780
|
+
return actions.reduce((status, action) => {
|
2781
|
+
switch (action.type) {
|
2782
|
+
case ActionType.CREATE:
|
2783
|
+
return EventStatus.CREATED;
|
2784
|
+
case ActionType.DECLARE:
|
2785
|
+
return EventStatus.DECLARED;
|
2786
|
+
case ActionType.VALIDATE:
|
2787
|
+
return EventStatus.VALIDATED;
|
2788
|
+
case ActionType.REGISTER:
|
2789
|
+
return EventStatus.REGISTERED;
|
2790
|
+
case ActionType.REJECT:
|
2791
|
+
return EventStatus.REJECTED;
|
2792
|
+
case ActionType.ARCHIVE:
|
2793
|
+
return EventStatus.ARCHIVED;
|
2794
|
+
case ActionType.NOTIFY:
|
2795
|
+
return EventStatus.NOTIFIED;
|
2796
|
+
case ActionType.PRINT_CERTIFICATE:
|
2797
|
+
return EventStatus.CERTIFIED;
|
2798
|
+
case ActionType.ASSIGN:
|
2799
|
+
case ActionType.UNASSIGN:
|
2800
|
+
case ActionType.REQUEST_CORRECTION:
|
2801
|
+
case ActionType.APPROVE_CORRECTION:
|
2802
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2803
|
+
case ActionType.REJECT_CORRECTION:
|
2804
|
+
case ActionType.READ:
|
2805
|
+
default:
|
2806
|
+
return status;
|
2807
|
+
}
|
2808
|
+
}, EventStatus.CREATED);
|
2809
|
+
}
|
2810
|
+
function getFlagsFromActions(actions) {
|
2811
|
+
const sortedactions = actions.sort(
|
2812
|
+
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
2813
|
+
);
|
2814
|
+
const actionStatus = sortedactions.reduce(
|
2815
|
+
(actionStatuses, { type, status }) => ({
|
2816
|
+
...actionStatuses,
|
2817
|
+
[type]: status
|
2818
|
+
}),
|
2819
|
+
{}
|
2820
|
+
);
|
2821
|
+
const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
|
2822
|
+
const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
|
2823
|
+
return flag;
|
2824
|
+
});
|
2825
|
+
const isCertificatePrinted = sortedactions.reduce(
|
2826
|
+
(prev, { type }) => {
|
2827
|
+
if (type === ActionType.PRINT_CERTIFICATE) {
|
2828
|
+
return true;
|
2829
|
+
}
|
2830
|
+
if (type === ActionType.APPROVE_CORRECTION) {
|
2831
|
+
return false;
|
2832
|
+
}
|
2833
|
+
return prev;
|
2834
|
+
},
|
2835
|
+
false
|
2836
|
+
);
|
2837
|
+
if (isCertificatePrinted) {
|
2838
|
+
flags.push(CustomFlags.CERTIFICATE_PRINTED);
|
2839
|
+
}
|
2840
|
+
return flags;
|
2841
|
+
}
|
2842
|
+
function getAssignedUserFromActions(actions) {
|
2843
|
+
return actions.reduce((user2, action) => {
|
2844
|
+
if (action.type === ActionType.ASSIGN) {
|
2845
|
+
return action.assignedTo;
|
2846
|
+
}
|
2847
|
+
if (action.type === ActionType.UNASSIGN) {
|
2848
|
+
return null;
|
2849
|
+
}
|
2850
|
+
return user2;
|
2851
|
+
}, null);
|
2852
|
+
}
|
2853
|
+
function aggregateActionDeclarations(actions) {
|
2854
|
+
const excludedActions = [
|
2855
|
+
ActionType.REQUEST_CORRECTION,
|
2856
|
+
ActionType.PRINT_CERTIFICATE
|
2857
|
+
];
|
2858
|
+
return actions.reduce((status, action) => {
|
2859
|
+
if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
|
2860
|
+
return status;
|
2861
|
+
}
|
2862
|
+
if (action.type === ActionType.APPROVE_CORRECTION) {
|
2863
|
+
const requestAction = actions.find(({ id }) => id === action.requestId);
|
2864
|
+
if (!requestAction) {
|
2865
|
+
return status;
|
2866
|
+
}
|
2867
|
+
return deepMerge(status, requestAction.declaration);
|
2868
|
+
}
|
2869
|
+
return deepMerge(status, action.declaration);
|
2870
|
+
}, {});
|
2871
|
+
}
|
2872
|
+
function deepDropNulls(obj) {
|
2873
|
+
if (Array.isArray(obj)) {
|
2874
|
+
return obj.map(deepDropNulls);
|
2875
|
+
}
|
2876
|
+
if (obj !== null && typeof obj === "object") {
|
2877
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2878
|
+
const cleanedValue = deepDropNulls(value);
|
2879
|
+
if (cleanedValue !== null) {
|
2880
|
+
;
|
2881
|
+
acc[key] = cleanedValue;
|
2882
|
+
}
|
2883
|
+
return acc;
|
2884
|
+
}, {});
|
2885
|
+
}
|
2886
|
+
return obj;
|
2887
|
+
}
|
2888
|
+
function isUndeclaredDraft(status) {
|
2889
|
+
return status === EventStatus.CREATED;
|
2890
|
+
}
|
2891
|
+
function getAcceptedActions(event2) {
|
2892
|
+
return event2.actions.filter(
|
2893
|
+
(a) => a.status === ActionStatus.Accepted
|
2894
|
+
);
|
2895
|
+
}
|
2896
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
2897
|
+
function getCurrentEventState(event2) {
|
2898
|
+
const creationAction = event2.actions.find(
|
2899
|
+
(action) => action.type === ActionType.CREATE
|
2900
|
+
);
|
2901
|
+
if (!creationAction) {
|
2902
|
+
throw new Error(`Event ${event2.id} has no creation action`);
|
2903
|
+
}
|
2904
|
+
const acceptedActions = getAcceptedActions(event2);
|
2905
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
2906
|
+
event2.actions
|
2907
|
+
);
|
2908
|
+
const declaration = aggregateActionDeclarations(acceptedActions);
|
2909
|
+
const dateOfEvent = ZodDate.safeParse(
|
2910
|
+
event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
|
2911
|
+
).data ?? null;
|
2912
|
+
return deepDropNulls({
|
2913
|
+
id: event2.id,
|
2914
|
+
type: event2.type,
|
2915
|
+
status: getStatusFromActions(event2.actions),
|
2916
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
2917
|
+
createdAt: creationAction.createdAt,
|
2918
|
+
createdBy: creationAction.createdBy,
|
2919
|
+
createdAtLocation: creationAction.createdAtLocation,
|
2920
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
2921
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
2922
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
2923
|
+
updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
|
2924
|
+
declaration,
|
2925
|
+
trackingId: event2.trackingId,
|
2926
|
+
// @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
|
2927
|
+
updatedByUserRole: declarationUpdateMetadata.createdByRole,
|
2928
|
+
dateOfEvent,
|
2929
|
+
flags: getFlagsFromActions(event2.actions)
|
2930
|
+
});
|
2931
|
+
}
|
2932
|
+
function getCurrentEventStateWithDrafts(event2, drafts) {
|
2933
|
+
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2934
|
+
const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
|
2935
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
2936
|
+
return [
|
2937
|
+
action,
|
2938
|
+
{
|
2939
|
+
...action,
|
2940
|
+
type: ActionType.APPROVE_CORRECTION
|
2941
|
+
}
|
2942
|
+
];
|
2943
|
+
}
|
2944
|
+
return [action];
|
2945
|
+
});
|
2946
|
+
const actionWithDrafts = [...actions, ...activeDrafts].sort();
|
2947
|
+
const withDrafts = {
|
2948
|
+
...event2,
|
2949
|
+
actions: actionWithDrafts
|
2950
|
+
};
|
2951
|
+
return getCurrentEventState(withDrafts);
|
2952
|
+
}
|
2953
|
+
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2954
|
+
const indexedAt = eventIndex.updatedAt;
|
2955
|
+
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2956
|
+
if (activeDrafts.length === 0) {
|
2957
|
+
return eventIndex;
|
2958
|
+
}
|
2959
|
+
return {
|
2960
|
+
...eventIndex,
|
2961
|
+
declaration: {
|
2962
|
+
...eventIndex.declaration,
|
2963
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2964
|
+
}
|
2965
|
+
};
|
2966
|
+
}
|
2967
|
+
function getAnnotationFromDrafts(drafts) {
|
2968
|
+
const actions = drafts.map((draft) => draft.action);
|
2969
|
+
const annotation = actions.reduce((ann, action) => {
|
2970
|
+
return deepMerge(ann, action.annotation ?? {});
|
2971
|
+
}, {});
|
2972
|
+
return deepDropNulls(annotation);
|
2973
|
+
}
|
2974
|
+
function getActionAnnotation({
|
2975
|
+
event: event2,
|
2976
|
+
actionType,
|
2977
|
+
drafts = []
|
2978
|
+
}) {
|
2979
|
+
const activeActions = getAcceptedActions(event2);
|
2980
|
+
const action = activeActions.find(
|
2981
|
+
(activeAction) => actionType === activeAction.type
|
2982
|
+
);
|
2983
|
+
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2984
|
+
const sorted = [
|
2985
|
+
...action ? [action] : [],
|
2986
|
+
...eventDrafts.map((draft) => draft.action)
|
2987
|
+
].sort();
|
2988
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2989
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2990
|
+
}, {});
|
2991
|
+
return deepDropNulls(annotation);
|
2992
|
+
}
|
2993
|
+
|
2994
|
+
// ../commons/src/events/defineConfig.ts
|
2995
|
+
var defineConfig = (config) => {
|
2996
|
+
const input = EventConfig.parse(config);
|
2997
|
+
return input;
|
2998
|
+
};
|
2999
|
+
|
3000
|
+
// ../commons/src/events/transactions.ts
|
3001
|
+
function generateTransactionId() {
|
3002
|
+
return getUUID();
|
3003
|
+
}
|
3004
|
+
|
3005
|
+
// ../commons/src/events/test.utils.ts
|
3006
|
+
var import_lodash2 = require("lodash");
|
3007
|
+
|
3008
|
+
// ../commons/src/field-config/field-configuration.ts
|
3009
|
+
function createFieldConfigs(fieldId) {
|
3010
|
+
const baseField = {
|
3011
|
+
fieldId,
|
3012
|
+
fieldType: "field"
|
3013
|
+
};
|
3014
|
+
return {
|
3015
|
+
/**
|
3016
|
+
* Creates a range configuration for the specified field.
|
2582
3017
|
*
|
2583
|
-
*
|
3018
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2584
3019
|
*
|
3020
|
+
* @example field('age').range()
|
3021
|
+
* // {
|
3022
|
+
* // fieldId: 'age',
|
3023
|
+
* // config: { type: 'range' }
|
3024
|
+
* // }
|
2585
3025
|
*/
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
[fieldId]: {
|
2590
|
-
anyOf: [
|
2591
|
-
{ const: "undefined" },
|
2592
|
-
{ const: false },
|
2593
|
-
{ const: null },
|
2594
|
-
{ const: "" }
|
2595
|
-
]
|
2596
|
-
}
|
2597
|
-
},
|
2598
|
-
anyOf: [
|
2599
|
-
{
|
2600
|
-
required: [fieldId]
|
2601
|
-
},
|
2602
|
-
{
|
2603
|
-
not: {
|
2604
|
-
required: [fieldId]
|
2605
|
-
}
|
2606
|
-
}
|
2607
|
-
]
|
2608
|
-
}),
|
2609
|
-
isUndefined: () => defineFormConditional({
|
2610
|
-
type: "object",
|
2611
|
-
properties: {
|
2612
|
-
[fieldId]: {
|
2613
|
-
type: "string",
|
2614
|
-
enum: ["undefined"]
|
2615
|
-
}
|
2616
|
-
},
|
2617
|
-
not: {
|
2618
|
-
required: [fieldId]
|
2619
|
-
}
|
2620
|
-
}),
|
2621
|
-
inArray: (values) => defineFormConditional({
|
2622
|
-
type: "object",
|
2623
|
-
properties: {
|
2624
|
-
[fieldId]: {
|
2625
|
-
type: "string",
|
2626
|
-
enum: values
|
2627
|
-
}
|
2628
|
-
},
|
2629
|
-
required: [fieldId]
|
2630
|
-
}),
|
2631
|
-
isValidEnglishName: () => defineFormConditional({
|
2632
|
-
type: "object",
|
2633
|
-
properties: {
|
2634
|
-
[fieldId]: {
|
2635
|
-
type: "string",
|
2636
|
-
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'._-]*)*$",
|
2637
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2638
|
-
}
|
2639
|
-
},
|
2640
|
-
required: [fieldId]
|
3026
|
+
range: () => ({
|
3027
|
+
...baseField,
|
3028
|
+
config: { type: "range" }
|
2641
3029
|
}),
|
2642
3030
|
/**
|
2643
|
-
*
|
2644
|
-
* @
|
2645
|
-
* @
|
3031
|
+
* Creates a configuration for exact matching of the specified field.
|
3032
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
3033
|
+
* @example field('dob').exact()
|
3034
|
+
* // {
|
3035
|
+
* // fieldId: 'dob',
|
3036
|
+
* // config: { type: 'exact' }
|
3037
|
+
* // }
|
2646
3038
|
*/
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
[fieldId]: {
|
2651
|
-
type: "string",
|
2652
|
-
pattern
|
2653
|
-
}
|
2654
|
-
},
|
2655
|
-
required: [fieldId]
|
3039
|
+
exact: () => ({
|
3040
|
+
...baseField,
|
3041
|
+
config: { type: "exact" }
|
2656
3042
|
}),
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
3043
|
+
/**
|
3044
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
3045
|
+
* @returns An object containing the field ID and a configuration object with a type of 'exact'.
|
3046
|
+
* @example field('name').fuzzy()
|
3047
|
+
* // {
|
3048
|
+
* // fieldId: 'name',
|
3049
|
+
* // config: { type: 'fuzzy' }
|
3050
|
+
* // }
|
3051
|
+
*/
|
3052
|
+
fuzzy: () => ({
|
3053
|
+
...baseField,
|
3054
|
+
config: { type: "fuzzy" }
|
2667
3055
|
})
|
2668
3056
|
};
|
2669
3057
|
}
|
2670
3058
|
|
3059
|
+
// ../commons/src/events/field.ts
|
3060
|
+
function field(fieldId) {
|
3061
|
+
return {
|
3062
|
+
/**
|
3063
|
+
* @private Internal property used for field reference tracking.
|
3064
|
+
*/
|
3065
|
+
_fieldId: fieldId,
|
3066
|
+
...createFieldConditionals(fieldId),
|
3067
|
+
...createFieldConfigs(fieldId)
|
3068
|
+
};
|
3069
|
+
}
|
3070
|
+
|
2671
3071
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2672
3072
|
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2673
3073
|
label: {
|
@@ -3406,9 +3806,8 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3406
3806
|
},
|
3407
3807
|
{
|
3408
3808
|
id: "applicant.dob",
|
3409
|
-
type:
|
3809
|
+
type: FieldType.DATE,
|
3410
3810
|
required: true,
|
3411
|
-
conditionals: [],
|
3412
3811
|
validation: [
|
3413
3812
|
{
|
3414
3813
|
message: {
|
@@ -3419,12 +3818,50 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3419
3818
|
validator: field("applicant.dob").isBefore().now()
|
3420
3819
|
}
|
3421
3820
|
],
|
3821
|
+
conditionals: [
|
3822
|
+
{
|
3823
|
+
type: ConditionalType.SHOW,
|
3824
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3825
|
+
}
|
3826
|
+
],
|
3422
3827
|
label: {
|
3423
3828
|
defaultMessage: "Applicant's date of birth",
|
3424
3829
|
description: "This is the label for the field",
|
3425
3830
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3426
3831
|
}
|
3427
3832
|
},
|
3833
|
+
{
|
3834
|
+
id: "applicant.dobUnknown",
|
3835
|
+
type: FieldType.CHECKBOX,
|
3836
|
+
required: false,
|
3837
|
+
label: {
|
3838
|
+
defaultMessage: "Exact date of birth unknown",
|
3839
|
+
description: "This is the label for the field",
|
3840
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3841
|
+
},
|
3842
|
+
conditionals: [
|
3843
|
+
{
|
3844
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3845
|
+
conditional: never()
|
3846
|
+
}
|
3847
|
+
]
|
3848
|
+
},
|
3849
|
+
{
|
3850
|
+
id: "applicant.age",
|
3851
|
+
type: FieldType.NUMBER,
|
3852
|
+
required: true,
|
3853
|
+
label: {
|
3854
|
+
defaultMessage: "Age of tennis-member",
|
3855
|
+
description: "This is the label for the field",
|
3856
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3857
|
+
},
|
3858
|
+
conditionals: [
|
3859
|
+
{
|
3860
|
+
type: ConditionalType.SHOW,
|
3861
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3862
|
+
}
|
3863
|
+
]
|
3864
|
+
},
|
3428
3865
|
{
|
3429
3866
|
id: "applicant.image",
|
3430
3867
|
type: FieldType.FILE,
|
@@ -3547,20 +3984,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3547
3984
|
description: "This is what this event is referred as in the system",
|
3548
3985
|
id: "event.tennis-club-membership.label"
|
3549
3986
|
},
|
3987
|
+
title: {
|
3988
|
+
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3989
|
+
description: "This is the title of the summary",
|
3990
|
+
id: "v2.event.tennis-club-membership.title"
|
3991
|
+
},
|
3550
3992
|
summary: {
|
3551
|
-
title: {
|
3552
|
-
id: "event.tennis-club-membership.summary.title",
|
3553
|
-
label: {
|
3554
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3555
|
-
description: "This is the title of the summary",
|
3556
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3557
|
-
},
|
3558
|
-
emptyValueMessage: {
|
3559
|
-
defaultMessage: "Membership application",
|
3560
|
-
description: "This is the message shown when the applicant name is missing",
|
3561
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3562
|
-
}
|
3563
|
-
},
|
3564
3993
|
fields: [
|
3565
3994
|
{
|
3566
3995
|
id: "applicant.firstname",
|
@@ -3600,28 +4029,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3600
4029
|
}
|
3601
4030
|
]
|
3602
4031
|
},
|
3603
|
-
workqueues: [
|
3604
|
-
{
|
3605
|
-
id: "all",
|
3606
|
-
filters: []
|
3607
|
-
},
|
3608
|
-
{
|
3609
|
-
id: "ready-for-review",
|
3610
|
-
filters: [
|
3611
|
-
{
|
3612
|
-
status: ["DECLARED"]
|
3613
|
-
}
|
3614
|
-
]
|
3615
|
-
},
|
3616
|
-
{
|
3617
|
-
id: "registered",
|
3618
|
-
filters: [
|
3619
|
-
{
|
3620
|
-
status: ["REGISTERED"]
|
3621
|
-
}
|
3622
|
-
]
|
3623
|
-
}
|
3624
|
-
],
|
3625
4032
|
actions: [
|
3626
4033
|
{
|
3627
4034
|
type: ActionType.DECLARE,
|
@@ -3929,18 +4336,14 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3929
4336
|
description: "This is what this event is referred as in the system",
|
3930
4337
|
id: "v2.event.tennis-club-membership.search"
|
3931
4338
|
},
|
3932
|
-
fields: [
|
3933
|
-
{
|
3934
|
-
fieldId: "applicant.dob"
|
3935
|
-
}
|
3936
|
-
]
|
4339
|
+
fields: [field("applicant.dob").exact()]
|
3937
4340
|
}
|
3938
4341
|
],
|
3939
4342
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3940
4343
|
});
|
3941
4344
|
|
3942
4345
|
// ../commons/src/events/test.utils.ts
|
3943
|
-
function
|
4346
|
+
function fieldConfigsToActionPayload(fields) {
|
3944
4347
|
return fields.reduce(
|
3945
4348
|
(acc, field2, i) => ({
|
3946
4349
|
...acc,
|
@@ -3949,26 +4352,27 @@ function fieldConfigsToActionAnnotation(fields) {
|
|
3949
4352
|
{}
|
3950
4353
|
);
|
3951
4354
|
}
|
3952
|
-
function
|
4355
|
+
function generateActionDeclarationInput(configuration, action) {
|
3953
4356
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
3954
4357
|
if (parsed.success) {
|
3955
4358
|
const fields = getDeclarationFields(configuration);
|
3956
|
-
const
|
3957
|
-
|
4359
|
+
const declarationConfig = getDeclaration(configuration);
|
4360
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4361
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
3958
4362
|
}
|
3959
4363
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
3960
4364
|
return {};
|
3961
4365
|
}
|
3962
|
-
function
|
4366
|
+
function generateActionAnnotationInput(configuration, action) {
|
3963
4367
|
const actionConfig = configuration.actions.find(
|
3964
4368
|
(ac) => ac.type === action
|
3965
4369
|
);
|
3966
4370
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3967
|
-
const annotation =
|
3968
|
-
const visibleVerificationPageIds =
|
3969
|
-
configuration,
|
3970
|
-
|
3971
|
-
)
|
4371
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4372
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4373
|
+
findRecordActionPages(configuration, action),
|
4374
|
+
annotation
|
4375
|
+
);
|
3972
4376
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3973
4377
|
(acc, pageId) => ({
|
3974
4378
|
...acc,
|
@@ -3976,7 +4380,7 @@ function generateActionMetadataInput(configuration, action) {
|
|
3976
4380
|
}),
|
3977
4381
|
{}
|
3978
4382
|
);
|
3979
|
-
const fieldBasedPayload =
|
4383
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
3980
4384
|
return {
|
3981
4385
|
...fieldBasedPayload,
|
3982
4386
|
...visiblePageVerificationMap
|
@@ -3999,6 +4403,7 @@ var eventPayloadGenerator = {
|
|
3999
4403
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4000
4404
|
transactionId: getUUID(),
|
4001
4405
|
action: {
|
4406
|
+
transactionId: getUUID(),
|
4002
4407
|
type: actionType,
|
4003
4408
|
status: ActionStatus.Accepted,
|
4004
4409
|
declaration: {
|
@@ -4013,6 +4418,7 @@ var eventPayloadGenerator = {
|
|
4013
4418
|
},
|
4014
4419
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4015
4420
|
createdBy: "@todo",
|
4421
|
+
createdByRole: "@todo",
|
4016
4422
|
createdAtLocation: "@todo"
|
4017
4423
|
}
|
4018
4424
|
},
|
@@ -4022,8 +4428,11 @@ var eventPayloadGenerator = {
|
|
4022
4428
|
declare: (eventId, input = {}) => ({
|
4023
4429
|
type: ActionType.DECLARE,
|
4024
4430
|
transactionId: input.transactionId ?? getUUID(),
|
4025
|
-
declaration: input.declaration ??
|
4026
|
-
|
4431
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4432
|
+
tennisClubMembershipEvent,
|
4433
|
+
ActionType.DECLARE
|
4434
|
+
),
|
4435
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4027
4436
|
tennisClubMembershipEvent,
|
4028
4437
|
ActionType.DECLARE
|
4029
4438
|
),
|
@@ -4036,7 +4445,10 @@ var eventPayloadGenerator = {
|
|
4036
4445
|
let declaration = input.declaration;
|
4037
4446
|
if (!declaration) {
|
4038
4447
|
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4039
|
-
|
4448
|
+
generateActionDeclarationInput(
|
4449
|
+
tennisClubMembershipEvent,
|
4450
|
+
ActionType.DECLARE
|
4451
|
+
),
|
4040
4452
|
import_lodash2.isString
|
4041
4453
|
);
|
4042
4454
|
declaration = partialDeclaration;
|
@@ -4051,8 +4463,11 @@ var eventPayloadGenerator = {
|
|
4051
4463
|
validate: (eventId, input = {}) => ({
|
4052
4464
|
type: ActionType.VALIDATE,
|
4053
4465
|
transactionId: input.transactionId ?? getUUID(),
|
4054
|
-
declaration: input.declaration ??
|
4055
|
-
|
4466
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4467
|
+
tennisClubMembershipEvent,
|
4468
|
+
ActionType.VALIDATE
|
4469
|
+
),
|
4470
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4056
4471
|
tennisClubMembershipEvent,
|
4057
4472
|
ActionType.VALIDATE
|
4058
4473
|
),
|
@@ -4086,7 +4501,7 @@ var eventPayloadGenerator = {
|
|
4086
4501
|
type: ActionType.REJECT,
|
4087
4502
|
transactionId: input.transactionId ?? getUUID(),
|
4088
4503
|
declaration: {},
|
4089
|
-
annotation: input.annotation ??
|
4504
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4090
4505
|
tennisClubMembershipEvent,
|
4091
4506
|
ActionType.REJECT
|
4092
4507
|
),
|
@@ -4096,8 +4511,11 @@ var eventPayloadGenerator = {
|
|
4096
4511
|
register: (eventId, input = {}) => ({
|
4097
4512
|
type: ActionType.REGISTER,
|
4098
4513
|
transactionId: input.transactionId ?? getUUID(),
|
4099
|
-
declaration: input.declaration ??
|
4100
|
-
|
4514
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4515
|
+
tennisClubMembershipEvent,
|
4516
|
+
ActionType.REGISTER
|
4517
|
+
),
|
4518
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4101
4519
|
tennisClubMembershipEvent,
|
4102
4520
|
ActionType.REGISTER
|
4103
4521
|
),
|
@@ -4107,7 +4525,7 @@ var eventPayloadGenerator = {
|
|
4107
4525
|
type: ActionType.PRINT_CERTIFICATE,
|
4108
4526
|
transactionId: input.transactionId ?? getUUID(),
|
4109
4527
|
declaration: {},
|
4110
|
-
annotation: input.annotation ??
|
4528
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4111
4529
|
tennisClubMembershipEvent,
|
4112
4530
|
ActionType.PRINT_CERTIFICATE
|
4113
4531
|
),
|
@@ -4117,11 +4535,11 @@ var eventPayloadGenerator = {
|
|
4117
4535
|
request: (eventId, input = {}) => ({
|
4118
4536
|
type: ActionType.REQUEST_CORRECTION,
|
4119
4537
|
transactionId: input.transactionId ?? getUUID(),
|
4120
|
-
declaration: input.declaration ??
|
4538
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4121
4539
|
tennisClubMembershipEvent,
|
4122
4540
|
ActionType.REQUEST_CORRECTION
|
4123
4541
|
),
|
4124
|
-
annotation: input.annotation ??
|
4542
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4125
4543
|
tennisClubMembershipEvent,
|
4126
4544
|
ActionType.REQUEST_CORRECTION
|
4127
4545
|
),
|
@@ -4131,7 +4549,7 @@ var eventPayloadGenerator = {
|
|
4131
4549
|
type: ActionType.APPROVE_CORRECTION,
|
4132
4550
|
transactionId: input.transactionId ?? getUUID(),
|
4133
4551
|
declaration: {},
|
4134
|
-
annotation: input.annotation ??
|
4552
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4135
4553
|
tennisClubMembershipEvent,
|
4136
4554
|
ActionType.APPROVE_CORRECTION
|
4137
4555
|
),
|
@@ -4142,7 +4560,7 @@ var eventPayloadGenerator = {
|
|
4142
4560
|
type: ActionType.REJECT_CORRECTION,
|
4143
4561
|
transactionId: input.transactionId ?? getUUID(),
|
4144
4562
|
declaration: {},
|
4145
|
-
annotation: input.annotation ??
|
4563
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4146
4564
|
tennisClubMembershipEvent,
|
4147
4565
|
ActionType.REJECT_CORRECTION
|
4148
4566
|
),
|
@@ -4162,12 +4580,14 @@ function generateActionDocument({
|
|
4162
4580
|
// @TODO: This should be fixed in the future.
|
4163
4581
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4164
4582
|
createdBy: getUUID(),
|
4583
|
+
createdByRole: "FIELD_AGENT",
|
4165
4584
|
id: getUUID(),
|
4166
|
-
createdAtLocation: "
|
4167
|
-
declaration:
|
4585
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4586
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4168
4587
|
annotation: {},
|
4169
|
-
|
4170
|
-
|
4588
|
+
status: ActionStatus.Accepted,
|
4589
|
+
transactionId: getUUID(),
|
4590
|
+
...defaults
|
4171
4591
|
};
|
4172
4592
|
switch (action) {
|
4173
4593
|
case ActionType.READ:
|
@@ -4177,7 +4597,7 @@ function generateActionDocument({
|
|
4177
4597
|
case ActionType.DECLARE:
|
4178
4598
|
return { ...actionBase, type: action };
|
4179
4599
|
case ActionType.UNASSIGN:
|
4180
|
-
return { ...actionBase, type: action };
|
4600
|
+
return { ...actionBase, type: action, assignedTo: null };
|
4181
4601
|
case ActionType.ASSIGN:
|
4182
4602
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
4183
4603
|
case ActionType.VALIDATE:
|
@@ -4226,7 +4646,7 @@ function generateEventDocument({
|
|
4226
4646
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4227
4647
|
// @TODO: This should be fixed in the future.
|
4228
4648
|
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4229
|
-
|
4649
|
+
dateOfEvent: configuration.dateOfEvent
|
4230
4650
|
};
|
4231
4651
|
}
|
4232
4652
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4248,24 +4668,76 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4248
4668
|
eventId
|
4249
4669
|
};
|
4250
4670
|
}
|
4671
|
+
function getEventStatus() {
|
4672
|
+
const statuses = [
|
4673
|
+
EventStatus.CREATED,
|
4674
|
+
EventStatus.REGISTERED,
|
4675
|
+
EventStatus.DECLARED
|
4676
|
+
];
|
4677
|
+
const randomIndex = Math.floor(Math.random() * 3);
|
4678
|
+
return statuses[randomIndex];
|
4679
|
+
}
|
4680
|
+
function getTrackingId() {
|
4681
|
+
const uuid = getUUID().replace(/-/g, "");
|
4682
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4683
|
+
return trackingId;
|
4684
|
+
}
|
4685
|
+
function getRandomApplicant() {
|
4686
|
+
const firstNames = [
|
4687
|
+
"Danny",
|
4688
|
+
"John",
|
4689
|
+
"Jane",
|
4690
|
+
"Emily",
|
4691
|
+
"Michael",
|
4692
|
+
"Sarah",
|
4693
|
+
"Chris",
|
4694
|
+
"Jessica"
|
4695
|
+
];
|
4696
|
+
const surnames = [
|
4697
|
+
"Doe",
|
4698
|
+
"Smith",
|
4699
|
+
"Johnson",
|
4700
|
+
"Brown",
|
4701
|
+
"Williams",
|
4702
|
+
"Jones",
|
4703
|
+
"Garcia",
|
4704
|
+
"Miller"
|
4705
|
+
];
|
4706
|
+
function getRandomDate(start, end) {
|
4707
|
+
const randomDate = new Date(
|
4708
|
+
start.getTime() + Math.random() * (end.getTime() - start.getTime())
|
4709
|
+
);
|
4710
|
+
return randomDate.toISOString().split("T")[0];
|
4711
|
+
}
|
4712
|
+
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
4713
|
+
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
|
4714
|
+
const randomDob = getRandomDate(
|
4715
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
4716
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
4717
|
+
);
|
4718
|
+
return {
|
4719
|
+
"recommender.none": true,
|
4720
|
+
"applicant.firstname": randomFirstName,
|
4721
|
+
"applicant.surname": randomSurname,
|
4722
|
+
"applicant.dob": randomDob
|
4723
|
+
};
|
4724
|
+
}
|
4251
4725
|
var eventQueryDataGenerator = (overrides = {}) => ({
|
4252
4726
|
id: overrides.id ?? getUUID(),
|
4253
|
-
type: overrides.type ?? "
|
4254
|
-
status: overrides.status ??
|
4727
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4728
|
+
status: overrides.status ?? getEventStatus(),
|
4255
4729
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4256
4730
|
createdBy: overrides.createdBy ?? getUUID(),
|
4257
4731
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
4258
4732
|
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4259
|
-
|
4733
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4260
4734
|
assignedTo: overrides.assignedTo ?? null,
|
4261
4735
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4262
|
-
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4266
|
-
|
4267
|
-
},
|
4268
|
-
trackingId: overrides.trackingId ?? "M3F8YQ"
|
4736
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4737
|
+
flags: [],
|
4738
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
4739
|
+
declaration: overrides.declaration ?? getRandomApplicant(),
|
4740
|
+
trackingId: overrides.trackingId ?? getTrackingId()
|
4269
4741
|
});
|
4270
4742
|
var generateTranslationConfig = (message) => ({
|
4271
4743
|
defaultMessage: message,
|
@@ -4304,3 +4776,197 @@ function isFieldConfigDefaultValue(value) {
|
|
4304
4776
|
}
|
4305
4777
|
return false;
|
4306
4778
|
}
|
4779
|
+
|
4780
|
+
// ../commons/src/events/scopes.ts
|
4781
|
+
var import_lodash3 = require("lodash");
|
4782
|
+
|
4783
|
+
// ../commons/src/scopes.ts
|
4784
|
+
var SCOPES = {
|
4785
|
+
// TODO v1.8 legacy scopes
|
4786
|
+
NATLSYSADMIN: "natlsysadmin",
|
4787
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
4788
|
+
DECLARE: "declare",
|
4789
|
+
REGISTER: "register",
|
4790
|
+
VALIDATE: "validate",
|
4791
|
+
DEMO: "demo",
|
4792
|
+
CERTIFY: "certify",
|
4793
|
+
PERFORMANCE: "performance",
|
4794
|
+
SYSADMIN: "sysadmin",
|
4795
|
+
TEAMS: "teams",
|
4796
|
+
CONFIG: "config",
|
4797
|
+
// systems / integrations
|
4798
|
+
WEBHOOK: "webhook",
|
4799
|
+
NATIONALID: "nationalId",
|
4800
|
+
NOTIFICATION_API: "notification-api",
|
4801
|
+
RECORDSEARCH: "recordsearch",
|
4802
|
+
/**
|
4803
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4804
|
+
*/
|
4805
|
+
RECORD_DECLARE: "record.declare-birth",
|
4806
|
+
// declare
|
4807
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4808
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4809
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
4810
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4811
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4812
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4813
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4814
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4815
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4816
|
+
// validate
|
4817
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4818
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4819
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4820
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4821
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4822
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4823
|
+
// register
|
4824
|
+
RECORD_REGISTER: "record.register",
|
4825
|
+
// certify
|
4826
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
4827
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4828
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4829
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4830
|
+
// v1.8
|
4831
|
+
/**
|
4832
|
+
* This scope is used to **print and **issue certified copies of a record
|
4833
|
+
* after it has been registered. Previously Registrars had this permission.
|
4834
|
+
*/
|
4835
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4836
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4837
|
+
// v1.8
|
4838
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4839
|
+
// v1.8
|
4840
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4841
|
+
// v1.8
|
4842
|
+
// correct
|
4843
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4844
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4845
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4846
|
+
// v1.8
|
4847
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4848
|
+
// v1.8
|
4849
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4850
|
+
// v1.8
|
4851
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4852
|
+
// v1.8
|
4853
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4854
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4855
|
+
// search
|
4856
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4857
|
+
SEARCH_BIRTH: "search.birth",
|
4858
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4859
|
+
SEARCH_DEATH: "search.death",
|
4860
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4861
|
+
SEARCH_MARRIAGE: "search.marriage",
|
4862
|
+
// audit v1.8
|
4863
|
+
RECORD_READ: "record.read",
|
4864
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
4865
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
4866
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4867
|
+
// profile
|
4868
|
+
PROFILE_UPDATE: "profile.update",
|
4869
|
+
//v1.8
|
4870
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4871
|
+
// performance
|
4872
|
+
PERFORMANCE_READ: "performance.read",
|
4873
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4874
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4875
|
+
// organisation
|
4876
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4877
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4878
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4879
|
+
// user
|
4880
|
+
USER_READ: "user.read:all",
|
4881
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
4882
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4883
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4884
|
+
//v1.8
|
4885
|
+
USER_CREATE: "user.create:all",
|
4886
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4887
|
+
USER_UPDATE: "user.update:all",
|
4888
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4889
|
+
// config
|
4890
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
4891
|
+
// data seeding
|
4892
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
4893
|
+
};
|
4894
|
+
var scopes = Object.values(SCOPES);
|
4895
|
+
|
4896
|
+
// ../commons/src/events/scopes.ts
|
4897
|
+
function hasAnyOfScopes(a, b) {
|
4898
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4899
|
+
}
|
4900
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
4901
|
+
SCOPES.RECORD_DECLARE,
|
4902
|
+
SCOPES.RECORD_READ,
|
4903
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4904
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4905
|
+
SCOPES.RECORD_REGISTER,
|
4906
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
4907
|
+
SCOPES.CONFIG,
|
4908
|
+
SCOPES.CONFIG_UPDATE_ALL
|
4909
|
+
];
|
4910
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
4911
|
+
SCOPES.SEARCH_BIRTH,
|
4912
|
+
SCOPES.SEARCH_DEATH,
|
4913
|
+
SCOPES.SEARCH_MARRIAGE,
|
4914
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
4915
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
4916
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
4917
|
+
];
|
4918
|
+
var ACTION_ALLOWED_SCOPES = {
|
4919
|
+
[ActionType.READ]: [
|
4920
|
+
SCOPES.RECORD_DECLARE,
|
4921
|
+
SCOPES.RECORD_READ,
|
4922
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4923
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4924
|
+
SCOPES.RECORD_REGISTER,
|
4925
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
4926
|
+
],
|
4927
|
+
[ActionType.CREATE]: [
|
4928
|
+
SCOPES.RECORD_DECLARE,
|
4929
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4930
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
4931
|
+
],
|
4932
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
4933
|
+
[ActionType.DECLARE]: [
|
4934
|
+
SCOPES.RECORD_DECLARE,
|
4935
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4936
|
+
SCOPES.RECORD_REGISTER
|
4937
|
+
],
|
4938
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
4939
|
+
[ActionType.VALIDATE]: [
|
4940
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4941
|
+
SCOPES.RECORD_REGISTER
|
4942
|
+
],
|
4943
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
4944
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
4945
|
+
[ActionType.REQUEST_CORRECTION]: [
|
4946
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
4947
|
+
],
|
4948
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4949
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4950
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4951
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4952
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
4953
|
+
[ActionType.ASSIGN]: null,
|
4954
|
+
[ActionType.UNASSIGN]: null,
|
4955
|
+
[ActionType.DETECT_DUPLICATE]: []
|
4956
|
+
};
|
4957
|
+
function filterUnallowedActions(actions, userScopes) {
|
4958
|
+
const allowedActions = actions.filter((action) => {
|
4959
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
4960
|
+
if (requiredScopes === null) {
|
4961
|
+
return true;
|
4962
|
+
}
|
4963
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
4964
|
+
});
|
4965
|
+
const hasOtherAllowedActions = allowedActions.some(
|
4966
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
4967
|
+
);
|
4968
|
+
if (hasOtherAllowedActions) {
|
4969
|
+
return allowedActions;
|
4970
|
+
}
|
4971
|
+
return [ActionType.READ];
|
4972
|
+
}
|