@opencrvs/toolkit 1.8.0-rc.f876361 → 1.8.0-rc.f881988
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 +7334 -1430
- package/dist/commons/conditionals/conditionals.d.ts +23 -13
- package/dist/commons/conditionals/validate.d.ts +12 -17
- package/dist/commons/events/ActionConfig.d.ts +86380 -1682
- package/dist/commons/events/ActionDocument.d.ts +420 -103
- package/dist/commons/events/ActionInput.d.ts +1135 -232
- package/dist/commons/events/ActionType.d.ts +5 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +371 -25
- package/dist/commons/events/CompositeFieldValue.d.ts +3 -0
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +37 -15
- package/dist/commons/events/EventConfig.d.ts +41061 -1337
- package/dist/commons/events/EventDocument.d.ts +334 -77
- package/dist/commons/events/EventIndex.d.ts +915 -4
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +13 -3
- package/dist/commons/events/FieldConfig.d.ts +3628 -745
- package/dist/commons/events/FieldType.d.ts +1 -2
- package/dist/commons/events/FieldValue.d.ts +1 -1
- package/dist/commons/events/FormConfig.d.ts +38845 -517
- package/dist/commons/events/PageConfig.d.ts +9655 -211
- package/dist/commons/events/SummaryConfig.d.ts +81 -42
- package/dist/commons/events/TemplateConfig.d.ts +5 -5
- package/dist/commons/events/User.d.ts +5 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +44 -20
- package/dist/commons/events/defineConfig.d.ts +6681 -31
- package/dist/commons/events/event.d.ts +25 -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 +20 -149
- package/dist/commons/events/utils.d.ts +3417 -97
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +164 -181
- package/dist/events/index.js +1336 -889
- package/package.json +3 -2
package/dist/events/index.js
CHANGED
@@ -30,6 +30,7 @@ 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,
|
@@ -49,8 +50,11 @@ __export(events_exports, {
|
|
49
50
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
50
51
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
51
52
|
ArchiveActionInput: () => ArchiveActionInput,
|
53
|
+
AssignActionInput: () => AssignActionInput,
|
52
54
|
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
53
55
|
BaseActionInput: () => BaseActionInput,
|
56
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
57
|
+
CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
|
54
58
|
CertificateConfig: () => CertificateConfig,
|
55
59
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
56
60
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
@@ -68,6 +72,8 @@ __export(events_exports, {
|
|
68
72
|
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
69
73
|
DeclareActionInput: () => DeclareActionInput,
|
70
74
|
DeduplicationConfig: () => DeduplicationConfig,
|
75
|
+
DeleteActionInput: () => DeleteActionInput,
|
76
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
71
77
|
Draft: () => Draft,
|
72
78
|
DraftInput: () => DraftInput,
|
73
79
|
EmailField: () => EmailField,
|
@@ -75,13 +81,17 @@ __export(events_exports, {
|
|
75
81
|
EnableConditional: () => EnableConditional,
|
76
82
|
EventConfig: () => EventConfig,
|
77
83
|
EventDocument: () => EventDocument,
|
84
|
+
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
85
|
+
EventFieldId: () => EventFieldId,
|
78
86
|
EventIndex: () => EventIndex,
|
79
87
|
EventInput: () => EventInput,
|
80
88
|
EventMetadata: () => EventMetadata,
|
81
89
|
EventSearchIndex: () => EventSearchIndex,
|
82
90
|
EventStatus: () => EventStatus,
|
83
91
|
EventStatuses: () => EventStatuses,
|
92
|
+
FieldConditional: () => FieldConditional,
|
84
93
|
FieldConfig: () => FieldConfig,
|
94
|
+
FieldConfigSchema: () => FieldConfigSchema,
|
85
95
|
FieldType: () => FieldType,
|
86
96
|
FieldUpdateValue: () => FieldUpdateValue,
|
87
97
|
FieldValue: () => FieldValue,
|
@@ -96,39 +106,48 @@ __export(events_exports, {
|
|
96
106
|
ImageMimeType: () => ImageMimeType,
|
97
107
|
LanguageConfig: () => LanguageConfig,
|
98
108
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
109
|
+
MatchType: () => MatchType,
|
99
110
|
MimeType: () => MimeType,
|
111
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
100
112
|
NotifyActionInput: () => NotifyActionInput,
|
101
113
|
NumberFieldValue: () => NumberFieldValue,
|
102
114
|
PageConfig: () => PageConfig,
|
103
|
-
PageConfigBase: () => PageConfigBase,
|
104
115
|
PageTypes: () => PageTypes,
|
105
116
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
117
|
+
QueryInput: () => QueryInput,
|
118
|
+
QueryType: () => QueryType,
|
106
119
|
ReadActionInput: () => ReadActionInput,
|
107
120
|
RegisterAction: () => RegisterAction,
|
108
121
|
RegisterActionInput: () => RegisterActionInput,
|
109
122
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
110
123
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
111
124
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
112
|
-
RequiredTextValue: () => RequiredTextValue,
|
113
125
|
ResolvedUser: () => ResolvedUser,
|
114
126
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
115
127
|
RuralAddressValue: () => RuralAddressValue,
|
128
|
+
SearchField: () => SearchField,
|
129
|
+
SelectOption: () => SelectOption,
|
116
130
|
ShowConditional: () => ShowConditional,
|
117
131
|
SummaryConfig: () => SummaryConfig,
|
118
132
|
TextValue: () => TextValue,
|
119
133
|
TranslationConfig: () => TranslationConfig,
|
134
|
+
UnassignActionInput: () => UnassignActionInput,
|
120
135
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
121
136
|
UrbanAddressValue: () => UrbanAddressValue,
|
122
137
|
ValidateActionInput: () => ValidateActionInput,
|
123
138
|
VerificationActionConfig: () => VerificationActionConfig,
|
124
139
|
VerificationPageConfig: () => VerificationPageConfig,
|
125
140
|
WorkqueueConfig: () => WorkqueueConfig,
|
141
|
+
ZodDate: () => ZodDate,
|
126
142
|
alwaysTrue: () => alwaysTrue,
|
127
143
|
and: () => and,
|
128
144
|
annotationActions: () => annotationActions,
|
129
145
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
146
|
+
areConditionsMet: () => areConditionsMet,
|
130
147
|
compositeFieldTypes: () => compositeFieldTypes,
|
131
148
|
createEmptyDraft: () => createEmptyDraft,
|
149
|
+
createEventConditionals: () => createEventConditionals,
|
150
|
+
createFieldConditionals: () => createFieldConditionals,
|
132
151
|
createValidationSchema: () => createValidationSchema,
|
133
152
|
deepDropNulls: () => deepDropNulls,
|
134
153
|
deepMerge: () => deepMerge,
|
@@ -136,8 +155,10 @@ __export(events_exports, {
|
|
136
155
|
defineConditional: () => defineConditional,
|
137
156
|
defineConfig: () => defineConfig,
|
138
157
|
defineDeclarationForm: () => defineDeclarationForm,
|
158
|
+
defineFormConditional: () => defineFormConditional,
|
139
159
|
defineFormPage: () => defineFormPage,
|
140
160
|
definePage: () => definePage,
|
161
|
+
defineWorkqueue: () => defineWorkqueue,
|
141
162
|
errorMessages: () => errorMessages,
|
142
163
|
event: () => event,
|
143
164
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -146,12 +167,14 @@ __export(events_exports, {
|
|
146
167
|
eventStatuses: () => eventStatuses,
|
147
168
|
field: () => field,
|
148
169
|
fieldTypes: () => fieldTypes,
|
170
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
149
171
|
findActiveDrafts: () => findActiveDrafts,
|
150
172
|
findAllFields: () => findAllFields,
|
173
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
151
174
|
findRecordActionPages: () => findRecordActionPages,
|
175
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
176
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
152
177
|
generateActionDocument: () => generateActionDocument,
|
153
|
-
generateActionInput: () => generateActionInput,
|
154
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
155
178
|
generateEventDocument: () => generateEventDocument,
|
156
179
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
157
180
|
generateTransactionId: () => generateTransactionId,
|
@@ -161,18 +184,21 @@ __export(events_exports, {
|
|
161
184
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
162
185
|
getActionReview: () => getActionReview,
|
163
186
|
getActionReviewFields: () => getActionReviewFields,
|
164
|
-
|
187
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
188
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
189
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
165
190
|
getCurrentEventState: () => getCurrentEventState,
|
166
191
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
167
192
|
getDeclaration: () => getDeclaration,
|
168
193
|
getDeclarationFields: () => getDeclarationFields,
|
169
194
|
getDeclarationPages: () => getDeclarationPages,
|
170
|
-
|
171
|
-
|
195
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
196
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
172
197
|
isAddressFieldType: () => isAddressFieldType,
|
173
198
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
174
199
|
isBulletListFieldType: () => isBulletListFieldType,
|
175
200
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
201
|
+
isConditionMet: () => isConditionMet,
|
176
202
|
isCountryFieldType: () => isCountryFieldType,
|
177
203
|
isDataFieldType: () => isDataFieldType,
|
178
204
|
isDateFieldType: () => isDateFieldType,
|
@@ -180,6 +206,7 @@ __export(events_exports, {
|
|
180
206
|
isEmailFieldType: () => isEmailFieldType,
|
181
207
|
isFacilityFieldType: () => isFacilityFieldType,
|
182
208
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
209
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
183
210
|
isFieldEnabled: () => isFieldEnabled,
|
184
211
|
isFieldValue: () => isFieldValue,
|
185
212
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -200,16 +227,21 @@ __export(events_exports, {
|
|
200
227
|
isTextFieldType: () => isTextFieldType,
|
201
228
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
202
229
|
isVerificationPage: () => isVerificationPage,
|
230
|
+
isWriteAction: () => isWriteAction,
|
203
231
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
204
232
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
205
233
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
234
|
+
never: () => never,
|
206
235
|
not: () => not,
|
236
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
237
|
+
omitHiddenFields: () => omitHiddenFields,
|
238
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
207
239
|
or: () => or,
|
208
|
-
|
240
|
+
runFieldValidations: () => runFieldValidations,
|
209
241
|
user: () => user,
|
210
242
|
validate: () => validate,
|
211
243
|
validateFieldInput: () => validateFieldInput,
|
212
|
-
|
244
|
+
writeActions: () => writeActions
|
213
245
|
});
|
214
246
|
module.exports = __toCommonJS(events_exports);
|
215
247
|
|
@@ -218,29 +250,46 @@ var import_zod9 = require("zod");
|
|
218
250
|
|
219
251
|
// ../commons/src/events/Conditional.ts
|
220
252
|
var import_zod = require("zod");
|
221
|
-
|
222
|
-
|
223
|
-
|
253
|
+
var Conditional = import_zod.z.custom(
|
254
|
+
(val) => typeof val === "object" && val !== null
|
255
|
+
);
|
224
256
|
var ConditionalType = {
|
225
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
226
257
|
SHOW: "SHOW",
|
227
|
-
|
228
|
-
|
258
|
+
ENABLE: "ENABLE",
|
259
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
229
260
|
};
|
230
261
|
var ShowConditional = import_zod.z.object({
|
231
262
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
232
|
-
conditional: Conditional
|
233
|
-
})
|
263
|
+
conditional: Conditional
|
264
|
+
}).describe(
|
265
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
266
|
+
);
|
234
267
|
var EnableConditional = import_zod.z.object({
|
235
268
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
236
|
-
conditional: Conditional
|
237
|
-
})
|
269
|
+
conditional: Conditional
|
270
|
+
}).describe(
|
271
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
272
|
+
);
|
238
273
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
239
274
|
// Action can be shown / hidden
|
240
275
|
ShowConditional,
|
241
276
|
// Action can be shown to the user in the list but as disabled
|
242
277
|
EnableConditional
|
243
278
|
]);
|
279
|
+
var DisplayOnReviewConditional = import_zod.z.object({
|
280
|
+
type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
281
|
+
conditional: Conditional
|
282
|
+
}).describe(
|
283
|
+
"If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
|
284
|
+
);
|
285
|
+
var FieldConditional = import_zod.z.discriminatedUnion("type", [
|
286
|
+
// Field input can be shown / hidden
|
287
|
+
ShowConditional,
|
288
|
+
// Field input can be shown to the user but as disabled
|
289
|
+
EnableConditional,
|
290
|
+
// Field output can be shown / hidden on the review page
|
291
|
+
DisplayOnReviewConditional
|
292
|
+
]);
|
244
293
|
|
245
294
|
// ../commons/src/events/PageConfig.ts
|
246
295
|
var import_zod6 = require("zod");
|
@@ -273,7 +322,6 @@ var FieldType = {
|
|
273
322
|
RADIO_GROUP: "RADIO_GROUP",
|
274
323
|
FILE: "FILE",
|
275
324
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
276
|
-
HIDDEN: "HIDDEN",
|
277
325
|
BULLET_LIST: "BULLET_LIST",
|
278
326
|
CHECKBOX: "CHECKBOX",
|
279
327
|
SELECT: "SELECT",
|
@@ -378,7 +426,7 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
378
426
|
|
379
427
|
// ../commons/src/events/FieldValue.ts
|
380
428
|
var TextValue = import_zod4.z.string();
|
381
|
-
var
|
429
|
+
var NonEmptyTextValue = TextValue.min(1);
|
382
430
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
383
431
|
var EmailValue = import_zod4.z.string().email();
|
384
432
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
@@ -411,35 +459,28 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
411
459
|
|
412
460
|
// ../commons/src/events/FieldConfig.ts
|
413
461
|
var FieldId = import_zod5.z.string();
|
414
|
-
var
|
415
|
-
|
416
|
-
|
417
|
-
});
|
462
|
+
var ParentReference = import_zod5.z.object({
|
463
|
+
_fieldId: FieldId.optional()
|
464
|
+
}).optional();
|
418
465
|
var BaseField = import_zod5.z.object({
|
419
466
|
id: FieldId,
|
420
467
|
defaultValue: import_zod5.z.union([
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
NumberFieldValue,
|
427
|
-
CheckboxFieldValue
|
428
|
-
]),
|
429
|
-
DependencyExpression
|
468
|
+
TextValue,
|
469
|
+
NonEmptyTextValue,
|
470
|
+
DateValue,
|
471
|
+
NumberFieldValue,
|
472
|
+
CheckboxFieldValue
|
430
473
|
]).optional(),
|
431
|
-
|
474
|
+
parent: ParentReference,
|
475
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
432
476
|
required: import_zod5.z.boolean().default(false).optional(),
|
433
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
434
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
435
477
|
placeholder: TranslationConfig.optional(),
|
436
478
|
validation: import_zod5.z.array(
|
437
479
|
import_zod5.z.object({
|
438
|
-
validator: Conditional
|
480
|
+
validator: Conditional,
|
439
481
|
message: TranslationConfig
|
440
482
|
})
|
441
483
|
).default([]).optional(),
|
442
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
443
484
|
label: TranslationConfig,
|
444
485
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
445
486
|
});
|
@@ -448,7 +489,7 @@ var Divider = BaseField.extend({
|
|
448
489
|
});
|
449
490
|
var TextField = BaseField.extend({
|
450
491
|
type: import_zod5.z.literal(FieldType.TEXT),
|
451
|
-
defaultValue:
|
492
|
+
defaultValue: NonEmptyTextValue.optional(),
|
452
493
|
configuration: import_zod5.z.object({
|
453
494
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
454
495
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -458,7 +499,7 @@ var TextField = BaseField.extend({
|
|
458
499
|
}).describe("Text input");
|
459
500
|
var NumberField = BaseField.extend({
|
460
501
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
461
|
-
defaultValue:
|
502
|
+
defaultValue: NumberFieldValue.optional(),
|
462
503
|
configuration: import_zod5.z.object({
|
463
504
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
464
505
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -468,7 +509,7 @@ var NumberField = BaseField.extend({
|
|
468
509
|
}).describe("Number input");
|
469
510
|
var TextAreaField = BaseField.extend({
|
470
511
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
471
|
-
defaultValue:
|
512
|
+
defaultValue: NonEmptyTextValue.optional(),
|
472
513
|
configuration: import_zod5.z.object({
|
473
514
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
474
515
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -502,11 +543,11 @@ var EmailField = BaseField.extend({
|
|
502
543
|
configuration: import_zod5.z.object({
|
503
544
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
504
545
|
}).default({ maxLength: 10 }).optional(),
|
505
|
-
defaultValue:
|
546
|
+
defaultValue: NonEmptyTextValue.optional()
|
506
547
|
});
|
507
548
|
var DateField = BaseField.extend({
|
508
549
|
type: import_zod5.z.literal(FieldType.DATE),
|
509
|
-
defaultValue:
|
550
|
+
defaultValue: DateValue.optional(),
|
510
551
|
configuration: import_zod5.z.object({
|
511
552
|
notice: TranslationConfig.describe(
|
512
553
|
"Text to display above the date input"
|
@@ -525,7 +566,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
525
566
|
]);
|
526
567
|
var Paragraph = BaseField.extend({
|
527
568
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
528
|
-
defaultValue:
|
569
|
+
defaultValue: NonEmptyTextValue.optional(),
|
529
570
|
configuration: import_zod5.z.object({
|
530
571
|
styles: import_zod5.z.object({
|
531
572
|
fontVariant: HtmlFontVariant.optional()
|
@@ -534,7 +575,7 @@ var Paragraph = BaseField.extend({
|
|
534
575
|
}).describe("A read-only HTML <p> paragraph");
|
535
576
|
var PageHeader = BaseField.extend({
|
536
577
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
537
|
-
defaultValue:
|
578
|
+
defaultValue: NonEmptyTextValue.optional()
|
538
579
|
}).describe("A read-only header component for form pages");
|
539
580
|
var File = BaseField.extend({
|
540
581
|
type: import_zod5.z.literal(FieldType.FILE),
|
@@ -545,7 +586,8 @@ var File = BaseField.extend({
|
|
545
586
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
546
587
|
"Whether the file upload button should take the full width of the container or not"
|
547
588
|
)
|
548
|
-
}).optional()
|
589
|
+
}).optional(),
|
590
|
+
fileName: TranslationConfig.optional()
|
549
591
|
}).default({
|
550
592
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
551
593
|
})
|
@@ -556,7 +598,7 @@ var SelectOption = import_zod5.z.object({
|
|
556
598
|
});
|
557
599
|
var RadioGroup = BaseField.extend({
|
558
600
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
559
|
-
defaultValue:
|
601
|
+
defaultValue: TextValue.optional(),
|
560
602
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
561
603
|
configuration: import_zod5.z.object({
|
562
604
|
styles: import_zod5.z.object({
|
@@ -566,7 +608,7 @@ var RadioGroup = BaseField.extend({
|
|
566
608
|
}).describe("Grouped radio options");
|
567
609
|
var BulletList = BaseField.extend({
|
568
610
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
569
|
-
defaultValue:
|
611
|
+
defaultValue: TextValue.optional(),
|
570
612
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
571
613
|
configuration: import_zod5.z.object({
|
572
614
|
styles: import_zod5.z.object({
|
@@ -576,16 +618,16 @@ var BulletList = BaseField.extend({
|
|
576
618
|
}).describe("A list of bullet points");
|
577
619
|
var Select = BaseField.extend({
|
578
620
|
type: import_zod5.z.literal(FieldType.SELECT),
|
579
|
-
defaultValue:
|
621
|
+
defaultValue: TextValue.optional(),
|
580
622
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
581
623
|
}).describe("Select input");
|
582
624
|
var Checkbox = BaseField.extend({
|
583
625
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
584
|
-
defaultValue:
|
626
|
+
defaultValue: CheckboxFieldValue.optional()
|
585
627
|
}).describe("Boolean checkbox field");
|
586
628
|
var Country = BaseField.extend({
|
587
629
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
588
|
-
defaultValue:
|
630
|
+
defaultValue: NonEmptyTextValue.optional()
|
589
631
|
}).describe("Country select field");
|
590
632
|
var AdministrativeAreas = import_zod5.z.enum([
|
591
633
|
"ADMIN_STRUCTURE",
|
@@ -600,12 +642,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
|
|
600
642
|
}).describe("Administrative area options");
|
601
643
|
var AdministrativeArea = BaseField.extend({
|
602
644
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
603
|
-
defaultValue:
|
645
|
+
defaultValue: NonEmptyTextValue.optional(),
|
604
646
|
configuration: AdministrativeAreaConfiguration
|
605
647
|
}).describe("Administrative area input field e.g. facility, office");
|
606
648
|
var Location = BaseField.extend({
|
607
649
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
608
|
-
defaultValue:
|
650
|
+
defaultValue: NonEmptyTextValue.optional()
|
609
651
|
}).describe("Input field for a location");
|
610
652
|
var FileUploadWithOptions = BaseField.extend({
|
611
653
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
@@ -619,11 +661,11 @@ var FileUploadWithOptions = BaseField.extend({
|
|
619
661
|
});
|
620
662
|
var Facility = BaseField.extend({
|
621
663
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
622
|
-
defaultValue:
|
664
|
+
defaultValue: NonEmptyTextValue.optional()
|
623
665
|
}).describe("Input field for a facility");
|
624
666
|
var Office = BaseField.extend({
|
625
667
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
626
|
-
defaultValue:
|
668
|
+
defaultValue: NonEmptyTextValue.optional()
|
627
669
|
}).describe("Input field for an office");
|
628
670
|
var Address = BaseField.extend({
|
629
671
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
@@ -632,7 +674,7 @@ var Address = BaseField.extend({
|
|
632
674
|
var DataEntry = import_zod5.z.union([
|
633
675
|
import_zod5.z.object({
|
634
676
|
label: TranslationConfig,
|
635
|
-
value: import_zod5.z.string()
|
677
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
636
678
|
}),
|
637
679
|
import_zod5.z.object({
|
638
680
|
fieldId: import_zod5.z.string()
|
@@ -676,7 +718,7 @@ var PageConfigBase = import_zod6.z.object({
|
|
676
718
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
677
719
|
title: TranslationConfig.describe("Header title of the page"),
|
678
720
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
679
|
-
conditional: Conditional
|
721
|
+
conditional: Conditional.optional().describe(
|
680
722
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
681
723
|
)
|
682
724
|
});
|
@@ -772,6 +814,12 @@ var DeclarationUpdateActions = ActionTypes.extract(
|
|
772
814
|
declarationUpdateActionValues
|
773
815
|
);
|
774
816
|
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
817
|
+
var writeActions = ActionTypes.exclude([
|
818
|
+
ActionType.CREATE,
|
819
|
+
ActionType.READ,
|
820
|
+
ActionType.ASSIGN,
|
821
|
+
ActionType.UNASSIGN
|
822
|
+
]);
|
775
823
|
|
776
824
|
// ../commons/src/events/FormConfig.ts
|
777
825
|
var import_zod8 = require("zod");
|
@@ -786,6 +834,8 @@ var ActionFormConfig = import_zod8.z.object({
|
|
786
834
|
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
787
835
|
|
788
836
|
// ../commons/src/events/ActionConfig.ts
|
837
|
+
var import_zod_openapi = require("zod-openapi");
|
838
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
|
789
839
|
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
790
840
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
791
841
|
ShowConditional,
|
@@ -863,18 +913,24 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
|
|
863
913
|
})
|
864
914
|
);
|
865
915
|
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
916
|
+
/*
|
917
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
918
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
919
|
+
*/
|
920
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
921
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
922
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
923
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
924
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
925
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
926
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
927
|
+
PrintCertificateActionConfig.openapi({
|
928
|
+
ref: "PrintCertificateActionConfig"
|
929
|
+
}),
|
930
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
931
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
932
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
933
|
+
]).openapi({ ref: "ActionConfig" });
|
878
934
|
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
879
935
|
DeclareConfig,
|
880
936
|
ValidateConfig,
|
@@ -918,10 +974,12 @@ var LanguageConfig = import_zod11.z.object({
|
|
918
974
|
});
|
919
975
|
|
920
976
|
// ../commons/src/events/EventConfig.ts
|
921
|
-
var
|
977
|
+
var import_zod16 = require("zod");
|
922
978
|
|
923
979
|
// ../commons/src/events/DeduplicationConfig.ts
|
924
980
|
var import_zod12 = require("zod");
|
981
|
+
var import_zod_openapi2 = require("zod-openapi");
|
982
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
|
925
983
|
var FieldReference = import_zod12.z.string();
|
926
984
|
var Matcher = import_zod12.z.object({
|
927
985
|
fieldId: import_zod12.z.string(),
|
@@ -965,10 +1023,12 @@ var DateDistanceMatcher = Matcher.extend({
|
|
965
1023
|
});
|
966
1024
|
var And = import_zod12.z.object({
|
967
1025
|
type: import_zod12.z.literal("and"),
|
1026
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
968
1027
|
clauses: import_zod12.z.lazy(() => Clause.array())
|
969
1028
|
});
|
970
1029
|
var Or = import_zod12.z.object({
|
971
1030
|
type: import_zod12.z.literal("or"),
|
1031
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
972
1032
|
clauses: import_zod12.z.lazy(() => Clause.array())
|
973
1033
|
});
|
974
1034
|
var Clause = import_zod12.z.lazy(
|
@@ -980,7 +1040,9 @@ var Clause = import_zod12.z.lazy(
|
|
980
1040
|
DateRangeMatcher,
|
981
1041
|
DateDistanceMatcher
|
982
1042
|
])
|
983
|
-
)
|
1043
|
+
).openapi({
|
1044
|
+
ref: "Clause"
|
1045
|
+
});
|
984
1046
|
var DeduplicationConfig = import_zod12.z.object({
|
985
1047
|
id: import_zod12.z.string(),
|
986
1048
|
label: TranslationConfig,
|
@@ -989,272 +1051,62 @@ var DeduplicationConfig = import_zod12.z.object({
|
|
989
1051
|
|
990
1052
|
// ../commons/src/events/SummaryConfig.ts
|
991
1053
|
var import_zod13 = require("zod");
|
992
|
-
var
|
1054
|
+
var BaseField2 = import_zod13.z.object({
|
1055
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1056
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1057
|
+
});
|
1058
|
+
var ReferenceField = BaseField2.extend({
|
1059
|
+
fieldId: import_zod13.z.string()
|
1060
|
+
}).describe("Field directly referencing event data with field id");
|
1061
|
+
var Field = BaseField2.extend({
|
993
1062
|
id: import_zod13.z.string().describe("Id of summary field"),
|
994
1063
|
value: TranslationConfig.describe(
|
995
1064
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
996
1065
|
),
|
997
1066
|
label: TranslationConfig,
|
998
1067
|
emptyValueMessage: TranslationConfig.optional()
|
999
|
-
});
|
1000
|
-
var Title = import_zod13.z.object({
|
1001
|
-
id: import_zod13.z.string(),
|
1002
|
-
label: TranslationConfig.describe("Title content"),
|
1003
|
-
emptyValueMessage: TranslationConfig.optional()
|
1004
|
-
});
|
1068
|
+
}).describe("Custom configured field");
|
1005
1069
|
var SummaryConfig = import_zod13.z.object({
|
1006
|
-
|
1007
|
-
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
1070
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
1008
1071
|
}).describe("Configuration for summary in event.");
|
1009
1072
|
|
1010
|
-
// ../commons/src/events/
|
1011
|
-
var import_zod15 = require("zod");
|
1012
|
-
|
1013
|
-
// ../commons/src/events/EventMetadata.ts
|
1073
|
+
// ../commons/src/events/AdvancedSearchConfig.ts
|
1014
1074
|
var import_zod14 = require("zod");
|
1015
|
-
var
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
CERTIFIED: "CERTIFIED",
|
1022
|
-
REJECTED: "REJECTED",
|
1023
|
-
ARCHIVED: "ARCHIVED"
|
1024
|
-
};
|
1025
|
-
var eventStatuses = Object.values(EventStatus);
|
1026
|
-
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1027
|
-
var EventMetadata = import_zod14.z.object({
|
1028
|
-
id: import_zod14.z.string(),
|
1029
|
-
type: import_zod14.z.string(),
|
1030
|
-
status: EventStatuses,
|
1031
|
-
createdAt: import_zod14.z.string().datetime(),
|
1032
|
-
createdBy: import_zod14.z.string(),
|
1033
|
-
createdAtLocation: import_zod14.z.string(),
|
1034
|
-
modifiedAt: import_zod14.z.string().datetime(),
|
1035
|
-
assignedTo: import_zod14.z.string().nullish(),
|
1036
|
-
updatedBy: import_zod14.z.string(),
|
1037
|
-
trackingId: import_zod14.z.string(),
|
1038
|
-
registrationNumber: import_zod14.z.string().nullish()
|
1075
|
+
var MatchType = import_zod14.z.enum(["FUZZY", "EXACT", "RANGE", "ANY_OF"]);
|
1076
|
+
var BaseField3 = import_zod14.z.object({
|
1077
|
+
config: import_zod14.z.object({
|
1078
|
+
type: MatchType.describe("Determines the type of field")
|
1079
|
+
}),
|
1080
|
+
options: import_zod14.z.array(SelectOption).optional()
|
1039
1081
|
});
|
1040
|
-
var
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
description: "Created At Location"
|
1055
|
-
},
|
1056
|
-
"event.createdBy": {
|
1057
|
-
id: "event.createdBy.label",
|
1058
|
-
defaultMessage: "Created By",
|
1059
|
-
description: "Created By"
|
1060
|
-
},
|
1061
|
-
"event.id": {
|
1062
|
-
id: "event.id.label",
|
1063
|
-
defaultMessage: "ID",
|
1064
|
-
description: "ID"
|
1065
|
-
},
|
1066
|
-
"event.modifiedAt": {
|
1067
|
-
id: "event.modifiedAt.label",
|
1068
|
-
defaultMessage: "Updated",
|
1069
|
-
description: "Modified At"
|
1070
|
-
},
|
1071
|
-
"event.status": {
|
1072
|
-
id: "event.status.label",
|
1073
|
-
defaultMessage: "Status",
|
1074
|
-
description: "Status"
|
1075
|
-
},
|
1076
|
-
"event.type": {
|
1077
|
-
id: "event.type.label",
|
1078
|
-
defaultMessage: "Type",
|
1079
|
-
description: "Type"
|
1080
|
-
},
|
1081
|
-
"event.updatedBy": {
|
1082
|
-
id: "event.updatedBy.label",
|
1083
|
-
defaultMessage: "Updated By",
|
1084
|
-
description: "Updated By"
|
1085
|
-
},
|
1086
|
-
"event.trackingId": {
|
1087
|
-
id: "event.trackingId.label",
|
1088
|
-
defaultMessage: "Tracking ID",
|
1089
|
-
description: "Tracking ID"
|
1090
|
-
},
|
1091
|
-
"event.registrationNumber": {
|
1092
|
-
id: "event.registrationNumber.label",
|
1093
|
-
defaultMessage: "Registration Number",
|
1094
|
-
description: "Registration Number"
|
1095
|
-
}
|
1096
|
-
};
|
1097
|
-
|
1098
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1099
|
-
var WorkqueueConfig = import_zod15.z.object({
|
1100
|
-
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1101
|
-
filters: import_zod15.z.array(
|
1102
|
-
import_zod15.z.object({
|
1103
|
-
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1104
|
-
})
|
1105
|
-
).describe("Filters to be applied to workqueue.")
|
1106
|
-
}).describe("Configuration for workqueue.");
|
1107
|
-
|
1108
|
-
// ../commons/src/events/AdvancedSearchConfig.ts
|
1109
|
-
var import_zod16 = require("zod");
|
1110
|
-
var AdvancedSearchConfig = import_zod16.z.object({
|
1082
|
+
var FieldConfigSchema = BaseField3.extend({
|
1083
|
+
fieldId: import_zod14.z.string(),
|
1084
|
+
fieldType: import_zod14.z.literal("field")
|
1085
|
+
});
|
1086
|
+
var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
|
1087
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1088
|
+
fieldId: EventFieldId,
|
1089
|
+
fieldType: import_zod14.z.literal("event")
|
1090
|
+
});
|
1091
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1092
|
+
FieldConfigSchema,
|
1093
|
+
EventFieldConfigSchema
|
1094
|
+
]);
|
1095
|
+
var AdvancedSearchConfig = import_zod14.z.object({
|
1111
1096
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1112
|
-
fields:
|
1113
|
-
import_zod16.z.object({
|
1114
|
-
fieldId: import_zod16.z.string(),
|
1115
|
-
config: import_zod16.z.object({
|
1116
|
-
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1117
|
-
}).optional().describe("Configuration options for the field")
|
1118
|
-
})
|
1119
|
-
).optional().default([]).describe("Advanced search fields.")
|
1097
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1120
1098
|
});
|
1121
1099
|
|
1122
1100
|
// ../commons/src/events/utils.ts
|
1123
1101
|
var import_lodash = require("lodash");
|
1124
1102
|
|
1125
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1126
|
-
var import_zod18 = require("zod");
|
1127
|
-
|
1128
|
-
// ../commons/src/workqueues/defaultColumns.ts
|
1129
|
-
var import_zod17 = require("zod");
|
1130
|
-
var WorkQueueColumnConfig = import_zod17.z.object({
|
1131
|
-
id: import_zod17.z.string(),
|
1132
|
-
label: TranslationConfig
|
1133
|
-
});
|
1134
|
-
var defaultColumns = {
|
1135
|
-
event: {
|
1136
|
-
id: "event",
|
1137
|
-
label: {
|
1138
|
-
defaultMessage: "Event",
|
1139
|
-
description: "This is the label for the workqueue column",
|
1140
|
-
id: "workqueue.default.column.event"
|
1141
|
-
}
|
1142
|
-
},
|
1143
|
-
status: {
|
1144
|
-
id: "status",
|
1145
|
-
label: {
|
1146
|
-
defaultMessage: "Status",
|
1147
|
-
description: "This is the label for the workqueue column",
|
1148
|
-
id: "workqueue.default.column.status"
|
1149
|
-
}
|
1150
|
-
},
|
1151
|
-
createdAt: {
|
1152
|
-
id: "createdAt",
|
1153
|
-
label: {
|
1154
|
-
defaultMessage: "Created",
|
1155
|
-
description: "This is the label for the workqueue column",
|
1156
|
-
id: "workqueue.default.column.createdAt"
|
1157
|
-
}
|
1158
|
-
},
|
1159
|
-
modifiedAt: {
|
1160
|
-
id: "modifiedAt",
|
1161
|
-
label: {
|
1162
|
-
defaultMessage: "Modified",
|
1163
|
-
description: "This is the label for the workqueue column",
|
1164
|
-
id: "workqueue.default.column.modifiedAt"
|
1165
|
-
}
|
1166
|
-
}
|
1167
|
-
};
|
1168
|
-
var DefaultColumnKeys = import_zod17.z.enum(
|
1169
|
-
Object.keys(defaultColumns)
|
1170
|
-
);
|
1171
|
-
|
1172
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1173
|
-
var rootWorkqueueConfig = import_zod18.z.object({
|
1174
|
-
id: import_zod18.z.string(),
|
1175
|
-
title: TranslationConfig,
|
1176
|
-
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1177
|
-
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1178
|
-
});
|
1179
|
-
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1180
|
-
|
1181
|
-
// ../commons/src/workqueues/all.ts
|
1182
|
-
var allWorkqueue = defineWorkqueue({
|
1183
|
-
id: "all",
|
1184
|
-
title: {
|
1185
|
-
defaultMessage: "All events",
|
1186
|
-
description: "This is the label for the workqueue",
|
1187
|
-
id: "workqueue.all.label"
|
1188
|
-
},
|
1189
|
-
columns: [
|
1190
|
-
{
|
1191
|
-
id: "title",
|
1192
|
-
label: {
|
1193
|
-
defaultMessage: "Title",
|
1194
|
-
description: "This is the label for the workqueue column",
|
1195
|
-
id: "workqueue.all.column.title"
|
1196
|
-
}
|
1197
|
-
}
|
1198
|
-
],
|
1199
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1200
|
-
});
|
1201
|
-
|
1202
|
-
// ../commons/src/workqueues/readyForReview.ts
|
1203
|
-
var inReviewWorkqueue = defineWorkqueue({
|
1204
|
-
id: "ready-for-review",
|
1205
|
-
title: {
|
1206
|
-
defaultMessage: "Ready for review",
|
1207
|
-
description: "Label for in review workqueue",
|
1208
|
-
id: "event.workqueue.in-review.label"
|
1209
|
-
},
|
1210
|
-
columns: [
|
1211
|
-
{
|
1212
|
-
id: "title",
|
1213
|
-
label: {
|
1214
|
-
defaultMessage: "Title",
|
1215
|
-
description: "This is the label for the workqueue column",
|
1216
|
-
id: "workqueue.in-reveiw.column.title"
|
1217
|
-
}
|
1218
|
-
}
|
1219
|
-
],
|
1220
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1221
|
-
});
|
1222
|
-
|
1223
|
-
// ../commons/src/workqueues/readyToPrint.ts
|
1224
|
-
var registeredWorkqueue = defineWorkqueue({
|
1225
|
-
id: "registered",
|
1226
|
-
title: {
|
1227
|
-
defaultMessage: "Ready to print",
|
1228
|
-
description: "Label for registered workqueue",
|
1229
|
-
id: "event.workqueue.registered.label"
|
1230
|
-
},
|
1231
|
-
columns: [
|
1232
|
-
{
|
1233
|
-
id: "title",
|
1234
|
-
label: {
|
1235
|
-
defaultMessage: "Title",
|
1236
|
-
description: "This is the label for the workqueue column",
|
1237
|
-
id: "workqueue.registered.column.title"
|
1238
|
-
}
|
1239
|
-
}
|
1240
|
-
],
|
1241
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1242
|
-
});
|
1243
|
-
|
1244
|
-
// ../commons/src/workqueues/index.ts
|
1245
|
-
var workqueues = {
|
1246
|
-
all: allWorkqueue,
|
1247
|
-
registered: registeredWorkqueue,
|
1248
|
-
inReview: inReviewWorkqueue
|
1249
|
-
};
|
1250
|
-
|
1251
1103
|
// ../commons/src/conditionals/validate.ts
|
1252
1104
|
var import_ajv = __toESM(require("ajv"));
|
1253
1105
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1254
1106
|
var import_date_fns = require("date-fns");
|
1255
1107
|
|
1256
1108
|
// ../commons/src/events/FieldTypeMapping.ts
|
1257
|
-
var
|
1109
|
+
var import_zod15 = require("zod");
|
1258
1110
|
function mapFieldTypeToZod(type, required) {
|
1259
1111
|
let schema;
|
1260
1112
|
switch (type) {
|
@@ -1278,8 +1130,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1278
1130
|
case FieldType.FACILITY:
|
1279
1131
|
case FieldType.OFFICE:
|
1280
1132
|
case FieldType.SIGNATURE:
|
1281
|
-
|
1282
|
-
schema = required ? RequiredTextValue : TextValue;
|
1133
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1283
1134
|
break;
|
1284
1135
|
case FieldType.NUMBER:
|
1285
1136
|
schema = NumberFieldValue;
|
@@ -1307,7 +1158,7 @@ function createValidationSchema(config) {
|
|
1307
1158
|
for (const field2 of config) {
|
1308
1159
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1309
1160
|
}
|
1310
|
-
return
|
1161
|
+
return import_zod15.z.object(shape);
|
1311
1162
|
}
|
1312
1163
|
function mapFieldTypeToMockValue(field2, i) {
|
1313
1164
|
switch (field2.type) {
|
@@ -1481,12 +1332,23 @@ var ajv = new import_ajv.default({
|
|
1481
1332
|
function validate(schema, data) {
|
1482
1333
|
return ajv.validate(schema, data);
|
1483
1334
|
}
|
1335
|
+
function isConditionMet(conditional, values) {
|
1336
|
+
return validate(conditional, {
|
1337
|
+
$form: values,
|
1338
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1339
|
+
});
|
1340
|
+
}
|
1484
1341
|
function getConditionalActionsForField(field2, values) {
|
1485
1342
|
if (!field2.conditionals) {
|
1486
1343
|
return [];
|
1487
1344
|
}
|
1488
1345
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1489
1346
|
}
|
1347
|
+
function areConditionsMet(conditions, values) {
|
1348
|
+
return conditions.every(
|
1349
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1350
|
+
);
|
1351
|
+
}
|
1490
1352
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1491
1353
|
const hasRule = (field2.conditionals ?? []).some(
|
1492
1354
|
(conditional) => conditional.type === conditionalType
|
@@ -1505,9 +1367,16 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1505
1367
|
function isFieldVisible(field2, form) {
|
1506
1368
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1507
1369
|
}
|
1370
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1371
|
+
const fieldValue = form[field2.id];
|
1372
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1373
|
+
}
|
1508
1374
|
function isFieldEnabled(field2, form) {
|
1509
1375
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1510
1376
|
}
|
1377
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1378
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1379
|
+
}
|
1511
1380
|
var errorMessages = {
|
1512
1381
|
hiddenField: {
|
1513
1382
|
id: "v2.error.hidden",
|
@@ -1535,12 +1404,14 @@ var errorMessages = {
|
|
1535
1404
|
id: "v2.error.invalid"
|
1536
1405
|
}
|
1537
1406
|
};
|
1538
|
-
|
1539
|
-
|
1540
|
-
message
|
1541
|
-
|
1542
|
-
}
|
1543
|
-
|
1407
|
+
function createIntlError(message) {
|
1408
|
+
return {
|
1409
|
+
message: {
|
1410
|
+
message
|
1411
|
+
}
|
1412
|
+
};
|
1413
|
+
}
|
1414
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1544
1415
|
switch (issue.code) {
|
1545
1416
|
case "invalid_string": {
|
1546
1417
|
if (_ctx.data === "") {
|
@@ -1578,41 +1449,6 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1578
1449
|
}
|
1579
1450
|
}
|
1580
1451
|
return createIntlError(errorMessages.invalidInput);
|
1581
|
-
};
|
1582
|
-
function getFieldValidationErrors({
|
1583
|
-
field: field2,
|
1584
|
-
values
|
1585
|
-
}) {
|
1586
|
-
const conditionalParameters = {
|
1587
|
-
$form: values,
|
1588
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1589
|
-
};
|
1590
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1591
|
-
if (values[field2.id]) {
|
1592
|
-
return {
|
1593
|
-
errors: [
|
1594
|
-
{
|
1595
|
-
message: errorMessages.hiddenField
|
1596
|
-
}
|
1597
|
-
]
|
1598
|
-
};
|
1599
|
-
}
|
1600
|
-
return {
|
1601
|
-
errors: []
|
1602
|
-
};
|
1603
|
-
}
|
1604
|
-
const fieldValidationResult = validateFieldInput({
|
1605
|
-
field: field2,
|
1606
|
-
value: values[field2.id]
|
1607
|
-
});
|
1608
|
-
const customValidationResults = runCustomFieldValidations({
|
1609
|
-
field: field2,
|
1610
|
-
conditionalParameters
|
1611
|
-
});
|
1612
|
-
return {
|
1613
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1614
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1615
|
-
};
|
1616
1452
|
}
|
1617
1453
|
function runCustomFieldValidations({
|
1618
1454
|
field: field2,
|
@@ -1635,6 +1471,32 @@ function validateFieldInput({
|
|
1635
1471
|
);
|
1636
1472
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1637
1473
|
}
|
1474
|
+
function runFieldValidations({
|
1475
|
+
field: field2,
|
1476
|
+
values
|
1477
|
+
}) {
|
1478
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1479
|
+
return {
|
1480
|
+
errors: []
|
1481
|
+
};
|
1482
|
+
}
|
1483
|
+
const conditionalParameters = {
|
1484
|
+
$form: values,
|
1485
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1486
|
+
};
|
1487
|
+
const fieldValidationResult = validateFieldInput({
|
1488
|
+
field: field2,
|
1489
|
+
value: values[field2.id]
|
1490
|
+
});
|
1491
|
+
const customValidationResults = runCustomFieldValidations({
|
1492
|
+
field: field2,
|
1493
|
+
conditionalParameters
|
1494
|
+
});
|
1495
|
+
return {
|
1496
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1497
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1498
|
+
};
|
1499
|
+
}
|
1638
1500
|
|
1639
1501
|
// ../commons/src/uuid.ts
|
1640
1502
|
var import_uuid = require("uuid");
|
@@ -1642,9 +1504,6 @@ function getUUID() {
|
|
1642
1504
|
return (0, import_uuid.v4)();
|
1643
1505
|
}
|
1644
1506
|
|
1645
|
-
// ../commons/src/events/utils.ts
|
1646
|
-
var import_date_fns2 = require("date-fns");
|
1647
|
-
|
1648
1507
|
// ../commons/src/utils.ts
|
1649
1508
|
function getOrThrow(x, message) {
|
1650
1509
|
if (x === void 0 || x === null) {
|
@@ -1654,15 +1513,18 @@ function getOrThrow(x, message) {
|
|
1654
1513
|
}
|
1655
1514
|
|
1656
1515
|
// ../commons/src/events/utils.ts
|
1657
|
-
|
1658
|
-
return (
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
}
|
1663
|
-
|
1664
|
-
return
|
1665
|
-
}
|
1516
|
+
function isDeclarationActionConfig(action) {
|
1517
|
+
return DeclarationActions.safeParse(action.type).success;
|
1518
|
+
}
|
1519
|
+
function getDeclarationFields(configuration) {
|
1520
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1521
|
+
}
|
1522
|
+
function getDeclarationPages(configuration) {
|
1523
|
+
return configuration.declaration.pages;
|
1524
|
+
}
|
1525
|
+
function getDeclaration(configuration) {
|
1526
|
+
return configuration.declaration;
|
1527
|
+
}
|
1666
1528
|
var getActionAnnotationFields = (actionConfig) => {
|
1667
1529
|
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1668
1530
|
return [
|
@@ -1671,13 +1533,16 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
1671
1533
|
];
|
1672
1534
|
}
|
1673
1535
|
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1674
|
-
return actionConfig
|
1536
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1675
1537
|
}
|
1676
1538
|
if (isDeclarationActionConfig(actionConfig)) {
|
1677
|
-
return actionConfig
|
1539
|
+
return actionConfig.review.fields;
|
1678
1540
|
}
|
1679
1541
|
return [];
|
1680
1542
|
};
|
1543
|
+
function getAllAnnotationFields(config) {
|
1544
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1545
|
+
}
|
1681
1546
|
var findRecordActionPages = (config, actionType) => {
|
1682
1547
|
const action = config.actions.find((a) => a.type === actionType);
|
1683
1548
|
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
@@ -1688,72 +1553,40 @@ var findRecordActionPages = (config, actionType) => {
|
|
1688
1553
|
}
|
1689
1554
|
return [];
|
1690
1555
|
};
|
1691
|
-
function isDeclarationActionConfig(action) {
|
1692
|
-
return DeclarationActions.safeParse(action.type).success;
|
1693
|
-
}
|
1694
|
-
function getDeclarationFields(configuration) {
|
1695
|
-
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1696
|
-
}
|
1697
|
-
function getDeclarationPages(configuration) {
|
1698
|
-
return configuration.declaration.pages;
|
1699
|
-
}
|
1700
|
-
function getDeclaration(configuration) {
|
1701
|
-
return configuration.declaration;
|
1702
|
-
}
|
1703
|
-
function getActionReviewFields(configuration, actionType) {
|
1704
|
-
return getActionReview(configuration, actionType).fields;
|
1705
|
-
}
|
1706
1556
|
function getActionReview(configuration, actionType) {
|
1707
1557
|
const [actionConfig] = configuration.actions.filter(
|
1708
1558
|
(a) => a.type === actionType
|
1709
1559
|
);
|
1710
1560
|
return getOrThrow(
|
1711
|
-
actionConfig
|
1561
|
+
actionConfig.review,
|
1712
1562
|
`No review config found for ${actionType}`
|
1713
1563
|
);
|
1714
1564
|
}
|
1715
|
-
function
|
1716
|
-
|
1717
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1718
|
-
(wq) => wq.id === workqueue.id
|
1719
|
-
);
|
1720
|
-
if (!rootWorkqueue) {
|
1721
|
-
throw new Error(
|
1722
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1723
|
-
);
|
1724
|
-
}
|
1725
|
-
});
|
1565
|
+
function getActionReviewFields(configuration, actionType) {
|
1566
|
+
return getActionReview(configuration, actionType).fields;
|
1726
1567
|
}
|
1727
1568
|
function isPageVisible(page, formValues) {
|
1728
1569
|
if (!page.conditional) {
|
1729
1570
|
return true;
|
1730
1571
|
}
|
1731
|
-
return
|
1732
|
-
$form: formValues,
|
1733
|
-
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1734
|
-
});
|
1572
|
+
return isConditionMet(page.conditional, formValues);
|
1735
1573
|
}
|
1736
|
-
|
1737
|
-
return
|
1738
|
-
|
1739
|
-
|
1740
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1741
|
-
return false;
|
1742
|
-
}
|
1743
|
-
return !form[field2.id];
|
1744
|
-
}
|
1745
|
-
function stripHiddenFields(fields, declaration) {
|
1746
|
-
return (0, import_lodash.omitBy)(declaration, (_2, fieldId) => {
|
1747
|
-
const field2 = fields.find((f) => f.id === fieldId);
|
1748
|
-
if (!field2) {
|
1749
|
-
return true;
|
1574
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1575
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1576
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1577
|
+
return false;
|
1750
1578
|
}
|
1751
|
-
|
1579
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1580
|
+
if (!fieldConfigs.length) {
|
1752
1581
|
return true;
|
1753
1582
|
}
|
1754
|
-
return !isFieldVisible(
|
1583
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1755
1584
|
});
|
1756
1585
|
}
|
1586
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1587
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1588
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1589
|
+
}
|
1757
1590
|
function findActiveDrafts(event2, drafts) {
|
1758
1591
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1759
1592
|
const lastAction = actions[actions.length - 1];
|
@@ -1778,6 +1611,39 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1778
1611
|
function isVerificationPage(page) {
|
1779
1612
|
return page.type === PageTypes.enum.VERIFICATION;
|
1780
1613
|
}
|
1614
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1615
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1616
|
+
}
|
1617
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1618
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1619
|
+
return [
|
1620
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1621
|
+
...getVisibleVerificationPageIds(
|
1622
|
+
actionConfig.additionalDetailsForm,
|
1623
|
+
annotation
|
1624
|
+
)
|
1625
|
+
];
|
1626
|
+
}
|
1627
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1628
|
+
return getVisibleVerificationPageIds(
|
1629
|
+
actionConfig.printForm.pages,
|
1630
|
+
annotation
|
1631
|
+
);
|
1632
|
+
}
|
1633
|
+
return [];
|
1634
|
+
}
|
1635
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1636
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1637
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1638
|
+
actionConfig,
|
1639
|
+
annotation
|
1640
|
+
);
|
1641
|
+
return omitHiddenFields(
|
1642
|
+
annotationFields,
|
1643
|
+
{ ...declaration, ...annotation },
|
1644
|
+
visibleVerificationPageIds
|
1645
|
+
);
|
1646
|
+
}
|
1781
1647
|
function deepMerge(currentDocument, actionDocument) {
|
1782
1648
|
return (0, import_lodash.mergeWith)(
|
1783
1649
|
currentDocument,
|
@@ -1796,19 +1662,39 @@ function deepMerge(currentDocument, actionDocument) {
|
|
1796
1662
|
}
|
1797
1663
|
);
|
1798
1664
|
}
|
1665
|
+
function findLastAssignmentAction(actions) {
|
1666
|
+
return actions.filter(
|
1667
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1668
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1669
|
+
}
|
1670
|
+
function isWriteAction(actionType) {
|
1671
|
+
return writeActions.safeParse(actionType).success;
|
1672
|
+
}
|
1673
|
+
var findAllFields = (config) => {
|
1674
|
+
return (0, import_lodash.flattenDeep)([
|
1675
|
+
...getDeclarationFields(config),
|
1676
|
+
...getAllAnnotationFields(config)
|
1677
|
+
]);
|
1678
|
+
};
|
1799
1679
|
|
1800
1680
|
// ../commons/src/events/EventConfig.ts
|
1801
|
-
var
|
1802
|
-
|
1681
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1682
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod16.z);
|
1683
|
+
var EventConfig = import_zod16.z.object({
|
1684
|
+
id: import_zod16.z.string().describe(
|
1803
1685
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1804
1686
|
),
|
1687
|
+
dateOfEvent: import_zod16.z.object({ fieldId: import_zod16.z.string() }).optional(),
|
1688
|
+
title: TranslationConfig,
|
1689
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1690
|
+
"This is a fallback title if actual title resolves to empty string"
|
1691
|
+
),
|
1805
1692
|
summary: SummaryConfig,
|
1806
1693
|
label: TranslationConfig,
|
1807
|
-
actions:
|
1694
|
+
actions: import_zod16.z.array(ActionConfig),
|
1808
1695
|
declaration: DeclarationFormConfig,
|
1809
|
-
|
1810
|
-
|
1811
|
-
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1696
|
+
deduplication: import_zod16.z.array(DeduplicationConfig).optional().default([]),
|
1697
|
+
advancedSearch: import_zod16.z.array(AdvancedSearchConfig).optional().default([])
|
1812
1698
|
}).superRefine((event2, ctx) => {
|
1813
1699
|
const allFields = findAllFields(event2);
|
1814
1700
|
const fieldIds = allFields.map((field2) => field2.id);
|
@@ -1824,16 +1710,43 @@ var EventConfig = import_zod20.z.object({
|
|
1824
1710
|
});
|
1825
1711
|
}
|
1826
1712
|
const invalidFields = event2.advancedSearch.flatMap(
|
1827
|
-
(section) =>
|
1713
|
+
(section) => (
|
1714
|
+
// Check if the fieldId is not in the fieldIds array
|
1715
|
+
// and also not in the metadataFields array
|
1716
|
+
section.fields.filter(
|
1717
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
1718
|
+
)
|
1719
|
+
)
|
1828
1720
|
);
|
1829
1721
|
if (invalidFields.length > 0) {
|
1830
1722
|
ctx.addIssue({
|
1831
1723
|
code: "custom",
|
1832
|
-
message: `Advanced search id must match a field id
|
1724
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1833
1725
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1834
1726
|
path: ["advancedSearch"]
|
1835
1727
|
});
|
1836
1728
|
}
|
1729
|
+
if (event2.dateOfEvent) {
|
1730
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
1731
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
1732
|
+
);
|
1733
|
+
if (!eventDateFieldId) {
|
1734
|
+
ctx.addIssue({
|
1735
|
+
code: "custom",
|
1736
|
+
message: `Date of event field id must match a field id in fields array.
|
1737
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
1738
|
+
path: ["dateOfEvent"]
|
1739
|
+
});
|
1740
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
1741
|
+
ctx.addIssue({
|
1742
|
+
code: "custom",
|
1743
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
1744
|
+
path: ["dateOfEvent.fieldType"]
|
1745
|
+
});
|
1746
|
+
}
|
1747
|
+
}
|
1748
|
+
}).openapi({
|
1749
|
+
ref: "EventConfig"
|
1837
1750
|
});
|
1838
1751
|
|
1839
1752
|
// ../commons/src/events/EventConfigInput.ts
|
@@ -1842,306 +1755,498 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
|
1842
1755
|
var definePage = (page) => PageConfig.parse(page);
|
1843
1756
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1844
1757
|
|
1758
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1759
|
+
var import_zod17 = require("zod");
|
1760
|
+
var WorkqueueConfig = import_zod17.z.object({
|
1761
|
+
slug: import_zod17.z.string().describe("Determines the url of the workqueue."),
|
1762
|
+
name: TranslationConfig.describe(
|
1763
|
+
"Title of the workflow (both in navigation and on the page)"
|
1764
|
+
),
|
1765
|
+
/**
|
1766
|
+
* Placeholder untill the following gets merged to develop
|
1767
|
+
* https://github.com/opencrvs/opencrvs-core/blob/5fbe9854a88504a7a13fcc856b3e82594b70c38c/packages/commons/src/events/EventIndex.ts#L92-L93
|
1768
|
+
*/
|
1769
|
+
query: import_zod17.z.string(),
|
1770
|
+
actions: import_zod17.z.array(
|
1771
|
+
import_zod17.z.object({
|
1772
|
+
type: import_zod17.z.string(),
|
1773
|
+
conditionals: import_zod17.z.array(Conditional).optional()
|
1774
|
+
})
|
1775
|
+
)
|
1776
|
+
}).describe("Configuration for workqueue.");
|
1777
|
+
function defineWorkqueue(workqueues) {
|
1778
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
1779
|
+
}
|
1780
|
+
|
1845
1781
|
// ../commons/src/events/Draft.ts
|
1846
|
-
var
|
1782
|
+
var import_zod20 = require("zod");
|
1847
1783
|
|
1848
1784
|
// ../commons/src/events/ActionDocument.ts
|
1849
|
-
var
|
1850
|
-
var
|
1785
|
+
var import_zod18 = require("zod");
|
1786
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1787
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod18.z);
|
1788
|
+
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1851
1789
|
var ActionStatus = {
|
1852
1790
|
Requested: "Requested",
|
1853
1791
|
Accepted: "Accepted",
|
1854
1792
|
Rejected: "Rejected"
|
1855
1793
|
};
|
1856
|
-
var ActionBase =
|
1857
|
-
id:
|
1858
|
-
|
1859
|
-
|
1794
|
+
var ActionBase = import_zod18.z.object({
|
1795
|
+
id: import_zod18.z.string(),
|
1796
|
+
transactionId: import_zod18.z.string(),
|
1797
|
+
createdAt: import_zod18.z.string().datetime(),
|
1798
|
+
createdBy: import_zod18.z.string(),
|
1799
|
+
createdByRole: import_zod18.z.string(),
|
1860
1800
|
declaration: ActionUpdate,
|
1861
1801
|
annotation: ActionUpdate.optional(),
|
1862
|
-
createdAtLocation:
|
1863
|
-
|
1802
|
+
createdAtLocation: import_zod18.z.string().optional(),
|
1803
|
+
updatedAtLocation: import_zod18.z.string().optional(),
|
1804
|
+
status: import_zod18.z.enum([
|
1864
1805
|
ActionStatus.Requested,
|
1865
1806
|
ActionStatus.Accepted,
|
1866
1807
|
ActionStatus.Rejected
|
1867
1808
|
]),
|
1868
1809
|
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1869
|
-
originalActionId:
|
1810
|
+
originalActionId: import_zod18.z.string().optional()
|
1870
1811
|
});
|
1871
1812
|
var AssignedAction = ActionBase.merge(
|
1872
|
-
|
1873
|
-
type:
|
1874
|
-
assignedTo:
|
1813
|
+
import_zod18.z.object({
|
1814
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1815
|
+
assignedTo: import_zod18.z.string()
|
1875
1816
|
})
|
1876
1817
|
);
|
1877
1818
|
var UnassignedAction = ActionBase.merge(
|
1878
|
-
|
1879
|
-
type:
|
1819
|
+
import_zod18.z.object({
|
1820
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1821
|
+
assignedTo: import_zod18.z.literal(null)
|
1880
1822
|
})
|
1881
1823
|
);
|
1882
1824
|
var RegisterAction = ActionBase.merge(
|
1883
|
-
|
1884
|
-
type:
|
1885
|
-
registrationNumber:
|
1825
|
+
import_zod18.z.object({
|
1826
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1827
|
+
registrationNumber: import_zod18.z.string().optional()
|
1886
1828
|
})
|
1887
1829
|
);
|
1888
1830
|
var DeclareAction = ActionBase.merge(
|
1889
|
-
|
1890
|
-
type:
|
1831
|
+
import_zod18.z.object({
|
1832
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1891
1833
|
})
|
1892
1834
|
);
|
1893
1835
|
var ValidateAction = ActionBase.merge(
|
1894
|
-
|
1895
|
-
type:
|
1836
|
+
import_zod18.z.object({
|
1837
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1896
1838
|
})
|
1897
1839
|
);
|
1898
1840
|
var RejectAction = ActionBase.merge(
|
1899
|
-
|
1900
|
-
type:
|
1841
|
+
import_zod18.z.object({
|
1842
|
+
type: import_zod18.z.literal(ActionType.REJECT)
|
1901
1843
|
})
|
1902
1844
|
);
|
1903
1845
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1904
|
-
|
1905
|
-
type:
|
1846
|
+
import_zod18.z.object({
|
1847
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1906
1848
|
})
|
1907
1849
|
);
|
1908
1850
|
var ArchiveAction = ActionBase.merge(
|
1909
|
-
|
1910
|
-
type:
|
1851
|
+
import_zod18.z.object({
|
1852
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE)
|
1911
1853
|
})
|
1912
1854
|
);
|
1913
1855
|
var CreatedAction = ActionBase.merge(
|
1914
|
-
|
1915
|
-
type:
|
1856
|
+
import_zod18.z.object({
|
1857
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1916
1858
|
})
|
1917
1859
|
);
|
1918
1860
|
var NotifiedAction = ActionBase.merge(
|
1919
|
-
|
1920
|
-
type:
|
1861
|
+
import_zod18.z.object({
|
1862
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1921
1863
|
})
|
1922
1864
|
);
|
1923
1865
|
var PrintCertificateAction = ActionBase.merge(
|
1924
|
-
|
1925
|
-
type:
|
1866
|
+
import_zod18.z.object({
|
1867
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1926
1868
|
})
|
1927
1869
|
);
|
1928
1870
|
var RequestedCorrectionAction = ActionBase.merge(
|
1929
|
-
|
1930
|
-
type:
|
1871
|
+
import_zod18.z.object({
|
1872
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1931
1873
|
})
|
1932
1874
|
);
|
1933
1875
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1934
|
-
|
1935
|
-
type:
|
1936
|
-
requestId:
|
1876
|
+
import_zod18.z.object({
|
1877
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1878
|
+
requestId: import_zod18.z.string()
|
1937
1879
|
})
|
1938
1880
|
);
|
1939
1881
|
var RejectedCorrectionAction = ActionBase.merge(
|
1940
|
-
|
1941
|
-
type:
|
1942
|
-
requestId:
|
1882
|
+
import_zod18.z.object({
|
1883
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1884
|
+
requestId: import_zod18.z.string()
|
1943
1885
|
})
|
1944
1886
|
);
|
1945
1887
|
var ReadAction = ActionBase.merge(
|
1946
|
-
|
1947
|
-
type:
|
1888
|
+
import_zod18.z.object({
|
1889
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1948
1890
|
})
|
1949
1891
|
);
|
1950
|
-
var ActionDocument =
|
1951
|
-
CreatedAction,
|
1952
|
-
ValidateAction,
|
1953
|
-
RejectAction,
|
1954
|
-
MarkAsDuplicateAction,
|
1955
|
-
ArchiveAction,
|
1956
|
-
NotifiedAction,
|
1957
|
-
RegisterAction,
|
1958
|
-
DeclareAction,
|
1959
|
-
AssignedAction,
|
1960
|
-
RequestedCorrectionAction,
|
1961
|
-
ApprovedCorrectionAction,
|
1962
|
-
RejectedCorrectionAction,
|
1963
|
-
UnassignedAction,
|
1964
|
-
PrintCertificateAction,
|
1965
|
-
ReadAction
|
1966
|
-
])
|
1892
|
+
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1893
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1894
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1895
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1896
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1897
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1898
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1899
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1900
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1901
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1902
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1903
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1904
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1905
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1906
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1907
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1908
|
+
]).openapi({
|
1909
|
+
ref: "ActionDocument"
|
1910
|
+
});
|
1967
1911
|
var AsyncRejectActionDocument = ActionBase.omit({
|
1968
1912
|
declaration: true,
|
1969
1913
|
annotation: true,
|
1970
1914
|
createdBy: true,
|
1915
|
+
createdByRole: true,
|
1971
1916
|
createdAtLocation: true
|
1972
1917
|
}).merge(
|
1973
|
-
|
1974
|
-
type:
|
1975
|
-
status:
|
1918
|
+
import_zod18.z.object({
|
1919
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1920
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1976
1921
|
})
|
1977
1922
|
);
|
1978
|
-
var Action =
|
1979
|
-
var ResolvedUser =
|
1980
|
-
id:
|
1981
|
-
role:
|
1982
|
-
name:
|
1983
|
-
|
1984
|
-
use:
|
1985
|
-
given:
|
1986
|
-
family:
|
1923
|
+
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1924
|
+
var ResolvedUser = import_zod18.z.object({
|
1925
|
+
id: import_zod18.z.string(),
|
1926
|
+
role: import_zod18.z.string(),
|
1927
|
+
name: import_zod18.z.array(
|
1928
|
+
import_zod18.z.object({
|
1929
|
+
use: import_zod18.z.string(),
|
1930
|
+
given: import_zod18.z.array(import_zod18.z.string()),
|
1931
|
+
family: import_zod18.z.string()
|
1987
1932
|
})
|
1988
1933
|
)
|
1989
1934
|
});
|
1990
1935
|
|
1991
1936
|
// ../commons/src/events/ActionInput.ts
|
1992
|
-
var
|
1993
|
-
var
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1937
|
+
var import_zod19 = require("zod");
|
1938
|
+
var import_zod_openapi5 = require("zod-openapi");
|
1939
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod19.z);
|
1940
|
+
var BaseActionInput = import_zod19.z.object({
|
1941
|
+
eventId: import_zod19.z.string(),
|
1942
|
+
transactionId: import_zod19.z.string(),
|
1943
|
+
declaration: ActionUpdate.default({}),
|
1997
1944
|
annotation: ActionUpdate.optional(),
|
1998
|
-
originalActionId:
|
1945
|
+
originalActionId: import_zod19.z.string().optional(),
|
1946
|
+
keepAssignment: import_zod19.z.boolean().optional()
|
1999
1947
|
});
|
2000
1948
|
var CreateActionInput = BaseActionInput.merge(
|
2001
|
-
|
2002
|
-
type:
|
2003
|
-
createdAtLocation:
|
1949
|
+
import_zod19.z.object({
|
1950
|
+
type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1951
|
+
createdAtLocation: import_zod19.z.string()
|
2004
1952
|
})
|
2005
1953
|
);
|
2006
1954
|
var RegisterActionInput = BaseActionInput.merge(
|
2007
|
-
|
2008
|
-
type:
|
2009
|
-
registrationNumber:
|
1955
|
+
import_zod19.z.object({
|
1956
|
+
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1957
|
+
registrationNumber: import_zod19.z.string().optional()
|
2010
1958
|
})
|
2011
1959
|
);
|
2012
1960
|
var ValidateActionInput = BaseActionInput.merge(
|
2013
|
-
|
2014
|
-
type:
|
2015
|
-
duplicates:
|
1961
|
+
import_zod19.z.object({
|
1962
|
+
type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1963
|
+
duplicates: import_zod19.z.array(import_zod19.z.string())
|
2016
1964
|
})
|
2017
1965
|
);
|
2018
1966
|
var NotifyActionInput = BaseActionInput.merge(
|
2019
|
-
|
2020
|
-
type:
|
1967
|
+
import_zod19.z.object({
|
1968
|
+
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
2021
1969
|
})
|
2022
1970
|
);
|
2023
1971
|
var DeclareActionInput = BaseActionInput.merge(
|
2024
|
-
|
2025
|
-
type:
|
1972
|
+
import_zod19.z.object({
|
1973
|
+
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
2026
1974
|
})
|
2027
1975
|
);
|
2028
1976
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
2029
|
-
|
2030
|
-
type:
|
1977
|
+
import_zod19.z.object({
|
1978
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
2031
1979
|
})
|
2032
1980
|
);
|
2033
1981
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
2034
|
-
|
2035
|
-
type:
|
1982
|
+
import_zod19.z.object({
|
1983
|
+
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
2036
1984
|
})
|
2037
1985
|
);
|
2038
1986
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
2039
|
-
|
2040
|
-
type:
|
1987
|
+
import_zod19.z.object({
|
1988
|
+
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
2041
1989
|
})
|
2042
1990
|
);
|
2043
1991
|
var ArchiveActionInput = BaseActionInput.merge(
|
2044
|
-
|
2045
|
-
type:
|
1992
|
+
import_zod19.z.object({
|
1993
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
2046
1994
|
})
|
2047
1995
|
);
|
2048
1996
|
var AssignActionInput = BaseActionInput.merge(
|
2049
|
-
|
2050
|
-
type:
|
2051
|
-
assignedTo:
|
1997
|
+
import_zod19.z.object({
|
1998
|
+
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1999
|
+
assignedTo: import_zod19.z.string()
|
2052
2000
|
})
|
2053
2001
|
);
|
2054
2002
|
var UnassignActionInput = BaseActionInput.merge(
|
2055
|
-
|
2056
|
-
type:
|
2003
|
+
import_zod19.z.object({
|
2004
|
+
type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2005
|
+
assignedTo: import_zod19.z.literal(null).default(null)
|
2057
2006
|
})
|
2058
2007
|
);
|
2059
2008
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
2060
|
-
|
2061
|
-
type:
|
2009
|
+
import_zod19.z.object({
|
2010
|
+
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
2062
2011
|
})
|
2063
2012
|
);
|
2064
2013
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2065
|
-
|
2066
|
-
requestId:
|
2067
|
-
type:
|
2014
|
+
import_zod19.z.object({
|
2015
|
+
requestId: import_zod19.z.string(),
|
2016
|
+
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2068
2017
|
})
|
2069
2018
|
);
|
2070
2019
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2071
|
-
|
2072
|
-
requestId:
|
2073
|
-
type:
|
2020
|
+
import_zod19.z.object({
|
2021
|
+
requestId: import_zod19.z.string(),
|
2022
|
+
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2074
2023
|
})
|
2075
2024
|
);
|
2076
2025
|
var ReadActionInput = BaseActionInput.merge(
|
2077
|
-
|
2078
|
-
type:
|
2026
|
+
import_zod19.z.object({
|
2027
|
+
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
2079
2028
|
})
|
2080
2029
|
);
|
2081
|
-
var
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2030
|
+
var DeleteActionInput = import_zod19.z.object({ eventId: import_zod19.z.string() });
|
2031
|
+
var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
2032
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2033
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2034
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2035
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2036
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2037
|
+
RejectDeclarationActionInput.openapi({
|
2038
|
+
ref: "RejectDeclarationActionInput"
|
2039
|
+
}),
|
2040
|
+
MarkedAsDuplicateActionInput.openapi({
|
2041
|
+
ref: "MarkedAsDuplicateActionInput"
|
2042
|
+
}),
|
2043
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2044
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2045
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2046
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2047
|
+
RequestCorrectionActionInput.openapi({
|
2048
|
+
ref: "RequestCorrectionActionInput"
|
2049
|
+
}),
|
2050
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2051
|
+
ApproveCorrectionActionInput.openapi({
|
2052
|
+
ref: "ApproveCorrectionActionInput"
|
2053
|
+
}),
|
2054
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2055
|
+
]).openapi({
|
2056
|
+
ref: "ActionInput"
|
2057
|
+
});
|
2098
2058
|
|
2099
2059
|
// ../commons/src/events/Draft.ts
|
2100
|
-
var Draft =
|
2101
|
-
id:
|
2102
|
-
eventId:
|
2103
|
-
transactionId:
|
2104
|
-
createdAt:
|
2060
|
+
var Draft = import_zod20.z.object({
|
2061
|
+
id: import_zod20.z.string(),
|
2062
|
+
eventId: import_zod20.z.string(),
|
2063
|
+
transactionId: import_zod20.z.string(),
|
2064
|
+
createdAt: import_zod20.z.string().datetime(),
|
2105
2065
|
action: ActionBase.extend({
|
2106
2066
|
type: ActionTypes
|
2107
|
-
}).omit({ id: true
|
2067
|
+
}).omit({ id: true })
|
2108
2068
|
});
|
2109
2069
|
var DraftInput = BaseActionInput.extend({
|
2110
2070
|
type: ActionTypes
|
2111
2071
|
});
|
2112
2072
|
|
2073
|
+
// ../commons/src/events/EventMetadata.ts
|
2074
|
+
var import_zod21 = require("zod");
|
2075
|
+
var EventStatus = {
|
2076
|
+
CREATED: "CREATED",
|
2077
|
+
NOTIFIED: "NOTIFIED",
|
2078
|
+
DECLARED: "DECLARED",
|
2079
|
+
VALIDATED: "VALIDATED",
|
2080
|
+
REGISTERED: "REGISTERED",
|
2081
|
+
CERTIFIED: "CERTIFIED",
|
2082
|
+
REJECTED: "REJECTED",
|
2083
|
+
ARCHIVED: "ARCHIVED"
|
2084
|
+
};
|
2085
|
+
var eventStatuses = Object.values(EventStatus);
|
2086
|
+
var EventStatuses = import_zod21.z.nativeEnum(EventStatus);
|
2087
|
+
var ZodDate = import_zod21.z.string().date();
|
2088
|
+
var EventMetadata = import_zod21.z.object({
|
2089
|
+
id: import_zod21.z.string(),
|
2090
|
+
type: import_zod21.z.string(),
|
2091
|
+
status: EventStatuses,
|
2092
|
+
createdAt: import_zod21.z.string().datetime(),
|
2093
|
+
dateOfEvent: ZodDate.nullish(),
|
2094
|
+
createdBy: import_zod21.z.string(),
|
2095
|
+
updatedByUserRole: import_zod21.z.string(),
|
2096
|
+
createdAtLocation: import_zod21.z.string(),
|
2097
|
+
updatedAtLocation: import_zod21.z.string(),
|
2098
|
+
updatedAt: import_zod21.z.string().datetime(),
|
2099
|
+
assignedTo: import_zod21.z.string().nullish(),
|
2100
|
+
updatedBy: import_zod21.z.string(),
|
2101
|
+
trackingId: import_zod21.z.string(),
|
2102
|
+
registrationNumber: import_zod21.z.string().nullish()
|
2103
|
+
});
|
2104
|
+
var eventMetadataLabelMap = {
|
2105
|
+
"event.assignedTo": {
|
2106
|
+
id: "event.assignedTo.label",
|
2107
|
+
defaultMessage: "Assigned To",
|
2108
|
+
description: "Assigned To"
|
2109
|
+
},
|
2110
|
+
"event.createdAt": {
|
2111
|
+
id: "event.createdAt.label",
|
2112
|
+
defaultMessage: "Created",
|
2113
|
+
description: "Created At"
|
2114
|
+
},
|
2115
|
+
"event.dateOfEvent": {
|
2116
|
+
id: "event.dateOfEvent.label",
|
2117
|
+
defaultMessage: "Date of Event",
|
2118
|
+
description: "Date of Event"
|
2119
|
+
},
|
2120
|
+
"event.createdAtLocation": {
|
2121
|
+
id: "event.createdAtLocation.label",
|
2122
|
+
defaultMessage: "Location",
|
2123
|
+
description: "Created At Location"
|
2124
|
+
},
|
2125
|
+
"event.updatedAtLocation": {
|
2126
|
+
id: "event.updatedAtLocation.label",
|
2127
|
+
defaultMessage: "Location",
|
2128
|
+
description: "Updated At Location"
|
2129
|
+
},
|
2130
|
+
"event.createdBy": {
|
2131
|
+
id: "event.createdBy.label",
|
2132
|
+
defaultMessage: "Created By",
|
2133
|
+
description: "Created By"
|
2134
|
+
},
|
2135
|
+
"event.updatedByUserRole": {
|
2136
|
+
id: "event.updatedByUserRole.label",
|
2137
|
+
defaultMessage: "Updated By Role",
|
2138
|
+
description: "Updated By Role"
|
2139
|
+
},
|
2140
|
+
"event.id": {
|
2141
|
+
id: "event.id.label",
|
2142
|
+
defaultMessage: "ID",
|
2143
|
+
description: "ID"
|
2144
|
+
},
|
2145
|
+
"event.updatedAt": {
|
2146
|
+
id: "event.modifiedAt.label",
|
2147
|
+
defaultMessage: "Updated",
|
2148
|
+
description: "Modified At"
|
2149
|
+
},
|
2150
|
+
"event.status": {
|
2151
|
+
id: "event.status.label",
|
2152
|
+
defaultMessage: "Status",
|
2153
|
+
description: "Status"
|
2154
|
+
},
|
2155
|
+
"event.type": {
|
2156
|
+
id: "event.type.label",
|
2157
|
+
defaultMessage: "Type",
|
2158
|
+
description: "Type"
|
2159
|
+
},
|
2160
|
+
"event.updatedBy": {
|
2161
|
+
id: "event.updatedBy.label",
|
2162
|
+
defaultMessage: "Updated By",
|
2163
|
+
description: "Updated By"
|
2164
|
+
},
|
2165
|
+
"event.trackingId": {
|
2166
|
+
id: "event.trackingId.label",
|
2167
|
+
defaultMessage: "Tracking ID",
|
2168
|
+
description: "Tracking ID"
|
2169
|
+
},
|
2170
|
+
"event.registrationNumber": {
|
2171
|
+
id: "event.registrationNumber.label",
|
2172
|
+
defaultMessage: "Registration Number",
|
2173
|
+
description: "Registration Number"
|
2174
|
+
}
|
2175
|
+
};
|
2176
|
+
|
2113
2177
|
// ../commons/src/events/EventInput.ts
|
2114
|
-
var
|
2115
|
-
var EventInput =
|
2116
|
-
transactionId:
|
2117
|
-
type:
|
2178
|
+
var import_zod22 = require("zod");
|
2179
|
+
var EventInput = import_zod22.z.object({
|
2180
|
+
transactionId: import_zod22.z.string(),
|
2181
|
+
type: import_zod22.z.string(),
|
2182
|
+
dateOfEvent: import_zod22.z.object({ fieldId: import_zod22.z.string() }).optional()
|
2118
2183
|
});
|
2119
2184
|
|
2120
2185
|
// ../commons/src/events/EventDocument.ts
|
2121
|
-
var
|
2122
|
-
var
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2186
|
+
var import_zod23 = require("zod");
|
2187
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2188
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod23.z);
|
2189
|
+
var EventDocument = import_zod23.z.object({
|
2190
|
+
id: import_zod23.z.string(),
|
2191
|
+
type: import_zod23.z.string(),
|
2192
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional(),
|
2193
|
+
createdAt: import_zod23.z.string().datetime(),
|
2194
|
+
updatedAt: import_zod23.z.string().datetime(),
|
2195
|
+
updatedAtLocation: import_zod23.z.string(),
|
2196
|
+
actions: import_zod23.z.array(Action),
|
2197
|
+
trackingId: import_zod23.z.string()
|
2198
|
+
}).openapi({ ref: "EventDocument" });
|
2130
2199
|
|
2131
2200
|
// ../commons/src/events/EventIndex.ts
|
2132
|
-
var
|
2201
|
+
var import_zod24 = require("zod");
|
2133
2202
|
var EventIndex = EventMetadata.extend({
|
2134
|
-
declaration:
|
2203
|
+
declaration: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
|
2135
2204
|
});
|
2136
|
-
var EventSearchIndex =
|
2137
|
-
|
2138
|
-
type:
|
2205
|
+
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
2206
|
+
import_zod24.z.object({
|
2207
|
+
type: import_zod24.z.string()
|
2139
2208
|
// Ensures "type" (event-id) exists and is a string
|
2140
2209
|
})
|
2141
2210
|
);
|
2211
|
+
var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() });
|
2212
|
+
var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() });
|
2213
|
+
var AnyOf = import_zod24.z.object({
|
2214
|
+
type: import_zod24.z.literal("anyOf"),
|
2215
|
+
terms: import_zod24.z.array(import_zod24.z.string())
|
2216
|
+
});
|
2217
|
+
var Range = import_zod24.z.object({
|
2218
|
+
type: import_zod24.z.literal("range"),
|
2219
|
+
gte: import_zod24.z.string(),
|
2220
|
+
lte: import_zod24.z.string()
|
2221
|
+
});
|
2222
|
+
var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() });
|
2223
|
+
var DateCondition = import_zod24.z.union([Exact, Range]);
|
2224
|
+
var QueryInput = import_zod24.z.lazy(
|
2225
|
+
() => import_zod24.z.union([
|
2226
|
+
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
2227
|
+
import_zod24.z.record(import_zod24.z.string(), QueryInput)
|
2228
|
+
])
|
2229
|
+
);
|
2230
|
+
var QueryExpression = import_zod24.z.object({
|
2231
|
+
type: import_zod24.z.literal("and"),
|
2232
|
+
eventType: import_zod24.z.string(),
|
2233
|
+
status: import_zod24.z.optional(import_zod24.z.union([AnyOf, Exact])),
|
2234
|
+
createdAt: import_zod24.z.optional(DateCondition),
|
2235
|
+
updatedAt: import_zod24.z.optional(DateCondition),
|
2236
|
+
createAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
2237
|
+
updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
2238
|
+
createdBy: import_zod24.z.optional(Exact),
|
2239
|
+
updatedBy: import_zod24.z.optional(Exact),
|
2240
|
+
trackingId: import_zod24.z.optional(Exact),
|
2241
|
+
data: QueryInput
|
2242
|
+
}).partial();
|
2243
|
+
var Or2 = import_zod24.z.object({
|
2244
|
+
type: import_zod24.z.literal("or"),
|
2245
|
+
clauses: import_zod24.z.array(QueryExpression)
|
2246
|
+
});
|
2247
|
+
var QueryType = import_zod24.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
2142
2248
|
|
2143
2249
|
// ../commons/src/events/state/index.ts
|
2144
|
-
var _ = __toESM(require("lodash"));
|
2145
2250
|
function getStatusFromActions(actions) {
|
2146
2251
|
const hasRejectedAction = actions.some(
|
2147
2252
|
(a) => a.status === ActionStatus.Rejected
|
@@ -2150,30 +2255,47 @@ function getStatusFromActions(actions) {
|
|
2150
2255
|
return EventStatus.REJECTED;
|
2151
2256
|
}
|
2152
2257
|
return actions.reduce((status, action) => {
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2258
|
+
switch (action.type) {
|
2259
|
+
case ActionType.CREATE:
|
2260
|
+
return EventStatus.CREATED;
|
2261
|
+
case ActionType.DECLARE:
|
2262
|
+
return EventStatus.DECLARED;
|
2263
|
+
case ActionType.VALIDATE:
|
2264
|
+
return EventStatus.VALIDATED;
|
2265
|
+
case ActionType.REGISTER:
|
2266
|
+
return EventStatus.REGISTERED;
|
2267
|
+
case ActionType.REJECT:
|
2268
|
+
return EventStatus.REJECTED;
|
2269
|
+
case ActionType.ARCHIVE:
|
2270
|
+
return EventStatus.ARCHIVED;
|
2271
|
+
case ActionType.NOTIFY:
|
2272
|
+
return EventStatus.NOTIFIED;
|
2273
|
+
case ActionType.PRINT_CERTIFICATE:
|
2274
|
+
return EventStatus.CERTIFIED;
|
2275
|
+
case ActionType.ASSIGN:
|
2276
|
+
case ActionType.UNASSIGN:
|
2277
|
+
case ActionType.REQUEST_CORRECTION:
|
2278
|
+
case ActionType.APPROVE_CORRECTION:
|
2279
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2280
|
+
case ActionType.REJECT_CORRECTION:
|
2281
|
+
case ActionType.READ:
|
2282
|
+
default:
|
2283
|
+
return status;
|
2173
2284
|
}
|
2174
|
-
return status;
|
2175
2285
|
}, EventStatus.CREATED);
|
2176
2286
|
}
|
2287
|
+
function getLastUpdatedByUserRoleFromActions(actions) {
|
2288
|
+
const actionsWithRoles = actions.filter(
|
2289
|
+
(action) => !isWriteAction(action.type) && action.status !== ActionStatus.Rejected
|
2290
|
+
).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2291
|
+
const lastAction = actionsWithRoles.at(-1);
|
2292
|
+
if (!lastAction) {
|
2293
|
+
throw new Error(
|
2294
|
+
"Should never happen, at least CREATE action should be present"
|
2295
|
+
);
|
2296
|
+
}
|
2297
|
+
return ActionDocument.parse(lastAction).createdByRole;
|
2298
|
+
}
|
2177
2299
|
function getAssignedUserFromActions(actions) {
|
2178
2300
|
return actions.reduce((user2, action) => {
|
2179
2301
|
if (action.type === ActionType.ASSIGN) {
|
@@ -2205,26 +2327,27 @@ function aggregateActionDeclarations(actions) {
|
|
2205
2327
|
}, {});
|
2206
2328
|
}
|
2207
2329
|
function deepDropNulls(obj) {
|
2208
|
-
if (
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
[key]
|
2217
|
-
}
|
2218
|
-
|
2219
|
-
|
2220
|
-
}
|
2330
|
+
if (Array.isArray(obj)) {
|
2331
|
+
return obj.map(deepDropNulls);
|
2332
|
+
}
|
2333
|
+
if (obj !== null && typeof obj === "object") {
|
2334
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2335
|
+
const cleanedValue = deepDropNulls(value);
|
2336
|
+
if (cleanedValue !== null) {
|
2337
|
+
;
|
2338
|
+
acc[key] = cleanedValue;
|
2339
|
+
}
|
2340
|
+
return acc;
|
2341
|
+
}, {});
|
2342
|
+
}
|
2343
|
+
return obj;
|
2221
2344
|
}
|
2222
2345
|
function isUndeclaredDraft(status) {
|
2223
2346
|
return status === EventStatus.CREATED;
|
2224
2347
|
}
|
2225
2348
|
function getAcceptedActions(event2) {
|
2226
2349
|
return event2.actions.filter(
|
2227
|
-
(a) =>
|
2350
|
+
(a) => a.status === ActionStatus.Accepted
|
2228
2351
|
);
|
2229
2352
|
}
|
2230
2353
|
function getCurrentEventState(event2) {
|
@@ -2240,19 +2363,29 @@ function getCurrentEventState(event2) {
|
|
2240
2363
|
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2241
2364
|
);
|
2242
2365
|
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2366
|
+
const declaration = aggregateActionDeclarations(activeActions);
|
2367
|
+
let dateOfEvent = event2.createdAt.split("T")[0];
|
2368
|
+
if (event2.dateOfEvent) {
|
2369
|
+
const parsedDate = ZodDate.safeParse(declaration[event2.dateOfEvent.fieldId]);
|
2370
|
+
dateOfEvent = parsedDate.success ? parsedDate.data : null;
|
2371
|
+
}
|
2243
2372
|
return deepDropNulls({
|
2244
2373
|
id: event2.id,
|
2245
2374
|
type: event2.type,
|
2246
2375
|
status: getStatusFromActions(event2.actions),
|
2247
2376
|
createdAt: event2.createdAt,
|
2248
2377
|
createdBy: creationAction.createdBy,
|
2249
|
-
createdAtLocation: creationAction.createdAtLocation,
|
2250
|
-
|
2378
|
+
createdAtLocation: creationAction.createdAtLocation ?? "",
|
2379
|
+
// @todo remove using empty string
|
2380
|
+
updatedAt: latestAction.createdAt,
|
2251
2381
|
assignedTo: getAssignedUserFromActions(activeActions),
|
2252
2382
|
updatedBy: latestAction.createdBy,
|
2253
|
-
|
2383
|
+
updatedAtLocation: event2.updatedAtLocation,
|
2384
|
+
declaration,
|
2254
2385
|
trackingId: event2.trackingId,
|
2255
|
-
registrationNumber
|
2386
|
+
registrationNumber,
|
2387
|
+
updatedByUserRole: getLastUpdatedByUserRoleFromActions(event2.actions),
|
2388
|
+
dateOfEvent
|
2256
2389
|
});
|
2257
2390
|
}
|
2258
2391
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2277,7 +2410,7 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
|
|
2277
2410
|
return getCurrentEventState(withDrafts);
|
2278
2411
|
}
|
2279
2412
|
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2280
|
-
const indexedAt = eventIndex.
|
2413
|
+
const indexedAt = eventIndex.updatedAt;
|
2281
2414
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2282
2415
|
if (activeDrafts.length === 0) {
|
2283
2416
|
return eventIndex;
|
@@ -2290,27 +2423,35 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2290
2423
|
}
|
2291
2424
|
};
|
2292
2425
|
}
|
2426
|
+
function getAnnotationFromDrafts(drafts) {
|
2427
|
+
const actions = drafts.map((draft) => draft.action);
|
2428
|
+
const annotation = actions.reduce((ann, action) => {
|
2429
|
+
return deepMerge(ann, action.annotation ?? {});
|
2430
|
+
}, {});
|
2431
|
+
return deepDropNulls(annotation);
|
2432
|
+
}
|
2293
2433
|
function getActionAnnotation({
|
2294
2434
|
event: event2,
|
2295
2435
|
actionType,
|
2296
|
-
drafts
|
2436
|
+
drafts = []
|
2297
2437
|
}) {
|
2298
2438
|
const activeActions = getAcceptedActions(event2);
|
2299
|
-
const action = activeActions.find(
|
2439
|
+
const action = activeActions.find(
|
2440
|
+
(activeAction) => actionType === activeAction.type
|
2441
|
+
);
|
2300
2442
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2301
2443
|
const sorted = [
|
2302
2444
|
...action ? [action] : [],
|
2303
2445
|
...eventDrafts.map((draft) => draft.action)
|
2304
2446
|
].sort();
|
2305
|
-
const annotation = sorted.reduce((
|
2306
|
-
return deepMerge(
|
2447
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2448
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2307
2449
|
}, {});
|
2308
2450
|
return deepDropNulls(annotation);
|
2309
2451
|
}
|
2310
2452
|
|
2311
2453
|
// ../commons/src/events/defineConfig.ts
|
2312
2454
|
var defineConfig = (config) => {
|
2313
|
-
validateWorkqueueConfig(config.workqueues);
|
2314
2455
|
const input = EventConfig.parse(config);
|
2315
2456
|
return input;
|
2316
2457
|
};
|
@@ -2327,6 +2468,16 @@ var import_lodash2 = require("lodash");
|
|
2327
2468
|
function defineConditional(schema) {
|
2328
2469
|
return schema;
|
2329
2470
|
}
|
2471
|
+
function defineFormConditional(schema) {
|
2472
|
+
const schemaWithForm = {
|
2473
|
+
type: "object",
|
2474
|
+
properties: {
|
2475
|
+
$form: schema
|
2476
|
+
},
|
2477
|
+
required: ["$form"]
|
2478
|
+
};
|
2479
|
+
return defineConditional(schemaWithForm);
|
2480
|
+
}
|
2330
2481
|
function alwaysTrue() {
|
2331
2482
|
return {};
|
2332
2483
|
}
|
@@ -2351,6 +2502,9 @@ function not(condition) {
|
|
2351
2502
|
required: []
|
2352
2503
|
});
|
2353
2504
|
}
|
2505
|
+
function never() {
|
2506
|
+
return not(alwaysTrue());
|
2507
|
+
}
|
2354
2508
|
var user = {
|
2355
2509
|
hasScope: (scope) => defineConditional({
|
2356
2510
|
type: "object",
|
@@ -2359,139 +2513,159 @@ var user = {
|
|
2359
2513
|
type: "object",
|
2360
2514
|
required: ["scope"],
|
2361
2515
|
properties: {
|
2362
|
-
scope: {
|
2363
|
-
type: "array",
|
2364
|
-
contains: {
|
2365
|
-
type: "string",
|
2366
|
-
const: scope
|
2367
|
-
}
|
2368
|
-
}
|
2369
|
-
}
|
2370
|
-
}
|
2371
|
-
},
|
2372
|
-
required: ["$user"]
|
2373
|
-
})
|
2374
|
-
};
|
2375
|
-
var event = {
|
2376
|
-
hasAction: (action) => defineConditional({
|
2377
|
-
type: "object",
|
2378
|
-
properties: {
|
2379
|
-
$event: {
|
2380
|
-
type: "object",
|
2381
|
-
properties: {
|
2382
|
-
actions: {
|
2516
|
+
scope: {
|
2383
2517
|
type: "array",
|
2384
2518
|
contains: {
|
2385
|
-
type: "
|
2386
|
-
|
2387
|
-
type: {
|
2388
|
-
const: action
|
2389
|
-
}
|
2390
|
-
},
|
2391
|
-
required: ["type"]
|
2519
|
+
type: "string",
|
2520
|
+
const: scope
|
2392
2521
|
}
|
2393
2522
|
}
|
2394
|
-
}
|
2395
|
-
required: ["actions"]
|
2523
|
+
}
|
2396
2524
|
}
|
2397
2525
|
},
|
2398
|
-
required: ["$
|
2526
|
+
required: ["$user"]
|
2399
2527
|
})
|
2400
2528
|
};
|
2401
|
-
function
|
2402
|
-
|
2529
|
+
function createEventConditionals() {
|
2530
|
+
return {
|
2531
|
+
/**
|
2532
|
+
* Checks if the event contains a specific action type.
|
2533
|
+
* @param action - The action type to check for.
|
2534
|
+
*/
|
2535
|
+
hasAction: (action) => defineConditional({
|
2536
|
+
type: "object",
|
2537
|
+
properties: {
|
2538
|
+
$event: {
|
2539
|
+
type: "object",
|
2540
|
+
properties: {
|
2541
|
+
actions: {
|
2542
|
+
type: "array",
|
2543
|
+
contains: {
|
2544
|
+
type: "object",
|
2545
|
+
properties: {
|
2546
|
+
type: {
|
2547
|
+
const: action
|
2548
|
+
}
|
2549
|
+
},
|
2550
|
+
required: ["type"]
|
2551
|
+
}
|
2552
|
+
}
|
2553
|
+
},
|
2554
|
+
required: ["actions"]
|
2555
|
+
}
|
2556
|
+
},
|
2557
|
+
required: ["$event"]
|
2558
|
+
})
|
2559
|
+
};
|
2560
|
+
}
|
2561
|
+
function getDateFromNow(days) {
|
2562
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2563
|
+
}
|
2564
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2565
|
+
return {
|
2566
|
+
type: "object",
|
2567
|
+
properties: {
|
2568
|
+
[fieldId]: {
|
2569
|
+
type: "string",
|
2570
|
+
format: "date",
|
2571
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2572
|
+
},
|
2573
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2574
|
+
},
|
2575
|
+
required: [fieldId]
|
2576
|
+
};
|
2577
|
+
}
|
2578
|
+
function isFieldReference(value) {
|
2579
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2580
|
+
}
|
2581
|
+
function createFieldConditionals(fieldId) {
|
2403
2582
|
const getDateRange = (date, clause) => ({
|
2404
2583
|
type: "object",
|
2405
2584
|
properties: {
|
2406
|
-
|
2407
|
-
type: "
|
2408
|
-
|
2409
|
-
|
2410
|
-
type: "string",
|
2411
|
-
format: "date",
|
2412
|
-
[clause]: date
|
2413
|
-
}
|
2414
|
-
},
|
2415
|
-
required: [fieldId]
|
2585
|
+
[fieldId]: {
|
2586
|
+
type: "string",
|
2587
|
+
format: "date",
|
2588
|
+
[clause]: date
|
2416
2589
|
}
|
2417
2590
|
},
|
2418
|
-
required: [
|
2591
|
+
required: [fieldId]
|
2419
2592
|
});
|
2420
2593
|
return {
|
2421
|
-
/**
|
2422
|
-
* @private Internal property used for field reference tracking.
|
2423
|
-
*/
|
2424
|
-
_returning: fieldId,
|
2425
2594
|
isAfter: () => ({
|
2426
2595
|
days: (days) => ({
|
2427
|
-
inPast: () =>
|
2596
|
+
inPast: () => defineFormConditional(
|
2428
2597
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2429
2598
|
),
|
2430
|
-
inFuture: () =>
|
2599
|
+
inFuture: () => defineFormConditional(
|
2431
2600
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2432
2601
|
)
|
2433
2602
|
}),
|
2434
|
-
date: (date) =>
|
2435
|
-
|
2603
|
+
date: (date) => {
|
2604
|
+
if (isFieldReference(date)) {
|
2605
|
+
const comparedFieldId = date._fieldId;
|
2606
|
+
return defineFormConditional(
|
2607
|
+
getDateRangeToFieldReference(
|
2608
|
+
fieldId,
|
2609
|
+
comparedFieldId,
|
2610
|
+
"formatMinimum"
|
2611
|
+
)
|
2612
|
+
);
|
2613
|
+
}
|
2614
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2615
|
+
},
|
2616
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2436
2617
|
}),
|
2437
2618
|
isBefore: () => ({
|
2438
2619
|
days: (days) => ({
|
2439
|
-
inPast: () =>
|
2620
|
+
inPast: () => defineFormConditional(
|
2440
2621
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2441
2622
|
),
|
2442
|
-
inFuture: () =>
|
2623
|
+
inFuture: () => defineFormConditional(
|
2443
2624
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2444
2625
|
)
|
2445
2626
|
}),
|
2446
|
-
date: (date) =>
|
2447
|
-
|
2627
|
+
date: (date) => {
|
2628
|
+
if (isFieldReference(date)) {
|
2629
|
+
const comparedFieldId = date._fieldId;
|
2630
|
+
return defineFormConditional(
|
2631
|
+
getDateRangeToFieldReference(
|
2632
|
+
fieldId,
|
2633
|
+
comparedFieldId,
|
2634
|
+
"formatMaximum"
|
2635
|
+
)
|
2636
|
+
);
|
2637
|
+
}
|
2638
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2639
|
+
},
|
2640
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2448
2641
|
}),
|
2449
|
-
// TODO CIHAN: typing
|
2450
2642
|
isEqualTo: (value) => {
|
2451
|
-
if (
|
2452
|
-
const comparedFieldId = value.
|
2453
|
-
return
|
2643
|
+
if (isFieldReference(value)) {
|
2644
|
+
const comparedFieldId = value._fieldId;
|
2645
|
+
return defineFormConditional({
|
2454
2646
|
type: "object",
|
2455
2647
|
properties: {
|
2456
|
-
|
2457
|
-
type: "
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
},
|
2462
|
-
required: [fieldId, comparedFieldId],
|
2463
|
-
allOf: [
|
2464
|
-
{
|
2465
|
-
properties: {
|
2466
|
-
[fieldId]: {
|
2467
|
-
const: { $data: `1/${comparedFieldId}` }
|
2468
|
-
}
|
2469
|
-
}
|
2470
|
-
}
|
2471
|
-
]
|
2472
|
-
}
|
2648
|
+
[fieldId]: {
|
2649
|
+
type: ["string", "boolean"],
|
2650
|
+
const: { $data: `1/${comparedFieldId}` }
|
2651
|
+
},
|
2652
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2473
2653
|
},
|
2474
|
-
required: [
|
2654
|
+
required: [fieldId, comparedFieldId]
|
2475
2655
|
});
|
2476
2656
|
}
|
2477
|
-
return
|
2657
|
+
return defineFormConditional({
|
2478
2658
|
type: "object",
|
2479
2659
|
properties: {
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
{ type: "boolean", const: value }
|
2487
|
-
],
|
2488
|
-
const: value
|
2489
|
-
}
|
2490
|
-
},
|
2491
|
-
required: [fieldId]
|
2660
|
+
[fieldId]: {
|
2661
|
+
oneOf: [
|
2662
|
+
{ type: "string", const: value },
|
2663
|
+
{ type: "boolean", const: value }
|
2664
|
+
],
|
2665
|
+
const: value
|
2492
2666
|
}
|
2493
2667
|
},
|
2494
|
-
required: [
|
2668
|
+
required: [fieldId]
|
2495
2669
|
});
|
2496
2670
|
},
|
2497
2671
|
/**
|
@@ -2502,144 +2676,155 @@ function field(fieldId) {
|
|
2502
2676
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2503
2677
|
*
|
2504
2678
|
*/
|
2505
|
-
isFalsy: () =>
|
2679
|
+
isFalsy: () => defineFormConditional({
|
2506
2680
|
type: "object",
|
2507
2681
|
properties: {
|
2508
|
-
|
2509
|
-
type: "object",
|
2510
|
-
properties: {
|
2511
|
-
[fieldId]: {
|
2512
|
-
anyOf: [
|
2513
|
-
{ const: "undefined" },
|
2514
|
-
{ const: false },
|
2515
|
-
{ const: null },
|
2516
|
-
{ const: "" }
|
2517
|
-
]
|
2518
|
-
}
|
2519
|
-
},
|
2682
|
+
[fieldId]: {
|
2520
2683
|
anyOf: [
|
2521
|
-
{
|
2522
|
-
|
2523
|
-
},
|
2524
|
-
{
|
2525
|
-
not: {
|
2526
|
-
required: [fieldId]
|
2527
|
-
}
|
2528
|
-
}
|
2684
|
+
{ const: "undefined" },
|
2685
|
+
{ const: false },
|
2686
|
+
{ const: null },
|
2687
|
+
{ const: "" }
|
2529
2688
|
]
|
2530
2689
|
}
|
2531
2690
|
},
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
$form: {
|
2538
|
-
type: "object",
|
2539
|
-
properties: {
|
2540
|
-
[fieldId]: {
|
2541
|
-
type: "string",
|
2542
|
-
enum: ["undefined"]
|
2543
|
-
}
|
2544
|
-
},
|
2691
|
+
anyOf: [
|
2692
|
+
{
|
2693
|
+
required: [fieldId]
|
2694
|
+
},
|
2695
|
+
{
|
2545
2696
|
not: {
|
2546
2697
|
required: [fieldId]
|
2547
2698
|
}
|
2548
2699
|
}
|
2549
|
-
|
2550
|
-
required: ["$form"]
|
2700
|
+
]
|
2551
2701
|
}),
|
2552
|
-
|
2702
|
+
isUndefined: () => defineFormConditional({
|
2553
2703
|
type: "object",
|
2554
2704
|
properties: {
|
2555
|
-
|
2556
|
-
type: "
|
2557
|
-
|
2558
|
-
[fieldId]: {
|
2559
|
-
type: "string",
|
2560
|
-
enum: values
|
2561
|
-
}
|
2562
|
-
},
|
2563
|
-
required: [fieldId]
|
2705
|
+
[fieldId]: {
|
2706
|
+
type: "string",
|
2707
|
+
enum: ["undefined"]
|
2564
2708
|
}
|
2565
2709
|
},
|
2566
|
-
|
2710
|
+
not: {
|
2711
|
+
required: [fieldId]
|
2712
|
+
}
|
2567
2713
|
}),
|
2568
|
-
|
2714
|
+
inArray: (values) => defineFormConditional({
|
2569
2715
|
type: "object",
|
2570
2716
|
properties: {
|
2571
|
-
|
2572
|
-
type: "
|
2573
|
-
|
2574
|
-
[fieldId]: {
|
2575
|
-
type: "string",
|
2576
|
-
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'._-]*)*$",
|
2577
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2578
|
-
}
|
2579
|
-
},
|
2580
|
-
required: [fieldId]
|
2717
|
+
[fieldId]: {
|
2718
|
+
type: "string",
|
2719
|
+
enum: values
|
2581
2720
|
}
|
2582
2721
|
},
|
2583
|
-
required: [
|
2722
|
+
required: [fieldId]
|
2584
2723
|
}),
|
2585
|
-
|
2724
|
+
isValidEnglishName: () => defineFormConditional({
|
2586
2725
|
type: "object",
|
2587
2726
|
properties: {
|
2588
|
-
|
2589
|
-
type: "
|
2590
|
-
|
2591
|
-
|
2592
|
-
type: "string",
|
2593
|
-
pattern: "^[0-9]{9}$",
|
2594
|
-
description: "The National ID can only be numeric and must be 9 digits long."
|
2595
|
-
}
|
2596
|
-
},
|
2597
|
-
required: [fieldId]
|
2727
|
+
[fieldId]: {
|
2728
|
+
type: "string",
|
2729
|
+
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'._-]*)*$",
|
2730
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2598
2731
|
}
|
2599
2732
|
},
|
2600
|
-
required: [
|
2733
|
+
required: [fieldId]
|
2601
2734
|
}),
|
2602
2735
|
/**
|
2603
2736
|
* Checks if the field value matches a given regular expression pattern.
|
2604
2737
|
* @param pattern - The regular expression pattern to match the field value against.
|
2605
2738
|
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2606
2739
|
*/
|
2607
|
-
matches: (pattern) =>
|
2740
|
+
matches: (pattern) => defineFormConditional({
|
2608
2741
|
type: "object",
|
2609
2742
|
properties: {
|
2610
|
-
|
2611
|
-
type: "
|
2612
|
-
|
2613
|
-
[fieldId]: {
|
2614
|
-
type: "string",
|
2615
|
-
pattern
|
2616
|
-
}
|
2617
|
-
},
|
2618
|
-
required: [fieldId]
|
2743
|
+
[fieldId]: {
|
2744
|
+
type: "string",
|
2745
|
+
pattern
|
2619
2746
|
}
|
2620
2747
|
},
|
2621
|
-
required: [
|
2748
|
+
required: [fieldId]
|
2622
2749
|
}),
|
2623
|
-
isBetween: (min, max) =>
|
2750
|
+
isBetween: (min, max) => defineFormConditional({
|
2624
2751
|
type: "object",
|
2625
2752
|
properties: {
|
2626
|
-
|
2627
|
-
type: "
|
2628
|
-
|
2629
|
-
|
2630
|
-
type: "number",
|
2631
|
-
minimum: min,
|
2632
|
-
maximum: max
|
2633
|
-
}
|
2634
|
-
},
|
2635
|
-
required: [fieldId]
|
2753
|
+
[fieldId]: {
|
2754
|
+
type: "number",
|
2755
|
+
minimum: min,
|
2756
|
+
maximum: max
|
2636
2757
|
}
|
2637
2758
|
},
|
2638
|
-
required: [
|
2759
|
+
required: [fieldId]
|
2760
|
+
}),
|
2761
|
+
getId: () => ({ fieldId })
|
2762
|
+
};
|
2763
|
+
}
|
2764
|
+
|
2765
|
+
// ../commons/src/field-config/field-configuration.ts
|
2766
|
+
function createFieldConfigs(fieldId) {
|
2767
|
+
const baseField = {
|
2768
|
+
fieldId,
|
2769
|
+
fieldType: "field"
|
2770
|
+
};
|
2771
|
+
return {
|
2772
|
+
/**
|
2773
|
+
* Creates a range configuration for the specified field.
|
2774
|
+
*
|
2775
|
+
* @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
|
2776
|
+
*
|
2777
|
+
* @example field('age').range()
|
2778
|
+
* // {
|
2779
|
+
* // fieldId: 'age',
|
2780
|
+
* // config: { type: 'RANGE' }
|
2781
|
+
* // }
|
2782
|
+
*/
|
2783
|
+
range: () => ({
|
2784
|
+
...baseField,
|
2785
|
+
config: { type: "RANGE" }
|
2786
|
+
}),
|
2787
|
+
/**
|
2788
|
+
* Creates a configuration for exact matching of the specified field.
|
2789
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2790
|
+
* @example field('dob').exact()
|
2791
|
+
* // {
|
2792
|
+
* // fieldId: 'dob',
|
2793
|
+
* // config: { type: 'EXACT' }
|
2794
|
+
* // }
|
2795
|
+
*/
|
2796
|
+
exact: () => ({
|
2797
|
+
...baseField,
|
2798
|
+
config: { type: "EXACT" }
|
2799
|
+
}),
|
2800
|
+
/**
|
2801
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
2802
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2803
|
+
* @example field('name').fuzzy()
|
2804
|
+
* // {
|
2805
|
+
* // fieldId: 'name',
|
2806
|
+
* // config: { type: 'FUZZY' }
|
2807
|
+
* // }
|
2808
|
+
*/
|
2809
|
+
fuzzy: () => ({
|
2810
|
+
...baseField,
|
2811
|
+
config: { type: "FUZZY" }
|
2639
2812
|
})
|
2640
2813
|
};
|
2641
2814
|
}
|
2642
2815
|
|
2816
|
+
// ../commons/src/events/field.ts
|
2817
|
+
function field(fieldId) {
|
2818
|
+
return {
|
2819
|
+
/**
|
2820
|
+
* @private Internal property used for field reference tracking.
|
2821
|
+
*/
|
2822
|
+
_fieldId: fieldId,
|
2823
|
+
...createFieldConditionals(fieldId),
|
2824
|
+
...createFieldConfigs(fieldId)
|
2825
|
+
};
|
2826
|
+
}
|
2827
|
+
|
2643
2828
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2644
2829
|
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2645
2830
|
label: {
|
@@ -3378,9 +3563,8 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3378
3563
|
},
|
3379
3564
|
{
|
3380
3565
|
id: "applicant.dob",
|
3381
|
-
type:
|
3566
|
+
type: FieldType.DATE,
|
3382
3567
|
required: true,
|
3383
|
-
conditionals: [],
|
3384
3568
|
validation: [
|
3385
3569
|
{
|
3386
3570
|
message: {
|
@@ -3391,12 +3575,50 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3391
3575
|
validator: field("applicant.dob").isBefore().now()
|
3392
3576
|
}
|
3393
3577
|
],
|
3578
|
+
conditionals: [
|
3579
|
+
{
|
3580
|
+
type: ConditionalType.SHOW,
|
3581
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3582
|
+
}
|
3583
|
+
],
|
3394
3584
|
label: {
|
3395
3585
|
defaultMessage: "Applicant's date of birth",
|
3396
3586
|
description: "This is the label for the field",
|
3397
3587
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3398
3588
|
}
|
3399
3589
|
},
|
3590
|
+
{
|
3591
|
+
id: "applicant.dobUnknown",
|
3592
|
+
type: FieldType.CHECKBOX,
|
3593
|
+
required: false,
|
3594
|
+
label: {
|
3595
|
+
defaultMessage: "Exact date of birth unknown",
|
3596
|
+
description: "This is the label for the field",
|
3597
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3598
|
+
},
|
3599
|
+
conditionals: [
|
3600
|
+
{
|
3601
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3602
|
+
conditional: never()
|
3603
|
+
}
|
3604
|
+
]
|
3605
|
+
},
|
3606
|
+
{
|
3607
|
+
id: "applicant.age",
|
3608
|
+
type: FieldType.NUMBER,
|
3609
|
+
required: true,
|
3610
|
+
label: {
|
3611
|
+
defaultMessage: "Age of tennis-member",
|
3612
|
+
description: "This is the label for the field",
|
3613
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3614
|
+
},
|
3615
|
+
conditionals: [
|
3616
|
+
{
|
3617
|
+
type: ConditionalType.SHOW,
|
3618
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3619
|
+
}
|
3620
|
+
]
|
3621
|
+
},
|
3400
3622
|
{
|
3401
3623
|
id: "applicant.image",
|
3402
3624
|
type: FieldType.FILE,
|
@@ -3519,20 +3741,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3519
3741
|
description: "This is what this event is referred as in the system",
|
3520
3742
|
id: "event.tennis-club-membership.label"
|
3521
3743
|
},
|
3744
|
+
title: {
|
3745
|
+
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3746
|
+
description: "This is the title of the summary",
|
3747
|
+
id: "v2.event.tennis-club-membership.title"
|
3748
|
+
},
|
3522
3749
|
summary: {
|
3523
|
-
title: {
|
3524
|
-
id: "event.tennis-club-membership.summary.title",
|
3525
|
-
label: {
|
3526
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3527
|
-
description: "This is the title of the summary",
|
3528
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3529
|
-
},
|
3530
|
-
emptyValueMessage: {
|
3531
|
-
defaultMessage: "Membership application",
|
3532
|
-
description: "This is the message shown when the applicant name is missing",
|
3533
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3534
|
-
}
|
3535
|
-
},
|
3536
3750
|
fields: [
|
3537
3751
|
{
|
3538
3752
|
id: "applicant.firstname",
|
@@ -3572,28 +3786,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3572
3786
|
}
|
3573
3787
|
]
|
3574
3788
|
},
|
3575
|
-
workqueues: [
|
3576
|
-
{
|
3577
|
-
id: "all",
|
3578
|
-
filters: []
|
3579
|
-
},
|
3580
|
-
{
|
3581
|
-
id: "ready-for-review",
|
3582
|
-
filters: [
|
3583
|
-
{
|
3584
|
-
status: ["DECLARED"]
|
3585
|
-
}
|
3586
|
-
]
|
3587
|
-
},
|
3588
|
-
{
|
3589
|
-
id: "registered",
|
3590
|
-
filters: [
|
3591
|
-
{
|
3592
|
-
status: ["REGISTERED"]
|
3593
|
-
}
|
3594
|
-
]
|
3595
|
-
}
|
3596
|
-
],
|
3597
3789
|
actions: [
|
3598
3790
|
{
|
3599
3791
|
type: ActionType.DECLARE,
|
@@ -3901,18 +4093,14 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3901
4093
|
description: "This is what this event is referred as in the system",
|
3902
4094
|
id: "v2.event.tennis-club-membership.search"
|
3903
4095
|
},
|
3904
|
-
fields: [
|
3905
|
-
{
|
3906
|
-
fieldId: "applicant.dob"
|
3907
|
-
}
|
3908
|
-
]
|
4096
|
+
fields: [field("applicant.dob").exact()]
|
3909
4097
|
}
|
3910
4098
|
],
|
3911
4099
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3912
4100
|
});
|
3913
4101
|
|
3914
4102
|
// ../commons/src/events/test.utils.ts
|
3915
|
-
function
|
4103
|
+
function fieldConfigsToActionPayload(fields) {
|
3916
4104
|
return fields.reduce(
|
3917
4105
|
(acc, field2, i) => ({
|
3918
4106
|
...acc,
|
@@ -3921,23 +4109,27 @@ function fieldConfigsToActionAnnotation(fields) {
|
|
3921
4109
|
{}
|
3922
4110
|
);
|
3923
4111
|
}
|
3924
|
-
function
|
4112
|
+
function generateActionDeclarationInput(configuration, action) {
|
3925
4113
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
3926
4114
|
if (parsed.success) {
|
3927
4115
|
const fields = getDeclarationFields(configuration);
|
3928
|
-
const
|
3929
|
-
|
4116
|
+
const declarationConfig = getDeclaration(configuration);
|
4117
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4118
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
3930
4119
|
}
|
3931
4120
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
3932
4121
|
return {};
|
3933
4122
|
}
|
3934
|
-
function
|
4123
|
+
function generateActionAnnotationInput(configuration, action) {
|
3935
4124
|
const actionConfig = configuration.actions.find(
|
3936
|
-
(
|
4125
|
+
(ac) => ac.type === action
|
3937
4126
|
);
|
3938
4127
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3939
|
-
const annotation =
|
3940
|
-
const visibleVerificationPageIds = (
|
4128
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4129
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4130
|
+
findRecordActionPages(configuration, action),
|
4131
|
+
annotation
|
4132
|
+
);
|
3941
4133
|
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3942
4134
|
(acc, pageId) => ({
|
3943
4135
|
...acc,
|
@@ -3945,7 +4137,7 @@ function generateActionMetadataInput(configuration, action) {
|
|
3945
4137
|
}),
|
3946
4138
|
{}
|
3947
4139
|
);
|
3948
|
-
const fieldBasedPayload =
|
4140
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
3949
4141
|
return {
|
3950
4142
|
...fieldBasedPayload,
|
3951
4143
|
...visiblePageVerificationMap
|
@@ -3961,14 +4153,16 @@ var eventPayloadGenerator = {
|
|
3961
4153
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3962
4154
|
id
|
3963
4155
|
}),
|
3964
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4156
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3965
4157
|
{
|
3966
4158
|
id: getUUID(),
|
3967
4159
|
eventId,
|
3968
4160
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3969
4161
|
transactionId: getUUID(),
|
3970
4162
|
action: {
|
3971
|
-
|
4163
|
+
transactionId: getUUID(),
|
4164
|
+
type: actionType,
|
4165
|
+
status: ActionStatus.Accepted,
|
3972
4166
|
declaration: {
|
3973
4167
|
"applicant.firstname": "Max",
|
3974
4168
|
"applicant.surname": "McLaren",
|
@@ -3981,7 +4175,9 @@ var eventPayloadGenerator = {
|
|
3981
4175
|
},
|
3982
4176
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3983
4177
|
createdBy: "@todo",
|
3984
|
-
|
4178
|
+
createdByRole: "@todo",
|
4179
|
+
createdAtLocation: "@todo",
|
4180
|
+
updatedAtLocation: "@todo"
|
3985
4181
|
}
|
3986
4182
|
},
|
3987
4183
|
input
|
@@ -3990,8 +4186,11 @@ var eventPayloadGenerator = {
|
|
3990
4186
|
declare: (eventId, input = {}) => ({
|
3991
4187
|
type: ActionType.DECLARE,
|
3992
4188
|
transactionId: input.transactionId ?? getUUID(),
|
3993
|
-
declaration: input.declaration ??
|
3994
|
-
|
4189
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4190
|
+
tennisClubMembershipEvent,
|
4191
|
+
ActionType.DECLARE
|
4192
|
+
),
|
4193
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3995
4194
|
tennisClubMembershipEvent,
|
3996
4195
|
ActionType.DECLARE
|
3997
4196
|
),
|
@@ -4004,7 +4203,10 @@ var eventPayloadGenerator = {
|
|
4004
4203
|
let declaration = input.declaration;
|
4005
4204
|
if (!declaration) {
|
4006
4205
|
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4007
|
-
|
4206
|
+
generateActionDeclarationInput(
|
4207
|
+
tennisClubMembershipEvent,
|
4208
|
+
ActionType.DECLARE
|
4209
|
+
),
|
4008
4210
|
import_lodash2.isString
|
4009
4211
|
);
|
4010
4212
|
declaration = partialDeclaration;
|
@@ -4019,14 +4221,31 @@ var eventPayloadGenerator = {
|
|
4019
4221
|
validate: (eventId, input = {}) => ({
|
4020
4222
|
type: ActionType.VALIDATE,
|
4021
4223
|
transactionId: input.transactionId ?? getUUID(),
|
4022
|
-
declaration: input.declaration ??
|
4023
|
-
|
4224
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4225
|
+
tennisClubMembershipEvent,
|
4226
|
+
ActionType.VALIDATE
|
4227
|
+
),
|
4228
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4024
4229
|
tennisClubMembershipEvent,
|
4025
4230
|
ActionType.VALIDATE
|
4026
4231
|
),
|
4027
4232
|
duplicates: [],
|
4028
4233
|
eventId
|
4029
4234
|
}),
|
4235
|
+
assign: (eventId, input = {}) => ({
|
4236
|
+
type: ActionType.ASSIGN,
|
4237
|
+
transactionId: input.transactionId ?? getUUID(),
|
4238
|
+
declaration: {},
|
4239
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4240
|
+
eventId
|
4241
|
+
}),
|
4242
|
+
unassign: (eventId, input = {}) => ({
|
4243
|
+
type: ActionType.UNASSIGN,
|
4244
|
+
transactionId: input.transactionId ?? getUUID(),
|
4245
|
+
declaration: {},
|
4246
|
+
assignedTo: null,
|
4247
|
+
eventId
|
4248
|
+
}),
|
4030
4249
|
archive: (eventId, input = {}, isDuplicate) => ({
|
4031
4250
|
type: ActionType.ARCHIVE,
|
4032
4251
|
transactionId: input.transactionId ?? getUUID(),
|
@@ -4040,7 +4259,7 @@ var eventPayloadGenerator = {
|
|
4040
4259
|
type: ActionType.REJECT,
|
4041
4260
|
transactionId: input.transactionId ?? getUUID(),
|
4042
4261
|
declaration: {},
|
4043
|
-
annotation: input.annotation ??
|
4262
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4044
4263
|
tennisClubMembershipEvent,
|
4045
4264
|
ActionType.REJECT
|
4046
4265
|
),
|
@@ -4050,8 +4269,11 @@ var eventPayloadGenerator = {
|
|
4050
4269
|
register: (eventId, input = {}) => ({
|
4051
4270
|
type: ActionType.REGISTER,
|
4052
4271
|
transactionId: input.transactionId ?? getUUID(),
|
4053
|
-
declaration: input.declaration ??
|
4054
|
-
|
4272
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4273
|
+
tennisClubMembershipEvent,
|
4274
|
+
ActionType.REGISTER
|
4275
|
+
),
|
4276
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4055
4277
|
tennisClubMembershipEvent,
|
4056
4278
|
ActionType.REGISTER
|
4057
4279
|
),
|
@@ -4061,7 +4283,7 @@ var eventPayloadGenerator = {
|
|
4061
4283
|
type: ActionType.PRINT_CERTIFICATE,
|
4062
4284
|
transactionId: input.transactionId ?? getUUID(),
|
4063
4285
|
declaration: {},
|
4064
|
-
annotation: input.annotation ??
|
4286
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4065
4287
|
tennisClubMembershipEvent,
|
4066
4288
|
ActionType.PRINT_CERTIFICATE
|
4067
4289
|
),
|
@@ -4071,11 +4293,11 @@ var eventPayloadGenerator = {
|
|
4071
4293
|
request: (eventId, input = {}) => ({
|
4072
4294
|
type: ActionType.REQUEST_CORRECTION,
|
4073
4295
|
transactionId: input.transactionId ?? getUUID(),
|
4074
|
-
declaration: input.declaration ??
|
4296
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4075
4297
|
tennisClubMembershipEvent,
|
4076
4298
|
ActionType.REQUEST_CORRECTION
|
4077
4299
|
),
|
4078
|
-
annotation: input.annotation ??
|
4300
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4079
4301
|
tennisClubMembershipEvent,
|
4080
4302
|
ActionType.REQUEST_CORRECTION
|
4081
4303
|
),
|
@@ -4085,7 +4307,7 @@ var eventPayloadGenerator = {
|
|
4085
4307
|
type: ActionType.APPROVE_CORRECTION,
|
4086
4308
|
transactionId: input.transactionId ?? getUUID(),
|
4087
4309
|
declaration: {},
|
4088
|
-
annotation: input.annotation ??
|
4310
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4089
4311
|
tennisClubMembershipEvent,
|
4090
4312
|
ActionType.APPROVE_CORRECTION
|
4091
4313
|
),
|
@@ -4096,7 +4318,7 @@ var eventPayloadGenerator = {
|
|
4096
4318
|
type: ActionType.REJECT_CORRECTION,
|
4097
4319
|
transactionId: input.transactionId ?? getUUID(),
|
4098
4320
|
declaration: {},
|
4099
|
-
annotation: input.annotation ??
|
4321
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4100
4322
|
tennisClubMembershipEvent,
|
4101
4323
|
ActionType.REJECT_CORRECTION
|
4102
4324
|
),
|
@@ -4116,18 +4338,25 @@ function generateActionDocument({
|
|
4116
4338
|
// @TODO: This should be fixed in the future.
|
4117
4339
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
4118
4340
|
createdBy: getUUID(),
|
4341
|
+
createdByRole: "FIELD_AGENT",
|
4119
4342
|
id: getUUID(),
|
4120
4343
|
createdAtLocation: "TODO",
|
4121
|
-
|
4344
|
+
updatedAtLocation: "TODO",
|
4345
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4122
4346
|
annotation: {},
|
4123
4347
|
...defaults,
|
4124
|
-
status: ActionStatus.Accepted
|
4348
|
+
status: ActionStatus.Accepted,
|
4349
|
+
transactionId: getUUID()
|
4125
4350
|
};
|
4126
4351
|
switch (action) {
|
4352
|
+
case ActionType.READ:
|
4353
|
+
return { ...actionBase, type: action };
|
4354
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4355
|
+
return { ...actionBase, type: action };
|
4127
4356
|
case ActionType.DECLARE:
|
4128
4357
|
return { ...actionBase, type: action };
|
4129
4358
|
case ActionType.UNASSIGN:
|
4130
|
-
return { ...actionBase, type: action };
|
4359
|
+
return { ...actionBase, type: action, assignedTo: null };
|
4131
4360
|
case ActionType.ASSIGN:
|
4132
4361
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
4133
4362
|
case ActionType.VALIDATE:
|
@@ -4153,6 +4382,8 @@ function generateActionDocument({
|
|
4153
4382
|
...actionBase,
|
4154
4383
|
type: action
|
4155
4384
|
};
|
4385
|
+
case ActionType.DELETE:
|
4386
|
+
case ActionType.DETECT_DUPLICATE:
|
4156
4387
|
default:
|
4157
4388
|
throw new Error(`Unsupported action type: ${action}`);
|
4158
4389
|
}
|
@@ -4173,7 +4404,9 @@ function generateEventDocument({
|
|
4173
4404
|
id: getUUID(),
|
4174
4405
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
4175
4406
|
// @TODO: This should be fixed in the future.
|
4176
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4407
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4408
|
+
dateOfEvent: configuration.dateOfEvent,
|
4409
|
+
updatedAtLocation: getUUID()
|
4177
4410
|
};
|
4178
4411
|
}
|
4179
4412
|
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
@@ -4202,9 +4435,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4202
4435
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4203
4436
|
createdBy: overrides.createdBy ?? getUUID(),
|
4204
4437
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
4205
|
-
|
4438
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4439
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4206
4440
|
assignedTo: overrides.assignedTo ?? null,
|
4207
4441
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4442
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4208
4443
|
declaration: overrides.declaration ?? {
|
4209
4444
|
"recommender.none": true,
|
4210
4445
|
"applicant.firstname": "Danny",
|
@@ -4236,7 +4471,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
4236
4471
|
return true;
|
4237
4472
|
}
|
4238
4473
|
function isFieldConfigDefaultValue(value) {
|
4239
|
-
if (!value)
|
4474
|
+
if (!value) {
|
4475
|
+
return false;
|
4476
|
+
}
|
4240
4477
|
if (isFieldValue(value)) {
|
4241
4478
|
return true;
|
4242
4479
|
}
|
@@ -4248,3 +4485,213 @@ function isFieldConfigDefaultValue(value) {
|
|
4248
4485
|
}
|
4249
4486
|
return false;
|
4250
4487
|
}
|
4488
|
+
|
4489
|
+
// ../commons/src/events/scopes.ts
|
4490
|
+
var import_lodash3 = require("lodash");
|
4491
|
+
|
4492
|
+
// ../commons/src/scopes.ts
|
4493
|
+
var SCOPES = {
|
4494
|
+
// TODO v1.8 legacy scopes
|
4495
|
+
NATLSYSADMIN: "natlsysadmin",
|
4496
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
4497
|
+
DECLARE: "declare",
|
4498
|
+
REGISTER: "register",
|
4499
|
+
VALIDATE: "validate",
|
4500
|
+
DEMO: "demo",
|
4501
|
+
CERTIFY: "certify",
|
4502
|
+
PERFORMANCE: "performance",
|
4503
|
+
SYSADMIN: "sysadmin",
|
4504
|
+
TEAMS: "teams",
|
4505
|
+
CONFIG: "config",
|
4506
|
+
// systems / integrations
|
4507
|
+
WEBHOOK: "webhook",
|
4508
|
+
NATIONALID: "nationalId",
|
4509
|
+
NOTIFICATION_API: "notification-api",
|
4510
|
+
RECORDSEARCH: "recordsearch",
|
4511
|
+
/**
|
4512
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4513
|
+
*/
|
4514
|
+
RECORD_DECLARE: "record.declare-birth",
|
4515
|
+
// declare
|
4516
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4517
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4518
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
4519
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4520
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4521
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4522
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4523
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4524
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4525
|
+
// validate
|
4526
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4527
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4528
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4529
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4530
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4531
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4532
|
+
// register
|
4533
|
+
RECORD_REGISTER: "record.register",
|
4534
|
+
// certify
|
4535
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
4536
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4537
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4538
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4539
|
+
// v1.8
|
4540
|
+
/**
|
4541
|
+
* This scope is used to **print and **issue certified copies of a record
|
4542
|
+
* after it has been registered. Previously Registrars had this permission.
|
4543
|
+
*/
|
4544
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4545
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4546
|
+
// v1.8
|
4547
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4548
|
+
// v1.8
|
4549
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4550
|
+
// v1.8
|
4551
|
+
// correct
|
4552
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4553
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4554
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4555
|
+
// v1.8
|
4556
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4557
|
+
// v1.8
|
4558
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4559
|
+
// v1.8
|
4560
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4561
|
+
// v1.8
|
4562
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4563
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4564
|
+
// search
|
4565
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4566
|
+
SEARCH_BIRTH: "search.birth",
|
4567
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4568
|
+
SEARCH_DEATH: "search.death",
|
4569
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4570
|
+
SEARCH_MARRIAGE: "search.marriage",
|
4571
|
+
// audit v1.8
|
4572
|
+
RECORD_READ: "record.read",
|
4573
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
4574
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
4575
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4576
|
+
// profile
|
4577
|
+
PROFILE_UPDATE: "profile.update",
|
4578
|
+
//v1.8
|
4579
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4580
|
+
// performance
|
4581
|
+
PERFORMANCE_READ: "performance.read",
|
4582
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4583
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4584
|
+
// organisation
|
4585
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4586
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4587
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4588
|
+
// user
|
4589
|
+
USER_READ: "user.read:all",
|
4590
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
4591
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4592
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4593
|
+
//v1.8
|
4594
|
+
USER_CREATE: "user.create:all",
|
4595
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4596
|
+
USER_UPDATE: "user.update:all",
|
4597
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4598
|
+
// config
|
4599
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
4600
|
+
// data seeding
|
4601
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
4602
|
+
};
|
4603
|
+
var scopes = Object.values(SCOPES);
|
4604
|
+
|
4605
|
+
// ../commons/src/events/scopes.ts
|
4606
|
+
function hasAnyOfScopes(a, b) {
|
4607
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4608
|
+
}
|
4609
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
4610
|
+
SCOPES.RECORD_DECLARE,
|
4611
|
+
SCOPES.RECORD_READ,
|
4612
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4613
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4614
|
+
SCOPES.RECORD_REGISTER,
|
4615
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
4616
|
+
SCOPES.CONFIG,
|
4617
|
+
SCOPES.CONFIG_UPDATE_ALL
|
4618
|
+
];
|
4619
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
4620
|
+
SCOPES.SEARCH_BIRTH,
|
4621
|
+
SCOPES.SEARCH_DEATH,
|
4622
|
+
SCOPES.SEARCH_MARRIAGE,
|
4623
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
4624
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
4625
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
4626
|
+
];
|
4627
|
+
var ACTION_ALLOWED_SCOPES = {
|
4628
|
+
[ActionType.READ]: [
|
4629
|
+
SCOPES.RECORD_DECLARE,
|
4630
|
+
SCOPES.RECORD_READ,
|
4631
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4632
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4633
|
+
SCOPES.RECORD_REGISTER,
|
4634
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
4635
|
+
],
|
4636
|
+
[ActionType.CREATE]: [
|
4637
|
+
SCOPES.RECORD_DECLARE,
|
4638
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4639
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
4640
|
+
],
|
4641
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
4642
|
+
[ActionType.DECLARE]: [
|
4643
|
+
SCOPES.RECORD_DECLARE,
|
4644
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4645
|
+
SCOPES.RECORD_REGISTER
|
4646
|
+
],
|
4647
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
4648
|
+
[ActionType.VALIDATE]: [
|
4649
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4650
|
+
SCOPES.RECORD_REGISTER
|
4651
|
+
],
|
4652
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
4653
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
4654
|
+
[ActionType.REQUEST_CORRECTION]: [
|
4655
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
4656
|
+
],
|
4657
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4658
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4659
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4660
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4661
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
4662
|
+
[ActionType.ASSIGN]: null,
|
4663
|
+
[ActionType.UNASSIGN]: null,
|
4664
|
+
[ActionType.DETECT_DUPLICATE]: []
|
4665
|
+
};
|
4666
|
+
function filterUnallowedActions(actions, userScopes) {
|
4667
|
+
const allowedActions = actions.filter((action) => {
|
4668
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
4669
|
+
if (requiredScopes === null) {
|
4670
|
+
return true;
|
4671
|
+
}
|
4672
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
4673
|
+
});
|
4674
|
+
const hasOtherAllowedActions = allowedActions.some(
|
4675
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
4676
|
+
);
|
4677
|
+
if (hasOtherAllowedActions) {
|
4678
|
+
return allowedActions;
|
4679
|
+
}
|
4680
|
+
return [ActionType.READ];
|
4681
|
+
}
|
4682
|
+
|
4683
|
+
// ../commons/src/event-config/event-configuration.ts
|
4684
|
+
function createEventFieldConfig(fieldId, options) {
|
4685
|
+
return {
|
4686
|
+
fieldId,
|
4687
|
+
options,
|
4688
|
+
config: { type: "EXACT" },
|
4689
|
+
fieldType: "event"
|
4690
|
+
};
|
4691
|
+
}
|
4692
|
+
|
4693
|
+
// ../commons/src/events/event.ts
|
4694
|
+
function eventFn(fieldId, options) {
|
4695
|
+
return createEventFieldConfig(fieldId, options);
|
4696
|
+
}
|
4697
|
+
var event = Object.assign(eventFn, createEventConditionals());
|