@opencrvs/toolkit 1.8.0-rc.f9911ed → 1.8.0-rc.f9d33b7
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/README.md +1 -1
- package/dist/commons/api/router.d.ts +10101 -14872
- package/dist/commons/conditionals/conditionals.d.ts +30 -5
- package/dist/commons/conditionals/validate.d.ts +12 -17
- package/dist/commons/events/ActionConfig.d.ts +85214 -5717
- package/dist/commons/events/ActionDocument.d.ts +7706 -295
- package/dist/commons/events/ActionInput.d.ts +2164 -419
- package/dist/commons/events/ActionType.d.ts +26 -16
- 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 +75 -45
- package/dist/commons/events/EventConfig.d.ts +40486 -2985
- package/dist/commons/events/EventConfigInput.d.ts +5 -2
- package/dist/commons/events/EventDocument.d.ts +1027 -379
- package/dist/commons/events/EventIndex.d.ts +921 -7
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +16 -3
- package/dist/commons/events/FieldConfig.d.ts +3702 -757
- 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 +38914 -339
- package/dist/commons/events/PageConfig.d.ts +9803 -0
- 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 +6758 -485
- 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 +5 -1
- package/dist/commons/events/scopes.d.ts +26 -0
- package/dist/commons/events/test.utils.d.ts +63 -321
- package/dist/commons/events/utils.d.ts +3423 -179
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +191 -120
- package/dist/events/index.js +1855 -1187
- package/package.json +3 -2
package/dist/events/index.js
CHANGED
@@ -30,13 +30,18 @@ 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,
|
34
|
+
Action: () => Action,
|
33
35
|
ActionBase: () => ActionBase,
|
34
36
|
ActionConditional: () => ActionConditional,
|
35
37
|
ActionConfig: () => ActionConfig,
|
36
38
|
ActionConfigBase: () => ActionConfigBase,
|
37
39
|
ActionDocument: () => ActionDocument,
|
40
|
+
ActionFormConfig: () => ActionFormConfig,
|
38
41
|
ActionInput: () => ActionInput,
|
42
|
+
ActionStatus: () => ActionStatus,
|
39
43
|
ActionType: () => ActionType,
|
44
|
+
ActionTypes: () => ActionTypes,
|
40
45
|
ActionUpdate: () => ActionUpdate,
|
41
46
|
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
42
47
|
AddressFieldValue: () => AddressFieldValue,
|
@@ -45,17 +50,30 @@ __export(events_exports, {
|
|
45
50
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
46
51
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
47
52
|
ArchiveActionInput: () => ArchiveActionInput,
|
53
|
+
AssignActionInput: () => AssignActionInput,
|
54
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
48
55
|
BaseActionInput: () => BaseActionInput,
|
56
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
57
|
+
CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
|
49
58
|
CertificateConfig: () => CertificateConfig,
|
50
59
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
51
60
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
52
61
|
Clause: () => Clause,
|
53
62
|
Conditional: () => Conditional,
|
54
63
|
ConditionalType: () => ConditionalType,
|
64
|
+
ConfirmableActions: () => ConfirmableActions,
|
65
|
+
DataEntry: () => DataEntry,
|
55
66
|
DataFieldValue: () => DataFieldValue,
|
56
67
|
DateValue: () => DateValue,
|
68
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
69
|
+
DeclarationActions: () => DeclarationActions,
|
70
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
71
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
72
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
57
73
|
DeclareActionInput: () => DeclareActionInput,
|
58
74
|
DeduplicationConfig: () => DeduplicationConfig,
|
75
|
+
DeleteActionInput: () => DeleteActionInput,
|
76
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
59
77
|
Draft: () => Draft,
|
60
78
|
DraftInput: () => DraftInput,
|
61
79
|
EmailField: () => EmailField,
|
@@ -63,13 +81,17 @@ __export(events_exports, {
|
|
63
81
|
EnableConditional: () => EnableConditional,
|
64
82
|
EventConfig: () => EventConfig,
|
65
83
|
EventDocument: () => EventDocument,
|
84
|
+
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
85
|
+
EventFieldId: () => EventFieldId,
|
66
86
|
EventIndex: () => EventIndex,
|
67
87
|
EventInput: () => EventInput,
|
68
88
|
EventMetadata: () => EventMetadata,
|
69
89
|
EventSearchIndex: () => EventSearchIndex,
|
70
90
|
EventStatus: () => EventStatus,
|
71
91
|
EventStatuses: () => EventStatuses,
|
92
|
+
FieldConditional: () => FieldConditional,
|
72
93
|
FieldConfig: () => FieldConfig,
|
94
|
+
FieldConfigSchema: () => FieldConfigSchema,
|
73
95
|
FieldType: () => FieldType,
|
74
96
|
FieldUpdateValue: () => FieldUpdateValue,
|
75
97
|
FieldValue: () => FieldValue,
|
@@ -77,49 +99,66 @@ __export(events_exports, {
|
|
77
99
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
78
100
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
79
101
|
FormConfig: () => FormConfig,
|
80
|
-
FormPage: () => FormPage,
|
81
102
|
FormPageConfig: () => FormPageConfig,
|
82
|
-
FormPageType: () => FormPageType,
|
83
103
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
84
104
|
GenericAddressValue: () => GenericAddressValue,
|
85
105
|
GeographicalArea: () => GeographicalArea,
|
86
106
|
ImageMimeType: () => ImageMimeType,
|
87
107
|
LanguageConfig: () => LanguageConfig,
|
88
|
-
LatentActions: () => LatentActions,
|
89
108
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
109
|
+
MatchType: () => MatchType,
|
90
110
|
MimeType: () => MimeType,
|
111
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
91
112
|
NotifyActionInput: () => NotifyActionInput,
|
92
113
|
NumberFieldValue: () => NumberFieldValue,
|
114
|
+
PageConfig: () => PageConfig,
|
115
|
+
PageTypes: () => PageTypes,
|
93
116
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
117
|
+
QueryInput: () => QueryInput,
|
118
|
+
QueryType: () => QueryType,
|
119
|
+
ReadActionInput: () => ReadActionInput,
|
120
|
+
RegisterAction: () => RegisterAction,
|
94
121
|
RegisterActionInput: () => RegisterActionInput,
|
95
122
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
96
123
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
97
124
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
98
|
-
RequiredTextValue: () => RequiredTextValue,
|
99
125
|
ResolvedUser: () => ResolvedUser,
|
100
126
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
101
127
|
RuralAddressValue: () => RuralAddressValue,
|
128
|
+
SearchField: () => SearchField,
|
129
|
+
SelectOption: () => SelectOption,
|
102
130
|
ShowConditional: () => ShowConditional,
|
103
131
|
SummaryConfig: () => SummaryConfig,
|
104
132
|
TextValue: () => TextValue,
|
105
133
|
TranslationConfig: () => TranslationConfig,
|
134
|
+
UnassignActionInput: () => UnassignActionInput,
|
106
135
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
107
136
|
UrbanAddressValue: () => UrbanAddressValue,
|
108
137
|
ValidateActionInput: () => ValidateActionInput,
|
109
|
-
|
138
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
110
139
|
VerificationPageConfig: () => VerificationPageConfig,
|
111
140
|
WorkqueueConfig: () => WorkqueueConfig,
|
141
|
+
ZodDate: () => ZodDate,
|
112
142
|
alwaysTrue: () => alwaysTrue,
|
113
143
|
and: () => and,
|
144
|
+
annotationActions: () => annotationActions,
|
114
145
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
146
|
+
areConditionsMet: () => areConditionsMet,
|
115
147
|
compositeFieldTypes: () => compositeFieldTypes,
|
116
148
|
createEmptyDraft: () => createEmptyDraft,
|
149
|
+
createEventConditionals: () => createEventConditionals,
|
150
|
+
createFieldConditionals: () => createFieldConditionals,
|
117
151
|
createValidationSchema: () => createValidationSchema,
|
118
152
|
deepDropNulls: () => deepDropNulls,
|
153
|
+
deepMerge: () => deepMerge,
|
154
|
+
defineActionForm: () => defineActionForm,
|
119
155
|
defineConditional: () => defineConditional,
|
120
156
|
defineConfig: () => defineConfig,
|
121
|
-
|
157
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
158
|
+
defineFormConditional: () => defineFormConditional,
|
122
159
|
defineFormPage: () => defineFormPage,
|
160
|
+
definePage: () => definePage,
|
161
|
+
defineWorkqueue: () => defineWorkqueue,
|
123
162
|
errorMessages: () => errorMessages,
|
124
163
|
event: () => event,
|
125
164
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -128,35 +167,38 @@ __export(events_exports, {
|
|
128
167
|
eventStatuses: () => eventStatuses,
|
129
168
|
field: () => field,
|
130
169
|
fieldTypes: () => fieldTypes,
|
131
|
-
|
132
|
-
findActiveActionForm: () => findActiveActionForm,
|
133
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
134
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
135
|
-
findActiveActionVerificationPageIds: () => findActiveActionVerificationPageIds,
|
170
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
136
171
|
findActiveDrafts: () => findActiveDrafts,
|
137
|
-
|
138
|
-
|
172
|
+
findAllFields: () => findAllFields,
|
173
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
174
|
+
findRecordActionPages: () => findRecordActionPages,
|
175
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
176
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
139
177
|
generateActionDocument: () => generateActionDocument,
|
140
|
-
generateActionInput: () => generateActionInput,
|
141
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
142
178
|
generateEventDocument: () => generateEventDocument,
|
143
179
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
144
180
|
generateTransactionId: () => generateTransactionId,
|
145
181
|
generateTranslationConfig: () => generateTranslationConfig,
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
182
|
+
getAcceptedActions: () => getAcceptedActions,
|
183
|
+
getActionAnnotation: () => getActionAnnotation,
|
184
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
185
|
+
getActionReview: () => getActionReview,
|
186
|
+
getActionReviewFields: () => getActionReviewFields,
|
187
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
188
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
189
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
150
190
|
getCurrentEventState: () => getCurrentEventState,
|
151
191
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
192
|
+
getDeclaration: () => getDeclaration,
|
193
|
+
getDeclarationFields: () => getDeclarationFields,
|
194
|
+
getDeclarationPages: () => getDeclarationPages,
|
195
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
196
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
156
197
|
isAddressFieldType: () => isAddressFieldType,
|
157
198
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
158
199
|
isBulletListFieldType: () => isBulletListFieldType,
|
159
200
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
201
|
+
isConditionMet: () => isConditionMet,
|
160
202
|
isCountryFieldType: () => isCountryFieldType,
|
161
203
|
isDataFieldType: () => isDataFieldType,
|
162
204
|
isDateFieldType: () => isDateFieldType,
|
@@ -164,6 +206,7 @@ __export(events_exports, {
|
|
164
206
|
isEmailFieldType: () => isEmailFieldType,
|
165
207
|
isFacilityFieldType: () => isFacilityFieldType,
|
166
208
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
209
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
167
210
|
isFieldEnabled: () => isFieldEnabled,
|
168
211
|
isFieldValue: () => isFieldValue,
|
169
212
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -174,6 +217,7 @@ __export(events_exports, {
|
|
174
217
|
isNumberFieldType: () => isNumberFieldType,
|
175
218
|
isOfficeFieldType: () => isOfficeFieldType,
|
176
219
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
220
|
+
isPageVisible: () => isPageVisible,
|
177
221
|
isParagraphFieldType: () => isParagraphFieldType,
|
178
222
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
179
223
|
isSelectFieldType: () => isSelectFieldType,
|
@@ -182,50 +226,72 @@ __export(events_exports, {
|
|
182
226
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
183
227
|
isTextFieldType: () => isTextFieldType,
|
184
228
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
229
|
+
isVerificationPage: () => isVerificationPage,
|
230
|
+
isWriteAction: () => isWriteAction,
|
185
231
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
186
232
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
187
233
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
234
|
+
never: () => never,
|
188
235
|
not: () => not,
|
236
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
237
|
+
omitHiddenFields: () => omitHiddenFields,
|
238
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
189
239
|
or: () => or,
|
190
|
-
|
191
|
-
stripHiddenFields: () => stripHiddenFields,
|
240
|
+
runFieldValidations: () => runFieldValidations,
|
192
241
|
user: () => user,
|
193
242
|
validate: () => validate,
|
194
243
|
validateFieldInput: () => validateFieldInput,
|
195
|
-
|
244
|
+
writeActions: () => writeActions
|
196
245
|
});
|
197
246
|
module.exports = __toCommonJS(events_exports);
|
198
247
|
|
199
248
|
// ../commons/src/events/ActionConfig.ts
|
200
|
-
var
|
249
|
+
var import_zod9 = require("zod");
|
201
250
|
|
202
251
|
// ../commons/src/events/Conditional.ts
|
203
252
|
var import_zod = require("zod");
|
204
|
-
|
205
|
-
|
206
|
-
|
253
|
+
var Conditional = import_zod.z.custom(
|
254
|
+
(val) => typeof val === "object" && val !== null
|
255
|
+
);
|
207
256
|
var ConditionalType = {
|
208
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
209
257
|
SHOW: "SHOW",
|
210
|
-
|
211
|
-
|
258
|
+
ENABLE: "ENABLE",
|
259
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
212
260
|
};
|
213
261
|
var ShowConditional = import_zod.z.object({
|
214
262
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
215
|
-
conditional: Conditional
|
216
|
-
})
|
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
|
+
);
|
217
267
|
var EnableConditional = import_zod.z.object({
|
218
268
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
219
|
-
conditional: Conditional
|
220
|
-
})
|
269
|
+
conditional: Conditional
|
270
|
+
}).describe(
|
271
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
272
|
+
);
|
221
273
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
222
274
|
// Action can be shown / hidden
|
223
275
|
ShowConditional,
|
224
276
|
// Action can be shown to the user in the list but as disabled
|
225
277
|
EnableConditional
|
226
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
|
+
]);
|
227
293
|
|
228
|
-
// ../commons/src/events/
|
294
|
+
// ../commons/src/events/PageConfig.ts
|
229
295
|
var import_zod6 = require("zod");
|
230
296
|
|
231
297
|
// ../commons/src/events/FieldConfig.ts
|
@@ -256,7 +322,6 @@ var FieldType = {
|
|
256
322
|
RADIO_GROUP: "RADIO_GROUP",
|
257
323
|
FILE: "FILE",
|
258
324
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
259
|
-
HIDDEN: "HIDDEN",
|
260
325
|
BULLET_LIST: "BULLET_LIST",
|
261
326
|
CHECKBOX: "CHECKBOX",
|
262
327
|
SELECT: "SELECT",
|
@@ -361,7 +426,7 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
361
426
|
|
362
427
|
// ../commons/src/events/FieldValue.ts
|
363
428
|
var TextValue = import_zod4.z.string();
|
364
|
-
var
|
429
|
+
var NonEmptyTextValue = TextValue.min(1);
|
365
430
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
366
431
|
var EmailValue = import_zod4.z.string().email();
|
367
432
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
@@ -394,35 +459,28 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
394
459
|
|
395
460
|
// ../commons/src/events/FieldConfig.ts
|
396
461
|
var FieldId = import_zod5.z.string();
|
397
|
-
var
|
398
|
-
|
399
|
-
|
400
|
-
});
|
462
|
+
var ParentReference = import_zod5.z.object({
|
463
|
+
_fieldId: FieldId.optional()
|
464
|
+
}).optional();
|
401
465
|
var BaseField = import_zod5.z.object({
|
402
466
|
id: FieldId,
|
403
467
|
defaultValue: import_zod5.z.union([
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
NumberFieldValue,
|
410
|
-
CheckboxFieldValue
|
411
|
-
]),
|
412
|
-
DependencyExpression
|
468
|
+
TextValue,
|
469
|
+
NonEmptyTextValue,
|
470
|
+
DateValue,
|
471
|
+
NumberFieldValue,
|
472
|
+
CheckboxFieldValue
|
413
473
|
]).optional(),
|
414
|
-
|
474
|
+
parent: ParentReference,
|
475
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
415
476
|
required: import_zod5.z.boolean().default(false).optional(),
|
416
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
417
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
418
477
|
placeholder: TranslationConfig.optional(),
|
419
478
|
validation: import_zod5.z.array(
|
420
479
|
import_zod5.z.object({
|
421
|
-
validator: Conditional
|
480
|
+
validator: Conditional,
|
422
481
|
message: TranslationConfig
|
423
482
|
})
|
424
483
|
).default([]).optional(),
|
425
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
426
484
|
label: TranslationConfig,
|
427
485
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
428
486
|
});
|
@@ -431,7 +489,7 @@ var Divider = BaseField.extend({
|
|
431
489
|
});
|
432
490
|
var TextField = BaseField.extend({
|
433
491
|
type: import_zod5.z.literal(FieldType.TEXT),
|
434
|
-
defaultValue:
|
492
|
+
defaultValue: NonEmptyTextValue.optional(),
|
435
493
|
configuration: import_zod5.z.object({
|
436
494
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
437
495
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -441,7 +499,7 @@ var TextField = BaseField.extend({
|
|
441
499
|
}).describe("Text input");
|
442
500
|
var NumberField = BaseField.extend({
|
443
501
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
444
|
-
defaultValue:
|
502
|
+
defaultValue: NumberFieldValue.optional(),
|
445
503
|
configuration: import_zod5.z.object({
|
446
504
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
447
505
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -451,7 +509,7 @@ var NumberField = BaseField.extend({
|
|
451
509
|
}).describe("Number input");
|
452
510
|
var TextAreaField = BaseField.extend({
|
453
511
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
454
|
-
defaultValue:
|
512
|
+
defaultValue: NonEmptyTextValue.optional(),
|
455
513
|
configuration: import_zod5.z.object({
|
456
514
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
457
515
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -485,11 +543,11 @@ var EmailField = BaseField.extend({
|
|
485
543
|
configuration: import_zod5.z.object({
|
486
544
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
487
545
|
}).default({ maxLength: 10 }).optional(),
|
488
|
-
defaultValue:
|
546
|
+
defaultValue: NonEmptyTextValue.optional()
|
489
547
|
});
|
490
548
|
var DateField = BaseField.extend({
|
491
549
|
type: import_zod5.z.literal(FieldType.DATE),
|
492
|
-
defaultValue:
|
550
|
+
defaultValue: DateValue.optional(),
|
493
551
|
configuration: import_zod5.z.object({
|
494
552
|
notice: TranslationConfig.describe(
|
495
553
|
"Text to display above the date input"
|
@@ -508,7 +566,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
508
566
|
]);
|
509
567
|
var Paragraph = BaseField.extend({
|
510
568
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
511
|
-
defaultValue:
|
569
|
+
defaultValue: NonEmptyTextValue.optional(),
|
512
570
|
configuration: import_zod5.z.object({
|
513
571
|
styles: import_zod5.z.object({
|
514
572
|
fontVariant: HtmlFontVariant.optional()
|
@@ -517,7 +575,7 @@ var Paragraph = BaseField.extend({
|
|
517
575
|
}).describe("A read-only HTML <p> paragraph");
|
518
576
|
var PageHeader = BaseField.extend({
|
519
577
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
520
|
-
defaultValue:
|
578
|
+
defaultValue: NonEmptyTextValue.optional()
|
521
579
|
}).describe("A read-only header component for form pages");
|
522
580
|
var File = BaseField.extend({
|
523
581
|
type: import_zod5.z.literal(FieldType.FILE),
|
@@ -528,7 +586,8 @@ var File = BaseField.extend({
|
|
528
586
|
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
529
587
|
"Whether the file upload button should take the full width of the container or not"
|
530
588
|
)
|
531
|
-
}).optional()
|
589
|
+
}).optional(),
|
590
|
+
fileName: TranslationConfig.optional()
|
532
591
|
}).default({
|
533
592
|
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
534
593
|
})
|
@@ -539,7 +598,7 @@ var SelectOption = import_zod5.z.object({
|
|
539
598
|
});
|
540
599
|
var RadioGroup = BaseField.extend({
|
541
600
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
542
|
-
defaultValue:
|
601
|
+
defaultValue: TextValue.optional(),
|
543
602
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
544
603
|
configuration: import_zod5.z.object({
|
545
604
|
styles: import_zod5.z.object({
|
@@ -549,7 +608,7 @@ var RadioGroup = BaseField.extend({
|
|
549
608
|
}).describe("Grouped radio options");
|
550
609
|
var BulletList = BaseField.extend({
|
551
610
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
552
|
-
defaultValue:
|
611
|
+
defaultValue: TextValue.optional(),
|
553
612
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
554
613
|
configuration: import_zod5.z.object({
|
555
614
|
styles: import_zod5.z.object({
|
@@ -559,16 +618,16 @@ var BulletList = BaseField.extend({
|
|
559
618
|
}).describe("A list of bullet points");
|
560
619
|
var Select = BaseField.extend({
|
561
620
|
type: import_zod5.z.literal(FieldType.SELECT),
|
562
|
-
defaultValue:
|
621
|
+
defaultValue: TextValue.optional(),
|
563
622
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
564
623
|
}).describe("Select input");
|
565
624
|
var Checkbox = BaseField.extend({
|
566
625
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
567
|
-
defaultValue:
|
626
|
+
defaultValue: CheckboxFieldValue.optional()
|
568
627
|
}).describe("Boolean checkbox field");
|
569
628
|
var Country = BaseField.extend({
|
570
629
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
571
|
-
defaultValue:
|
630
|
+
defaultValue: NonEmptyTextValue.optional()
|
572
631
|
}).describe("Country select field");
|
573
632
|
var AdministrativeAreas = import_zod5.z.enum([
|
574
633
|
"ADMIN_STRUCTURE",
|
@@ -577,18 +636,18 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
577
636
|
]);
|
578
637
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
579
638
|
partOf: import_zod5.z.object({
|
580
|
-
$
|
639
|
+
$declaration: import_zod5.z.string()
|
581
640
|
}).optional().describe("Parent location"),
|
582
641
|
type: AdministrativeAreas
|
583
642
|
}).describe("Administrative area options");
|
584
643
|
var AdministrativeArea = BaseField.extend({
|
585
644
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
586
|
-
defaultValue:
|
645
|
+
defaultValue: NonEmptyTextValue.optional(),
|
587
646
|
configuration: AdministrativeAreaConfiguration
|
588
647
|
}).describe("Administrative area input field e.g. facility, office");
|
589
648
|
var Location = BaseField.extend({
|
590
649
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
591
|
-
defaultValue:
|
650
|
+
defaultValue: NonEmptyTextValue.optional()
|
592
651
|
}).describe("Input field for a location");
|
593
652
|
var FileUploadWithOptions = BaseField.extend({
|
594
653
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
@@ -602,21 +661,30 @@ var FileUploadWithOptions = BaseField.extend({
|
|
602
661
|
});
|
603
662
|
var Facility = BaseField.extend({
|
604
663
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
605
|
-
defaultValue:
|
664
|
+
defaultValue: NonEmptyTextValue.optional()
|
606
665
|
}).describe("Input field for a facility");
|
607
666
|
var Office = BaseField.extend({
|
608
667
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
609
|
-
defaultValue:
|
668
|
+
defaultValue: NonEmptyTextValue.optional()
|
610
669
|
}).describe("Input field for an office");
|
611
670
|
var Address = BaseField.extend({
|
612
671
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
613
672
|
defaultValue: AddressFieldValue.optional()
|
614
673
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
674
|
+
var DataEntry = import_zod5.z.union([
|
675
|
+
import_zod5.z.object({
|
676
|
+
label: TranslationConfig,
|
677
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
678
|
+
}),
|
679
|
+
import_zod5.z.object({
|
680
|
+
fieldId: import_zod5.z.string()
|
681
|
+
})
|
682
|
+
]);
|
615
683
|
var DataField = BaseField.extend({
|
616
684
|
type: import_zod5.z.literal(FieldType.DATA),
|
617
685
|
configuration: import_zod5.z.object({
|
618
686
|
subtitle: TranslationConfig.optional(),
|
619
|
-
data: import_zod5.z.array(
|
687
|
+
data: import_zod5.z.array(DataEntry)
|
620
688
|
})
|
621
689
|
}).describe("Data field for displaying read-only data");
|
622
690
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
@@ -644,18 +712,20 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
644
712
|
DataField
|
645
713
|
]);
|
646
714
|
|
647
|
-
// ../commons/src/events/
|
648
|
-
var
|
649
|
-
|
650
|
-
VERIFICATION: "VERIFICATION"
|
651
|
-
};
|
652
|
-
var FormPage = import_zod6.z.object({
|
715
|
+
// ../commons/src/events/PageConfig.ts
|
716
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
717
|
+
var PageConfigBase = import_zod6.z.object({
|
653
718
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
654
719
|
title: TranslationConfig.describe("Header title of the page"),
|
655
720
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
656
|
-
|
721
|
+
conditional: Conditional.optional().describe(
|
722
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
723
|
+
)
|
724
|
+
});
|
725
|
+
var FormPageConfig = PageConfigBase.extend({
|
726
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
657
727
|
});
|
658
|
-
var
|
728
|
+
var VerificationActionConfig = import_zod6.z.object({
|
659
729
|
verify: import_zod6.z.object({ label: TranslationConfig }),
|
660
730
|
cancel: import_zod6.z.object({
|
661
731
|
label: TranslationConfig,
|
@@ -665,242 +735,304 @@ var VerificationPageConfig = import_zod6.z.object({
|
|
665
735
|
})
|
666
736
|
})
|
667
737
|
}).describe("Actions available on the verification page");
|
668
|
-
var
|
669
|
-
type: import_zod6.z.literal(
|
670
|
-
actions:
|
671
|
-
});
|
672
|
-
var FormPageConfig = import_zod6.z.preprocess(
|
673
|
-
(pageConfig) => ({
|
674
|
-
...pageConfig,
|
675
|
-
type: pageConfig.type ?? FormPageType.FORM
|
676
|
-
// Default type to "FORM" if not provided
|
677
|
-
}),
|
678
|
-
import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
|
679
|
-
);
|
680
|
-
var FormConfig = import_zod6.z.object({
|
681
|
-
label: TranslationConfig.describe("Human readable description of the form"),
|
682
|
-
version: import_zod6.z.object({
|
683
|
-
id: import_zod6.z.string().describe(
|
684
|
-
"Form version. Semantic versioning recommended. Example: 0.0.1"
|
685
|
-
),
|
686
|
-
label: TranslationConfig.describe(
|
687
|
-
"Human readable description of the version"
|
688
|
-
)
|
689
|
-
}),
|
690
|
-
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
691
|
-
pages: import_zod6.z.array(FormPageConfig),
|
692
|
-
review: import_zod6.z.object({
|
693
|
-
title: TranslationConfig.describe(
|
694
|
-
"Title of the form to show in review page"
|
695
|
-
),
|
696
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
697
|
-
})
|
738
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
739
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
740
|
+
actions: VerificationActionConfig
|
698
741
|
});
|
742
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
743
|
+
FormPageConfig,
|
744
|
+
VerificationPageConfig
|
745
|
+
]);
|
699
746
|
|
700
747
|
// ../commons/src/events/ActionType.ts
|
748
|
+
var import_zod7 = require("zod");
|
701
749
|
var ActionType = {
|
750
|
+
// Pre-declaration actions
|
751
|
+
DELETE: "DELETE",
|
702
752
|
CREATE: "CREATE",
|
703
|
-
ASSIGN: "ASSIGN",
|
704
|
-
UNASSIGN: "UNASSIGN",
|
705
|
-
REGISTER: "REGISTER",
|
706
|
-
VALIDATE: "VALIDATE",
|
707
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
708
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
709
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
710
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
711
753
|
NOTIFY: "NOTIFY",
|
754
|
+
// Declaration actions
|
712
755
|
DECLARE: "DECLARE",
|
713
|
-
|
714
|
-
|
715
|
-
|
756
|
+
VALIDATE: "VALIDATE",
|
757
|
+
REGISTER: "REGISTER",
|
758
|
+
// Declaration system actions. Non-configurable.
|
759
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
716
760
|
REJECT: "REJECT",
|
761
|
+
// REJECT_DECLARATION
|
717
762
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
718
|
-
|
763
|
+
// MARK_AS_DUPLICATE
|
764
|
+
ARCHIVE: "ARCHIVE",
|
765
|
+
// Record actions
|
766
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
767
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
768
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
769
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
770
|
+
// General actions
|
771
|
+
READ: "READ",
|
772
|
+
ASSIGN: "ASSIGN",
|
773
|
+
UNASSIGN: "UNASSIGN"
|
719
774
|
};
|
720
|
-
var
|
775
|
+
var ConfirmableActions = [
|
776
|
+
ActionType.NOTIFY,
|
777
|
+
ActionType.DECLARE,
|
778
|
+
ActionType.VALIDATE,
|
779
|
+
ActionType.REGISTER,
|
780
|
+
ActionType.REJECT,
|
781
|
+
ActionType.ARCHIVE,
|
782
|
+
ActionType.PRINT_CERTIFICATE
|
783
|
+
];
|
784
|
+
var ActionTypes = import_zod7.z.enum([
|
785
|
+
"DELETE",
|
786
|
+
"CREATE",
|
787
|
+
"NOTIFY",
|
788
|
+
"DECLARE",
|
789
|
+
"VALIDATE",
|
790
|
+
"REGISTER",
|
791
|
+
"DETECT_DUPLICATE",
|
792
|
+
"REJECT",
|
793
|
+
"MARKED_AS_DUPLICATE",
|
794
|
+
"ARCHIVE",
|
795
|
+
"PRINT_CERTIFICATE",
|
796
|
+
"REQUEST_CORRECTION",
|
797
|
+
"REJECT_CORRECTION",
|
798
|
+
"APPROVE_CORRECTION",
|
799
|
+
"READ",
|
800
|
+
"ASSIGN",
|
801
|
+
"UNASSIGN"
|
802
|
+
]);
|
803
|
+
var declarationActionValues = [
|
804
|
+
ActionTypes.enum.DECLARE,
|
805
|
+
ActionTypes.enum.VALIDATE,
|
806
|
+
ActionTypes.enum.REGISTER
|
807
|
+
];
|
808
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
809
|
+
var declarationUpdateActionValues = [
|
810
|
+
...declarationActionValues,
|
811
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
812
|
+
];
|
813
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
814
|
+
declarationUpdateActionValues
|
815
|
+
);
|
816
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
817
|
+
var writeActions = ActionTypes.exclude([
|
818
|
+
ActionType.CREATE,
|
819
|
+
ActionType.READ,
|
820
|
+
ActionType.ASSIGN,
|
821
|
+
ActionType.UNASSIGN
|
822
|
+
]);
|
823
|
+
|
824
|
+
// ../commons/src/events/FormConfig.ts
|
825
|
+
var import_zod8 = require("zod");
|
826
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
827
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
828
|
+
pages: import_zod8.z.array(FormPageConfig)
|
829
|
+
}).describe("Configuration for a declaration form");
|
830
|
+
var ActionFormConfig = import_zod8.z.object({
|
831
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
832
|
+
pages: import_zod8.z.array(PageConfig)
|
833
|
+
});
|
834
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
721
835
|
|
722
836
|
// ../commons/src/events/ActionConfig.ts
|
723
|
-
var
|
837
|
+
var import_zod_openapi = require("zod-openapi");
|
838
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
|
839
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
724
840
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
725
841
|
ShowConditional,
|
726
842
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
727
843
|
EnableConditional
|
728
844
|
]);
|
729
|
-
var
|
845
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
846
|
+
title: TranslationConfig.describe("Title of the review page"),
|
847
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
848
|
+
}).describe("Configuration for **declaration** review page.");
|
849
|
+
var ActionConfigBase = import_zod9.z.object({
|
730
850
|
label: TranslationConfig,
|
731
|
-
conditionals:
|
732
|
-
draft:
|
733
|
-
forms: import_zod7.z.array(FormConfig)
|
851
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
852
|
+
draft: import_zod9.z.boolean().optional()
|
734
853
|
});
|
735
854
|
var DeclareConfig = ActionConfigBase.merge(
|
736
|
-
|
737
|
-
type:
|
855
|
+
import_zod9.z.object({
|
856
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
857
|
+
review: DeclarationReviewConfig
|
738
858
|
})
|
739
859
|
);
|
740
860
|
var ValidateConfig = ActionConfigBase.merge(
|
741
|
-
|
742
|
-
type:
|
861
|
+
import_zod9.z.object({
|
862
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
863
|
+
review: DeclarationReviewConfig
|
864
|
+
})
|
865
|
+
);
|
866
|
+
var RegisterConfig = ActionConfigBase.merge(
|
867
|
+
import_zod9.z.object({
|
868
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
869
|
+
review: DeclarationReviewConfig
|
743
870
|
})
|
744
871
|
);
|
745
872
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
746
|
-
|
747
|
-
type:
|
873
|
+
import_zod9.z.object({
|
874
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
748
875
|
})
|
749
876
|
);
|
750
877
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
751
|
-
|
752
|
-
type:
|
878
|
+
import_zod9.z.object({
|
879
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
753
880
|
})
|
754
881
|
);
|
755
882
|
var ArchiveConfig = ActionConfigBase.merge(
|
756
|
-
|
757
|
-
type:
|
758
|
-
})
|
759
|
-
);
|
760
|
-
var RegisterConfig = ActionConfigBase.merge(
|
761
|
-
import_zod7.z.object({
|
762
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
883
|
+
import_zod9.z.object({
|
884
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
763
885
|
})
|
764
886
|
);
|
765
887
|
var DeleteConfig = ActionConfigBase.merge(
|
766
|
-
|
767
|
-
type:
|
888
|
+
import_zod9.z.object({
|
889
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
768
890
|
})
|
769
891
|
);
|
770
892
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
771
|
-
|
772
|
-
type:
|
893
|
+
import_zod9.z.object({
|
894
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
895
|
+
printForm: ActionFormConfig
|
773
896
|
})
|
774
897
|
);
|
775
898
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
776
|
-
|
777
|
-
type:
|
778
|
-
onboardingForm:
|
779
|
-
additionalDetailsForm:
|
899
|
+
import_zod9.z.object({
|
900
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
901
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
902
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
780
903
|
})
|
781
904
|
);
|
782
905
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
783
|
-
|
784
|
-
type:
|
906
|
+
import_zod9.z.object({
|
907
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
785
908
|
})
|
786
909
|
);
|
787
910
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
788
|
-
|
789
|
-
type:
|
790
|
-
})
|
791
|
-
);
|
792
|
-
var CustomConfig = ActionConfigBase.merge(
|
793
|
-
import_zod7.z.object({
|
794
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
911
|
+
import_zod9.z.object({
|
912
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
795
913
|
})
|
796
914
|
);
|
797
|
-
var ActionConfig =
|
915
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
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" });
|
934
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
798
935
|
DeclareConfig,
|
799
936
|
ValidateConfig,
|
800
|
-
|
801
|
-
MarkedAsDuplicateConfig,
|
802
|
-
ArchiveConfig,
|
803
|
-
RegisterConfig,
|
804
|
-
DeleteConfig,
|
805
|
-
PrintCertificateActionConfig,
|
806
|
-
RequestCorrectionConfig,
|
807
|
-
RejectCorrectionConfig,
|
808
|
-
ApproveCorrectionConfig,
|
809
|
-
CustomConfig
|
937
|
+
RegisterConfig
|
810
938
|
]);
|
811
939
|
|
812
940
|
// ../commons/src/events/offline/CertificateConfig.ts
|
813
|
-
var
|
814
|
-
var FontFamily =
|
815
|
-
normal:
|
816
|
-
bold:
|
817
|
-
italics:
|
818
|
-
bolditalics:
|
941
|
+
var import_zod10 = require("zod");
|
942
|
+
var FontFamily = import_zod10.z.object({
|
943
|
+
normal: import_zod10.z.string(),
|
944
|
+
bold: import_zod10.z.string(),
|
945
|
+
italics: import_zod10.z.string(),
|
946
|
+
bolditalics: import_zod10.z.string()
|
819
947
|
});
|
820
|
-
var CertificateConfig =
|
821
|
-
id:
|
822
|
-
event:
|
948
|
+
var CertificateConfig = import_zod10.z.object({
|
949
|
+
id: import_zod10.z.string(),
|
950
|
+
event: import_zod10.z.string(),
|
823
951
|
label: TranslationConfig,
|
824
|
-
isDefault:
|
825
|
-
fee:
|
826
|
-
onTime:
|
827
|
-
late:
|
828
|
-
delayed:
|
952
|
+
isDefault: import_zod10.z.boolean(),
|
953
|
+
fee: import_zod10.z.object({
|
954
|
+
onTime: import_zod10.z.number(),
|
955
|
+
late: import_zod10.z.number(),
|
956
|
+
delayed: import_zod10.z.number()
|
829
957
|
}),
|
830
|
-
svgUrl:
|
831
|
-
fonts:
|
958
|
+
svgUrl: import_zod10.z.string(),
|
959
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
832
960
|
});
|
833
961
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
834
|
-
hash:
|
835
|
-
svg:
|
962
|
+
hash: import_zod10.z.string().optional(),
|
963
|
+
svg: import_zod10.z.string()
|
836
964
|
});
|
837
965
|
|
838
966
|
// ../commons/src/events/offline/LanguageConfig.ts
|
839
|
-
var
|
840
|
-
var LanguageConfig =
|
841
|
-
lang:
|
967
|
+
var import_zod11 = require("zod");
|
968
|
+
var LanguageConfig = import_zod11.z.object({
|
969
|
+
lang: import_zod11.z.string(),
|
842
970
|
/**
|
843
971
|
* client.csv contents
|
844
972
|
*/
|
845
|
-
messages:
|
973
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
846
974
|
});
|
847
975
|
|
848
976
|
// ../commons/src/events/EventConfig.ts
|
849
|
-
var
|
977
|
+
var import_zod16 = require("zod");
|
850
978
|
|
851
979
|
// ../commons/src/events/DeduplicationConfig.ts
|
852
|
-
var
|
853
|
-
var
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
980
|
+
var import_zod12 = require("zod");
|
981
|
+
var import_zod_openapi2 = require("zod-openapi");
|
982
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
|
983
|
+
var FieldReference = import_zod12.z.string();
|
984
|
+
var Matcher = import_zod12.z.object({
|
985
|
+
fieldId: import_zod12.z.string(),
|
986
|
+
options: import_zod12.z.object({
|
987
|
+
boost: import_zod12.z.number().optional()
|
858
988
|
}).optional().default({})
|
859
989
|
});
|
860
990
|
var FuzzyMatcher = Matcher.extend({
|
861
|
-
type:
|
862
|
-
options:
|
991
|
+
type: import_zod12.z.literal("fuzzy"),
|
992
|
+
options: import_zod12.z.object({
|
863
993
|
/**
|
864
994
|
* Names of length 3 or less characters = 0 edits allowed
|
865
995
|
* Names of length 4 - 6 characters = 1 edit allowed
|
866
996
|
* Names of length >7 characters = 2 edits allowed
|
867
997
|
*/
|
868
|
-
fuzziness:
|
869
|
-
boost:
|
998
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
999
|
+
boost: import_zod12.z.number().optional().default(1)
|
870
1000
|
}).optional().default({})
|
871
1001
|
});
|
872
1002
|
var StrictMatcher = Matcher.extend({
|
873
|
-
type:
|
874
|
-
options:
|
875
|
-
boost:
|
1003
|
+
type: import_zod12.z.literal("strict"),
|
1004
|
+
options: import_zod12.z.object({
|
1005
|
+
boost: import_zod12.z.number().optional().default(1)
|
876
1006
|
}).optional().default({})
|
877
1007
|
});
|
878
1008
|
var DateRangeMatcher = Matcher.extend({
|
879
|
-
type:
|
880
|
-
options:
|
881
|
-
days:
|
1009
|
+
type: import_zod12.z.literal("dateRange"),
|
1010
|
+
options: import_zod12.z.object({
|
1011
|
+
days: import_zod12.z.number(),
|
882
1012
|
origin: FieldReference,
|
883
|
-
boost:
|
1013
|
+
boost: import_zod12.z.number().optional().default(1)
|
884
1014
|
})
|
885
1015
|
});
|
886
1016
|
var DateDistanceMatcher = Matcher.extend({
|
887
|
-
type:
|
888
|
-
options:
|
889
|
-
days:
|
1017
|
+
type: import_zod12.z.literal("dateDistance"),
|
1018
|
+
options: import_zod12.z.object({
|
1019
|
+
days: import_zod12.z.number(),
|
890
1020
|
origin: FieldReference,
|
891
|
-
boost:
|
1021
|
+
boost: import_zod12.z.number().optional().default(1)
|
892
1022
|
})
|
893
1023
|
});
|
894
|
-
var And =
|
895
|
-
type:
|
896
|
-
|
1024
|
+
var And = import_zod12.z.object({
|
1025
|
+
type: import_zod12.z.literal("and"),
|
1026
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1027
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
897
1028
|
});
|
898
|
-
var Or =
|
899
|
-
type:
|
900
|
-
|
1029
|
+
var Or = import_zod12.z.object({
|
1030
|
+
type: import_zod12.z.literal("or"),
|
1031
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1032
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
901
1033
|
});
|
902
|
-
var Clause =
|
903
|
-
() =>
|
1034
|
+
var Clause = import_zod12.z.lazy(
|
1035
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
904
1036
|
And,
|
905
1037
|
Or,
|
906
1038
|
FuzzyMatcher,
|
@@ -908,275 +1040,73 @@ var Clause = import_zod10.z.lazy(
|
|
908
1040
|
DateRangeMatcher,
|
909
1041
|
DateDistanceMatcher
|
910
1042
|
])
|
911
|
-
)
|
912
|
-
|
913
|
-
|
1043
|
+
).openapi({
|
1044
|
+
ref: "Clause"
|
1045
|
+
});
|
1046
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1047
|
+
id: import_zod12.z.string(),
|
914
1048
|
label: TranslationConfig,
|
915
1049
|
query: Clause
|
916
1050
|
});
|
917
1051
|
|
918
1052
|
// ../commons/src/events/SummaryConfig.ts
|
919
|
-
var
|
920
|
-
var
|
921
|
-
|
1053
|
+
var import_zod13 = require("zod");
|
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({
|
1062
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
922
1063
|
value: TranslationConfig.describe(
|
923
1064
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
924
1065
|
),
|
925
1066
|
label: TranslationConfig,
|
926
1067
|
emptyValueMessage: TranslationConfig.optional()
|
927
|
-
});
|
928
|
-
var
|
929
|
-
|
930
|
-
label: TranslationConfig.describe("Title content"),
|
931
|
-
emptyValueMessage: TranslationConfig.optional()
|
932
|
-
});
|
933
|
-
var SummaryConfig = import_zod11.z.object({
|
934
|
-
title: Title.describe("Title of summary view."),
|
935
|
-
fields: import_zod11.z.array(Field).describe("Fields rendered in summary view.")
|
1068
|
+
}).describe("Custom configured field");
|
1069
|
+
var SummaryConfig = import_zod13.z.object({
|
1070
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
936
1071
|
}).describe("Configuration for summary in event.");
|
937
1072
|
|
938
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
939
|
-
var import_zod13 = require("zod");
|
940
|
-
|
941
|
-
// ../commons/src/events/EventMetadata.ts
|
942
|
-
var import_zod12 = require("zod");
|
943
|
-
var EventStatus = {
|
944
|
-
CREATED: "CREATED",
|
945
|
-
NOTIFIED: "NOTIFIED",
|
946
|
-
DECLARED: "DECLARED",
|
947
|
-
VALIDATED: "VALIDATED",
|
948
|
-
REGISTERED: "REGISTERED",
|
949
|
-
CERTIFIED: "CERTIFIED",
|
950
|
-
REJECTED: "REJECTED",
|
951
|
-
ARCHIVED: "ARCHIVED"
|
952
|
-
};
|
953
|
-
var eventStatuses = Object.values(EventStatus);
|
954
|
-
var EventStatuses = import_zod12.z.nativeEnum(EventStatus);
|
955
|
-
var EventMetadata = import_zod12.z.object({
|
956
|
-
id: import_zod12.z.string(),
|
957
|
-
type: import_zod12.z.string(),
|
958
|
-
status: EventStatuses,
|
959
|
-
createdAt: import_zod12.z.string().datetime(),
|
960
|
-
createdBy: import_zod12.z.string(),
|
961
|
-
createdAtLocation: import_zod12.z.string(),
|
962
|
-
modifiedAt: import_zod12.z.string().datetime(),
|
963
|
-
assignedTo: import_zod12.z.string().nullish(),
|
964
|
-
updatedBy: import_zod12.z.string(),
|
965
|
-
trackingId: import_zod12.z.string()
|
966
|
-
});
|
967
|
-
var eventMetadataLabelMap = {
|
968
|
-
"event.assignedTo": {
|
969
|
-
id: "event.assignedTo.label",
|
970
|
-
defaultMessage: "Assigned To",
|
971
|
-
description: "Assigned To"
|
972
|
-
},
|
973
|
-
"event.createdAt": {
|
974
|
-
id: "event.createdAt.label",
|
975
|
-
defaultMessage: "Created",
|
976
|
-
description: "Created At"
|
977
|
-
},
|
978
|
-
"event.createdAtLocation": {
|
979
|
-
id: "event.createdAtLocation.label",
|
980
|
-
defaultMessage: "Location",
|
981
|
-
description: "Created At Location"
|
982
|
-
},
|
983
|
-
"event.createdBy": {
|
984
|
-
id: "event.createdBy.label",
|
985
|
-
defaultMessage: "Created By",
|
986
|
-
description: "Created By"
|
987
|
-
},
|
988
|
-
"event.id": {
|
989
|
-
id: "event.id.label",
|
990
|
-
defaultMessage: "ID",
|
991
|
-
description: "ID"
|
992
|
-
},
|
993
|
-
"event.modifiedAt": {
|
994
|
-
id: "event.modifiedAt.label",
|
995
|
-
defaultMessage: "Updated",
|
996
|
-
description: "Modified At"
|
997
|
-
},
|
998
|
-
"event.status": {
|
999
|
-
id: "event.status.label",
|
1000
|
-
defaultMessage: "Status",
|
1001
|
-
description: "Status"
|
1002
|
-
},
|
1003
|
-
"event.type": {
|
1004
|
-
id: "event.type.label",
|
1005
|
-
defaultMessage: "Type",
|
1006
|
-
description: "Type"
|
1007
|
-
},
|
1008
|
-
"event.updatedBy": {
|
1009
|
-
id: "event.updatedBy.label",
|
1010
|
-
defaultMessage: "Updated By",
|
1011
|
-
description: "Updated By"
|
1012
|
-
},
|
1013
|
-
"event.trackingId": {
|
1014
|
-
id: "event.trackingId.label",
|
1015
|
-
defaultMessage: "Tracking ID",
|
1016
|
-
description: "Tracking ID"
|
1017
|
-
}
|
1018
|
-
};
|
1019
|
-
|
1020
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
1021
|
-
var WorkqueueConfig = import_zod13.z.object({
|
1022
|
-
id: import_zod13.z.string().describe("Unique identifier for workqueue."),
|
1023
|
-
filters: import_zod13.z.array(
|
1024
|
-
import_zod13.z.object({
|
1025
|
-
status: import_zod13.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1026
|
-
})
|
1027
|
-
).describe("Filters to be applied to workqueue.")
|
1028
|
-
}).describe("Configuration for workqueue.");
|
1029
|
-
|
1030
1073
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1031
1074
|
var import_zod14 = require("zod");
|
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()
|
1081
|
+
});
|
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
|
+
]);
|
1032
1095
|
var AdvancedSearchConfig = import_zod14.z.object({
|
1033
1096
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1034
|
-
fields: import_zod14.z.array(
|
1035
|
-
import_zod14.z.object({
|
1036
|
-
fieldId: import_zod14.z.string(),
|
1037
|
-
config: import_zod14.z.object({
|
1038
|
-
type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1039
|
-
}).optional().describe("Configuration options for the field")
|
1040
|
-
})
|
1041
|
-
).optional().default([]).describe("Advanced search fields.")
|
1097
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
1042
1098
|
});
|
1043
1099
|
|
1044
1100
|
// ../commons/src/events/utils.ts
|
1045
1101
|
var import_lodash = require("lodash");
|
1046
1102
|
|
1047
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1048
|
-
var import_zod16 = require("zod");
|
1049
|
-
|
1050
|
-
// ../commons/src/workqueues/defaultColumns.ts
|
1051
|
-
var import_zod15 = require("zod");
|
1052
|
-
var WorkQueueColumnConfig = import_zod15.z.object({
|
1053
|
-
id: import_zod15.z.string(),
|
1054
|
-
label: TranslationConfig
|
1055
|
-
});
|
1056
|
-
var defaultColumns = {
|
1057
|
-
event: {
|
1058
|
-
id: "event",
|
1059
|
-
label: {
|
1060
|
-
defaultMessage: "Event",
|
1061
|
-
description: "This is the label for the workqueue column",
|
1062
|
-
id: "workqueue.default.column.event"
|
1063
|
-
}
|
1064
|
-
},
|
1065
|
-
status: {
|
1066
|
-
id: "status",
|
1067
|
-
label: {
|
1068
|
-
defaultMessage: "Status",
|
1069
|
-
description: "This is the label for the workqueue column",
|
1070
|
-
id: "workqueue.default.column.status"
|
1071
|
-
}
|
1072
|
-
},
|
1073
|
-
createdAt: {
|
1074
|
-
id: "createdAt",
|
1075
|
-
label: {
|
1076
|
-
defaultMessage: "Created",
|
1077
|
-
description: "This is the label for the workqueue column",
|
1078
|
-
id: "workqueue.default.column.createdAt"
|
1079
|
-
}
|
1080
|
-
},
|
1081
|
-
modifiedAt: {
|
1082
|
-
id: "modifiedAt",
|
1083
|
-
label: {
|
1084
|
-
defaultMessage: "Modified",
|
1085
|
-
description: "This is the label for the workqueue column",
|
1086
|
-
id: "workqueue.default.column.modifiedAt"
|
1087
|
-
}
|
1088
|
-
}
|
1089
|
-
};
|
1090
|
-
var DefaultColumnKeys = import_zod15.z.enum(
|
1091
|
-
Object.keys(defaultColumns)
|
1092
|
-
);
|
1093
|
-
|
1094
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1095
|
-
var rootWorkqueueConfig = import_zod16.z.object({
|
1096
|
-
id: import_zod16.z.string(),
|
1097
|
-
title: TranslationConfig,
|
1098
|
-
columns: import_zod16.z.array(WorkQueueColumnConfig),
|
1099
|
-
defaultColumns: import_zod16.z.array(DefaultColumnKeys)
|
1100
|
-
});
|
1101
|
-
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1102
|
-
|
1103
|
-
// ../commons/src/workqueues/all.ts
|
1104
|
-
var allWorkqueue = defineWorkqueue({
|
1105
|
-
id: "all",
|
1106
|
-
title: {
|
1107
|
-
defaultMessage: "All events",
|
1108
|
-
description: "This is the label for the workqueue",
|
1109
|
-
id: "workqueue.all.label"
|
1110
|
-
},
|
1111
|
-
columns: [
|
1112
|
-
{
|
1113
|
-
id: "title",
|
1114
|
-
label: {
|
1115
|
-
defaultMessage: "Title",
|
1116
|
-
description: "This is the label for the workqueue column",
|
1117
|
-
id: "workqueue.all.column.title"
|
1118
|
-
}
|
1119
|
-
}
|
1120
|
-
],
|
1121
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1122
|
-
});
|
1123
|
-
|
1124
|
-
// ../commons/src/workqueues/readyForReview.ts
|
1125
|
-
var inReviewWorkqueue = defineWorkqueue({
|
1126
|
-
id: "ready-for-review",
|
1127
|
-
title: {
|
1128
|
-
defaultMessage: "Ready for review",
|
1129
|
-
description: "Label for in review workqueue",
|
1130
|
-
id: "event.workqueue.in-review.label"
|
1131
|
-
},
|
1132
|
-
columns: [
|
1133
|
-
{
|
1134
|
-
id: "title",
|
1135
|
-
label: {
|
1136
|
-
defaultMessage: "Title",
|
1137
|
-
description: "This is the label for the workqueue column",
|
1138
|
-
id: "workqueue.in-reveiw.column.title"
|
1139
|
-
}
|
1140
|
-
}
|
1141
|
-
],
|
1142
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1143
|
-
});
|
1144
|
-
|
1145
|
-
// ../commons/src/workqueues/readyToPrint.ts
|
1146
|
-
var registeredWorkqueue = defineWorkqueue({
|
1147
|
-
id: "registered",
|
1148
|
-
title: {
|
1149
|
-
defaultMessage: "Ready to print",
|
1150
|
-
description: "Label for registered workqueue",
|
1151
|
-
id: "event.workqueue.registered.label"
|
1152
|
-
},
|
1153
|
-
columns: [
|
1154
|
-
{
|
1155
|
-
id: "title",
|
1156
|
-
label: {
|
1157
|
-
defaultMessage: "Title",
|
1158
|
-
description: "This is the label for the workqueue column",
|
1159
|
-
id: "workqueue.registered.column.title"
|
1160
|
-
}
|
1161
|
-
}
|
1162
|
-
],
|
1163
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1164
|
-
});
|
1165
|
-
|
1166
|
-
// ../commons/src/workqueues/index.ts
|
1167
|
-
var workqueues = {
|
1168
|
-
all: allWorkqueue,
|
1169
|
-
registered: registeredWorkqueue,
|
1170
|
-
inReview: inReviewWorkqueue
|
1171
|
-
};
|
1172
|
-
|
1173
1103
|
// ../commons/src/conditionals/validate.ts
|
1174
1104
|
var import_ajv = __toESM(require("ajv"));
|
1175
1105
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1176
1106
|
var import_date_fns = require("date-fns");
|
1177
1107
|
|
1178
1108
|
// ../commons/src/events/FieldTypeMapping.ts
|
1179
|
-
var
|
1109
|
+
var import_zod15 = require("zod");
|
1180
1110
|
function mapFieldTypeToZod(type, required) {
|
1181
1111
|
let schema;
|
1182
1112
|
switch (type) {
|
@@ -1200,8 +1130,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1200
1130
|
case FieldType.FACILITY:
|
1201
1131
|
case FieldType.OFFICE:
|
1202
1132
|
case FieldType.SIGNATURE:
|
1203
|
-
|
1204
|
-
schema = required ? RequiredTextValue : TextValue;
|
1133
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1205
1134
|
break;
|
1206
1135
|
case FieldType.NUMBER:
|
1207
1136
|
schema = NumberFieldValue;
|
@@ -1229,7 +1158,7 @@ function createValidationSchema(config) {
|
|
1229
1158
|
for (const field2 of config) {
|
1230
1159
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1231
1160
|
}
|
1232
|
-
return
|
1161
|
+
return import_zod15.z.object(shape);
|
1233
1162
|
}
|
1234
1163
|
function mapFieldTypeToMockValue(field2, i) {
|
1235
1164
|
switch (field2.type) {
|
@@ -1396,18 +1325,30 @@ var isDataFieldType = (field2) => {
|
|
1396
1325
|
|
1397
1326
|
// ../commons/src/conditionals/validate.ts
|
1398
1327
|
var ajv = new import_ajv.default({
|
1399
|
-
$data: true
|
1328
|
+
$data: true,
|
1329
|
+
allowUnionTypes: true
|
1400
1330
|
});
|
1401
1331
|
(0, import_ajv_formats.default)(ajv);
|
1402
1332
|
function validate(schema, data) {
|
1403
1333
|
return ajv.validate(schema, data);
|
1404
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
|
+
}
|
1405
1341
|
function getConditionalActionsForField(field2, values) {
|
1406
1342
|
if (!field2.conditionals) {
|
1407
1343
|
return [];
|
1408
1344
|
}
|
1409
1345
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1410
1346
|
}
|
1347
|
+
function areConditionsMet(conditions, values) {
|
1348
|
+
return conditions.every(
|
1349
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1350
|
+
);
|
1351
|
+
}
|
1411
1352
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1412
1353
|
const hasRule = (field2.conditionals ?? []).some(
|
1413
1354
|
(conditional) => conditional.type === conditionalType
|
@@ -1426,9 +1367,16 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1426
1367
|
function isFieldVisible(field2, form) {
|
1427
1368
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1428
1369
|
}
|
1370
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1371
|
+
const fieldValue = form[field2.id];
|
1372
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1373
|
+
}
|
1429
1374
|
function isFieldEnabled(field2, form) {
|
1430
1375
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1431
1376
|
}
|
1377
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1378
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1379
|
+
}
|
1432
1380
|
var errorMessages = {
|
1433
1381
|
hiddenField: {
|
1434
1382
|
id: "v2.error.hidden",
|
@@ -1456,12 +1404,14 @@ var errorMessages = {
|
|
1456
1404
|
id: "v2.error.invalid"
|
1457
1405
|
}
|
1458
1406
|
};
|
1459
|
-
|
1460
|
-
|
1461
|
-
message
|
1462
|
-
|
1463
|
-
}
|
1464
|
-
|
1407
|
+
function createIntlError(message) {
|
1408
|
+
return {
|
1409
|
+
message: {
|
1410
|
+
message
|
1411
|
+
}
|
1412
|
+
};
|
1413
|
+
}
|
1414
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1465
1415
|
switch (issue.code) {
|
1466
1416
|
case "invalid_string": {
|
1467
1417
|
if (_ctx.data === "") {
|
@@ -1499,45 +1449,10 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1499
1449
|
}
|
1500
1450
|
}
|
1501
1451
|
return createIntlError(errorMessages.invalidInput);
|
1502
|
-
}
|
1503
|
-
function
|
1452
|
+
}
|
1453
|
+
function runCustomFieldValidations({
|
1504
1454
|
field: field2,
|
1505
|
-
|
1506
|
-
}) {
|
1507
|
-
const conditionalParameters = {
|
1508
|
-
$form: values,
|
1509
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1510
|
-
};
|
1511
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1512
|
-
if (values[field2.id]) {
|
1513
|
-
return {
|
1514
|
-
errors: [
|
1515
|
-
{
|
1516
|
-
message: errorMessages.hiddenField
|
1517
|
-
}
|
1518
|
-
]
|
1519
|
-
};
|
1520
|
-
}
|
1521
|
-
return {
|
1522
|
-
errors: []
|
1523
|
-
};
|
1524
|
-
}
|
1525
|
-
const fieldValidationResult = validateFieldInput({
|
1526
|
-
field: field2,
|
1527
|
-
value: values[field2.id]
|
1528
|
-
});
|
1529
|
-
const customValidationResults = runCustomFieldValidations({
|
1530
|
-
field: field2,
|
1531
|
-
conditionalParameters
|
1532
|
-
});
|
1533
|
-
return {
|
1534
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1535
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1536
|
-
};
|
1537
|
-
}
|
1538
|
-
function runCustomFieldValidations({
|
1539
|
-
field: field2,
|
1540
|
-
conditionalParameters
|
1455
|
+
conditionalParameters
|
1541
1456
|
}) {
|
1542
1457
|
return (field2.validation ?? []).filter((validation) => {
|
1543
1458
|
return !validate(validation.validator, conditionalParameters);
|
@@ -1556,13 +1471,31 @@ function validateFieldInput({
|
|
1556
1471
|
);
|
1557
1472
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1558
1473
|
}
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1474
|
+
function runFieldValidations({
|
1475
|
+
field: field2,
|
1476
|
+
values
|
1477
|
+
}) {
|
1478
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1479
|
+
return {
|
1480
|
+
errors: []
|
1481
|
+
};
|
1564
1482
|
}
|
1565
|
-
|
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
|
+
};
|
1566
1499
|
}
|
1567
1500
|
|
1568
1501
|
// ../commons/src/uuid.ts
|
@@ -1571,145 +1504,91 @@ function getUUID() {
|
|
1571
1504
|
return (0, import_uuid.v4)();
|
1572
1505
|
}
|
1573
1506
|
|
1507
|
+
// ../commons/src/utils.ts
|
1508
|
+
function getOrThrow(x, message) {
|
1509
|
+
if (x === void 0 || x === null) {
|
1510
|
+
throw new Error(message);
|
1511
|
+
}
|
1512
|
+
return x;
|
1513
|
+
}
|
1514
|
+
|
1574
1515
|
// ../commons/src/events/utils.ts
|
1575
|
-
function
|
1576
|
-
return
|
1577
|
-
}
|
1578
|
-
var findInputPageFields = (config) => {
|
1579
|
-
return (0, import_lodash.flattenDeep)(
|
1580
|
-
config.actions.map(
|
1581
|
-
({ forms }) => forms.map(
|
1582
|
-
({ pages }) => pages.map(
|
1583
|
-
({ fields }) => fields.map(({ id, label }) => ({ id, label }))
|
1584
|
-
)
|
1585
|
-
)
|
1586
|
-
)
|
1587
|
-
);
|
1588
|
-
};
|
1589
|
-
var findPageFields = (config) => {
|
1590
|
-
return (0, import_lodash.flattenDeep)(
|
1591
|
-
config.actions.map((action) => {
|
1592
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1593
|
-
return [
|
1594
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1595
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1596
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1597
|
-
];
|
1598
|
-
}
|
1599
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1600
|
-
})
|
1601
|
-
);
|
1602
|
-
};
|
1603
|
-
var resolveLabelsFromKnownFields = ({
|
1604
|
-
pageFields,
|
1605
|
-
refFields
|
1606
|
-
}) => {
|
1607
|
-
return refFields.map((field2) => {
|
1608
|
-
if (field2.label) {
|
1609
|
-
return field2;
|
1610
|
-
}
|
1611
|
-
if (isMetadataField(field2.id)) {
|
1612
|
-
return {
|
1613
|
-
...field2,
|
1614
|
-
label: eventMetadataLabelMap[field2.id]
|
1615
|
-
};
|
1616
|
-
}
|
1617
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1618
|
-
if (!pageLabel) {
|
1619
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1620
|
-
}
|
1621
|
-
return {
|
1622
|
-
...field2,
|
1623
|
-
label: pageLabel.label
|
1624
|
-
};
|
1625
|
-
});
|
1626
|
-
};
|
1627
|
-
function getAllFields(configuration) {
|
1628
|
-
return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
|
1629
|
-
...form.review.fields,
|
1630
|
-
...form.pages.flatMap((page) => page.fields)
|
1631
|
-
]);
|
1516
|
+
function isDeclarationActionConfig(action) {
|
1517
|
+
return DeclarationActions.safeParse(action.type).success;
|
1632
1518
|
}
|
1633
|
-
function
|
1634
|
-
return configuration.
|
1519
|
+
function getDeclarationFields(configuration) {
|
1520
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1635
1521
|
}
|
1636
|
-
function
|
1637
|
-
|
1638
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1639
|
-
(wq) => wq.id === workqueue.id
|
1640
|
-
);
|
1641
|
-
if (!rootWorkqueue) {
|
1642
|
-
throw new Error(
|
1643
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1644
|
-
);
|
1645
|
-
}
|
1646
|
-
});
|
1522
|
+
function getDeclarationPages(configuration) {
|
1523
|
+
return configuration.declaration.pages;
|
1647
1524
|
}
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
}
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1525
|
+
function getDeclaration(configuration) {
|
1526
|
+
return configuration.declaration;
|
1527
|
+
}
|
1528
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1529
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1530
|
+
return [
|
1531
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1532
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1533
|
+
];
|
1534
|
+
}
|
1535
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1536
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1537
|
+
}
|
1538
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1539
|
+
return actionConfig.review.fields;
|
1540
|
+
}
|
1541
|
+
return [];
|
1662
1542
|
};
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
const
|
1668
|
-
|
1543
|
+
function getAllAnnotationFields(config) {
|
1544
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1545
|
+
}
|
1546
|
+
var findRecordActionPages = (config, actionType) => {
|
1547
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1548
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1549
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1550
|
+
}
|
1551
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1552
|
+
return action.printForm.pages;
|
1553
|
+
}
|
1554
|
+
return [];
|
1669
1555
|
};
|
1670
|
-
|
1556
|
+
function getActionReview(configuration, actionType) {
|
1557
|
+
const [actionConfig] = configuration.actions.filter(
|
1558
|
+
(a) => a.type === actionType
|
1559
|
+
);
|
1671
1560
|
return getOrThrow(
|
1672
|
-
|
1673
|
-
|
1561
|
+
actionConfig.review,
|
1562
|
+
`No review config found for ${actionType}`
|
1674
1563
|
);
|
1675
|
-
};
|
1676
|
-
function getActiveActionFields(configuration, action) {
|
1677
|
-
if (LatentActions.some((latentAction) => latentAction === action)) {
|
1678
|
-
return getActiveActionFields(configuration, ActionType.DECLARE);
|
1679
|
-
}
|
1680
|
-
const fields = findActiveActionFields(configuration, action);
|
1681
|
-
if (!fields) {
|
1682
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1683
|
-
}
|
1684
|
-
return fields;
|
1685
1564
|
}
|
1686
|
-
function
|
1687
|
-
|
1688
|
-
if (!config) {
|
1689
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1690
|
-
}
|
1691
|
-
return config;
|
1565
|
+
function getActionReviewFields(configuration, actionType) {
|
1566
|
+
return getActionReview(configuration, actionType).fields;
|
1692
1567
|
}
|
1693
|
-
function
|
1694
|
-
if (
|
1695
|
-
return
|
1568
|
+
function isPageVisible(page, formValues) {
|
1569
|
+
if (!page.conditional) {
|
1570
|
+
return true;
|
1696
1571
|
}
|
1697
|
-
return
|
1572
|
+
return isConditionMet(page.conditional, formValues);
|
1698
1573
|
}
|
1699
|
-
function
|
1700
|
-
return (0, import_lodash.omitBy)(
|
1701
|
-
|
1702
|
-
|
1703
|
-
return true;
|
1574
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1575
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1576
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1577
|
+
return false;
|
1704
1578
|
}
|
1705
|
-
|
1579
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1580
|
+
if (!fieldConfigs.length) {
|
1706
1581
|
return true;
|
1707
1582
|
}
|
1708
|
-
return !isFieldVisible(
|
1583
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1709
1584
|
});
|
1710
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
|
+
}
|
1711
1590
|
function findActiveDrafts(event2, drafts) {
|
1712
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1591
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1713
1592
|
const lastAction = actions[actions.length - 1];
|
1714
1593
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1715
1594
|
}
|
@@ -1721,35 +1600,103 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1721
1600
|
transactionId: getUUID(),
|
1722
1601
|
action: {
|
1723
1602
|
type: actionType,
|
1724
|
-
|
1725
|
-
|
1603
|
+
declaration: {},
|
1604
|
+
annotation: {},
|
1726
1605
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1727
1606
|
createdBy: "@todo",
|
1728
1607
|
createdAtLocation: "@todo"
|
1729
1608
|
}
|
1730
1609
|
};
|
1731
1610
|
}
|
1732
|
-
function
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1611
|
+
function isVerificationPage(page) {
|
1612
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
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
|
+
);
|
1736
1632
|
}
|
1737
|
-
return
|
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
|
+
);
|
1738
1646
|
}
|
1647
|
+
function deepMerge(currentDocument, actionDocument) {
|
1648
|
+
return (0, import_lodash.mergeWith)(
|
1649
|
+
currentDocument,
|
1650
|
+
actionDocument,
|
1651
|
+
(previousValue, incomingValue) => {
|
1652
|
+
if (incomingValue === void 0) {
|
1653
|
+
return previousValue;
|
1654
|
+
}
|
1655
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1656
|
+
return incomingValue;
|
1657
|
+
}
|
1658
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1659
|
+
return void 0;
|
1660
|
+
}
|
1661
|
+
return incomingValue;
|
1662
|
+
}
|
1663
|
+
);
|
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
|
+
};
|
1739
1679
|
|
1740
1680
|
// ../commons/src/events/EventConfig.ts
|
1741
|
-
var
|
1742
|
-
|
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(
|
1743
1685
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1744
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
|
+
),
|
1745
1692
|
summary: SummaryConfig,
|
1746
1693
|
label: TranslationConfig,
|
1747
|
-
actions:
|
1748
|
-
|
1749
|
-
deduplication:
|
1750
|
-
advancedSearch:
|
1694
|
+
actions: import_zod16.z.array(ActionConfig),
|
1695
|
+
declaration: DeclarationFormConfig,
|
1696
|
+
deduplication: import_zod16.z.array(DeduplicationConfig).optional().default([]),
|
1697
|
+
advancedSearch: import_zod16.z.array(AdvancedSearchConfig).optional().default([])
|
1751
1698
|
}).superRefine((event2, ctx) => {
|
1752
|
-
const allFields =
|
1699
|
+
const allFields = findAllFields(event2);
|
1753
1700
|
const fieldIds = allFields.map((field2) => field2.id);
|
1754
1701
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1755
1702
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1763,287 +1710,497 @@ var EventConfig = import_zod18.z.object({
|
|
1763
1710
|
});
|
1764
1711
|
}
|
1765
1712
|
const invalidFields = event2.advancedSearch.flatMap(
|
1766
|
-
(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
|
+
)
|
1767
1720
|
);
|
1768
1721
|
if (invalidFields.length > 0) {
|
1769
1722
|
ctx.addIssue({
|
1770
1723
|
code: "custom",
|
1771
|
-
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.
|
1772
1725
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1773
1726
|
path: ["advancedSearch"]
|
1774
1727
|
});
|
1775
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"
|
1776
1750
|
});
|
1777
1751
|
|
1778
1752
|
// ../commons/src/events/EventConfigInput.ts
|
1779
|
-
var
|
1753
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1754
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1755
|
+
var definePage = (page) => PageConfig.parse(page);
|
1780
1756
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1781
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
|
+
|
1782
1781
|
// ../commons/src/events/Draft.ts
|
1783
|
-
var
|
1782
|
+
var import_zod20 = require("zod");
|
1784
1783
|
|
1785
1784
|
// ../commons/src/events/ActionDocument.ts
|
1786
|
-
var
|
1787
|
-
var
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
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);
|
1789
|
+
var ActionStatus = {
|
1790
|
+
Requested: "Requested",
|
1791
|
+
Accepted: "Accepted",
|
1792
|
+
Rejected: "Rejected"
|
1793
|
+
};
|
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(),
|
1800
|
+
declaration: ActionUpdate,
|
1801
|
+
annotation: ActionUpdate.optional(),
|
1802
|
+
createdAtLocation: import_zod18.z.string().optional(),
|
1803
|
+
updatedAtLocation: import_zod18.z.string().optional(),
|
1804
|
+
status: import_zod18.z.enum([
|
1805
|
+
ActionStatus.Requested,
|
1806
|
+
ActionStatus.Accepted,
|
1807
|
+
ActionStatus.Rejected
|
1808
|
+
]),
|
1809
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1810
|
+
originalActionId: import_zod18.z.string().optional()
|
1795
1811
|
});
|
1796
1812
|
var AssignedAction = ActionBase.merge(
|
1797
|
-
|
1798
|
-
type:
|
1799
|
-
assignedTo:
|
1813
|
+
import_zod18.z.object({
|
1814
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1815
|
+
assignedTo: import_zod18.z.string()
|
1800
1816
|
})
|
1801
1817
|
);
|
1802
1818
|
var UnassignedAction = ActionBase.merge(
|
1803
|
-
|
1804
|
-
type:
|
1819
|
+
import_zod18.z.object({
|
1820
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1821
|
+
assignedTo: import_zod18.z.literal(null)
|
1805
1822
|
})
|
1806
1823
|
);
|
1807
1824
|
var RegisterAction = ActionBase.merge(
|
1808
|
-
|
1809
|
-
type:
|
1810
|
-
|
1811
|
-
trackingId: import_zod19.z.string(),
|
1812
|
-
registrationNumber: import_zod19.z.string()
|
1813
|
-
})
|
1825
|
+
import_zod18.z.object({
|
1826
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1827
|
+
registrationNumber: import_zod18.z.string().optional()
|
1814
1828
|
})
|
1815
1829
|
);
|
1816
1830
|
var DeclareAction = ActionBase.merge(
|
1817
|
-
|
1818
|
-
type:
|
1831
|
+
import_zod18.z.object({
|
1832
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1819
1833
|
})
|
1820
1834
|
);
|
1821
1835
|
var ValidateAction = ActionBase.merge(
|
1822
|
-
|
1823
|
-
type:
|
1836
|
+
import_zod18.z.object({
|
1837
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1824
1838
|
})
|
1825
1839
|
);
|
1826
1840
|
var RejectAction = ActionBase.merge(
|
1827
|
-
|
1828
|
-
type:
|
1841
|
+
import_zod18.z.object({
|
1842
|
+
type: import_zod18.z.literal(ActionType.REJECT)
|
1829
1843
|
})
|
1830
1844
|
);
|
1831
1845
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1832
|
-
|
1833
|
-
type:
|
1846
|
+
import_zod18.z.object({
|
1847
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1834
1848
|
})
|
1835
1849
|
);
|
1836
1850
|
var ArchiveAction = ActionBase.merge(
|
1837
|
-
|
1838
|
-
type:
|
1851
|
+
import_zod18.z.object({
|
1852
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE)
|
1839
1853
|
})
|
1840
1854
|
);
|
1841
1855
|
var CreatedAction = ActionBase.merge(
|
1842
|
-
|
1843
|
-
type:
|
1856
|
+
import_zod18.z.object({
|
1857
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1844
1858
|
})
|
1845
1859
|
);
|
1846
1860
|
var NotifiedAction = ActionBase.merge(
|
1847
|
-
|
1848
|
-
type:
|
1861
|
+
import_zod18.z.object({
|
1862
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1849
1863
|
})
|
1850
1864
|
);
|
1851
1865
|
var PrintCertificateAction = ActionBase.merge(
|
1852
|
-
|
1853
|
-
type:
|
1866
|
+
import_zod18.z.object({
|
1867
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1854
1868
|
})
|
1855
1869
|
);
|
1856
1870
|
var RequestedCorrectionAction = ActionBase.merge(
|
1857
|
-
|
1858
|
-
type:
|
1871
|
+
import_zod18.z.object({
|
1872
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1859
1873
|
})
|
1860
1874
|
);
|
1861
1875
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1862
|
-
|
1863
|
-
type:
|
1864
|
-
requestId:
|
1876
|
+
import_zod18.z.object({
|
1877
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1878
|
+
requestId: import_zod18.z.string()
|
1865
1879
|
})
|
1866
1880
|
);
|
1867
1881
|
var RejectedCorrectionAction = ActionBase.merge(
|
1868
|
-
|
1869
|
-
type:
|
1870
|
-
requestId:
|
1882
|
+
import_zod18.z.object({
|
1883
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1884
|
+
requestId: import_zod18.z.string()
|
1871
1885
|
})
|
1872
1886
|
);
|
1873
|
-
var
|
1874
|
-
|
1875
|
-
type:
|
1887
|
+
var ReadAction = ActionBase.merge(
|
1888
|
+
import_zod18.z.object({
|
1889
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1876
1890
|
})
|
1877
1891
|
);
|
1878
|
-
var ActionDocument =
|
1879
|
-
CreatedAction,
|
1880
|
-
ValidateAction,
|
1881
|
-
RejectAction,
|
1882
|
-
MarkAsDuplicateAction,
|
1883
|
-
ArchiveAction,
|
1884
|
-
NotifiedAction,
|
1885
|
-
RegisterAction,
|
1886
|
-
DeclareAction,
|
1887
|
-
AssignedAction,
|
1888
|
-
RequestedCorrectionAction,
|
1889
|
-
ApprovedCorrectionAction,
|
1890
|
-
RejectedCorrectionAction,
|
1891
|
-
UnassignedAction,
|
1892
|
-
PrintCertificateAction,
|
1893
|
-
|
1894
|
-
])
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
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
|
+
});
|
1911
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1912
|
+
declaration: true,
|
1913
|
+
annotation: true,
|
1914
|
+
createdBy: true,
|
1915
|
+
createdByRole: true,
|
1916
|
+
createdAtLocation: true
|
1917
|
+
}).merge(
|
1918
|
+
import_zod18.z.object({
|
1919
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1920
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1921
|
+
})
|
1922
|
+
);
|
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()
|
1903
1932
|
})
|
1904
1933
|
)
|
1905
1934
|
});
|
1906
1935
|
|
1907
1936
|
// ../commons/src/events/ActionInput.ts
|
1908
|
-
var
|
1909
|
-
var
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
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({}),
|
1944
|
+
annotation: ActionUpdate.optional(),
|
1945
|
+
originalActionId: import_zod19.z.string().optional(),
|
1946
|
+
keepAssignment: import_zod19.z.boolean().optional()
|
1914
1947
|
});
|
1915
1948
|
var CreateActionInput = BaseActionInput.merge(
|
1916
|
-
|
1917
|
-
type:
|
1918
|
-
createdAtLocation:
|
1949
|
+
import_zod19.z.object({
|
1950
|
+
type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1951
|
+
createdAtLocation: import_zod19.z.string()
|
1919
1952
|
})
|
1920
1953
|
);
|
1921
1954
|
var RegisterActionInput = BaseActionInput.merge(
|
1922
|
-
|
1923
|
-
type:
|
1924
|
-
|
1925
|
-
trackingId: import_zod20.z.string(),
|
1926
|
-
registrationNumber: import_zod20.z.string()
|
1927
|
-
})
|
1955
|
+
import_zod19.z.object({
|
1956
|
+
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1957
|
+
registrationNumber: import_zod19.z.string().optional()
|
1928
1958
|
})
|
1929
1959
|
);
|
1930
1960
|
var ValidateActionInput = BaseActionInput.merge(
|
1931
|
-
|
1932
|
-
type:
|
1933
|
-
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())
|
1934
1964
|
})
|
1935
1965
|
);
|
1936
1966
|
var NotifyActionInput = BaseActionInput.merge(
|
1937
|
-
|
1938
|
-
type:
|
1967
|
+
import_zod19.z.object({
|
1968
|
+
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1939
1969
|
})
|
1940
1970
|
);
|
1941
1971
|
var DeclareActionInput = BaseActionInput.merge(
|
1942
|
-
|
1943
|
-
type:
|
1972
|
+
import_zod19.z.object({
|
1973
|
+
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1944
1974
|
})
|
1945
1975
|
);
|
1946
1976
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1947
|
-
|
1948
|
-
type:
|
1977
|
+
import_zod19.z.object({
|
1978
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1949
1979
|
})
|
1950
1980
|
);
|
1951
1981
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1952
|
-
|
1953
|
-
type:
|
1982
|
+
import_zod19.z.object({
|
1983
|
+
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1954
1984
|
})
|
1955
1985
|
);
|
1956
1986
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1957
|
-
|
1958
|
-
type:
|
1987
|
+
import_zod19.z.object({
|
1988
|
+
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1959
1989
|
})
|
1960
1990
|
);
|
1961
1991
|
var ArchiveActionInput = BaseActionInput.merge(
|
1962
|
-
|
1963
|
-
type:
|
1992
|
+
import_zod19.z.object({
|
1993
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1964
1994
|
})
|
1965
1995
|
);
|
1966
1996
|
var AssignActionInput = BaseActionInput.merge(
|
1967
|
-
|
1968
|
-
type:
|
1969
|
-
assignedTo:
|
1997
|
+
import_zod19.z.object({
|
1998
|
+
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1999
|
+
assignedTo: import_zod19.z.string()
|
1970
2000
|
})
|
1971
2001
|
);
|
1972
2002
|
var UnassignActionInput = BaseActionInput.merge(
|
1973
|
-
|
1974
|
-
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)
|
1975
2006
|
})
|
1976
2007
|
);
|
1977
2008
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1978
|
-
|
1979
|
-
type:
|
2009
|
+
import_zod19.z.object({
|
2010
|
+
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1980
2011
|
})
|
1981
2012
|
);
|
1982
2013
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1983
|
-
|
1984
|
-
requestId:
|
1985
|
-
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)
|
1986
2017
|
})
|
1987
2018
|
);
|
1988
2019
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1989
|
-
|
1990
|
-
requestId:
|
1991
|
-
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)
|
1992
2023
|
})
|
1993
2024
|
);
|
1994
|
-
var
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2025
|
+
var ReadActionInput = BaseActionInput.merge(
|
2026
|
+
import_zod19.z.object({
|
2027
|
+
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
2028
|
+
})
|
2029
|
+
);
|
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
|
+
});
|
2010
2058
|
|
2011
2059
|
// ../commons/src/events/Draft.ts
|
2012
|
-
var Draft =
|
2013
|
-
id:
|
2014
|
-
eventId:
|
2015
|
-
transactionId:
|
2016
|
-
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(),
|
2017
2065
|
action: ActionBase.extend({
|
2018
|
-
type:
|
2066
|
+
type: ActionTypes
|
2019
2067
|
}).omit({ id: true })
|
2020
2068
|
});
|
2021
2069
|
var DraftInput = BaseActionInput.extend({
|
2022
|
-
type:
|
2070
|
+
type: ActionTypes
|
2071
|
+
});
|
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()
|
2023
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
|
+
};
|
2024
2176
|
|
2025
2177
|
// ../commons/src/events/EventInput.ts
|
2026
2178
|
var import_zod22 = require("zod");
|
2027
2179
|
var EventInput = import_zod22.z.object({
|
2028
2180
|
transactionId: import_zod22.z.string(),
|
2029
|
-
type: import_zod22.z.string()
|
2181
|
+
type: import_zod22.z.string(),
|
2182
|
+
dateOfEvent: import_zod22.z.object({ fieldId: import_zod22.z.string() }).optional()
|
2030
2183
|
});
|
2031
2184
|
|
2032
2185
|
// ../commons/src/events/EventDocument.ts
|
2033
2186
|
var import_zod23 = require("zod");
|
2187
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2188
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod23.z);
|
2034
2189
|
var EventDocument = import_zod23.z.object({
|
2035
2190
|
id: import_zod23.z.string(),
|
2036
2191
|
type: import_zod23.z.string(),
|
2192
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional(),
|
2037
2193
|
createdAt: import_zod23.z.string().datetime(),
|
2038
2194
|
updatedAt: import_zod23.z.string().datetime(),
|
2039
|
-
|
2195
|
+
updatedAtLocation: import_zod23.z.string(),
|
2196
|
+
actions: import_zod23.z.array(Action),
|
2040
2197
|
trackingId: import_zod23.z.string()
|
2041
|
-
});
|
2198
|
+
}).openapi({ ref: "EventDocument" });
|
2042
2199
|
|
2043
2200
|
// ../commons/src/events/EventIndex.ts
|
2044
2201
|
var import_zod24 = require("zod");
|
2045
2202
|
var EventIndex = EventMetadata.extend({
|
2046
|
-
|
2203
|
+
declaration: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
|
2047
2204
|
});
|
2048
2205
|
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
2049
2206
|
import_zod24.z.object({
|
@@ -2051,35 +2208,94 @@ var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod
|
|
2051
2208
|
// Ensures "type" (event-id) exists and is a string
|
2052
2209
|
})
|
2053
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]);
|
2054
2248
|
|
2055
2249
|
// ../commons/src/events/state/index.ts
|
2056
|
-
var _ = __toESM(require("lodash"));
|
2057
2250
|
function getStatusFromActions(actions) {
|
2251
|
+
const hasRejectedAction = actions.some(
|
2252
|
+
(a) => a.status === ActionStatus.Rejected
|
2253
|
+
);
|
2254
|
+
if (hasRejectedAction) {
|
2255
|
+
return EventStatus.REJECTED;
|
2256
|
+
}
|
2058
2257
|
return actions.reduce((status, action) => {
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
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;
|
2079
2284
|
}
|
2080
|
-
return status;
|
2081
2285
|
}, EventStatus.CREATED);
|
2082
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
|
+
}
|
2083
2299
|
function getAssignedUserFromActions(actions) {
|
2084
2300
|
return actions.reduce((user2, action) => {
|
2085
2301
|
if (action.type === ActionType.ASSIGN) {
|
@@ -2091,7 +2307,7 @@ function getAssignedUserFromActions(actions) {
|
|
2091
2307
|
return user2;
|
2092
2308
|
}, null);
|
2093
2309
|
}
|
2094
|
-
function
|
2310
|
+
function aggregateActionDeclarations(actions) {
|
2095
2311
|
const excludedActions = [
|
2096
2312
|
ActionType.REQUEST_CORRECTION,
|
2097
2313
|
ActionType.PRINT_CERTIFICATE
|
@@ -2105,47 +2321,35 @@ function getData(actions) {
|
|
2105
2321
|
if (!requestAction) {
|
2106
2322
|
return status;
|
2107
2323
|
}
|
2108
|
-
return deepMerge(status, requestAction.
|
2324
|
+
return deepMerge(status, requestAction.declaration);
|
2109
2325
|
}
|
2110
|
-
return deepMerge(status, action.
|
2326
|
+
return deepMerge(status, action.declaration);
|
2111
2327
|
}, {});
|
2112
2328
|
}
|
2113
2329
|
function deepDropNulls(obj) {
|
2114
|
-
if (
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
[key]
|
2123
|
-
};
|
2124
|
-
}
|
2125
|
-
return acc;
|
2126
|
-
}, {});
|
2127
|
-
}
|
2128
|
-
function deepMerge(currentDocument, actionDocument) {
|
2129
|
-
return _.mergeWith(
|
2130
|
-
currentDocument,
|
2131
|
-
actionDocument,
|
2132
|
-
(previousValue, incomingValue) => {
|
2133
|
-
if (incomingValue === void 0) {
|
2134
|
-
return previousValue;
|
2135
|
-
}
|
2136
|
-
if (_.isArray(incomingValue)) {
|
2137
|
-
return incomingValue;
|
2138
|
-
}
|
2139
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2140
|
-
return void 0;
|
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;
|
2141
2339
|
}
|
2142
|
-
return
|
2143
|
-
}
|
2144
|
-
|
2340
|
+
return acc;
|
2341
|
+
}, {});
|
2342
|
+
}
|
2343
|
+
return obj;
|
2145
2344
|
}
|
2146
2345
|
function isUndeclaredDraft(status) {
|
2147
2346
|
return status === EventStatus.CREATED;
|
2148
2347
|
}
|
2348
|
+
function getAcceptedActions(event2) {
|
2349
|
+
return event2.actions.filter(
|
2350
|
+
(a) => a.status === ActionStatus.Accepted
|
2351
|
+
);
|
2352
|
+
}
|
2149
2353
|
function getCurrentEventState(event2) {
|
2150
2354
|
const creationAction = event2.actions.find(
|
2151
2355
|
(action) => action.type === ActionType.CREATE
|
@@ -2153,19 +2357,35 @@ function getCurrentEventState(event2) {
|
|
2153
2357
|
if (!creationAction) {
|
2154
2358
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2155
2359
|
}
|
2156
|
-
const
|
2360
|
+
const activeActions = getAcceptedActions(event2);
|
2361
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2362
|
+
const registrationAction = activeActions.find(
|
2363
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2364
|
+
);
|
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
|
+
}
|
2157
2372
|
return deepDropNulls({
|
2158
2373
|
id: event2.id,
|
2159
2374
|
type: event2.type,
|
2160
2375
|
status: getStatusFromActions(event2.actions),
|
2161
2376
|
createdAt: event2.createdAt,
|
2162
2377
|
createdBy: creationAction.createdBy,
|
2163
|
-
createdAtLocation: creationAction.createdAtLocation,
|
2164
|
-
|
2165
|
-
|
2378
|
+
createdAtLocation: creationAction.createdAtLocation ?? "",
|
2379
|
+
// @todo remove using empty string
|
2380
|
+
updatedAt: latestAction.createdAt,
|
2381
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2166
2382
|
updatedBy: latestAction.createdBy,
|
2167
|
-
|
2168
|
-
|
2383
|
+
updatedAtLocation: event2.updatedAtLocation,
|
2384
|
+
declaration,
|
2385
|
+
trackingId: event2.trackingId,
|
2386
|
+
registrationNumber,
|
2387
|
+
updatedByUserRole: getLastUpdatedByUserRoleFromActions(event2.actions),
|
2388
|
+
dateOfEvent
|
2169
2389
|
});
|
2170
2390
|
}
|
2171
2391
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2190,45 +2410,50 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
|
|
2190
2410
|
return getCurrentEventState(withDrafts);
|
2191
2411
|
}
|
2192
2412
|
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2193
|
-
const indexedAt = eventIndex.
|
2413
|
+
const indexedAt = eventIndex.updatedAt;
|
2194
2414
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2195
2415
|
if (activeDrafts.length === 0) {
|
2196
2416
|
return eventIndex;
|
2197
2417
|
}
|
2198
2418
|
return {
|
2199
2419
|
...eventIndex,
|
2200
|
-
|
2201
|
-
...eventIndex.
|
2202
|
-
...activeDrafts[activeDrafts.length - 1].
|
2420
|
+
declaration: {
|
2421
|
+
...eventIndex.declaration,
|
2422
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2203
2423
|
}
|
2204
2424
|
};
|
2205
2425
|
}
|
2206
|
-
function
|
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
|
+
}
|
2433
|
+
function getActionAnnotation({
|
2207
2434
|
event: event2,
|
2208
2435
|
actionType,
|
2209
|
-
drafts
|
2436
|
+
drafts = []
|
2210
2437
|
}) {
|
2211
|
-
const
|
2438
|
+
const activeActions = getAcceptedActions(event2);
|
2439
|
+
const action = activeActions.find(
|
2440
|
+
(activeAction) => actionType === activeAction.type
|
2441
|
+
);
|
2212
2442
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2213
2443
|
const sorted = [
|
2214
2444
|
...action ? [action] : [],
|
2215
2445
|
...eventDrafts.map((draft) => draft.action)
|
2216
2446
|
].sort();
|
2217
|
-
const
|
2218
|
-
return deepMerge(
|
2447
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2448
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2219
2449
|
}, {});
|
2220
|
-
return deepDropNulls(
|
2450
|
+
return deepDropNulls(annotation);
|
2221
2451
|
}
|
2222
2452
|
|
2223
2453
|
// ../commons/src/events/defineConfig.ts
|
2224
2454
|
var defineConfig = (config) => {
|
2225
|
-
validateWorkqueueConfig(config.workqueues);
|
2226
2455
|
const input = EventConfig.parse(config);
|
2227
|
-
|
2228
|
-
return EventConfig.parse({
|
2229
|
-
...input,
|
2230
|
-
pageFields
|
2231
|
-
});
|
2456
|
+
return input;
|
2232
2457
|
};
|
2233
2458
|
|
2234
2459
|
// ../commons/src/events/transactions.ts
|
@@ -2243,6 +2468,16 @@ var import_lodash2 = require("lodash");
|
|
2243
2468
|
function defineConditional(schema) {
|
2244
2469
|
return schema;
|
2245
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
|
+
}
|
2246
2481
|
function alwaysTrue() {
|
2247
2482
|
return {};
|
2248
2483
|
}
|
@@ -2267,6 +2502,9 @@ function not(condition) {
|
|
2267
2502
|
required: []
|
2268
2503
|
});
|
2269
2504
|
}
|
2505
|
+
function never() {
|
2506
|
+
return not(alwaysTrue());
|
2507
|
+
}
|
2270
2508
|
var user = {
|
2271
2509
|
hasScope: (scope) => defineConditional({
|
2272
2510
|
type: "object",
|
@@ -2288,205 +2526,316 @@ var user = {
|
|
2288
2526
|
required: ["$user"]
|
2289
2527
|
})
|
2290
2528
|
};
|
2291
|
-
|
2292
|
-
|
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 {
|
2293
2566
|
type: "object",
|
2294
2567
|
properties: {
|
2295
|
-
|
2296
|
-
type: "
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
type: "object",
|
2302
|
-
properties: {
|
2303
|
-
type: {
|
2304
|
-
const: action
|
2305
|
-
}
|
2306
|
-
},
|
2307
|
-
required: ["type"]
|
2308
|
-
}
|
2309
|
-
}
|
2310
|
-
},
|
2311
|
-
required: ["actions"]
|
2312
|
-
}
|
2568
|
+
[fieldId]: {
|
2569
|
+
type: "string",
|
2570
|
+
format: "date",
|
2571
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2572
|
+
},
|
2573
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2313
2574
|
},
|
2314
|
-
required: [
|
2315
|
-
}
|
2316
|
-
}
|
2317
|
-
function
|
2318
|
-
|
2575
|
+
required: [fieldId]
|
2576
|
+
};
|
2577
|
+
}
|
2578
|
+
function isFieldReference(value) {
|
2579
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2580
|
+
}
|
2581
|
+
function createFieldConditionals(fieldId) {
|
2319
2582
|
const getDateRange = (date, clause) => ({
|
2320
2583
|
type: "object",
|
2321
2584
|
properties: {
|
2322
|
-
|
2323
|
-
type: "
|
2324
|
-
|
2325
|
-
|
2326
|
-
type: "string",
|
2327
|
-
format: "date",
|
2328
|
-
[clause]: date
|
2329
|
-
}
|
2330
|
-
},
|
2331
|
-
required: [fieldId]
|
2585
|
+
[fieldId]: {
|
2586
|
+
type: "string",
|
2587
|
+
format: "date",
|
2588
|
+
[clause]: date
|
2332
2589
|
}
|
2333
2590
|
},
|
2334
|
-
required: [
|
2591
|
+
required: [fieldId]
|
2335
2592
|
});
|
2336
2593
|
return {
|
2337
2594
|
isAfter: () => ({
|
2338
2595
|
days: (days) => ({
|
2339
|
-
inPast: () =>
|
2596
|
+
inPast: () => defineFormConditional(
|
2340
2597
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2341
2598
|
),
|
2342
|
-
inFuture: () =>
|
2599
|
+
inFuture: () => defineFormConditional(
|
2343
2600
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2344
2601
|
)
|
2345
2602
|
}),
|
2346
|
-
date: (date) =>
|
2347
|
-
|
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"))
|
2348
2617
|
}),
|
2349
2618
|
isBefore: () => ({
|
2350
2619
|
days: (days) => ({
|
2351
|
-
inPast: () =>
|
2620
|
+
inPast: () => defineFormConditional(
|
2352
2621
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2353
2622
|
),
|
2354
|
-
inFuture: () =>
|
2623
|
+
inFuture: () => defineFormConditional(
|
2355
2624
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2356
2625
|
)
|
2357
2626
|
}),
|
2358
|
-
date: (date) =>
|
2359
|
-
|
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"))
|
2641
|
+
}),
|
2642
|
+
isEqualTo: (value) => {
|
2643
|
+
if (isFieldReference(value)) {
|
2644
|
+
const comparedFieldId = value._fieldId;
|
2645
|
+
return defineFormConditional({
|
2646
|
+
type: "object",
|
2647
|
+
properties: {
|
2648
|
+
[fieldId]: {
|
2649
|
+
type: ["string", "boolean"],
|
2650
|
+
const: { $data: `1/${comparedFieldId}` }
|
2651
|
+
},
|
2652
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2653
|
+
},
|
2654
|
+
required: [fieldId, comparedFieldId]
|
2655
|
+
});
|
2656
|
+
}
|
2657
|
+
return defineFormConditional({
|
2658
|
+
type: "object",
|
2659
|
+
properties: {
|
2660
|
+
[fieldId]: {
|
2661
|
+
oneOf: [
|
2662
|
+
{ type: "string", const: value },
|
2663
|
+
{ type: "boolean", const: value }
|
2664
|
+
],
|
2665
|
+
const: value
|
2666
|
+
}
|
2667
|
+
},
|
2668
|
+
required: [fieldId]
|
2669
|
+
});
|
2670
|
+
},
|
2671
|
+
/**
|
2672
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2673
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
2674
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
2675
|
+
*
|
2676
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2677
|
+
*
|
2678
|
+
*/
|
2679
|
+
isFalsy: () => defineFormConditional({
|
2680
|
+
type: "object",
|
2681
|
+
properties: {
|
2682
|
+
[fieldId]: {
|
2683
|
+
anyOf: [
|
2684
|
+
{ const: "undefined" },
|
2685
|
+
{ const: false },
|
2686
|
+
{ const: null },
|
2687
|
+
{ const: "" }
|
2688
|
+
]
|
2689
|
+
}
|
2690
|
+
},
|
2691
|
+
anyOf: [
|
2692
|
+
{
|
2693
|
+
required: [fieldId]
|
2694
|
+
},
|
2695
|
+
{
|
2696
|
+
not: {
|
2697
|
+
required: [fieldId]
|
2698
|
+
}
|
2699
|
+
}
|
2700
|
+
]
|
2360
2701
|
}),
|
2361
|
-
|
2702
|
+
isUndefined: () => defineFormConditional({
|
2362
2703
|
type: "object",
|
2363
2704
|
properties: {
|
2364
|
-
|
2365
|
-
type: "
|
2366
|
-
|
2367
|
-
[fieldId]: {
|
2368
|
-
oneOf: [
|
2369
|
-
{ type: "string", const: value },
|
2370
|
-
{ type: "boolean", const: value }
|
2371
|
-
],
|
2372
|
-
const: value
|
2373
|
-
}
|
2374
|
-
},
|
2375
|
-
required: [fieldId]
|
2705
|
+
[fieldId]: {
|
2706
|
+
type: "string",
|
2707
|
+
enum: ["undefined"]
|
2376
2708
|
}
|
2377
2709
|
},
|
2378
|
-
|
2710
|
+
not: {
|
2711
|
+
required: [fieldId]
|
2712
|
+
}
|
2379
2713
|
}),
|
2380
|
-
|
2381
|
-
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2382
|
-
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
2383
|
-
* @returns whether the field is falsy (undefined, false, null, empty string)
|
2384
|
-
*
|
2385
|
-
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2386
|
-
*
|
2387
|
-
*/
|
2388
|
-
isFalsy: () => defineConditional({
|
2714
|
+
inArray: (values) => defineFormConditional({
|
2389
2715
|
type: "object",
|
2390
2716
|
properties: {
|
2391
|
-
|
2392
|
-
type: "
|
2393
|
-
|
2394
|
-
[fieldId]: {
|
2395
|
-
anyOf: [
|
2396
|
-
{ const: "undefined" },
|
2397
|
-
{ const: false },
|
2398
|
-
{ const: null },
|
2399
|
-
{ const: "" }
|
2400
|
-
]
|
2401
|
-
}
|
2402
|
-
},
|
2403
|
-
anyOf: [
|
2404
|
-
{
|
2405
|
-
required: [fieldId]
|
2406
|
-
},
|
2407
|
-
{
|
2408
|
-
not: {
|
2409
|
-
required: [fieldId]
|
2410
|
-
}
|
2411
|
-
}
|
2412
|
-
]
|
2717
|
+
[fieldId]: {
|
2718
|
+
type: "string",
|
2719
|
+
enum: values
|
2413
2720
|
}
|
2414
2721
|
},
|
2415
|
-
required: [
|
2722
|
+
required: [fieldId]
|
2416
2723
|
}),
|
2417
|
-
|
2724
|
+
isValidEnglishName: () => defineFormConditional({
|
2418
2725
|
type: "object",
|
2419
2726
|
properties: {
|
2420
|
-
|
2421
|
-
type: "
|
2422
|
-
|
2423
|
-
|
2424
|
-
type: "string",
|
2425
|
-
enum: ["undefined"]
|
2426
|
-
}
|
2427
|
-
},
|
2428
|
-
not: {
|
2429
|
-
required: [fieldId]
|
2430
|
-
}
|
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."
|
2431
2731
|
}
|
2432
2732
|
},
|
2433
|
-
required: [
|
2733
|
+
required: [fieldId]
|
2434
2734
|
}),
|
2435
|
-
|
2735
|
+
/**
|
2736
|
+
* Checks if the field value matches a given regular expression pattern.
|
2737
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2738
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2739
|
+
*/
|
2740
|
+
matches: (pattern) => defineFormConditional({
|
2436
2741
|
type: "object",
|
2437
2742
|
properties: {
|
2438
|
-
|
2439
|
-
type: "
|
2440
|
-
|
2441
|
-
[fieldId]: {
|
2442
|
-
type: "string",
|
2443
|
-
enum: values
|
2444
|
-
}
|
2445
|
-
},
|
2446
|
-
required: [fieldId]
|
2743
|
+
[fieldId]: {
|
2744
|
+
type: "string",
|
2745
|
+
pattern
|
2447
2746
|
}
|
2448
2747
|
},
|
2449
|
-
required: [
|
2748
|
+
required: [fieldId]
|
2450
2749
|
}),
|
2451
|
-
|
2750
|
+
isBetween: (min, max) => defineFormConditional({
|
2452
2751
|
type: "object",
|
2453
2752
|
properties: {
|
2454
|
-
|
2455
|
-
type: "
|
2456
|
-
|
2457
|
-
|
2458
|
-
type: "string",
|
2459
|
-
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'._-]*)*$",
|
2460
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2461
|
-
}
|
2462
|
-
},
|
2463
|
-
required: [fieldId]
|
2753
|
+
[fieldId]: {
|
2754
|
+
type: "number",
|
2755
|
+
minimum: min,
|
2756
|
+
maximum: max
|
2464
2757
|
}
|
2465
2758
|
},
|
2466
|
-
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" }
|
2467
2812
|
})
|
2468
2813
|
};
|
2469
2814
|
}
|
2470
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
|
+
|
2471
2828
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2472
|
-
var PRINT_CERTIFICATE_FORM =
|
2829
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2473
2830
|
label: {
|
2474
2831
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2475
2832
|
defaultMessage: "Tennis club membership certificate collector",
|
2476
2833
|
description: "This is what this form is referred as in the system"
|
2477
2834
|
},
|
2478
|
-
version: {
|
2479
|
-
id: "1.0.0",
|
2480
|
-
label: {
|
2481
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2482
|
-
defaultMessage: "Version 1",
|
2483
|
-
description: "This is the first version of the form"
|
2484
|
-
}
|
2485
|
-
},
|
2486
|
-
active: true,
|
2487
2835
|
pages: [
|
2488
2836
|
{
|
2489
2837
|
id: "collector",
|
2838
|
+
type: PageTypes.enum.FORM,
|
2490
2839
|
title: {
|
2491
2840
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2492
2841
|
defaultMessage: "Print certified copy",
|
@@ -2501,7 +2850,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2501
2850
|
defaultMessage: "Requester",
|
2502
2851
|
description: "This is the label for the field"
|
2503
2852
|
},
|
2504
|
-
type:
|
2853
|
+
type: FieldType.SELECT,
|
2505
2854
|
options: [
|
2506
2855
|
{
|
2507
2856
|
value: "INFORMANT",
|
@@ -2578,7 +2927,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2578
2927
|
defaultMessage: "Select Type of ID",
|
2579
2928
|
description: "This is the label for selecting the type of ID"
|
2580
2929
|
},
|
2581
|
-
type:
|
2930
|
+
type: FieldType.SELECT,
|
2582
2931
|
options: [
|
2583
2932
|
{
|
2584
2933
|
value: "PASSPORT",
|
@@ -2679,7 +3028,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2679
3028
|
defaultMessage: "Passport Details",
|
2680
3029
|
description: "Field for entering Passport details"
|
2681
3030
|
},
|
2682
|
-
type:
|
3031
|
+
type: FieldType.TEXT
|
2683
3032
|
},
|
2684
3033
|
{
|
2685
3034
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2730,7 +3079,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2730
3079
|
defaultMessage: "Driving License Details",
|
2731
3080
|
description: "Field for entering Driving License details"
|
2732
3081
|
},
|
2733
|
-
type:
|
3082
|
+
type: FieldType.TEXT
|
2734
3083
|
},
|
2735
3084
|
{
|
2736
3085
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2781,7 +3130,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2781
3130
|
defaultMessage: "Refugee Number Details",
|
2782
3131
|
description: "Field for entering Refugee Number details"
|
2783
3132
|
},
|
2784
|
-
type:
|
3133
|
+
type: FieldType.TEXT
|
2785
3134
|
},
|
2786
3135
|
{
|
2787
3136
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2832,7 +3181,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2832
3181
|
defaultMessage: "Alien Number Details",
|
2833
3182
|
description: "Field for entering Alien Number details"
|
2834
3183
|
},
|
2835
|
-
type:
|
3184
|
+
type: FieldType.TEXT
|
2836
3185
|
},
|
2837
3186
|
{
|
2838
3187
|
id: "collector.OTHER.idTypeOther",
|
@@ -2883,7 +3232,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2883
3232
|
defaultMessage: "Other ID Type (if applicable)",
|
2884
3233
|
description: 'Field for entering ID type if "Other" is selected'
|
2885
3234
|
},
|
2886
|
-
type:
|
3235
|
+
type: FieldType.TEXT
|
2887
3236
|
},
|
2888
3237
|
{
|
2889
3238
|
id: "collector.OTHER.firstName",
|
@@ -2934,7 +3283,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2934
3283
|
defaultMessage: "First Name",
|
2935
3284
|
description: "This is the label for the first name field"
|
2936
3285
|
},
|
2937
|
-
type:
|
3286
|
+
type: FieldType.TEXT
|
2938
3287
|
},
|
2939
3288
|
{
|
2940
3289
|
id: "collector.OTHER.lastName",
|
@@ -2985,7 +3334,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2985
3334
|
defaultMessage: "Last Name",
|
2986
3335
|
description: "This is the label for the last name field"
|
2987
3336
|
},
|
2988
|
-
type:
|
3337
|
+
type: FieldType.TEXT
|
2989
3338
|
},
|
2990
3339
|
{
|
2991
3340
|
id: "collector.OTHER.relationshipToMember",
|
@@ -3036,7 +3385,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3036
3385
|
defaultMessage: "Relationship to Member",
|
3037
3386
|
description: "This is the label for the relationship to member field"
|
3038
3387
|
},
|
3039
|
-
type:
|
3388
|
+
type: FieldType.TEXT
|
3040
3389
|
},
|
3041
3390
|
{
|
3042
3391
|
id: "collector.OTHER.signedAffidavit",
|
@@ -3087,13 +3436,14 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3087
3436
|
defaultMessage: "Signed Affidavit (Optional)",
|
3088
3437
|
description: "This is the label for uploading a signed affidavit"
|
3089
3438
|
},
|
3090
|
-
type:
|
3439
|
+
type: FieldType.FILE
|
3091
3440
|
}
|
3092
3441
|
]
|
3093
3442
|
},
|
3094
3443
|
{
|
3095
3444
|
id: "collector.identity.verify",
|
3096
|
-
type:
|
3445
|
+
type: PageTypes.enum.VERIFICATION,
|
3446
|
+
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3097
3447
|
title: {
|
3098
3448
|
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
3099
3449
|
defaultMessage: "Verify their identity",
|
@@ -3129,62 +3479,45 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3129
3479
|
}
|
3130
3480
|
}
|
3131
3481
|
}
|
3132
|
-
]
|
3133
|
-
review: {
|
3134
|
-
title: {
|
3135
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
3136
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
3137
|
-
description: "Title of the form to show in review page"
|
3138
|
-
},
|
3139
|
-
fields: []
|
3140
|
-
}
|
3482
|
+
]
|
3141
3483
|
});
|
3142
|
-
var
|
3143
|
-
|
3144
|
-
id: "v2.event.tennis-club-membership.action.declare.form.
|
3145
|
-
defaultMessage: "
|
3146
|
-
description: "
|
3147
|
-
},
|
3148
|
-
active: true,
|
3149
|
-
version: {
|
3150
|
-
id: "1.0.0",
|
3151
|
-
label: {
|
3152
|
-
id: "v2.event.tennis-club-membership.action.declare.form.version.1",
|
3153
|
-
defaultMessage: "Version 1",
|
3154
|
-
description: "This is the first version of the form"
|
3155
|
-
}
|
3484
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3485
|
+
title: {
|
3486
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3487
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3488
|
+
description: "Title of the review page"
|
3156
3489
|
},
|
3157
|
-
|
3158
|
-
|
3159
|
-
id: "
|
3160
|
-
|
3161
|
-
|
3490
|
+
fields: [
|
3491
|
+
{
|
3492
|
+
id: "review.comment",
|
3493
|
+
type: FieldType.TEXTAREA,
|
3494
|
+
label: {
|
3495
|
+
defaultMessage: "Comment",
|
3496
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3497
|
+
description: "Label for the comment field in the review section"
|
3498
|
+
}
|
3162
3499
|
},
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
description: "Label for the comment field in the review section"
|
3171
|
-
}
|
3500
|
+
{
|
3501
|
+
type: FieldType.SIGNATURE,
|
3502
|
+
id: "review.signature",
|
3503
|
+
label: {
|
3504
|
+
defaultMessage: "Signature of informant",
|
3505
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3506
|
+
description: "Label for the signature field in the review section"
|
3172
3507
|
},
|
3173
|
-
{
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
defaultMessage: "Signature of informant",
|
3178
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3179
|
-
description: "Label for the signature field in the review section"
|
3180
|
-
},
|
3181
|
-
signaturePromptLabel: {
|
3182
|
-
id: "v2.signature.upload.modal.title",
|
3183
|
-
defaultMessage: "Draw signature",
|
3184
|
-
description: "Title for the modal to draw signature"
|
3185
|
-
}
|
3508
|
+
signaturePromptLabel: {
|
3509
|
+
id: "v2.signature.upload.modal.title",
|
3510
|
+
defaultMessage: "Draw signature",
|
3511
|
+
description: "Title for the modal to draw signature"
|
3186
3512
|
}
|
3187
|
-
|
3513
|
+
}
|
3514
|
+
]
|
3515
|
+
};
|
3516
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3517
|
+
label: {
|
3518
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3519
|
+
defaultMessage: "Tennis club membership application",
|
3520
|
+
description: "This is what this form is referred as in the system"
|
3188
3521
|
},
|
3189
3522
|
pages: [
|
3190
3523
|
{
|
@@ -3197,7 +3530,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3197
3530
|
fields: [
|
3198
3531
|
{
|
3199
3532
|
id: "applicant.firstname",
|
3200
|
-
type:
|
3533
|
+
type: FieldType.TEXT,
|
3201
3534
|
required: true,
|
3202
3535
|
conditionals: [],
|
3203
3536
|
label: {
|
@@ -3208,7 +3541,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3208
3541
|
},
|
3209
3542
|
{
|
3210
3543
|
id: "applicant.surname",
|
3211
|
-
type:
|
3544
|
+
type: FieldType.TEXT,
|
3212
3545
|
required: true,
|
3213
3546
|
conditionals: [],
|
3214
3547
|
label: {
|
@@ -3230,9 +3563,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3230
3563
|
},
|
3231
3564
|
{
|
3232
3565
|
id: "applicant.dob",
|
3233
|
-
type:
|
3566
|
+
type: FieldType.DATE,
|
3234
3567
|
required: true,
|
3235
|
-
conditionals: [],
|
3236
3568
|
validation: [
|
3237
3569
|
{
|
3238
3570
|
message: {
|
@@ -3243,15 +3575,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3243
3575
|
validator: field("applicant.dob").isBefore().now()
|
3244
3576
|
}
|
3245
3577
|
],
|
3578
|
+
conditionals: [
|
3579
|
+
{
|
3580
|
+
type: ConditionalType.SHOW,
|
3581
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3582
|
+
}
|
3583
|
+
],
|
3246
3584
|
label: {
|
3247
3585
|
defaultMessage: "Applicant's date of birth",
|
3248
3586
|
description: "This is the label for the field",
|
3249
3587
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3250
3588
|
}
|
3251
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
|
+
},
|
3252
3622
|
{
|
3253
3623
|
id: "applicant.image",
|
3254
|
-
type:
|
3624
|
+
type: FieldType.FILE,
|
3255
3625
|
required: false,
|
3256
3626
|
label: {
|
3257
3627
|
defaultMessage: "Applicant's profile picture",
|
@@ -3272,6 +3642,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3272
3642
|
}
|
3273
3643
|
]
|
3274
3644
|
},
|
3645
|
+
{
|
3646
|
+
id: "senior-pass",
|
3647
|
+
conditional: field("applicant.dob").isBefore().date("1950-01-01"),
|
3648
|
+
title: {
|
3649
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
|
3650
|
+
defaultMessage: "Assign senior pass for applicant",
|
3651
|
+
description: "This is the title of the section"
|
3652
|
+
},
|
3653
|
+
fields: [
|
3654
|
+
{
|
3655
|
+
id: "senior-pass.id",
|
3656
|
+
type: FieldType.TEXT,
|
3657
|
+
required: true,
|
3658
|
+
label: {
|
3659
|
+
defaultMessage: "Senior pass ID",
|
3660
|
+
description: "This is the label for the field",
|
3661
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
|
3662
|
+
}
|
3663
|
+
}
|
3664
|
+
]
|
3665
|
+
},
|
3275
3666
|
{
|
3276
3667
|
id: "recommender",
|
3277
3668
|
title: {
|
@@ -3293,7 +3684,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3293
3684
|
},
|
3294
3685
|
{
|
3295
3686
|
id: "recommender.firstname",
|
3296
|
-
type:
|
3687
|
+
type: FieldType.TEXT,
|
3297
3688
|
required: true,
|
3298
3689
|
conditionals: [
|
3299
3690
|
{
|
@@ -3309,7 +3700,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3309
3700
|
},
|
3310
3701
|
{
|
3311
3702
|
id: "recommender.surname",
|
3312
|
-
type:
|
3703
|
+
type: FieldType.TEXT,
|
3313
3704
|
required: true,
|
3314
3705
|
conditionals: [
|
3315
3706
|
{
|
@@ -3325,7 +3716,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3325
3716
|
},
|
3326
3717
|
{
|
3327
3718
|
id: "recommender.id",
|
3328
|
-
type:
|
3719
|
+
type: FieldType.TEXT,
|
3329
3720
|
required: true,
|
3330
3721
|
conditionals: [
|
3331
3722
|
{
|
@@ -3350,20 +3741,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3350
3741
|
description: "This is what this event is referred as in the system",
|
3351
3742
|
id: "event.tennis-club-membership.label"
|
3352
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
|
+
},
|
3353
3749
|
summary: {
|
3354
|
-
title: {
|
3355
|
-
id: "event.tennis-club-membership.summary.title",
|
3356
|
-
label: {
|
3357
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3358
|
-
description: "This is the title of the summary",
|
3359
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3360
|
-
},
|
3361
|
-
emptyValueMessage: {
|
3362
|
-
defaultMessage: "Membership application",
|
3363
|
-
description: "This is the message shown when the applicant name is missing",
|
3364
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3365
|
-
}
|
3366
|
-
},
|
3367
3750
|
fields: [
|
3368
3751
|
{
|
3369
3752
|
id: "applicant.firstname",
|
@@ -3403,28 +3786,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3403
3786
|
}
|
3404
3787
|
]
|
3405
3788
|
},
|
3406
|
-
workqueues: [
|
3407
|
-
{
|
3408
|
-
id: "all",
|
3409
|
-
filters: []
|
3410
|
-
},
|
3411
|
-
{
|
3412
|
-
id: "ready-for-review",
|
3413
|
-
filters: [
|
3414
|
-
{
|
3415
|
-
status: ["DECLARED"]
|
3416
|
-
}
|
3417
|
-
]
|
3418
|
-
},
|
3419
|
-
{
|
3420
|
-
id: "registered",
|
3421
|
-
filters: [
|
3422
|
-
{
|
3423
|
-
status: ["REGISTERED"]
|
3424
|
-
}
|
3425
|
-
]
|
3426
|
-
}
|
3427
|
-
],
|
3428
3789
|
actions: [
|
3429
3790
|
{
|
3430
3791
|
type: ActionType.DECLARE,
|
@@ -3433,7 +3794,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3433
3794
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3434
3795
|
id: "event.tennis-club-membership.action.declare.label"
|
3435
3796
|
},
|
3436
|
-
|
3797
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3437
3798
|
},
|
3438
3799
|
{
|
3439
3800
|
type: ActionType.VALIDATE,
|
@@ -3442,7 +3803,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3442
3803
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3443
3804
|
id: "event.tennis-club-membership.action.validate.label"
|
3444
3805
|
},
|
3445
|
-
|
3806
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3446
3807
|
},
|
3447
3808
|
{
|
3448
3809
|
type: ActionType.REGISTER,
|
@@ -3451,7 +3812,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3451
3812
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3452
3813
|
id: "event.tennis-club-membership.action.register.label"
|
3453
3814
|
},
|
3454
|
-
|
3815
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3455
3816
|
},
|
3456
3817
|
{
|
3457
3818
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3460,10 +3821,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3460
3821
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3461
3822
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3462
3823
|
},
|
3463
|
-
forms: [TENNIS_CLUB_FORM],
|
3464
3824
|
onboardingForm: [
|
3465
3825
|
{
|
3466
3826
|
id: "correction-requester",
|
3827
|
+
type: PageTypes.enum.FORM,
|
3467
3828
|
title: {
|
3468
3829
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3469
3830
|
defaultMessage: "Correction requester",
|
@@ -3527,6 +3888,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3527
3888
|
},
|
3528
3889
|
{
|
3529
3890
|
id: "identity-check",
|
3891
|
+
type: PageTypes.enum.FORM,
|
3530
3892
|
title: {
|
3531
3893
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3532
3894
|
defaultMessage: "Verify their identity",
|
@@ -3569,6 +3931,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3569
3931
|
additionalDetailsForm: [
|
3570
3932
|
{
|
3571
3933
|
id: "correction-request.supporting-documents",
|
3934
|
+
type: PageTypes.enum.FORM,
|
3572
3935
|
title: {
|
3573
3936
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3574
3937
|
defaultMessage: "Upload supporting documents",
|
@@ -3586,7 +3949,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3586
3949
|
},
|
3587
3950
|
{
|
3588
3951
|
id: "correction.supportingDocs",
|
3589
|
-
type:
|
3952
|
+
type: FieldType.FILE,
|
3590
3953
|
label: {
|
3591
3954
|
id: "correction.corrector.title",
|
3592
3955
|
defaultMessage: "Upload supporting documents",
|
@@ -3630,6 +3993,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3630
3993
|
},
|
3631
3994
|
{
|
3632
3995
|
id: "correction-request.additional-details",
|
3996
|
+
type: PageTypes.enum.FORM,
|
3633
3997
|
title: {
|
3634
3998
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3635
3999
|
defaultMessage: "Reason for correction",
|
@@ -3638,7 +4002,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3638
4002
|
fields: [
|
3639
4003
|
{
|
3640
4004
|
id: "correction.request.reason",
|
3641
|
-
type:
|
4005
|
+
type: FieldType.TEXT,
|
3642
4006
|
label: {
|
3643
4007
|
id: "correction.reason.title",
|
3644
4008
|
defaultMessage: "Reason for correction?",
|
@@ -3651,7 +4015,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3651
4015
|
},
|
3652
4016
|
{
|
3653
4017
|
type: ActionType.APPROVE_CORRECTION,
|
3654
|
-
forms: [TENNIS_CLUB_FORM],
|
3655
4018
|
label: {
|
3656
4019
|
defaultMessage: "Approve correction",
|
3657
4020
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3665,7 +4028,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3665
4028
|
defaultMessage: "Print certificate",
|
3666
4029
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3667
4030
|
},
|
3668
|
-
|
4031
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3669
4032
|
conditionals: [
|
3670
4033
|
{
|
3671
4034
|
type: "SHOW",
|
@@ -3712,8 +4075,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3712
4075
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3713
4076
|
defaultMessage: "Archive",
|
3714
4077
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3715
|
-
}
|
3716
|
-
forms: [TENNIS_CLUB_FORM]
|
4078
|
+
}
|
3717
4079
|
},
|
3718
4080
|
{
|
3719
4081
|
type: ActionType.REJECT,
|
@@ -3721,8 +4083,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3721
4083
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3722
4084
|
defaultMessage: "Reject",
|
3723
4085
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3724
|
-
}
|
3725
|
-
forms: [TENNIS_CLUB_FORM]
|
4086
|
+
}
|
3726
4087
|
}
|
3727
4088
|
],
|
3728
4089
|
advancedSearch: [
|
@@ -3732,39 +4093,55 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3732
4093
|
description: "This is what this event is referred as in the system",
|
3733
4094
|
id: "v2.event.tennis-club-membership.search"
|
3734
4095
|
},
|
3735
|
-
fields: [
|
3736
|
-
{
|
3737
|
-
fieldId: "applicant.dob"
|
3738
|
-
}
|
3739
|
-
]
|
4096
|
+
fields: [field("applicant.dob").exact()]
|
3740
4097
|
}
|
3741
|
-
]
|
4098
|
+
],
|
4099
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3742
4100
|
});
|
3743
4101
|
|
3744
4102
|
// ../commons/src/events/test.utils.ts
|
3745
|
-
function
|
3746
|
-
|
3747
|
-
const data = fields.reduce(
|
4103
|
+
function fieldConfigsToActionPayload(fields) {
|
4104
|
+
return fields.reduce(
|
3748
4105
|
(acc, field2, i) => ({
|
3749
4106
|
...acc,
|
3750
4107
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3751
4108
|
}),
|
3752
4109
|
{}
|
3753
4110
|
);
|
3754
|
-
return stripHiddenFields(fields, data);
|
3755
4111
|
}
|
3756
|
-
function
|
3757
|
-
const
|
3758
|
-
|
3759
|
-
|
4112
|
+
function generateActionDeclarationInput(configuration, action) {
|
4113
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
4114
|
+
if (parsed.success) {
|
4115
|
+
const fields = getDeclarationFields(configuration);
|
4116
|
+
const declarationConfig = getDeclaration(configuration);
|
4117
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4118
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
4119
|
+
}
|
4120
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
4121
|
+
return {};
|
4122
|
+
}
|
4123
|
+
function generateActionAnnotationInput(configuration, action) {
|
4124
|
+
const actionConfig = configuration.actions.find(
|
4125
|
+
(ac) => ac.type === action
|
4126
|
+
);
|
4127
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4128
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4129
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4130
|
+
findRecordActionPages(configuration, action),
|
4131
|
+
annotation
|
3760
4132
|
);
|
3761
|
-
|
4133
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3762
4134
|
(acc, pageId) => ({
|
3763
4135
|
...acc,
|
3764
4136
|
[pageId]: true
|
3765
4137
|
}),
|
3766
4138
|
{}
|
3767
4139
|
);
|
4140
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4141
|
+
return {
|
4142
|
+
...fieldBasedPayload,
|
4143
|
+
...visiblePageVerificationMap
|
4144
|
+
};
|
3768
4145
|
}
|
3769
4146
|
var eventPayloadGenerator = {
|
3770
4147
|
create: (input = {}) => ({
|
@@ -3776,27 +4153,31 @@ var eventPayloadGenerator = {
|
|
3776
4153
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3777
4154
|
id
|
3778
4155
|
}),
|
3779
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4156
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3780
4157
|
{
|
3781
4158
|
id: getUUID(),
|
3782
4159
|
eventId,
|
3783
4160
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3784
4161
|
transactionId: getUUID(),
|
3785
4162
|
action: {
|
3786
|
-
|
3787
|
-
|
4163
|
+
transactionId: getUUID(),
|
4164
|
+
type: actionType,
|
4165
|
+
status: ActionStatus.Accepted,
|
4166
|
+
declaration: {
|
3788
4167
|
"applicant.firstname": "Max",
|
3789
4168
|
"applicant.surname": "McLaren",
|
3790
4169
|
"applicant.dob": "2020-01-02",
|
3791
4170
|
"recommender.none": true
|
3792
4171
|
},
|
3793
|
-
|
4172
|
+
annotation: {
|
3794
4173
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3795
4174
|
"correction.request.reason": "Child's name was incorrect"
|
3796
4175
|
},
|
3797
4176
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3798
4177
|
createdBy: "@todo",
|
3799
|
-
|
4178
|
+
createdByRole: "@todo",
|
4179
|
+
createdAtLocation: "@todo",
|
4180
|
+
updatedAtLocation: "@todo"
|
3800
4181
|
}
|
3801
4182
|
},
|
3802
4183
|
input
|
@@ -3805,45 +4186,104 @@ var eventPayloadGenerator = {
|
|
3805
4186
|
declare: (eventId, input = {}) => ({
|
3806
4187
|
type: ActionType.DECLARE,
|
3807
4188
|
transactionId: input.transactionId ?? getUUID(),
|
3808
|
-
|
4189
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4190
|
+
tennisClubMembershipEvent,
|
4191
|
+
ActionType.DECLARE
|
4192
|
+
),
|
4193
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4194
|
+
tennisClubMembershipEvent,
|
4195
|
+
ActionType.DECLARE
|
4196
|
+
),
|
3809
4197
|
eventId
|
3810
4198
|
}),
|
4199
|
+
/**
|
4200
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4201
|
+
*/
|
4202
|
+
notify: (eventId, input = {}) => {
|
4203
|
+
let declaration = input.declaration;
|
4204
|
+
if (!declaration) {
|
4205
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4206
|
+
generateActionDeclarationInput(
|
4207
|
+
tennisClubMembershipEvent,
|
4208
|
+
ActionType.DECLARE
|
4209
|
+
),
|
4210
|
+
import_lodash2.isString
|
4211
|
+
);
|
4212
|
+
declaration = partialDeclaration;
|
4213
|
+
}
|
4214
|
+
return {
|
4215
|
+
type: ActionType.NOTIFY,
|
4216
|
+
transactionId: input.transactionId ?? getUUID(),
|
4217
|
+
declaration,
|
4218
|
+
eventId
|
4219
|
+
};
|
4220
|
+
},
|
3811
4221
|
validate: (eventId, input = {}) => ({
|
3812
4222
|
type: ActionType.VALIDATE,
|
3813
4223
|
transactionId: input.transactionId ?? getUUID(),
|
3814
|
-
|
4224
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4225
|
+
tennisClubMembershipEvent,
|
4226
|
+
ActionType.VALIDATE
|
4227
|
+
),
|
4228
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4229
|
+
tennisClubMembershipEvent,
|
4230
|
+
ActionType.VALIDATE
|
4231
|
+
),
|
3815
4232
|
duplicates: [],
|
3816
4233
|
eventId
|
3817
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
|
+
}),
|
3818
4249
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3819
4250
|
type: ActionType.ARCHIVE,
|
3820
4251
|
transactionId: input.transactionId ?? getUUID(),
|
3821
|
-
|
3822
|
-
|
4252
|
+
declaration: {},
|
4253
|
+
// @TODO: Check whether generator is needed?
|
4254
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3823
4255
|
duplicates: [],
|
3824
4256
|
eventId
|
3825
4257
|
}),
|
3826
4258
|
reject: (eventId, input = {}) => ({
|
3827
4259
|
type: ActionType.REJECT,
|
3828
4260
|
transactionId: input.transactionId ?? getUUID(),
|
3829
|
-
|
4261
|
+
declaration: {},
|
4262
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4263
|
+
tennisClubMembershipEvent,
|
4264
|
+
ActionType.REJECT
|
4265
|
+
),
|
3830
4266
|
duplicates: [],
|
3831
4267
|
eventId
|
3832
4268
|
}),
|
3833
4269
|
register: (eventId, input = {}) => ({
|
3834
4270
|
type: ActionType.REGISTER,
|
3835
4271
|
transactionId: input.transactionId ?? getUUID(),
|
3836
|
-
|
4272
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4273
|
+
tennisClubMembershipEvent,
|
4274
|
+
ActionType.REGISTER
|
4275
|
+
),
|
4276
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4277
|
+
tennisClubMembershipEvent,
|
4278
|
+
ActionType.REGISTER
|
4279
|
+
),
|
3837
4280
|
eventId
|
3838
4281
|
}),
|
3839
4282
|
printCertificate: (eventId, input = {}) => ({
|
3840
4283
|
type: ActionType.PRINT_CERTIFICATE,
|
3841
4284
|
transactionId: input.transactionId ?? getUUID(),
|
3842
|
-
|
3843
|
-
|
3844
|
-
ActionType.PRINT_CERTIFICATE
|
3845
|
-
),
|
3846
|
-
metadata: input.metadata ?? generateActionMetadataInput(
|
4285
|
+
declaration: {},
|
4286
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3847
4287
|
tennisClubMembershipEvent,
|
3848
4288
|
ActionType.PRINT_CERTIFICATE
|
3849
4289
|
),
|
@@ -3853,17 +4293,21 @@ var eventPayloadGenerator = {
|
|
3853
4293
|
request: (eventId, input = {}) => ({
|
3854
4294
|
type: ActionType.REQUEST_CORRECTION,
|
3855
4295
|
transactionId: input.transactionId ?? getUUID(),
|
3856
|
-
|
4296
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4297
|
+
tennisClubMembershipEvent,
|
4298
|
+
ActionType.REQUEST_CORRECTION
|
4299
|
+
),
|
4300
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3857
4301
|
tennisClubMembershipEvent,
|
3858
4302
|
ActionType.REQUEST_CORRECTION
|
3859
4303
|
),
|
3860
|
-
metadata: {},
|
3861
4304
|
eventId
|
3862
4305
|
}),
|
3863
4306
|
approve: (eventId, requestId, input = {}) => ({
|
3864
4307
|
type: ActionType.APPROVE_CORRECTION,
|
3865
4308
|
transactionId: input.transactionId ?? getUUID(),
|
3866
|
-
|
4309
|
+
declaration: {},
|
4310
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3867
4311
|
tennisClubMembershipEvent,
|
3868
4312
|
ActionType.APPROVE_CORRECTION
|
3869
4313
|
),
|
@@ -3873,7 +4317,8 @@ var eventPayloadGenerator = {
|
|
3873
4317
|
reject: (eventId, requestId, input = {}) => ({
|
3874
4318
|
type: ActionType.REJECT_CORRECTION,
|
3875
4319
|
transactionId: input.transactionId ?? getUUID(),
|
3876
|
-
|
4320
|
+
declaration: {},
|
4321
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3877
4322
|
tennisClubMembershipEvent,
|
3878
4323
|
ActionType.REJECT_CORRECTION
|
3879
4324
|
),
|
@@ -3893,17 +4338,25 @@ function generateActionDocument({
|
|
3893
4338
|
// @TODO: This should be fixed in the future.
|
3894
4339
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
3895
4340
|
createdBy: getUUID(),
|
4341
|
+
createdByRole: "FIELD_AGENT",
|
3896
4342
|
id: getUUID(),
|
3897
4343
|
createdAtLocation: "TODO",
|
3898
|
-
|
3899
|
-
|
3900
|
-
|
4344
|
+
updatedAtLocation: "TODO",
|
4345
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4346
|
+
annotation: {},
|
4347
|
+
...defaults,
|
4348
|
+
status: ActionStatus.Accepted,
|
4349
|
+
transactionId: getUUID()
|
3901
4350
|
};
|
3902
4351
|
switch (action) {
|
4352
|
+
case ActionType.READ:
|
4353
|
+
return { ...actionBase, type: action };
|
4354
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4355
|
+
return { ...actionBase, type: action };
|
3903
4356
|
case ActionType.DECLARE:
|
3904
4357
|
return { ...actionBase, type: action };
|
3905
4358
|
case ActionType.UNASSIGN:
|
3906
|
-
return { ...actionBase, type: action };
|
4359
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3907
4360
|
case ActionType.ASSIGN:
|
3908
4361
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3909
4362
|
case ActionType.VALIDATE:
|
@@ -3924,14 +4377,13 @@ function generateActionDocument({
|
|
3924
4377
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3925
4378
|
case ActionType.REJECT_CORRECTION:
|
3926
4379
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3927
|
-
case ActionType.CUSTOM:
|
3928
|
-
return { ...actionBase, type: action };
|
3929
4380
|
case ActionType.REGISTER:
|
3930
4381
|
return {
|
3931
4382
|
...actionBase,
|
3932
|
-
type: action
|
3933
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4383
|
+
type: action
|
3934
4384
|
};
|
4385
|
+
case ActionType.DELETE:
|
4386
|
+
case ActionType.DETECT_DUPLICATE:
|
3935
4387
|
default:
|
3936
4388
|
throw new Error(`Unsupported action type: ${action}`);
|
3937
4389
|
}
|
@@ -3952,10 +4404,12 @@ function generateEventDocument({
|
|
3952
4404
|
id: getUUID(),
|
3953
4405
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3954
4406
|
// @TODO: This should be fixed in the future.
|
3955
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4407
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4408
|
+
dateOfEvent: configuration.dateOfEvent,
|
4409
|
+
updatedAtLocation: getUUID()
|
3956
4410
|
};
|
3957
4411
|
}
|
3958
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4412
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3959
4413
|
const action = generateActionDocument({
|
3960
4414
|
configuration: tennisClubMembershipEvent,
|
3961
4415
|
action: actionType
|
@@ -3965,9 +4419,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3965
4419
|
transactionId: getUUID(),
|
3966
4420
|
action: {
|
3967
4421
|
...action,
|
3968
|
-
|
3969
|
-
...action.
|
3970
|
-
...
|
4422
|
+
declaration: {
|
4423
|
+
...action.declaration,
|
4424
|
+
...declaration
|
3971
4425
|
}
|
3972
4426
|
},
|
3973
4427
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3981,10 +4435,12 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3981
4435
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3982
4436
|
createdBy: overrides.createdBy ?? getUUID(),
|
3983
4437
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
3984
|
-
|
4438
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4439
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3985
4440
|
assignedTo: overrides.assignedTo ?? null,
|
3986
4441
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3987
|
-
|
4442
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4443
|
+
declaration: overrides.declaration ?? {
|
3988
4444
|
"recommender.none": true,
|
3989
4445
|
"applicant.firstname": "Danny",
|
3990
4446
|
"applicant.surname": "Doe",
|
@@ -4015,7 +4471,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
4015
4471
|
return true;
|
4016
4472
|
}
|
4017
4473
|
function isFieldConfigDefaultValue(value) {
|
4018
|
-
if (!value)
|
4474
|
+
if (!value) {
|
4475
|
+
return false;
|
4476
|
+
}
|
4019
4477
|
if (isFieldValue(value)) {
|
4020
4478
|
return true;
|
4021
4479
|
}
|
@@ -4027,3 +4485,213 @@ function isFieldConfigDefaultValue(value) {
|
|
4027
4485
|
}
|
4028
4486
|
return false;
|
4029
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());
|