@opencrvs/toolkit 1.8.0-rc.fe799b0 → 1.8.0-rc.fea3888

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