@opencrvs/toolkit 1.8.0-rc.fd31705 → 1.8.0-rc.fd754eb
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 +7717 -4214
- 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 +466 -368
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +369 -25
- package/dist/commons/events/CompositeFieldValue.d.ts +3 -0
- package/dist/commons/events/Draft.d.ts +39 -23
- package/dist/commons/events/EventConfig.d.ts +42812 -1344
- package/dist/commons/events/EventDocument.d.ts +339 -153
- package/dist/commons/events/EventIndex.d.ts +1346 -13
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +273 -11
- 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/TemplateConfig.d.ts +4 -4
- package/dist/commons/events/User.d.ts +5 -0
- 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 +1864 -1099
- package/dist/scopes/index.d.ts +70 -1
- package/dist/scopes/index.js +130 -0
- package/package.json +3 -2
package/dist/events/index.js
CHANGED
@@ -30,11 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
30
30
|
// src/events/index.ts
|
31
31
|
var events_exports = {};
|
32
32
|
__export(events_exports, {
|
33
|
+
ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
|
33
34
|
Action: () => Action,
|
34
35
|
ActionBase: () => ActionBase,
|
35
36
|
ActionConditional: () => ActionConditional,
|
36
37
|
ActionConfig: () => ActionConfig,
|
37
38
|
ActionConfigBase: () => ActionConfigBase,
|
39
|
+
ActionCreationMetadata: () => ActionCreationMetadata,
|
38
40
|
ActionDocument: () => ActionDocument,
|
39
41
|
ActionFormConfig: () => ActionFormConfig,
|
40
42
|
ActionInput: () => ActionInput,
|
@@ -52,6 +54,8 @@ __export(events_exports, {
|
|
52
54
|
AssignActionInput: () => AssignActionInput,
|
53
55
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
54
56
|
BaseActionInput: () => BaseActionInput,
|
57
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
58
|
+
CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
|
55
59
|
CertificateConfig: () => CertificateConfig,
|
56
60
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
57
61
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
@@ -59,9 +63,13 @@ __export(events_exports, {
|
|
59
63
|
Conditional: () => Conditional,
|
60
64
|
ConditionalType: () => ConditionalType,
|
61
65
|
ConfirmableActions: () => ConfirmableActions,
|
66
|
+
CustomFlags: () => CustomFlags,
|
67
|
+
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
62
68
|
DataEntry: () => DataEntry,
|
63
69
|
DataFieldValue: () => DataFieldValue,
|
70
|
+
DateRangeFieldValue: () => DateRangeFieldValue,
|
64
71
|
DateValue: () => DateValue,
|
72
|
+
DatetimeValue: () => DatetimeValue,
|
65
73
|
DeclarationActionConfig: () => DeclarationActionConfig,
|
66
74
|
DeclarationActions: () => DeclarationActions,
|
67
75
|
DeclarationFormConfig: () => DeclarationFormConfig,
|
@@ -69,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,272 +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
|
-
modifiedAt: import_zod14.z.string().datetime(),
|
1062
|
-
assignedTo: import_zod14.z.string().nullish(),
|
1063
|
-
updatedBy: import_zod14.z.string(),
|
1064
|
-
trackingId: import_zod14.z.string(),
|
1065
|
-
registrationNumber: import_zod14.z.string().nullish()
|
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()
|
1066
1114
|
});
|
1067
|
-
var
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
description: "Created At Location"
|
1082
|
-
},
|
1083
|
-
"event.createdBy": {
|
1084
|
-
id: "event.createdBy.label",
|
1085
|
-
defaultMessage: "Created By",
|
1086
|
-
description: "Created By"
|
1087
|
-
},
|
1088
|
-
"event.id": {
|
1089
|
-
id: "event.id.label",
|
1090
|
-
defaultMessage: "ID",
|
1091
|
-
description: "ID"
|
1092
|
-
},
|
1093
|
-
"event.modifiedAt": {
|
1094
|
-
id: "event.modifiedAt.label",
|
1095
|
-
defaultMessage: "Updated",
|
1096
|
-
description: "Modified At"
|
1097
|
-
},
|
1098
|
-
"event.status": {
|
1099
|
-
id: "event.status.label",
|
1100
|
-
defaultMessage: "Status",
|
1101
|
-
description: "Status"
|
1102
|
-
},
|
1103
|
-
"event.type": {
|
1104
|
-
id: "event.type.label",
|
1105
|
-
defaultMessage: "Type",
|
1106
|
-
description: "Type"
|
1107
|
-
},
|
1108
|
-
"event.updatedBy": {
|
1109
|
-
id: "event.updatedBy.label",
|
1110
|
-
defaultMessage: "Updated By",
|
1111
|
-
description: "Updated By"
|
1112
|
-
},
|
1113
|
-
"event.trackingId": {
|
1114
|
-
id: "event.trackingId.label",
|
1115
|
-
defaultMessage: "Tracking ID",
|
1116
|
-
description: "Tracking ID"
|
1117
|
-
},
|
1118
|
-
"event.registrationNumber": {
|
1119
|
-
id: "event.registrationNumber.label",
|
1120
|
-
defaultMessage: "Registration Number",
|
1121
|
-
description: "Registration Number"
|
1122
|
-
}
|
1123
|
-
};
|
1124
|
-
|
1125
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1126
|
-
var WorkqueueConfig = import_zod15.z.object({
|
1127
|
-
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1128
|
-
filters: import_zod15.z.array(
|
1129
|
-
import_zod15.z.object({
|
1130
|
-
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1131
|
-
})
|
1132
|
-
).describe("Filters to be applied to workqueue.")
|
1133
|
-
}).describe("Configuration for workqueue.");
|
1134
|
-
|
1135
|
-
// ../commons/src/events/AdvancedSearchConfig.ts
|
1136
|
-
var import_zod16 = require("zod");
|
1137
|
-
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({
|
1138
1129
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1139
|
-
fields:
|
1140
|
-
import_zod16.z.object({
|
1141
|
-
fieldId: import_zod16.z.string(),
|
1142
|
-
config: import_zod16.z.object({
|
1143
|
-
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1144
|
-
}).optional().describe("Configuration options for the field")
|
1145
|
-
})
|
1146
|
-
).optional().default([]).describe("Advanced search fields.")
|
1130
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1147
1131
|
});
|
1148
1132
|
|
1149
1133
|
// ../commons/src/events/utils.ts
|
1150
1134
|
var import_lodash = require("lodash");
|
1151
1135
|
|
1152
|
-
// ../commons/src/
|
1153
|
-
var
|
1154
|
-
|
1155
|
-
|
1156
|
-
var
|
1157
|
-
var
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
event: {
|
1163
|
-
id: "event",
|
1164
|
-
label: {
|
1165
|
-
defaultMessage: "Event",
|
1166
|
-
description: "This is the label for the workqueue column",
|
1167
|
-
id: "workqueue.default.column.event"
|
1168
|
-
}
|
1169
|
-
},
|
1170
|
-
status: {
|
1171
|
-
id: "status",
|
1172
|
-
label: {
|
1173
|
-
defaultMessage: "Status",
|
1174
|
-
description: "This is the label for the workqueue column",
|
1175
|
-
id: "workqueue.default.column.status"
|
1176
|
-
}
|
1177
|
-
},
|
1178
|
-
createdAt: {
|
1179
|
-
id: "createdAt",
|
1180
|
-
label: {
|
1181
|
-
defaultMessage: "Created",
|
1182
|
-
description: "This is the label for the workqueue column",
|
1183
|
-
id: "workqueue.default.column.createdAt"
|
1184
|
-
}
|
1185
|
-
},
|
1186
|
-
modifiedAt: {
|
1187
|
-
id: "modifiedAt",
|
1188
|
-
label: {
|
1189
|
-
defaultMessage: "Modified",
|
1190
|
-
description: "This is the label for the workqueue column",
|
1191
|
-
id: "workqueue.default.column.modifiedAt"
|
1192
|
-
}
|
1193
|
-
}
|
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"
|
1194
1146
|
};
|
1195
|
-
var
|
1196
|
-
|
1197
|
-
)
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
title: {
|
1212
|
-
defaultMessage: "All events",
|
1213
|
-
description: "This is the label for the workqueue",
|
1214
|
-
id: "workqueue.all.label"
|
1215
|
-
},
|
1216
|
-
columns: [
|
1217
|
-
{
|
1218
|
-
id: "title",
|
1219
|
-
label: {
|
1220
|
-
defaultMessage: "Title",
|
1221
|
-
description: "This is the label for the workqueue column",
|
1222
|
-
id: "workqueue.all.column.title"
|
1223
|
-
}
|
1224
|
-
}
|
1225
|
-
],
|
1226
|
-
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()
|
1227
1163
|
});
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
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"
|
1248
1262
|
});
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
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
|
+
)
|
1269
1283
|
});
|
1270
1284
|
|
1271
|
-
// ../commons/src/workqueues/index.ts
|
1272
|
-
var workqueues = {
|
1273
|
-
all: allWorkqueue,
|
1274
|
-
registered: registeredWorkqueue,
|
1275
|
-
inReview: inReviewWorkqueue
|
1276
|
-
};
|
1277
|
-
|
1278
1285
|
// ../commons/src/conditionals/validate.ts
|
1279
1286
|
var import_ajv = __toESM(require("ajv"));
|
1280
1287
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1281
1288
|
var import_date_fns = require("date-fns");
|
1282
1289
|
|
1283
1290
|
// ../commons/src/events/FieldTypeMapping.ts
|
1284
|
-
var
|
1291
|
+
var import_zod16 = require("zod");
|
1285
1292
|
function mapFieldTypeToZod(type, required) {
|
1286
1293
|
let schema;
|
1287
1294
|
switch (type) {
|
@@ -1291,6 +1298,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1291
1298
|
case FieldType.EMAIL:
|
1292
1299
|
schema = EmailValue;
|
1293
1300
|
break;
|
1301
|
+
case FieldType.DATE_RANGE:
|
1302
|
+
schema = DateRangeFieldValue;
|
1303
|
+
break;
|
1294
1304
|
case FieldType.TEXT:
|
1295
1305
|
case FieldType.TEXTAREA:
|
1296
1306
|
case FieldType.DIVIDER:
|
@@ -1305,8 +1315,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1305
1315
|
case FieldType.FACILITY:
|
1306
1316
|
case FieldType.OFFICE:
|
1307
1317
|
case FieldType.SIGNATURE:
|
1308
|
-
|
1309
|
-
schema = required ? RequiredTextValue : TextValue;
|
1318
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1310
1319
|
break;
|
1311
1320
|
case FieldType.NUMBER:
|
1312
1321
|
schema = NumberFieldValue;
|
@@ -1334,7 +1343,7 @@ function createValidationSchema(config) {
|
|
1334
1343
|
for (const field2 of config) {
|
1335
1344
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1336
1345
|
}
|
1337
|
-
return
|
1346
|
+
return import_zod16.z.object(shape);
|
1338
1347
|
}
|
1339
1348
|
function mapFieldTypeToMockValue(field2, i) {
|
1340
1349
|
switch (field2.type) {
|
@@ -1372,6 +1381,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1372
1381
|
};
|
1373
1382
|
case FieldType.DATE:
|
1374
1383
|
return "2021-01-01";
|
1384
|
+
case FieldType.DATE_RANGE:
|
1385
|
+
return ["2021-01-01", "2021-01-02"];
|
1375
1386
|
case FieldType.CHECKBOX:
|
1376
1387
|
return true;
|
1377
1388
|
case FieldType.FILE:
|
@@ -1406,6 +1417,7 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1406
1417
|
case FieldType.EMAIL:
|
1407
1418
|
case FieldType.DATE:
|
1408
1419
|
case FieldType.CHECKBOX:
|
1420
|
+
case FieldType.DATE_RANGE:
|
1409
1421
|
case FieldType.DATA:
|
1410
1422
|
return null;
|
1411
1423
|
case FieldType.ADDRESS:
|
@@ -1438,6 +1450,9 @@ var isParagraphFieldType = (field2) => {
|
|
1438
1450
|
var isDateFieldType = (field2) => {
|
1439
1451
|
return field2.config.type === FieldType.DATE;
|
1440
1452
|
};
|
1453
|
+
var isDateRangeFieldType = (field2) => {
|
1454
|
+
return field2.config.type === FieldType.DATE_RANGE;
|
1455
|
+
};
|
1441
1456
|
var isPageHeaderFieldType = (field2) => {
|
1442
1457
|
return field2.config.type === FieldType.PAGE_HEADER;
|
1443
1458
|
};
|
@@ -1508,12 +1523,23 @@ var ajv = new import_ajv.default({
|
|
1508
1523
|
function validate(schema, data) {
|
1509
1524
|
return ajv.validate(schema, data);
|
1510
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
|
+
}
|
1511
1532
|
function getConditionalActionsForField(field2, values) {
|
1512
1533
|
if (!field2.conditionals) {
|
1513
1534
|
return [];
|
1514
1535
|
}
|
1515
1536
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1516
1537
|
}
|
1538
|
+
function areConditionsMet(conditions, values) {
|
1539
|
+
return conditions.every(
|
1540
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1541
|
+
);
|
1542
|
+
}
|
1517
1543
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1518
1544
|
const hasRule = (field2.conditionals ?? []).some(
|
1519
1545
|
(conditional) => conditional.type === conditionalType
|
@@ -1532,6 +1558,10 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1532
1558
|
function isFieldVisible(field2, form) {
|
1533
1559
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1534
1560
|
}
|
1561
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1562
|
+
const fieldValue = form[field2.id];
|
1563
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1564
|
+
}
|
1535
1565
|
function isFieldEnabled(field2, form) {
|
1536
1566
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1537
1567
|
}
|
@@ -1632,28 +1662,19 @@ function validateFieldInput({
|
|
1632
1662
|
);
|
1633
1663
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1634
1664
|
}
|
1635
|
-
function
|
1665
|
+
function runFieldValidations({
|
1636
1666
|
field: field2,
|
1637
1667
|
values
|
1638
1668
|
}) {
|
1639
|
-
|
1640
|
-
$form: values,
|
1641
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1642
|
-
};
|
1643
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1644
|
-
if (values[field2.id]) {
|
1645
|
-
return {
|
1646
|
-
errors: [
|
1647
|
-
{
|
1648
|
-
message: errorMessages.hiddenField
|
1649
|
-
}
|
1650
|
-
]
|
1651
|
-
};
|
1652
|
-
}
|
1669
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1653
1670
|
return {
|
1654
1671
|
errors: []
|
1655
1672
|
};
|
1656
1673
|
}
|
1674
|
+
const conditionalParameters = {
|
1675
|
+
$form: values,
|
1676
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1677
|
+
};
|
1657
1678
|
const fieldValidationResult = validateFieldInput({
|
1658
1679
|
field: field2,
|
1659
1680
|
value: values[field2.id]
|
@@ -1674,9 +1695,6 @@ function getUUID() {
|
|
1674
1695
|
return (0, import_uuid.v4)();
|
1675
1696
|
}
|
1676
1697
|
|
1677
|
-
// ../commons/src/events/utils.ts
|
1678
|
-
var import_date_fns2 = require("date-fns");
|
1679
|
-
|
1680
1698
|
// ../commons/src/utils.ts
|
1681
1699
|
function getOrThrow(x, message) {
|
1682
1700
|
if (x === void 0 || x === null) {
|
@@ -1713,15 +1731,9 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1713
1731
|
}
|
1714
1732
|
return [];
|
1715
1733
|
};
|
1716
|
-
|
1734
|
+
function getAllAnnotationFields(config) {
|
1717
1735
|
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1718
|
-
}
|
1719
|
-
var findAllFields = (config) => {
|
1720
|
-
return (0, import_lodash.flattenDeep)([
|
1721
|
-
...getDeclarationFields(config),
|
1722
|
-
...getAllAnnotationFields(config)
|
1723
|
-
]);
|
1724
|
-
};
|
1736
|
+
}
|
1725
1737
|
var findRecordActionPages = (config, actionType) => {
|
1726
1738
|
const action = config.actions.find((a) => a.type === actionType);
|
1727
1739
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1744,47 +1756,27 @@ function getActionReview(configuration, actionType) {
|
|
1744
1756
|
function getActionReviewFields(configuration, actionType) {
|
1745
1757
|
return getActionReview(configuration, actionType).fields;
|
1746
1758
|
}
|
1747
|
-
function validateWorkqueueConfig(workqueueConfigs) {
|
1748
|
-
workqueueConfigs.map((workqueue) => {
|
1749
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1750
|
-
(wq) => wq.id === workqueue.id
|
1751
|
-
);
|
1752
|
-
if (!rootWorkqueue) {
|
1753
|
-
throw new Error(
|
1754
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1755
|
-
);
|
1756
|
-
}
|
1757
|
-
});
|
1758
|
-
}
|
1759
1759
|
function isPageVisible(page, formValues) {
|
1760
1760
|
if (!page.conditional) {
|
1761
1761
|
return true;
|
1762
1762
|
}
|
1763
|
-
return
|
1764
|
-
|
1765
|
-
|
1763
|
+
return isConditionMet(page.conditional, formValues);
|
1764
|
+
}
|
1765
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1766
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1767
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1768
|
+
return false;
|
1769
|
+
}
|
1770
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1771
|
+
if (!fieldConfigs.length) {
|
1772
|
+
return true;
|
1773
|
+
}
|
1774
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1766
1775
|
});
|
1767
1776
|
}
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1772
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1773
|
-
return false;
|
1774
|
-
}
|
1775
|
-
return !form[field2.id];
|
1776
|
-
}
|
1777
|
-
function stripHiddenFields(fields, declaration) {
|
1778
|
-
return (0, import_lodash.omitBy)(declaration, (_, fieldId) => {
|
1779
|
-
const field2 = fields.find((f) => f.id === fieldId);
|
1780
|
-
if (!field2) {
|
1781
|
-
return true;
|
1782
|
-
}
|
1783
|
-
if (isOptionalUncheckedCheckbox(field2, declaration)) {
|
1784
|
-
return true;
|
1785
|
-
}
|
1786
|
-
return !isFieldVisible(field2, declaration);
|
1787
|
-
});
|
1777
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1778
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1779
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1788
1780
|
}
|
1789
1781
|
function findActiveDrafts(event2, drafts) {
|
1790
1782
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
@@ -1803,13 +1795,49 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1803
1795
|
annotation: {},
|
1804
1796
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1805
1797
|
createdBy: "@todo",
|
1806
|
-
createdAtLocation: "@todo"
|
1798
|
+
createdAtLocation: "@todo",
|
1799
|
+
status: ActionStatus.Accepted,
|
1800
|
+
transactionId: "@todo",
|
1801
|
+
createdByRole: "@todo"
|
1807
1802
|
}
|
1808
1803
|
};
|
1809
1804
|
}
|
1810
1805
|
function isVerificationPage(page) {
|
1811
1806
|
return page.type === PageTypes.enum.VERIFICATION;
|
1812
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
|
+
}
|
1813
1841
|
function deepMerge(currentDocument, actionDocument) {
|
1814
1842
|
return (0, import_lodash.mergeWith)(
|
1815
1843
|
currentDocument,
|
@@ -1828,19 +1856,57 @@ function deepMerge(currentDocument, actionDocument) {
|
|
1828
1856
|
}
|
1829
1857
|
);
|
1830
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
|
+
}
|
1831
1891
|
|
1832
1892
|
// ../commons/src/events/EventConfig.ts
|
1833
|
-
var
|
1834
|
-
|
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(
|
1835
1897
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1836
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
|
+
),
|
1837
1904
|
summary: SummaryConfig,
|
1838
1905
|
label: TranslationConfig,
|
1839
|
-
actions:
|
1906
|
+
actions: import_zod17.z.array(ActionConfig),
|
1840
1907
|
declaration: DeclarationFormConfig,
|
1841
|
-
|
1842
|
-
|
1843
|
-
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([])
|
1844
1910
|
}).superRefine((event2, ctx) => {
|
1845
1911
|
const allFields = findAllFields(event2);
|
1846
1912
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1856,16 +1922,43 @@ var EventConfig = import_zod20.z.object({
|
|
1856
1922
|
});
|
1857
1923
|
}
|
1858
1924
|
const invalidFields = event2.advancedSearch.flatMap(
|
1859
|
-
(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
|
+
)
|
1860
1932
|
);
|
1861
1933
|
if (invalidFields.length > 0) {
|
1862
1934
|
ctx.addIssue({
|
1863
1935
|
code: "custom",
|
1864
|
-
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.
|
1865
1937
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1866
1938
|
path: ["advancedSearch"]
|
1867
1939
|
});
|
1868
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"
|
1869
1962
|
});
|
1870
1963
|
|
1871
1964
|
// ../commons/src/events/EventConfigInput.ts
|
@@ -1874,338 +1967,878 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
|
1874
1967
|
var definePage = (page) => PageConfig.parse(page);
|
1875
1968
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1876
1969
|
|
1877
|
-
// ../commons/src/events/
|
1878
|
-
var
|
1970
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1971
|
+
var import_zod20 = require("zod");
|
1879
1972
|
|
1880
|
-
// ../commons/src/events/
|
1881
|
-
var
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
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"
|
1887
1987
|
};
|
1888
|
-
var
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
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.")
|
1902
2006
|
});
|
1903
|
-
var
|
1904
|
-
|
1905
|
-
|
1906
|
-
assignedTo: import_zod21.z.string()
|
1907
|
-
})
|
1908
|
-
);
|
1909
|
-
var UnassignedAction = ActionBase.merge(
|
1910
|
-
import_zod21.z.object({
|
1911
|
-
type: import_zod21.z.literal(ActionType.UNASSIGN)
|
1912
|
-
})
|
1913
|
-
);
|
1914
|
-
var RegisterAction = ActionBase.merge(
|
1915
|
-
import_zod21.z.object({
|
1916
|
-
type: import_zod21.z.literal(ActionType.REGISTER),
|
1917
|
-
registrationNumber: import_zod21.z.string().optional()
|
1918
|
-
})
|
1919
|
-
);
|
1920
|
-
var DeclareAction = ActionBase.merge(
|
1921
|
-
import_zod21.z.object({
|
1922
|
-
type: import_zod21.z.literal(ActionType.DECLARE)
|
1923
|
-
})
|
1924
|
-
);
|
1925
|
-
var ValidateAction = ActionBase.merge(
|
1926
|
-
import_zod21.z.object({
|
1927
|
-
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1928
|
-
})
|
1929
|
-
);
|
1930
|
-
var RejectAction = ActionBase.merge(
|
1931
|
-
import_zod21.z.object({
|
1932
|
-
type: import_zod21.z.literal(ActionType.REJECT)
|
1933
|
-
})
|
1934
|
-
);
|
1935
|
-
var MarkAsDuplicateAction = ActionBase.merge(
|
1936
|
-
import_zod21.z.object({
|
1937
|
-
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1938
|
-
})
|
1939
|
-
);
|
1940
|
-
var ArchiveAction = ActionBase.merge(
|
1941
|
-
import_zod21.z.object({
|
1942
|
-
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1943
|
-
})
|
1944
|
-
);
|
1945
|
-
var CreatedAction = ActionBase.merge(
|
1946
|
-
import_zod21.z.object({
|
1947
|
-
type: import_zod21.z.literal(ActionType.CREATE)
|
1948
|
-
})
|
1949
|
-
);
|
1950
|
-
var NotifiedAction = ActionBase.merge(
|
1951
|
-
import_zod21.z.object({
|
1952
|
-
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1953
|
-
})
|
1954
|
-
);
|
1955
|
-
var PrintCertificateAction = ActionBase.merge(
|
1956
|
-
import_zod21.z.object({
|
1957
|
-
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1958
|
-
})
|
1959
|
-
);
|
1960
|
-
var RequestedCorrectionAction = ActionBase.merge(
|
1961
|
-
import_zod21.z.object({
|
1962
|
-
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1963
|
-
})
|
1964
|
-
);
|
1965
|
-
var ApprovedCorrectionAction = ActionBase.merge(
|
1966
|
-
import_zod21.z.object({
|
1967
|
-
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1968
|
-
requestId: import_zod21.z.string()
|
1969
|
-
})
|
1970
|
-
);
|
1971
|
-
var RejectedCorrectionAction = ActionBase.merge(
|
1972
|
-
import_zod21.z.object({
|
1973
|
-
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1974
|
-
requestId: import_zod21.z.string()
|
1975
|
-
})
|
1976
|
-
);
|
1977
|
-
var ReadAction = ActionBase.merge(
|
1978
|
-
import_zod21.z.object({
|
1979
|
-
type: import_zod21.z.literal(ActionType.READ)
|
1980
|
-
})
|
1981
|
-
);
|
1982
|
-
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1983
|
-
CreatedAction,
|
1984
|
-
ValidateAction,
|
1985
|
-
RejectAction,
|
1986
|
-
MarkAsDuplicateAction,
|
1987
|
-
ArchiveAction,
|
1988
|
-
NotifiedAction,
|
1989
|
-
RegisterAction,
|
1990
|
-
DeclareAction,
|
1991
|
-
AssignedAction,
|
1992
|
-
RequestedCorrectionAction,
|
1993
|
-
ApprovedCorrectionAction,
|
1994
|
-
RejectedCorrectionAction,
|
1995
|
-
UnassignedAction,
|
1996
|
-
PrintCertificateAction,
|
1997
|
-
ReadAction
|
1998
|
-
]);
|
1999
|
-
var AsyncRejectActionDocument = ActionBase.omit({
|
2000
|
-
declaration: true,
|
2001
|
-
annotation: true,
|
2002
|
-
createdBy: true,
|
2003
|
-
createdAtLocation: true
|
2004
|
-
}).merge(
|
2005
|
-
import_zod21.z.object({
|
2006
|
-
type: import_zod21.z.enum(ConfirmableActions),
|
2007
|
-
status: import_zod21.z.literal(ActionStatus.Rejected)
|
2008
|
-
})
|
2009
|
-
);
|
2010
|
-
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
2011
|
-
var ResolvedUser = import_zod21.z.object({
|
2012
|
-
id: import_zod21.z.string(),
|
2013
|
-
role: import_zod21.z.string(),
|
2014
|
-
name: import_zod21.z.array(
|
2015
|
-
import_zod21.z.object({
|
2016
|
-
use: import_zod21.z.string(),
|
2017
|
-
given: import_zod21.z.array(import_zod21.z.string()),
|
2018
|
-
family: import_zod21.z.string()
|
2019
|
-
})
|
2007
|
+
var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
2008
|
+
registrationNumber: import_zod18.z.string().describe(
|
2009
|
+
"Registration number of the event. Always present for accepted registrations."
|
2020
2010
|
)
|
2021
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
|
+
};
|
2022
2130
|
|
2023
|
-
// ../commons/src/events/
|
2024
|
-
var
|
2025
|
-
|
2026
|
-
eventId: import_zod22.z.string(),
|
2027
|
-
transactionId: import_zod22.z.string(),
|
2028
|
-
declaration: ActionUpdate,
|
2029
|
-
annotation: ActionUpdate.optional(),
|
2030
|
-
originalActionId: import_zod22.z.string().optional()
|
2131
|
+
// ../commons/src/events/EventIndex.ts
|
2132
|
+
var EventIndex = EventMetadata.extend({
|
2133
|
+
declaration: EventState
|
2031
2134
|
});
|
2032
|
-
var
|
2033
|
-
|
2034
|
-
type:
|
2035
|
-
|
2036
|
-
})
|
2037
|
-
);
|
2038
|
-
var RegisterActionInput = BaseActionInput.merge(
|
2039
|
-
import_zod22.z.object({
|
2040
|
-
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2041
|
-
registrationNumber: import_zod22.z.string().optional()
|
2042
|
-
})
|
2043
|
-
);
|
2044
|
-
var ValidateActionInput = BaseActionInput.merge(
|
2045
|
-
import_zod22.z.object({
|
2046
|
-
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2047
|
-
duplicates: import_zod22.z.array(import_zod22.z.string())
|
2048
|
-
})
|
2049
|
-
);
|
2050
|
-
var NotifyActionInput = BaseActionInput.merge(
|
2051
|
-
import_zod22.z.object({
|
2052
|
-
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2053
|
-
})
|
2054
|
-
);
|
2055
|
-
var DeclareActionInput = BaseActionInput.merge(
|
2056
|
-
import_zod22.z.object({
|
2057
|
-
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2058
|
-
})
|
2059
|
-
);
|
2060
|
-
var PrintCertificateActionInput = BaseActionInput.merge(
|
2061
|
-
import_zod22.z.object({
|
2062
|
-
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2063
|
-
})
|
2064
|
-
);
|
2065
|
-
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2066
|
-
import_zod22.z.object({
|
2067
|
-
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2068
|
-
})
|
2069
|
-
);
|
2070
|
-
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2071
|
-
import_zod22.z.object({
|
2072
|
-
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2073
|
-
})
|
2074
|
-
);
|
2075
|
-
var ArchiveActionInput = BaseActionInput.merge(
|
2076
|
-
import_zod22.z.object({
|
2077
|
-
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2078
|
-
})
|
2079
|
-
);
|
2080
|
-
var AssignActionInput = BaseActionInput.merge(
|
2081
|
-
import_zod22.z.object({
|
2082
|
-
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2083
|
-
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
|
2084
2139
|
})
|
2085
2140
|
);
|
2086
|
-
var
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
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
|
+
])
|
2091
2160
|
);
|
2092
|
-
var
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
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)
|
2178
|
+
});
|
2179
|
+
var QueryType = import_zod19.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
2180
|
+
|
2181
|
+
// ../commons/src/conditionals/conditionals.ts
|
2182
|
+
function defineConditional(schema) {
|
2183
|
+
return schema;
|
2184
|
+
}
|
2185
|
+
function defineFormConditional(schema) {
|
2186
|
+
const schemaWithForm = {
|
2187
|
+
type: "object",
|
2188
|
+
properties: {
|
2189
|
+
$form: schema
|
2190
|
+
},
|
2191
|
+
required: ["$form"]
|
2192
|
+
};
|
2193
|
+
return defineConditional(schemaWithForm);
|
2194
|
+
}
|
2195
|
+
function alwaysTrue() {
|
2196
|
+
return {};
|
2197
|
+
}
|
2198
|
+
function and(...conditions) {
|
2199
|
+
return defineConditional({
|
2200
|
+
type: "object",
|
2201
|
+
allOf: conditions,
|
2202
|
+
required: []
|
2203
|
+
});
|
2204
|
+
}
|
2205
|
+
function or(...conditions) {
|
2206
|
+
return defineConditional({
|
2207
|
+
type: "object",
|
2208
|
+
anyOf: conditions,
|
2209
|
+
required: []
|
2210
|
+
});
|
2211
|
+
}
|
2212
|
+
function not(condition) {
|
2213
|
+
return defineConditional({
|
2214
|
+
type: "object",
|
2215
|
+
not: condition,
|
2216
|
+
required: []
|
2217
|
+
});
|
2218
|
+
}
|
2219
|
+
function never() {
|
2220
|
+
return not(alwaysTrue());
|
2221
|
+
}
|
2222
|
+
var user = {
|
2223
|
+
hasScope: (scope) => defineConditional({
|
2224
|
+
type: "object",
|
2225
|
+
properties: {
|
2226
|
+
$user: {
|
2227
|
+
type: "object",
|
2228
|
+
required: ["scope"],
|
2229
|
+
properties: {
|
2230
|
+
scope: {
|
2231
|
+
type: "array",
|
2232
|
+
contains: {
|
2233
|
+
type: "string",
|
2234
|
+
const: scope
|
2235
|
+
}
|
2236
|
+
}
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
},
|
2240
|
+
required: ["$user"]
|
2241
|
+
})
|
2242
|
+
};
|
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
|
+
}
|
2266
|
+
}
|
2267
|
+
},
|
2268
|
+
required: ["actions"]
|
2269
|
+
}
|
2270
|
+
},
|
2271
|
+
required: ["$event"]
|
2272
|
+
})
|
2273
|
+
};
|
2274
|
+
}
|
2275
|
+
function getDateFromNow(days) {
|
2276
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2277
|
+
}
|
2278
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2279
|
+
return {
|
2280
|
+
type: "object",
|
2281
|
+
properties: {
|
2282
|
+
[fieldId]: {
|
2283
|
+
type: "string",
|
2284
|
+
format: "date",
|
2285
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2286
|
+
},
|
2287
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2288
|
+
},
|
2289
|
+
required: [fieldId]
|
2290
|
+
};
|
2291
|
+
}
|
2292
|
+
function isFieldReference(value) {
|
2293
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2294
|
+
}
|
2295
|
+
function createFieldConditionals(fieldId) {
|
2296
|
+
const getDateRange = (date, clause) => ({
|
2297
|
+
type: "object",
|
2298
|
+
properties: {
|
2299
|
+
[fieldId]: {
|
2300
|
+
type: "string",
|
2301
|
+
format: "date",
|
2302
|
+
[clause]: date
|
2303
|
+
}
|
2304
|
+
},
|
2305
|
+
required: [fieldId]
|
2306
|
+
});
|
2307
|
+
return {
|
2308
|
+
isAfter: () => ({
|
2309
|
+
days: (days) => ({
|
2310
|
+
inPast: () => defineFormConditional(
|
2311
|
+
getDateRange(getDateFromNow(days), "formatMinimum")
|
2312
|
+
),
|
2313
|
+
inFuture: () => defineFormConditional(
|
2314
|
+
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2315
|
+
)
|
2316
|
+
}),
|
2317
|
+
date: (date) => {
|
2318
|
+
if (isFieldReference(date)) {
|
2319
|
+
const comparedFieldId = date._fieldId;
|
2320
|
+
return defineFormConditional(
|
2321
|
+
getDateRangeToFieldReference(
|
2322
|
+
fieldId,
|
2323
|
+
comparedFieldId,
|
2324
|
+
"formatMinimum"
|
2325
|
+
)
|
2326
|
+
);
|
2327
|
+
}
|
2328
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2329
|
+
},
|
2330
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2331
|
+
}),
|
2332
|
+
isBefore: () => ({
|
2333
|
+
days: (days) => ({
|
2334
|
+
inPast: () => defineFormConditional(
|
2335
|
+
getDateRange(getDateFromNow(days), "formatMaximum")
|
2336
|
+
),
|
2337
|
+
inFuture: () => defineFormConditional(
|
2338
|
+
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2339
|
+
)
|
2340
|
+
}),
|
2341
|
+
date: (date) => {
|
2342
|
+
if (isFieldReference(date)) {
|
2343
|
+
const comparedFieldId = date._fieldId;
|
2344
|
+
return defineFormConditional(
|
2345
|
+
getDateRangeToFieldReference(
|
2346
|
+
fieldId,
|
2347
|
+
comparedFieldId,
|
2348
|
+
"formatMaximum"
|
2349
|
+
)
|
2350
|
+
);
|
2351
|
+
}
|
2352
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2353
|
+
},
|
2354
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2355
|
+
}),
|
2356
|
+
isEqualTo: (value) => {
|
2357
|
+
if (isFieldReference(value)) {
|
2358
|
+
const comparedFieldId = value._fieldId;
|
2359
|
+
return defineFormConditional({
|
2360
|
+
type: "object",
|
2361
|
+
properties: {
|
2362
|
+
[fieldId]: {
|
2363
|
+
type: ["string", "boolean"],
|
2364
|
+
const: { $data: `1/${comparedFieldId}` }
|
2365
|
+
},
|
2366
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2367
|
+
},
|
2368
|
+
required: [fieldId, comparedFieldId]
|
2369
|
+
});
|
2370
|
+
}
|
2371
|
+
return defineFormConditional({
|
2372
|
+
type: "object",
|
2373
|
+
properties: {
|
2374
|
+
[fieldId]: {
|
2375
|
+
oneOf: [
|
2376
|
+
{ type: "string", const: value },
|
2377
|
+
{ type: "boolean", const: value }
|
2378
|
+
],
|
2379
|
+
const: value
|
2380
|
+
}
|
2381
|
+
},
|
2382
|
+
required: [fieldId]
|
2383
|
+
});
|
2384
|
+
},
|
2385
|
+
/**
|
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
|
+
})
|
2096
2611
|
);
|
2097
2612
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2098
|
-
|
2099
|
-
requestId:
|
2100
|
-
type:
|
2613
|
+
import_zod21.z.object({
|
2614
|
+
requestId: import_zod21.z.string(),
|
2615
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2101
2616
|
})
|
2102
2617
|
);
|
2103
2618
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2104
|
-
|
2105
|
-
requestId:
|
2106
|
-
type:
|
2619
|
+
import_zod21.z.object({
|
2620
|
+
requestId: import_zod21.z.string(),
|
2621
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2107
2622
|
})
|
2108
2623
|
);
|
2109
2624
|
var ReadActionInput = BaseActionInput.merge(
|
2110
|
-
|
2111
|
-
type:
|
2625
|
+
import_zod21.z.object({
|
2626
|
+
type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
|
2112
2627
|
})
|
2113
2628
|
);
|
2114
|
-
var
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
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
|
+
});
|
2131
2657
|
|
2132
2658
|
// ../commons/src/events/Draft.ts
|
2133
|
-
var Draft =
|
2134
|
-
id:
|
2135
|
-
eventId:
|
2136
|
-
transactionId:
|
2137
|
-
createdAt:
|
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(),
|
2138
2664
|
action: ActionBase.extend({
|
2139
2665
|
type: ActionTypes
|
2140
2666
|
}).omit({ id: true })
|
2141
2667
|
});
|
2142
2668
|
var DraftInput = BaseActionInput.extend({
|
2143
|
-
type: ActionTypes
|
2669
|
+
type: ActionTypes,
|
2670
|
+
status: import_zod22.z.enum([
|
2671
|
+
ActionStatus.Requested,
|
2672
|
+
ActionStatus.Accepted,
|
2673
|
+
ActionStatus.Rejected
|
2674
|
+
])
|
2144
2675
|
});
|
2145
2676
|
|
2146
2677
|
// ../commons/src/events/EventInput.ts
|
2147
|
-
var
|
2148
|
-
var EventInput =
|
2149
|
-
transactionId:
|
2150
|
-
type:
|
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()
|
2151
2683
|
});
|
2152
2684
|
|
2153
2685
|
// ../commons/src/events/EventDocument.ts
|
2154
|
-
var
|
2155
|
-
var
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
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" });
|
2163
2698
|
|
2164
|
-
// ../commons/src/events/
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
)
|
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
|
+
}
|
2175
2771
|
|
2176
2772
|
// ../commons/src/events/state/index.ts
|
2177
2773
|
function getStatusFromActions(actions) {
|
2178
2774
|
const hasRejectedAction = actions.some(
|
2179
2775
|
(a) => a.status === ActionStatus.Rejected
|
2180
2776
|
);
|
2181
|
-
if (hasRejectedAction) {
|
2182
|
-
return EventStatus.REJECTED;
|
2183
|
-
}
|
2184
|
-
return actions.reduce((status, action) => {
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
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;
|
2205
2807
|
}
|
2206
|
-
return status;
|
2207
2808
|
}, EventStatus.CREATED);
|
2208
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
|
+
}
|
2209
2842
|
function getAssignedUserFromActions(actions) {
|
2210
2843
|
return actions.reduce((user2, action) => {
|
2211
2844
|
if (action.type === ActionType.ASSIGN) {
|
@@ -2238,7 +2871,7 @@ function aggregateActionDeclarations(actions) {
|
|
2238
2871
|
}
|
2239
2872
|
function deepDropNulls(obj) {
|
2240
2873
|
if (Array.isArray(obj)) {
|
2241
|
-
return obj;
|
2874
|
+
return obj.map(deepDropNulls);
|
2242
2875
|
}
|
2243
2876
|
if (obj !== null && typeof obj === "object") {
|
2244
2877
|
return Object.entries(obj).reduce((acc, [key, value]) => {
|
@@ -2260,6 +2893,7 @@ function getAcceptedActions(event2) {
|
|
2260
2893
|
(a) => a.status === ActionStatus.Accepted
|
2261
2894
|
);
|
2262
2895
|
}
|
2896
|
+
var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
2263
2897
|
function getCurrentEventState(event2) {
|
2264
2898
|
const creationAction = event2.actions.find(
|
2265
2899
|
(action) => action.type === ActionType.CREATE
|
@@ -2267,25 +2901,32 @@ function getCurrentEventState(event2) {
|
|
2267
2901
|
if (!creationAction) {
|
2268
2902
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2269
2903
|
}
|
2270
|
-
const
|
2271
|
-
const
|
2272
|
-
|
2273
|
-
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2904
|
+
const acceptedActions = getAcceptedActions(event2);
|
2905
|
+
const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
|
2906
|
+
event2.actions
|
2274
2907
|
);
|
2275
|
-
const
|
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;
|
2276
2912
|
return deepDropNulls({
|
2277
2913
|
id: event2.id,
|
2278
2914
|
type: event2.type,
|
2279
2915
|
status: getStatusFromActions(event2.actions),
|
2280
|
-
|
2916
|
+
legalStatuses: getLegalStatuses(event2.actions),
|
2917
|
+
createdAt: creationAction.createdAt,
|
2281
2918
|
createdBy: creationAction.createdBy,
|
2282
2919
|
createdAtLocation: creationAction.createdAtLocation,
|
2283
|
-
|
2284
|
-
assignedTo: getAssignedUserFromActions(
|
2285
|
-
updatedBy:
|
2286
|
-
|
2920
|
+
updatedAt: declarationUpdateMetadata.createdAt,
|
2921
|
+
assignedTo: getAssignedUserFromActions(acceptedActions),
|
2922
|
+
updatedBy: declarationUpdateMetadata.createdBy,
|
2923
|
+
updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
|
2924
|
+
declaration,
|
2287
2925
|
trackingId: event2.trackingId,
|
2288
|
-
|
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)
|
2289
2930
|
});
|
2290
2931
|
}
|
2291
2932
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2310,356 +2951,123 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
|
|
2310
2951
|
return getCurrentEventState(withDrafts);
|
2311
2952
|
}
|
2312
2953
|
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2313
|
-
const indexedAt = eventIndex.
|
2954
|
+
const indexedAt = eventIndex.updatedAt;
|
2314
2955
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2315
2956
|
if (activeDrafts.length === 0) {
|
2316
2957
|
return eventIndex;
|
2317
2958
|
}
|
2318
2959
|
return {
|
2319
|
-
...eventIndex,
|
2320
|
-
declaration: {
|
2321
|
-
...eventIndex.declaration,
|
2322
|
-
...activeDrafts[activeDrafts.length - 1].declaration
|
2323
|
-
}
|
2324
|
-
};
|
2325
|
-
}
|
2326
|
-
function getAnnotationFromDrafts(drafts) {
|
2327
|
-
const actions = drafts.map((draft) => draft.action);
|
2328
|
-
const annotation = actions.reduce((ann, action) => {
|
2329
|
-
return deepMerge(ann, action.annotation ?? {});
|
2330
|
-
}, {});
|
2331
|
-
return deepDropNulls(annotation);
|
2332
|
-
}
|
2333
|
-
function getActionAnnotation({
|
2334
|
-
event: event2,
|
2335
|
-
actionType,
|
2336
|
-
drafts
|
2337
|
-
}) {
|
2338
|
-
const activeActions = getAcceptedActions(event2);
|
2339
|
-
const action = activeActions.find(
|
2340
|
-
(activeAction) => actionType === activeAction.type
|
2341
|
-
);
|
2342
|
-
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2343
|
-
const sorted = [
|
2344
|
-
...action ? [action] : [],
|
2345
|
-
...eventDrafts.map((draft) => draft.action)
|
2346
|
-
].sort();
|
2347
|
-
const annotation = sorted.reduce((ann, sortedAction) => {
|
2348
|
-
return deepMerge(ann, sortedAction.annotation ?? {});
|
2349
|
-
}, {});
|
2350
|
-
return deepDropNulls(annotation);
|
2351
|
-
}
|
2352
|
-
|
2353
|
-
// ../commons/src/events/defineConfig.ts
|
2354
|
-
var defineConfig = (config) => {
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2367
|
-
|
2368
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
type: "object",
|
2375
|
-
properties: {
|
2376
|
-
$form: schema
|
2377
|
-
},
|
2378
|
-
required: ["$form"]
|
2379
|
-
};
|
2380
|
-
return defineConditional(schemaWithForm);
|
2381
|
-
}
|
2382
|
-
function alwaysTrue() {
|
2383
|
-
return {};
|
2384
|
-
}
|
2385
|
-
function and(...conditions) {
|
2386
|
-
return defineConditional({
|
2387
|
-
type: "object",
|
2388
|
-
allOf: conditions,
|
2389
|
-
required: []
|
2390
|
-
});
|
2391
|
-
}
|
2392
|
-
function or(...conditions) {
|
2393
|
-
return defineConditional({
|
2394
|
-
type: "object",
|
2395
|
-
anyOf: conditions,
|
2396
|
-
required: []
|
2397
|
-
});
|
2398
|
-
}
|
2399
|
-
function not(condition) {
|
2400
|
-
return defineConditional({
|
2401
|
-
type: "object",
|
2402
|
-
not: condition,
|
2403
|
-
required: []
|
2404
|
-
});
|
2405
|
-
}
|
2406
|
-
function never() {
|
2407
|
-
return not(alwaysTrue());
|
2408
|
-
}
|
2409
|
-
var user = {
|
2410
|
-
hasScope: (scope) => defineConditional({
|
2411
|
-
type: "object",
|
2412
|
-
properties: {
|
2413
|
-
$user: {
|
2414
|
-
type: "object",
|
2415
|
-
required: ["scope"],
|
2416
|
-
properties: {
|
2417
|
-
scope: {
|
2418
|
-
type: "array",
|
2419
|
-
contains: {
|
2420
|
-
type: "string",
|
2421
|
-
const: scope
|
2422
|
-
}
|
2423
|
-
}
|
2424
|
-
}
|
2425
|
-
}
|
2426
|
-
},
|
2427
|
-
required: ["$user"]
|
2428
|
-
})
|
2429
|
-
};
|
2430
|
-
var event = {
|
2431
|
-
hasAction: (action) => defineConditional({
|
2432
|
-
type: "object",
|
2433
|
-
properties: {
|
2434
|
-
$event: {
|
2435
|
-
type: "object",
|
2436
|
-
properties: {
|
2437
|
-
actions: {
|
2438
|
-
type: "array",
|
2439
|
-
contains: {
|
2440
|
-
type: "object",
|
2441
|
-
properties: {
|
2442
|
-
type: {
|
2443
|
-
const: action
|
2444
|
-
}
|
2445
|
-
},
|
2446
|
-
required: ["type"]
|
2447
|
-
}
|
2448
|
-
}
|
2449
|
-
},
|
2450
|
-
required: ["actions"]
|
2451
|
-
}
|
2452
|
-
},
|
2453
|
-
required: ["$event"]
|
2454
|
-
})
|
2455
|
-
};
|
2456
|
-
function getDateFromNow(days) {
|
2457
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2458
|
-
}
|
2459
|
-
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2460
|
-
return {
|
2461
|
-
type: "object",
|
2462
|
-
properties: {
|
2463
|
-
[fieldId]: {
|
2464
|
-
type: "string",
|
2465
|
-
format: "date",
|
2466
|
-
[clause]: { $data: `1/${comparedFieldId}` }
|
2467
|
-
},
|
2468
|
-
[comparedFieldId]: { type: "string", format: "date" }
|
2469
|
-
},
|
2470
|
-
required: [fieldId]
|
2471
|
-
};
|
2472
|
-
}
|
2473
|
-
function isFieldReference(value) {
|
2474
|
-
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2475
|
-
}
|
2476
|
-
function field(fieldId) {
|
2477
|
-
const getDateRange = (date, clause) => ({
|
2478
|
-
type: "object",
|
2479
|
-
properties: {
|
2480
|
-
[fieldId]: {
|
2481
|
-
type: "string",
|
2482
|
-
format: "date",
|
2483
|
-
[clause]: date
|
2484
|
-
}
|
2485
|
-
},
|
2486
|
-
required: [fieldId]
|
2487
|
-
});
|
2488
|
-
return {
|
2489
|
-
/**
|
2490
|
-
* @private Internal property used for field reference tracking.
|
2491
|
-
*/
|
2492
|
-
_fieldId: fieldId,
|
2493
|
-
isAfter: () => ({
|
2494
|
-
days: (days) => ({
|
2495
|
-
inPast: () => defineFormConditional(
|
2496
|
-
getDateRange(getDateFromNow(days), "formatMinimum")
|
2497
|
-
),
|
2498
|
-
inFuture: () => defineFormConditional(
|
2499
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2500
|
-
)
|
2501
|
-
}),
|
2502
|
-
date: (date) => {
|
2503
|
-
if (isFieldReference(date)) {
|
2504
|
-
const comparedFieldId = date._fieldId;
|
2505
|
-
return defineFormConditional(
|
2506
|
-
getDateRangeToFieldReference(
|
2507
|
-
fieldId,
|
2508
|
-
comparedFieldId,
|
2509
|
-
"formatMinimum"
|
2510
|
-
)
|
2511
|
-
);
|
2512
|
-
}
|
2513
|
-
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2514
|
-
},
|
2515
|
-
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2516
|
-
}),
|
2517
|
-
isBefore: () => ({
|
2518
|
-
days: (days) => ({
|
2519
|
-
inPast: () => defineFormConditional(
|
2520
|
-
getDateRange(getDateFromNow(days), "formatMaximum")
|
2521
|
-
),
|
2522
|
-
inFuture: () => defineFormConditional(
|
2523
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2524
|
-
)
|
2525
|
-
}),
|
2526
|
-
date: (date) => {
|
2527
|
-
if (isFieldReference(date)) {
|
2528
|
-
const comparedFieldId = date._fieldId;
|
2529
|
-
return defineFormConditional(
|
2530
|
-
getDateRangeToFieldReference(
|
2531
|
-
fieldId,
|
2532
|
-
comparedFieldId,
|
2533
|
-
"formatMaximum"
|
2534
|
-
)
|
2535
|
-
);
|
2536
|
-
}
|
2537
|
-
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2538
|
-
},
|
2539
|
-
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2540
|
-
}),
|
2541
|
-
isEqualTo: (value) => {
|
2542
|
-
if (isFieldReference(value)) {
|
2543
|
-
const comparedFieldId = value._fieldId;
|
2544
|
-
return defineFormConditional({
|
2545
|
-
type: "object",
|
2546
|
-
properties: {
|
2547
|
-
[fieldId]: {
|
2548
|
-
type: ["string", "boolean"],
|
2549
|
-
const: { $data: `1/${comparedFieldId}` }
|
2550
|
-
},
|
2551
|
-
[comparedFieldId]: { type: ["string", "boolean"] }
|
2552
|
-
},
|
2553
|
-
required: [fieldId, comparedFieldId]
|
2554
|
-
});
|
2555
|
-
}
|
2556
|
-
return defineFormConditional({
|
2557
|
-
type: "object",
|
2558
|
-
properties: {
|
2559
|
-
[fieldId]: {
|
2560
|
-
oneOf: [
|
2561
|
-
{ type: "string", const: value },
|
2562
|
-
{ type: "boolean", const: value }
|
2563
|
-
],
|
2564
|
-
const: value
|
2565
|
-
}
|
2566
|
-
},
|
2567
|
-
required: [fieldId]
|
2568
|
-
});
|
2569
|
-
},
|
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 {
|
2570
3015
|
/**
|
2571
|
-
*
|
2572
|
-
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
2573
|
-
* @returns whether the field is falsy (undefined, false, null, empty string)
|
3016
|
+
* Creates a range configuration for the specified field.
|
2574
3017
|
*
|
2575
|
-
*
|
3018
|
+
* @returns An object containing the field ID and a configuration object with a type of 'range'.
|
2576
3019
|
*
|
3020
|
+
* @example field('age').range()
|
3021
|
+
* // {
|
3022
|
+
* // fieldId: 'age',
|
3023
|
+
* // config: { type: 'range' }
|
3024
|
+
* // }
|
2577
3025
|
*/
|
2578
|
-
|
2579
|
-
|
2580
|
-
|
2581
|
-
[fieldId]: {
|
2582
|
-
anyOf: [
|
2583
|
-
{ const: "undefined" },
|
2584
|
-
{ const: false },
|
2585
|
-
{ const: null },
|
2586
|
-
{ const: "" }
|
2587
|
-
]
|
2588
|
-
}
|
2589
|
-
},
|
2590
|
-
anyOf: [
|
2591
|
-
{
|
2592
|
-
required: [fieldId]
|
2593
|
-
},
|
2594
|
-
{
|
2595
|
-
not: {
|
2596
|
-
required: [fieldId]
|
2597
|
-
}
|
2598
|
-
}
|
2599
|
-
]
|
2600
|
-
}),
|
2601
|
-
isUndefined: () => defineFormConditional({
|
2602
|
-
type: "object",
|
2603
|
-
properties: {
|
2604
|
-
[fieldId]: {
|
2605
|
-
type: "string",
|
2606
|
-
enum: ["undefined"]
|
2607
|
-
}
|
2608
|
-
},
|
2609
|
-
not: {
|
2610
|
-
required: [fieldId]
|
2611
|
-
}
|
2612
|
-
}),
|
2613
|
-
inArray: (values) => defineFormConditional({
|
2614
|
-
type: "object",
|
2615
|
-
properties: {
|
2616
|
-
[fieldId]: {
|
2617
|
-
type: "string",
|
2618
|
-
enum: values
|
2619
|
-
}
|
2620
|
-
},
|
2621
|
-
required: [fieldId]
|
2622
|
-
}),
|
2623
|
-
isValidEnglishName: () => defineFormConditional({
|
2624
|
-
type: "object",
|
2625
|
-
properties: {
|
2626
|
-
[fieldId]: {
|
2627
|
-
type: "string",
|
2628
|
-
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'._-]*)*$",
|
2629
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2630
|
-
}
|
2631
|
-
},
|
2632
|
-
required: [fieldId]
|
3026
|
+
range: () => ({
|
3027
|
+
...baseField,
|
3028
|
+
config: { type: "range" }
|
2633
3029
|
}),
|
2634
3030
|
/**
|
2635
|
-
*
|
2636
|
-
* @
|
2637
|
-
* @
|
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
|
+
* // }
|
2638
3038
|
*/
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
[fieldId]: {
|
2643
|
-
type: "string",
|
2644
|
-
pattern
|
2645
|
-
}
|
2646
|
-
},
|
2647
|
-
required: [fieldId]
|
3039
|
+
exact: () => ({
|
3040
|
+
...baseField,
|
3041
|
+
config: { type: "exact" }
|
2648
3042
|
}),
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
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" }
|
2659
3055
|
})
|
2660
3056
|
};
|
2661
3057
|
}
|
2662
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
|
+
|
2663
3071
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2664
3072
|
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2665
3073
|
label: {
|
@@ -3398,9 +3806,8 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3398
3806
|
},
|
3399
3807
|
{
|
3400
3808
|
id: "applicant.dob",
|
3401
|
-
type:
|
3809
|
+
type: FieldType.DATE,
|
3402
3810
|
required: true,
|
3403
|
-
conditionals: [],
|
3404
3811
|
validation: [
|
3405
3812
|
{
|
3406
3813
|
message: {
|
@@ -3411,12 +3818,50 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3411
3818
|
validator: field("applicant.dob").isBefore().now()
|
3412
3819
|
}
|
3413
3820
|
],
|
3821
|
+
conditionals: [
|
3822
|
+
{
|
3823
|
+
type: ConditionalType.SHOW,
|
3824
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3825
|
+
}
|
3826
|
+
],
|
3414
3827
|
label: {
|
3415
3828
|
defaultMessage: "Applicant's date of birth",
|
3416
3829
|
description: "This is the label for the field",
|
3417
3830
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3418
3831
|
}
|
3419
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
|
+
},
|
3420
3865
|
{
|
3421
3866
|
id: "applicant.image",
|
3422
3867
|
type: FieldType.FILE,
|
@@ -3539,20 +3984,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3539
3984
|
description: "This is what this event is referred as in the system",
|
3540
3985
|
id: "event.tennis-club-membership.label"
|
3541
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
|
+
},
|
3542
3992
|
summary: {
|
3543
|
-
title: {
|
3544
|
-
id: "event.tennis-club-membership.summary.title",
|
3545
|
-
label: {
|
3546
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3547
|
-
description: "This is the title of the summary",
|
3548
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3549
|
-
},
|
3550
|
-
emptyValueMessage: {
|
3551
|
-
defaultMessage: "Membership application",
|
3552
|
-
description: "This is the message shown when the applicant name is missing",
|
3553
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3554
|
-
}
|
3555
|
-
},
|
3556
3993
|
fields: [
|
3557
3994
|
{
|
3558
3995
|
id: "applicant.firstname",
|
@@ -3573,47 +4010,18 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3573
4010
|
}
|
3574
4011
|
},
|
3575
4012
|
{
|
3576
|
-
|
4013
|
+
fieldId: "applicant.surname",
|
3577
4014
|
label: {
|
3578
4015
|
defaultMessage: "Applicant's last name",
|
3579
|
-
description: "
|
3580
|
-
id: "event.tennis-club-membership.summary.field.surname.label"
|
3581
|
-
},
|
3582
|
-
value: {
|
3583
|
-
defaultMessage: "{applicant.surname}",
|
3584
|
-
description: "This is the value to show in the summary",
|
3585
|
-
id: "event.tennis-club-membership.summary.field.surname"
|
3586
|
-
},
|
3587
|
-
emptyValueMessage: {
|
3588
|
-
defaultMessage: "Last name is not provided",
|
3589
|
-
description: "This is the message to show when the field is empty",
|
3590
|
-
id: "event.tennis-club-membership.summary.field.surname.empty"
|
4016
|
+
description: "Label for surname",
|
4017
|
+
id: "v2.event.tennis-club-membership.summary.field.surname.label"
|
3591
4018
|
}
|
4019
|
+
},
|
4020
|
+
{
|
4021
|
+
fieldId: "applicant.email"
|
3592
4022
|
}
|
3593
4023
|
]
|
3594
4024
|
},
|
3595
|
-
workqueues: [
|
3596
|
-
{
|
3597
|
-
id: "all",
|
3598
|
-
filters: []
|
3599
|
-
},
|
3600
|
-
{
|
3601
|
-
id: "ready-for-review",
|
3602
|
-
filters: [
|
3603
|
-
{
|
3604
|
-
status: ["DECLARED"]
|
3605
|
-
}
|
3606
|
-
]
|
3607
|
-
},
|
3608
|
-
{
|
3609
|
-
id: "registered",
|
3610
|
-
filters: [
|
3611
|
-
{
|
3612
|
-
status: ["REGISTERED"]
|
3613
|
-
}
|
3614
|
-
]
|
3615
|
-
}
|
3616
|
-
],
|
3617
4025
|
actions: [
|
3618
4026
|
{
|
3619
4027
|
type: ActionType.DECLARE,
|
@@ -3921,18 +4329,14 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3921
4329
|
description: "This is what this event is referred as in the system",
|
3922
4330
|
id: "v2.event.tennis-club-membership.search"
|
3923
4331
|
},
|
3924
|
-
fields: [
|
3925
|
-
{
|
3926
|
-
fieldId: "applicant.dob"
|
3927
|
-
}
|
3928
|
-
]
|
4332
|
+
fields: [field("applicant.dob").exact()]
|
3929
4333
|
}
|
3930
4334
|
],
|
3931
4335
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3932
4336
|
});
|
3933
4337
|
|
3934
4338
|
// ../commons/src/events/test.utils.ts
|
3935
|
-
function
|
4339
|
+
function fieldConfigsToActionPayload(fields) {
|
3936
4340
|
return fields.reduce(
|
3937
4341
|
(acc, field2, i) => ({
|
3938
4342
|
...acc,
|
@@ -3941,26 +4345,27 @@ function fieldConfigsToActionAnnotation(fields) {
|
|
3941
4345
|
{}
|
3942
4346
|
);
|
3943
4347
|
}
|
3944
|
-
function
|
4348
|
+
function generateActionDeclarationInput(configuration, action) {
|
3945
4349
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
3946
4350
|
if (parsed.success) {
|
3947
4351
|
const fields = getDeclarationFields(configuration);
|
3948
|
-
const
|
3949
|
-
|
4352
|
+
const declarationConfig = getDeclaration(configuration);
|
4353
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4354
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
3950
4355
|
}
|
3951
4356
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
3952
4357
|
return {};
|
3953
4358
|
}
|
3954
|
-
function
|
4359
|
+
function generateActionAnnotationInput(configuration, action) {
|
3955
4360
|
const actionConfig = configuration.actions.find(
|
3956
4361
|
(ac) => ac.type === action
|
3957
4362
|
);
|
3958
4363
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3959
|
-
const annotation =
|
3960
|
-
const visibleVerificationPageIds =
|
3961
|
-
configuration,
|
3962
|
-
|
3963
|
-
)
|
4364
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4365
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4366
|
+
findRecordActionPages(configuration, action),
|
4367
|
+
annotation
|
4368
|
+
);
|
3964
4369
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3965
4370
|
(acc, pageId) => ({
|
3966
4371
|
...acc,
|
@@ -3968,7 +4373,7 @@ function generateActionMetadataInput(configuration, action) {
|
|
3968
4373
|
}),
|
3969
4374
|
{}
|
3970
4375
|
);
|
3971
|
-
const fieldBasedPayload =
|
4376
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
3972
4377
|
return {
|
3973
4378
|
...fieldBasedPayload,
|
3974
4379
|
...visiblePageVerificationMap
|
@@ -3991,6 +4396,7 @@ var eventPayloadGenerator = {
|
|
3991
4396
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3992
4397
|
transactionId: getUUID(),
|
3993
4398
|
action: {
|
4399
|
+
transactionId: getUUID(),
|
3994
4400
|
type: actionType,
|
3995
4401
|
status: ActionStatus.Accepted,
|
3996
4402
|
declaration: {
|
@@ -4005,6 +4411,7 @@ var eventPayloadGenerator = {
|
|
4005
4411
|
},
|
4006
4412
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
4007
4413
|
createdBy: "@todo",
|
4414
|
+
createdByRole: "@todo",
|
4008
4415
|
createdAtLocation: "@todo"
|
4009
4416
|
}
|
4010
4417
|
},
|
@@ -4014,8 +4421,11 @@ var eventPayloadGenerator = {
|
|
4014
4421
|
declare: (eventId, input = {}) => ({
|
4015
4422
|
type: ActionType.DECLARE,
|
4016
4423
|
transactionId: input.transactionId ?? getUUID(),
|
4017
|
-
declaration: input.declaration ??
|
4018
|
-
|
4424
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4425
|
+
tennisClubMembershipEvent,
|
4426
|
+
ActionType.DECLARE
|
4427
|
+
),
|
4428
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4019
4429
|
tennisClubMembershipEvent,
|
4020
4430
|
ActionType.DECLARE
|
4021
4431
|
),
|
@@ -4028,7 +4438,10 @@ var eventPayloadGenerator = {
|
|
4028
4438
|
let declaration = input.declaration;
|
4029
4439
|
if (!declaration) {
|
4030
4440
|
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4031
|
-
|
4441
|
+
generateActionDeclarationInput(
|
4442
|
+
tennisClubMembershipEvent,
|
4443
|
+
ActionType.DECLARE
|
4444
|
+
),
|
4032
4445
|
import_lodash2.isString
|
4033
4446
|
);
|
4034
4447
|
declaration = partialDeclaration;
|
@@ -4043,8 +4456,11 @@ var eventPayloadGenerator = {
|
|
4043
4456
|
validate: (eventId, input = {}) => ({
|
4044
4457
|
type: ActionType.VALIDATE,
|
4045
4458
|
transactionId: input.transactionId ?? getUUID(),
|
4046
|
-
declaration: input.declaration ??
|
4047
|
-
|
4459
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4460
|
+
tennisClubMembershipEvent,
|
4461
|
+
ActionType.VALIDATE
|
4462
|
+
),
|
4463
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4048
4464
|
tennisClubMembershipEvent,
|
4049
4465
|
ActionType.VALIDATE
|
4050
4466
|
),
|
@@ -4078,7 +4494,7 @@ var eventPayloadGenerator = {
|
|
4078
4494
|
type: ActionType.REJECT,
|
4079
4495
|
transactionId: input.transactionId ?? getUUID(),
|
4080
4496
|
declaration: {},
|
4081
|
-
annotation: input.annotation ??
|
4497
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4082
4498
|
tennisClubMembershipEvent,
|
4083
4499
|
ActionType.REJECT
|
4084
4500
|
),
|
@@ -4088,8 +4504,11 @@ var eventPayloadGenerator = {
|
|
4088
4504
|
register: (eventId, input = {}) => ({
|
4089
4505
|
type: ActionType.REGISTER,
|
4090
4506
|
transactionId: input.transactionId ?? getUUID(),
|
4091
|
-
declaration: input.declaration ??
|
4092
|
-
|
4507
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4508
|
+
tennisClubMembershipEvent,
|
4509
|
+
ActionType.REGISTER
|
4510
|
+
),
|
4511
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4093
4512
|
tennisClubMembershipEvent,
|
4094
4513
|
ActionType.REGISTER
|
4095
4514
|
),
|
@@ -4099,7 +4518,7 @@ var eventPayloadGenerator = {
|
|
4099
4518
|
type: ActionType.PRINT_CERTIFICATE,
|
4100
4519
|
transactionId: input.transactionId ?? getUUID(),
|
4101
4520
|
declaration: {},
|
4102
|
-
annotation: input.annotation ??
|
4521
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4103
4522
|
tennisClubMembershipEvent,
|
4104
4523
|
ActionType.PRINT_CERTIFICATE
|
4105
4524
|
),
|
@@ -4109,11 +4528,11 @@ var eventPayloadGenerator = {
|
|
4109
4528
|
request: (eventId, input = {}) => ({
|
4110
4529
|
type: ActionType.REQUEST_CORRECTION,
|
4111
4530
|
transactionId: input.transactionId ?? getUUID(),
|
4112
|
-
declaration: input.declaration ??
|
4531
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4113
4532
|
tennisClubMembershipEvent,
|
4114
4533
|
ActionType.REQUEST_CORRECTION
|
4115
4534
|
),
|
4116
|
-
annotation: input.annotation ??
|
4535
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4117
4536
|
tennisClubMembershipEvent,
|
4118
4537
|
ActionType.REQUEST_CORRECTION
|
4119
4538
|
),
|
@@ -4123,7 +4542,7 @@ var eventPayloadGenerator = {
|
|
4123
4542
|
type: ActionType.APPROVE_CORRECTION,
|
4124
4543
|
transactionId: input.transactionId ?? getUUID(),
|
4125
4544
|
declaration: {},
|
4126
|
-
annotation: input.annotation ??
|
4545
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4127
4546
|
tennisClubMembershipEvent,
|
4128
4547
|
ActionType.APPROVE_CORRECTION
|
4129
4548
|
),
|
@@ -4134,7 +4553,7 @@ var eventPayloadGenerator = {
|
|
4134
4553
|
type: ActionType.REJECT_CORRECTION,
|
4135
4554
|
transactionId: input.transactionId ?? getUUID(),
|
4136
4555
|
declaration: {},
|
4137
|
-
annotation: input.annotation ??
|
4556
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4138
4557
|
tennisClubMembershipEvent,
|
4139
4558
|
ActionType.REJECT_CORRECTION
|
4140
4559
|
),
|
@@ -4154,12 +4573,14 @@ function generateActionDocument({
|
|
4154
4573
|
// @TODO: This should be fixed in the future.
|
4155
4574
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4156
4575
|
createdBy: getUUID(),
|
4576
|
+
createdByRole: "FIELD_AGENT",
|
4157
4577
|
id: getUUID(),
|
4158
|
-
createdAtLocation: "
|
4159
|
-
declaration:
|
4578
|
+
createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
4579
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4160
4580
|
annotation: {},
|
4161
|
-
|
4162
|
-
|
4581
|
+
status: ActionStatus.Accepted,
|
4582
|
+
transactionId: getUUID(),
|
4583
|
+
...defaults
|
4163
4584
|
};
|
4164
4585
|
switch (action) {
|
4165
4586
|
case ActionType.READ:
|
@@ -4169,7 +4590,7 @@ function generateActionDocument({
|
|
4169
4590
|
case ActionType.DECLARE:
|
4170
4591
|
return { ...actionBase, type: action };
|
4171
4592
|
case ActionType.UNASSIGN:
|
4172
|
-
return { ...actionBase, type: action };
|
4593
|
+
return { ...actionBase, type: action, assignedTo: null };
|
4173
4594
|
case ActionType.ASSIGN:
|
4174
4595
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
4175
4596
|
case ActionType.VALIDATE:
|
@@ -4217,7 +4638,8 @@ function generateEventDocument({
|
|
4217
4638
|
id: getUUID(),
|
4218
4639
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4219
4640
|
// @TODO: This should be fixed in the future.
|
4220
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4641
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4642
|
+
dateOfEvent: configuration.dateOfEvent
|
4221
4643
|
};
|
4222
4644
|
}
|
4223
4645
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4239,23 +4661,76 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
|
|
4239
4661
|
eventId
|
4240
4662
|
};
|
4241
4663
|
}
|
4664
|
+
function getEventStatus() {
|
4665
|
+
const statuses = [
|
4666
|
+
EventStatus.CREATED,
|
4667
|
+
EventStatus.REGISTERED,
|
4668
|
+
EventStatus.DECLARED
|
4669
|
+
];
|
4670
|
+
const randomIndex = Math.floor(Math.random() * 3);
|
4671
|
+
return statuses[randomIndex];
|
4672
|
+
}
|
4673
|
+
function getTrackingId() {
|
4674
|
+
const uuid = getUUID().replace(/-/g, "");
|
4675
|
+
const trackingId = uuid.slice(0, 6).toUpperCase();
|
4676
|
+
return trackingId;
|
4677
|
+
}
|
4678
|
+
function getRandomApplicant() {
|
4679
|
+
const firstNames = [
|
4680
|
+
"Danny",
|
4681
|
+
"John",
|
4682
|
+
"Jane",
|
4683
|
+
"Emily",
|
4684
|
+
"Michael",
|
4685
|
+
"Sarah",
|
4686
|
+
"Chris",
|
4687
|
+
"Jessica"
|
4688
|
+
];
|
4689
|
+
const surnames = [
|
4690
|
+
"Doe",
|
4691
|
+
"Smith",
|
4692
|
+
"Johnson",
|
4693
|
+
"Brown",
|
4694
|
+
"Williams",
|
4695
|
+
"Jones",
|
4696
|
+
"Garcia",
|
4697
|
+
"Miller"
|
4698
|
+
];
|
4699
|
+
function getRandomDate(start, end) {
|
4700
|
+
const randomDate = new Date(
|
4701
|
+
start.getTime() + Math.random() * (end.getTime() - start.getTime())
|
4702
|
+
);
|
4703
|
+
return randomDate.toISOString().split("T")[0];
|
4704
|
+
}
|
4705
|
+
const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
4706
|
+
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
|
4707
|
+
const randomDob = getRandomDate(
|
4708
|
+
/* @__PURE__ */ new Date("1990-01-01"),
|
4709
|
+
/* @__PURE__ */ new Date("2010-12-31")
|
4710
|
+
);
|
4711
|
+
return {
|
4712
|
+
"recommender.none": true,
|
4713
|
+
"applicant.firstname": randomFirstName,
|
4714
|
+
"applicant.surname": randomSurname,
|
4715
|
+
"applicant.dob": randomDob
|
4716
|
+
};
|
4717
|
+
}
|
4242
4718
|
var eventQueryDataGenerator = (overrides = {}) => ({
|
4243
4719
|
id: overrides.id ?? getUUID(),
|
4244
|
-
type: overrides.type ?? "
|
4245
|
-
status: overrides.status ??
|
4720
|
+
type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
4721
|
+
status: overrides.status ?? getEventStatus(),
|
4246
4722
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4247
4723
|
createdBy: overrides.createdBy ?? getUUID(),
|
4248
4724
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
4249
|
-
|
4725
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4726
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4250
4727
|
assignedTo: overrides.assignedTo ?? null,
|
4251
4728
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4255
|
-
|
4256
|
-
|
4257
|
-
},
|
4258
|
-
trackingId: overrides.trackingId ?? "M3F8YQ"
|
4729
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4730
|
+
flags: [],
|
4731
|
+
legalStatuses: overrides.legalStatuses ?? {},
|
4732
|
+
declaration: overrides.declaration ?? getRandomApplicant(),
|
4733
|
+
trackingId: overrides.trackingId ?? getTrackingId()
|
4259
4734
|
});
|
4260
4735
|
var generateTranslationConfig = (message) => ({
|
4261
4736
|
defaultMessage: message,
|
@@ -4294,3 +4769,293 @@ function isFieldConfigDefaultValue(value) {
|
|
4294
4769
|
}
|
4295
4770
|
return false;
|
4296
4771
|
}
|
4772
|
+
|
4773
|
+
// ../commons/src/events/scopes.ts
|
4774
|
+
var import_lodash3 = require("lodash");
|
4775
|
+
|
4776
|
+
// ../commons/src/scopes.ts
|
4777
|
+
var import_zod25 = require("zod");
|
4778
|
+
var SCOPES = {
|
4779
|
+
// TODO v1.8 legacy scopes
|
4780
|
+
NATLSYSADMIN: "natlsysadmin",
|
4781
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
4782
|
+
DECLARE: "declare",
|
4783
|
+
REGISTER: "register",
|
4784
|
+
VALIDATE: "validate",
|
4785
|
+
DEMO: "demo",
|
4786
|
+
CERTIFY: "certify",
|
4787
|
+
PERFORMANCE: "performance",
|
4788
|
+
SYSADMIN: "sysadmin",
|
4789
|
+
TEAMS: "teams",
|
4790
|
+
CONFIG: "config",
|
4791
|
+
// systems / integrations
|
4792
|
+
WEBHOOK: "webhook",
|
4793
|
+
NATIONALID: "nationalId",
|
4794
|
+
NOTIFICATION_API: "notification-api",
|
4795
|
+
RECORDSEARCH: "recordsearch",
|
4796
|
+
/**
|
4797
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4798
|
+
*/
|
4799
|
+
RECORD_DECLARE: "record.declare-birth",
|
4800
|
+
// declare
|
4801
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4802
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4803
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
4804
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4805
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4806
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4807
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4808
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4809
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4810
|
+
// validate
|
4811
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4812
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4813
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4814
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4815
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4816
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4817
|
+
// register
|
4818
|
+
RECORD_REGISTER: "record.register",
|
4819
|
+
// certify
|
4820
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
4821
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4822
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4823
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4824
|
+
// v1.8
|
4825
|
+
/**
|
4826
|
+
* This scope is used to **print and **issue certified copies of a record
|
4827
|
+
* after it has been registered. Previously Registrars had this permission.
|
4828
|
+
*/
|
4829
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4830
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4831
|
+
// v1.8
|
4832
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4833
|
+
// v1.8
|
4834
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4835
|
+
// v1.8
|
4836
|
+
// correct
|
4837
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4838
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4839
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4840
|
+
// v1.8
|
4841
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4842
|
+
// v1.8
|
4843
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4844
|
+
// v1.8
|
4845
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4846
|
+
// v1.8
|
4847
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4848
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4849
|
+
// search
|
4850
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4851
|
+
SEARCH_BIRTH: "search.birth",
|
4852
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4853
|
+
SEARCH_DEATH: "search.death",
|
4854
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4855
|
+
SEARCH_MARRIAGE: "search.marriage",
|
4856
|
+
// audit v1.8
|
4857
|
+
RECORD_READ: "record.read",
|
4858
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
4859
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
4860
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4861
|
+
// profile
|
4862
|
+
PROFILE_UPDATE: "profile.update",
|
4863
|
+
//v1.8
|
4864
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4865
|
+
// performance
|
4866
|
+
PERFORMANCE_READ: "performance.read",
|
4867
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4868
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4869
|
+
// organisation
|
4870
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4871
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4872
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4873
|
+
// user
|
4874
|
+
USER_READ: "user.read:all",
|
4875
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
4876
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4877
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4878
|
+
//v1.8
|
4879
|
+
USER_CREATE: "user.create:all",
|
4880
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4881
|
+
USER_UPDATE: "user.update:all",
|
4882
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4883
|
+
// config
|
4884
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
4885
|
+
// data seeding
|
4886
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
4887
|
+
};
|
4888
|
+
var LiteralScopes = import_zod25.z.union([
|
4889
|
+
import_zod25.z.literal(SCOPES.NATLSYSADMIN),
|
4890
|
+
import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
|
4891
|
+
import_zod25.z.literal(SCOPES.DECLARE),
|
4892
|
+
import_zod25.z.literal(SCOPES.REGISTER),
|
4893
|
+
import_zod25.z.literal(SCOPES.VALIDATE),
|
4894
|
+
import_zod25.z.literal(SCOPES.DEMO),
|
4895
|
+
import_zod25.z.literal(SCOPES.CERTIFY),
|
4896
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE),
|
4897
|
+
import_zod25.z.literal(SCOPES.SYSADMIN),
|
4898
|
+
import_zod25.z.literal(SCOPES.TEAMS),
|
4899
|
+
import_zod25.z.literal(SCOPES.CONFIG),
|
4900
|
+
import_zod25.z.literal(SCOPES.WEBHOOK),
|
4901
|
+
import_zod25.z.literal(SCOPES.NATIONALID),
|
4902
|
+
import_zod25.z.literal(SCOPES.NOTIFICATION_API),
|
4903
|
+
import_zod25.z.literal(SCOPES.RECORDSEARCH),
|
4904
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
4905
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
4906
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
4907
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
4908
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
4909
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
4910
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
4911
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
|
4912
|
+
import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
|
4913
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
4914
|
+
import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
4915
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
4916
|
+
import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
4917
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
4918
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
|
4919
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTER),
|
4920
|
+
import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
4921
|
+
import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
4922
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
4923
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
|
4924
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
4925
|
+
import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
4926
|
+
import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
4927
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
|
4928
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
4929
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
4930
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
4931
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
|
4932
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
4933
|
+
import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
4934
|
+
import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
4935
|
+
import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
|
4936
|
+
import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
4937
|
+
import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
|
4938
|
+
import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
4939
|
+
import_zod25.z.literal(SCOPES.SEARCH_DEATH),
|
4940
|
+
import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
4941
|
+
import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
|
4942
|
+
import_zod25.z.literal(SCOPES.RECORD_READ),
|
4943
|
+
import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
|
4944
|
+
import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
4945
|
+
import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
|
4946
|
+
import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
|
4947
|
+
import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
4948
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
|
4949
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
4950
|
+
import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
|
4951
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
4952
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
4953
|
+
import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
|
4954
|
+
import_zod25.z.literal(SCOPES.USER_READ),
|
4955
|
+
import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
4956
|
+
import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
4957
|
+
import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
4958
|
+
import_zod25.z.literal(SCOPES.USER_CREATE),
|
4959
|
+
import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
4960
|
+
import_zod25.z.literal(SCOPES.USER_UPDATE),
|
4961
|
+
import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
|
4962
|
+
import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
4963
|
+
import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
|
4964
|
+
]);
|
4965
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
|
4966
|
+
var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
|
4967
|
+
var CreateUserScope = import_zod25.z.object({
|
4968
|
+
type: import_zod25.z.literal("user.create"),
|
4969
|
+
options: import_zod25.z.object({
|
4970
|
+
role: import_zod25.z.array(import_zod25.z.string())
|
4971
|
+
})
|
4972
|
+
});
|
4973
|
+
var EditUserScope = import_zod25.z.object({
|
4974
|
+
type: import_zod25.z.literal("user.edit"),
|
4975
|
+
options: import_zod25.z.object({
|
4976
|
+
role: import_zod25.z.array(import_zod25.z.string())
|
4977
|
+
})
|
4978
|
+
});
|
4979
|
+
var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
|
4980
|
+
CreateUserScope,
|
4981
|
+
EditUserScope
|
4982
|
+
]);
|
4983
|
+
var scopes = Object.values(SCOPES);
|
4984
|
+
|
4985
|
+
// ../commons/src/events/scopes.ts
|
4986
|
+
function hasAnyOfScopes(a, b) {
|
4987
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4988
|
+
}
|
4989
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
4990
|
+
SCOPES.RECORD_DECLARE,
|
4991
|
+
SCOPES.RECORD_READ,
|
4992
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4993
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4994
|
+
SCOPES.RECORD_REGISTER,
|
4995
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
4996
|
+
SCOPES.CONFIG,
|
4997
|
+
SCOPES.CONFIG_UPDATE_ALL
|
4998
|
+
];
|
4999
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
5000
|
+
SCOPES.SEARCH_BIRTH,
|
5001
|
+
SCOPES.SEARCH_DEATH,
|
5002
|
+
SCOPES.SEARCH_MARRIAGE,
|
5003
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
5004
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
5005
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
5006
|
+
];
|
5007
|
+
var ACTION_ALLOWED_SCOPES = {
|
5008
|
+
[ActionType.READ]: [
|
5009
|
+
SCOPES.RECORD_DECLARE,
|
5010
|
+
SCOPES.RECORD_READ,
|
5011
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5012
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
5013
|
+
SCOPES.RECORD_REGISTER,
|
5014
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
5015
|
+
],
|
5016
|
+
[ActionType.CREATE]: [
|
5017
|
+
SCOPES.RECORD_DECLARE,
|
5018
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
5019
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
5020
|
+
],
|
5021
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
5022
|
+
[ActionType.DECLARE]: [
|
5023
|
+
SCOPES.RECORD_DECLARE,
|
5024
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5025
|
+
SCOPES.RECORD_REGISTER
|
5026
|
+
],
|
5027
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
5028
|
+
[ActionType.VALIDATE]: [
|
5029
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
5030
|
+
SCOPES.RECORD_REGISTER
|
5031
|
+
],
|
5032
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
5033
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
5034
|
+
[ActionType.REQUEST_CORRECTION]: [
|
5035
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
5036
|
+
],
|
5037
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5038
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
5039
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5040
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
5041
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
5042
|
+
[ActionType.ASSIGN]: null,
|
5043
|
+
[ActionType.UNASSIGN]: null,
|
5044
|
+
[ActionType.DETECT_DUPLICATE]: []
|
5045
|
+
};
|
5046
|
+
function filterUnallowedActions(actions, userScopes) {
|
5047
|
+
const allowedActions = actions.filter((action) => {
|
5048
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
5049
|
+
if (requiredScopes === null) {
|
5050
|
+
return true;
|
5051
|
+
}
|
5052
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
5053
|
+
});
|
5054
|
+
const hasOtherAllowedActions = allowedActions.some(
|
5055
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
5056
|
+
);
|
5057
|
+
if (hasOtherAllowedActions) {
|
5058
|
+
return allowedActions;
|
5059
|
+
}
|
5060
|
+
return [ActionType.READ];
|
5061
|
+
}
|