@opencrvs/toolkit 1.8.0-rc.fa72fdf → 1.8.0-rc.fa8bcf6
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 +10779 -10294
- package/dist/commons/conditionals/conditionals.d.ts +31 -5
- package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
- 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 +9850 -363
- package/dist/commons/events/ActionInput.d.ts +5361 -496
- 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 +155 -2
- package/dist/commons/events/Conditional.d.ts +21 -5
- package/dist/commons/events/Draft.d.ts +374 -56
- 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 +3667 -499
- 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 +3954 -757
- package/dist/commons/events/FieldType.d.ts +2 -2
- package/dist/commons/events/FieldTypeMapping.d.ts +124 -3
- package/dist/commons/events/FieldValue.d.ts +77 -3
- 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 +127 -237
- package/dist/commons/events/utils.d.ts +3462 -109
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/conditionals/index.js +196 -108
- package/dist/events/index.js +2018 -1139
- 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,40 +99,66 @@ __export(events_exports, {
|
|
75
99
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
76
100
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
77
101
|
FormConfig: () => FormConfig,
|
78
|
-
|
102
|
+
FormPageConfig: () => FormPageConfig,
|
103
|
+
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
104
|
+
GenericAddressValue: () => GenericAddressValue,
|
79
105
|
GeographicalArea: () => GeographicalArea,
|
106
|
+
ImageMimeType: () => ImageMimeType,
|
80
107
|
LanguageConfig: () => LanguageConfig,
|
81
108
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
109
|
+
MatchType: () => MatchType,
|
110
|
+
MimeType: () => MimeType,
|
111
|
+
NonEmptyTextValue: () => NonEmptyTextValue,
|
82
112
|
NotifyActionInput: () => NotifyActionInput,
|
83
113
|
NumberFieldValue: () => NumberFieldValue,
|
114
|
+
PageConfig: () => PageConfig,
|
115
|
+
PageTypes: () => PageTypes,
|
84
116
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
117
|
+
QueryInput: () => QueryInput,
|
118
|
+
QueryType: () => QueryType,
|
119
|
+
ReadActionInput: () => ReadActionInput,
|
120
|
+
RegisterAction: () => RegisterAction,
|
85
121
|
RegisterActionInput: () => RegisterActionInput,
|
86
122
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
87
123
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
88
124
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
89
|
-
RequiredTextValue: () => RequiredTextValue,
|
90
125
|
ResolvedUser: () => ResolvedUser,
|
91
126
|
RuralAddressUpdateValue: () => RuralAddressUpdateValue,
|
92
127
|
RuralAddressValue: () => RuralAddressValue,
|
128
|
+
SearchField: () => SearchField,
|
129
|
+
SelectOption: () => SelectOption,
|
93
130
|
ShowConditional: () => ShowConditional,
|
94
131
|
SummaryConfig: () => SummaryConfig,
|
95
132
|
TextValue: () => TextValue,
|
96
133
|
TranslationConfig: () => TranslationConfig,
|
134
|
+
UnassignActionInput: () => UnassignActionInput,
|
97
135
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
98
136
|
UrbanAddressValue: () => UrbanAddressValue,
|
99
137
|
ValidateActionInput: () => ValidateActionInput,
|
138
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
139
|
+
VerificationPageConfig: () => VerificationPageConfig,
|
100
140
|
WorkqueueConfig: () => WorkqueueConfig,
|
141
|
+
ZodDate: () => ZodDate,
|
101
142
|
alwaysTrue: () => alwaysTrue,
|
102
143
|
and: () => and,
|
144
|
+
annotationActions: () => annotationActions,
|
103
145
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
146
|
+
areConditionsMet: () => areConditionsMet,
|
104
147
|
compositeFieldTypes: () => compositeFieldTypes,
|
105
148
|
createEmptyDraft: () => createEmptyDraft,
|
149
|
+
createEventConditionals: () => createEventConditionals,
|
150
|
+
createFieldConditionals: () => createFieldConditionals,
|
106
151
|
createValidationSchema: () => createValidationSchema,
|
107
152
|
deepDropNulls: () => deepDropNulls,
|
153
|
+
deepMerge: () => deepMerge,
|
154
|
+
defineActionForm: () => defineActionForm,
|
108
155
|
defineConditional: () => defineConditional,
|
109
156
|
defineConfig: () => defineConfig,
|
110
|
-
|
157
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
158
|
+
defineFormConditional: () => defineFormConditional,
|
111
159
|
defineFormPage: () => defineFormPage,
|
160
|
+
definePage: () => definePage,
|
161
|
+
defineWorkqueue: () => defineWorkqueue,
|
112
162
|
errorMessages: () => errorMessages,
|
113
163
|
event: () => event,
|
114
164
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -117,38 +167,46 @@ __export(events_exports, {
|
|
117
167
|
eventStatuses: () => eventStatuses,
|
118
168
|
field: () => field,
|
119
169
|
fieldTypes: () => fieldTypes,
|
120
|
-
|
121
|
-
findActiveActionForm: () => findActiveActionForm,
|
122
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
123
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
170
|
+
filterUnallowedActions: () => filterUnallowedActions,
|
124
171
|
findActiveDrafts: () => findActiveDrafts,
|
125
|
-
|
126
|
-
|
172
|
+
findAllFields: () => findAllFields,
|
173
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
174
|
+
findRecordActionPages: () => findRecordActionPages,
|
175
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
176
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
127
177
|
generateActionDocument: () => generateActionDocument,
|
128
|
-
generateActionInput: () => generateActionInput,
|
129
178
|
generateEventDocument: () => generateEventDocument,
|
130
179
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
131
180
|
generateTransactionId: () => generateTransactionId,
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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,
|
136
190
|
getCurrentEventState: () => getCurrentEventState,
|
137
191
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
192
|
+
getDeclaration: () => getDeclaration,
|
193
|
+
getDeclarationFields: () => getDeclarationFields,
|
194
|
+
getDeclarationPages: () => getDeclarationPages,
|
195
|
+
getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
|
196
|
+
hasAnyOfScopes: () => hasAnyOfScopes,
|
142
197
|
isAddressFieldType: () => isAddressFieldType,
|
143
198
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
144
199
|
isBulletListFieldType: () => isBulletListFieldType,
|
145
200
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
201
|
+
isConditionMet: () => isConditionMet,
|
146
202
|
isCountryFieldType: () => isCountryFieldType,
|
203
|
+
isDataFieldType: () => isDataFieldType,
|
147
204
|
isDateFieldType: () => isDateFieldType,
|
148
205
|
isDividerFieldType: () => isDividerFieldType,
|
149
206
|
isEmailFieldType: () => isEmailFieldType,
|
150
207
|
isFacilityFieldType: () => isFacilityFieldType,
|
151
208
|
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
209
|
+
isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
|
152
210
|
isFieldEnabled: () => isFieldEnabled,
|
153
211
|
isFieldValue: () => isFieldValue,
|
154
212
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
@@ -159,6 +217,7 @@ __export(events_exports, {
|
|
159
217
|
isNumberFieldType: () => isNumberFieldType,
|
160
218
|
isOfficeFieldType: () => isOfficeFieldType,
|
161
219
|
isPageHeaderFieldType: () => isPageHeaderFieldType,
|
220
|
+
isPageVisible: () => isPageVisible,
|
162
221
|
isParagraphFieldType: () => isParagraphFieldType,
|
163
222
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
164
223
|
isSelectFieldType: () => isSelectFieldType,
|
@@ -167,50 +226,72 @@ __export(events_exports, {
|
|
167
226
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
168
227
|
isTextFieldType: () => isTextFieldType,
|
169
228
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
229
|
+
isVerificationPage: () => isVerificationPage,
|
230
|
+
isWriteAction: () => isWriteAction,
|
170
231
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
171
232
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
172
233
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
234
|
+
never: () => never,
|
173
235
|
not: () => not,
|
236
|
+
omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
|
237
|
+
omitHiddenFields: () => omitHiddenFields,
|
238
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
174
239
|
or: () => or,
|
175
|
-
|
176
|
-
stripHiddenFields: () => stripHiddenFields,
|
240
|
+
runFieldValidations: () => runFieldValidations,
|
177
241
|
user: () => user,
|
178
242
|
validate: () => validate,
|
179
243
|
validateFieldInput: () => validateFieldInput,
|
180
|
-
|
244
|
+
writeActions: () => writeActions
|
181
245
|
});
|
182
246
|
module.exports = __toCommonJS(events_exports);
|
183
247
|
|
184
248
|
// ../commons/src/events/ActionConfig.ts
|
185
|
-
var
|
249
|
+
var import_zod9 = require("zod");
|
186
250
|
|
187
251
|
// ../commons/src/events/Conditional.ts
|
188
252
|
var import_zod = require("zod");
|
189
|
-
|
190
|
-
|
191
|
-
|
253
|
+
var Conditional = import_zod.z.custom(
|
254
|
+
(val) => typeof val === "object" && val !== null
|
255
|
+
);
|
192
256
|
var ConditionalType = {
|
193
|
-
/** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
|
194
257
|
SHOW: "SHOW",
|
195
|
-
|
196
|
-
|
258
|
+
ENABLE: "ENABLE",
|
259
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
197
260
|
};
|
198
261
|
var ShowConditional = import_zod.z.object({
|
199
262
|
type: import_zod.z.literal(ConditionalType.SHOW),
|
200
|
-
conditional: Conditional
|
201
|
-
})
|
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
|
+
);
|
202
267
|
var EnableConditional = import_zod.z.object({
|
203
268
|
type: import_zod.z.literal(ConditionalType.ENABLE),
|
204
|
-
conditional: Conditional
|
205
|
-
})
|
269
|
+
conditional: Conditional
|
270
|
+
}).describe(
|
271
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
272
|
+
);
|
206
273
|
var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
207
274
|
// Action can be shown / hidden
|
208
275
|
ShowConditional,
|
209
276
|
// Action can be shown to the user in the list but as disabled
|
210
277
|
EnableConditional
|
211
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
|
+
]);
|
212
293
|
|
213
|
-
// ../commons/src/events/
|
294
|
+
// ../commons/src/events/PageConfig.ts
|
214
295
|
var import_zod6 = require("zod");
|
215
296
|
|
216
297
|
// ../commons/src/events/FieldConfig.ts
|
@@ -241,7 +322,6 @@ var FieldType = {
|
|
241
322
|
RADIO_GROUP: "RADIO_GROUP",
|
242
323
|
FILE: "FILE",
|
243
324
|
FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
|
244
|
-
HIDDEN: "HIDDEN",
|
245
325
|
BULLET_LIST: "BULLET_LIST",
|
246
326
|
CHECKBOX: "CHECKBOX",
|
247
327
|
SELECT: "SELECT",
|
@@ -251,7 +331,8 @@ var FieldType = {
|
|
251
331
|
ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
|
252
332
|
FACILITY: "FACILITY",
|
253
333
|
OFFICE: "OFFICE",
|
254
|
-
SIGNATURE: "SIGNATURE"
|
334
|
+
SIGNATURE: "SIGNATURE",
|
335
|
+
DATA: "DATA"
|
255
336
|
};
|
256
337
|
var fieldTypes = Object.values(FieldType);
|
257
338
|
var compositeFieldTypes = [
|
@@ -269,6 +350,10 @@ var GeographicalArea = {
|
|
269
350
|
URBAN: "URBAN",
|
270
351
|
RURAL: "RURAL"
|
271
352
|
};
|
353
|
+
var AddressType = {
|
354
|
+
DOMESTIC: "DOMESTIC",
|
355
|
+
INTERNATIONAL: "INTERNATIONAL"
|
356
|
+
};
|
272
357
|
var FileFieldValue = import_zod3.z.object({
|
273
358
|
filename: import_zod3.z.string(),
|
274
359
|
originalFilename: import_zod3.z.string(),
|
@@ -276,6 +361,7 @@ var FileFieldValue = import_zod3.z.object({
|
|
276
361
|
});
|
277
362
|
var AdminStructure = import_zod3.z.object({
|
278
363
|
country: import_zod3.z.string(),
|
364
|
+
addressType: import_zod3.z.literal(AddressType.DOMESTIC),
|
279
365
|
province: import_zod3.z.string(),
|
280
366
|
district: import_zod3.z.string()
|
281
367
|
});
|
@@ -303,14 +389,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
|
|
303
389
|
urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
|
304
390
|
village: import_zod3.z.string().nullish()
|
305
391
|
});
|
306
|
-
var
|
307
|
-
|
308
|
-
|
309
|
-
|
392
|
+
var GenericAddressValue = import_zod3.z.object({
|
393
|
+
country: import_zod3.z.string(),
|
394
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
395
|
+
state: import_zod3.z.string(),
|
396
|
+
district2: import_zod3.z.string(),
|
397
|
+
cityOrTown: import_zod3.z.string().optional(),
|
398
|
+
addressLine1: import_zod3.z.string().optional(),
|
399
|
+
addressLine2: import_zod3.z.string().optional(),
|
400
|
+
addressLine3: import_zod3.z.string().optional(),
|
401
|
+
postcodeOrZip: import_zod3.z.string().optional()
|
402
|
+
});
|
403
|
+
var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
|
404
|
+
var GenericAddressUpdateValue = import_zod3.z.object({
|
405
|
+
country: import_zod3.z.string(),
|
406
|
+
addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
|
407
|
+
state: import_zod3.z.string(),
|
408
|
+
district2: import_zod3.z.string(),
|
409
|
+
cityOrTown: import_zod3.z.string().nullish(),
|
410
|
+
addressLine1: import_zod3.z.string().nullish(),
|
411
|
+
addressLine2: import_zod3.z.string().nullish(),
|
412
|
+
addressLine3: import_zod3.z.string().nullish(),
|
413
|
+
postcodeOrZip: import_zod3.z.string().nullish()
|
414
|
+
});
|
310
415
|
var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
|
311
416
|
UrbanAddressUpdateValue,
|
312
417
|
RuralAddressUpdateValue
|
313
|
-
]);
|
418
|
+
]).or(GenericAddressUpdateValue);
|
314
419
|
var FileFieldValueWithOption = import_zod3.z.object({
|
315
420
|
filename: import_zod3.z.string(),
|
316
421
|
originalFilename: import_zod3.z.string(),
|
@@ -321,11 +426,12 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
|
|
321
426
|
|
322
427
|
// ../commons/src/events/FieldValue.ts
|
323
428
|
var TextValue = import_zod4.z.string();
|
324
|
-
var
|
429
|
+
var NonEmptyTextValue = TextValue.min(1);
|
325
430
|
var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
|
326
431
|
var EmailValue = import_zod4.z.string().email();
|
327
432
|
var CheckboxFieldValue = import_zod4.z.boolean();
|
328
433
|
var NumberFieldValue = import_zod4.z.number();
|
434
|
+
var DataFieldValue = import_zod4.z.undefined();
|
329
435
|
var FieldValue = import_zod4.z.union([
|
330
436
|
TextValue,
|
331
437
|
DateValue,
|
@@ -334,7 +440,9 @@ var FieldValue = import_zod4.z.union([
|
|
334
440
|
FileFieldValue,
|
335
441
|
FileFieldWithOptionValue,
|
336
442
|
UrbanAddressValue,
|
337
|
-
RuralAddressValue
|
443
|
+
RuralAddressValue,
|
444
|
+
DataFieldValue,
|
445
|
+
GenericAddressValue
|
338
446
|
]);
|
339
447
|
var FieldUpdateValue = import_zod4.z.union([
|
340
448
|
TextValue,
|
@@ -344,40 +452,35 @@ var FieldUpdateValue = import_zod4.z.union([
|
|
344
452
|
FileFieldValue,
|
345
453
|
FileFieldWithOptionValue,
|
346
454
|
UrbanAddressUpdateValue,
|
347
|
-
RuralAddressUpdateValue
|
455
|
+
RuralAddressUpdateValue,
|
456
|
+
DataFieldValue,
|
457
|
+
GenericAddressUpdateValue
|
348
458
|
]);
|
349
459
|
|
350
460
|
// ../commons/src/events/FieldConfig.ts
|
351
461
|
var FieldId = import_zod5.z.string();
|
352
|
-
var
|
353
|
-
|
354
|
-
|
355
|
-
});
|
462
|
+
var ParentReference = import_zod5.z.object({
|
463
|
+
_fieldId: FieldId.optional()
|
464
|
+
}).optional();
|
356
465
|
var BaseField = import_zod5.z.object({
|
357
466
|
id: FieldId,
|
358
467
|
defaultValue: import_zod5.z.union([
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
NumberFieldValue,
|
365
|
-
CheckboxFieldValue
|
366
|
-
]),
|
367
|
-
DependencyExpression
|
468
|
+
TextValue,
|
469
|
+
NonEmptyTextValue,
|
470
|
+
DateValue,
|
471
|
+
NumberFieldValue,
|
472
|
+
CheckboxFieldValue
|
368
473
|
]).optional(),
|
369
|
-
|
474
|
+
parent: ParentReference,
|
475
|
+
conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
|
370
476
|
required: import_zod5.z.boolean().default(false).optional(),
|
371
|
-
disabled: import_zod5.z.boolean().default(false).optional(),
|
372
|
-
hidden: import_zod5.z.boolean().default(false).optional(),
|
373
477
|
placeholder: TranslationConfig.optional(),
|
374
478
|
validation: import_zod5.z.array(
|
375
479
|
import_zod5.z.object({
|
376
|
-
validator: Conditional
|
480
|
+
validator: Conditional,
|
377
481
|
message: TranslationConfig
|
378
482
|
})
|
379
483
|
).default([]).optional(),
|
380
|
-
dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
|
381
484
|
label: TranslationConfig,
|
382
485
|
hideLabel: import_zod5.z.boolean().default(false).optional()
|
383
486
|
});
|
@@ -386,7 +489,7 @@ var Divider = BaseField.extend({
|
|
386
489
|
});
|
387
490
|
var TextField = BaseField.extend({
|
388
491
|
type: import_zod5.z.literal(FieldType.TEXT),
|
389
|
-
defaultValue:
|
492
|
+
defaultValue: NonEmptyTextValue.optional(),
|
390
493
|
configuration: import_zod5.z.object({
|
391
494
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
392
495
|
type: import_zod5.z.enum(["text", "password"]).optional(),
|
@@ -396,7 +499,7 @@ var TextField = BaseField.extend({
|
|
396
499
|
}).describe("Text input");
|
397
500
|
var NumberField = BaseField.extend({
|
398
501
|
type: import_zod5.z.literal(FieldType.NUMBER),
|
399
|
-
defaultValue:
|
502
|
+
defaultValue: NumberFieldValue.optional(),
|
400
503
|
configuration: import_zod5.z.object({
|
401
504
|
min: import_zod5.z.number().optional().describe("Minimum value"),
|
402
505
|
max: import_zod5.z.number().optional().describe("Maximum value"),
|
@@ -406,7 +509,7 @@ var NumberField = BaseField.extend({
|
|
406
509
|
}).describe("Number input");
|
407
510
|
var TextAreaField = BaseField.extend({
|
408
511
|
type: import_zod5.z.literal(FieldType.TEXTAREA),
|
409
|
-
defaultValue:
|
512
|
+
defaultValue: NonEmptyTextValue.optional(),
|
410
513
|
configuration: import_zod5.z.object({
|
411
514
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
|
412
515
|
rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
|
@@ -415,26 +518,36 @@ var TextAreaField = BaseField.extend({
|
|
415
518
|
postfix: TranslationConfig.optional()
|
416
519
|
}).default({ rows: 4 }).optional()
|
417
520
|
}).describe("Multiline text input");
|
521
|
+
var ImageMimeType = import_zod5.z.enum([
|
522
|
+
"image/png",
|
523
|
+
"image/jpg",
|
524
|
+
"image/jpeg",
|
525
|
+
"image/svg+xml"
|
526
|
+
]);
|
527
|
+
var MimeType = ImageMimeType;
|
528
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
418
529
|
var SignatureField = BaseField.extend({
|
419
530
|
type: import_zod5.z.literal(FieldType.SIGNATURE),
|
420
531
|
signaturePromptLabel: TranslationConfig.describe(
|
421
532
|
"Title of the signature modal"
|
422
533
|
),
|
423
534
|
configuration: import_zod5.z.object({
|
424
|
-
|
425
|
-
|
426
|
-
}).default({
|
535
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
536
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
537
|
+
}).default({
|
538
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
539
|
+
})
|
427
540
|
}).describe("Signature input field");
|
428
541
|
var EmailField = BaseField.extend({
|
429
542
|
type: import_zod5.z.literal(FieldType.EMAIL),
|
430
543
|
configuration: import_zod5.z.object({
|
431
544
|
maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
|
432
545
|
}).default({ maxLength: 10 }).optional(),
|
433
|
-
defaultValue:
|
546
|
+
defaultValue: NonEmptyTextValue.optional()
|
434
547
|
});
|
435
548
|
var DateField = BaseField.extend({
|
436
549
|
type: import_zod5.z.literal(FieldType.DATE),
|
437
|
-
defaultValue:
|
550
|
+
defaultValue: DateValue.optional(),
|
438
551
|
configuration: import_zod5.z.object({
|
439
552
|
notice: TranslationConfig.describe(
|
440
553
|
"Text to display above the date input"
|
@@ -453,7 +566,7 @@ var HtmlFontVariant = import_zod5.z.enum([
|
|
453
566
|
]);
|
454
567
|
var Paragraph = BaseField.extend({
|
455
568
|
type: import_zod5.z.literal(FieldType.PARAGRAPH),
|
456
|
-
defaultValue:
|
569
|
+
defaultValue: NonEmptyTextValue.optional(),
|
457
570
|
configuration: import_zod5.z.object({
|
458
571
|
styles: import_zod5.z.object({
|
459
572
|
fontVariant: HtmlFontVariant.optional()
|
@@ -462,17 +575,22 @@ var Paragraph = BaseField.extend({
|
|
462
575
|
}).describe("A read-only HTML <p> paragraph");
|
463
576
|
var PageHeader = BaseField.extend({
|
464
577
|
type: import_zod5.z.literal(FieldType.PAGE_HEADER),
|
465
|
-
defaultValue:
|
578
|
+
defaultValue: NonEmptyTextValue.optional()
|
466
579
|
}).describe("A read-only header component for form pages");
|
467
580
|
var File = BaseField.extend({
|
468
581
|
type: import_zod5.z.literal(FieldType.FILE),
|
469
|
-
|
582
|
+
configuration: import_zod5.z.object({
|
583
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
584
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
470
585
|
style: import_zod5.z.object({
|
471
|
-
|
586
|
+
width: import_zod5.z.enum(["full", "auto"]).optional().describe(
|
472
587
|
"Whether the file upload button should take the full width of the container or not"
|
473
588
|
)
|
474
|
-
})
|
475
|
-
|
589
|
+
}).optional(),
|
590
|
+
fileName: TranslationConfig.optional()
|
591
|
+
}).default({
|
592
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
593
|
+
})
|
476
594
|
}).describe("File upload");
|
477
595
|
var SelectOption = import_zod5.z.object({
|
478
596
|
value: import_zod5.z.string().describe("The value of the option"),
|
@@ -480,7 +598,7 @@ var SelectOption = import_zod5.z.object({
|
|
480
598
|
});
|
481
599
|
var RadioGroup = BaseField.extend({
|
482
600
|
type: import_zod5.z.literal(FieldType.RADIO_GROUP),
|
483
|
-
defaultValue:
|
601
|
+
defaultValue: TextValue.optional(),
|
484
602
|
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
485
603
|
configuration: import_zod5.z.object({
|
486
604
|
styles: import_zod5.z.object({
|
@@ -490,7 +608,7 @@ var RadioGroup = BaseField.extend({
|
|
490
608
|
}).describe("Grouped radio options");
|
491
609
|
var BulletList = BaseField.extend({
|
492
610
|
type: import_zod5.z.literal(FieldType.BULLET_LIST),
|
493
|
-
defaultValue:
|
611
|
+
defaultValue: TextValue.optional(),
|
494
612
|
items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
|
495
613
|
configuration: import_zod5.z.object({
|
496
614
|
styles: import_zod5.z.object({
|
@@ -500,16 +618,16 @@ var BulletList = BaseField.extend({
|
|
500
618
|
}).describe("A list of bullet points");
|
501
619
|
var Select = BaseField.extend({
|
502
620
|
type: import_zod5.z.literal(FieldType.SELECT),
|
503
|
-
defaultValue:
|
621
|
+
defaultValue: TextValue.optional(),
|
504
622
|
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
505
623
|
}).describe("Select input");
|
506
624
|
var Checkbox = BaseField.extend({
|
507
625
|
type: import_zod5.z.literal(FieldType.CHECKBOX),
|
508
|
-
defaultValue:
|
626
|
+
defaultValue: CheckboxFieldValue.optional()
|
509
627
|
}).describe("Boolean checkbox field");
|
510
628
|
var Country = BaseField.extend({
|
511
629
|
type: import_zod5.z.literal(FieldType.COUNTRY),
|
512
|
-
defaultValue:
|
630
|
+
defaultValue: NonEmptyTextValue.optional()
|
513
631
|
}).describe("Country select field");
|
514
632
|
var AdministrativeAreas = import_zod5.z.enum([
|
515
633
|
"ADMIN_STRUCTURE",
|
@@ -518,35 +636,57 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
518
636
|
]);
|
519
637
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
520
638
|
partOf: import_zod5.z.object({
|
521
|
-
$
|
639
|
+
$declaration: import_zod5.z.string()
|
522
640
|
}).optional().describe("Parent location"),
|
523
641
|
type: AdministrativeAreas
|
524
642
|
}).describe("Administrative area options");
|
525
643
|
var AdministrativeArea = BaseField.extend({
|
526
644
|
type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
527
|
-
defaultValue:
|
645
|
+
defaultValue: NonEmptyTextValue.optional(),
|
528
646
|
configuration: AdministrativeAreaConfiguration
|
529
647
|
}).describe("Administrative area input field e.g. facility, office");
|
530
648
|
var Location = BaseField.extend({
|
531
649
|
type: import_zod5.z.literal(FieldType.LOCATION),
|
532
|
-
defaultValue:
|
650
|
+
defaultValue: NonEmptyTextValue.optional()
|
533
651
|
}).describe("Input field for a location");
|
534
652
|
var FileUploadWithOptions = BaseField.extend({
|
535
653
|
type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
|
536
|
-
options: import_zod5.z.array(SelectOption).describe("A list of options")
|
537
|
-
|
654
|
+
options: import_zod5.z.array(SelectOption).describe("A list of options"),
|
655
|
+
configuration: import_zod5.z.object({
|
656
|
+
maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
657
|
+
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
658
|
+
}).default({
|
659
|
+
maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
|
660
|
+
})
|
661
|
+
});
|
538
662
|
var Facility = BaseField.extend({
|
539
663
|
type: import_zod5.z.literal(FieldType.FACILITY),
|
540
|
-
defaultValue:
|
664
|
+
defaultValue: NonEmptyTextValue.optional()
|
541
665
|
}).describe("Input field for a facility");
|
542
666
|
var Office = BaseField.extend({
|
543
667
|
type: import_zod5.z.literal(FieldType.OFFICE),
|
544
|
-
defaultValue:
|
668
|
+
defaultValue: NonEmptyTextValue.optional()
|
545
669
|
}).describe("Input field for an office");
|
546
670
|
var Address = BaseField.extend({
|
547
671
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
548
672
|
defaultValue: AddressFieldValue.optional()
|
549
673
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
674
|
+
var DataEntry = import_zod5.z.union([
|
675
|
+
import_zod5.z.object({
|
676
|
+
label: TranslationConfig,
|
677
|
+
value: TranslationConfig.or(import_zod5.z.string())
|
678
|
+
}),
|
679
|
+
import_zod5.z.object({
|
680
|
+
fieldId: import_zod5.z.string()
|
681
|
+
})
|
682
|
+
]);
|
683
|
+
var DataField = BaseField.extend({
|
684
|
+
type: import_zod5.z.literal(FieldType.DATA),
|
685
|
+
configuration: import_zod5.z.object({
|
686
|
+
subtitle: TranslationConfig.optional(),
|
687
|
+
data: import_zod5.z.array(DataEntry)
|
688
|
+
})
|
689
|
+
}).describe("Data field for displaying read-only data");
|
550
690
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
551
691
|
Address,
|
552
692
|
TextField,
|
@@ -568,238 +708,331 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
568
708
|
Office,
|
569
709
|
SignatureField,
|
570
710
|
EmailField,
|
571
|
-
FileUploadWithOptions
|
711
|
+
FileUploadWithOptions,
|
712
|
+
DataField
|
572
713
|
]);
|
573
714
|
|
574
|
-
// ../commons/src/events/
|
575
|
-
var
|
715
|
+
// ../commons/src/events/PageConfig.ts
|
716
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
717
|
+
var PageConfigBase = import_zod6.z.object({
|
576
718
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
577
719
|
title: TranslationConfig.describe("Header title of the page"),
|
578
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
720
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
721
|
+
conditional: Conditional.optional().describe(
|
722
|
+
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
723
|
+
)
|
579
724
|
});
|
580
|
-
var
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
label: TranslationConfig
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
pages: import_zod6.z.array(FormPage),
|
592
|
-
review: import_zod6.z.object({
|
593
|
-
title: TranslationConfig.describe(
|
594
|
-
"Title of the form to show in review page"
|
595
|
-
),
|
596
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
725
|
+
var FormPageConfig = PageConfigBase.extend({
|
726
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
727
|
+
});
|
728
|
+
var VerificationActionConfig = import_zod6.z.object({
|
729
|
+
verify: import_zod6.z.object({ label: TranslationConfig }),
|
730
|
+
cancel: import_zod6.z.object({
|
731
|
+
label: TranslationConfig,
|
732
|
+
confirmation: import_zod6.z.object({
|
733
|
+
title: TranslationConfig,
|
734
|
+
body: TranslationConfig
|
735
|
+
})
|
597
736
|
})
|
737
|
+
}).describe("Actions available on the verification page");
|
738
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
739
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
740
|
+
actions: VerificationActionConfig
|
598
741
|
});
|
742
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
743
|
+
FormPageConfig,
|
744
|
+
VerificationPageConfig
|
745
|
+
]);
|
599
746
|
|
600
747
|
// ../commons/src/events/ActionType.ts
|
748
|
+
var import_zod7 = require("zod");
|
601
749
|
var ActionType = {
|
750
|
+
// Pre-declaration actions
|
751
|
+
DELETE: "DELETE",
|
602
752
|
CREATE: "CREATE",
|
603
|
-
ASSIGN: "ASSIGN",
|
604
|
-
UNASSIGN: "UNASSIGN",
|
605
|
-
REGISTER: "REGISTER",
|
606
|
-
VALIDATE: "VALIDATE",
|
607
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
608
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
609
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
610
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
611
753
|
NOTIFY: "NOTIFY",
|
754
|
+
// Declaration actions
|
612
755
|
DECLARE: "DECLARE",
|
613
|
-
|
614
|
-
|
615
|
-
|
756
|
+
VALIDATE: "VALIDATE",
|
757
|
+
REGISTER: "REGISTER",
|
758
|
+
// Declaration system actions. Non-configurable.
|
759
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
616
760
|
REJECT: "REJECT",
|
761
|
+
// REJECT_DECLARATION
|
617
762
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
618
|
-
|
763
|
+
// MARK_AS_DUPLICATE
|
764
|
+
ARCHIVE: "ARCHIVE",
|
765
|
+
// Record actions
|
766
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
767
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
768
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
769
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
770
|
+
// General actions
|
771
|
+
READ: "READ",
|
772
|
+
ASSIGN: "ASSIGN",
|
773
|
+
UNASSIGN: "UNASSIGN"
|
619
774
|
};
|
775
|
+
var ConfirmableActions = [
|
776
|
+
ActionType.NOTIFY,
|
777
|
+
ActionType.DECLARE,
|
778
|
+
ActionType.VALIDATE,
|
779
|
+
ActionType.REGISTER,
|
780
|
+
ActionType.REJECT,
|
781
|
+
ActionType.ARCHIVE,
|
782
|
+
ActionType.PRINT_CERTIFICATE
|
783
|
+
];
|
784
|
+
var ActionTypes = import_zod7.z.enum([
|
785
|
+
"DELETE",
|
786
|
+
"CREATE",
|
787
|
+
"NOTIFY",
|
788
|
+
"DECLARE",
|
789
|
+
"VALIDATE",
|
790
|
+
"REGISTER",
|
791
|
+
"DETECT_DUPLICATE",
|
792
|
+
"REJECT",
|
793
|
+
"MARKED_AS_DUPLICATE",
|
794
|
+
"ARCHIVE",
|
795
|
+
"PRINT_CERTIFICATE",
|
796
|
+
"REQUEST_CORRECTION",
|
797
|
+
"REJECT_CORRECTION",
|
798
|
+
"APPROVE_CORRECTION",
|
799
|
+
"READ",
|
800
|
+
"ASSIGN",
|
801
|
+
"UNASSIGN"
|
802
|
+
]);
|
803
|
+
var declarationActionValues = [
|
804
|
+
ActionTypes.enum.DECLARE,
|
805
|
+
ActionTypes.enum.VALIDATE,
|
806
|
+
ActionTypes.enum.REGISTER
|
807
|
+
];
|
808
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
809
|
+
var declarationUpdateActionValues = [
|
810
|
+
...declarationActionValues,
|
811
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
812
|
+
];
|
813
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
814
|
+
declarationUpdateActionValues
|
815
|
+
);
|
816
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
817
|
+
var writeActions = ActionTypes.exclude([
|
818
|
+
ActionType.CREATE,
|
819
|
+
ActionType.READ,
|
820
|
+
ActionType.ASSIGN,
|
821
|
+
ActionType.UNASSIGN
|
822
|
+
]);
|
823
|
+
|
824
|
+
// ../commons/src/events/FormConfig.ts
|
825
|
+
var import_zod8 = require("zod");
|
826
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
827
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
828
|
+
pages: import_zod8.z.array(FormPageConfig)
|
829
|
+
}).describe("Configuration for a declaration form");
|
830
|
+
var ActionFormConfig = import_zod8.z.object({
|
831
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
832
|
+
pages: import_zod8.z.array(PageConfig)
|
833
|
+
});
|
834
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
620
835
|
|
621
836
|
// ../commons/src/events/ActionConfig.ts
|
622
|
-
var
|
837
|
+
var import_zod_openapi = require("zod-openapi");
|
838
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
|
839
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
623
840
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
624
841
|
ShowConditional,
|
625
842
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
626
843
|
EnableConditional
|
627
844
|
]);
|
628
|
-
var
|
845
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
846
|
+
title: TranslationConfig.describe("Title of the review page"),
|
847
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
848
|
+
}).describe("Configuration for **declaration** review page.");
|
849
|
+
var ActionConfigBase = import_zod9.z.object({
|
629
850
|
label: TranslationConfig,
|
630
|
-
conditionals:
|
631
|
-
draft:
|
632
|
-
forms: import_zod7.z.array(FormConfig)
|
851
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
852
|
+
draft: import_zod9.z.boolean().optional()
|
633
853
|
});
|
634
854
|
var DeclareConfig = ActionConfigBase.merge(
|
635
|
-
|
636
|
-
type:
|
855
|
+
import_zod9.z.object({
|
856
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
857
|
+
review: DeclarationReviewConfig
|
637
858
|
})
|
638
859
|
);
|
639
860
|
var ValidateConfig = ActionConfigBase.merge(
|
640
|
-
|
641
|
-
type:
|
861
|
+
import_zod9.z.object({
|
862
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
863
|
+
review: DeclarationReviewConfig
|
864
|
+
})
|
865
|
+
);
|
866
|
+
var RegisterConfig = ActionConfigBase.merge(
|
867
|
+
import_zod9.z.object({
|
868
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
869
|
+
review: DeclarationReviewConfig
|
642
870
|
})
|
643
871
|
);
|
644
872
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
645
|
-
|
646
|
-
type:
|
873
|
+
import_zod9.z.object({
|
874
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
647
875
|
})
|
648
876
|
);
|
649
877
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
650
|
-
|
651
|
-
type:
|
878
|
+
import_zod9.z.object({
|
879
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
652
880
|
})
|
653
881
|
);
|
654
882
|
var ArchiveConfig = ActionConfigBase.merge(
|
655
|
-
|
656
|
-
type:
|
657
|
-
})
|
658
|
-
);
|
659
|
-
var RegisterConfig = ActionConfigBase.merge(
|
660
|
-
import_zod7.z.object({
|
661
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
883
|
+
import_zod9.z.object({
|
884
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
662
885
|
})
|
663
886
|
);
|
664
887
|
var DeleteConfig = ActionConfigBase.merge(
|
665
|
-
|
666
|
-
type:
|
888
|
+
import_zod9.z.object({
|
889
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
667
890
|
})
|
668
891
|
);
|
669
892
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
670
|
-
|
671
|
-
type:
|
893
|
+
import_zod9.z.object({
|
894
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
895
|
+
printForm: ActionFormConfig
|
672
896
|
})
|
673
897
|
);
|
674
898
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
675
|
-
|
676
|
-
type:
|
677
|
-
onboardingForm:
|
678
|
-
additionalDetailsForm:
|
899
|
+
import_zod9.z.object({
|
900
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
901
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
902
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
679
903
|
})
|
680
904
|
);
|
681
905
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
682
|
-
|
683
|
-
type:
|
906
|
+
import_zod9.z.object({
|
907
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
684
908
|
})
|
685
909
|
);
|
686
910
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
687
|
-
|
688
|
-
type:
|
689
|
-
})
|
690
|
-
);
|
691
|
-
var CustomConfig = ActionConfigBase.merge(
|
692
|
-
import_zod7.z.object({
|
693
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
911
|
+
import_zod9.z.object({
|
912
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
694
913
|
})
|
695
914
|
);
|
696
|
-
var ActionConfig =
|
915
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
916
|
+
/*
|
917
|
+
* OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
|
918
|
+
* and treat them as "models" instead of duplicating the data structure in each endpoint.
|
919
|
+
*/
|
920
|
+
DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
|
921
|
+
ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
|
922
|
+
RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
|
923
|
+
MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
|
924
|
+
ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
|
925
|
+
RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
|
926
|
+
DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
|
927
|
+
PrintCertificateActionConfig.openapi({
|
928
|
+
ref: "PrintCertificateActionConfig"
|
929
|
+
}),
|
930
|
+
RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
|
931
|
+
RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
|
932
|
+
ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
|
933
|
+
]).openapi({ ref: "ActionConfig" });
|
934
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
697
935
|
DeclareConfig,
|
698
936
|
ValidateConfig,
|
699
|
-
|
700
|
-
MarkedAsDuplicateConfig,
|
701
|
-
ArchiveConfig,
|
702
|
-
RegisterConfig,
|
703
|
-
DeleteConfig,
|
704
|
-
PrintCertificateActionConfig,
|
705
|
-
RequestCorrectionConfig,
|
706
|
-
RejectCorrectionConfig,
|
707
|
-
ApproveCorrectionConfig,
|
708
|
-
CustomConfig
|
937
|
+
RegisterConfig
|
709
938
|
]);
|
710
939
|
|
711
940
|
// ../commons/src/events/offline/CertificateConfig.ts
|
712
|
-
var
|
713
|
-
var FontFamily =
|
714
|
-
normal:
|
715
|
-
bold:
|
716
|
-
italics:
|
717
|
-
bolditalics:
|
941
|
+
var import_zod10 = require("zod");
|
942
|
+
var FontFamily = import_zod10.z.object({
|
943
|
+
normal: import_zod10.z.string(),
|
944
|
+
bold: import_zod10.z.string(),
|
945
|
+
italics: import_zod10.z.string(),
|
946
|
+
bolditalics: import_zod10.z.string()
|
718
947
|
});
|
719
|
-
var CertificateConfig =
|
720
|
-
id:
|
721
|
-
event:
|
948
|
+
var CertificateConfig = import_zod10.z.object({
|
949
|
+
id: import_zod10.z.string(),
|
950
|
+
event: import_zod10.z.string(),
|
722
951
|
label: TranslationConfig,
|
723
|
-
isDefault:
|
724
|
-
fee:
|
725
|
-
onTime:
|
726
|
-
late:
|
727
|
-
delayed:
|
952
|
+
isDefault: import_zod10.z.boolean(),
|
953
|
+
fee: import_zod10.z.object({
|
954
|
+
onTime: import_zod10.z.number(),
|
955
|
+
late: import_zod10.z.number(),
|
956
|
+
delayed: import_zod10.z.number()
|
728
957
|
}),
|
729
|
-
svgUrl:
|
730
|
-
fonts:
|
958
|
+
svgUrl: import_zod10.z.string(),
|
959
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
731
960
|
});
|
732
961
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
733
|
-
hash:
|
734
|
-
svg:
|
962
|
+
hash: import_zod10.z.string().optional(),
|
963
|
+
svg: import_zod10.z.string()
|
735
964
|
});
|
736
965
|
|
737
966
|
// ../commons/src/events/offline/LanguageConfig.ts
|
738
|
-
var
|
739
|
-
var LanguageConfig =
|
740
|
-
lang:
|
967
|
+
var import_zod11 = require("zod");
|
968
|
+
var LanguageConfig = import_zod11.z.object({
|
969
|
+
lang: import_zod11.z.string(),
|
741
970
|
/**
|
742
971
|
* client.csv contents
|
743
972
|
*/
|
744
|
-
messages:
|
973
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
745
974
|
});
|
746
975
|
|
747
976
|
// ../commons/src/events/EventConfig.ts
|
748
|
-
var
|
977
|
+
var import_zod16 = require("zod");
|
749
978
|
|
750
979
|
// ../commons/src/events/DeduplicationConfig.ts
|
751
|
-
var
|
752
|
-
var
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
980
|
+
var import_zod12 = require("zod");
|
981
|
+
var import_zod_openapi2 = require("zod-openapi");
|
982
|
+
(0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
|
983
|
+
var FieldReference = import_zod12.z.string();
|
984
|
+
var Matcher = import_zod12.z.object({
|
985
|
+
fieldId: import_zod12.z.string(),
|
986
|
+
options: import_zod12.z.object({
|
987
|
+
boost: import_zod12.z.number().optional()
|
757
988
|
}).optional().default({})
|
758
989
|
});
|
759
990
|
var FuzzyMatcher = Matcher.extend({
|
760
|
-
type:
|
761
|
-
options:
|
991
|
+
type: import_zod12.z.literal("fuzzy"),
|
992
|
+
options: import_zod12.z.object({
|
762
993
|
/**
|
763
994
|
* Names of length 3 or less characters = 0 edits allowed
|
764
995
|
* Names of length 4 - 6 characters = 1 edit allowed
|
765
996
|
* Names of length >7 characters = 2 edits allowed
|
766
997
|
*/
|
767
|
-
fuzziness:
|
768
|
-
boost:
|
998
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
999
|
+
boost: import_zod12.z.number().optional().default(1)
|
769
1000
|
}).optional().default({})
|
770
1001
|
});
|
771
1002
|
var StrictMatcher = Matcher.extend({
|
772
|
-
type:
|
773
|
-
options:
|
774
|
-
boost:
|
1003
|
+
type: import_zod12.z.literal("strict"),
|
1004
|
+
options: import_zod12.z.object({
|
1005
|
+
boost: import_zod12.z.number().optional().default(1)
|
775
1006
|
}).optional().default({})
|
776
1007
|
});
|
777
1008
|
var DateRangeMatcher = Matcher.extend({
|
778
|
-
type:
|
779
|
-
options:
|
780
|
-
days:
|
1009
|
+
type: import_zod12.z.literal("dateRange"),
|
1010
|
+
options: import_zod12.z.object({
|
1011
|
+
days: import_zod12.z.number(),
|
781
1012
|
origin: FieldReference,
|
782
|
-
boost:
|
1013
|
+
boost: import_zod12.z.number().optional().default(1)
|
783
1014
|
})
|
784
1015
|
});
|
785
1016
|
var DateDistanceMatcher = Matcher.extend({
|
786
|
-
type:
|
787
|
-
options:
|
788
|
-
days:
|
1017
|
+
type: import_zod12.z.literal("dateDistance"),
|
1018
|
+
options: import_zod12.z.object({
|
1019
|
+
days: import_zod12.z.number(),
|
789
1020
|
origin: FieldReference,
|
790
|
-
boost:
|
1021
|
+
boost: import_zod12.z.number().optional().default(1)
|
791
1022
|
})
|
792
1023
|
});
|
793
|
-
var And =
|
794
|
-
type:
|
795
|
-
|
1024
|
+
var And = import_zod12.z.object({
|
1025
|
+
type: import_zod12.z.literal("and"),
|
1026
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1027
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
796
1028
|
});
|
797
|
-
var Or =
|
798
|
-
type:
|
799
|
-
|
1029
|
+
var Or = import_zod12.z.object({
|
1030
|
+
type: import_zod12.z.literal("or"),
|
1031
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
1032
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
800
1033
|
});
|
801
|
-
var Clause =
|
802
|
-
() =>
|
1034
|
+
var Clause = import_zod12.z.lazy(
|
1035
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
803
1036
|
And,
|
804
1037
|
Or,
|
805
1038
|
FuzzyMatcher,
|
@@ -807,275 +1040,73 @@ var Clause = import_zod10.z.lazy(
|
|
807
1040
|
DateRangeMatcher,
|
808
1041
|
DateDistanceMatcher
|
809
1042
|
])
|
810
|
-
)
|
811
|
-
|
812
|
-
|
1043
|
+
).openapi({
|
1044
|
+
ref: "Clause"
|
1045
|
+
});
|
1046
|
+
var DeduplicationConfig = import_zod12.z.object({
|
1047
|
+
id: import_zod12.z.string(),
|
813
1048
|
label: TranslationConfig,
|
814
1049
|
query: Clause
|
815
1050
|
});
|
816
1051
|
|
817
1052
|
// ../commons/src/events/SummaryConfig.ts
|
818
|
-
var
|
819
|
-
var
|
820
|
-
|
1053
|
+
var import_zod13 = require("zod");
|
1054
|
+
var BaseField2 = import_zod13.z.object({
|
1055
|
+
emptyValueMessage: TranslationConfig.optional(),
|
1056
|
+
conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
|
1057
|
+
});
|
1058
|
+
var ReferenceField = BaseField2.extend({
|
1059
|
+
fieldId: import_zod13.z.string()
|
1060
|
+
}).describe("Field directly referencing event data with field id");
|
1061
|
+
var Field = BaseField2.extend({
|
1062
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
821
1063
|
value: TranslationConfig.describe(
|
822
1064
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
823
1065
|
),
|
824
1066
|
label: TranslationConfig,
|
825
1067
|
emptyValueMessage: TranslationConfig.optional()
|
826
|
-
});
|
827
|
-
var
|
828
|
-
|
829
|
-
label: TranslationConfig.describe("Title content"),
|
830
|
-
emptyValueMessage: TranslationConfig.optional()
|
831
|
-
});
|
832
|
-
var SummaryConfig = import_zod11.z.object({
|
833
|
-
title: Title.describe("Title of summary view."),
|
834
|
-
fields: import_zod11.z.array(Field).describe("Fields rendered in summary view.")
|
1068
|
+
}).describe("Custom configured field");
|
1069
|
+
var SummaryConfig = import_zod13.z.object({
|
1070
|
+
fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
|
835
1071
|
}).describe("Configuration for summary in event.");
|
836
1072
|
|
837
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
838
|
-
var import_zod13 = require("zod");
|
839
|
-
|
840
|
-
// ../commons/src/events/EventMetadata.ts
|
841
|
-
var import_zod12 = require("zod");
|
842
|
-
var EventStatus = {
|
843
|
-
CREATED: "CREATED",
|
844
|
-
NOTIFIED: "NOTIFIED",
|
845
|
-
DECLARED: "DECLARED",
|
846
|
-
VALIDATED: "VALIDATED",
|
847
|
-
REGISTERED: "REGISTERED",
|
848
|
-
CERTIFIED: "CERTIFIED",
|
849
|
-
REJECTED: "REJECTED",
|
850
|
-
ARCHIVED: "ARCHIVED"
|
851
|
-
};
|
852
|
-
var eventStatuses = Object.values(EventStatus);
|
853
|
-
var EventStatuses = import_zod12.z.nativeEnum(EventStatus);
|
854
|
-
var EventMetadata = import_zod12.z.object({
|
855
|
-
id: import_zod12.z.string(),
|
856
|
-
type: import_zod12.z.string(),
|
857
|
-
status: EventStatuses,
|
858
|
-
createdAt: import_zod12.z.string().datetime(),
|
859
|
-
createdBy: import_zod12.z.string(),
|
860
|
-
createdAtLocation: import_zod12.z.string(),
|
861
|
-
modifiedAt: import_zod12.z.string().datetime(),
|
862
|
-
assignedTo: import_zod12.z.string().nullish(),
|
863
|
-
updatedBy: import_zod12.z.string(),
|
864
|
-
trackingId: import_zod12.z.string()
|
865
|
-
});
|
866
|
-
var eventMetadataLabelMap = {
|
867
|
-
"event.assignedTo": {
|
868
|
-
id: "event.assignedTo.label",
|
869
|
-
defaultMessage: "Assigned To",
|
870
|
-
description: "Assigned To"
|
871
|
-
},
|
872
|
-
"event.createdAt": {
|
873
|
-
id: "event.createdAt.label",
|
874
|
-
defaultMessage: "Created",
|
875
|
-
description: "Created At"
|
876
|
-
},
|
877
|
-
"event.createdAtLocation": {
|
878
|
-
id: "event.createdAtLocation.label",
|
879
|
-
defaultMessage: "Location",
|
880
|
-
description: "Created At Location"
|
881
|
-
},
|
882
|
-
"event.createdBy": {
|
883
|
-
id: "event.createdBy.label",
|
884
|
-
defaultMessage: "Created By",
|
885
|
-
description: "Created By"
|
886
|
-
},
|
887
|
-
"event.id": {
|
888
|
-
id: "event.id.label",
|
889
|
-
defaultMessage: "ID",
|
890
|
-
description: "ID"
|
891
|
-
},
|
892
|
-
"event.modifiedAt": {
|
893
|
-
id: "event.modifiedAt.label",
|
894
|
-
defaultMessage: "Updated",
|
895
|
-
description: "Modified At"
|
896
|
-
},
|
897
|
-
"event.status": {
|
898
|
-
id: "event.status.label",
|
899
|
-
defaultMessage: "Status",
|
900
|
-
description: "Status"
|
901
|
-
},
|
902
|
-
"event.type": {
|
903
|
-
id: "event.type.label",
|
904
|
-
defaultMessage: "Type",
|
905
|
-
description: "Type"
|
906
|
-
},
|
907
|
-
"event.updatedBy": {
|
908
|
-
id: "event.updatedBy.label",
|
909
|
-
defaultMessage: "Updated By",
|
910
|
-
description: "Updated By"
|
911
|
-
},
|
912
|
-
"event.trackingId": {
|
913
|
-
id: "event.trackingId.label",
|
914
|
-
defaultMessage: "Tracking ID",
|
915
|
-
description: "Tracking ID"
|
916
|
-
}
|
917
|
-
};
|
918
|
-
|
919
|
-
// ../commons/src/events/WorkqueueConfig.ts
|
920
|
-
var WorkqueueConfig = import_zod13.z.object({
|
921
|
-
id: import_zod13.z.string().describe("Unique identifier for workqueue."),
|
922
|
-
filters: import_zod13.z.array(
|
923
|
-
import_zod13.z.object({
|
924
|
-
status: import_zod13.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
925
|
-
})
|
926
|
-
).describe("Filters to be applied to workqueue.")
|
927
|
-
}).describe("Configuration for workqueue.");
|
928
|
-
|
929
1073
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
930
1074
|
var import_zod14 = require("zod");
|
1075
|
+
var MatchType = import_zod14.z.enum(["FUZZY", "EXACT", "RANGE", "ANY_OF"]);
|
1076
|
+
var BaseField3 = import_zod14.z.object({
|
1077
|
+
config: import_zod14.z.object({
|
1078
|
+
type: MatchType.describe("Determines the type of field")
|
1079
|
+
}),
|
1080
|
+
options: import_zod14.z.array(SelectOption).optional()
|
1081
|
+
});
|
1082
|
+
var FieldConfigSchema = BaseField3.extend({
|
1083
|
+
fieldId: import_zod14.z.string(),
|
1084
|
+
fieldType: import_zod14.z.literal("field")
|
1085
|
+
});
|
1086
|
+
var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
|
1087
|
+
var EventFieldConfigSchema = BaseField3.extend({
|
1088
|
+
fieldId: EventFieldId,
|
1089
|
+
fieldType: import_zod14.z.literal("event")
|
1090
|
+
});
|
1091
|
+
var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
|
1092
|
+
FieldConfigSchema,
|
1093
|
+
EventFieldConfigSchema
|
1094
|
+
]);
|
931
1095
|
var AdvancedSearchConfig = import_zod14.z.object({
|
932
1096
|
title: TranslationConfig.describe("Advanced search tab title"),
|
933
|
-
fields: import_zod14.z.array(
|
934
|
-
import_zod14.z.object({
|
935
|
-
fieldId: import_zod14.z.string(),
|
936
|
-
config: import_zod14.z.object({
|
937
|
-
type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
938
|
-
}).optional().describe("Configuration options for the field")
|
939
|
-
})
|
940
|
-
).optional().default([]).describe("Advanced search fields.")
|
1097
|
+
fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
|
941
1098
|
});
|
942
1099
|
|
943
1100
|
// ../commons/src/events/utils.ts
|
944
1101
|
var import_lodash = require("lodash");
|
945
1102
|
|
946
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
947
|
-
var import_zod16 = require("zod");
|
948
|
-
|
949
|
-
// ../commons/src/workqueues/defaultColumns.ts
|
950
|
-
var import_zod15 = require("zod");
|
951
|
-
var WorkQueueColumnConfig = import_zod15.z.object({
|
952
|
-
id: import_zod15.z.string(),
|
953
|
-
label: TranslationConfig
|
954
|
-
});
|
955
|
-
var defaultColumns = {
|
956
|
-
event: {
|
957
|
-
id: "event",
|
958
|
-
label: {
|
959
|
-
defaultMessage: "Event",
|
960
|
-
description: "This is the label for the workqueue column",
|
961
|
-
id: "workqueue.default.column.event"
|
962
|
-
}
|
963
|
-
},
|
964
|
-
status: {
|
965
|
-
id: "status",
|
966
|
-
label: {
|
967
|
-
defaultMessage: "Status",
|
968
|
-
description: "This is the label for the workqueue column",
|
969
|
-
id: "workqueue.default.column.status"
|
970
|
-
}
|
971
|
-
},
|
972
|
-
createdAt: {
|
973
|
-
id: "createdAt",
|
974
|
-
label: {
|
975
|
-
defaultMessage: "Created",
|
976
|
-
description: "This is the label for the workqueue column",
|
977
|
-
id: "workqueue.default.column.createdAt"
|
978
|
-
}
|
979
|
-
},
|
980
|
-
modifiedAt: {
|
981
|
-
id: "modifiedAt",
|
982
|
-
label: {
|
983
|
-
defaultMessage: "Modified",
|
984
|
-
description: "This is the label for the workqueue column",
|
985
|
-
id: "workqueue.default.column.modifiedAt"
|
986
|
-
}
|
987
|
-
}
|
988
|
-
};
|
989
|
-
var DefaultColumnKeys = import_zod15.z.enum(
|
990
|
-
Object.keys(defaultColumns)
|
991
|
-
);
|
992
|
-
|
993
|
-
// ../commons/src/workqueues/WorkqueueConfig.ts
|
994
|
-
var rootWorkqueueConfig = import_zod16.z.object({
|
995
|
-
id: import_zod16.z.string(),
|
996
|
-
title: TranslationConfig,
|
997
|
-
columns: import_zod16.z.array(WorkQueueColumnConfig),
|
998
|
-
defaultColumns: import_zod16.z.array(DefaultColumnKeys)
|
999
|
-
});
|
1000
|
-
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1001
|
-
|
1002
|
-
// ../commons/src/workqueues/all.ts
|
1003
|
-
var allWorkqueue = defineWorkqueue({
|
1004
|
-
id: "all",
|
1005
|
-
title: {
|
1006
|
-
defaultMessage: "All events",
|
1007
|
-
description: "This is the label for the workqueue",
|
1008
|
-
id: "workqueue.all.label"
|
1009
|
-
},
|
1010
|
-
columns: [
|
1011
|
-
{
|
1012
|
-
id: "title",
|
1013
|
-
label: {
|
1014
|
-
defaultMessage: "Title",
|
1015
|
-
description: "This is the label for the workqueue column",
|
1016
|
-
id: "workqueue.all.column.title"
|
1017
|
-
}
|
1018
|
-
}
|
1019
|
-
],
|
1020
|
-
defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
|
1021
|
-
});
|
1022
|
-
|
1023
|
-
// ../commons/src/workqueues/readyForReview.ts
|
1024
|
-
var inReviewWorkqueue = defineWorkqueue({
|
1025
|
-
id: "ready-for-review",
|
1026
|
-
title: {
|
1027
|
-
defaultMessage: "Ready for review",
|
1028
|
-
description: "Label for in review workqueue",
|
1029
|
-
id: "event.workqueue.in-review.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.in-reveiw.column.title"
|
1038
|
-
}
|
1039
|
-
}
|
1040
|
-
],
|
1041
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1042
|
-
});
|
1043
|
-
|
1044
|
-
// ../commons/src/workqueues/readyToPrint.ts
|
1045
|
-
var registeredWorkqueue = defineWorkqueue({
|
1046
|
-
id: "registered",
|
1047
|
-
title: {
|
1048
|
-
defaultMessage: "Ready to print",
|
1049
|
-
description: "Label for registered workqueue",
|
1050
|
-
id: "event.workqueue.registered.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.registered.column.title"
|
1059
|
-
}
|
1060
|
-
}
|
1061
|
-
],
|
1062
|
-
defaultColumns: ["event", "createdAt", "modifiedAt"]
|
1063
|
-
});
|
1064
|
-
|
1065
|
-
// ../commons/src/workqueues/index.ts
|
1066
|
-
var workqueues = {
|
1067
|
-
all: allWorkqueue,
|
1068
|
-
registered: registeredWorkqueue,
|
1069
|
-
inReview: inReviewWorkqueue
|
1070
|
-
};
|
1071
|
-
|
1072
1103
|
// ../commons/src/conditionals/validate.ts
|
1073
1104
|
var import_ajv = __toESM(require("ajv"));
|
1074
1105
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
1075
1106
|
var import_date_fns = require("date-fns");
|
1076
1107
|
|
1077
1108
|
// ../commons/src/events/FieldTypeMapping.ts
|
1078
|
-
var
|
1109
|
+
var import_zod15 = require("zod");
|
1079
1110
|
function mapFieldTypeToZod(type, required) {
|
1080
1111
|
let schema;
|
1081
1112
|
switch (type) {
|
@@ -1099,8 +1130,7 @@ function mapFieldTypeToZod(type, required) {
|
|
1099
1130
|
case FieldType.FACILITY:
|
1100
1131
|
case FieldType.OFFICE:
|
1101
1132
|
case FieldType.SIGNATURE:
|
1102
|
-
|
1103
|
-
schema = required ? RequiredTextValue : TextValue;
|
1133
|
+
schema = required ? NonEmptyTextValue : TextValue;
|
1104
1134
|
break;
|
1105
1135
|
case FieldType.NUMBER:
|
1106
1136
|
schema = NumberFieldValue;
|
@@ -1117,6 +1147,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1117
1147
|
case FieldType.ADDRESS:
|
1118
1148
|
schema = AddressFieldUpdateValue;
|
1119
1149
|
break;
|
1150
|
+
case FieldType.DATA:
|
1151
|
+
schema = DataFieldValue;
|
1152
|
+
break;
|
1120
1153
|
}
|
1121
1154
|
return required ? schema : schema.nullish();
|
1122
1155
|
}
|
@@ -1125,7 +1158,7 @@ function createValidationSchema(config) {
|
|
1125
1158
|
for (const field2 of config) {
|
1126
1159
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1127
1160
|
}
|
1128
|
-
return
|
1161
|
+
return import_zod15.z.object(shape);
|
1129
1162
|
}
|
1130
1163
|
function mapFieldTypeToMockValue(field2, i) {
|
1131
1164
|
switch (field2.type) {
|
@@ -1151,6 +1184,7 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1151
1184
|
case FieldType.ADDRESS:
|
1152
1185
|
return {
|
1153
1186
|
country: "FAR",
|
1187
|
+
addressType: AddressType.DOMESTIC,
|
1154
1188
|
province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
|
1155
1189
|
district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
|
1156
1190
|
urbanOrRural: "URBAN",
|
@@ -1172,6 +1206,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1172
1206
|
};
|
1173
1207
|
case FieldType.FILE_WITH_OPTIONS:
|
1174
1208
|
return null;
|
1209
|
+
case FieldType.DATA:
|
1210
|
+
return {};
|
1175
1211
|
}
|
1176
1212
|
}
|
1177
1213
|
function mapFieldTypeToEmptyValue(field2) {
|
@@ -1194,10 +1230,12 @@ function mapFieldTypeToEmptyValue(field2) {
|
|
1194
1230
|
case FieldType.EMAIL:
|
1195
1231
|
case FieldType.DATE:
|
1196
1232
|
case FieldType.CHECKBOX:
|
1233
|
+
case FieldType.DATA:
|
1197
1234
|
return null;
|
1198
1235
|
case FieldType.ADDRESS:
|
1199
1236
|
return {
|
1200
1237
|
country: null,
|
1238
|
+
addressType: AddressType.DOMESTIC,
|
1201
1239
|
province: null,
|
1202
1240
|
district: null,
|
1203
1241
|
urbanOrRural: "URBAN",
|
@@ -1281,21 +1319,36 @@ var isFacilityFieldType = (field2) => {
|
|
1281
1319
|
var isOfficeFieldType = (field2) => {
|
1282
1320
|
return field2.config.type === FieldType.OFFICE;
|
1283
1321
|
};
|
1322
|
+
var isDataFieldType = (field2) => {
|
1323
|
+
return field2.config.type === FieldType.DATA;
|
1324
|
+
};
|
1284
1325
|
|
1285
1326
|
// ../commons/src/conditionals/validate.ts
|
1286
1327
|
var ajv = new import_ajv.default({
|
1287
|
-
$data: true
|
1328
|
+
$data: true,
|
1329
|
+
allowUnionTypes: true
|
1288
1330
|
});
|
1289
1331
|
(0, import_ajv_formats.default)(ajv);
|
1290
1332
|
function validate(schema, data) {
|
1291
1333
|
return ajv.validate(schema, data);
|
1292
1334
|
}
|
1335
|
+
function isConditionMet(conditional, values) {
|
1336
|
+
return validate(conditional, {
|
1337
|
+
$form: values,
|
1338
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1339
|
+
});
|
1340
|
+
}
|
1293
1341
|
function getConditionalActionsForField(field2, values) {
|
1294
1342
|
if (!field2.conditionals) {
|
1295
1343
|
return [];
|
1296
1344
|
}
|
1297
1345
|
return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
1298
1346
|
}
|
1347
|
+
function areConditionsMet(conditions, values) {
|
1348
|
+
return conditions.every(
|
1349
|
+
(condition) => isConditionMet(condition.conditional, values)
|
1350
|
+
);
|
1351
|
+
}
|
1299
1352
|
function isFieldConditionMet(field2, form, conditionalType) {
|
1300
1353
|
const hasRule = (field2.conditionals ?? []).some(
|
1301
1354
|
(conditional) => conditional.type === conditionalType
|
@@ -1314,9 +1367,16 @@ function isFieldConditionMet(field2, form, conditionalType) {
|
|
1314
1367
|
function isFieldVisible(field2, form) {
|
1315
1368
|
return isFieldConditionMet(field2, form, ConditionalType.SHOW);
|
1316
1369
|
}
|
1370
|
+
function isFieldEmptyAndNotRequired(field2, form) {
|
1371
|
+
const fieldValue = form[field2.id];
|
1372
|
+
return !field2.required && (fieldValue === void 0 || fieldValue === "");
|
1373
|
+
}
|
1317
1374
|
function isFieldEnabled(field2, form) {
|
1318
1375
|
return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
|
1319
1376
|
}
|
1377
|
+
function isFieldDisplayedOnReview(field2, form) {
|
1378
|
+
return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
|
1379
|
+
}
|
1320
1380
|
var errorMessages = {
|
1321
1381
|
hiddenField: {
|
1322
1382
|
id: "v2.error.hidden",
|
@@ -1344,12 +1404,14 @@ var errorMessages = {
|
|
1344
1404
|
id: "v2.error.invalid"
|
1345
1405
|
}
|
1346
1406
|
};
|
1347
|
-
|
1348
|
-
|
1349
|
-
message
|
1350
|
-
|
1351
|
-
}
|
1352
|
-
|
1407
|
+
function createIntlError(message) {
|
1408
|
+
return {
|
1409
|
+
message: {
|
1410
|
+
message
|
1411
|
+
}
|
1412
|
+
};
|
1413
|
+
}
|
1414
|
+
function zodToIntlErrorMap(issue, _ctx) {
|
1353
1415
|
switch (issue.code) {
|
1354
1416
|
case "invalid_string": {
|
1355
1417
|
if (_ctx.data === "") {
|
@@ -1375,43 +1437,18 @@ var zodToIntlErrorMap = (issue, _ctx) => {
|
|
1375
1437
|
}
|
1376
1438
|
break;
|
1377
1439
|
}
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
values
|
1384
|
-
}) {
|
1385
|
-
const conditionalParameters = {
|
1386
|
-
$form: values,
|
1387
|
-
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1388
|
-
};
|
1389
|
-
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1390
|
-
if (values[field2.id]) {
|
1391
|
-
return {
|
1392
|
-
errors: [
|
1393
|
-
{
|
1394
|
-
message: errorMessages.hiddenField
|
1440
|
+
case "invalid_union": {
|
1441
|
+
for (const { issues } of issue.unionErrors) {
|
1442
|
+
for (const e of issues) {
|
1443
|
+
if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
|
1444
|
+
return createIntlError(errorMessages.invalidInput);
|
1395
1445
|
}
|
1396
|
-
|
1397
|
-
}
|
1446
|
+
}
|
1447
|
+
}
|
1448
|
+
return createIntlError(errorMessages.requiredField);
|
1398
1449
|
}
|
1399
|
-
return {
|
1400
|
-
errors: []
|
1401
|
-
};
|
1402
1450
|
}
|
1403
|
-
|
1404
|
-
field: field2,
|
1405
|
-
value: values[field2.id]
|
1406
|
-
});
|
1407
|
-
const customValidationResults = runCustomFieldValidations({
|
1408
|
-
field: field2,
|
1409
|
-
conditionalParameters
|
1410
|
-
});
|
1411
|
-
return {
|
1412
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1413
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1414
|
-
};
|
1451
|
+
return createIntlError(errorMessages.invalidInput);
|
1415
1452
|
}
|
1416
1453
|
function runCustomFieldValidations({
|
1417
1454
|
field: field2,
|
@@ -1434,13 +1471,31 @@ function validateFieldInput({
|
|
1434
1471
|
);
|
1435
1472
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1436
1473
|
}
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1474
|
+
function runFieldValidations({
|
1475
|
+
field: field2,
|
1476
|
+
values
|
1477
|
+
}) {
|
1478
|
+
if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
|
1479
|
+
return {
|
1480
|
+
errors: []
|
1481
|
+
};
|
1442
1482
|
}
|
1443
|
-
|
1483
|
+
const conditionalParameters = {
|
1484
|
+
$form: values,
|
1485
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1486
|
+
};
|
1487
|
+
const fieldValidationResult = validateFieldInput({
|
1488
|
+
field: field2,
|
1489
|
+
value: values[field2.id]
|
1490
|
+
});
|
1491
|
+
const customValidationResults = runCustomFieldValidations({
|
1492
|
+
field: field2,
|
1493
|
+
conditionalParameters
|
1494
|
+
});
|
1495
|
+
return {
|
1496
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1497
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1498
|
+
};
|
1444
1499
|
}
|
1445
1500
|
|
1446
1501
|
// ../commons/src/uuid.ts
|
@@ -1449,142 +1504,91 @@ function getUUID() {
|
|
1449
1504
|
return (0, import_uuid.v4)();
|
1450
1505
|
}
|
1451
1506
|
|
1507
|
+
// ../commons/src/utils.ts
|
1508
|
+
function getOrThrow(x, message) {
|
1509
|
+
if (x === void 0 || x === null) {
|
1510
|
+
throw new Error(message);
|
1511
|
+
}
|
1512
|
+
return x;
|
1513
|
+
}
|
1514
|
+
|
1452
1515
|
// ../commons/src/events/utils.ts
|
1453
|
-
function
|
1454
|
-
return
|
1455
|
-
}
|
1456
|
-
var findInputPageFields = (config) => {
|
1457
|
-
return (0, import_lodash.flattenDeep)(
|
1458
|
-
config.actions.map(
|
1459
|
-
({ forms }) => forms.map(
|
1460
|
-
({ pages }) => pages.map(
|
1461
|
-
({ fields }) => fields.map(({ id, label }) => ({ id, label }))
|
1462
|
-
)
|
1463
|
-
)
|
1464
|
-
)
|
1465
|
-
);
|
1466
|
-
};
|
1467
|
-
var findPageFields = (config) => {
|
1468
|
-
return (0, import_lodash.flattenDeep)(
|
1469
|
-
config.actions.map((action) => {
|
1470
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1471
|
-
return [
|
1472
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1473
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1474
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1475
|
-
];
|
1476
|
-
}
|
1477
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1478
|
-
})
|
1479
|
-
);
|
1480
|
-
};
|
1481
|
-
var resolveLabelsFromKnownFields = ({
|
1482
|
-
pageFields,
|
1483
|
-
refFields
|
1484
|
-
}) => {
|
1485
|
-
return refFields.map((field2) => {
|
1486
|
-
if (field2.label) {
|
1487
|
-
return field2;
|
1488
|
-
}
|
1489
|
-
if (isMetadataField(field2.id)) {
|
1490
|
-
return {
|
1491
|
-
...field2,
|
1492
|
-
label: eventMetadataLabelMap[field2.id]
|
1493
|
-
};
|
1494
|
-
}
|
1495
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1496
|
-
if (!pageLabel) {
|
1497
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1498
|
-
}
|
1499
|
-
return {
|
1500
|
-
...field2,
|
1501
|
-
label: pageLabel.label
|
1502
|
-
};
|
1503
|
-
});
|
1504
|
-
};
|
1505
|
-
function getAllFields(configuration) {
|
1506
|
-
return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
|
1507
|
-
...form.review.fields,
|
1508
|
-
...form.pages.flatMap((page) => page.fields)
|
1509
|
-
]);
|
1516
|
+
function isDeclarationActionConfig(action) {
|
1517
|
+
return DeclarationActions.safeParse(action.type).success;
|
1510
1518
|
}
|
1511
|
-
function
|
1512
|
-
return configuration.
|
1519
|
+
function getDeclarationFields(configuration) {
|
1520
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1513
1521
|
}
|
1514
|
-
function
|
1515
|
-
|
1516
|
-
const rootWorkqueue = Object.values(workqueues).find(
|
1517
|
-
(wq) => wq.id === workqueue.id
|
1518
|
-
);
|
1519
|
-
if (!rootWorkqueue) {
|
1520
|
-
throw new Error(
|
1521
|
-
`Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
|
1522
|
-
);
|
1523
|
-
}
|
1524
|
-
});
|
1522
|
+
function getDeclarationPages(configuration) {
|
1523
|
+
return configuration.declaration.pages;
|
1525
1524
|
}
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
}
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1525
|
+
function getDeclaration(configuration) {
|
1526
|
+
return configuration.declaration;
|
1527
|
+
}
|
1528
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1529
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1530
|
+
return [
|
1531
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1532
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1533
|
+
];
|
1534
|
+
}
|
1535
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1536
|
+
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
1537
|
+
}
|
1538
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1539
|
+
return actionConfig.review.fields;
|
1540
|
+
}
|
1541
|
+
return [];
|
1540
1542
|
};
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
const
|
1546
|
-
|
1543
|
+
function getAllAnnotationFields(config) {
|
1544
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1545
|
+
}
|
1546
|
+
var findRecordActionPages = (config, actionType) => {
|
1547
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1548
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1549
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1550
|
+
}
|
1551
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1552
|
+
return action.printForm.pages;
|
1553
|
+
}
|
1554
|
+
return [];
|
1547
1555
|
};
|
1548
|
-
|
1556
|
+
function getActionReview(configuration, actionType) {
|
1557
|
+
const [actionConfig] = configuration.actions.filter(
|
1558
|
+
(a) => a.type === actionType
|
1559
|
+
);
|
1549
1560
|
return getOrThrow(
|
1550
|
-
|
1551
|
-
|
1561
|
+
actionConfig.review,
|
1562
|
+
`No review config found for ${actionType}`
|
1552
1563
|
);
|
1553
|
-
};
|
1554
|
-
function getActiveActionFields(configuration, action) {
|
1555
|
-
const fields = findActiveActionFields(configuration, action);
|
1556
|
-
if (!fields) {
|
1557
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1558
|
-
}
|
1559
|
-
return fields;
|
1560
1564
|
}
|
1561
|
-
function
|
1562
|
-
|
1563
|
-
if (!config) {
|
1564
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1565
|
-
}
|
1566
|
-
return config;
|
1565
|
+
function getActionReviewFields(configuration, actionType) {
|
1566
|
+
return getActionReview(configuration, actionType).fields;
|
1567
1567
|
}
|
1568
|
-
function
|
1569
|
-
if (
|
1570
|
-
return
|
1568
|
+
function isPageVisible(page, formValues) {
|
1569
|
+
if (!page.conditional) {
|
1570
|
+
return true;
|
1571
1571
|
}
|
1572
|
-
return
|
1572
|
+
return isConditionMet(page.conditional, formValues);
|
1573
1573
|
}
|
1574
|
-
function
|
1575
|
-
return (0, import_lodash.omitBy)(
|
1576
|
-
|
1577
|
-
|
1578
|
-
return true;
|
1574
|
+
function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
|
1575
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1576
|
+
if (visibleVerificationPageIds.includes(fieldId)) {
|
1577
|
+
return false;
|
1579
1578
|
}
|
1580
|
-
|
1579
|
+
const fieldConfigs = fields.filter((f) => f.id === fieldId);
|
1580
|
+
if (!fieldConfigs.length) {
|
1581
1581
|
return true;
|
1582
1582
|
}
|
1583
|
-
return !isFieldVisible(
|
1583
|
+
return fieldConfigs.every((f) => !isFieldVisible(f, values));
|
1584
1584
|
});
|
1585
1585
|
}
|
1586
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1587
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1588
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1589
|
+
}
|
1586
1590
|
function findActiveDrafts(event2, drafts) {
|
1587
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1591
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1588
1592
|
const lastAction = actions[actions.length - 1];
|
1589
1593
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1590
1594
|
}
|
@@ -1596,28 +1600,103 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1596
1600
|
transactionId: getUUID(),
|
1597
1601
|
action: {
|
1598
1602
|
type: actionType,
|
1599
|
-
|
1600
|
-
|
1603
|
+
declaration: {},
|
1604
|
+
annotation: {},
|
1601
1605
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1602
1606
|
createdBy: "@todo",
|
1603
1607
|
createdAtLocation: "@todo"
|
1604
1608
|
}
|
1605
1609
|
};
|
1606
1610
|
}
|
1611
|
+
function isVerificationPage(page) {
|
1612
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
1613
|
+
}
|
1614
|
+
function getVisibleVerificationPageIds(pages, annotation) {
|
1615
|
+
return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
|
1616
|
+
}
|
1617
|
+
function getActionVerificationPageIds(actionConfig, annotation) {
|
1618
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1619
|
+
return [
|
1620
|
+
...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
|
1621
|
+
...getVisibleVerificationPageIds(
|
1622
|
+
actionConfig.additionalDetailsForm,
|
1623
|
+
annotation
|
1624
|
+
)
|
1625
|
+
];
|
1626
|
+
}
|
1627
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1628
|
+
return getVisibleVerificationPageIds(
|
1629
|
+
actionConfig.printForm.pages,
|
1630
|
+
annotation
|
1631
|
+
);
|
1632
|
+
}
|
1633
|
+
return [];
|
1634
|
+
}
|
1635
|
+
function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
|
1636
|
+
const annotationFields = getActionAnnotationFields(actionConfig);
|
1637
|
+
const visibleVerificationPageIds = getActionVerificationPageIds(
|
1638
|
+
actionConfig,
|
1639
|
+
annotation
|
1640
|
+
);
|
1641
|
+
return omitHiddenFields(
|
1642
|
+
annotationFields,
|
1643
|
+
{ ...declaration, ...annotation },
|
1644
|
+
visibleVerificationPageIds
|
1645
|
+
);
|
1646
|
+
}
|
1647
|
+
function deepMerge(currentDocument, actionDocument) {
|
1648
|
+
return (0, import_lodash.mergeWith)(
|
1649
|
+
currentDocument,
|
1650
|
+
actionDocument,
|
1651
|
+
(previousValue, incomingValue) => {
|
1652
|
+
if (incomingValue === void 0) {
|
1653
|
+
return previousValue;
|
1654
|
+
}
|
1655
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1656
|
+
return incomingValue;
|
1657
|
+
}
|
1658
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1659
|
+
return void 0;
|
1660
|
+
}
|
1661
|
+
return incomingValue;
|
1662
|
+
}
|
1663
|
+
);
|
1664
|
+
}
|
1665
|
+
function findLastAssignmentAction(actions) {
|
1666
|
+
return actions.filter(
|
1667
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1668
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1669
|
+
}
|
1670
|
+
function isWriteAction(actionType) {
|
1671
|
+
return writeActions.safeParse(actionType).success;
|
1672
|
+
}
|
1673
|
+
var findAllFields = (config) => {
|
1674
|
+
return (0, import_lodash.flattenDeep)([
|
1675
|
+
...getDeclarationFields(config),
|
1676
|
+
...getAllAnnotationFields(config)
|
1677
|
+
]);
|
1678
|
+
};
|
1607
1679
|
|
1608
1680
|
// ../commons/src/events/EventConfig.ts
|
1609
|
-
var
|
1610
|
-
|
1681
|
+
var import_zod_openapi3 = require("zod-openapi");
|
1682
|
+
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod16.z);
|
1683
|
+
var EventConfig = import_zod16.z.object({
|
1684
|
+
id: import_zod16.z.string().describe(
|
1611
1685
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1612
1686
|
),
|
1687
|
+
dateOfEvent: import_zod16.z.object({ fieldId: import_zod16.z.string() }).optional(),
|
1688
|
+
title: TranslationConfig,
|
1689
|
+
fallbackTitle: TranslationConfig.optional().describe(
|
1690
|
+
"This is a fallback title if actual title resolves to empty string"
|
1691
|
+
),
|
1613
1692
|
summary: SummaryConfig,
|
1614
1693
|
label: TranslationConfig,
|
1615
|
-
actions:
|
1616
|
-
|
1617
|
-
deduplication:
|
1618
|
-
advancedSearch:
|
1694
|
+
actions: import_zod16.z.array(ActionConfig),
|
1695
|
+
declaration: DeclarationFormConfig,
|
1696
|
+
deduplication: import_zod16.z.array(DeduplicationConfig).optional().default([]),
|
1697
|
+
advancedSearch: import_zod16.z.array(AdvancedSearchConfig).optional().default([])
|
1619
1698
|
}).superRefine((event2, ctx) => {
|
1620
|
-
const allFields =
|
1699
|
+
const allFields = findAllFields(event2);
|
1621
1700
|
const fieldIds = allFields.map((field2) => field2.id);
|
1622
1701
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1623
1702
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1631,287 +1710,497 @@ var EventConfig = import_zod18.z.object({
|
|
1631
1710
|
});
|
1632
1711
|
}
|
1633
1712
|
const invalidFields = event2.advancedSearch.flatMap(
|
1634
|
-
(section) =>
|
1713
|
+
(section) => (
|
1714
|
+
// Check if the fieldId is not in the fieldIds array
|
1715
|
+
// and also not in the metadataFields array
|
1716
|
+
section.fields.filter(
|
1717
|
+
(field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
|
1718
|
+
)
|
1719
|
+
)
|
1635
1720
|
);
|
1636
1721
|
if (invalidFields.length > 0) {
|
1637
1722
|
ctx.addIssue({
|
1638
1723
|
code: "custom",
|
1639
|
-
message: `Advanced search id must match a field id
|
1724
|
+
message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
|
1640
1725
|
Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
|
1641
1726
|
path: ["advancedSearch"]
|
1642
1727
|
});
|
1643
1728
|
}
|
1729
|
+
if (event2.dateOfEvent) {
|
1730
|
+
const eventDateFieldId = getDeclarationFields(event2).find(
|
1731
|
+
({ id }) => id === event2.dateOfEvent?.fieldId
|
1732
|
+
);
|
1733
|
+
if (!eventDateFieldId) {
|
1734
|
+
ctx.addIssue({
|
1735
|
+
code: "custom",
|
1736
|
+
message: `Date of event field id must match a field id in fields array.
|
1737
|
+
Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
|
1738
|
+
path: ["dateOfEvent"]
|
1739
|
+
});
|
1740
|
+
} else if (eventDateFieldId.type !== FieldType.DATE) {
|
1741
|
+
ctx.addIssue({
|
1742
|
+
code: "custom",
|
1743
|
+
message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
|
1744
|
+
path: ["dateOfEvent.fieldType"]
|
1745
|
+
});
|
1746
|
+
}
|
1747
|
+
}
|
1748
|
+
}).openapi({
|
1749
|
+
ref: "EventConfig"
|
1644
1750
|
});
|
1645
1751
|
|
1646
1752
|
// ../commons/src/events/EventConfigInput.ts
|
1647
|
-
var
|
1648
|
-
var
|
1753
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1754
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1755
|
+
var definePage = (page) => PageConfig.parse(page);
|
1756
|
+
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1757
|
+
|
1758
|
+
// ../commons/src/events/WorkqueueConfig.ts
|
1759
|
+
var import_zod17 = require("zod");
|
1760
|
+
var WorkqueueConfig = import_zod17.z.object({
|
1761
|
+
slug: import_zod17.z.string().describe("Determines the url of the workqueue."),
|
1762
|
+
name: TranslationConfig.describe(
|
1763
|
+
"Title of the workflow (both in navigation and on the page)"
|
1764
|
+
),
|
1765
|
+
/**
|
1766
|
+
* Placeholder untill the following gets merged to develop
|
1767
|
+
* https://github.com/opencrvs/opencrvs-core/blob/5fbe9854a88504a7a13fcc856b3e82594b70c38c/packages/commons/src/events/EventIndex.ts#L92-L93
|
1768
|
+
*/
|
1769
|
+
query: import_zod17.z.string(),
|
1770
|
+
actions: import_zod17.z.array(
|
1771
|
+
import_zod17.z.object({
|
1772
|
+
type: import_zod17.z.string(),
|
1773
|
+
conditionals: import_zod17.z.array(Conditional).optional()
|
1774
|
+
})
|
1775
|
+
)
|
1776
|
+
}).describe("Configuration for workqueue.");
|
1777
|
+
function defineWorkqueue(workqueues) {
|
1778
|
+
return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
|
1779
|
+
}
|
1649
1780
|
|
1650
1781
|
// ../commons/src/events/Draft.ts
|
1651
|
-
var
|
1782
|
+
var import_zod20 = require("zod");
|
1652
1783
|
|
1653
1784
|
// ../commons/src/events/ActionDocument.ts
|
1654
|
-
var
|
1655
|
-
var
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1785
|
+
var import_zod18 = require("zod");
|
1786
|
+
var import_zod_openapi4 = require("zod-openapi");
|
1787
|
+
(0, import_zod_openapi4.extendZodWithOpenApi)(import_zod18.z);
|
1788
|
+
var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
|
1789
|
+
var ActionStatus = {
|
1790
|
+
Requested: "Requested",
|
1791
|
+
Accepted: "Accepted",
|
1792
|
+
Rejected: "Rejected"
|
1793
|
+
};
|
1794
|
+
var ActionBase = import_zod18.z.object({
|
1795
|
+
id: import_zod18.z.string(),
|
1796
|
+
transactionId: import_zod18.z.string(),
|
1797
|
+
createdAt: import_zod18.z.string().datetime(),
|
1798
|
+
createdBy: import_zod18.z.string(),
|
1799
|
+
createdByRole: import_zod18.z.string(),
|
1800
|
+
declaration: ActionUpdate,
|
1801
|
+
annotation: ActionUpdate.optional(),
|
1802
|
+
createdAtLocation: import_zod18.z.string().optional(),
|
1803
|
+
updatedAtLocation: import_zod18.z.string().optional(),
|
1804
|
+
status: import_zod18.z.enum([
|
1805
|
+
ActionStatus.Requested,
|
1806
|
+
ActionStatus.Accepted,
|
1807
|
+
ActionStatus.Rejected
|
1808
|
+
]),
|
1809
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1810
|
+
originalActionId: import_zod18.z.string().optional()
|
1663
1811
|
});
|
1664
1812
|
var AssignedAction = ActionBase.merge(
|
1665
|
-
|
1666
|
-
type:
|
1667
|
-
assignedTo:
|
1813
|
+
import_zod18.z.object({
|
1814
|
+
type: import_zod18.z.literal(ActionType.ASSIGN),
|
1815
|
+
assignedTo: import_zod18.z.string()
|
1668
1816
|
})
|
1669
1817
|
);
|
1670
1818
|
var UnassignedAction = ActionBase.merge(
|
1671
|
-
|
1672
|
-
type:
|
1819
|
+
import_zod18.z.object({
|
1820
|
+
type: import_zod18.z.literal(ActionType.UNASSIGN),
|
1821
|
+
assignedTo: import_zod18.z.literal(null)
|
1673
1822
|
})
|
1674
1823
|
);
|
1675
1824
|
var RegisterAction = ActionBase.merge(
|
1676
|
-
|
1677
|
-
type:
|
1678
|
-
|
1679
|
-
trackingId: import_zod19.z.string(),
|
1680
|
-
registrationNumber: import_zod19.z.string()
|
1681
|
-
})
|
1825
|
+
import_zod18.z.object({
|
1826
|
+
type: import_zod18.z.literal(ActionType.REGISTER),
|
1827
|
+
registrationNumber: import_zod18.z.string().optional()
|
1682
1828
|
})
|
1683
1829
|
);
|
1684
1830
|
var DeclareAction = ActionBase.merge(
|
1685
|
-
|
1686
|
-
type:
|
1831
|
+
import_zod18.z.object({
|
1832
|
+
type: import_zod18.z.literal(ActionType.DECLARE)
|
1687
1833
|
})
|
1688
1834
|
);
|
1689
1835
|
var ValidateAction = ActionBase.merge(
|
1690
|
-
|
1691
|
-
type:
|
1836
|
+
import_zod18.z.object({
|
1837
|
+
type: import_zod18.z.literal(ActionType.VALIDATE)
|
1692
1838
|
})
|
1693
1839
|
);
|
1694
1840
|
var RejectAction = ActionBase.merge(
|
1695
|
-
|
1696
|
-
type:
|
1841
|
+
import_zod18.z.object({
|
1842
|
+
type: import_zod18.z.literal(ActionType.REJECT)
|
1697
1843
|
})
|
1698
1844
|
);
|
1699
1845
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1700
|
-
|
1701
|
-
type:
|
1846
|
+
import_zod18.z.object({
|
1847
|
+
type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1702
1848
|
})
|
1703
1849
|
);
|
1704
1850
|
var ArchiveAction = ActionBase.merge(
|
1705
|
-
|
1706
|
-
type:
|
1851
|
+
import_zod18.z.object({
|
1852
|
+
type: import_zod18.z.literal(ActionType.ARCHIVE)
|
1707
1853
|
})
|
1708
1854
|
);
|
1709
1855
|
var CreatedAction = ActionBase.merge(
|
1710
|
-
|
1711
|
-
type:
|
1856
|
+
import_zod18.z.object({
|
1857
|
+
type: import_zod18.z.literal(ActionType.CREATE)
|
1712
1858
|
})
|
1713
1859
|
);
|
1714
1860
|
var NotifiedAction = ActionBase.merge(
|
1715
|
-
|
1716
|
-
type:
|
1861
|
+
import_zod18.z.object({
|
1862
|
+
type: import_zod18.z.literal(ActionType.NOTIFY)
|
1717
1863
|
})
|
1718
1864
|
);
|
1719
1865
|
var PrintCertificateAction = ActionBase.merge(
|
1720
|
-
|
1721
|
-
type:
|
1866
|
+
import_zod18.z.object({
|
1867
|
+
type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
|
1722
1868
|
})
|
1723
1869
|
);
|
1724
1870
|
var RequestedCorrectionAction = ActionBase.merge(
|
1725
|
-
|
1726
|
-
type:
|
1871
|
+
import_zod18.z.object({
|
1872
|
+
type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
|
1727
1873
|
})
|
1728
1874
|
);
|
1729
1875
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1730
|
-
|
1731
|
-
type:
|
1732
|
-
requestId:
|
1876
|
+
import_zod18.z.object({
|
1877
|
+
type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
|
1878
|
+
requestId: import_zod18.z.string()
|
1733
1879
|
})
|
1734
1880
|
);
|
1735
1881
|
var RejectedCorrectionAction = ActionBase.merge(
|
1736
|
-
|
1737
|
-
type:
|
1738
|
-
requestId:
|
1882
|
+
import_zod18.z.object({
|
1883
|
+
type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
|
1884
|
+
requestId: import_zod18.z.string()
|
1739
1885
|
})
|
1740
1886
|
);
|
1741
|
-
var
|
1742
|
-
|
1743
|
-
type:
|
1887
|
+
var ReadAction = ActionBase.merge(
|
1888
|
+
import_zod18.z.object({
|
1889
|
+
type: import_zod18.z.literal(ActionType.READ)
|
1744
1890
|
})
|
1745
1891
|
);
|
1746
|
-
var ActionDocument =
|
1747
|
-
CreatedAction,
|
1748
|
-
ValidateAction,
|
1749
|
-
RejectAction,
|
1750
|
-
MarkAsDuplicateAction,
|
1751
|
-
ArchiveAction,
|
1752
|
-
NotifiedAction,
|
1753
|
-
RegisterAction,
|
1754
|
-
DeclareAction,
|
1755
|
-
AssignedAction,
|
1756
|
-
RequestedCorrectionAction,
|
1757
|
-
ApprovedCorrectionAction,
|
1758
|
-
RejectedCorrectionAction,
|
1759
|
-
UnassignedAction,
|
1760
|
-
PrintCertificateAction,
|
1761
|
-
|
1762
|
-
])
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1892
|
+
var ActionDocument = import_zod18.z.discriminatedUnion("type", [
|
1893
|
+
CreatedAction.openapi({ ref: "CreatedAction" }),
|
1894
|
+
ValidateAction.openapi({ ref: "ValidateAction" }),
|
1895
|
+
RejectAction.openapi({ ref: "RejectAction" }),
|
1896
|
+
MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
|
1897
|
+
ArchiveAction.openapi({ ref: "ArchiveAction" }),
|
1898
|
+
NotifiedAction.openapi({ ref: "NotifiedAction" }),
|
1899
|
+
RegisterAction.openapi({ ref: "RegisterAction" }),
|
1900
|
+
DeclareAction.openapi({ ref: "DeclareAction" }),
|
1901
|
+
AssignedAction.openapi({ ref: "AssignedAction" }),
|
1902
|
+
RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
|
1903
|
+
ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
|
1904
|
+
RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
|
1905
|
+
UnassignedAction.openapi({ ref: "UnassignedAction" }),
|
1906
|
+
PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
|
1907
|
+
ReadAction.openapi({ ref: "ReadAction" })
|
1908
|
+
]).openapi({
|
1909
|
+
ref: "ActionDocument"
|
1910
|
+
});
|
1911
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1912
|
+
declaration: true,
|
1913
|
+
annotation: true,
|
1914
|
+
createdBy: true,
|
1915
|
+
createdByRole: true,
|
1916
|
+
createdAtLocation: true
|
1917
|
+
}).merge(
|
1918
|
+
import_zod18.z.object({
|
1919
|
+
type: import_zod18.z.enum(ConfirmableActions),
|
1920
|
+
status: import_zod18.z.literal(ActionStatus.Rejected)
|
1921
|
+
})
|
1922
|
+
);
|
1923
|
+
var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1924
|
+
var ResolvedUser = import_zod18.z.object({
|
1925
|
+
id: import_zod18.z.string(),
|
1926
|
+
role: import_zod18.z.string(),
|
1927
|
+
name: import_zod18.z.array(
|
1928
|
+
import_zod18.z.object({
|
1929
|
+
use: import_zod18.z.string(),
|
1930
|
+
given: import_zod18.z.array(import_zod18.z.string()),
|
1931
|
+
family: import_zod18.z.string()
|
1771
1932
|
})
|
1772
1933
|
)
|
1773
1934
|
});
|
1774
1935
|
|
1775
1936
|
// ../commons/src/events/ActionInput.ts
|
1776
|
-
var
|
1777
|
-
var
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1937
|
+
var import_zod19 = require("zod");
|
1938
|
+
var import_zod_openapi5 = require("zod-openapi");
|
1939
|
+
(0, import_zod_openapi5.extendZodWithOpenApi)(import_zod19.z);
|
1940
|
+
var BaseActionInput = import_zod19.z.object({
|
1941
|
+
eventId: import_zod19.z.string(),
|
1942
|
+
transactionId: import_zod19.z.string(),
|
1943
|
+
declaration: ActionUpdate.default({}),
|
1944
|
+
annotation: ActionUpdate.optional(),
|
1945
|
+
originalActionId: import_zod19.z.string().optional(),
|
1946
|
+
keepAssignment: import_zod19.z.boolean().optional()
|
1782
1947
|
});
|
1783
1948
|
var CreateActionInput = BaseActionInput.merge(
|
1784
|
-
|
1785
|
-
type:
|
1786
|
-
createdAtLocation:
|
1949
|
+
import_zod19.z.object({
|
1950
|
+
type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
1951
|
+
createdAtLocation: import_zod19.z.string()
|
1787
1952
|
})
|
1788
1953
|
);
|
1789
1954
|
var RegisterActionInput = BaseActionInput.merge(
|
1790
|
-
|
1791
|
-
type:
|
1792
|
-
|
1793
|
-
trackingId: import_zod20.z.string(),
|
1794
|
-
registrationNumber: import_zod20.z.string()
|
1795
|
-
})
|
1955
|
+
import_zod19.z.object({
|
1956
|
+
type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
1957
|
+
registrationNumber: import_zod19.z.string().optional()
|
1796
1958
|
})
|
1797
1959
|
);
|
1798
1960
|
var ValidateActionInput = BaseActionInput.merge(
|
1799
|
-
|
1800
|
-
type:
|
1801
|
-
duplicates:
|
1961
|
+
import_zod19.z.object({
|
1962
|
+
type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
1963
|
+
duplicates: import_zod19.z.array(import_zod19.z.string())
|
1802
1964
|
})
|
1803
1965
|
);
|
1804
1966
|
var NotifyActionInput = BaseActionInput.merge(
|
1805
|
-
|
1806
|
-
type:
|
1967
|
+
import_zod19.z.object({
|
1968
|
+
type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1807
1969
|
})
|
1808
1970
|
);
|
1809
1971
|
var DeclareActionInput = BaseActionInput.merge(
|
1810
|
-
|
1811
|
-
type:
|
1972
|
+
import_zod19.z.object({
|
1973
|
+
type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1812
1974
|
})
|
1813
1975
|
);
|
1814
1976
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1815
|
-
|
1816
|
-
type:
|
1977
|
+
import_zod19.z.object({
|
1978
|
+
type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1817
1979
|
})
|
1818
1980
|
);
|
1819
1981
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1820
|
-
|
1821
|
-
type:
|
1982
|
+
import_zod19.z.object({
|
1983
|
+
type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1822
1984
|
})
|
1823
1985
|
);
|
1824
1986
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1825
|
-
|
1826
|
-
type:
|
1987
|
+
import_zod19.z.object({
|
1988
|
+
type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1827
1989
|
})
|
1828
1990
|
);
|
1829
1991
|
var ArchiveActionInput = BaseActionInput.merge(
|
1830
|
-
|
1831
|
-
type:
|
1992
|
+
import_zod19.z.object({
|
1993
|
+
type: import_zod19.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1832
1994
|
})
|
1833
1995
|
);
|
1834
1996
|
var AssignActionInput = BaseActionInput.merge(
|
1835
|
-
|
1836
|
-
type:
|
1837
|
-
assignedTo:
|
1997
|
+
import_zod19.z.object({
|
1998
|
+
type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
1999
|
+
assignedTo: import_zod19.z.string()
|
1838
2000
|
})
|
1839
2001
|
);
|
1840
2002
|
var UnassignActionInput = BaseActionInput.merge(
|
1841
|
-
|
1842
|
-
type:
|
2003
|
+
import_zod19.z.object({
|
2004
|
+
type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
|
2005
|
+
assignedTo: import_zod19.z.literal(null).default(null)
|
1843
2006
|
})
|
1844
2007
|
);
|
1845
2008
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1846
|
-
|
1847
|
-
type:
|
2009
|
+
import_zod19.z.object({
|
2010
|
+
type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1848
2011
|
})
|
1849
2012
|
);
|
1850
2013
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
1851
|
-
|
1852
|
-
requestId:
|
1853
|
-
type:
|
2014
|
+
import_zod19.z.object({
|
2015
|
+
requestId: import_zod19.z.string(),
|
2016
|
+
type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
1854
2017
|
})
|
1855
2018
|
);
|
1856
2019
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
1857
|
-
|
1858
|
-
requestId:
|
1859
|
-
type:
|
2020
|
+
import_zod19.z.object({
|
2021
|
+
requestId: import_zod19.z.string(),
|
2022
|
+
type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
1860
2023
|
})
|
1861
2024
|
);
|
1862
|
-
var
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
2025
|
+
var ReadActionInput = BaseActionInput.merge(
|
2026
|
+
import_zod19.z.object({
|
2027
|
+
type: import_zod19.z.literal(ActionType.READ).default(ActionType.READ)
|
2028
|
+
})
|
2029
|
+
);
|
2030
|
+
var DeleteActionInput = import_zod19.z.object({ eventId: import_zod19.z.string() });
|
2031
|
+
var ActionInput = import_zod19.z.discriminatedUnion("type", [
|
2032
|
+
CreateActionInput.openapi({ ref: "CreateActionInput" }),
|
2033
|
+
ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
|
2034
|
+
RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
|
2035
|
+
NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
|
2036
|
+
DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
|
2037
|
+
RejectDeclarationActionInput.openapi({
|
2038
|
+
ref: "RejectDeclarationActionInput"
|
2039
|
+
}),
|
2040
|
+
MarkedAsDuplicateActionInput.openapi({
|
2041
|
+
ref: "MarkedAsDuplicateActionInput"
|
2042
|
+
}),
|
2043
|
+
ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
|
2044
|
+
AssignActionInput.openapi({ ref: "AssignActionInput" }),
|
2045
|
+
UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
|
2046
|
+
PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
|
2047
|
+
RequestCorrectionActionInput.openapi({
|
2048
|
+
ref: "RequestCorrectionActionInput"
|
2049
|
+
}),
|
2050
|
+
RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
|
2051
|
+
ApproveCorrectionActionInput.openapi({
|
2052
|
+
ref: "ApproveCorrectionActionInput"
|
2053
|
+
}),
|
2054
|
+
ReadActionInput.openapi({ ref: "ReadActionInput" })
|
2055
|
+
]).openapi({
|
2056
|
+
ref: "ActionInput"
|
2057
|
+
});
|
1878
2058
|
|
1879
2059
|
// ../commons/src/events/Draft.ts
|
1880
|
-
var Draft =
|
1881
|
-
id:
|
1882
|
-
eventId:
|
1883
|
-
transactionId:
|
1884
|
-
createdAt:
|
2060
|
+
var Draft = import_zod20.z.object({
|
2061
|
+
id: import_zod20.z.string(),
|
2062
|
+
eventId: import_zod20.z.string(),
|
2063
|
+
transactionId: import_zod20.z.string(),
|
2064
|
+
createdAt: import_zod20.z.string().datetime(),
|
1885
2065
|
action: ActionBase.extend({
|
1886
|
-
type:
|
2066
|
+
type: ActionTypes
|
1887
2067
|
}).omit({ id: true })
|
1888
2068
|
});
|
1889
2069
|
var DraftInput = BaseActionInput.extend({
|
1890
|
-
type:
|
2070
|
+
type: ActionTypes
|
2071
|
+
});
|
2072
|
+
|
2073
|
+
// ../commons/src/events/EventMetadata.ts
|
2074
|
+
var import_zod21 = require("zod");
|
2075
|
+
var EventStatus = {
|
2076
|
+
CREATED: "CREATED",
|
2077
|
+
NOTIFIED: "NOTIFIED",
|
2078
|
+
DECLARED: "DECLARED",
|
2079
|
+
VALIDATED: "VALIDATED",
|
2080
|
+
REGISTERED: "REGISTERED",
|
2081
|
+
CERTIFIED: "CERTIFIED",
|
2082
|
+
REJECTED: "REJECTED",
|
2083
|
+
ARCHIVED: "ARCHIVED"
|
2084
|
+
};
|
2085
|
+
var eventStatuses = Object.values(EventStatus);
|
2086
|
+
var EventStatuses = import_zod21.z.nativeEnum(EventStatus);
|
2087
|
+
var ZodDate = import_zod21.z.string().date();
|
2088
|
+
var EventMetadata = import_zod21.z.object({
|
2089
|
+
id: import_zod21.z.string(),
|
2090
|
+
type: import_zod21.z.string(),
|
2091
|
+
status: EventStatuses,
|
2092
|
+
createdAt: import_zod21.z.string().datetime(),
|
2093
|
+
dateOfEvent: ZodDate.nullish(),
|
2094
|
+
createdBy: import_zod21.z.string(),
|
2095
|
+
updatedByUserRole: import_zod21.z.string(),
|
2096
|
+
createdAtLocation: import_zod21.z.string(),
|
2097
|
+
updatedAtLocation: import_zod21.z.string(),
|
2098
|
+
updatedAt: import_zod21.z.string().datetime(),
|
2099
|
+
assignedTo: import_zod21.z.string().nullish(),
|
2100
|
+
updatedBy: import_zod21.z.string(),
|
2101
|
+
trackingId: import_zod21.z.string(),
|
2102
|
+
registrationNumber: import_zod21.z.string().nullish()
|
1891
2103
|
});
|
2104
|
+
var eventMetadataLabelMap = {
|
2105
|
+
"event.assignedTo": {
|
2106
|
+
id: "event.assignedTo.label",
|
2107
|
+
defaultMessage: "Assigned To",
|
2108
|
+
description: "Assigned To"
|
2109
|
+
},
|
2110
|
+
"event.createdAt": {
|
2111
|
+
id: "event.createdAt.label",
|
2112
|
+
defaultMessage: "Created",
|
2113
|
+
description: "Created At"
|
2114
|
+
},
|
2115
|
+
"event.dateOfEvent": {
|
2116
|
+
id: "event.dateOfEvent.label",
|
2117
|
+
defaultMessage: "Date of Event",
|
2118
|
+
description: "Date of Event"
|
2119
|
+
},
|
2120
|
+
"event.createdAtLocation": {
|
2121
|
+
id: "event.createdAtLocation.label",
|
2122
|
+
defaultMessage: "Location",
|
2123
|
+
description: "Created At Location"
|
2124
|
+
},
|
2125
|
+
"event.updatedAtLocation": {
|
2126
|
+
id: "event.updatedAtLocation.label",
|
2127
|
+
defaultMessage: "Location",
|
2128
|
+
description: "Updated At Location"
|
2129
|
+
},
|
2130
|
+
"event.createdBy": {
|
2131
|
+
id: "event.createdBy.label",
|
2132
|
+
defaultMessage: "Created By",
|
2133
|
+
description: "Created By"
|
2134
|
+
},
|
2135
|
+
"event.updatedByUserRole": {
|
2136
|
+
id: "event.updatedByUserRole.label",
|
2137
|
+
defaultMessage: "Updated By Role",
|
2138
|
+
description: "Updated By Role"
|
2139
|
+
},
|
2140
|
+
"event.id": {
|
2141
|
+
id: "event.id.label",
|
2142
|
+
defaultMessage: "ID",
|
2143
|
+
description: "ID"
|
2144
|
+
},
|
2145
|
+
"event.updatedAt": {
|
2146
|
+
id: "event.modifiedAt.label",
|
2147
|
+
defaultMessage: "Updated",
|
2148
|
+
description: "Modified At"
|
2149
|
+
},
|
2150
|
+
"event.status": {
|
2151
|
+
id: "event.status.label",
|
2152
|
+
defaultMessage: "Status",
|
2153
|
+
description: "Status"
|
2154
|
+
},
|
2155
|
+
"event.type": {
|
2156
|
+
id: "event.type.label",
|
2157
|
+
defaultMessage: "Type",
|
2158
|
+
description: "Type"
|
2159
|
+
},
|
2160
|
+
"event.updatedBy": {
|
2161
|
+
id: "event.updatedBy.label",
|
2162
|
+
defaultMessage: "Updated By",
|
2163
|
+
description: "Updated By"
|
2164
|
+
},
|
2165
|
+
"event.trackingId": {
|
2166
|
+
id: "event.trackingId.label",
|
2167
|
+
defaultMessage: "Tracking ID",
|
2168
|
+
description: "Tracking ID"
|
2169
|
+
},
|
2170
|
+
"event.registrationNumber": {
|
2171
|
+
id: "event.registrationNumber.label",
|
2172
|
+
defaultMessage: "Registration Number",
|
2173
|
+
description: "Registration Number"
|
2174
|
+
}
|
2175
|
+
};
|
1892
2176
|
|
1893
2177
|
// ../commons/src/events/EventInput.ts
|
1894
2178
|
var import_zod22 = require("zod");
|
1895
2179
|
var EventInput = import_zod22.z.object({
|
1896
2180
|
transactionId: import_zod22.z.string(),
|
1897
|
-
type: import_zod22.z.string()
|
2181
|
+
type: import_zod22.z.string(),
|
2182
|
+
dateOfEvent: import_zod22.z.object({ fieldId: import_zod22.z.string() }).optional()
|
1898
2183
|
});
|
1899
2184
|
|
1900
2185
|
// ../commons/src/events/EventDocument.ts
|
1901
2186
|
var import_zod23 = require("zod");
|
2187
|
+
var import_zod_openapi6 = require("zod-openapi");
|
2188
|
+
(0, import_zod_openapi6.extendZodWithOpenApi)(import_zod23.z);
|
1902
2189
|
var EventDocument = import_zod23.z.object({
|
1903
2190
|
id: import_zod23.z.string(),
|
1904
2191
|
type: import_zod23.z.string(),
|
2192
|
+
dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional(),
|
1905
2193
|
createdAt: import_zod23.z.string().datetime(),
|
1906
2194
|
updatedAt: import_zod23.z.string().datetime(),
|
1907
|
-
|
2195
|
+
updatedAtLocation: import_zod23.z.string(),
|
2196
|
+
actions: import_zod23.z.array(Action),
|
1908
2197
|
trackingId: import_zod23.z.string()
|
1909
|
-
});
|
2198
|
+
}).openapi({ ref: "EventDocument" });
|
1910
2199
|
|
1911
2200
|
// ../commons/src/events/EventIndex.ts
|
1912
2201
|
var import_zod24 = require("zod");
|
1913
2202
|
var EventIndex = EventMetadata.extend({
|
1914
|
-
|
2203
|
+
declaration: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
|
1915
2204
|
});
|
1916
2205
|
var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
|
1917
2206
|
import_zod24.z.object({
|
@@ -1919,35 +2208,94 @@ var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod
|
|
1919
2208
|
// Ensures "type" (event-id) exists and is a string
|
1920
2209
|
})
|
1921
2210
|
);
|
2211
|
+
var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() });
|
2212
|
+
var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() });
|
2213
|
+
var AnyOf = import_zod24.z.object({
|
2214
|
+
type: import_zod24.z.literal("anyOf"),
|
2215
|
+
terms: import_zod24.z.array(import_zod24.z.string())
|
2216
|
+
});
|
2217
|
+
var Range = import_zod24.z.object({
|
2218
|
+
type: import_zod24.z.literal("range"),
|
2219
|
+
gte: import_zod24.z.string(),
|
2220
|
+
lte: import_zod24.z.string()
|
2221
|
+
});
|
2222
|
+
var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() });
|
2223
|
+
var DateCondition = import_zod24.z.union([Exact, Range]);
|
2224
|
+
var QueryInput = import_zod24.z.lazy(
|
2225
|
+
() => import_zod24.z.union([
|
2226
|
+
import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
|
2227
|
+
import_zod24.z.record(import_zod24.z.string(), QueryInput)
|
2228
|
+
])
|
2229
|
+
);
|
2230
|
+
var QueryExpression = import_zod24.z.object({
|
2231
|
+
type: import_zod24.z.literal("and"),
|
2232
|
+
eventType: import_zod24.z.string(),
|
2233
|
+
status: import_zod24.z.optional(import_zod24.z.union([AnyOf, Exact])),
|
2234
|
+
createdAt: import_zod24.z.optional(DateCondition),
|
2235
|
+
updatedAt: import_zod24.z.optional(DateCondition),
|
2236
|
+
createAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
2237
|
+
updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
|
2238
|
+
createdBy: import_zod24.z.optional(Exact),
|
2239
|
+
updatedBy: import_zod24.z.optional(Exact),
|
2240
|
+
trackingId: import_zod24.z.optional(Exact),
|
2241
|
+
data: QueryInput
|
2242
|
+
}).partial();
|
2243
|
+
var Or2 = import_zod24.z.object({
|
2244
|
+
type: import_zod24.z.literal("or"),
|
2245
|
+
clauses: import_zod24.z.array(QueryExpression)
|
2246
|
+
});
|
2247
|
+
var QueryType = import_zod24.z.discriminatedUnion("type", [QueryExpression, Or2]);
|
1922
2248
|
|
1923
2249
|
// ../commons/src/events/state/index.ts
|
1924
|
-
var _ = __toESM(require("lodash"));
|
1925
2250
|
function getStatusFromActions(actions) {
|
2251
|
+
const hasRejectedAction = actions.some(
|
2252
|
+
(a) => a.status === ActionStatus.Rejected
|
2253
|
+
);
|
2254
|
+
if (hasRejectedAction) {
|
2255
|
+
return EventStatus.REJECTED;
|
2256
|
+
}
|
1926
2257
|
return actions.reduce((status, action) => {
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
2258
|
+
switch (action.type) {
|
2259
|
+
case ActionType.CREATE:
|
2260
|
+
return EventStatus.CREATED;
|
2261
|
+
case ActionType.DECLARE:
|
2262
|
+
return EventStatus.DECLARED;
|
2263
|
+
case ActionType.VALIDATE:
|
2264
|
+
return EventStatus.VALIDATED;
|
2265
|
+
case ActionType.REGISTER:
|
2266
|
+
return EventStatus.REGISTERED;
|
2267
|
+
case ActionType.REJECT:
|
2268
|
+
return EventStatus.REJECTED;
|
2269
|
+
case ActionType.ARCHIVE:
|
2270
|
+
return EventStatus.ARCHIVED;
|
2271
|
+
case ActionType.NOTIFY:
|
2272
|
+
return EventStatus.NOTIFIED;
|
2273
|
+
case ActionType.PRINT_CERTIFICATE:
|
2274
|
+
return EventStatus.CERTIFIED;
|
2275
|
+
case ActionType.ASSIGN:
|
2276
|
+
case ActionType.UNASSIGN:
|
2277
|
+
case ActionType.REQUEST_CORRECTION:
|
2278
|
+
case ActionType.APPROVE_CORRECTION:
|
2279
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
2280
|
+
case ActionType.REJECT_CORRECTION:
|
2281
|
+
case ActionType.READ:
|
2282
|
+
default:
|
2283
|
+
return status;
|
1947
2284
|
}
|
1948
|
-
return status;
|
1949
2285
|
}, EventStatus.CREATED);
|
1950
2286
|
}
|
2287
|
+
function getLastUpdatedByUserRoleFromActions(actions) {
|
2288
|
+
const actionsWithRoles = actions.filter(
|
2289
|
+
(action) => !isWriteAction(action.type) && action.status !== ActionStatus.Rejected
|
2290
|
+
).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
2291
|
+
const lastAction = actionsWithRoles.at(-1);
|
2292
|
+
if (!lastAction) {
|
2293
|
+
throw new Error(
|
2294
|
+
"Should never happen, at least CREATE action should be present"
|
2295
|
+
);
|
2296
|
+
}
|
2297
|
+
return ActionDocument.parse(lastAction).createdByRole;
|
2298
|
+
}
|
1951
2299
|
function getAssignedUserFromActions(actions) {
|
1952
2300
|
return actions.reduce((user2, action) => {
|
1953
2301
|
if (action.type === ActionType.ASSIGN) {
|
@@ -1959,7 +2307,7 @@ function getAssignedUserFromActions(actions) {
|
|
1959
2307
|
return user2;
|
1960
2308
|
}, null);
|
1961
2309
|
}
|
1962
|
-
function
|
2310
|
+
function aggregateActionDeclarations(actions) {
|
1963
2311
|
const excludedActions = [
|
1964
2312
|
ActionType.REQUEST_CORRECTION,
|
1965
2313
|
ActionType.PRINT_CERTIFICATE
|
@@ -1973,47 +2321,35 @@ function getData(actions) {
|
|
1973
2321
|
if (!requestAction) {
|
1974
2322
|
return status;
|
1975
2323
|
}
|
1976
|
-
return deepMerge(status, requestAction.
|
2324
|
+
return deepMerge(status, requestAction.declaration);
|
1977
2325
|
}
|
1978
|
-
return deepMerge(status, action.
|
2326
|
+
return deepMerge(status, action.declaration);
|
1979
2327
|
}, {});
|
1980
2328
|
}
|
1981
2329
|
function deepDropNulls(obj) {
|
1982
|
-
if (
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
[key]
|
1991
|
-
};
|
1992
|
-
}
|
1993
|
-
return acc;
|
1994
|
-
}, {});
|
1995
|
-
}
|
1996
|
-
function deepMerge(currentDocument, actionDocument) {
|
1997
|
-
return _.mergeWith(
|
1998
|
-
currentDocument,
|
1999
|
-
actionDocument,
|
2000
|
-
(previousValue, incomingValue) => {
|
2001
|
-
if (incomingValue === void 0) {
|
2002
|
-
return previousValue;
|
2003
|
-
}
|
2004
|
-
if (_.isArray(incomingValue)) {
|
2005
|
-
return incomingValue;
|
2006
|
-
}
|
2007
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2008
|
-
return void 0;
|
2330
|
+
if (Array.isArray(obj)) {
|
2331
|
+
return obj.map(deepDropNulls);
|
2332
|
+
}
|
2333
|
+
if (obj !== null && typeof obj === "object") {
|
2334
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
2335
|
+
const cleanedValue = deepDropNulls(value);
|
2336
|
+
if (cleanedValue !== null) {
|
2337
|
+
;
|
2338
|
+
acc[key] = cleanedValue;
|
2009
2339
|
}
|
2010
|
-
return
|
2011
|
-
}
|
2012
|
-
|
2340
|
+
return acc;
|
2341
|
+
}, {});
|
2342
|
+
}
|
2343
|
+
return obj;
|
2013
2344
|
}
|
2014
2345
|
function isUndeclaredDraft(status) {
|
2015
2346
|
return status === EventStatus.CREATED;
|
2016
2347
|
}
|
2348
|
+
function getAcceptedActions(event2) {
|
2349
|
+
return event2.actions.filter(
|
2350
|
+
(a) => a.status === ActionStatus.Accepted
|
2351
|
+
);
|
2352
|
+
}
|
2017
2353
|
function getCurrentEventState(event2) {
|
2018
2354
|
const creationAction = event2.actions.find(
|
2019
2355
|
(action) => action.type === ActionType.CREATE
|
@@ -2021,19 +2357,37 @@ function getCurrentEventState(event2) {
|
|
2021
2357
|
if (!creationAction) {
|
2022
2358
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2023
2359
|
}
|
2024
|
-
const
|
2360
|
+
const activeActions = getAcceptedActions(event2);
|
2361
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2362
|
+
const registrationAction = activeActions.find(
|
2363
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2364
|
+
);
|
2365
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2366
|
+
const declaration = aggregateActionDeclarations(activeActions);
|
2367
|
+
let dateOfEvent = event2.createdAt.split("T")[0];
|
2368
|
+
if (event2.dateOfEvent) {
|
2369
|
+
const parsedDate = ZodDate.safeParse(declaration[event2.dateOfEvent.fieldId]);
|
2370
|
+
dateOfEvent = parsedDate.success ? parsedDate.data : null;
|
2371
|
+
}
|
2025
2372
|
return deepDropNulls({
|
2026
2373
|
id: event2.id,
|
2027
2374
|
type: event2.type,
|
2028
2375
|
status: getStatusFromActions(event2.actions),
|
2376
|
+
// TODO CIHAN:
|
2377
|
+
// requestStatus: 'Requested',
|
2029
2378
|
createdAt: event2.createdAt,
|
2030
2379
|
createdBy: creationAction.createdBy,
|
2031
|
-
createdAtLocation: creationAction.createdAtLocation,
|
2032
|
-
|
2033
|
-
|
2380
|
+
createdAtLocation: creationAction.createdAtLocation ?? "",
|
2381
|
+
// @todo remove using empty string
|
2382
|
+
updatedAt: latestAction.createdAt,
|
2383
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2034
2384
|
updatedBy: latestAction.createdBy,
|
2035
|
-
|
2036
|
-
|
2385
|
+
updatedAtLocation: event2.updatedAtLocation,
|
2386
|
+
declaration,
|
2387
|
+
trackingId: event2.trackingId,
|
2388
|
+
registrationNumber,
|
2389
|
+
updatedByUserRole: getLastUpdatedByUserRoleFromActions(event2.actions),
|
2390
|
+
dateOfEvent
|
2037
2391
|
});
|
2038
2392
|
}
|
2039
2393
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2058,45 +2412,50 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
|
|
2058
2412
|
return getCurrentEventState(withDrafts);
|
2059
2413
|
}
|
2060
2414
|
function applyDraftsToEventIndex(eventIndex, drafts) {
|
2061
|
-
const indexedAt = eventIndex.
|
2415
|
+
const indexedAt = eventIndex.updatedAt;
|
2062
2416
|
const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
|
2063
2417
|
if (activeDrafts.length === 0) {
|
2064
2418
|
return eventIndex;
|
2065
2419
|
}
|
2066
2420
|
return {
|
2067
2421
|
...eventIndex,
|
2068
|
-
|
2069
|
-
...eventIndex.
|
2070
|
-
...activeDrafts[activeDrafts.length - 1].
|
2422
|
+
declaration: {
|
2423
|
+
...eventIndex.declaration,
|
2424
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2071
2425
|
}
|
2072
2426
|
};
|
2073
2427
|
}
|
2074
|
-
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({
|
2075
2436
|
event: event2,
|
2076
2437
|
actionType,
|
2077
|
-
drafts
|
2438
|
+
drafts = []
|
2078
2439
|
}) {
|
2079
|
-
const
|
2440
|
+
const activeActions = getAcceptedActions(event2);
|
2441
|
+
const action = activeActions.find(
|
2442
|
+
(activeAction) => actionType === activeAction.type
|
2443
|
+
);
|
2080
2444
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2081
2445
|
const sorted = [
|
2082
2446
|
...action ? [action] : [],
|
2083
2447
|
...eventDrafts.map((draft) => draft.action)
|
2084
2448
|
].sort();
|
2085
|
-
const
|
2086
|
-
return deepMerge(
|
2449
|
+
const annotation = sorted.reduce((ann, sortedAction) => {
|
2450
|
+
return deepMerge(ann, sortedAction.annotation ?? {});
|
2087
2451
|
}, {});
|
2088
|
-
return deepDropNulls(
|
2452
|
+
return deepDropNulls(annotation);
|
2089
2453
|
}
|
2090
2454
|
|
2091
2455
|
// ../commons/src/events/defineConfig.ts
|
2092
2456
|
var defineConfig = (config) => {
|
2093
|
-
validateWorkqueueConfig(config.workqueues);
|
2094
2457
|
const input = EventConfig.parse(config);
|
2095
|
-
|
2096
|
-
return EventConfig.parse({
|
2097
|
-
...input,
|
2098
|
-
pageFields
|
2099
|
-
});
|
2458
|
+
return input;
|
2100
2459
|
};
|
2101
2460
|
|
2102
2461
|
// ../commons/src/events/transactions.ts
|
@@ -2111,6 +2470,16 @@ var import_lodash2 = require("lodash");
|
|
2111
2470
|
function defineConditional(schema) {
|
2112
2471
|
return schema;
|
2113
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
|
+
}
|
2114
2483
|
function alwaysTrue() {
|
2115
2484
|
return {};
|
2116
2485
|
}
|
@@ -2135,6 +2504,9 @@ function not(condition) {
|
|
2135
2504
|
required: []
|
2136
2505
|
});
|
2137
2506
|
}
|
2507
|
+
function never() {
|
2508
|
+
return not(alwaysTrue());
|
2509
|
+
}
|
2138
2510
|
var user = {
|
2139
2511
|
hasScope: (scope) => defineConditional({
|
2140
2512
|
type: "object",
|
@@ -2156,95 +2528,148 @@ var user = {
|
|
2156
2528
|
required: ["$user"]
|
2157
2529
|
})
|
2158
2530
|
};
|
2159
|
-
|
2160
|
-
|
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 {
|
2161
2568
|
type: "object",
|
2162
2569
|
properties: {
|
2163
|
-
|
2164
|
-
type: "
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
type: "object",
|
2170
|
-
properties: {
|
2171
|
-
type: {
|
2172
|
-
const: action
|
2173
|
-
}
|
2174
|
-
},
|
2175
|
-
required: ["type"]
|
2176
|
-
}
|
2177
|
-
}
|
2178
|
-
},
|
2179
|
-
required: ["actions"]
|
2180
|
-
}
|
2570
|
+
[fieldId]: {
|
2571
|
+
type: "string",
|
2572
|
+
format: "date",
|
2573
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
2574
|
+
},
|
2575
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
2181
2576
|
},
|
2182
|
-
required: [
|
2183
|
-
}
|
2184
|
-
}
|
2185
|
-
function
|
2186
|
-
|
2577
|
+
required: [fieldId]
|
2578
|
+
};
|
2579
|
+
}
|
2580
|
+
function isFieldReference(value) {
|
2581
|
+
return typeof value === "object" && value !== null && "_fieldId" in value;
|
2582
|
+
}
|
2583
|
+
function createFieldConditionals(fieldId) {
|
2187
2584
|
const getDateRange = (date, clause) => ({
|
2188
2585
|
type: "object",
|
2189
2586
|
properties: {
|
2190
|
-
|
2191
|
-
type: "
|
2192
|
-
|
2193
|
-
|
2194
|
-
type: "string",
|
2195
|
-
format: "date",
|
2196
|
-
[clause]: date
|
2197
|
-
}
|
2198
|
-
},
|
2199
|
-
required: [fieldId]
|
2587
|
+
[fieldId]: {
|
2588
|
+
type: "string",
|
2589
|
+
format: "date",
|
2590
|
+
[clause]: date
|
2200
2591
|
}
|
2201
2592
|
},
|
2202
|
-
required: [
|
2593
|
+
required: [fieldId]
|
2203
2594
|
});
|
2204
2595
|
return {
|
2205
2596
|
isAfter: () => ({
|
2206
2597
|
days: (days) => ({
|
2207
|
-
inPast: () =>
|
2598
|
+
inPast: () => defineFormConditional(
|
2208
2599
|
getDateRange(getDateFromNow(days), "formatMinimum")
|
2209
2600
|
),
|
2210
|
-
inFuture: () =>
|
2601
|
+
inFuture: () => defineFormConditional(
|
2211
2602
|
getDateRange(getDateFromNow(-days), "formatMinimum")
|
2212
2603
|
)
|
2213
2604
|
}),
|
2214
|
-
date: (date) =>
|
2215
|
-
|
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"))
|
2216
2619
|
}),
|
2217
2620
|
isBefore: () => ({
|
2218
2621
|
days: (days) => ({
|
2219
|
-
inPast: () =>
|
2622
|
+
inPast: () => defineFormConditional(
|
2220
2623
|
getDateRange(getDateFromNow(days), "formatMaximum")
|
2221
2624
|
),
|
2222
|
-
inFuture: () =>
|
2625
|
+
inFuture: () => defineFormConditional(
|
2223
2626
|
getDateRange(getDateFromNow(-days), "formatMaximum")
|
2224
2627
|
)
|
2225
2628
|
}),
|
2226
|
-
date: (date) =>
|
2227
|
-
|
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"))
|
2228
2643
|
}),
|
2229
|
-
isEqualTo: (value) =>
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2644
|
+
isEqualTo: (value) => {
|
2645
|
+
if (isFieldReference(value)) {
|
2646
|
+
const comparedFieldId = value._fieldId;
|
2647
|
+
return defineFormConditional({
|
2233
2648
|
type: "object",
|
2234
2649
|
properties: {
|
2235
2650
|
[fieldId]: {
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
const: value
|
2241
|
-
}
|
2651
|
+
type: ["string", "boolean"],
|
2652
|
+
const: { $data: `1/${comparedFieldId}` }
|
2653
|
+
},
|
2654
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2242
2655
|
},
|
2243
|
-
required: [fieldId]
|
2244
|
-
}
|
2245
|
-
}
|
2246
|
-
|
2247
|
-
|
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
|
+
},
|
2248
2673
|
/**
|
2249
2674
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2250
2675
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2253,91 +2678,166 @@ function field(fieldId) {
|
|
2253
2678
|
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
2254
2679
|
*
|
2255
2680
|
*/
|
2256
|
-
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({
|
2257
2727
|
type: "object",
|
2258
2728
|
properties: {
|
2259
|
-
|
2260
|
-
type: "
|
2261
|
-
|
2262
|
-
|
2263
|
-
anyOf: [
|
2264
|
-
{ const: "undefined" },
|
2265
|
-
{ const: false },
|
2266
|
-
{ const: null },
|
2267
|
-
{ const: "" }
|
2268
|
-
]
|
2269
|
-
}
|
2270
|
-
},
|
2271
|
-
anyOf: [
|
2272
|
-
{
|
2273
|
-
required: [fieldId]
|
2274
|
-
},
|
2275
|
-
{
|
2276
|
-
not: {
|
2277
|
-
required: [fieldId]
|
2278
|
-
}
|
2279
|
-
}
|
2280
|
-
]
|
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."
|
2281
2733
|
}
|
2282
2734
|
},
|
2283
|
-
required: [
|
2735
|
+
required: [fieldId]
|
2284
2736
|
}),
|
2285
|
-
|
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({
|
2286
2743
|
type: "object",
|
2287
2744
|
properties: {
|
2288
|
-
|
2289
|
-
type: "
|
2290
|
-
|
2291
|
-
[fieldId]: {
|
2292
|
-
type: "string",
|
2293
|
-
enum: ["undefined"]
|
2294
|
-
}
|
2295
|
-
},
|
2296
|
-
not: {
|
2297
|
-
required: [fieldId]
|
2298
|
-
}
|
2745
|
+
[fieldId]: {
|
2746
|
+
type: "string",
|
2747
|
+
pattern
|
2299
2748
|
}
|
2300
2749
|
},
|
2301
|
-
required: [
|
2750
|
+
required: [fieldId]
|
2302
2751
|
}),
|
2303
|
-
|
2752
|
+
isBetween: (min, max) => defineFormConditional({
|
2304
2753
|
type: "object",
|
2305
2754
|
properties: {
|
2306
|
-
|
2307
|
-
type: "
|
2308
|
-
|
2309
|
-
|
2310
|
-
type: "string",
|
2311
|
-
enum: values
|
2312
|
-
}
|
2313
|
-
},
|
2314
|
-
required: [fieldId]
|
2755
|
+
[fieldId]: {
|
2756
|
+
type: "number",
|
2757
|
+
minimum: min,
|
2758
|
+
maximum: max
|
2315
2759
|
}
|
2316
2760
|
},
|
2317
|
-
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" }
|
2318
2814
|
})
|
2319
2815
|
};
|
2320
2816
|
}
|
2321
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
|
+
|
2322
2830
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2323
|
-
var PRINT_CERTIFICATE_FORM =
|
2831
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2324
2832
|
label: {
|
2325
2833
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2326
2834
|
defaultMessage: "Tennis club membership certificate collector",
|
2327
2835
|
description: "This is what this form is referred as in the system"
|
2328
2836
|
},
|
2329
|
-
version: {
|
2330
|
-
id: "1.0.0",
|
2331
|
-
label: {
|
2332
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2333
|
-
defaultMessage: "Version 1",
|
2334
|
-
description: "This is the first version of the form"
|
2335
|
-
}
|
2336
|
-
},
|
2337
|
-
active: true,
|
2338
2837
|
pages: [
|
2339
2838
|
{
|
2340
2839
|
id: "collector",
|
2840
|
+
type: PageTypes.enum.FORM,
|
2341
2841
|
title: {
|
2342
2842
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2343
2843
|
defaultMessage: "Print certified copy",
|
@@ -2352,7 +2852,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2352
2852
|
defaultMessage: "Requester",
|
2353
2853
|
description: "This is the label for the field"
|
2354
2854
|
},
|
2355
|
-
type:
|
2855
|
+
type: FieldType.SELECT,
|
2356
2856
|
options: [
|
2357
2857
|
{
|
2358
2858
|
value: "INFORMANT",
|
@@ -2429,7 +2929,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2429
2929
|
defaultMessage: "Select Type of ID",
|
2430
2930
|
description: "This is the label for selecting the type of ID"
|
2431
2931
|
},
|
2432
|
-
type:
|
2932
|
+
type: FieldType.SELECT,
|
2433
2933
|
options: [
|
2434
2934
|
{
|
2435
2935
|
value: "PASSPORT",
|
@@ -2530,7 +3030,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2530
3030
|
defaultMessage: "Passport Details",
|
2531
3031
|
description: "Field for entering Passport details"
|
2532
3032
|
},
|
2533
|
-
type:
|
3033
|
+
type: FieldType.TEXT
|
2534
3034
|
},
|
2535
3035
|
{
|
2536
3036
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2581,7 +3081,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2581
3081
|
defaultMessage: "Driving License Details",
|
2582
3082
|
description: "Field for entering Driving License details"
|
2583
3083
|
},
|
2584
|
-
type:
|
3084
|
+
type: FieldType.TEXT
|
2585
3085
|
},
|
2586
3086
|
{
|
2587
3087
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2632,7 +3132,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2632
3132
|
defaultMessage: "Refugee Number Details",
|
2633
3133
|
description: "Field for entering Refugee Number details"
|
2634
3134
|
},
|
2635
|
-
type:
|
3135
|
+
type: FieldType.TEXT
|
2636
3136
|
},
|
2637
3137
|
{
|
2638
3138
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2683,7 +3183,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2683
3183
|
defaultMessage: "Alien Number Details",
|
2684
3184
|
description: "Field for entering Alien Number details"
|
2685
3185
|
},
|
2686
|
-
type:
|
3186
|
+
type: FieldType.TEXT
|
2687
3187
|
},
|
2688
3188
|
{
|
2689
3189
|
id: "collector.OTHER.idTypeOther",
|
@@ -2734,7 +3234,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2734
3234
|
defaultMessage: "Other ID Type (if applicable)",
|
2735
3235
|
description: 'Field for entering ID type if "Other" is selected'
|
2736
3236
|
},
|
2737
|
-
type:
|
3237
|
+
type: FieldType.TEXT
|
2738
3238
|
},
|
2739
3239
|
{
|
2740
3240
|
id: "collector.OTHER.firstName",
|
@@ -2785,7 +3285,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2785
3285
|
defaultMessage: "First Name",
|
2786
3286
|
description: "This is the label for the first name field"
|
2787
3287
|
},
|
2788
|
-
type:
|
3288
|
+
type: FieldType.TEXT
|
2789
3289
|
},
|
2790
3290
|
{
|
2791
3291
|
id: "collector.OTHER.lastName",
|
@@ -2836,7 +3336,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2836
3336
|
defaultMessage: "Last Name",
|
2837
3337
|
description: "This is the label for the last name field"
|
2838
3338
|
},
|
2839
|
-
type:
|
3339
|
+
type: FieldType.TEXT
|
2840
3340
|
},
|
2841
3341
|
{
|
2842
3342
|
id: "collector.OTHER.relationshipToMember",
|
@@ -2887,7 +3387,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2887
3387
|
defaultMessage: "Relationship to Member",
|
2888
3388
|
description: "This is the label for the relationship to member field"
|
2889
3389
|
},
|
2890
|
-
type:
|
3390
|
+
type: FieldType.TEXT
|
2891
3391
|
},
|
2892
3392
|
{
|
2893
3393
|
id: "collector.OTHER.signedAffidavit",
|
@@ -2938,66 +3438,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2938
3438
|
defaultMessage: "Signed Affidavit (Optional)",
|
2939
3439
|
description: "This is the label for uploading a signed affidavit"
|
2940
3440
|
},
|
2941
|
-
type:
|
3441
|
+
type: FieldType.FILE
|
2942
3442
|
}
|
2943
3443
|
]
|
2944
|
-
}
|
2945
|
-
],
|
2946
|
-
review: {
|
2947
|
-
title: {
|
2948
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
2949
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
2950
|
-
description: "Title of the form to show in review page"
|
2951
3444
|
},
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
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
|
+
}
|
2968
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"
|
2969
3491
|
},
|
2970
|
-
|
2971
|
-
|
2972
|
-
id: "
|
2973
|
-
|
2974
|
-
|
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
|
+
}
|
2975
3501
|
},
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
2979
|
-
|
2980
|
-
|
2981
|
-
|
2982
|
-
|
2983
|
-
description: "Label for the comment field in the review section"
|
2984
|
-
}
|
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"
|
2985
3509
|
},
|
2986
|
-
{
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
defaultMessage: "Signature of informant",
|
2991
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
2992
|
-
description: "Label for the signature field in the review section"
|
2993
|
-
},
|
2994
|
-
signaturePromptLabel: {
|
2995
|
-
id: "v2.signature.upload.modal.title",
|
2996
|
-
defaultMessage: "Draw signature",
|
2997
|
-
description: "Title for the modal to draw signature"
|
2998
|
-
}
|
3510
|
+
signaturePromptLabel: {
|
3511
|
+
id: "v2.signature.upload.modal.title",
|
3512
|
+
defaultMessage: "Draw signature",
|
3513
|
+
description: "Title for the modal to draw signature"
|
2999
3514
|
}
|
3000
|
-
|
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"
|
3001
3523
|
},
|
3002
3524
|
pages: [
|
3003
3525
|
{
|
@@ -3010,7 +3532,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3010
3532
|
fields: [
|
3011
3533
|
{
|
3012
3534
|
id: "applicant.firstname",
|
3013
|
-
type:
|
3535
|
+
type: FieldType.TEXT,
|
3014
3536
|
required: true,
|
3015
3537
|
conditionals: [],
|
3016
3538
|
label: {
|
@@ -3021,7 +3543,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3021
3543
|
},
|
3022
3544
|
{
|
3023
3545
|
id: "applicant.surname",
|
3024
|
-
type:
|
3546
|
+
type: FieldType.TEXT,
|
3025
3547
|
required: true,
|
3026
3548
|
conditionals: [],
|
3027
3549
|
label: {
|
@@ -3043,9 +3565,8 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3043
3565
|
},
|
3044
3566
|
{
|
3045
3567
|
id: "applicant.dob",
|
3046
|
-
type:
|
3568
|
+
type: FieldType.DATE,
|
3047
3569
|
required: true,
|
3048
|
-
conditionals: [],
|
3049
3570
|
validation: [
|
3050
3571
|
{
|
3051
3572
|
message: {
|
@@ -3056,15 +3577,53 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3056
3577
|
validator: field("applicant.dob").isBefore().now()
|
3057
3578
|
}
|
3058
3579
|
],
|
3580
|
+
conditionals: [
|
3581
|
+
{
|
3582
|
+
type: ConditionalType.SHOW,
|
3583
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3584
|
+
}
|
3585
|
+
],
|
3059
3586
|
label: {
|
3060
3587
|
defaultMessage: "Applicant's date of birth",
|
3061
3588
|
description: "This is the label for the field",
|
3062
3589
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3063
3590
|
}
|
3064
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
|
+
},
|
3065
3624
|
{
|
3066
3625
|
id: "applicant.image",
|
3067
|
-
type:
|
3626
|
+
type: FieldType.FILE,
|
3068
3627
|
required: false,
|
3069
3628
|
label: {
|
3070
3629
|
defaultMessage: "Applicant's profile picture",
|
@@ -3085,6 +3644,27 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3085
3644
|
}
|
3086
3645
|
]
|
3087
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
|
+
},
|
3088
3668
|
{
|
3089
3669
|
id: "recommender",
|
3090
3670
|
title: {
|
@@ -3106,7 +3686,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3106
3686
|
},
|
3107
3687
|
{
|
3108
3688
|
id: "recommender.firstname",
|
3109
|
-
type:
|
3689
|
+
type: FieldType.TEXT,
|
3110
3690
|
required: true,
|
3111
3691
|
conditionals: [
|
3112
3692
|
{
|
@@ -3122,7 +3702,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3122
3702
|
},
|
3123
3703
|
{
|
3124
3704
|
id: "recommender.surname",
|
3125
|
-
type:
|
3705
|
+
type: FieldType.TEXT,
|
3126
3706
|
required: true,
|
3127
3707
|
conditionals: [
|
3128
3708
|
{
|
@@ -3138,7 +3718,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3138
3718
|
},
|
3139
3719
|
{
|
3140
3720
|
id: "recommender.id",
|
3141
|
-
type:
|
3721
|
+
type: FieldType.TEXT,
|
3142
3722
|
required: true,
|
3143
3723
|
conditionals: [
|
3144
3724
|
{
|
@@ -3163,20 +3743,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3163
3743
|
description: "This is what this event is referred as in the system",
|
3164
3744
|
id: "event.tennis-club-membership.label"
|
3165
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
|
+
},
|
3166
3751
|
summary: {
|
3167
|
-
title: {
|
3168
|
-
id: "event.tennis-club-membership.summary.title",
|
3169
|
-
label: {
|
3170
|
-
defaultMessage: "{applicant.firstname} {applicant.surname}",
|
3171
|
-
description: "This is the title of the summary",
|
3172
|
-
id: "v2.event.tennis-club-membership.summary.title"
|
3173
|
-
},
|
3174
|
-
emptyValueMessage: {
|
3175
|
-
defaultMessage: "Membership application",
|
3176
|
-
description: "This is the message shown when the applicant name is missing",
|
3177
|
-
id: "event.tennis-club-membership.summary.title.empty"
|
3178
|
-
}
|
3179
|
-
},
|
3180
3752
|
fields: [
|
3181
3753
|
{
|
3182
3754
|
id: "applicant.firstname",
|
@@ -3216,28 +3788,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3216
3788
|
}
|
3217
3789
|
]
|
3218
3790
|
},
|
3219
|
-
workqueues: [
|
3220
|
-
{
|
3221
|
-
id: "all",
|
3222
|
-
filters: []
|
3223
|
-
},
|
3224
|
-
{
|
3225
|
-
id: "ready-for-review",
|
3226
|
-
filters: [
|
3227
|
-
{
|
3228
|
-
status: ["DECLARED"]
|
3229
|
-
}
|
3230
|
-
]
|
3231
|
-
},
|
3232
|
-
{
|
3233
|
-
id: "registered",
|
3234
|
-
filters: [
|
3235
|
-
{
|
3236
|
-
status: ["REGISTERED"]
|
3237
|
-
}
|
3238
|
-
]
|
3239
|
-
}
|
3240
|
-
],
|
3241
3791
|
actions: [
|
3242
3792
|
{
|
3243
3793
|
type: ActionType.DECLARE,
|
@@ -3246,7 +3796,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3246
3796
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3247
3797
|
id: "event.tennis-club-membership.action.declare.label"
|
3248
3798
|
},
|
3249
|
-
|
3799
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3250
3800
|
},
|
3251
3801
|
{
|
3252
3802
|
type: ActionType.VALIDATE,
|
@@ -3255,7 +3805,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3255
3805
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3256
3806
|
id: "event.tennis-club-membership.action.validate.label"
|
3257
3807
|
},
|
3258
|
-
|
3808
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3259
3809
|
},
|
3260
3810
|
{
|
3261
3811
|
type: ActionType.REGISTER,
|
@@ -3264,7 +3814,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3264
3814
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3265
3815
|
id: "event.tennis-club-membership.action.register.label"
|
3266
3816
|
},
|
3267
|
-
|
3817
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3268
3818
|
},
|
3269
3819
|
{
|
3270
3820
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3273,10 +3823,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3273
3823
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3274
3824
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3275
3825
|
},
|
3276
|
-
forms: [TENNIS_CLUB_FORM],
|
3277
3826
|
onboardingForm: [
|
3278
3827
|
{
|
3279
3828
|
id: "correction-requester",
|
3829
|
+
type: PageTypes.enum.FORM,
|
3280
3830
|
title: {
|
3281
3831
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3282
3832
|
defaultMessage: "Correction requester",
|
@@ -3340,6 +3890,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3340
3890
|
},
|
3341
3891
|
{
|
3342
3892
|
id: "identity-check",
|
3893
|
+
type: PageTypes.enum.FORM,
|
3343
3894
|
title: {
|
3344
3895
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3345
3896
|
defaultMessage: "Verify their identity",
|
@@ -3382,6 +3933,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3382
3933
|
additionalDetailsForm: [
|
3383
3934
|
{
|
3384
3935
|
id: "correction-request.supporting-documents",
|
3936
|
+
type: PageTypes.enum.FORM,
|
3385
3937
|
title: {
|
3386
3938
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3387
3939
|
defaultMessage: "Upload supporting documents",
|
@@ -3399,7 +3951,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3399
3951
|
},
|
3400
3952
|
{
|
3401
3953
|
id: "correction.supportingDocs",
|
3402
|
-
type:
|
3954
|
+
type: FieldType.FILE,
|
3403
3955
|
label: {
|
3404
3956
|
id: "correction.corrector.title",
|
3405
3957
|
defaultMessage: "Upload supporting documents",
|
@@ -3443,6 +3995,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3443
3995
|
},
|
3444
3996
|
{
|
3445
3997
|
id: "correction-request.additional-details",
|
3998
|
+
type: PageTypes.enum.FORM,
|
3446
3999
|
title: {
|
3447
4000
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3448
4001
|
defaultMessage: "Reason for correction",
|
@@ -3451,7 +4004,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3451
4004
|
fields: [
|
3452
4005
|
{
|
3453
4006
|
id: "correction.request.reason",
|
3454
|
-
type:
|
4007
|
+
type: FieldType.TEXT,
|
3455
4008
|
label: {
|
3456
4009
|
id: "correction.reason.title",
|
3457
4010
|
defaultMessage: "Reason for correction?",
|
@@ -3464,7 +4017,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3464
4017
|
},
|
3465
4018
|
{
|
3466
4019
|
type: ActionType.APPROVE_CORRECTION,
|
3467
|
-
forms: [TENNIS_CLUB_FORM],
|
3468
4020
|
label: {
|
3469
4021
|
defaultMessage: "Approve correction",
|
3470
4022
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3478,7 +4030,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3478
4030
|
defaultMessage: "Print certificate",
|
3479
4031
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3480
4032
|
},
|
3481
|
-
|
4033
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3482
4034
|
conditionals: [
|
3483
4035
|
{
|
3484
4036
|
type: "SHOW",
|
@@ -3525,8 +4077,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3525
4077
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3526
4078
|
defaultMessage: "Archive",
|
3527
4079
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3528
|
-
}
|
3529
|
-
forms: [TENNIS_CLUB_FORM]
|
4080
|
+
}
|
3530
4081
|
},
|
3531
4082
|
{
|
3532
4083
|
type: ActionType.REJECT,
|
@@ -3534,8 +4085,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3534
4085
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3535
4086
|
defaultMessage: "Reject",
|
3536
4087
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3537
|
-
}
|
3538
|
-
forms: [TENNIS_CLUB_FORM]
|
4088
|
+
}
|
3539
4089
|
}
|
3540
4090
|
],
|
3541
4091
|
advancedSearch: [
|
@@ -3545,26 +4095,55 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3545
4095
|
description: "This is what this event is referred as in the system",
|
3546
4096
|
id: "v2.event.tennis-club-membership.search"
|
3547
4097
|
},
|
3548
|
-
fields: [
|
3549
|
-
{
|
3550
|
-
fieldId: "applicant.dob"
|
3551
|
-
}
|
3552
|
-
]
|
4098
|
+
fields: [field("applicant.dob").exact()]
|
3553
4099
|
}
|
3554
|
-
]
|
4100
|
+
],
|
4101
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3555
4102
|
});
|
3556
4103
|
|
3557
4104
|
// ../commons/src/events/test.utils.ts
|
3558
|
-
function
|
3559
|
-
|
3560
|
-
const data = fields.reduce(
|
4105
|
+
function fieldConfigsToActionPayload(fields) {
|
4106
|
+
return fields.reduce(
|
3561
4107
|
(acc, field2, i) => ({
|
3562
4108
|
...acc,
|
3563
4109
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3564
4110
|
}),
|
3565
4111
|
{}
|
3566
4112
|
);
|
3567
|
-
|
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
|
+
};
|
3568
4147
|
}
|
3569
4148
|
var eventPayloadGenerator = {
|
3570
4149
|
create: (input = {}) => ({
|
@@ -3576,27 +4155,31 @@ var eventPayloadGenerator = {
|
|
3576
4155
|
type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
|
3577
4156
|
id
|
3578
4157
|
}),
|
3579
|
-
draft: (eventId, input = {}) => (0, import_lodash2.merge)(
|
4158
|
+
draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
|
3580
4159
|
{
|
3581
4160
|
id: getUUID(),
|
3582
4161
|
eventId,
|
3583
4162
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3584
4163
|
transactionId: getUUID(),
|
3585
4164
|
action: {
|
3586
|
-
|
3587
|
-
|
4165
|
+
transactionId: getUUID(),
|
4166
|
+
type: actionType,
|
4167
|
+
status: ActionStatus.Accepted,
|
4168
|
+
declaration: {
|
3588
4169
|
"applicant.firstname": "Max",
|
3589
4170
|
"applicant.surname": "McLaren",
|
3590
4171
|
"applicant.dob": "2020-01-02",
|
3591
4172
|
"recommender.none": true
|
3592
4173
|
},
|
3593
|
-
|
4174
|
+
annotation: {
|
3594
4175
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3595
4176
|
"correction.request.reason": "Child's name was incorrect"
|
3596
4177
|
},
|
3597
4178
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
3598
4179
|
createdBy: "@todo",
|
3599
|
-
|
4180
|
+
createdByRole: "@todo",
|
4181
|
+
createdAtLocation: "@todo",
|
4182
|
+
updatedAtLocation: "@todo"
|
3600
4183
|
}
|
3601
4184
|
},
|
3602
4185
|
input
|
@@ -3605,41 +4188,104 @@ var eventPayloadGenerator = {
|
|
3605
4188
|
declare: (eventId, input = {}) => ({
|
3606
4189
|
type: ActionType.DECLARE,
|
3607
4190
|
transactionId: input.transactionId ?? getUUID(),
|
3608
|
-
|
4191
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4192
|
+
tennisClubMembershipEvent,
|
4193
|
+
ActionType.DECLARE
|
4194
|
+
),
|
4195
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4196
|
+
tennisClubMembershipEvent,
|
4197
|
+
ActionType.DECLARE
|
4198
|
+
),
|
3609
4199
|
eventId
|
3610
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
|
+
},
|
3611
4223
|
validate: (eventId, input = {}) => ({
|
3612
4224
|
type: ActionType.VALIDATE,
|
3613
4225
|
transactionId: input.transactionId ?? getUUID(),
|
3614
|
-
|
4226
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4227
|
+
tennisClubMembershipEvent,
|
4228
|
+
ActionType.VALIDATE
|
4229
|
+
),
|
4230
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4231
|
+
tennisClubMembershipEvent,
|
4232
|
+
ActionType.VALIDATE
|
4233
|
+
),
|
3615
4234
|
duplicates: [],
|
3616
4235
|
eventId
|
3617
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
|
+
}),
|
3618
4251
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3619
4252
|
type: ActionType.ARCHIVE,
|
3620
4253
|
transactionId: input.transactionId ?? getUUID(),
|
3621
|
-
|
3622
|
-
|
4254
|
+
declaration: {},
|
4255
|
+
// @TODO: Check whether generator is needed?
|
4256
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3623
4257
|
duplicates: [],
|
3624
4258
|
eventId
|
3625
4259
|
}),
|
3626
4260
|
reject: (eventId, input = {}) => ({
|
3627
4261
|
type: ActionType.REJECT,
|
3628
4262
|
transactionId: input.transactionId ?? getUUID(),
|
3629
|
-
|
4263
|
+
declaration: {},
|
4264
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4265
|
+
tennisClubMembershipEvent,
|
4266
|
+
ActionType.REJECT
|
4267
|
+
),
|
3630
4268
|
duplicates: [],
|
3631
4269
|
eventId
|
3632
4270
|
}),
|
3633
4271
|
register: (eventId, input = {}) => ({
|
3634
4272
|
type: ActionType.REGISTER,
|
3635
4273
|
transactionId: input.transactionId ?? getUUID(),
|
3636
|
-
|
4274
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4275
|
+
tennisClubMembershipEvent,
|
4276
|
+
ActionType.REGISTER
|
4277
|
+
),
|
4278
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4279
|
+
tennisClubMembershipEvent,
|
4280
|
+
ActionType.REGISTER
|
4281
|
+
),
|
3637
4282
|
eventId
|
3638
4283
|
}),
|
3639
4284
|
printCertificate: (eventId, input = {}) => ({
|
3640
4285
|
type: ActionType.PRINT_CERTIFICATE,
|
3641
4286
|
transactionId: input.transactionId ?? getUUID(),
|
3642
|
-
|
4287
|
+
declaration: {},
|
4288
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3643
4289
|
tennisClubMembershipEvent,
|
3644
4290
|
ActionType.PRINT_CERTIFICATE
|
3645
4291
|
),
|
@@ -3649,17 +4295,21 @@ var eventPayloadGenerator = {
|
|
3649
4295
|
request: (eventId, input = {}) => ({
|
3650
4296
|
type: ActionType.REQUEST_CORRECTION,
|
3651
4297
|
transactionId: input.transactionId ?? getUUID(),
|
3652
|
-
|
4298
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4299
|
+
tennisClubMembershipEvent,
|
4300
|
+
ActionType.REQUEST_CORRECTION
|
4301
|
+
),
|
4302
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3653
4303
|
tennisClubMembershipEvent,
|
3654
4304
|
ActionType.REQUEST_CORRECTION
|
3655
4305
|
),
|
3656
|
-
metadata: {},
|
3657
4306
|
eventId
|
3658
4307
|
}),
|
3659
4308
|
approve: (eventId, requestId, input = {}) => ({
|
3660
4309
|
type: ActionType.APPROVE_CORRECTION,
|
3661
4310
|
transactionId: input.transactionId ?? getUUID(),
|
3662
|
-
|
4311
|
+
declaration: {},
|
4312
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3663
4313
|
tennisClubMembershipEvent,
|
3664
4314
|
ActionType.APPROVE_CORRECTION
|
3665
4315
|
),
|
@@ -3669,7 +4319,8 @@ var eventPayloadGenerator = {
|
|
3669
4319
|
reject: (eventId, requestId, input = {}) => ({
|
3670
4320
|
type: ActionType.REJECT_CORRECTION,
|
3671
4321
|
transactionId: input.transactionId ?? getUUID(),
|
3672
|
-
|
4322
|
+
declaration: {},
|
4323
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
3673
4324
|
tennisClubMembershipEvent,
|
3674
4325
|
ActionType.REJECT_CORRECTION
|
3675
4326
|
),
|
@@ -3689,17 +4340,25 @@ function generateActionDocument({
|
|
3689
4340
|
// @TODO: This should be fixed in the future.
|
3690
4341
|
createdAt: new Date(Date.now() - 500).toISOString(),
|
3691
4342
|
createdBy: getUUID(),
|
4343
|
+
createdByRole: "FIELD_AGENT",
|
3692
4344
|
id: getUUID(),
|
3693
4345
|
createdAtLocation: "TODO",
|
3694
|
-
|
3695
|
-
|
3696
|
-
|
4346
|
+
updatedAtLocation: "TODO",
|
4347
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4348
|
+
annotation: {},
|
4349
|
+
...defaults,
|
4350
|
+
status: ActionStatus.Accepted,
|
4351
|
+
transactionId: getUUID()
|
3697
4352
|
};
|
3698
4353
|
switch (action) {
|
4354
|
+
case ActionType.READ:
|
4355
|
+
return { ...actionBase, type: action };
|
4356
|
+
case ActionType.MARKED_AS_DUPLICATE:
|
4357
|
+
return { ...actionBase, type: action };
|
3699
4358
|
case ActionType.DECLARE:
|
3700
4359
|
return { ...actionBase, type: action };
|
3701
4360
|
case ActionType.UNASSIGN:
|
3702
|
-
return { ...actionBase, type: action };
|
4361
|
+
return { ...actionBase, type: action, assignedTo: null };
|
3703
4362
|
case ActionType.ASSIGN:
|
3704
4363
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
3705
4364
|
case ActionType.VALIDATE:
|
@@ -3720,14 +4379,13 @@ function generateActionDocument({
|
|
3720
4379
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3721
4380
|
case ActionType.REJECT_CORRECTION:
|
3722
4381
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3723
|
-
case ActionType.CUSTOM:
|
3724
|
-
return { ...actionBase, type: action };
|
3725
4382
|
case ActionType.REGISTER:
|
3726
4383
|
return {
|
3727
4384
|
...actionBase,
|
3728
|
-
type: action
|
3729
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4385
|
+
type: action
|
3730
4386
|
};
|
4387
|
+
case ActionType.DELETE:
|
4388
|
+
case ActionType.DETECT_DUPLICATE:
|
3731
4389
|
default:
|
3732
4390
|
throw new Error(`Unsupported action type: ${action}`);
|
3733
4391
|
}
|
@@ -3748,10 +4406,12 @@ function generateEventDocument({
|
|
3748
4406
|
id: getUUID(),
|
3749
4407
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
3750
4408
|
// @TODO: This should be fixed in the future.
|
3751
|
-
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
4409
|
+
updatedAt: new Date(Date.now() - 1e3).toISOString(),
|
4410
|
+
dateOfEvent: configuration.dateOfEvent,
|
4411
|
+
updatedAtLocation: getUUID()
|
3752
4412
|
};
|
3753
4413
|
}
|
3754
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4414
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3755
4415
|
const action = generateActionDocument({
|
3756
4416
|
configuration: tennisClubMembershipEvent,
|
3757
4417
|
action: actionType
|
@@ -3761,9 +4421,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
3761
4421
|
transactionId: getUUID(),
|
3762
4422
|
action: {
|
3763
4423
|
...action,
|
3764
|
-
|
3765
|
-
...action.
|
3766
|
-
...
|
4424
|
+
declaration: {
|
4425
|
+
...action.declaration,
|
4426
|
+
...declaration
|
3767
4427
|
}
|
3768
4428
|
},
|
3769
4429
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -3777,10 +4437,12 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3777
4437
|
createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3778
4438
|
createdBy: overrides.createdBy ?? getUUID(),
|
3779
4439
|
createdAtLocation: overrides.createdAtLocation ?? getUUID(),
|
3780
|
-
|
4440
|
+
updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
|
4441
|
+
updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
3781
4442
|
assignedTo: overrides.assignedTo ?? null,
|
3782
4443
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
3783
|
-
|
4444
|
+
updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
|
4445
|
+
declaration: overrides.declaration ?? {
|
3784
4446
|
"recommender.none": true,
|
3785
4447
|
"applicant.firstname": "Danny",
|
3786
4448
|
"applicant.surname": "Doe",
|
@@ -3788,6 +4450,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3788
4450
|
},
|
3789
4451
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3790
4452
|
});
|
4453
|
+
var generateTranslationConfig = (message) => ({
|
4454
|
+
defaultMessage: message,
|
4455
|
+
description: "Description for ${message}",
|
4456
|
+
id: message
|
4457
|
+
});
|
3791
4458
|
|
3792
4459
|
// ../commons/src/events/TemplateConfig.ts
|
3793
4460
|
function isTemplateVariable(value) {
|
@@ -3806,7 +4473,9 @@ function isFieldValueWithoutTemplates(value) {
|
|
3806
4473
|
return true;
|
3807
4474
|
}
|
3808
4475
|
function isFieldConfigDefaultValue(value) {
|
3809
|
-
if (!value)
|
4476
|
+
if (!value) {
|
4477
|
+
return false;
|
4478
|
+
}
|
3810
4479
|
if (isFieldValue(value)) {
|
3811
4480
|
return true;
|
3812
4481
|
}
|
@@ -3818,3 +4487,213 @@ function isFieldConfigDefaultValue(value) {
|
|
3818
4487
|
}
|
3819
4488
|
return false;
|
3820
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());
|