@opencrvs/toolkit 1.8.0-rc.fd6feaa → 1.8.0-rc.fea3888
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 +10466 -13734
- package/dist/commons/conditionals/conditionals.d.ts +31 -5
- package/dist/commons/conditionals/validate.d.ts +12 -17
- package/dist/commons/events/ActionConfig.d.ts +85746 -1981
- package/dist/commons/events/ActionDocument.d.ts +8433 -503
- package/dist/commons/events/ActionInput.d.ts +3229 -704
- package/dist/commons/events/ActionType.d.ts +26 -11
- package/dist/commons/events/AdvancedSearchConfig.d.ts +371 -25
- package/dist/commons/events/CompositeFieldValue.d.ts +55 -12
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +174 -72
- package/dist/commons/events/EventConfig.d.ts +40845 -1776
- package/dist/commons/events/EventConfigInput.d.ts +6 -3
- package/dist/commons/events/EventDocument.d.ts +1897 -619
- 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 +3911 -759
- package/dist/commons/events/FieldType.d.ts +2 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +57 -8
- package/dist/commons/events/FieldValue.d.ts +31 -11
- package/dist/commons/events/FormConfig.d.ts +38982 -69
- 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 +6749 -224
- 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 +84 -302
- package/dist/commons/events/utils.d.ts +3444 -118
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +196 -108
- package/dist/events/index.js +1984 -1136
- package/package.json +3 -2
package/dist/events/index.js
CHANGED
@@ -30,30 +30,50 @@ 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,
|
48
|
+
AddressType: () => AddressType,
|
43
49
|
AdministrativeAreas: () => AdministrativeAreas,
|
44
50
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
45
51
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
46
52
|
ArchiveActionInput: () => ArchiveActionInput,
|
53
|
+
AssignActionInput: () => AssignActionInput,
|
54
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
47
55
|
BaseActionInput: () => BaseActionInput,
|
56
|
+
CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
|
57
|
+
CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
|
48
58
|
CertificateConfig: () => CertificateConfig,
|
49
59
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
50
60
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
51
61
|
Clause: () => Clause,
|
52
62
|
Conditional: () => Conditional,
|
53
63
|
ConditionalType: () => ConditionalType,
|
64
|
+
ConfirmableActions: () => ConfirmableActions,
|
65
|
+
DataEntry: () => DataEntry,
|
66
|
+
DataFieldValue: () => DataFieldValue,
|
54
67
|
DateValue: () => DateValue,
|
68
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
69
|
+
DeclarationActions: () => DeclarationActions,
|
70
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
71
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
72
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
55
73
|
DeclareActionInput: () => DeclareActionInput,
|
56
74
|
DeduplicationConfig: () => DeduplicationConfig,
|
75
|
+
DeleteActionInput: () => DeleteActionInput,
|
76
|
+
DisplayOnReviewConditional: () => DisplayOnReviewConditional,
|
57
77
|
Draft: () => Draft,
|
58
78
|
DraftInput: () => DraftInput,
|
59
79
|
EmailField: () => EmailField,
|
@@ -61,13 +81,17 @@ __export(events_exports, {
|
|
61
81
|
EnableConditional: () => EnableConditional,
|
62
82
|
EventConfig: () => EventConfig,
|
63
83
|
EventDocument: () => EventDocument,
|
84
|
+
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
85
|
+
EventFieldId: () => EventFieldId,
|
64
86
|
EventIndex: () => EventIndex,
|
65
87
|
EventInput: () => EventInput,
|
66
88
|
EventMetadata: () => EventMetadata,
|
67
89
|
EventSearchIndex: () => EventSearchIndex,
|
68
90
|
EventStatus: () => EventStatus,
|
69
91
|
EventStatuses: () => EventStatuses,
|
92
|
+
FieldConditional: () => FieldConditional,
|
70
93
|
FieldConfig: () => FieldConfig,
|
94
|
+
FieldConfigSchema: () => FieldConfigSchema,
|
71
95
|
FieldType: () => FieldType,
|
72
96
|
FieldUpdateValue: () => FieldUpdateValue,
|
73
97
|
FieldValue: () => FieldValue,
|
@@ -75,42 +99,66 @@ __export(events_exports, {
|
|
75
99
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
76
100
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
77
101
|
FormConfig: () => FormConfig,
|
78
|
-
|
102
|
+
FormPageConfig: () => FormPageConfig,
|
79
103
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
80
104
|
GenericAddressValue: () => GenericAddressValue,
|
81
105
|
GeographicalArea: () => GeographicalArea,
|
106
|
+
ImageMimeType: () => ImageMimeType,
|
82
107
|
LanguageConfig: () => LanguageConfig,
|
83
108
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
109
|
+
MatchType: () => MatchType,
|
110
|
+
MimeType: () => MimeType,
|
111
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
84
112
|
NotifyActionInput: () => NotifyActionInput,
|
85
113
|
NumberFieldValue: () => NumberFieldValue,
|
114
|
+
PageConfig: () => PageConfig,
|
115
|
+
PageTypes: () => PageTypes,
|
86
116
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
117
|
+
QueryInput: () => QueryInput,
|
118
|
+
QueryType: () => QueryType,
|
119
|
+
ReadActionInput: () => ReadActionInput,
|
120
|
+
RegisterAction: () => RegisterAction,
|
87
121
|
RegisterActionInput: () => RegisterActionInput,
|
88
122
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
89
123
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
90
124
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
91
|
-
RequiredTextValue: () => RequiredTextValue,
|
92
125
|
ResolvedUser: () => ResolvedUser,
|
93
126
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
94
127
|
RuralAddressValue: () => RuralAddressValue,
|
128
|
+
SearchField: () => SearchField,
|
129
|
+
SelectOption: () => SelectOption,
|
95
130
|
ShowConditional: () => ShowConditional,
|
96
131
|
SummaryConfig: () => SummaryConfig,
|
97
132
|
TextValue: () => TextValue,
|
98
133
|
TranslationConfig: () => TranslationConfig,
|
134
|
+
UnassignActionInput: () => UnassignActionInput,
|
99
135
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
100
136
|
UrbanAddressValue: () => UrbanAddressValue,
|
101
137
|
ValidateActionInput: () => ValidateActionInput,
|
138
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
139
|
+
VerificationPageConfig: () => VerificationPageConfig,
|
102
140
|
WorkqueueConfig: () => WorkqueueConfig,
|
141
|
+
ZodDate: () => ZodDate,
|
103
142
|
alwaysTrue: () => alwaysTrue,
|
104
143
|
and: () => and,
|
144
|
+
annotationActions: () => annotationActions,
|
105
145
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
146
|
+
areConditionsMet: () => areConditionsMet,
|
106
147
|
compositeFieldTypes: () => compositeFieldTypes,
|
107
148
|
createEmptyDraft: () => createEmptyDraft,
|
149
|
+
createEventConditionals: () => createEventConditionals,
|
150
|
+
createFieldConditionals: () => createFieldConditionals,
|
108
151
|
createValidationSchema: () => createValidationSchema,
|
109
152
|
deepDropNulls: () => deepDropNulls,
|
153
|
+
deepMerge: () => deepMerge,
|
154
|
+
defineActionForm: () => defineActionForm,
|
110
155
|
defineConditional: () => defineConditional,
|
111
156
|
defineConfig: () => defineConfig,
|
112
|
-
|
157
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
158
|
+
defineFormConditional: () => defineFormConditional,
|
113
159
|
defineFormPage: () => defineFormPage,
|
160
|
+
definePage: () => definePage,
|
161
|
+
defineWorkqueue: () => defineWorkqueue,
|
114
162
|
errorMessages: () => errorMessages,
|
115
163
|
event: () => event,
|
116
164
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -119,38 +167,46 @@ __export(events_exports, {
|
|
119
167
|
eventStatuses: () => eventStatuses,
|
120
168
|
field: () => field,
|
121
169
|
fieldTypes: () => fieldTypes,
|
122
|
-
|
123
|
-
findActiveActionForm: () => findActiveActionForm,
|
124
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
125
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
170
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
126
171
|
findActiveDrafts: () => findActiveDrafts,
|
127
|
-
|
128
|
-
|
172
|
+
findAllFields: () => findAllFields,
|
173
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
174
|
+
findRecordActionPages: () => findRecordActionPages,
|
175
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
176
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
129
177
|
generateActionDocument: () => generateActionDocument,
|
130
|
-
generateActionInput: () => generateActionInput,
|
131
178
|
generateEventDocument: () => generateEventDocument,
|
132
179
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
133
180
|
generateTransactionId: () => generateTransactionId,
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
181
|
+
generateTranslationConfig: () => generateTranslationConfig,
|
182
|
+
getAcceptedActions: () => getAcceptedActions,
|
183
|
+
getActionAnnotation: () => getActionAnnotation,
|
184
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
185
|
+
getActionReview: () => getActionReview,
|
186
|
+
getActionReviewFields: () => getActionReviewFields,
|
187
|
+
getActionVerificationPageIds: () => getActionVerificationPageIds,
|
188
|
+
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
189
|
+
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
138
190
|
getCurrentEventState: () => getCurrentEventState,
|
139
191
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
192
|
+
getDeclaration: () => getDeclaration,
|
193
|
+
getDeclarationFields: () => getDeclarationFields,
|
194
|
+
getDeclarationPages: () => getDeclarationPages,
|
195
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
196
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
144
197
|
isAddressFieldType: () => isAddressFieldType,
|
145
198
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
146
199
|
isBulletListFieldType: () => isBulletListFieldType,
|
147
200
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
201
|
+
isConditionMet: () => isConditionMet,
|
148
202
|
isCountryFieldType: () => isCountryFieldType,
|
203
|
+
isDataFieldType: () => isDataFieldType,
|
149
204
|
isDateFieldType: () => isDateFieldType,
|
150
205
|
isDividerFieldType: () => isDividerFieldType,
|
151
206
|
isEmailFieldType: () => isEmailFieldType,
|
152
207
|
isFacilityFieldType: () => isFacilityFieldType,
|
153
208
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
209
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
154
210
|
isFieldEnabled: () => isFieldEnabled,
|
155
211
|
isFieldValue: () => isFieldValue,
|
156
212
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -161,6 +217,7 @@ __export(events_exports, {
|
|
161
217
|
isNumberFieldType: () => isNumberFieldType,
|
162
218
|
isOfficeFieldType: () => isOfficeFieldType,
|
163
219
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
220
|
+
isPageVisible: () => isPageVisible,
|
164
221
|
isParagraphFieldType: () => isParagraphFieldType,
|
165
222
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
166
223
|
isSelectFieldType: () => isSelectFieldType,
|
@@ -169,50 +226,72 @@ __export(events_exports, {
|
|
169
226
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
170
227
|
isTextFieldType: () => isTextFieldType,
|
171
228
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
229
|
+
isVerificationPage: () => isVerificationPage,
|
230
|
+
isWriteAction: () => isWriteAction,
|
172
231
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
173
232
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
174
233
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
234
|
+
never: () => never,
|
175
235
|
not: () => not,
|
236
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
237
|
+
omitHiddenFields: () => omitHiddenFields,
|
238
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
176
239
|
or: () => or,
|
177
|
-
|
178
|
-
stripHiddenFields: () => stripHiddenFields,
|
240
|
+
runFieldValidations: () => runFieldValidations,
|
179
241
|
user: () => user,
|
180
242
|
validate: () => validate,
|
181
243
|
validateFieldInput: () => validateFieldInput,
|
182
|
-
|
244
|
+
writeActions: () => writeActions
|
183
245
|
});
|
184
246
|
module.exports = __toCommonJS(events_exports);
|
185
247
|
|
186
248
|
// ../commons/src/events/ActionConfig.ts
|
187
|
-
var
|
249
|
+
var import_zod9 = require("zod");
|
188
250
|
|
189
251
|
// ../commons/src/events/Conditional.ts
|
190
252
|
var import_zod = require("zod");
|
191
|
-
|
192
|
-
|
193
|
-
|
253
|
+
var Conditional = import_zod.z.custom(
|
254
|
+
(val) => typeof val === "object" && val !== null
|
255
|
+
);
|
194
256
|
var ConditionalType = {
|
195
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
196
257
|
SHOW: "SHOW",
|
197
|
-
|
198
|
-
|
258
|
+
ENABLE: "ENABLE",
|
259
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
199
260
|
};
|
200
261
|
var ShowConditional = import_zod.z.object({
|
201
262
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
202
|
-
conditional: Conditional
|
203
|
-
})
|
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
|
+
);
|
204
267
|
var EnableConditional = import_zod.z.object({
|
205
268
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
206
|
-
conditional: Conditional
|
207
|
-
})
|
269
|
+
conditional: Conditional
|
270
|
+
}).describe(
|
271
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
272
|
+
);
|
208
273
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
209
274
|
// Action can be shown / hidden
|
210
275
|
ShowConditional,
|
211
276
|
// Action can be shown to the user in the list but as disabled
|
212
277
|
EnableConditional
|
213
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
|
+
]);
|
214
293
|
|
215
|
-
// ../commons/src/events/
|
294
|
+
// ../commons/src/events/PageConfig.ts
|
216
295
|
var import_zod6 = require("zod");
|
217
296
|
|
218
297
|
// ../commons/src/events/FieldConfig.ts
|
@@ -253,7 +332,8 @@ var FieldType = {
|
|
253
332
|
ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
|
254
333
|
FACILITY: "FACILITY",
|
255
334
|
OFFICE: "OFFICE",
|
256
|
-
SIGNATURE: "SIGNATURE"
|
335
|
+
SIGNATURE: "SIGNATURE",
|
336
|
+
DATA: "DATA"
|
257
337
|
};
|
258
338
|
var fieldTypes = Object.values(FieldType);
|
259
339
|
var compositeFieldTypes = [
|
@@ -271,13 +351,18 @@ var GeographicalArea = {
|
|
271
351
|
URBAN: "URBAN",
|
272
352
|
RURAL: "RURAL"
|
273
353
|
};
|
354
|
+
var AddressType = {
|
355
|
+
DOMESTIC: "DOMESTIC",
|
356
|
+
INTERNATIONAL: "INTERNATIONAL"
|
357
|
+
};
|
274
358
|
var FileFieldValue = import_zod3.z.object({
|
275
359
|
filename: import_zod3.z.string(),
|
276
360
|
originalFilename: import_zod3.z.string(),
|
277
361
|
type: import_zod3.z.string()
|
278
362
|
});
|
279
363
|
var AdminStructure = import_zod3.z.object({
|
280
|
-
country: import_zod3.z.
|
364
|
+
country: import_zod3.z.string(),
|
365
|
+
addressType: import_zod3.z.literal(AddressType.DOMESTIC),
|
281
366
|
province: import_zod3.z.string(),
|
282
367
|
district: import_zod3.z.string()
|
283
368
|
});
|
@@ -306,7 +391,8 @@ var RuralAddressUpdateValue = AdminStructure.extend({
|
|
306
391
|
village: import_zod3.z.string().nullish()
|
307
392
|
});
|
308
393
|
var GenericAddressValue = import_zod3.z.object({
|
309
|
-
country: import_zod3.z.string()
|
394
|
+
country: import_zod3.z.string(),
|
395
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
310
396
|
state: import_zod3.z.string(),
|
311
397
|
district2: import_zod3.z.string(),
|
312
398
|
cityOrTown: import_zod3.z.string().optional(),
|
@@ -317,7 +403,8 @@ var GenericAddressValue = import_zod3.z.object({
|
|
317
403
|
});
|
318
404
|
var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
|
319
405
|
var GenericAddressUpdateValue = import_zod3.z.object({
|
320
|
-
country: import_zod3.z.string()
|
406
|
+
country: import_zod3.z.string(),
|
407
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
321
408
|
state: import_zod3.z.string(),
|
322
409
|
district2: import_zod3.z.string(),
|
323
410
|
cityOrTown: import_zod3.z.string().nullish(),
|
@@ -340,11 +427,12 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
340
427
|
|
341
428
|
// ../commons/src/events/FieldValue.ts
|
342
429
|
var TextValue = import_zod4.z.string();
|
343
|
-
var
|
430
|
+
var NonEmptyTextValue = TextValue.min(1);
|
344
431
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
345
432
|
var EmailValue = import_zod4.z.string().email();
|
346
433
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
347
434
|
var NumberFieldValue = import_zod4.z.number();
|
435
|
+
var DataFieldValue = import_zod4.z.undefined();
|
348
436
|
var FieldValue = import_zod4.z.union([
|
349
437
|
TextValue,
|
350
438
|
DateValue,
|
@@ -354,6 +442,7 @@ var FieldValue = import_zod4.z.union([
|
|
354
442
|
FileFieldWithOptionValue,
|
355
443
|
UrbanAddressValue,
|
356
444
|
RuralAddressValue,
|
445
|
+
DataFieldValue,
|
357
446
|
GenericAddressValue
|
358
447
|
]);
|
359
448
|
var FieldUpdateValue = import_zod4.z.union([
|
@@ -365,40 +454,34 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
365
454
|
FileFieldWithOptionValue,
|
366
455
|
UrbanAddressUpdateValue,
|
367
456
|
RuralAddressUpdateValue,
|
457
|
+
DataFieldValue,
|
368
458
|
GenericAddressUpdateValue
|
369
459
|
]);
|
370
460
|
|
371
461
|
// ../commons/src/events/FieldConfig.ts
|
372
462
|
var FieldId = import_zod5.z.string();
|
373
|
-
var
|
374
|
-
|
375
|
-
|
376
|
-
});
|
463
|
+
var ParentReference = import_zod5.z.object({
|
464
|
+
_fieldId: FieldId.optional()
|
465
|
+
}).optional();
|
377
466
|
var BaseField = import_zod5.z.object({
|
378
467
|
id: FieldId,
|
379
468
|
defaultValue: import_zod5.z.union([
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
NumberFieldValue,
|
386
|
-
CheckboxFieldValue
|
387
|
-
]),
|
388
|
-
DependencyExpression
|
469
|
+
TextValue,
|
470
|
+
NonEmptyTextValue,
|
471
|
+
DateValue,
|
472
|
+
NumberFieldValue,
|
473
|
+
CheckboxFieldValue
|
389
474
|
]).optional(),
|
390
|
-
|
475
|
+
parent: ParentReference,
|
476
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
391
477
|
required: import_zod5.z.boolean().default(false).optional(),
|
392
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
393
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
394
478
|
placeholder: TranslationConfig.optional(),
|
395
479
|
validation: import_zod5.z.array(
|
396
480
|
import_zod5.z.object({
|
397
|
-
validator: Conditional
|
481
|
+
validator: Conditional,
|
398
482
|
message: TranslationConfig
|
399
483
|
})
|
400
484
|
).default([]).optional(),
|
401
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
402
485
|
label: TranslationConfig,
|
403
486
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
404
487
|
});
|
@@ -407,7 +490,7 @@ var Divider = BaseField.extend({
|
|
407
490
|
});
|
408
491
|
var TextField = BaseField.extend({
|
409
492
|
type: import_zod5.z.literal(FieldType.TEXT),
|
410
|
-
defaultValue:
|
493
|
+
defaultValue: NonEmptyTextValue.optional(),
|
411
494
|
configuration: import_zod5.z.object({
|
412
495
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
413
496
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -417,7 +500,7 @@ var TextField = BaseField.extend({
|
|
417
500
|
}).describe("Text input");
|
418
501
|
var NumberField = BaseField.extend({
|
419
502
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
420
|
-
defaultValue:
|
503
|
+
defaultValue: NumberFieldValue.optional(),
|
421
504
|
configuration: import_zod5.z.object({
|
422
505
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
423
506
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -427,7 +510,7 @@ var NumberField = BaseField.extend({
|
|
427
510
|
}).describe("Number input");
|
428
511
|
var TextAreaField = BaseField.extend({
|
429
512
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
430
|
-
defaultValue:
|
513
|
+
defaultValue: NonEmptyTextValue.optional(),
|
431
514
|
configuration: import_zod5.z.object({
|
432
515
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
433
516
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -436,26 +519,36 @@ var TextAreaField = BaseField.extend({
|
|
436
519
|
postfix: TranslationConfig.optional()
|
437
520
|
}).default({ rows: 4 }).optional()
|
438
521
|
}).describe("Multiline text input");
|
522
|
+
var ImageMimeType = import_zod5.z.enum([
|
523
|
+
"image/png",
|
524
|
+
"image/jpg",
|
525
|
+
"image/jpeg",
|
526
|
+
"image/svg+xml"
|
527
|
+
]);
|
528
|
+
var MimeType = ImageMimeType;
|
529
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
439
530
|
var SignatureField = BaseField.extend({
|
440
531
|
type: import_zod5.z.literal(FieldType.SIGNATURE),
|
441
532
|
signaturePromptLabel: TranslationConfig.describe(
|
442
533
|
"Title of the signature modal"
|
443
534
|
),
|
444
535
|
configuration: import_zod5.z.object({
|
445
|
-
|
446
|
-
|
447
|
-
}).default({
|
536
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
537
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
538
|
+
}).default({
|
539
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
540
|
+
})
|
448
541
|
}).describe("Signature input field");
|
449
542
|
var EmailField = BaseField.extend({
|
450
543
|
type: import_zod5.z.literal(FieldType.EMAIL),
|
451
544
|
configuration: import_zod5.z.object({
|
452
545
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
453
546
|
}).default({ maxLength: 10 }).optional(),
|
454
|
-
defaultValue:
|
547
|
+
defaultValue: NonEmptyTextValue.optional()
|
455
548
|
});
|
456
549
|
var DateField = BaseField.extend({
|
457
550
|
type: import_zod5.z.literal(FieldType.DATE),
|
458
|
-
defaultValue:
|
551
|
+
defaultValue: DateValue.optional(),
|
459
552
|
configuration: import_zod5.z.object({
|
460
553
|
notice: TranslationConfig.describe(
|
461
554
|
"Text to display above the date input"
|
@@ -474,7 +567,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
474
567
|
]);
|
475
568
|
var Paragraph = BaseField.extend({
|
476
569
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
477
|
-
defaultValue:
|
570
|
+
defaultValue: NonEmptyTextValue.optional(),
|
478
571
|
configuration: import_zod5.z.object({
|
479
572
|
styles: import_zod5.z.object({
|
480
573
|
fontVariant: HtmlFontVariant.optional()
|
@@ -483,17 +576,22 @@ var Paragraph = BaseField.extend({
|
|
483
576
|
}).describe("A read-only HTML <p> paragraph");
|
484
577
|
var PageHeader = BaseField.extend({
|
485
578
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
486
|
-
defaultValue:
|
579
|
+
defaultValue: NonEmptyTextValue.optional()
|
487
580
|
}).describe("A read-only header component for form pages");
|
488
581
|
var File = BaseField.extend({
|
489
582
|
type: import_zod5.z.literal(FieldType.FILE),
|
490
|
-
|
583
|
+
configuration: import_zod5.z.object({
|
584
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
585
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
491
586
|
style: import_zod5.z.object({
|
492
|
-
|
587
|
+
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
493
588
|
"Whether the file upload button should take the full width of the container or not"
|
494
589
|
)
|
495
|
-
})
|
496
|
-
|
590
|
+
}).optional(),
|
591
|
+
fileName: TranslationConfig.optional()
|
592
|
+
}).default({
|
593
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
594
|
+
})
|
497
595
|
}).describe("File upload");
|
498
596
|
var SelectOption = import_zod5.z.object({
|
499
597
|
value: import_zod5.z.string().describe("The value of the option"),
|
@@ -501,7 +599,7 @@ var SelectOption = import_zod5.z.object({
|
|
501
599
|
});
|
502
600
|
var RadioGroup = BaseField.extend({
|
503
601
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
504
|
-
defaultValue:
|
602
|
+
defaultValue: TextValue.optional(),
|
505
603
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
506
604
|
configuration: import_zod5.z.object({
|
507
605
|
styles: import_zod5.z.object({
|
@@ -511,7 +609,7 @@ var RadioGroup = BaseField.extend({
|
|
511
609
|
}).describe("Grouped radio options");
|
512
610
|
var BulletList = BaseField.extend({
|
513
611
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
514
|
-
defaultValue:
|
612
|
+
defaultValue: TextValue.optional(),
|
515
613
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
516
614
|
configuration: import_zod5.z.object({
|
517
615
|
styles: import_zod5.z.object({
|
@@ -521,16 +619,16 @@ var BulletList = BaseField.extend({
|
|
521
619
|
}).describe("A list of bullet points");
|
522
620
|
var Select = BaseField.extend({
|
523
621
|
type: import_zod5.z.literal(FieldType.SELECT),
|
524
|
-
defaultValue:
|
622
|
+
defaultValue: TextValue.optional(),
|
525
623
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
526
624
|
}).describe("Select input");
|
527
625
|
var Checkbox = BaseField.extend({
|
528
626
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
529
|
-
defaultValue:
|
627
|
+
defaultValue: CheckboxFieldValue.optional()
|
530
628
|
}).describe("Boolean checkbox field");
|
531
629
|
var Country = BaseField.extend({
|
532
630
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
533
|
-
defaultValue:
|
631
|
+
defaultValue: NonEmptyTextValue.optional()
|
534
632
|
}).describe("Country select field");
|
535
633
|
var AdministrativeAreas = import_zod5.z.enum([
|
536
634
|
"ADMIN_STRUCTURE",
|
@@ -539,35 +637,57 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
539
637
|
]);
|
540
638
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
541
639
|
partOf: import_zod5.z.object({
|
542
|
-
$
|
640
|
+
$declaration: import_zod5.z.string()
|
543
641
|
}).optional().describe("Parent location"),
|
544
642
|
type: AdministrativeAreas
|
545
643
|
}).describe("Administrative area options");
|
546
644
|
var AdministrativeArea = BaseField.extend({
|
547
645
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
548
|
-
defaultValue:
|
646
|
+
defaultValue: NonEmptyTextValue.optional(),
|
549
647
|
configuration: AdministrativeAreaConfiguration
|
550
648
|
}).describe("Administrative area input field e.g. facility, office");
|
551
649
|
var Location = BaseField.extend({
|
552
650
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
553
|
-
defaultValue:
|
651
|
+
defaultValue: NonEmptyTextValue.optional()
|
554
652
|
}).describe("Input field for a location");
|
555
653
|
var FileUploadWithOptions = BaseField.extend({
|
556
654
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
557
|
-
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
558
|
-
|
655
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
656
|
+
configuration: import_zod5.z.object({
|
657
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
658
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
659
|
+
}).default({
|
660
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
661
|
+
})
|
662
|
+
});
|
559
663
|
var Facility = BaseField.extend({
|
560
664
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
561
|
-
defaultValue:
|
665
|
+
defaultValue: NonEmptyTextValue.optional()
|
562
666
|
}).describe("Input field for a facility");
|
563
667
|
var Office = BaseField.extend({
|
564
668
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
565
|
-
defaultValue:
|
669
|
+
defaultValue: NonEmptyTextValue.optional()
|
566
670
|
}).describe("Input field for an office");
|
567
671
|
var Address = BaseField.extend({
|
568
672
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
569
673
|
defaultValue: AddressFieldValue.optional()
|
570
674
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
675
|
+
var DataEntry = import_zod5.z.union([
|
676
|
+
import_zod5.z.object({
|
677
|
+
label: TranslationConfig,
|
678
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
679
|
+
}),
|
680
|
+
import_zod5.z.object({
|
681
|
+
fieldId: import_zod5.z.string()
|
682
|
+
})
|
683
|
+
]);
|
684
|
+
var DataField = BaseField.extend({
|
685
|
+
type: import_zod5.z.literal(FieldType.DATA),
|
686
|
+
configuration: import_zod5.z.object({
|
687
|
+
subtitle: TranslationConfig.optional(),
|
688
|
+
data: import_zod5.z.array(DataEntry)
|
689
|
+
})
|
690
|
+
}).describe("Data field for displaying read-only data");
|
571
691
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
572
692
|
Address,
|
573
693
|
TextField,
|
@@ -589,238 +709,331 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
589
709
|
Office,
|
590
710
|
SignatureField,
|
591
711
|
EmailField,
|
592
|
-
FileUploadWithOptions
|
712
|
+
FileUploadWithOptions,
|
713
|
+
DataField
|
593
714
|
]);
|
594
715
|
|
595
|
-
// ../commons/src/events/
|
596
|
-
var
|
716
|
+
// ../commons/src/events/PageConfig.ts
|
717
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
718
|
+
var PageConfigBase = import_zod6.z.object({
|
597
719
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
598
720
|
title: TranslationConfig.describe("Header title of the page"),
|
599
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
721
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
722
|
+
conditional: Conditional.optional().describe(
|
723
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
724
|
+
)
|
600
725
|
});
|
601
|
-
var
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
label: TranslationConfig
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
pages: import_zod6.z.array(FormPage),
|
613
|
-
review: import_zod6.z.object({
|
614
|
-
title: TranslationConfig.describe(
|
615
|
-
"Title of the form to show in review page"
|
616
|
-
),
|
617
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
726
|
+
var FormPageConfig = PageConfigBase.extend({
|
727
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
728
|
+
});
|
729
|
+
var VerificationActionConfig = import_zod6.z.object({
|
730
|
+
verify: import_zod6.z.object({ label: TranslationConfig }),
|
731
|
+
cancel: import_zod6.z.object({
|
732
|
+
label: TranslationConfig,
|
733
|
+
confirmation: import_zod6.z.object({
|
734
|
+
title: TranslationConfig,
|
735
|
+
body: TranslationConfig
|
736
|
+
})
|
618
737
|
})
|
738
|
+
}).describe("Actions available on the verification page");
|
739
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
740
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
741
|
+
actions: VerificationActionConfig
|
619
742
|
});
|
743
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
744
|
+
FormPageConfig,
|
745
|
+
VerificationPageConfig
|
746
|
+
]);
|
620
747
|
|
621
748
|
// ../commons/src/events/ActionType.ts
|
749
|
+
var import_zod7 = require("zod");
|
622
750
|
var ActionType = {
|
751
|
+
// Pre-declaration actions
|
752
|
+
DELETE: "DELETE",
|
623
753
|
CREATE: "CREATE",
|
624
|
-
ASSIGN: "ASSIGN",
|
625
|
-
UNASSIGN: "UNASSIGN",
|
626
|
-
REGISTER: "REGISTER",
|
627
|
-
VALIDATE: "VALIDATE",
|
628
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
629
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
630
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
631
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
632
754
|
NOTIFY: "NOTIFY",
|
755
|
+
// Declaration actions
|
633
756
|
DECLARE: "DECLARE",
|
634
|
-
|
635
|
-
|
636
|
-
|
757
|
+
VALIDATE: "VALIDATE",
|
758
|
+
REGISTER: "REGISTER",
|
759
|
+
// Declaration system actions. Non-configurable.
|
760
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
637
761
|
REJECT: "REJECT",
|
762
|
+
// REJECT_DECLARATION
|
638
763
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
639
|
-
|
764
|
+
// MARK_AS_DUPLICATE
|
765
|
+
ARCHIVE: "ARCHIVE",
|
766
|
+
// Record actions
|
767
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
768
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
769
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
770
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
771
|
+
// General actions
|
772
|
+
READ: "READ",
|
773
|
+
ASSIGN: "ASSIGN",
|
774
|
+
UNASSIGN: "UNASSIGN"
|
640
775
|
};
|
776
|
+
var ConfirmableActions = [
|
777
|
+
ActionType.NOTIFY,
|
778
|
+
ActionType.DECLARE,
|
779
|
+
ActionType.VALIDATE,
|
780
|
+
ActionType.REGISTER,
|
781
|
+
ActionType.REJECT,
|
782
|
+
ActionType.ARCHIVE,
|
783
|
+
ActionType.PRINT_CERTIFICATE
|
784
|
+
];
|
785
|
+
var ActionTypes = import_zod7.z.enum([
|
786
|
+
"DELETE",
|
787
|
+
"CREATE",
|
788
|
+
"NOTIFY",
|
789
|
+
"DECLARE",
|
790
|
+
"VALIDATE",
|
791
|
+
"REGISTER",
|
792
|
+
"DETECT_DUPLICATE",
|
793
|
+
"REJECT",
|
794
|
+
"MARKED_AS_DUPLICATE",
|
795
|
+
"ARCHIVE",
|
796
|
+
"PRINT_CERTIFICATE",
|
797
|
+
"REQUEST_CORRECTION",
|
798
|
+
"REJECT_CORRECTION",
|
799
|
+
"APPROVE_CORRECTION",
|
800
|
+
"READ",
|
801
|
+
"ASSIGN",
|
802
|
+
"UNASSIGN"
|
803
|
+
]);
|
804
|
+
var declarationActionValues = [
|
805
|
+
ActionTypes.enum.DECLARE,
|
806
|
+
ActionTypes.enum.VALIDATE,
|
807
|
+
ActionTypes.enum.REGISTER
|
808
|
+
];
|
809
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
810
|
+
var declarationUpdateActionValues = [
|
811
|
+
...declarationActionValues,
|
812
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
813
|
+
];
|
814
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
815
|
+
declarationUpdateActionValues
|
816
|
+
);
|
817
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
818
|
+
var writeActions = ActionTypes.exclude([
|
819
|
+
ActionType.CREATE,
|
820
|
+
ActionType.READ,
|
821
|
+
ActionType.ASSIGN,
|
822
|
+
ActionType.UNASSIGN
|
823
|
+
]);
|
824
|
+
|
825
|
+
// ../commons/src/events/FormConfig.ts
|
826
|
+
var import_zod8 = require("zod");
|
827
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
828
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
829
|
+
pages: import_zod8.z.array(FormPageConfig)
|
830
|
+
}).describe("Configuration for a declaration form");
|
831
|
+
var ActionFormConfig = import_zod8.z.object({
|
832
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
833
|
+
pages: import_zod8.z.array(PageConfig)
|
834
|
+
});
|
835
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
641
836
|
|
642
837
|
// ../commons/src/events/ActionConfig.ts
|
643
|
-
var
|
838
|
+
var import_zod_openapi = require("zod-openapi");
|
839
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
|
840
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
644
841
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
645
842
|
ShowConditional,
|
646
843
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
647
844
|
EnableConditional
|
648
845
|
]);
|
649
|
-
var
|
846
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
847
|
+
title: TranslationConfig.describe("Title of the review page"),
|
848
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
849
|
+
}).describe("Configuration for **declaration** review page.");
|
850
|
+
var ActionConfigBase = import_zod9.z.object({
|
650
851
|
label: TranslationConfig,
|
651
|
-
conditionals:
|
652
|
-
draft:
|
653
|
-
forms: import_zod7.z.array(FormConfig)
|
852
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
853
|
+
draft: import_zod9.z.boolean().optional()
|
654
854
|
});
|
655
855
|
var DeclareConfig = ActionConfigBase.merge(
|
656
|
-
|
657
|
-
type:
|
856
|
+
import_zod9.z.object({
|
857
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
858
|
+
review: DeclarationReviewConfig
|
658
859
|
})
|
659
860
|
);
|
660
861
|
var ValidateConfig = ActionConfigBase.merge(
|
661
|
-
|
662
|
-
type:
|
862
|
+
import_zod9.z.object({
|
863
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
864
|
+
review: DeclarationReviewConfig
|
865
|
+
})
|
866
|
+
);
|
867
|
+
var RegisterConfig = ActionConfigBase.merge(
|
868
|
+
import_zod9.z.object({
|
869
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
870
|
+
review: DeclarationReviewConfig
|
663
871
|
})
|
664
872
|
);
|
665
873
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
666
|
-
|
667
|
-
type:
|
874
|
+
import_zod9.z.object({
|
875
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
668
876
|
})
|
669
877
|
);
|
670
878
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
671
|
-
|
672
|
-
type:
|
879
|
+
import_zod9.z.object({
|
880
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
673
881
|
})
|
674
882
|
);
|
675
883
|
var ArchiveConfig = ActionConfigBase.merge(
|
676
|
-
|
677
|
-
type:
|
678
|
-
})
|
679
|
-
);
|
680
|
-
var RegisterConfig = ActionConfigBase.merge(
|
681
|
-
import_zod7.z.object({
|
682
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
884
|
+
import_zod9.z.object({
|
885
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
683
886
|
})
|
684
887
|
);
|
685
888
|
var DeleteConfig = ActionConfigBase.merge(
|
686
|
-
|
687
|
-
type:
|
889
|
+
import_zod9.z.object({
|
890
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
688
891
|
})
|
689
892
|
);
|
690
893
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
691
|
-
|
692
|
-
type:
|
894
|
+
import_zod9.z.object({
|
895
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
896
|
+
printForm: ActionFormConfig
|
693
897
|
})
|
694
898
|
);
|
695
899
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
696
|
-
|
697
|
-
type:
|
698
|
-
onboardingForm:
|
699
|
-
additionalDetailsForm:
|
900
|
+
import_zod9.z.object({
|
901
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
902
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
903
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
700
904
|
})
|
701
905
|
);
|
702
906
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
703
|
-
|
704
|
-
type:
|
907
|
+
import_zod9.z.object({
|
908
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
705
909
|
})
|
706
910
|
);
|
707
911
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
708
|
-
|
709
|
-
type:
|
710
|
-
})
|
711
|
-
);
|
712
|
-
var CustomConfig = ActionConfigBase.merge(
|
713
|
-
import_zod7.z.object({
|
714
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
912
|
+
import_zod9.z.object({
|
913
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
715
914
|
})
|
716
915
|
);
|
717
|
-
var ActionConfig =
|
916
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
917
|
+
/*
|
918
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
919
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
920
|
+
*/
|
921
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
922
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
923
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
924
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
925
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
926
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
927
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
928
|
+
PrintCertificateActionConfig.openapi({
|
929
|
+
ref: "PrintCertificateActionConfig"
|
930
|
+
}),
|
931
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
932
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
933
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
934
|
+
]).openapi({ ref: "ActionConfig" });
|
935
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
718
936
|
DeclareConfig,
|
719
937
|
ValidateConfig,
|
720
|
-
|
721
|
-
MarkedAsDuplicateConfig,
|
722
|
-
ArchiveConfig,
|
723
|
-
RegisterConfig,
|
724
|
-
DeleteConfig,
|
725
|
-
PrintCertificateActionConfig,
|
726
|
-
RequestCorrectionConfig,
|
727
|
-
RejectCorrectionConfig,
|
728
|
-
ApproveCorrectionConfig,
|
729
|
-
CustomConfig
|
938
|
+
RegisterConfig
|
730
939
|
]);
|
731
940
|
|
732
941
|
// ../commons/src/events/offline/CertificateConfig.ts
|
733
|
-
var
|
734
|
-
var FontFamily =
|
735
|
-
normal:
|
736
|
-
bold:
|
737
|
-
italics:
|
738
|
-
bolditalics:
|
942
|
+
var import_zod10 = require("zod");
|
943
|
+
var FontFamily = import_zod10.z.object({
|
944
|
+
normal: import_zod10.z.string(),
|
945
|
+
bold: import_zod10.z.string(),
|
946
|
+
italics: import_zod10.z.string(),
|
947
|
+
bolditalics: import_zod10.z.string()
|
739
948
|
});
|
740
|
-
var CertificateConfig =
|
741
|
-
id:
|
742
|
-
event:
|
949
|
+
var CertificateConfig = import_zod10.z.object({
|
950
|
+
id: import_zod10.z.string(),
|
951
|
+
event: import_zod10.z.string(),
|
743
952
|
label: TranslationConfig,
|
744
|
-
isDefault:
|
745
|
-
fee:
|
746
|
-
onTime:
|
747
|
-
late:
|
748
|
-
delayed:
|
953
|
+
isDefault: import_zod10.z.boolean(),
|
954
|
+
fee: import_zod10.z.object({
|
955
|
+
onTime: import_zod10.z.number(),
|
956
|
+
late: import_zod10.z.number(),
|
957
|
+
delayed: import_zod10.z.number()
|
749
958
|
}),
|
750
|
-
svgUrl:
|
751
|
-
fonts:
|
959
|
+
svgUrl: import_zod10.z.string(),
|
960
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
752
961
|
});
|
753
962
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
754
|
-
hash:
|
755
|
-
svg:
|
963
|
+
hash: import_zod10.z.string().optional(),
|
964
|
+
svg: import_zod10.z.string()
|
756
965
|
});
|
757
966
|
|
758
967
|
// ../commons/src/events/offline/LanguageConfig.ts
|
759
|
-
var
|
760
|
-
var LanguageConfig =
|
761
|
-
lang:
|
968
|
+
var import_zod11 = require("zod");
|
969
|
+
var LanguageConfig = import_zod11.z.object({
|
970
|
+
lang: import_zod11.z.string(),
|
762
971
|
/**
|
763
972
|
* client.csv contents
|
764
973
|
*/
|
765
|
-
messages:
|
974
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
766
975
|
});
|
767
976
|
|
768
977
|
// ../commons/src/events/EventConfig.ts
|
769
|
-
var
|
978
|
+
var import_zod16 = require("zod");
|
770
979
|
|
771
980
|
// ../commons/src/events/DeduplicationConfig.ts
|
772
|
-
var
|
773
|
-
var
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
981
|
+
var import_zod12 = require("zod");
|
982
|
+
var import_zod_openapi2 = require("zod-openapi");
|
983
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
|
984
|
+
var FieldReference = import_zod12.z.string();
|
985
|
+
var Matcher = import_zod12.z.object({
|
986
|
+
fieldId: import_zod12.z.string(),
|
987
|
+
options: import_zod12.z.object({
|
988
|
+
boost: import_zod12.z.number().optional()
|
778
989
|
}).optional().default({})
|
779
990
|
});
|
780
991
|
var FuzzyMatcher = Matcher.extend({
|
781
|
-
type:
|
782
|
-
options:
|
992
|
+
type: import_zod12.z.literal("fuzzy"),
|
993
|
+
options: import_zod12.z.object({
|
783
994
|
/**
|
784
995
|
* Names of length 3 or less characters = 0 edits allowed
|
785
996
|
* Names of length 4 - 6 characters = 1 edit allowed
|
786
997
|
* Names of length >7 characters = 2 edits allowed
|
787
998
|
*/
|
788
|
-
fuzziness:
|
789
|
-
boost:
|
999
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
1000
|
+
boost: import_zod12.z.number().optional().default(1)
|
790
1001
|
}).optional().default({})
|
791
1002
|
});
|
792
1003
|
var StrictMatcher = Matcher.extend({
|
793
|
-
type:
|
794
|
-
options:
|
795
|
-
boost:
|
1004
|
+
type: import_zod12.z.literal("strict"),
|
1005
|
+
options: import_zod12.z.object({
|
1006
|
+
boost: import_zod12.z.number().optional().default(1)
|
796
1007
|
}).optional().default({})
|
797
1008
|
});
|
798
1009
|
var DateRangeMatcher = Matcher.extend({
|
799
|
-
type:
|
800
|
-
options:
|
801
|
-
days:
|
1010
|
+
type: import_zod12.z.literal("dateRange"),
|
1011
|
+
options: import_zod12.z.object({
|
1012
|
+
days: import_zod12.z.number(),
|
802
1013
|
origin: FieldReference,
|
803
|
-
boost:
|
1014
|
+
boost: import_zod12.z.number().optional().default(1)
|
804
1015
|
})
|
805
1016
|
});
|
806
1017
|
var DateDistanceMatcher = Matcher.extend({
|
807
|
-
type:
|
808
|
-
options:
|
809
|
-
days:
|
1018
|
+
type: import_zod12.z.literal("dateDistance"),
|
1019
|
+
options: import_zod12.z.object({
|
1020
|
+
days: import_zod12.z.number(),
|
810
1021
|
origin: FieldReference,
|
811
|
-
boost:
|
1022
|
+
boost: import_zod12.z.number().optional().default(1)
|
812
1023
|
})
|
813
1024
|
});
|
814
|
-
var And =
|
815
|
-
type:
|
816
|
-
|
1025
|
+
var And = import_zod12.z.object({
|
1026
|
+
type: import_zod12.z.literal("and"),
|
1027
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1028
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
817
1029
|
});
|
818
|
-
var Or =
|
819
|
-
type:
|
820
|
-
|
1030
|
+
var Or = import_zod12.z.object({
|
1031
|
+
type: import_zod12.z.literal("or"),
|
1032
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1033
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
821
1034
|
});
|
822
|
-
var Clause =
|
823
|
-
() =>
|
1035
|
+
var Clause = import_zod12.z.lazy(
|
1036
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
824
1037
|
And,
|
825
1038
|
Or,
|
826
1039
|
FuzzyMatcher,
|
@@ -828,275 +1041,73 @@ var Clause = import_zod10.z.lazy(
|
|
828
1041
|
DateRangeMatcher,
|
829
1042
|
DateDistanceMatcher
|
830
1043
|
])
|
831
|
-
)
|
832
|
-
|
833
|
-
|
1044
|
+
).openapi({
|
1045
|
+
ref: "Clause"
|
1046
|
+
});
|
1047
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1048
|
+
id: import_zod12.z.string(),
|
834
1049
|
label: TranslationConfig,
|
835
1050
|
query: Clause
|
836
1051
|
});
|
837
1052
|
|
838
1053
|
// ../commons/src/events/SummaryConfig.ts
|
839
|
-
var
|
840
|
-
var
|
841
|
-
|
1054
|
+
var import_zod13 = require("zod");
|
1055
|
+
var BaseField2 = import_zod13.z.object({
|
1056
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1057
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1058
|
+
});
|
1059
|
+
var ReferenceField = BaseField2.extend({
|
1060
|
+
fieldId: import_zod13.z.string()
|
1061
|
+
}).describe("Field directly referencing event data with field id");
|
1062
|
+
var Field = BaseField2.extend({
|
1063
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
842
1064
|
value: TranslationConfig.describe(
|
843
1065
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
844
1066
|
),
|
845
1067
|
label: TranslationConfig,
|
846
1068
|
emptyValueMessage: TranslationConfig.optional()
|
847
|
-
});
|
848
|
-
var
|
849
|
-
|
850
|
-
label: TranslationConfig.describe("Title content"),
|
851
|
-
emptyValueMessage: TranslationConfig.optional()
|
852
|
-
});
|
853
|
-
var SummaryConfig = import_zod11.z.object({
|
854
|
-
title: Title.describe("Title of summary view."),
|
855
|
-
fields: import_zod11.z.array(Field).describe("Fields rendered in summary view.")
|
1069
|
+
}).describe("Custom configured field");
|
1070
|
+
var SummaryConfig = import_zod13.z.object({
|
1071
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
856
1072
|
}).describe("Configuration for summary in event.");
|
857
1073
|
|
858
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
859
|
-
var import_zod13 = require("zod");
|
860
|
-
|
861
|
-
// ../commons/src/events/EventMetadata.ts
|
862
|
-
var import_zod12 = require("zod");
|
863
|
-
var EventStatus = {
|
864
|
-
CREATED: "CREATED",
|
865
|
-
NOTIFIED: "NOTIFIED",
|
866
|
-
DECLARED: "DECLARED",
|
867
|
-
VALIDATED: "VALIDATED",
|
868
|
-
REGISTERED: "REGISTERED",
|
869
|
-
CERTIFIED: "CERTIFIED",
|
870
|
-
REJECTED: "REJECTED",
|
871
|
-
ARCHIVED: "ARCHIVED"
|
872
|
-
};
|
873
|
-
var eventStatuses = Object.values(EventStatus);
|
874
|
-
var EventStatuses = import_zod12.z.nativeEnum(EventStatus);
|
875
|
-
var EventMetadata = import_zod12.z.object({
|
876
|
-
id: import_zod12.z.string(),
|
877
|
-
type: import_zod12.z.string(),
|
878
|
-
status: EventStatuses,
|
879
|
-
createdAt: import_zod12.z.string().datetime(),
|
880
|
-
createdBy: import_zod12.z.string(),
|
881
|
-
createdAtLocation: import_zod12.z.string(),
|
882
|
-
modifiedAt: import_zod12.z.string().datetime(),
|
883
|
-
assignedTo: import_zod12.z.string().nullish(),
|
884
|
-
updatedBy: import_zod12.z.string(),
|
885
|
-
trackingId: import_zod12.z.string()
|
886
|
-
});
|
887
|
-
var eventMetadataLabelMap = {
|
888
|
-
"event.assignedTo": {
|
889
|
-
id: "event.assignedTo.label",
|
890
|
-
defaultMessage: "Assigned To",
|
891
|
-
description: "Assigned To"
|
892
|
-
},
|
893
|
-
"event.createdAt": {
|
894
|
-
id: "event.createdAt.label",
|
895
|
-
defaultMessage: "Created",
|
896
|
-
description: "Created At"
|
897
|
-
},
|
898
|
-
"event.createdAtLocation": {
|
899
|
-
id: "event.createdAtLocation.label",
|
900
|
-
defaultMessage: "Location",
|
901
|
-
description: "Created At Location"
|
902
|
-
},
|
903
|
-
"event.createdBy": {
|
904
|
-
id: "event.createdBy.label",
|
905
|
-
defaultMessage: "Created By",
|
906
|
-
description: "Created By"
|
907
|
-
},
|
908
|
-
"event.id": {
|
909
|
-
id: "event.id.label",
|
910
|
-
defaultMessage: "ID",
|
911
|
-
description: "ID"
|
912
|
-
},
|
913
|
-
"event.modifiedAt": {
|
914
|
-
id: "event.modifiedAt.label",
|
915
|
-
defaultMessage: "Updated",
|
916
|
-
description: "Modified At"
|
917
|
-
},
|
918
|
-
"event.status": {
|
919
|
-
id: "event.status.label",
|
920
|
-
defaultMessage: "Status",
|
921
|
-
description: "Status"
|
922
|
-
},
|
923
|
-
"event.type": {
|
924
|
-
id: "event.type.label",
|
925
|
-
defaultMessage: "Type",
|
926
|
-
description: "Type"
|
927
|
-
},
|
928
|
-
"event.updatedBy": {
|
929
|
-
id: "event.updatedBy.label",
|
930
|
-
defaultMessage: "Updated By",
|
931
|
-
description: "Updated By"
|
932
|
-
},
|
933
|
-
"event.trackingId": {
|
934
|
-
id: "event.trackingId.label",
|
935
|
-
defaultMessage: "Tracking ID",
|
936
|
-
description: "Tracking ID"
|
937
|
-
}
|
938
|
-
};
|
939
|
-
|
940
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
941
|
-
var WorkqueueConfig = import_zod13.z.object({
|
942
|
-
id: import_zod13.z.string().describe("Unique identifier for workqueue."),
|
943
|
-
filters: import_zod13.z.array(
|
944
|
-
import_zod13.z.object({
|
945
|
-
status: import_zod13.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
946
|
-
})
|
947
|
-
).describe("Filters to be applied to workqueue.")
|
948
|
-
}).describe("Configuration for workqueue.");
|
949
|
-
|
950
1074
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
951
1075
|
var import_zod14 = require("zod");
|
1076
|
+
var MatchType = import_zod14.z.enum(["FUZZY", "EXACT", "RANGE", "ANY_OF"]);
|
1077
|
+
var BaseField3 = import_zod14.z.object({
|
1078
|
+
config: import_zod14.z.object({
|
1079
|
+
type: MatchType.describe("Determines the type of field")
|
1080
|
+
}),
|
1081
|
+
options: import_zod14.z.array(SelectOption).optional()
|
1082
|
+
});
|
1083
|
+
var FieldConfigSchema = BaseField3.extend({
|
1084
|
+
fieldId: import_zod14.z.string(),
|
1085
|
+
fieldType: import_zod14.z.literal("field")
|
1086
|
+
});
|
1087
|
+
var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
|
1088
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1089
|
+
fieldId: EventFieldId,
|
1090
|
+
fieldType: import_zod14.z.literal("event")
|
1091
|
+
});
|
1092
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1093
|
+
FieldConfigSchema,
|
1094
|
+
EventFieldConfigSchema
|
1095
|
+
]);
|
952
1096
|
var AdvancedSearchConfig = import_zod14.z.object({
|
953
1097
|
title: TranslationConfig.describe("Advanced search tab title"),
|
954
|
-
fields: import_zod14.z.array(
|
955
|
-
import_zod14.z.object({
|
956
|
-
fieldId: import_zod14.z.string(),
|
957
|
-
config: import_zod14.z.object({
|
958
|
-
type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
959
|
-
}).optional().describe("Configuration options for the field")
|
960
|
-
})
|
961
|
-
).optional().default([]).describe("Advanced search fields.")
|
1098
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
962
1099
|
});
|
963
1100
|
|
964
1101
|
// ../commons/src/events/utils.ts
|
965
1102
|
var import_lodash = require("lodash");
|
966
1103
|
|
967
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
968
|
-
var import_zod16 = require("zod");
|
969
|
-
|
970
|
-
// ../commons/src/workqueues/defaultColumns.ts
|
971
|
-
var import_zod15 = require("zod");
|
972
|
-
var WorkQueueColumnConfig = import_zod15.z.object({
|
973
|
-
id: import_zod15.z.string(),
|
974
|
-
label: TranslationConfig
|
975
|
-
});
|
976
|
-
var defaultColumns = {
|
977
|
-
event: {
|
978
|
-
id: "event",
|
979
|
-
label: {
|
980
|
-
defaultMessage: "Event",
|
981
|
-
description: "This is the label for the workqueue column",
|
982
|
-
id: "workqueue.default.column.event"
|
983
|
-
}
|
984
|
-
},
|
985
|
-
status: {
|
986
|
-
id: "status",
|
987
|
-
label: {
|
988
|
-
defaultMessage: "Status",
|
989
|
-
description: "This is the label for the workqueue column",
|
990
|
-
id: "workqueue.default.column.status"
|
991
|
-
}
|
992
|
-
},
|
993
|
-
createdAt: {
|
994
|
-
id: "createdAt",
|
995
|
-
label: {
|
996
|
-
defaultMessage: "Created",
|
997
|
-
description: "This is the label for the workqueue column",
|
998
|
-
id: "workqueue.default.column.createdAt"
|
999
|
-
}
|
1000
|
-
},
|
1001
|
-
modifiedAt: {
|
1002
|
-
id: "modifiedAt",
|
1003
|
-
label: {
|
1004
|
-
defaultMessage: "Modified",
|
1005
|
-
description: "This is the label for the workqueue column",
|
1006
|
-
id: "workqueue.default.column.modifiedAt"
|
1007
|
-
}
|
1008
|
-
}
|
1009
|
-
};
|
1010
|
-
var DefaultColumnKeys = import_zod15.z.enum(
|
1011
|
-
Object.keys(defaultColumns)
|
1012
|
-
);
|
1013
|
-
|
1014
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1015
|
-
var rootWorkqueueConfig = import_zod16.z.object({
|
1016
|
-
id: import_zod16.z.string(),
|
1017
|
-
title: TranslationConfig,
|
1018
|
-
columns: import_zod16.z.array(WorkQueueColumnConfig),
|
1019
|
-
defaultColumns: import_zod16.z.array(DefaultColumnKeys)
|
1020
|
-
});
|
1021
|
-
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1022
|
-
|
1023
|
-
// ../commons/src/workqueues/all.ts
|
1024
|
-
var allWorkqueue = defineWorkqueue({
|
1025
|
-
id: "all",
|
1026
|
-
title: {
|
1027
|
-
defaultMessage: "All events",
|
1028
|
-
description: "This is the label for the workqueue",
|
1029
|
-
id: "workqueue.all.label"
|
1030
|
-
},
|
1031
|
-
columns: [
|
1032
|
-
{
|
1033
|
-
id: "title",
|
1034
|
-
label: {
|
1035
|
-
defaultMessage: "Title",
|
1036
|
-
description: "This is the label for the workqueue column",
|
1037
|
-
id: "workqueue.all.column.title"
|
1038
|
-
}
|
1039
|
-
}
|
1040
|
-
],
|
1041
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1042
|
-
});
|
1043
|
-
|
1044
|
-
// ../commons/src/workqueues/readyForReview.ts
|
1045
|
-
var inReviewWorkqueue = defineWorkqueue({
|
1046
|
-
id: "ready-for-review",
|
1047
|
-
title: {
|
1048
|
-
defaultMessage: "Ready for review",
|
1049
|
-
description: "Label for in review workqueue",
|
1050
|
-
id: "event.workqueue.in-review.label"
|
1051
|
-
},
|
1052
|
-
columns: [
|
1053
|
-
{
|
1054
|
-
id: "title",
|
1055
|
-
label: {
|
1056
|
-
defaultMessage: "Title",
|
1057
|
-
description: "This is the label for the workqueue column",
|
1058
|
-
id: "workqueue.in-reveiw.column.title"
|
1059
|
-
}
|
1060
|
-
}
|
1061
|
-
],
|
1062
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1063
|
-
});
|
1064
|
-
|
1065
|
-
// ../commons/src/workqueues/readyToPrint.ts
|
1066
|
-
var registeredWorkqueue = defineWorkqueue({
|
1067
|
-
id: "registered",
|
1068
|
-
title: {
|
1069
|
-
defaultMessage: "Ready to print",
|
1070
|
-
description: "Label for registered workqueue",
|
1071
|
-
id: "event.workqueue.registered.label"
|
1072
|
-
},
|
1073
|
-
columns: [
|
1074
|
-
{
|
1075
|
-
id: "title",
|
1076
|
-
label: {
|
1077
|
-
defaultMessage: "Title",
|
1078
|
-
description: "This is the label for the workqueue column",
|
1079
|
-
id: "workqueue.registered.column.title"
|
1080
|
-
}
|
1081
|
-
}
|
1082
|
-
],
|
1083
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1084
|
-
});
|
1085
|
-
|
1086
|
-
// ../commons/src/workqueues/index.ts
|
1087
|
-
var workqueues = {
|
1088
|
-
all: allWorkqueue,
|
1089
|
-
registered: registeredWorkqueue,
|
1090
|
-
inReview: inReviewWorkqueue
|
1091
|
-
};
|
1092
|
-
|
1093
1104
|
// ../commons/src/conditionals/validate.ts
|
1094
1105
|
var import_ajv = __toESM(require("ajv"));
|
1095
1106
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1096
1107
|
var import_date_fns = require("date-fns");
|
1097
1108
|
|
1098
1109
|
// ../commons/src/events/FieldTypeMapping.ts
|
1099
|
-
var
|
1110
|
+
var import_zod15 = require("zod");
|
1100
1111
|
function mapFieldTypeToZod(type, required) {
|
1101
1112
|
let schema;
|
1102
1113
|
switch (type) {
|
@@ -1121,7 +1132,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1121
1132
|
case FieldType.OFFICE:
|
1122
1133
|
case FieldType.SIGNATURE:
|
1123
1134
|
case FieldType.HIDDEN:
|
1124
|
-
schema = required ?
|
1135
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1125
1136
|
break;
|
1126
1137
|
case FieldType.NUMBER:
|
1127
1138
|
schema = NumberFieldValue;
|
@@ -1138,6 +1149,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1138
1149
|
case FieldType.ADDRESS:
|
1139
1150
|
schema = AddressFieldUpdateValue;
|
1140
1151
|
break;
|
1152
|
+
case FieldType.DATA:
|
1153
|
+
schema = DataFieldValue;
|
1154
|
+
break;
|
1141
1155
|
}
|
1142
1156
|
return required ? schema : schema.nullish();
|
1143
1157
|
}
|
@@ -1146,7 +1160,7 @@ function createValidationSchema(config) {
|
|
1146
1160
|
for (const field2 of config) {
|
1147
1161
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1148
1162
|
}
|
1149
|
-
return
|
1163
|
+
return import_zod15.z.object(shape);
|
1150
1164
|
}
|
1151
1165
|
function mapFieldTypeToMockValue(field2, i) {
|
1152
1166
|
switch (field2.type) {
|
@@ -1171,7 +1185,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1171
1185
|
return "test@opencrvs.org";
|
1172
1186
|
case FieldType.ADDRESS:
|
1173
1187
|
return {
|
1174
|
-
country:
|
1188
|
+
country: "FAR",
|
1189
|
+
addressType: AddressType.DOMESTIC,
|
1175
1190
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1176
1191
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1177
1192
|
urbanOrRural: "URBAN",
|
@@ -1193,6 +1208,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1193
1208
|
};
|
1194
1209
|
case FieldType.FILE_WITH_OPTIONS:
|
1195
1210
|
return null;
|
1211
|
+
case FieldType.DATA:
|
1212
|
+
return {};
|
1196
1213
|
}
|
1197
1214
|
}
|
1198
1215
|
function mapFieldTypeToEmptyValue(field2) {
|
@@ -1215,10 +1232,12 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1215
1232
|
case FieldType.EMAIL:
|
1216
1233
|
case FieldType.DATE:
|
1217
1234
|
case FieldType.CHECKBOX:
|
1235
|
+
case FieldType.DATA:
|
1218
1236
|
return null;
|
1219
1237
|
case FieldType.ADDRESS:
|
1220
1238
|
return {
|
1221
1239
|
country: null,
|
1240
|
+
addressType: AddressType.DOMESTIC,
|
1222
1241
|
province: null,
|
1223
1242
|
district: null,
|
1224
1243
|
urbanOrRural: "URBAN",
|
@@ -1302,21 +1321,36 @@ var isFacilityFieldType = (field2) => {
|
|
1302
1321
|
var isOfficeFieldType = (field2) => {
|
1303
1322
|
return field2.config.type === FieldType.OFFICE;
|
1304
1323
|
};
|
1324
|
+
var isDataFieldType = (field2) => {
|
1325
|
+
return field2.config.type === FieldType.DATA;
|
1326
|
+
};
|
1305
1327
|
|
1306
1328
|
// ../commons/src/conditionals/validate.ts
|
1307
1329
|
var ajv = new import_ajv.default({
|
1308
|
-
$data: true
|
1330
|
+
$data: true,
|
1331
|
+
allowUnionTypes: true
|
1309
1332
|
});
|
1310
1333
|
(0, import_ajv_formats.default)(ajv);
|
1311
1334
|
function validate(schema, data) {
|
1312
1335
|
return ajv.validate(schema, data);
|
1313
1336
|
}
|
1337
|
+
function isConditionMet(conditional, values) {
|
1338
|
+
return validate(conditional, {
|
1339
|
+
$form: values,
|
1340
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1341
|
+
});
|
1342
|
+
}
|
1314
1343
|
function getConditionalActionsForField(field2, values) {
|
1315
1344
|
if (!field2.conditionals) {
|
1316
1345
|
return [];
|
1317
1346
|
}
|
1318
1347
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1319
1348
|
}
|
1349
|
+
function areConditionsMet(conditions, values) {
|
1350
|
+
return conditions.every(
|
1351
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1352
|
+
);
|
1353
|
+
}
|
1320
1354
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1321
1355
|
const hasRule = (field2.conditionals ?? []).some(
|
1322
1356
|
(conditional) => conditional.type === conditionalType
|
@@ -1335,9 +1369,16 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1335
1369
|
function isFieldVisible(field2, form) {
|
1336
1370
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1337
1371
|
}
|
1372
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1373
|
+
const fieldValue = form[field2.id];
|
1374
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1375
|
+
}
|
1338
1376
|
function isFieldEnabled(field2, form) {
|
1339
1377
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1340
1378
|
}
|
1379
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1380
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1381
|
+
}
|
1341
1382
|
var errorMessages = {
|
1342
1383
|
hiddenField: {
|
1343
1384
|
id: "v2.error.hidden",
|
@@ -1365,12 +1406,14 @@ var errorMessages = {
|
|
1365
1406
|
id: "v2.error.invalid"
|
1366
1407
|
}
|
1367
1408
|
};
|
1368
|
-
|
1369
|
-
|
1370
|
-
message
|
1371
|
-
|
1372
|
-
}
|
1373
|
-
|
1409
|
+
function createIntlError(message) {
|
1410
|
+
return {
|
1411
|
+
message: {
|
1412
|
+
message
|
1413
|
+
}
|
1414
|
+
};
|
1415
|
+
}
|
1416
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1374
1417
|
switch (issue.code) {
|
1375
1418
|
case "invalid_string": {
|
1376
1419
|
if (_ctx.data === "") {
|
@@ -1408,29 +1451,41 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1408
1451
|
}
|
1409
1452
|
}
|
1410
1453
|
return createIntlError(errorMessages.invalidInput);
|
1411
|
-
}
|
1412
|
-
function
|
1454
|
+
}
|
1455
|
+
function runCustomFieldValidations({
|
1413
1456
|
field: field2,
|
1414
|
-
|
1457
|
+
conditionalParameters
|
1415
1458
|
}) {
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1459
|
+
return (field2.validation ?? []).filter((validation) => {
|
1460
|
+
return !validate(validation.validator, conditionalParameters);
|
1461
|
+
}).map((validation) => ({ message: validation.message }));
|
1462
|
+
}
|
1463
|
+
function validateFieldInput({
|
1464
|
+
field: field2,
|
1465
|
+
value
|
1466
|
+
}) {
|
1467
|
+
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1468
|
+
value,
|
1469
|
+
{
|
1470
|
+
// @ts-expect-error
|
1471
|
+
errorMap: zodToIntlErrorMap
|
1429
1472
|
}
|
1473
|
+
);
|
1474
|
+
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1475
|
+
}
|
1476
|
+
function runFieldValidations({
|
1477
|
+
field: field2,
|
1478
|
+
values
|
1479
|
+
}) {
|
1480
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1430
1481
|
return {
|
1431
1482
|
errors: []
|
1432
1483
|
};
|
1433
1484
|
}
|
1485
|
+
const conditionalParameters = {
|
1486
|
+
$form: values,
|
1487
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1488
|
+
};
|
1434
1489
|
const fieldValidationResult = validateFieldInput({
|
1435
1490
|
field: field2,
|
1436
1491
|
value: values[field2.id]
|
@@ -1444,26 +1499,11 @@ function getFieldValidationErrors({
|
|
1444
1499
|
errors: [...fieldValidationResult, ...customValidationResults]
|
1445
1500
|
};
|
1446
1501
|
}
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
return (
|
1452
|
-
return !validate(validation.validator, conditionalParameters);
|
1453
|
-
}).map((validation) => ({ message: validation.message }));
|
1454
|
-
}
|
1455
|
-
function validateFieldInput({
|
1456
|
-
field: field2,
|
1457
|
-
value
|
1458
|
-
}) {
|
1459
|
-
const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
|
1460
|
-
value,
|
1461
|
-
{
|
1462
|
-
// @ts-expect-error
|
1463
|
-
errorMap: zodToIntlErrorMap
|
1464
|
-
}
|
1465
|
-
);
|
1466
|
-
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1502
|
+
|
1503
|
+
// ../commons/src/uuid.ts
|
1504
|
+
var import_uuid = require("uuid");
|
1505
|
+
function getUUID() {
|
1506
|
+
return (0, import_uuid.v4)();
|
1467
1507
|
}
|
1468
1508
|
|
1469
1509
|
// ../commons/src/utils.ts
|
@@ -1474,148 +1514,83 @@ function getOrThrow(x, message) {
|
|
1474
1514
|
return x;
|
1475
1515
|
}
|
1476
1516
|
|
1477
|
-
// ../commons/src/uuid.ts
|
1478
|
-
var import_uuid = require("uuid");
|
1479
|
-
function getUUID() {
|
1480
|
-
return (0, import_uuid.v4)();
|
1481
|
-
}
|
1482
|
-
|
1483
1517
|
// ../commons/src/events/utils.ts
|
1484
|
-
function
|
1485
|
-
return
|
1486
|
-
}
|
1487
|
-
var findInputPageFields = (config) => {
|
1488
|
-
return (0, import_lodash.flattenDeep)(
|
1489
|
-
config.actions.map(
|
1490
|
-
({ forms }) => forms.map(
|
1491
|
-
({ pages }) => pages.map(
|
1492
|
-
({ fields }) => fields.map(({ id, label }) => ({ id, label }))
|
1493
|
-
)
|
1494
|
-
)
|
1495
|
-
)
|
1496
|
-
);
|
1497
|
-
};
|
1498
|
-
var findPageFields = (config) => {
|
1499
|
-
return (0, import_lodash.flattenDeep)(
|
1500
|
-
config.actions.map((action) => {
|
1501
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1502
|
-
return [
|
1503
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1504
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1505
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1506
|
-
];
|
1507
|
-
}
|
1508
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1509
|
-
})
|
1510
|
-
);
|
1511
|
-
};
|
1512
|
-
var resolveLabelsFromKnownFields = ({
|
1513
|
-
pageFields,
|
1514
|
-
refFields
|
1515
|
-
}) => {
|
1516
|
-
return refFields.map((field2) => {
|
1517
|
-
if (field2.label) {
|
1518
|
-
return field2;
|
1519
|
-
}
|
1520
|
-
if (isMetadataField(field2.id)) {
|
1521
|
-
return {
|
1522
|
-
...field2,
|
1523
|
-
label: eventMetadataLabelMap[field2.id]
|
1524
|
-
};
|
1525
|
-
}
|
1526
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1527
|
-
if (!pageLabel) {
|
1528
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1529
|
-
}
|
1530
|
-
return {
|
1531
|
-
...field2,
|
1532
|
-
label: pageLabel.label
|
1533
|
-
};
|
1534
|
-
});
|
1535
|
-
};
|
1536
|
-
function getAllFields(configuration) {
|
1537
|
-
return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
|
1538
|
-
...form.review.fields,
|
1539
|
-
...form.pages.flatMap((page) => page.fields)
|
1540
|
-
]);
|
1518
|
+
function isDeclarationActionConfig(action) {
|
1519
|
+
return DeclarationActions.safeParse(action.type).success;
|
1541
1520
|
}
|
1542
|
-
function
|
1543
|
-
return configuration.
|
1521
|
+
function getDeclarationFields(configuration) {
|
1522
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1544
1523
|
}
|
1545
|
-
function
|
1546
|
-
|
1547
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1548
|
-
(wq) => wq.id === workqueue.id
|
1549
|
-
);
|
1550
|
-
if (!rootWorkqueue) {
|
1551
|
-
throw new Error(
|
1552
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1553
|
-
);
|
1554
|
-
}
|
1555
|
-
});
|
1524
|
+
function getDeclarationPages(configuration) {
|
1525
|
+
return configuration.declaration.pages;
|
1556
1526
|
}
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
}
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1527
|
+
function getDeclaration(configuration) {
|
1528
|
+
return configuration.declaration;
|
1529
|
+
}
|
1530
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1531
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1532
|
+
return [
|
1533
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1534
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1535
|
+
];
|
1536
|
+
}
|
1537
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1538
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1539
|
+
}
|
1540
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1541
|
+
return actionConfig.review.fields;
|
1542
|
+
}
|
1543
|
+
return [];
|
1571
1544
|
};
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
const
|
1577
|
-
|
1545
|
+
function getAllAnnotationFields(config) {
|
1546
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1547
|
+
}
|
1548
|
+
var findRecordActionPages = (config, actionType) => {
|
1549
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1550
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1551
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1552
|
+
}
|
1553
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1554
|
+
return action.printForm.pages;
|
1555
|
+
}
|
1556
|
+
return [];
|
1578
1557
|
};
|
1579
|
-
|
1558
|
+
function getActionReview(configuration, actionType) {
|
1559
|
+
const [actionConfig] = configuration.actions.filter(
|
1560
|
+
(a) => a.type === actionType
|
1561
|
+
);
|
1580
1562
|
return getOrThrow(
|
1581
|
-
|
1582
|
-
|
1563
|
+
actionConfig.review,
|
1564
|
+
`No review config found for ${actionType}`
|
1583
1565
|
);
|
1584
|
-
};
|
1585
|
-
function getActiveActionFields(configuration, action) {
|
1586
|
-
const fields = findActiveActionFields(configuration, action);
|
1587
|
-
if (!fields) {
|
1588
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1589
|
-
}
|
1590
|
-
return fields;
|
1591
1566
|
}
|
1592
|
-
function
|
1593
|
-
|
1594
|
-
if (!config) {
|
1595
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1596
|
-
}
|
1597
|
-
return config;
|
1567
|
+
function getActionReviewFields(configuration, actionType) {
|
1568
|
+
return getActionReview(configuration, actionType).fields;
|
1598
1569
|
}
|
1599
|
-
function
|
1600
|
-
if (
|
1601
|
-
return
|
1570
|
+
function isPageVisible(page, formValues) {
|
1571
|
+
if (!page.conditional) {
|
1572
|
+
return true;
|
1602
1573
|
}
|
1603
|
-
return
|
1574
|
+
return isConditionMet(page.conditional, formValues);
|
1604
1575
|
}
|
1605
|
-
function
|
1606
|
-
return (0, import_lodash.omitBy)(
|
1607
|
-
|
1608
|
-
|
1609
|
-
return true;
|
1576
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1577
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1578
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1579
|
+
return false;
|
1610
1580
|
}
|
1611
|
-
|
1581
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1582
|
+
if (!fieldConfigs.length) {
|
1612
1583
|
return true;
|
1613
1584
|
}
|
1614
|
-
return !isFieldVisible(
|
1585
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1615
1586
|
});
|
1616
1587
|
}
|
1588
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1589
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1590
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1591
|
+
}
|
1617
1592
|
function findActiveDrafts(event2, drafts) {
|
1618
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1593
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1619
1594
|
const lastAction = actions[actions.length - 1];
|
1620
1595
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1621
1596
|
}
|
@@ -1627,28 +1602,103 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1627
1602
|
transactionId: getUUID(),
|
1628
1603
|
action: {
|
1629
1604
|
type: actionType,
|
1630
|
-
|
1631
|
-
|
1605
|
+
declaration: {},
|
1606
|
+
annotation: {},
|
1632
1607
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1633
1608
|
createdBy: "@todo",
|
1634
1609
|
createdAtLocation: "@todo"
|
1635
1610
|
}
|
1636
1611
|
};
|
1637
1612
|
}
|
1613
|
+
function isVerificationPage(page) {
|
1614
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
1615
|
+
}
|
1616
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1617
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1618
|
+
}
|
1619
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1620
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1621
|
+
return [
|
1622
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1623
|
+
...getVisibleVerificationPageIds(
|
1624
|
+
actionConfig.additionalDetailsForm,
|
1625
|
+
annotation
|
1626
|
+
)
|
1627
|
+
];
|
1628
|
+
}
|
1629
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1630
|
+
return getVisibleVerificationPageIds(
|
1631
|
+
actionConfig.printForm.pages,
|
1632
|
+
annotation
|
1633
|
+
);
|
1634
|
+
}
|
1635
|
+
return [];
|
1636
|
+
}
|
1637
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1638
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1639
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1640
|
+
actionConfig,
|
1641
|
+
annotation
|
1642
|
+
);
|
1643
|
+
return omitHiddenFields(
|
1644
|
+
annotationFields,
|
1645
|
+
{ ...declaration, ...annotation },
|
1646
|
+
visibleVerificationPageIds
|
1647
|
+
);
|
1648
|
+
}
|
1649
|
+
function deepMerge(currentDocument, actionDocument) {
|
1650
|
+
return (0, import_lodash.mergeWith)(
|
1651
|
+
currentDocument,
|
1652
|
+
actionDocument,
|
1653
|
+
(previousValue, incomingValue) => {
|
1654
|
+
if (incomingValue === void 0) {
|
1655
|
+
return previousValue;
|
1656
|
+
}
|
1657
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1658
|
+
return incomingValue;
|
1659
|
+
}
|
1660
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1661
|
+
return void 0;
|
1662
|
+
}
|
1663
|
+
return incomingValue;
|
1664
|
+
}
|
1665
|
+
);
|
1666
|
+
}
|
1667
|
+
function findLastAssignmentAction(actions) {
|
1668
|
+
return actions.filter(
|
1669
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1670
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1671
|
+
}
|
1672
|
+
function isWriteAction(actionType) {
|
1673
|
+
return writeActions.safeParse(actionType).success;
|
1674
|
+
}
|
1675
|
+
var findAllFields = (config) => {
|
1676
|
+
return (0, import_lodash.flattenDeep)([
|
1677
|
+
...getDeclarationFields(config),
|
1678
|
+
...getAllAnnotationFields(config)
|
1679
|
+
]);
|
1680
|
+
};
|
1638
1681
|
|
1639
1682
|
// ../commons/src/events/EventConfig.ts
|
1640
|
-
var
|
1641
|
-
|
1683
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1684
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod16.z);
|
1685
|
+
var EventConfig = import_zod16.z.object({
|
1686
|
+
id: import_zod16.z.string().describe(
|
1642
1687
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1643
1688
|
),
|
1689
|
+
dateOfEvent: import_zod16.z.object({ fieldId: import_zod16.z.string() }).optional(),
|
1690
|
+
title: TranslationConfig,
|
1691
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1692
|
+
"This is a fallback title if actual title resolves to empty string"
|
1693
|
+
),
|
1644
1694
|
summary: SummaryConfig,
|
1645
1695
|
label: TranslationConfig,
|
1646
|
-
actions:
|
1647
|
-
|
1648
|
-
deduplication:
|
1649
|
-
advancedSearch:
|
1696
|
+
actions: import_zod16.z.array(ActionConfig),
|
1697
|
+
declaration: DeclarationFormConfig,
|
1698
|
+
deduplication: import_zod16.z.array(DeduplicationConfig).optional().default([]),
|
1699
|
+
advancedSearch: import_zod16.z.array(AdvancedSearchConfig).optional().default([])
|
1650
1700
|
}).superRefine((event2, ctx) => {
|
1651
|
-
const allFields =
|
1701
|
+
const allFields = findAllFields(event2);
|
1652
1702
|
const fieldIds = allFields.map((field2) => field2.id);
|
1653
1703
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1654
1704
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1662,287 +1712,497 @@ var EventConfig = import_zod18.z.object({
|
|
1662
1712
|
});
|
1663
1713
|
}
|
1664
1714
|
const invalidFields = event2.advancedSearch.flatMap(
|
1665
|
-
(section) =>
|
1715
|
+
(section) => (
|
1716
|
+
// Check if the fieldId is not in the fieldIds array
|
1717
|
+
// and also not in the metadataFields array
|
1718
|
+
section.fields.filter(
|
1719
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
1720
|
+
)
|
1721
|
+
)
|
1666
1722
|
);
|
1667
1723
|
if (invalidFields.length > 0) {
|
1668
1724
|
ctx.addIssue({
|
1669
1725
|
code: "custom",
|
1670
|
-
message: `Advanced search id must match a field id
|
1726
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1671
1727
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1672
1728
|
path: ["advancedSearch"]
|
1673
1729
|
});
|
1674
1730
|
}
|
1731
|
+
if (event2.dateOfEvent) {
|
1732
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
1733
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
1734
|
+
);
|
1735
|
+
if (!eventDateFieldId) {
|
1736
|
+
ctx.addIssue({
|
1737
|
+
code: "custom",
|
1738
|
+
message: `Date of event field id must match a field id in fields array.
|
1739
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
1740
|
+
path: ["dateOfEvent"]
|
1741
|
+
});
|
1742
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
1743
|
+
ctx.addIssue({
|
1744
|
+
code: "custom",
|
1745
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
1746
|
+
path: ["dateOfEvent.fieldType"]
|
1747
|
+
});
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
}).openapi({
|
1751
|
+
ref: "EventConfig"
|
1675
1752
|
});
|
1676
1753
|
|
1677
1754
|
// ../commons/src/events/EventConfigInput.ts
|
1678
|
-
var
|
1679
|
-
var
|
1755
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1756
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1757
|
+
var definePage = (page) => PageConfig.parse(page);
|
1758
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1759
|
+
|
1760
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1761
|
+
var import_zod17 = require("zod");
|
1762
|
+
var WorkqueueConfig = import_zod17.z.object({
|
1763
|
+
slug: import_zod17.z.string().describe("Determines the url of the workqueue."),
|
1764
|
+
name: TranslationConfig.describe(
|
1765
|
+
"Title of the workflow (both in navigation and on the page)"
|
1766
|
+
),
|
1767
|
+
/**
|
1768
|
+
* Placeholder untill the following gets merged to develop
|
1769
|
+
* https://github.com/opencrvs/opencrvs-core/blob/5fbe9854a88504a7a13fcc856b3e82594b70c38c/packages/commons/src/events/EventIndex.ts#L92-L93
|
1770
|
+
*/
|
1771
|
+
query: import_zod17.z.string(),
|
1772
|
+
actions: import_zod17.z.array(
|
1773
|
+
import_zod17.z.object({
|
1774
|
+
type: import_zod17.z.string(),
|
1775
|
+
conditionals: import_zod17.z.array(Conditional).optional()
|
1776
|
+
})
|
1777
|
+
)
|
1778
|
+
}).describe("Configuration for workqueue.");
|
1779
|
+
function defineWorkqueue(workqueues) {
|
1780
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
1781
|
+
}
|
1680
1782
|
|
1681
1783
|
// ../commons/src/events/Draft.ts
|
1682
|
-
var
|
1784
|
+
var import_zod20 = require("zod");
|
1683
1785
|
|
1684
1786
|
// ../commons/src/events/ActionDocument.ts
|
1685
|
-
var
|
1686
|
-
var
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1787
|
+
var import_zod18 = require("zod");
|
1788
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1789
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod18.z);
|
1790
|
+
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1791
|
+
var ActionStatus = {
|
1792
|
+
Requested: "Requested",
|
1793
|
+
Accepted: "Accepted",
|
1794
|
+
Rejected: "Rejected"
|
1795
|
+
};
|
1796
|
+
var ActionBase = import_zod18.z.object({
|
1797
|
+
id: import_zod18.z.string(),
|
1798
|
+
transactionId: import_zod18.z.string(),
|
1799
|
+
createdAt: import_zod18.z.string().datetime(),
|
1800
|
+
createdBy: import_zod18.z.string(),
|
1801
|
+
createdByRole: import_zod18.z.string(),
|
1802
|
+
declaration: ActionUpdate,
|
1803
|
+
annotation: ActionUpdate.optional(),
|
1804
|
+
createdAtLocation: import_zod18.z.string().optional(),
|
1805
|
+
updatedAtLocation: import_zod18.z.string().optional(),
|
1806
|
+
status: import_zod18.z.enum([
|
1807
|
+
ActionStatus.Requested,
|
1808
|
+
ActionStatus.Accepted,
|
1809
|
+
ActionStatus.Rejected
|
1810
|
+
]),
|
1811
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1812
|
+
originalActionId: import_zod18.z.string().optional()
|
1694
1813
|
});
|
1695
1814
|
var AssignedAction = ActionBase.merge(
|
1696
|
-
|
1697
|
-
type:
|
1698
|
-
assignedTo:
|
1815
|
+
import_zod18.z.object({
|
1816
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1817
|
+
assignedTo: import_zod18.z.string()
|
1699
1818
|
})
|
1700
1819
|
);
|
1701
1820
|
var UnassignedAction = ActionBase.merge(
|
1702
|
-
|
1703
|
-
type:
|
1821
|
+
import_zod18.z.object({
|
1822
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1823
|
+
assignedTo: import_zod18.z.literal(null)
|
1704
1824
|
})
|
1705
1825
|
);
|
1706
1826
|
var RegisterAction = ActionBase.merge(
|
1707
|
-
|
1708
|
-
type:
|
1709
|
-
|
1710
|
-
trackingId: import_zod19.z.string(),
|
1711
|
-
registrationNumber: import_zod19.z.string()
|
1712
|
-
})
|
1827
|
+
import_zod18.z.object({
|
1828
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1829
|
+
registrationNumber: import_zod18.z.string().optional()
|
1713
1830
|
})
|
1714
1831
|
);
|
1715
1832
|
var DeclareAction = ActionBase.merge(
|
1716
|
-
|
1717
|
-
type:
|
1833
|
+
import_zod18.z.object({
|
1834
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1718
1835
|
})
|
1719
1836
|
);
|
1720
1837
|
var ValidateAction = ActionBase.merge(
|
1721
|
-
|
1722
|
-
type:
|
1838
|
+
import_zod18.z.object({
|
1839
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1723
1840
|
})
|
1724
1841
|
);
|
1725
1842
|
var RejectAction = ActionBase.merge(
|
1726
|
-
|
1727
|
-
type:
|
1843
|
+
import_zod18.z.object({
|
1844
|
+
type: import_zod18.z.literal(ActionType.REJECT)
|
1728
1845
|
})
|
1729
1846
|
);
|
1730
1847
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1731
|
-
|
1732
|
-
type:
|
1848
|
+
import_zod18.z.object({
|
1849
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1733
1850
|
})
|
1734
1851
|
);
|
1735
1852
|
var ArchiveAction = ActionBase.merge(
|
1736
|
-
|
1737
|
-
type:
|
1853
|
+
import_zod18.z.object({
|
1854
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE)
|
1738
1855
|
})
|
1739
1856
|
);
|
1740
1857
|
var CreatedAction = ActionBase.merge(
|
1741
|
-
|
1742
|
-
type:
|
1858
|
+
import_zod18.z.object({
|
1859
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1743
1860
|
})
|
1744
1861
|
);
|
1745
1862
|
var NotifiedAction = ActionBase.merge(
|
1746
|
-
|
1747
|
-
type:
|
1863
|
+
import_zod18.z.object({
|
1864
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1748
1865
|
})
|
1749
1866
|
);
|
1750
1867
|
var PrintCertificateAction = ActionBase.merge(
|
1751
|
-
|
1752
|
-
type:
|
1868
|
+
import_zod18.z.object({
|
1869
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1753
1870
|
})
|
1754
1871
|
);
|
1755
1872
|
var RequestedCorrectionAction = ActionBase.merge(
|
1756
|
-
|
1757
|
-
type:
|
1873
|
+
import_zod18.z.object({
|
1874
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1758
1875
|
})
|
1759
1876
|
);
|
1760
1877
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1761
|
-
|
1762
|
-
type:
|
1763
|
-
requestId:
|
1878
|
+
import_zod18.z.object({
|
1879
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1880
|
+
requestId: import_zod18.z.string()
|
1764
1881
|
})
|
1765
1882
|
);
|
1766
1883
|
var RejectedCorrectionAction = ActionBase.merge(
|
1767
|
-
|
1768
|
-
type:
|
1769
|
-
requestId:
|
1884
|
+
import_zod18.z.object({
|
1885
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1886
|
+
requestId: import_zod18.z.string()
|
1770
1887
|
})
|
1771
1888
|
);
|
1772
|
-
var
|
1773
|
-
|
1774
|
-
type:
|
1889
|
+
var ReadAction = ActionBase.merge(
|
1890
|
+
import_zod18.z.object({
|
1891
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1775
1892
|
})
|
1776
1893
|
);
|
1777
|
-
var ActionDocument =
|
1778
|
-
CreatedAction,
|
1779
|
-
ValidateAction,
|
1780
|
-
RejectAction,
|
1781
|
-
MarkAsDuplicateAction,
|
1782
|
-
ArchiveAction,
|
1783
|
-
NotifiedAction,
|
1784
|
-
RegisterAction,
|
1785
|
-
DeclareAction,
|
1786
|
-
AssignedAction,
|
1787
|
-
RequestedCorrectionAction,
|
1788
|
-
ApprovedCorrectionAction,
|
1789
|
-
RejectedCorrectionAction,
|
1790
|
-
UnassignedAction,
|
1791
|
-
PrintCertificateAction,
|
1792
|
-
|
1793
|
-
])
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1894
|
+
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1895
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1896
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1897
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1898
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1899
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1900
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1901
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1902
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1903
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1904
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1905
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1906
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1907
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1908
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1909
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1910
|
+
]).openapi({
|
1911
|
+
ref: "ActionDocument"
|
1912
|
+
});
|
1913
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1914
|
+
declaration: true,
|
1915
|
+
annotation: true,
|
1916
|
+
createdBy: true,
|
1917
|
+
createdByRole: true,
|
1918
|
+
createdAtLocation: true
|
1919
|
+
}).merge(
|
1920
|
+
import_zod18.z.object({
|
1921
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1922
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1923
|
+
})
|
1924
|
+
);
|
1925
|
+
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1926
|
+
var ResolvedUser = import_zod18.z.object({
|
1927
|
+
id: import_zod18.z.string(),
|
1928
|
+
role: import_zod18.z.string(),
|
1929
|
+
name: import_zod18.z.array(
|
1930
|
+
import_zod18.z.object({
|
1931
|
+
use: import_zod18.z.string(),
|
1932
|
+
given: import_zod18.z.array(import_zod18.z.string()),
|
1933
|
+
family: import_zod18.z.string()
|
1802
1934
|
})
|
1803
1935
|
)
|
1804
1936
|
});
|
1805
1937
|
|
1806
1938
|
// ../commons/src/events/ActionInput.ts
|
1807
|
-
var
|
1808
|
-
var
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1939
|
+
var import_zod19 = require("zod");
|
1940
|
+
var import_zod_openapi5 = require("zod-openapi");
|
1941
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod19.z);
|
1942
|
+
var BaseActionInput = import_zod19.z.object({
|
1943
|
+
eventId: import_zod19.z.string(),
|
1944
|
+
transactionId: import_zod19.z.string(),
|
1945
|
+
declaration: ActionUpdate.default({}),
|
1946
|
+
annotation: ActionUpdate.optional(),
|
1947
|
+
originalActionId: import_zod19.z.string().optional(),
|
1948
|
+
keepAssignment: import_zod19.z.boolean().optional()
|
1813
1949
|
});
|
1814
1950
|
var CreateActionInput = BaseActionInput.merge(
|
1815
|
-
|
1816
|
-
type:
|
1817
|
-
createdAtLocation:
|
1951
|
+
import_zod19.z.object({
|
1952
|
+
type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1953
|
+
createdAtLocation: import_zod19.z.string()
|
1818
1954
|
})
|
1819
1955
|
);
|
1820
1956
|
var RegisterActionInput = BaseActionInput.merge(
|
1821
|
-
|
1822
|
-
type:
|
1823
|
-
|
1824
|
-
trackingId: import_zod20.z.string(),
|
1825
|
-
registrationNumber: import_zod20.z.string()
|
1826
|
-
})
|
1957
|
+
import_zod19.z.object({
|
1958
|
+
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1959
|
+
registrationNumber: import_zod19.z.string().optional()
|
1827
1960
|
})
|
1828
1961
|
);
|
1829
1962
|
var ValidateActionInput = BaseActionInput.merge(
|
1830
|
-
|
1831
|
-
type:
|
1832
|
-
duplicates:
|
1963
|
+
import_zod19.z.object({
|
1964
|
+
type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1965
|
+
duplicates: import_zod19.z.array(import_zod19.z.string())
|
1833
1966
|
})
|
1834
1967
|
);
|
1835
1968
|
var NotifyActionInput = BaseActionInput.merge(
|
1836
|
-
|
1837
|
-
type:
|
1969
|
+
import_zod19.z.object({
|
1970
|
+
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1838
1971
|
})
|
1839
1972
|
);
|
1840
1973
|
var DeclareActionInput = BaseActionInput.merge(
|
1841
|
-
|
1842
|
-
type:
|
1974
|
+
import_zod19.z.object({
|
1975
|
+
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1843
1976
|
})
|
1844
1977
|
);
|
1845
1978
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1846
|
-
|
1847
|
-
type:
|
1979
|
+
import_zod19.z.object({
|
1980
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1848
1981
|
})
|
1849
1982
|
);
|
1850
1983
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1851
|
-
|
1852
|
-
type:
|
1984
|
+
import_zod19.z.object({
|
1985
|
+
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1853
1986
|
})
|
1854
1987
|
);
|
1855
1988
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1856
|
-
|
1857
|
-
type:
|
1989
|
+
import_zod19.z.object({
|
1990
|
+
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1858
1991
|
})
|
1859
1992
|
);
|
1860
1993
|
var ArchiveActionInput = BaseActionInput.merge(
|
1861
|
-
|
1862
|
-
type:
|
1994
|
+
import_zod19.z.object({
|
1995
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1863
1996
|
})
|
1864
1997
|
);
|
1865
1998
|
var AssignActionInput = BaseActionInput.merge(
|
1866
|
-
|
1867
|
-
type:
|
1868
|
-
assignedTo:
|
1999
|
+
import_zod19.z.object({
|
2000
|
+
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2001
|
+
assignedTo: import_zod19.z.string()
|
1869
2002
|
})
|
1870
2003
|
);
|
1871
2004
|
var UnassignActionInput = BaseActionInput.merge(
|
1872
|
-
|
1873
|
-
type:
|
2005
|
+
import_zod19.z.object({
|
2006
|
+
type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2007
|
+
assignedTo: import_zod19.z.literal(null).default(null)
|
1874
2008
|
})
|
1875
2009
|
);
|
1876
2010
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1877
|
-
|
1878
|
-
type:
|
2011
|
+
import_zod19.z.object({
|
2012
|
+
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1879
2013
|
})
|
1880
2014
|
);
|
1881
2015
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1882
|
-
|
1883
|
-
requestId:
|
1884
|
-
type:
|
2016
|
+
import_zod19.z.object({
|
2017
|
+
requestId: import_zod19.z.string(),
|
2018
|
+
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1885
2019
|
})
|
1886
2020
|
);
|
1887
2021
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1888
|
-
|
1889
|
-
requestId:
|
1890
|
-
type:
|
2022
|
+
import_zod19.z.object({
|
2023
|
+
requestId: import_zod19.z.string(),
|
2024
|
+
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1891
2025
|
})
|
1892
2026
|
);
|
1893
|
-
var
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
2027
|
+
var ReadActionInput = BaseActionInput.merge(
|
2028
|
+
import_zod19.z.object({
|
2029
|
+
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
2030
|
+
})
|
2031
|
+
);
|
2032
|
+
var DeleteActionInput = import_zod19.z.object({ eventId: import_zod19.z.string() });
|
2033
|
+
var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
2034
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2035
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2036
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2037
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2038
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2039
|
+
RejectDeclarationActionInput.openapi({
|
2040
|
+
ref: "RejectDeclarationActionInput"
|
2041
|
+
}),
|
2042
|
+
MarkedAsDuplicateActionInput.openapi({
|
2043
|
+
ref: "MarkedAsDuplicateActionInput"
|
2044
|
+
}),
|
2045
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2046
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2047
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2048
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2049
|
+
RequestCorrectionActionInput.openapi({
|
2050
|
+
ref: "RequestCorrectionActionInput"
|
2051
|
+
}),
|
2052
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2053
|
+
ApproveCorrectionActionInput.openapi({
|
2054
|
+
ref: "ApproveCorrectionActionInput"
|
2055
|
+
}),
|
2056
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2057
|
+
]).openapi({
|
2058
|
+
ref: "ActionInput"
|
2059
|
+
});
|
1909
2060
|
|
1910
2061
|
// ../commons/src/events/Draft.ts
|
1911
|
-
var Draft =
|
1912
|
-
id:
|
1913
|
-
eventId:
|
1914
|
-
transactionId:
|
1915
|
-
createdAt:
|
2062
|
+
var Draft = import_zod20.z.object({
|
2063
|
+
id: import_zod20.z.string(),
|
2064
|
+
eventId: import_zod20.z.string(),
|
2065
|
+
transactionId: import_zod20.z.string(),
|
2066
|
+
createdAt: import_zod20.z.string().datetime(),
|
1916
2067
|
action: ActionBase.extend({
|
1917
|
-
type:
|
2068
|
+
type: ActionTypes
|
1918
2069
|
}).omit({ id: true })
|
1919
2070
|
});
|
1920
2071
|
var DraftInput = BaseActionInput.extend({
|
1921
|
-
type:
|
2072
|
+
type: ActionTypes
|
2073
|
+
});
|
2074
|
+
|
2075
|
+
// ../commons/src/events/EventMetadata.ts
|
2076
|
+
var import_zod21 = require("zod");
|
2077
|
+
var EventStatus = {
|
2078
|
+
CREATED: "CREATED",
|
2079
|
+
NOTIFIED: "NOTIFIED",
|
2080
|
+
DECLARED: "DECLARED",
|
2081
|
+
VALIDATED: "VALIDATED",
|
2082
|
+
REGISTERED: "REGISTERED",
|
2083
|
+
CERTIFIED: "CERTIFIED",
|
2084
|
+
REJECTED: "REJECTED",
|
2085
|
+
ARCHIVED: "ARCHIVED"
|
2086
|
+
};
|
2087
|
+
var eventStatuses = Object.values(EventStatus);
|
2088
|
+
var EventStatuses = import_zod21.z.nativeEnum(EventStatus);
|
2089
|
+
var ZodDate = import_zod21.z.string().date();
|
2090
|
+
var EventMetadata = import_zod21.z.object({
|
2091
|
+
id: import_zod21.z.string(),
|
2092
|
+
type: import_zod21.z.string(),
|
2093
|
+
status: EventStatuses,
|
2094
|
+
createdAt: import_zod21.z.string().datetime(),
|
2095
|
+
dateOfEvent: ZodDate.nullish(),
|
2096
|
+
createdBy: import_zod21.z.string(),
|
2097
|
+
updatedByUserRole: import_zod21.z.string(),
|
2098
|
+
createdAtLocation: import_zod21.z.string(),
|
2099
|
+
updatedAtLocation: import_zod21.z.string(),
|
2100
|
+
updatedAt: import_zod21.z.string().datetime(),
|
2101
|
+
assignedTo: import_zod21.z.string().nullish(),
|
2102
|
+
updatedBy: import_zod21.z.string(),
|
2103
|
+
trackingId: import_zod21.z.string(),
|
2104
|
+
registrationNumber: import_zod21.z.string().nullish()
|
1922
2105
|
});
|
2106
|
+
var eventMetadataLabelMap = {
|
2107
|
+
"event.assignedTo": {
|
2108
|
+
id: "event.assignedTo.label",
|
2109
|
+
defaultMessage: "Assigned To",
|
2110
|
+
description: "Assigned To"
|
2111
|
+
},
|
2112
|
+
"event.createdAt": {
|
2113
|
+
id: "event.createdAt.label",
|
2114
|
+
defaultMessage: "Created",
|
2115
|
+
description: "Created At"
|
2116
|
+
},
|
2117
|
+
"event.dateOfEvent": {
|
2118
|
+
id: "event.dateOfEvent.label",
|
2119
|
+
defaultMessage: "Date of Event",
|
2120
|
+
description: "Date of Event"
|
2121
|
+
},
|
2122
|
+
"event.createdAtLocation": {
|
2123
|
+
id: "event.createdAtLocation.label",
|
2124
|
+
defaultMessage: "Location",
|
2125
|
+
description: "Created At Location"
|
2126
|
+
},
|
2127
|
+
"event.updatedAtLocation": {
|
2128
|
+
id: "event.updatedAtLocation.label",
|
2129
|
+
defaultMessage: "Location",
|
2130
|
+
description: "Updated At Location"
|
2131
|
+
},
|
2132
|
+
"event.createdBy": {
|
2133
|
+
id: "event.createdBy.label",
|
2134
|
+
defaultMessage: "Created By",
|
2135
|
+
description: "Created By"
|
2136
|
+
},
|
2137
|
+
"event.updatedByUserRole": {
|
2138
|
+
id: "event.updatedByUserRole.label",
|
2139
|
+
defaultMessage: "Updated By Role",
|
2140
|
+
description: "Updated By Role"
|
2141
|
+
},
|
2142
|
+
"event.id": {
|
2143
|
+
id: "event.id.label",
|
2144
|
+
defaultMessage: "ID",
|
2145
|
+
description: "ID"
|
2146
|
+
},
|
2147
|
+
"event.updatedAt": {
|
2148
|
+
id: "event.modifiedAt.label",
|
2149
|
+
defaultMessage: "Updated",
|
2150
|
+
description: "Modified At"
|
2151
|
+
},
|
2152
|
+
"event.status": {
|
2153
|
+
id: "event.status.label",
|
2154
|
+
defaultMessage: "Status",
|
2155
|
+
description: "Status"
|
2156
|
+
},
|
2157
|
+
"event.type": {
|
2158
|
+
id: "event.type.label",
|
2159
|
+
defaultMessage: "Type",
|
2160
|
+
description: "Type"
|
2161
|
+
},
|
2162
|
+
"event.updatedBy": {
|
2163
|
+
id: "event.updatedBy.label",
|
2164
|
+
defaultMessage: "Updated By",
|
2165
|
+
description: "Updated By"
|
2166
|
+
},
|
2167
|
+
"event.trackingId": {
|
2168
|
+
id: "event.trackingId.label",
|
2169
|
+
defaultMessage: "Tracking ID",
|
2170
|
+
description: "Tracking ID"
|
2171
|
+
},
|
2172
|
+
"event.registrationNumber": {
|
2173
|
+
id: "event.registrationNumber.label",
|
2174
|
+
defaultMessage: "Registration Number",
|
2175
|
+
description: "Registration Number"
|
2176
|
+
}
|
2177
|
+
};
|
1923
2178
|
|
1924
2179
|
// ../commons/src/events/EventInput.ts
|
1925
2180
|
var import_zod22 = require("zod");
|
1926
2181
|
var EventInput = import_zod22.z.object({
|
1927
2182
|
transactionId: import_zod22.z.string(),
|
1928
|
-
type: import_zod22.z.string()
|
2183
|
+
type: import_zod22.z.string(),
|
2184
|
+
dateOfEvent: import_zod22.z.object({ fieldId: import_zod22.z.string() }).optional()
|
1929
2185
|
});
|
1930
2186
|
|
1931
2187
|
// ../commons/src/events/EventDocument.ts
|
1932
2188
|
var import_zod23 = require("zod");
|
2189
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2190
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod23.z);
|
1933
2191
|
var EventDocument = import_zod23.z.object({
|
1934
2192
|
id: import_zod23.z.string(),
|
1935
2193
|
type: import_zod23.z.string(),
|
2194
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional(),
|
1936
2195
|
createdAt: import_zod23.z.string().datetime(),
|
1937
2196
|
updatedAt: import_zod23.z.string().datetime(),
|
1938
|
-
|
2197
|
+
updatedAtLocation: import_zod23.z.string(),
|
2198
|
+
actions: import_zod23.z.array(Action),
|
1939
2199
|
trackingId: import_zod23.z.string()
|
1940
|
-
});
|
2200
|
+
}).openapi({ ref: "EventDocument" });
|
1941
2201
|
|
1942
2202
|
// ../commons/src/events/EventIndex.ts
|
1943
2203
|
var import_zod24 = require("zod");
|
1944
2204
|
var EventIndex = EventMetadata.extend({
|
1945
|
-
|
2205
|
+
declaration: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
|
1946
2206
|
});
|
1947
2207
|
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
1948
2208
|
import_zod24.z.object({
|
@@ -1950,35 +2210,94 @@ var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod
|
|
1950
2210
|
// Ensures "type" (event-id) exists and is a string
|
1951
2211
|
})
|
1952
2212
|
);
|
2213
|
+
var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() });
|
2214
|
+
var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() });
|
2215
|
+
var AnyOf = import_zod24.z.object({
|
2216
|
+
type: import_zod24.z.literal("anyOf"),
|
2217
|
+
terms: import_zod24.z.array(import_zod24.z.string())
|
2218
|
+
});
|
2219
|
+
var Range = import_zod24.z.object({
|
2220
|
+
type: import_zod24.z.literal("range"),
|
2221
|
+
gte: import_zod24.z.string(),
|
2222
|
+
lte: import_zod24.z.string()
|
2223
|
+
});
|
2224
|
+
var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() });
|
2225
|
+
var DateCondition = import_zod24.z.union([Exact, Range]);
|
2226
|
+
var QueryInput = import_zod24.z.lazy(
|
2227
|
+
() => import_zod24.z.union([
|
2228
|
+
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
2229
|
+
import_zod24.z.record(import_zod24.z.string(), QueryInput)
|
2230
|
+
])
|
2231
|
+
);
|
2232
|
+
var QueryExpression = import_zod24.z.object({
|
2233
|
+
type: import_zod24.z.literal("and"),
|
2234
|
+
eventType: import_zod24.z.string(),
|
2235
|
+
status: import_zod24.z.optional(import_zod24.z.union([AnyOf, Exact])),
|
2236
|
+
createdAt: import_zod24.z.optional(DateCondition),
|
2237
|
+
updatedAt: import_zod24.z.optional(DateCondition),
|
2238
|
+
createAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
2239
|
+
updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
2240
|
+
createdBy: import_zod24.z.optional(Exact),
|
2241
|
+
updatedBy: import_zod24.z.optional(Exact),
|
2242
|
+
trackingId: import_zod24.z.optional(Exact),
|
2243
|
+
data: QueryInput
|
2244
|
+
}).partial();
|
2245
|
+
var Or2 = import_zod24.z.object({
|
2246
|
+
type: import_zod24.z.literal("or"),
|
2247
|
+
clauses: import_zod24.z.array(QueryExpression)
|
2248
|
+
});
|
2249
|
+
var QueryType = import_zod24.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
1953
2250
|
|
1954
2251
|
// ../commons/src/events/state/index.ts
|
1955
|
-
var _ = __toESM(require("lodash"));
|
1956
2252
|
function getStatusFromActions(actions) {
|
2253
|
+
const hasRejectedAction = actions.some(
|
2254
|
+
(a) => a.status === ActionStatus.Rejected
|
2255
|
+
);
|
2256
|
+
if (hasRejectedAction) {
|
2257
|
+
return EventStatus.REJECTED;
|
2258
|
+
}
|
1957
2259
|
return actions.reduce((status, action) => {
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
2260
|
+
switch (action.type) {
|
2261
|
+
case ActionType.CREATE:
|
2262
|
+
return EventStatus.CREATED;
|
2263
|
+
case ActionType.DECLARE:
|
2264
|
+
return EventStatus.DECLARED;
|
2265
|
+
case ActionType.VALIDATE:
|
2266
|
+
return EventStatus.VALIDATED;
|
2267
|
+
case ActionType.REGISTER:
|
2268
|
+
return EventStatus.REGISTERED;
|
2269
|
+
case ActionType.REJECT:
|
2270
|
+
return EventStatus.REJECTED;
|
2271
|
+
case ActionType.ARCHIVE:
|
2272
|
+
return EventStatus.ARCHIVED;
|
2273
|
+
case ActionType.NOTIFY:
|
2274
|
+
return EventStatus.NOTIFIED;
|
2275
|
+
case ActionType.PRINT_CERTIFICATE:
|
2276
|
+
return EventStatus.CERTIFIED;
|
2277
|
+
case ActionType.ASSIGN:
|
2278
|
+
case ActionType.UNASSIGN:
|
2279
|
+
case ActionType.REQUEST_CORRECTION:
|
2280
|
+
case ActionType.APPROVE_CORRECTION:
|
2281
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2282
|
+
case ActionType.REJECT_CORRECTION:
|
2283
|
+
case ActionType.READ:
|
2284
|
+
default:
|
2285
|
+
return status;
|
1978
2286
|
}
|
1979
|
-
return status;
|
1980
2287
|
}, EventStatus.CREATED);
|
1981
2288
|
}
|
2289
|
+
function getLastUpdatedByUserRoleFromActions(actions) {
|
2290
|
+
const actionsWithRoles = actions.filter(
|
2291
|
+
(action) => !isWriteAction(action.type) && action.status !== ActionStatus.Rejected
|
2292
|
+
).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2293
|
+
const lastAction = actionsWithRoles.at(-1);
|
2294
|
+
if (!lastAction) {
|
2295
|
+
throw new Error(
|
2296
|
+
"Should never happen, at least CREATE action should be present"
|
2297
|
+
);
|
2298
|
+
}
|
2299
|
+
return ActionDocument.parse(lastAction).createdByRole;
|
2300
|
+
}
|
1982
2301
|
function getAssignedUserFromActions(actions) {
|
1983
2302
|
return actions.reduce((user2, action) => {
|
1984
2303
|
if (action.type === ActionType.ASSIGN) {
|
@@ -1990,7 +2309,7 @@ function getAssignedUserFromActions(actions) {
|
|
1990
2309
|
return user2;
|
1991
2310
|
}, null);
|
1992
2311
|
}
|
1993
|
-
function
|
2312
|
+
function aggregateActionDeclarations(actions) {
|
1994
2313
|
const excludedActions = [
|
1995
2314
|
ActionType.REQUEST_CORRECTION,
|
1996
2315
|
ActionType.PRINT_CERTIFICATE
|
@@ -2004,47 +2323,35 @@ function getData(actions) {
|
|
2004
2323
|
if (!requestAction) {
|
2005
2324
|
return status;
|
2006
2325
|
}
|
2007
|
-
return deepMerge(status, requestAction.
|
2326
|
+
return deepMerge(status, requestAction.declaration);
|
2008
2327
|
}
|
2009
|
-
return deepMerge(status, action.
|
2328
|
+
return deepMerge(status, action.declaration);
|
2010
2329
|
}, {});
|
2011
2330
|
}
|
2012
2331
|
function deepDropNulls(obj) {
|
2013
|
-
if (
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
[key]
|
2022
|
-
};
|
2023
|
-
}
|
2024
|
-
return acc;
|
2025
|
-
}, {});
|
2026
|
-
}
|
2027
|
-
function deepMerge(currentDocument, actionDocument) {
|
2028
|
-
return _.mergeWith(
|
2029
|
-
currentDocument,
|
2030
|
-
actionDocument,
|
2031
|
-
(previousValue, incomingValue) => {
|
2032
|
-
if (incomingValue === void 0) {
|
2033
|
-
return previousValue;
|
2034
|
-
}
|
2035
|
-
if (_.isArray(incomingValue)) {
|
2036
|
-
return incomingValue;
|
2037
|
-
}
|
2038
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2039
|
-
return void 0;
|
2332
|
+
if (Array.isArray(obj)) {
|
2333
|
+
return obj.map(deepDropNulls);
|
2334
|
+
}
|
2335
|
+
if (obj !== null && typeof obj === "object") {
|
2336
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2337
|
+
const cleanedValue = deepDropNulls(value);
|
2338
|
+
if (cleanedValue !== null) {
|
2339
|
+
;
|
2340
|
+
acc[key] = cleanedValue;
|
2040
2341
|
}
|
2041
|
-
return
|
2042
|
-
}
|
2043
|
-
|
2342
|
+
return acc;
|
2343
|
+
}, {});
|
2344
|
+
}
|
2345
|
+
return obj;
|
2044
2346
|
}
|
2045
2347
|
function isUndeclaredDraft(status) {
|
2046
2348
|
return status === EventStatus.CREATED;
|
2047
2349
|
}
|
2350
|
+
function getAcceptedActions(event2) {
|
2351
|
+
return event2.actions.filter(
|
2352
|
+
(a) => a.status === ActionStatus.Accepted
|
2353
|
+
);
|
2354
|
+
}
|
2048
2355
|
function getCurrentEventState(event2) {
|
2049
2356
|
const creationAction = event2.actions.find(
|
2050
2357
|
(action) => action.type === ActionType.CREATE
|
@@ -2052,19 +2359,35 @@ function getCurrentEventState(event2) {
|
|
2052
2359
|
if (!creationAction) {
|
2053
2360
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2054
2361
|
}
|
2055
|
-
const
|
2362
|
+
const activeActions = getAcceptedActions(event2);
|
2363
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2364
|
+
const registrationAction = activeActions.find(
|
2365
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2366
|
+
);
|
2367
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2368
|
+
const declaration = aggregateActionDeclarations(activeActions);
|
2369
|
+
let dateOfEvent = event2.createdAt.split("T")[0];
|
2370
|
+
if (event2.dateOfEvent) {
|
2371
|
+
const parsedDate = ZodDate.safeParse(declaration[event2.dateOfEvent.fieldId]);
|
2372
|
+
dateOfEvent = parsedDate.success ? parsedDate.data : null;
|
2373
|
+
}
|
2056
2374
|
return deepDropNulls({
|
2057
2375
|
id: event2.id,
|
2058
2376
|
type: event2.type,
|
2059
2377
|
status: getStatusFromActions(event2.actions),
|
2060
2378
|
createdAt: event2.createdAt,
|
2061
2379
|
createdBy: creationAction.createdBy,
|
2062
|
-
createdAtLocation: creationAction.createdAtLocation,
|
2063
|
-
|
2064
|
-
|
2380
|
+
createdAtLocation: creationAction.createdAtLocation ?? "",
|
2381
|
+
// @todo remove using empty string
|
2382
|
+
updatedAt: latestAction.createdAt,
|
2383
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2065
2384
|
updatedBy: latestAction.createdBy,
|
2066
|
-
|
2067
|
-
|
2385
|
+
updatedAtLocation: event2.updatedAtLocation,
|
2386
|
+
declaration,
|
2387
|
+
trackingId: event2.trackingId,
|
2388
|
+
registrationNumber,
|
2389
|
+
updatedByUserRole: getLastUpdatedByUserRoleFromActions(event2.actions),
|
2390
|
+
dateOfEvent
|
2068
2391
|
});
|
2069
2392
|
}
|
2070
2393
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2089,45 +2412,50 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
|
|
2089
2412
|
return getCurrentEventState(withDrafts);
|
2090
2413
|
}
|
2091
2414
|
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2092
|
-
const indexedAt = eventIndex.
|
2415
|
+
const indexedAt = eventIndex.updatedAt;
|
2093
2416
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2094
2417
|
if (activeDrafts.length === 0) {
|
2095
2418
|
return eventIndex;
|
2096
2419
|
}
|
2097
2420
|
return {
|
2098
2421
|
...eventIndex,
|
2099
|
-
|
2100
|
-
...eventIndex.
|
2101
|
-
...activeDrafts[activeDrafts.length - 1].
|
2422
|
+
declaration: {
|
2423
|
+
...eventIndex.declaration,
|
2424
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2102
2425
|
}
|
2103
2426
|
};
|
2104
2427
|
}
|
2105
|
-
function
|
2428
|
+
function getAnnotationFromDrafts(drafts) {
|
2429
|
+
const actions = drafts.map((draft) => draft.action);
|
2430
|
+
const annotation = actions.reduce((ann, action) => {
|
2431
|
+
return deepMerge(ann, action.annotation ?? {});
|
2432
|
+
}, {});
|
2433
|
+
return deepDropNulls(annotation);
|
2434
|
+
}
|
2435
|
+
function getActionAnnotation({
|
2106
2436
|
event: event2,
|
2107
2437
|
actionType,
|
2108
|
-
drafts
|
2438
|
+
drafts = []
|
2109
2439
|
}) {
|
2110
|
-
const
|
2440
|
+
const activeActions = getAcceptedActions(event2);
|
2441
|
+
const action = activeActions.find(
|
2442
|
+
(activeAction) => actionType === activeAction.type
|
2443
|
+
);
|
2111
2444
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2112
2445
|
const sorted = [
|
2113
2446
|
...action ? [action] : [],
|
2114
2447
|
...eventDrafts.map((draft) => draft.action)
|
2115
2448
|
].sort();
|
2116
|
-
const
|
2117
|
-
return deepMerge(
|
2449
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2450
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2118
2451
|
}, {});
|
2119
|
-
return deepDropNulls(
|
2452
|
+
return deepDropNulls(annotation);
|
2120
2453
|
}
|
2121
2454
|
|
2122
2455
|
// ../commons/src/events/defineConfig.ts
|
2123
2456
|
var defineConfig = (config) => {
|
2124
|
-
validateWorkqueueConfig(config.workqueues);
|
2125
2457
|
const input = EventConfig.parse(config);
|
2126
|
-
|
2127
|
-
return EventConfig.parse({
|
2128
|
-
...input,
|
2129
|
-
pageFields
|
2130
|
-
});
|
2458
|
+
return input;
|
2131
2459
|
};
|
2132
2460
|
|
2133
2461
|
// ../commons/src/events/transactions.ts
|
@@ -2142,6 +2470,16 @@ var import_lodash2 = require("lodash");
|
|
2142
2470
|
function defineConditional(schema) {
|
2143
2471
|
return schema;
|
2144
2472
|
}
|
2473
|
+
function defineFormConditional(schema) {
|
2474
|
+
const schemaWithForm = {
|
2475
|
+
type: "object",
|
2476
|
+
properties: {
|
2477
|
+
$form: schema
|
2478
|
+
},
|
2479
|
+
required: ["$form"]
|
2480
|
+
};
|
2481
|
+
return defineConditional(schemaWithForm);
|
2482
|
+
}
|
2145
2483
|
function alwaysTrue() {
|
2146
2484
|
return {};
|
2147
2485
|
}
|
@@ -2166,6 +2504,9 @@ function not(condition) {
|
|
2166
2504
|
required: []
|
2167
2505
|
});
|
2168
2506
|
}
|
2507
|
+
function never() {
|
2508
|
+
return not(alwaysTrue());
|
2509
|
+
}
|
2169
2510
|
var user = {
|
2170
2511
|
hasScope: (scope) => defineConditional({
|
2171
2512
|
type: "object",
|
@@ -2187,95 +2528,148 @@ var user = {
|
|
2187
2528
|
required: ["$user"]
|
2188
2529
|
})
|
2189
2530
|
};
|
2190
|
-
|
2191
|
-
|
2531
|
+
function createEventConditionals() {
|
2532
|
+
return {
|
2533
|
+
/**
|
2534
|
+
* Checks if the event contains a specific action type.
|
2535
|
+
* @param action - The action type to check for.
|
2536
|
+
*/
|
2537
|
+
hasAction: (action) => defineConditional({
|
2538
|
+
type: "object",
|
2539
|
+
properties: {
|
2540
|
+
$event: {
|
2541
|
+
type: "object",
|
2542
|
+
properties: {
|
2543
|
+
actions: {
|
2544
|
+
type: "array",
|
2545
|
+
contains: {
|
2546
|
+
type: "object",
|
2547
|
+
properties: {
|
2548
|
+
type: {
|
2549
|
+
const: action
|
2550
|
+
}
|
2551
|
+
},
|
2552
|
+
required: ["type"]
|
2553
|
+
}
|
2554
|
+
}
|
2555
|
+
},
|
2556
|
+
required: ["actions"]
|
2557
|
+
}
|
2558
|
+
},
|
2559
|
+
required: ["$event"]
|
2560
|
+
})
|
2561
|
+
};
|
2562
|
+
}
|
2563
|
+
function getDateFromNow(days) {
|
2564
|
+
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
2565
|
+
}
|
2566
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
2567
|
+
return {
|
2192
2568
|
type: "object",
|
2193
2569
|
properties: {
|
2194
|
-
|
2195
|
-
type: "
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
type: "object",
|
2201
|
-
properties: {
|
2202
|
-
type: {
|
2203
|
-
const: action
|
2204
|
-
}
|
2205
|
-
},
|
2206
|
-
required: ["type"]
|
2207
|
-
}
|
2208
|
-
}
|
2209
|
-
},
|
2210
|
-
required: ["actions"]
|
2211
|
-
}
|
2570
|
+
[fieldId]: {
|
2571
|
+
type: "string",
|
2572
|
+
format: "date",
|
2573
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2574
|
+
},
|
2575
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2212
2576
|
},
|
2213
|
-
required: [
|
2214
|
-
}
|
2215
|
-
}
|
2216
|
-
function
|
2217
|
-
|
2577
|
+
required: [fieldId]
|
2578
|
+
};
|
2579
|
+
}
|
2580
|
+
function isFieldReference(value) {
|
2581
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2582
|
+
}
|
2583
|
+
function createFieldConditionals(fieldId) {
|
2218
2584
|
const getDateRange = (date, clause) => ({
|
2219
2585
|
type: "object",
|
2220
2586
|
properties: {
|
2221
|
-
|
2222
|
-
type: "
|
2223
|
-
|
2224
|
-
|
2225
|
-
type: "string",
|
2226
|
-
format: "date",
|
2227
|
-
[clause]: date
|
2228
|
-
}
|
2229
|
-
},
|
2230
|
-
required: [fieldId]
|
2587
|
+
[fieldId]: {
|
2588
|
+
type: "string",
|
2589
|
+
format: "date",
|
2590
|
+
[clause]: date
|
2231
2591
|
}
|
2232
2592
|
},
|
2233
|
-
required: [
|
2593
|
+
required: [fieldId]
|
2234
2594
|
});
|
2235
2595
|
return {
|
2236
2596
|
isAfter: () => ({
|
2237
2597
|
days: (days) => ({
|
2238
|
-
inPast: () =>
|
2598
|
+
inPast: () => defineFormConditional(
|
2239
2599
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2240
2600
|
),
|
2241
|
-
inFuture: () =>
|
2601
|
+
inFuture: () => defineFormConditional(
|
2242
2602
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2243
2603
|
)
|
2244
2604
|
}),
|
2245
|
-
date: (date) =>
|
2246
|
-
|
2605
|
+
date: (date) => {
|
2606
|
+
if (isFieldReference(date)) {
|
2607
|
+
const comparedFieldId = date._fieldId;
|
2608
|
+
return defineFormConditional(
|
2609
|
+
getDateRangeToFieldReference(
|
2610
|
+
fieldId,
|
2611
|
+
comparedFieldId,
|
2612
|
+
"formatMinimum"
|
2613
|
+
)
|
2614
|
+
);
|
2615
|
+
}
|
2616
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
2617
|
+
},
|
2618
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
|
2247
2619
|
}),
|
2248
2620
|
isBefore: () => ({
|
2249
2621
|
days: (days) => ({
|
2250
|
-
inPast: () =>
|
2622
|
+
inPast: () => defineFormConditional(
|
2251
2623
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2252
2624
|
),
|
2253
|
-
inFuture: () =>
|
2625
|
+
inFuture: () => defineFormConditional(
|
2254
2626
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2255
2627
|
)
|
2256
2628
|
}),
|
2257
|
-
date: (date) =>
|
2258
|
-
|
2629
|
+
date: (date) => {
|
2630
|
+
if (isFieldReference(date)) {
|
2631
|
+
const comparedFieldId = date._fieldId;
|
2632
|
+
return defineFormConditional(
|
2633
|
+
getDateRangeToFieldReference(
|
2634
|
+
fieldId,
|
2635
|
+
comparedFieldId,
|
2636
|
+
"formatMaximum"
|
2637
|
+
)
|
2638
|
+
);
|
2639
|
+
}
|
2640
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
2641
|
+
},
|
2642
|
+
now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2259
2643
|
}),
|
2260
|
-
isEqualTo: (value) =>
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2644
|
+
isEqualTo: (value) => {
|
2645
|
+
if (isFieldReference(value)) {
|
2646
|
+
const comparedFieldId = value._fieldId;
|
2647
|
+
return defineFormConditional({
|
2264
2648
|
type: "object",
|
2265
2649
|
properties: {
|
2266
2650
|
[fieldId]: {
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
const: value
|
2272
|
-
}
|
2651
|
+
type: ["string", "boolean"],
|
2652
|
+
const: { $data: `1/${comparedFieldId}` }
|
2653
|
+
},
|
2654
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2273
2655
|
},
|
2274
|
-
required: [fieldId]
|
2275
|
-
}
|
2276
|
-
}
|
2277
|
-
|
2278
|
-
|
2656
|
+
required: [fieldId, comparedFieldId]
|
2657
|
+
});
|
2658
|
+
}
|
2659
|
+
return defineFormConditional({
|
2660
|
+
type: "object",
|
2661
|
+
properties: {
|
2662
|
+
[fieldId]: {
|
2663
|
+
oneOf: [
|
2664
|
+
{ type: "string", const: value },
|
2665
|
+
{ type: "boolean", const: value }
|
2666
|
+
],
|
2667
|
+
const: value
|
2668
|
+
}
|
2669
|
+
},
|
2670
|
+
required: [fieldId]
|
2671
|
+
});
|
2672
|
+
},
|
2279
2673
|
/**
|
2280
2674
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2281
2675
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2284,91 +2678,166 @@ function field(fieldId) {
|
|
2284
2678
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2285
2679
|
*
|
2286
2680
|
*/
|
2287
|
-
isFalsy: () =>
|
2681
|
+
isFalsy: () => defineFormConditional({
|
2682
|
+
type: "object",
|
2683
|
+
properties: {
|
2684
|
+
[fieldId]: {
|
2685
|
+
anyOf: [
|
2686
|
+
{ const: "undefined" },
|
2687
|
+
{ const: false },
|
2688
|
+
{ const: null },
|
2689
|
+
{ const: "" }
|
2690
|
+
]
|
2691
|
+
}
|
2692
|
+
},
|
2693
|
+
anyOf: [
|
2694
|
+
{
|
2695
|
+
required: [fieldId]
|
2696
|
+
},
|
2697
|
+
{
|
2698
|
+
not: {
|
2699
|
+
required: [fieldId]
|
2700
|
+
}
|
2701
|
+
}
|
2702
|
+
]
|
2703
|
+
}),
|
2704
|
+
isUndefined: () => defineFormConditional({
|
2705
|
+
type: "object",
|
2706
|
+
properties: {
|
2707
|
+
[fieldId]: {
|
2708
|
+
type: "string",
|
2709
|
+
enum: ["undefined"]
|
2710
|
+
}
|
2711
|
+
},
|
2712
|
+
not: {
|
2713
|
+
required: [fieldId]
|
2714
|
+
}
|
2715
|
+
}),
|
2716
|
+
inArray: (values) => defineFormConditional({
|
2717
|
+
type: "object",
|
2718
|
+
properties: {
|
2719
|
+
[fieldId]: {
|
2720
|
+
type: "string",
|
2721
|
+
enum: values
|
2722
|
+
}
|
2723
|
+
},
|
2724
|
+
required: [fieldId]
|
2725
|
+
}),
|
2726
|
+
isValidEnglishName: () => defineFormConditional({
|
2288
2727
|
type: "object",
|
2289
2728
|
properties: {
|
2290
|
-
|
2291
|
-
type: "
|
2292
|
-
|
2293
|
-
|
2294
|
-
anyOf: [
|
2295
|
-
{ const: "undefined" },
|
2296
|
-
{ const: false },
|
2297
|
-
{ const: null },
|
2298
|
-
{ const: "" }
|
2299
|
-
]
|
2300
|
-
}
|
2301
|
-
},
|
2302
|
-
anyOf: [
|
2303
|
-
{
|
2304
|
-
required: [fieldId]
|
2305
|
-
},
|
2306
|
-
{
|
2307
|
-
not: {
|
2308
|
-
required: [fieldId]
|
2309
|
-
}
|
2310
|
-
}
|
2311
|
-
]
|
2729
|
+
[fieldId]: {
|
2730
|
+
type: "string",
|
2731
|
+
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'._-]*)*$",
|
2732
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
2312
2733
|
}
|
2313
2734
|
},
|
2314
|
-
required: [
|
2735
|
+
required: [fieldId]
|
2315
2736
|
}),
|
2316
|
-
|
2737
|
+
/**
|
2738
|
+
* Checks if the field value matches a given regular expression pattern.
|
2739
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2740
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2741
|
+
*/
|
2742
|
+
matches: (pattern) => defineFormConditional({
|
2317
2743
|
type: "object",
|
2318
2744
|
properties: {
|
2319
|
-
|
2320
|
-
type: "
|
2321
|
-
|
2322
|
-
[fieldId]: {
|
2323
|
-
type: "string",
|
2324
|
-
enum: ["undefined"]
|
2325
|
-
}
|
2326
|
-
},
|
2327
|
-
not: {
|
2328
|
-
required: [fieldId]
|
2329
|
-
}
|
2745
|
+
[fieldId]: {
|
2746
|
+
type: "string",
|
2747
|
+
pattern
|
2330
2748
|
}
|
2331
2749
|
},
|
2332
|
-
required: [
|
2750
|
+
required: [fieldId]
|
2333
2751
|
}),
|
2334
|
-
|
2752
|
+
isBetween: (min, max) => defineFormConditional({
|
2335
2753
|
type: "object",
|
2336
2754
|
properties: {
|
2337
|
-
|
2338
|
-
type: "
|
2339
|
-
|
2340
|
-
|
2341
|
-
type: "string",
|
2342
|
-
enum: values
|
2343
|
-
}
|
2344
|
-
},
|
2345
|
-
required: [fieldId]
|
2755
|
+
[fieldId]: {
|
2756
|
+
type: "number",
|
2757
|
+
minimum: min,
|
2758
|
+
maximum: max
|
2346
2759
|
}
|
2347
2760
|
},
|
2348
|
-
required: [
|
2761
|
+
required: [fieldId]
|
2762
|
+
}),
|
2763
|
+
getId: () => ({ fieldId })
|
2764
|
+
};
|
2765
|
+
}
|
2766
|
+
|
2767
|
+
// ../commons/src/field-config/field-configuration.ts
|
2768
|
+
function createFieldConfigs(fieldId) {
|
2769
|
+
const baseField = {
|
2770
|
+
fieldId,
|
2771
|
+
fieldType: "field"
|
2772
|
+
};
|
2773
|
+
return {
|
2774
|
+
/**
|
2775
|
+
* Creates a range configuration for the specified field.
|
2776
|
+
*
|
2777
|
+
* @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
|
2778
|
+
*
|
2779
|
+
* @example field('age').range()
|
2780
|
+
* // {
|
2781
|
+
* // fieldId: 'age',
|
2782
|
+
* // config: { type: 'RANGE' }
|
2783
|
+
* // }
|
2784
|
+
*/
|
2785
|
+
range: () => ({
|
2786
|
+
...baseField,
|
2787
|
+
config: { type: "RANGE" }
|
2788
|
+
}),
|
2789
|
+
/**
|
2790
|
+
* Creates a configuration for exact matching of the specified field.
|
2791
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2792
|
+
* @example field('dob').exact()
|
2793
|
+
* // {
|
2794
|
+
* // fieldId: 'dob',
|
2795
|
+
* // config: { type: 'EXACT' }
|
2796
|
+
* // }
|
2797
|
+
*/
|
2798
|
+
exact: () => ({
|
2799
|
+
...baseField,
|
2800
|
+
config: { type: "EXACT" }
|
2801
|
+
}),
|
2802
|
+
/**
|
2803
|
+
* Creates a configuration for fuzzy matching of the specified field.
|
2804
|
+
* @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
|
2805
|
+
* @example field('name').fuzzy()
|
2806
|
+
* // {
|
2807
|
+
* // fieldId: 'name',
|
2808
|
+
* // config: { type: 'FUZZY' }
|
2809
|
+
* // }
|
2810
|
+
*/
|
2811
|
+
fuzzy: () => ({
|
2812
|
+
...baseField,
|
2813
|
+
config: { type: "FUZZY" }
|
2349
2814
|
})
|
2350
2815
|
};
|
2351
2816
|
}
|
2352
2817
|
|
2818
|
+
// ../commons/src/events/field.ts
|
2819
|
+
function field(fieldId) {
|
2820
|
+
return {
|
2821
|
+
/**
|
2822
|
+
* @private Internal property used for field reference tracking.
|
2823
|
+
*/
|
2824
|
+
_fieldId: fieldId,
|
2825
|
+
...createFieldConditionals(fieldId),
|
2826
|
+
...createFieldConfigs(fieldId)
|
2827
|
+
};
|
2828
|
+
}
|
2829
|
+
|
2353
2830
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2354
|
-
var PRINT_CERTIFICATE_FORM =
|
2831
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2355
2832
|
label: {
|
2356
2833
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2357
2834
|
defaultMessage: "Tennis club membership certificate collector",
|
2358
2835
|
description: "This is what this form is referred as in the system"
|
2359
2836
|
},
|
2360
|
-
version: {
|
2361
|
-
id: "1.0.0",
|
2362
|
-
label: {
|
2363
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2364
|
-
defaultMessage: "Version 1",
|
2365
|
-
description: "This is the first version of the form"
|
2366
|
-
}
|
2367
|
-
},
|
2368
|
-
active: true,
|
2369
2837
|
pages: [
|
2370
2838
|
{
|
2371
2839
|
id: "collector",
|
2840
|
+
type: PageTypes.enum.FORM,
|
2372
2841
|
title: {
|
2373
2842
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2374
2843
|
defaultMessage: "Print certified copy",
|
@@ -2383,7 +2852,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2383
2852
|
defaultMessage: "Requester",
|
2384
2853
|
description: "This is the label for the field"
|
2385
2854
|
},
|
2386
|
-
type:
|
2855
|
+
type: FieldType.SELECT,
|
2387
2856
|
options: [
|
2388
2857
|
{
|
2389
2858
|
value: "INFORMANT",
|
@@ -2460,7 +2929,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2460
2929
|
defaultMessage: "Select Type of ID",
|
2461
2930
|
description: "This is the label for selecting the type of ID"
|
2462
2931
|
},
|
2463
|
-
type:
|
2932
|
+
type: FieldType.SELECT,
|
2464
2933
|
options: [
|
2465
2934
|
{
|
2466
2935
|
value: "PASSPORT",
|
@@ -2561,7 +3030,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2561
3030
|
defaultMessage: "Passport Details",
|
2562
3031
|
description: "Field for entering Passport details"
|
2563
3032
|
},
|
2564
|
-
type:
|
3033
|
+
type: FieldType.TEXT
|
2565
3034
|
},
|
2566
3035
|
{
|
2567
3036
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2612,7 +3081,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2612
3081
|
defaultMessage: "Driving License Details",
|
2613
3082
|
description: "Field for entering Driving License details"
|
2614
3083
|
},
|
2615
|
-
type:
|
3084
|
+
type: FieldType.TEXT
|
2616
3085
|
},
|
2617
3086
|
{
|
2618
3087
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2663,7 +3132,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2663
3132
|
defaultMessage: "Refugee Number Details",
|
2664
3133
|
description: "Field for entering Refugee Number details"
|
2665
3134
|
},
|
2666
|
-
type:
|
3135
|
+
type: FieldType.TEXT
|
2667
3136
|
},
|
2668
3137
|
{
|
2669
3138
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2714,7 +3183,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2714
3183
|
defaultMessage: "Alien Number Details",
|
2715
3184
|
description: "Field for entering Alien Number details"
|
2716
3185
|
},
|
2717
|
-
type:
|
3186
|
+
type: FieldType.TEXT
|
2718
3187
|
},
|
2719
3188
|
{
|
2720
3189
|
id: "collector.OTHER.idTypeOther",
|
@@ -2765,7 +3234,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2765
3234
|
defaultMessage: "Other ID Type (if applicable)",
|
2766
3235
|
description: 'Field for entering ID type if "Other" is selected'
|
2767
3236
|
},
|
2768
|
-
type:
|
3237
|
+
type: FieldType.TEXT
|
2769
3238
|
},
|
2770
3239
|
{
|
2771
3240
|
id: "collector.OTHER.firstName",
|
@@ -2816,7 +3285,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2816
3285
|
defaultMessage: "First Name",
|
2817
3286
|
description: "This is the label for the first name field"
|
2818
3287
|
},
|
2819
|
-
type:
|
3288
|
+
type: FieldType.TEXT
|
2820
3289
|
},
|
2821
3290
|
{
|
2822
3291
|
id: "collector.OTHER.lastName",
|
@@ -2867,7 +3336,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2867
3336
|
defaultMessage: "Last Name",
|
2868
3337
|
description: "This is the label for the last name field"
|
2869
3338
|
},
|
2870
|
-
type:
|
3339
|
+
type: FieldType.TEXT
|
2871
3340
|
},
|
2872
3341
|
{
|
2873
3342
|
id: "collector.OTHER.relationshipToMember",
|
@@ -2918,7 +3387,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2918
3387
|
defaultMessage: "Relationship to Member",
|
2919
3388
|
description: "This is the label for the relationship to member field"
|
2920
3389
|
},
|
2921
|
-
type:
|
3390
|
+
type: FieldType.TEXT
|
2922
3391
|
},
|
2923
3392
|
{
|
2924
3393
|
id: "collector.OTHER.signedAffidavit",
|
@@ -2969,66 +3438,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2969
3438
|
defaultMessage: "Signed Affidavit (Optional)",
|
2970
3439
|
description: "This is the label for uploading a signed affidavit"
|
2971
3440
|
},
|
2972
|
-
type:
|
3441
|
+
type: FieldType.FILE
|
2973
3442
|
}
|
2974
3443
|
]
|
2975
|
-
}
|
2976
|
-
],
|
2977
|
-
review: {
|
2978
|
-
title: {
|
2979
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
2980
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
2981
|
-
description: "Title of the form to show in review page"
|
2982
3444
|
},
|
2983
|
-
|
2984
|
-
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
3445
|
+
{
|
3446
|
+
id: "collector.identity.verify",
|
3447
|
+
type: PageTypes.enum.VERIFICATION,
|
3448
|
+
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3449
|
+
title: {
|
3450
|
+
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
3451
|
+
defaultMessage: "Verify their identity",
|
3452
|
+
description: "This is the title of the section"
|
3453
|
+
},
|
3454
|
+
fields: [],
|
3455
|
+
actions: {
|
3456
|
+
verify: {
|
3457
|
+
label: {
|
3458
|
+
defaultMessage: "Verified",
|
3459
|
+
description: "This is the label for the verification button",
|
3460
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.verify"
|
3461
|
+
}
|
3462
|
+
},
|
3463
|
+
cancel: {
|
3464
|
+
label: {
|
3465
|
+
defaultMessage: "Identity does not match",
|
3466
|
+
description: "This is the label for the verification cancellation button",
|
3467
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
|
3468
|
+
},
|
3469
|
+
confirmation: {
|
3470
|
+
title: {
|
3471
|
+
defaultMessage: "Print without proof of ID?",
|
3472
|
+
description: "This is the title for the verification cancellation modal",
|
3473
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
|
3474
|
+
},
|
3475
|
+
body: {
|
3476
|
+
defaultMessage: "Please be aware that if you proceed, you will be responsible for issuing a certificate without the necessary proof of ID from the collector",
|
3477
|
+
description: "This is the body for the verification cancellation modal",
|
3478
|
+
id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
|
3479
|
+
}
|
3480
|
+
}
|
3481
|
+
}
|
3482
|
+
}
|
2999
3483
|
}
|
3484
|
+
]
|
3485
|
+
});
|
3486
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3487
|
+
title: {
|
3488
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3489
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3490
|
+
description: "Title of the review page"
|
3000
3491
|
},
|
3001
|
-
|
3002
|
-
|
3003
|
-
id: "
|
3004
|
-
|
3005
|
-
|
3492
|
+
fields: [
|
3493
|
+
{
|
3494
|
+
id: "review.comment",
|
3495
|
+
type: FieldType.TEXTAREA,
|
3496
|
+
label: {
|
3497
|
+
defaultMessage: "Comment",
|
3498
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3499
|
+
description: "Label for the comment field in the review section"
|
3500
|
+
}
|
3006
3501
|
},
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
description: "Label for the comment field in the review section"
|
3015
|
-
}
|
3502
|
+
{
|
3503
|
+
type: FieldType.SIGNATURE,
|
3504
|
+
id: "review.signature",
|
3505
|
+
label: {
|
3506
|
+
defaultMessage: "Signature of informant",
|
3507
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3508
|
+
description: "Label for the signature field in the review section"
|
3016
3509
|
},
|
3017
|
-
{
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
defaultMessage: "Signature of informant",
|
3022
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3023
|
-
description: "Label for the signature field in the review section"
|
3024
|
-
},
|
3025
|
-
signaturePromptLabel: {
|
3026
|
-
id: "v2.signature.upload.modal.title",
|
3027
|
-
defaultMessage: "Draw signature",
|
3028
|
-
description: "Title for the modal to draw signature"
|
3029
|
-
}
|
3510
|
+
signaturePromptLabel: {
|
3511
|
+
id: "v2.signature.upload.modal.title",
|
3512
|
+
defaultMessage: "Draw signature",
|
3513
|
+
description: "Title for the modal to draw signature"
|
3030
3514
|
}
|
3031
|
-
|
3515
|
+
}
|
3516
|
+
]
|
3517
|
+
};
|
3518
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3519
|
+
label: {
|
3520
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3521
|
+
defaultMessage: "Tennis club membership application",
|
3522
|
+
description: "This is what this form is referred as in the system"
|
3032
3523
|
},
|
3033
3524
|
pages: [
|
3034
3525
|
{
|
@@ -3041,7 +3532,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3041
3532
|
fields: [
|
3042
3533
|
{
|
3043
3534
|
id: "applicant.firstname",
|
3044
|
-
type:
|
3535
|
+
type: FieldType.TEXT,
|
3045
3536
|
required: true,
|
3046
3537
|
conditionals: [],
|
3047
3538
|
label: {
|
@@ -3052,7 +3543,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3052
3543
|
},
|
3053
3544
|
{
|
3054
3545
|
id: "applicant.surname",
|
3055
|
-
type:
|
3546
|
+
type: FieldType.TEXT,
|
3056
3547
|
required: true,
|
3057
3548
|
conditionals: [],
|
3058
3549
|
label: {
|
@@ -3074,9 +3565,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3074
3565
|
},
|
3075
3566
|
{
|
3076
3567
|
id: "applicant.dob",
|
3077
|
-
type:
|
3568
|
+
type: FieldType.DATE,
|
3078
3569
|
required: true,
|
3079
|
-
conditionals: [],
|
3080
3570
|
validation: [
|
3081
3571
|
{
|
3082
3572
|
message: {
|
@@ -3087,15 +3577,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3087
3577
|
validator: field("applicant.dob").isBefore().now()
|
3088
3578
|
}
|
3089
3579
|
],
|
3580
|
+
conditionals: [
|
3581
|
+
{
|
3582
|
+
type: ConditionalType.SHOW,
|
3583
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3584
|
+
}
|
3585
|
+
],
|
3090
3586
|
label: {
|
3091
3587
|
defaultMessage: "Applicant's date of birth",
|
3092
3588
|
description: "This is the label for the field",
|
3093
3589
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3094
3590
|
}
|
3095
3591
|
},
|
3592
|
+
{
|
3593
|
+
id: "applicant.dobUnknown",
|
3594
|
+
type: FieldType.CHECKBOX,
|
3595
|
+
required: false,
|
3596
|
+
label: {
|
3597
|
+
defaultMessage: "Exact date of birth unknown",
|
3598
|
+
description: "This is the label for the field",
|
3599
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3600
|
+
},
|
3601
|
+
conditionals: [
|
3602
|
+
{
|
3603
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3604
|
+
conditional: never()
|
3605
|
+
}
|
3606
|
+
]
|
3607
|
+
},
|
3608
|
+
{
|
3609
|
+
id: "applicant.age",
|
3610
|
+
type: FieldType.NUMBER,
|
3611
|
+
required: true,
|
3612
|
+
label: {
|
3613
|
+
defaultMessage: "Age of tennis-member",
|
3614
|
+
description: "This is the label for the field",
|
3615
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3616
|
+
},
|
3617
|
+
conditionals: [
|
3618
|
+
{
|
3619
|
+
type: ConditionalType.SHOW,
|
3620
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3621
|
+
}
|
3622
|
+
]
|
3623
|
+
},
|
3096
3624
|
{
|
3097
3625
|
id: "applicant.image",
|
3098
|
-
type:
|
3626
|
+
type: FieldType.FILE,
|
3099
3627
|
required: false,
|
3100
3628
|
label: {
|
3101
3629
|
defaultMessage: "Applicant's profile picture",
|
@@ -3116,6 +3644,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3116
3644
|
}
|
3117
3645
|
]
|
3118
3646
|
},
|
3647
|
+
{
|
3648
|
+
id: "senior-pass",
|
3649
|
+
conditional: field("applicant.dob").isBefore().date("1950-01-01"),
|
3650
|
+
title: {
|
3651
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
|
3652
|
+
defaultMessage: "Assign senior pass for applicant",
|
3653
|
+
description: "This is the title of the section"
|
3654
|
+
},
|
3655
|
+
fields: [
|
3656
|
+
{
|
3657
|
+
id: "senior-pass.id",
|
3658
|
+
type: FieldType.TEXT,
|
3659
|
+
required: true,
|
3660
|
+
label: {
|
3661
|
+
defaultMessage: "Senior pass ID",
|
3662
|
+
description: "This is the label for the field",
|
3663
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
|
3664
|
+
}
|
3665
|
+
}
|
3666
|
+
]
|
3667
|
+
},
|
3119
3668
|
{
|
3120
3669
|
id: "recommender",
|
3121
3670
|
title: {
|
@@ -3137,7 +3686,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3137
3686
|
},
|
3138
3687
|
{
|
3139
3688
|
id: "recommender.firstname",
|
3140
|
-
type:
|
3689
|
+
type: FieldType.TEXT,
|
3141
3690
|
required: true,
|
3142
3691
|
conditionals: [
|
3143
3692
|
{
|
@@ -3153,7 +3702,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3153
3702
|
},
|
3154
3703
|
{
|
3155
3704
|
id: "recommender.surname",
|
3156
|
-
type:
|
3705
|
+
type: FieldType.TEXT,
|
3157
3706
|
required: true,
|
3158
3707
|
conditionals: [
|
3159
3708
|
{
|
@@ -3169,7 +3718,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3169
3718
|
},
|
3170
3719
|
{
|
3171
3720
|
id: "recommender.id",
|
3172
|
-
type:
|
3721
|
+
type: FieldType.TEXT,
|
3173
3722
|
required: true,
|
3174
3723
|
conditionals: [
|
3175
3724
|
{
|
@@ -3194,20 +3743,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3194
3743
|
description: "This is what this event is referred as in the system",
|
3195
3744
|
id: "event.tennis-club-membership.label"
|
3196
3745
|
},
|
3746
|
+
title: {
|
3747
|
+
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3748
|
+
description: "This is the title of the summary",
|
3749
|
+
id: "v2.event.tennis-club-membership.title"
|
3750
|
+
},
|
3197
3751
|
summary: {
|
3198
|
-
title: {
|
3199
|
-
id: "event.tennis-club-membership.summary.title",
|
3200
|
-
label: {
|
3201
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3202
|
-
description: "This is the title of the summary",
|
3203
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3204
|
-
},
|
3205
|
-
emptyValueMessage: {
|
3206
|
-
defaultMessage: "Membership application",
|
3207
|
-
description: "This is the message shown when the applicant name is missing",
|
3208
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3209
|
-
}
|
3210
|
-
},
|
3211
3752
|
fields: [
|
3212
3753
|
{
|
3213
3754
|
id: "applicant.firstname",
|
@@ -3247,28 +3788,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3247
3788
|
}
|
3248
3789
|
]
|
3249
3790
|
},
|
3250
|
-
workqueues: [
|
3251
|
-
{
|
3252
|
-
id: "all",
|
3253
|
-
filters: []
|
3254
|
-
},
|
3255
|
-
{
|
3256
|
-
id: "ready-for-review",
|
3257
|
-
filters: [
|
3258
|
-
{
|
3259
|
-
status: ["DECLARED"]
|
3260
|
-
}
|
3261
|
-
]
|
3262
|
-
},
|
3263
|
-
{
|
3264
|
-
id: "registered",
|
3265
|
-
filters: [
|
3266
|
-
{
|
3267
|
-
status: ["REGISTERED"]
|
3268
|
-
}
|
3269
|
-
]
|
3270
|
-
}
|
3271
|
-
],
|
3272
3791
|
actions: [
|
3273
3792
|
{
|
3274
3793
|
type: ActionType.DECLARE,
|
@@ -3277,7 +3796,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3277
3796
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3278
3797
|
id: "event.tennis-club-membership.action.declare.label"
|
3279
3798
|
},
|
3280
|
-
|
3799
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3281
3800
|
},
|
3282
3801
|
{
|
3283
3802
|
type: ActionType.VALIDATE,
|
@@ -3286,7 +3805,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3286
3805
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3287
3806
|
id: "event.tennis-club-membership.action.validate.label"
|
3288
3807
|
},
|
3289
|
-
|
3808
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3290
3809
|
},
|
3291
3810
|
{
|
3292
3811
|
type: ActionType.REGISTER,
|
@@ -3295,7 +3814,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3295
3814
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3296
3815
|
id: "event.tennis-club-membership.action.register.label"
|
3297
3816
|
},
|
3298
|
-
|
3817
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3299
3818
|
},
|
3300
3819
|
{
|
3301
3820
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3304,10 +3823,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3304
3823
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3305
3824
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3306
3825
|
},
|
3307
|
-
forms: [TENNIS_CLUB_FORM],
|
3308
3826
|
onboardingForm: [
|
3309
3827
|
{
|
3310
3828
|
id: "correction-requester",
|
3829
|
+
type: PageTypes.enum.FORM,
|
3311
3830
|
title: {
|
3312
3831
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3313
3832
|
defaultMessage: "Correction requester",
|
@@ -3371,6 +3890,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3371
3890
|
},
|
3372
3891
|
{
|
3373
3892
|
id: "identity-check",
|
3893
|
+
type: PageTypes.enum.FORM,
|
3374
3894
|
title: {
|
3375
3895
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3376
3896
|
defaultMessage: "Verify their identity",
|
@@ -3413,6 +3933,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3413
3933
|
additionalDetailsForm: [
|
3414
3934
|
{
|
3415
3935
|
id: "correction-request.supporting-documents",
|
3936
|
+
type: PageTypes.enum.FORM,
|
3416
3937
|
title: {
|
3417
3938
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3418
3939
|
defaultMessage: "Upload supporting documents",
|
@@ -3430,7 +3951,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3430
3951
|
},
|
3431
3952
|
{
|
3432
3953
|
id: "correction.supportingDocs",
|
3433
|
-
type:
|
3954
|
+
type: FieldType.FILE,
|
3434
3955
|
label: {
|
3435
3956
|
id: "correction.corrector.title",
|
3436
3957
|
defaultMessage: "Upload supporting documents",
|
@@ -3474,6 +3995,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3474
3995
|
},
|
3475
3996
|
{
|
3476
3997
|
id: "correction-request.additional-details",
|
3998
|
+
type: PageTypes.enum.FORM,
|
3477
3999
|
title: {
|
3478
4000
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3479
4001
|
defaultMessage: "Reason for correction",
|
@@ -3482,7 +4004,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3482
4004
|
fields: [
|
3483
4005
|
{
|
3484
4006
|
id: "correction.request.reason",
|
3485
|
-
type:
|
4007
|
+
type: FieldType.TEXT,
|
3486
4008
|
label: {
|
3487
4009
|
id: "correction.reason.title",
|
3488
4010
|
defaultMessage: "Reason for correction?",
|
@@ -3495,7 +4017,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3495
4017
|
},
|
3496
4018
|
{
|
3497
4019
|
type: ActionType.APPROVE_CORRECTION,
|
3498
|
-
forms: [TENNIS_CLUB_FORM],
|
3499
4020
|
label: {
|
3500
4021
|
defaultMessage: "Approve correction",
|
3501
4022
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3509,7 +4030,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3509
4030
|
defaultMessage: "Print certificate",
|
3510
4031
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3511
4032
|
},
|
3512
|
-
|
4033
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3513
4034
|
conditionals: [
|
3514
4035
|
{
|
3515
4036
|
type: "SHOW",
|
@@ -3556,8 +4077,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3556
4077
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3557
4078
|
defaultMessage: "Archive",
|
3558
4079
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3559
|
-
}
|
3560
|
-
forms: [TENNIS_CLUB_FORM]
|
4080
|
+
}
|
3561
4081
|
},
|
3562
4082
|
{
|
3563
4083
|
type: ActionType.REJECT,
|
@@ -3565,8 +4085,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3565
4085
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3566
4086
|
defaultMessage: "Reject",
|
3567
4087
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3568
|
-
}
|
3569
|
-
forms: [TENNIS_CLUB_FORM]
|
4088
|
+
}
|
3570
4089
|
}
|
3571
4090
|
],
|
3572
4091
|
advancedSearch: [
|
@@ -3576,26 +4095,55 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3576
4095
|
description: "This is what this event is referred as in the system",
|
3577
4096
|
id: "v2.event.tennis-club-membership.search"
|
3578
4097
|
},
|
3579
|
-
fields: [
|
3580
|
-
{
|
3581
|
-
fieldId: "applicant.dob"
|
3582
|
-
}
|
3583
|
-
]
|
4098
|
+
fields: [field("applicant.dob").exact()]
|
3584
4099
|
}
|
3585
|
-
]
|
4100
|
+
],
|
4101
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3586
4102
|
});
|
3587
4103
|
|
3588
4104
|
// ../commons/src/events/test.utils.ts
|
3589
|
-
function
|
3590
|
-
|
3591
|
-
const data = fields.reduce(
|
4105
|
+
function fieldConfigsToActionPayload(fields) {
|
4106
|
+
return fields.reduce(
|
3592
4107
|
(acc, field2, i) => ({
|
3593
4108
|
...acc,
|
3594
4109
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3595
4110
|
}),
|
3596
4111
|
{}
|
3597
4112
|
);
|
3598
|
-
|
4113
|
+
}
|
4114
|
+
function generateActionDeclarationInput(configuration, action) {
|
4115
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
4116
|
+
if (parsed.success) {
|
4117
|
+
const fields = getDeclarationFields(configuration);
|
4118
|
+
const declarationConfig = getDeclaration(configuration);
|
4119
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4120
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
4121
|
+
}
|
4122
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
4123
|
+
return {};
|
4124
|
+
}
|
4125
|
+
function generateActionAnnotationInput(configuration, action) {
|
4126
|
+
const actionConfig = configuration.actions.find(
|
4127
|
+
(ac) => ac.type === action
|
4128
|
+
);
|
4129
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
4130
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
4131
|
+
const visibleVerificationPageIds = getVisibleVerificationPageIds(
|
4132
|
+
findRecordActionPages(configuration, action),
|
4133
|
+
annotation
|
4134
|
+
);
|
4135
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
4136
|
+
(acc, pageId) => ({
|
4137
|
+
...acc,
|
4138
|
+
[pageId]: true
|
4139
|
+
}),
|
4140
|
+
{}
|
4141
|
+
);
|
4142
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
4143
|
+
return {
|
4144
|
+
...fieldBasedPayload,
|
4145
|
+
...visiblePageVerificationMap
|
4146
|
+
};
|
3599
4147
|
}
|
3600
4148
|
var eventPayloadGenerator = {
|
3601
4149
|
create: (input = {}) => ({
|
@@ -3607,27 +4155,31 @@ var eventPayloadGenerator = {
|
|
3607
4155
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3608
4156
|
id
|
3609
4157
|
}),
|
3610
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4158
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3611
4159
|
{
|
3612
4160
|
id: getUUID(),
|
3613
4161
|
eventId,
|
3614
4162
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3615
4163
|
transactionId: getUUID(),
|
3616
4164
|
action: {
|
3617
|
-
|
3618
|
-
|
4165
|
+
transactionId: getUUID(),
|
4166
|
+
type: actionType,
|
4167
|
+
status: ActionStatus.Accepted,
|
4168
|
+
declaration: {
|
3619
4169
|
"applicant.firstname": "Max",
|
3620
4170
|
"applicant.surname": "McLaren",
|
3621
4171
|
"applicant.dob": "2020-01-02",
|
3622
4172
|
"recommender.none": true
|
3623
4173
|
},
|
3624
|
-
|
4174
|
+
annotation: {
|
3625
4175
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3626
4176
|
"correction.request.reason": "Child's name was incorrect"
|
3627
4177
|
},
|
3628
4178
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3629
4179
|
createdBy: "@todo",
|
3630
|
-
|
4180
|
+
createdByRole: "@todo",
|
4181
|
+
createdAtLocation: "@todo",
|
4182
|
+
updatedAtLocation: "@todo"
|
3631
4183
|
}
|
3632
4184
|
},
|
3633
4185
|
input
|
@@ -3636,41 +4188,104 @@ var eventPayloadGenerator = {
|
|
3636
4188
|
declare: (eventId, input = {}) => ({
|
3637
4189
|
type: ActionType.DECLARE,
|
3638
4190
|
transactionId: input.transactionId ?? getUUID(),
|
3639
|
-
|
4191
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4192
|
+
tennisClubMembershipEvent,
|
4193
|
+
ActionType.DECLARE
|
4194
|
+
),
|
4195
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4196
|
+
tennisClubMembershipEvent,
|
4197
|
+
ActionType.DECLARE
|
4198
|
+
),
|
3640
4199
|
eventId
|
3641
4200
|
}),
|
4201
|
+
/**
|
4202
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4203
|
+
*/
|
4204
|
+
notify: (eventId, input = {}) => {
|
4205
|
+
let declaration = input.declaration;
|
4206
|
+
if (!declaration) {
|
4207
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4208
|
+
generateActionDeclarationInput(
|
4209
|
+
tennisClubMembershipEvent,
|
4210
|
+
ActionType.DECLARE
|
4211
|
+
),
|
4212
|
+
import_lodash2.isString
|
4213
|
+
);
|
4214
|
+
declaration = partialDeclaration;
|
4215
|
+
}
|
4216
|
+
return {
|
4217
|
+
type: ActionType.NOTIFY,
|
4218
|
+
transactionId: input.transactionId ?? getUUID(),
|
4219
|
+
declaration,
|
4220
|
+
eventId
|
4221
|
+
};
|
4222
|
+
},
|
3642
4223
|
validate: (eventId, input = {}) => ({
|
3643
4224
|
type: ActionType.VALIDATE,
|
3644
4225
|
transactionId: input.transactionId ?? getUUID(),
|
3645
|
-
|
4226
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4227
|
+
tennisClubMembershipEvent,
|
4228
|
+
ActionType.VALIDATE
|
4229
|
+
),
|
4230
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4231
|
+
tennisClubMembershipEvent,
|
4232
|
+
ActionType.VALIDATE
|
4233
|
+
),
|
3646
4234
|
duplicates: [],
|
3647
4235
|
eventId
|
3648
4236
|
}),
|
4237
|
+
assign: (eventId, input = {}) => ({
|
4238
|
+
type: ActionType.ASSIGN,
|
4239
|
+
transactionId: input.transactionId ?? getUUID(),
|
4240
|
+
declaration: {},
|
4241
|
+
assignedTo: input.assignedTo ?? getUUID(),
|
4242
|
+
eventId
|
4243
|
+
}),
|
4244
|
+
unassign: (eventId, input = {}) => ({
|
4245
|
+
type: ActionType.UNASSIGN,
|
4246
|
+
transactionId: input.transactionId ?? getUUID(),
|
4247
|
+
declaration: {},
|
4248
|
+
assignedTo: null,
|
4249
|
+
eventId
|
4250
|
+
}),
|
3649
4251
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3650
4252
|
type: ActionType.ARCHIVE,
|
3651
4253
|
transactionId: input.transactionId ?? getUUID(),
|
3652
|
-
|
3653
|
-
|
4254
|
+
declaration: {},
|
4255
|
+
// @TODO: Check whether generator is needed?
|
4256
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3654
4257
|
duplicates: [],
|
3655
4258
|
eventId
|
3656
4259
|
}),
|
3657
4260
|
reject: (eventId, input = {}) => ({
|
3658
4261
|
type: ActionType.REJECT,
|
3659
4262
|
transactionId: input.transactionId ?? getUUID(),
|
3660
|
-
|
4263
|
+
declaration: {},
|
4264
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4265
|
+
tennisClubMembershipEvent,
|
4266
|
+
ActionType.REJECT
|
4267
|
+
),
|
3661
4268
|
duplicates: [],
|
3662
4269
|
eventId
|
3663
4270
|
}),
|
3664
4271
|
register: (eventId, input = {}) => ({
|
3665
4272
|
type: ActionType.REGISTER,
|
3666
4273
|
transactionId: input.transactionId ?? getUUID(),
|
3667
|
-
|
4274
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4275
|
+
tennisClubMembershipEvent,
|
4276
|
+
ActionType.REGISTER
|
4277
|
+
),
|
4278
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4279
|
+
tennisClubMembershipEvent,
|
4280
|
+
ActionType.REGISTER
|
4281
|
+
),
|
3668
4282
|
eventId
|
3669
4283
|
}),
|
3670
4284
|
printCertificate: (eventId, input = {}) => ({
|
3671
4285
|
type: ActionType.PRINT_CERTIFICATE,
|
3672
4286
|
transactionId: input.transactionId ?? getUUID(),
|
3673
|
-
|
4287
|
+
declaration: {},
|
4288
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3674
4289
|
tennisClubMembershipEvent,
|
3675
4290
|
ActionType.PRINT_CERTIFICATE
|
3676
4291
|
),
|
@@ -3680,17 +4295,21 @@ var eventPayloadGenerator = {
|
|
3680
4295
|
request: (eventId, input = {}) => ({
|
3681
4296
|
type: ActionType.REQUEST_CORRECTION,
|
3682
4297
|
transactionId: input.transactionId ?? getUUID(),
|
3683
|
-
|
4298
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4299
|
+
tennisClubMembershipEvent,
|
4300
|
+
ActionType.REQUEST_CORRECTION
|
4301
|
+
),
|
4302
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3684
4303
|
tennisClubMembershipEvent,
|
3685
4304
|
ActionType.REQUEST_CORRECTION
|
3686
4305
|
),
|
3687
|
-
metadata: {},
|
3688
4306
|
eventId
|
3689
4307
|
}),
|
3690
4308
|
approve: (eventId, requestId, input = {}) => ({
|
3691
4309
|
type: ActionType.APPROVE_CORRECTION,
|
3692
4310
|
transactionId: input.transactionId ?? getUUID(),
|
3693
|
-
|
4311
|
+
declaration: {},
|
4312
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3694
4313
|
tennisClubMembershipEvent,
|
3695
4314
|
ActionType.APPROVE_CORRECTION
|
3696
4315
|
),
|
@@ -3700,7 +4319,8 @@ var eventPayloadGenerator = {
|
|
3700
4319
|
reject: (eventId, requestId, input = {}) => ({
|
3701
4320
|
type: ActionType.REJECT_CORRECTION,
|
3702
4321
|
transactionId: input.transactionId ?? getUUID(),
|
3703
|
-
|
4322
|
+
declaration: {},
|
4323
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3704
4324
|
tennisClubMembershipEvent,
|
3705
4325
|
ActionType.REJECT_CORRECTION
|
3706
4326
|
),
|
@@ -3720,17 +4340,25 @@ function generateActionDocument({
|
|
3720
4340
|
// @TODO: This should be fixed in the future.
|
3721
4341
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
3722
4342
|
createdBy: getUUID(),
|
4343
|
+
createdByRole: "FIELD_AGENT",
|
3723
4344
|
id: getUUID(),
|
3724
4345
|
createdAtLocation: "TODO",
|
3725
|
-
|
3726
|
-
|
3727
|
-
|
4346
|
+
updatedAtLocation: "TODO",
|
4347
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4348
|
+
annotation: {},
|
4349
|
+
...defaults,
|
4350
|
+
status: ActionStatus.Accepted,
|
4351
|
+
transactionId: getUUID()
|
3728
4352
|
};
|
3729
4353
|
switch (action) {
|
4354
|
+
case ActionType.READ:
|
4355
|
+
return { ...actionBase, type: action };
|
4356
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4357
|
+
return { ...actionBase, type: action };
|
3730
4358
|
case ActionType.DECLARE:
|
3731
4359
|
return { ...actionBase, type: action };
|
3732
4360
|
case ActionType.UNASSIGN:
|
3733
|
-
return { ...actionBase, type: action };
|
4361
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3734
4362
|
case ActionType.ASSIGN:
|
3735
4363
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3736
4364
|
case ActionType.VALIDATE:
|
@@ -3751,14 +4379,13 @@ function generateActionDocument({
|
|
3751
4379
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3752
4380
|
case ActionType.REJECT_CORRECTION:
|
3753
4381
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3754
|
-
case ActionType.CUSTOM:
|
3755
|
-
return { ...actionBase, type: action };
|
3756
4382
|
case ActionType.REGISTER:
|
3757
4383
|
return {
|
3758
4384
|
...actionBase,
|
3759
|
-
type: action
|
3760
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4385
|
+
type: action
|
3761
4386
|
};
|
4387
|
+
case ActionType.DELETE:
|
4388
|
+
case ActionType.DETECT_DUPLICATE:
|
3762
4389
|
default:
|
3763
4390
|
throw new Error(`Unsupported action type: ${action}`);
|
3764
4391
|
}
|
@@ -3779,10 +4406,12 @@ function generateEventDocument({
|
|
3779
4406
|
id: getUUID(),
|
3780
4407
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3781
4408
|
// @TODO: This should be fixed in the future.
|
3782
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4409
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4410
|
+
dateOfEvent: configuration.dateOfEvent,
|
4411
|
+
updatedAtLocation: getUUID()
|
3783
4412
|
};
|
3784
4413
|
}
|
3785
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4414
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3786
4415
|
const action = generateActionDocument({
|
3787
4416
|
configuration: tennisClubMembershipEvent,
|
3788
4417
|
action: actionType
|
@@ -3792,9 +4421,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3792
4421
|
transactionId: getUUID(),
|
3793
4422
|
action: {
|
3794
4423
|
...action,
|
3795
|
-
|
3796
|
-
...action.
|
3797
|
-
...
|
4424
|
+
declaration: {
|
4425
|
+
...action.declaration,
|
4426
|
+
...declaration
|
3798
4427
|
}
|
3799
4428
|
},
|
3800
4429
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3808,10 +4437,12 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3808
4437
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3809
4438
|
createdBy: overrides.createdBy ?? getUUID(),
|
3810
4439
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
3811
|
-
|
4440
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4441
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3812
4442
|
assignedTo: overrides.assignedTo ?? null,
|
3813
4443
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3814
|
-
|
4444
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4445
|
+
declaration: overrides.declaration ?? {
|
3815
4446
|
"recommender.none": true,
|
3816
4447
|
"applicant.firstname": "Danny",
|
3817
4448
|
"applicant.surname": "Doe",
|
@@ -3819,6 +4450,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3819
4450
|
},
|
3820
4451
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3821
4452
|
});
|
4453
|
+
var generateTranslationConfig = (message) => ({
|
4454
|
+
defaultMessage: message,
|
4455
|
+
description: "Description for ${message}",
|
4456
|
+
id: message
|
4457
|
+
});
|
3822
4458
|
|
3823
4459
|
// ../commons/src/events/TemplateConfig.ts
|
3824
4460
|
function isTemplateVariable(value) {
|
@@ -3837,7 +4473,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
3837
4473
|
return true;
|
3838
4474
|
}
|
3839
4475
|
function isFieldConfigDefaultValue(value) {
|
3840
|
-
if (!value)
|
4476
|
+
if (!value) {
|
4477
|
+
return false;
|
4478
|
+
}
|
3841
4479
|
if (isFieldValue(value)) {
|
3842
4480
|
return true;
|
3843
4481
|
}
|
@@ -3849,3 +4487,213 @@ function isFieldConfigDefaultValue(value) {
|
|
3849
4487
|
}
|
3850
4488
|
return false;
|
3851
4489
|
}
|
4490
|
+
|
4491
|
+
// ../commons/src/events/scopes.ts
|
4492
|
+
var import_lodash3 = require("lodash");
|
4493
|
+
|
4494
|
+
// ../commons/src/scopes.ts
|
4495
|
+
var SCOPES = {
|
4496
|
+
// TODO v1.8 legacy scopes
|
4497
|
+
NATLSYSADMIN: "natlsysadmin",
|
4498
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
4499
|
+
DECLARE: "declare",
|
4500
|
+
REGISTER: "register",
|
4501
|
+
VALIDATE: "validate",
|
4502
|
+
DEMO: "demo",
|
4503
|
+
CERTIFY: "certify",
|
4504
|
+
PERFORMANCE: "performance",
|
4505
|
+
SYSADMIN: "sysadmin",
|
4506
|
+
TEAMS: "teams",
|
4507
|
+
CONFIG: "config",
|
4508
|
+
// systems / integrations
|
4509
|
+
WEBHOOK: "webhook",
|
4510
|
+
NATIONALID: "nationalId",
|
4511
|
+
NOTIFICATION_API: "notification-api",
|
4512
|
+
RECORDSEARCH: "recordsearch",
|
4513
|
+
/**
|
4514
|
+
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
4515
|
+
*/
|
4516
|
+
RECORD_DECLARE: "record.declare-birth",
|
4517
|
+
// declare
|
4518
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
4519
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
4520
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
4521
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
4522
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
4523
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
4524
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
4525
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
4526
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
4527
|
+
// validate
|
4528
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
4529
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
4530
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
4531
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
4532
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
4533
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
4534
|
+
// register
|
4535
|
+
RECORD_REGISTER: "record.register",
|
4536
|
+
// certify
|
4537
|
+
RECORD_EXPORT_RECORDS: "record.export-records",
|
4538
|
+
RECORD_DECLARATION_PRINT: "record.declaration-print",
|
4539
|
+
RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
|
4540
|
+
RECORD_REGISTRATION_PRINT: "record.registration-print",
|
4541
|
+
// v1.8
|
4542
|
+
/**
|
4543
|
+
* This scope is used to **print and **issue certified copies of a record
|
4544
|
+
* after it has been registered. Previously Registrars had this permission.
|
4545
|
+
*/
|
4546
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
4547
|
+
RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
|
4548
|
+
// v1.8
|
4549
|
+
RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
|
4550
|
+
// v1.8
|
4551
|
+
RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
|
4552
|
+
// v1.8
|
4553
|
+
// correct
|
4554
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
4555
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
4556
|
+
RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
|
4557
|
+
// v1.8
|
4558
|
+
RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
|
4559
|
+
// v1.8
|
4560
|
+
RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
|
4561
|
+
// v1.8
|
4562
|
+
RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
|
4563
|
+
// v1.8
|
4564
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
4565
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
4566
|
+
// search
|
4567
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
4568
|
+
SEARCH_BIRTH: "search.birth",
|
4569
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
4570
|
+
SEARCH_DEATH: "search.death",
|
4571
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
4572
|
+
SEARCH_MARRIAGE: "search.marriage",
|
4573
|
+
// audit v1.8
|
4574
|
+
RECORD_READ: "record.read",
|
4575
|
+
RECORD_READ_AUDIT: "record.read-audit",
|
4576
|
+
RECORD_READ_COMMENTS: "record.read-comments",
|
4577
|
+
RECORD_CREATE_COMMENTS: "record.create-comments",
|
4578
|
+
// profile
|
4579
|
+
PROFILE_UPDATE: "profile.update",
|
4580
|
+
//v1.8
|
4581
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
4582
|
+
// performance
|
4583
|
+
PERFORMANCE_READ: "performance.read",
|
4584
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
4585
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
4586
|
+
// organisation
|
4587
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
4588
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
4589
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
4590
|
+
// user
|
4591
|
+
USER_READ: "user.read:all",
|
4592
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
4593
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
4594
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
4595
|
+
//v1.8
|
4596
|
+
USER_CREATE: "user.create:all",
|
4597
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
4598
|
+
USER_UPDATE: "user.update:all",
|
4599
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
4600
|
+
// config
|
4601
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
4602
|
+
// data seeding
|
4603
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
4604
|
+
};
|
4605
|
+
var scopes = Object.values(SCOPES);
|
4606
|
+
|
4607
|
+
// ../commons/src/events/scopes.ts
|
4608
|
+
function hasAnyOfScopes(a, b) {
|
4609
|
+
return (0, import_lodash3.intersection)(a, b).length > 0;
|
4610
|
+
}
|
4611
|
+
var CONFIG_GET_ALLOWED_SCOPES = [
|
4612
|
+
SCOPES.RECORD_DECLARE,
|
4613
|
+
SCOPES.RECORD_READ,
|
4614
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4615
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4616
|
+
SCOPES.RECORD_REGISTER,
|
4617
|
+
SCOPES.RECORD_EXPORT_RECORDS,
|
4618
|
+
SCOPES.CONFIG,
|
4619
|
+
SCOPES.CONFIG_UPDATE_ALL
|
4620
|
+
];
|
4621
|
+
var CONFIG_SEARCH_ALLOWED_SCOPES = [
|
4622
|
+
SCOPES.SEARCH_BIRTH,
|
4623
|
+
SCOPES.SEARCH_DEATH,
|
4624
|
+
SCOPES.SEARCH_MARRIAGE,
|
4625
|
+
SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
|
4626
|
+
SCOPES.SEARCH_DEATH_MY_JURISDICTION,
|
4627
|
+
SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
|
4628
|
+
];
|
4629
|
+
var ACTION_ALLOWED_SCOPES = {
|
4630
|
+
[ActionType.READ]: [
|
4631
|
+
SCOPES.RECORD_DECLARE,
|
4632
|
+
SCOPES.RECORD_READ,
|
4633
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4634
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
|
4635
|
+
SCOPES.RECORD_REGISTER,
|
4636
|
+
SCOPES.RECORD_EXPORT_RECORDS
|
4637
|
+
],
|
4638
|
+
[ActionType.CREATE]: [
|
4639
|
+
SCOPES.RECORD_DECLARE,
|
4640
|
+
SCOPES.RECORD_SUBMIT_INCOMPLETE,
|
4641
|
+
SCOPES.RECORD_SUBMIT_FOR_REVIEW
|
4642
|
+
],
|
4643
|
+
[ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
|
4644
|
+
[ActionType.DECLARE]: [
|
4645
|
+
SCOPES.RECORD_DECLARE,
|
4646
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4647
|
+
SCOPES.RECORD_REGISTER
|
4648
|
+
],
|
4649
|
+
[ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
|
4650
|
+
[ActionType.VALIDATE]: [
|
4651
|
+
SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
|
4652
|
+
SCOPES.RECORD_REGISTER
|
4653
|
+
],
|
4654
|
+
[ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
|
4655
|
+
[ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
|
4656
|
+
[ActionType.REQUEST_CORRECTION]: [
|
4657
|
+
SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
|
4658
|
+
],
|
4659
|
+
[ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4660
|
+
[ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
|
4661
|
+
[ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4662
|
+
[ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
|
4663
|
+
[ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
|
4664
|
+
[ActionType.ASSIGN]: null,
|
4665
|
+
[ActionType.UNASSIGN]: null,
|
4666
|
+
[ActionType.DETECT_DUPLICATE]: []
|
4667
|
+
};
|
4668
|
+
function filterUnallowedActions(actions, userScopes) {
|
4669
|
+
const allowedActions = actions.filter((action) => {
|
4670
|
+
const requiredScopes = ACTION_ALLOWED_SCOPES[action];
|
4671
|
+
if (requiredScopes === null) {
|
4672
|
+
return true;
|
4673
|
+
}
|
4674
|
+
return hasAnyOfScopes(userScopes, requiredScopes);
|
4675
|
+
});
|
4676
|
+
const hasOtherAllowedActions = allowedActions.some(
|
4677
|
+
(action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
|
4678
|
+
);
|
4679
|
+
if (hasOtherAllowedActions) {
|
4680
|
+
return allowedActions;
|
4681
|
+
}
|
4682
|
+
return [ActionType.READ];
|
4683
|
+
}
|
4684
|
+
|
4685
|
+
// ../commons/src/event-config/event-configuration.ts
|
4686
|
+
function createEventFieldConfig(fieldId, options) {
|
4687
|
+
return {
|
4688
|
+
fieldId,
|
4689
|
+
options,
|
4690
|
+
config: { type: "EXACT" },
|
4691
|
+
fieldType: "event"
|
4692
|
+
};
|
4693
|
+
}
|
4694
|
+
|
4695
|
+
// ../commons/src/events/event.ts
|
4696
|
+
function eventFn(fieldId, options) {
|
4697
|
+
return createEventFieldConfig(fieldId, options);
|
4698
|
+
}
|
4699
|
+
var event = Object.assign(eventFn, createEventConditionals());
|