@opencrvs/toolkit 1.8.0-rc.f7910f3 → 1.8.0-rc.f876361
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commons/api/router.d.ts +4276 -14979
- package/dist/commons/conditionals/conditionals.d.ts +16 -1
- package/dist/commons/events/ActionConfig.d.ts +1202 -6605
- package/dist/commons/events/ActionDocument.d.ts +7338 -244
- package/dist/commons/events/ActionInput.d.ts +1098 -256
- package/dist/commons/events/ActionType.d.ts +24 -16
- package/dist/commons/events/Draft.d.ts +42 -34
- package/dist/commons/events/EventConfig.d.ts +648 -2983
- package/dist/commons/events/EventConfigInput.d.ts +5 -2
- package/dist/commons/events/EventDocument.d.ts +695 -304
- package/dist/commons/events/EventIndex.d.ts +6 -3
- package/dist/commons/events/EventMetadata.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +84 -22
- package/dist/commons/events/FormConfig.d.ts +559 -322
- package/dist/commons/events/PageConfig.d.ts +359 -0
- package/dist/commons/events/defineConfig.d.ts +28 -433
- package/dist/commons/events/index.d.ts +2 -1
- package/dist/commons/events/test.utils.d.ts +53 -182
- package/dist/commons/events/utils.d.ts +73 -177
- package/dist/conditionals/index.js +103 -15
- package/dist/events/index.js +833 -651
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -30,13 +30,17 @@ 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: () => Action,
|
33
34
|
ActionBase: () => ActionBase,
|
34
35
|
ActionConditional: () => ActionConditional,
|
35
36
|
ActionConfig: () => ActionConfig,
|
36
37
|
ActionConfigBase: () => ActionConfigBase,
|
37
38
|
ActionDocument: () => ActionDocument,
|
39
|
+
ActionFormConfig: () => ActionFormConfig,
|
38
40
|
ActionInput: () => ActionInput,
|
41
|
+
ActionStatus: () => ActionStatus,
|
39
42
|
ActionType: () => ActionType,
|
43
|
+
ActionTypes: () => ActionTypes,
|
40
44
|
ActionUpdate: () => ActionUpdate,
|
41
45
|
AddressFieldUpdateValue: () => AddressFieldUpdateValue,
|
42
46
|
AddressFieldValue: () => AddressFieldValue,
|
@@ -45,6 +49,7 @@ __export(events_exports, {
|
|
45
49
|
AdvancedSearchConfig: () => AdvancedSearchConfig,
|
46
50
|
ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
|
47
51
|
ArchiveActionInput: () => ArchiveActionInput,
|
52
|
+
AsyncRejectActionDocument: () => AsyncRejectActionDocument,
|
48
53
|
BaseActionInput: () => BaseActionInput,
|
49
54
|
CertificateConfig: () => CertificateConfig,
|
50
55
|
CertificateTemplateConfig: () => CertificateTemplateConfig,
|
@@ -52,8 +57,15 @@ __export(events_exports, {
|
|
52
57
|
Clause: () => Clause,
|
53
58
|
Conditional: () => Conditional,
|
54
59
|
ConditionalType: () => ConditionalType,
|
60
|
+
ConfirmableActions: () => ConfirmableActions,
|
61
|
+
DataEntry: () => DataEntry,
|
55
62
|
DataFieldValue: () => DataFieldValue,
|
56
63
|
DateValue: () => DateValue,
|
64
|
+
DeclarationActionConfig: () => DeclarationActionConfig,
|
65
|
+
DeclarationActions: () => DeclarationActions,
|
66
|
+
DeclarationFormConfig: () => DeclarationFormConfig,
|
67
|
+
DeclarationReviewConfig: () => DeclarationReviewConfig,
|
68
|
+
DeclarationUpdateActions: () => DeclarationUpdateActions,
|
57
69
|
DeclareActionInput: () => DeclareActionInput,
|
58
70
|
DeduplicationConfig: () => DeduplicationConfig,
|
59
71
|
Draft: () => Draft,
|
@@ -77,20 +89,22 @@ __export(events_exports, {
|
|
77
89
|
FileFieldValueWithOption: () => FileFieldValueWithOption,
|
78
90
|
FileFieldWithOptionValue: () => FileFieldWithOptionValue,
|
79
91
|
FormConfig: () => FormConfig,
|
80
|
-
FormPage: () => FormPage,
|
81
92
|
FormPageConfig: () => FormPageConfig,
|
82
|
-
FormPageType: () => FormPageType,
|
83
93
|
GenericAddressUpdateValue: () => GenericAddressUpdateValue,
|
84
94
|
GenericAddressValue: () => GenericAddressValue,
|
85
95
|
GeographicalArea: () => GeographicalArea,
|
86
96
|
ImageMimeType: () => ImageMimeType,
|
87
97
|
LanguageConfig: () => LanguageConfig,
|
88
|
-
LatentActions: () => LatentActions,
|
89
98
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
90
99
|
MimeType: () => MimeType,
|
91
100
|
NotifyActionInput: () => NotifyActionInput,
|
92
101
|
NumberFieldValue: () => NumberFieldValue,
|
102
|
+
PageConfig: () => PageConfig,
|
103
|
+
PageConfigBase: () => PageConfigBase,
|
104
|
+
PageTypes: () => PageTypes,
|
93
105
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
106
|
+
ReadActionInput: () => ReadActionInput,
|
107
|
+
RegisterAction: () => RegisterAction,
|
94
108
|
RegisterActionInput: () => RegisterActionInput,
|
95
109
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
96
110
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
@@ -106,20 +120,24 @@ __export(events_exports, {
|
|
106
120
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
107
121
|
UrbanAddressValue: () => UrbanAddressValue,
|
108
122
|
ValidateActionInput: () => ValidateActionInput,
|
109
|
-
|
123
|
+
VerificationActionConfig: () => VerificationActionConfig,
|
110
124
|
VerificationPageConfig: () => VerificationPageConfig,
|
111
125
|
WorkqueueConfig: () => WorkqueueConfig,
|
112
126
|
alwaysTrue: () => alwaysTrue,
|
113
127
|
and: () => and,
|
128
|
+
annotationActions: () => annotationActions,
|
114
129
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
115
130
|
compositeFieldTypes: () => compositeFieldTypes,
|
116
131
|
createEmptyDraft: () => createEmptyDraft,
|
117
132
|
createValidationSchema: () => createValidationSchema,
|
118
133
|
deepDropNulls: () => deepDropNulls,
|
134
|
+
deepMerge: () => deepMerge,
|
135
|
+
defineActionForm: () => defineActionForm,
|
119
136
|
defineConditional: () => defineConditional,
|
120
137
|
defineConfig: () => defineConfig,
|
121
|
-
|
138
|
+
defineDeclarationForm: () => defineDeclarationForm,
|
122
139
|
defineFormPage: () => defineFormPage,
|
140
|
+
definePage: () => definePage,
|
123
141
|
errorMessages: () => errorMessages,
|
124
142
|
event: () => event,
|
125
143
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
@@ -128,13 +146,9 @@ __export(events_exports, {
|
|
128
146
|
eventStatuses: () => eventStatuses,
|
129
147
|
field: () => field,
|
130
148
|
fieldTypes: () => fieldTypes,
|
131
|
-
findActiveActionFields: () => findActiveActionFields,
|
132
|
-
findActiveActionForm: () => findActiveActionForm,
|
133
|
-
findActiveActionFormFields: () => findActiveActionFormFields,
|
134
|
-
findActiveActionFormPages: () => findActiveActionFormPages,
|
135
149
|
findActiveDrafts: () => findActiveDrafts,
|
136
|
-
|
137
|
-
|
150
|
+
findAllFields: () => findAllFields,
|
151
|
+
findRecordActionPages: () => findRecordActionPages,
|
138
152
|
generateActionDocument: () => generateActionDocument,
|
139
153
|
generateActionInput: () => generateActionInput,
|
140
154
|
generateActionMetadataInput: () => generateActionMetadataInput,
|
@@ -142,16 +156,18 @@ __export(events_exports, {
|
|
142
156
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
143
157
|
generateTransactionId: () => generateTransactionId,
|
144
158
|
generateTranslationConfig: () => generateTranslationConfig,
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
159
|
+
getAcceptedActions: () => getAcceptedActions,
|
160
|
+
getActionAnnotation: () => getActionAnnotation,
|
161
|
+
getActionAnnotationFields: () => getActionAnnotationFields,
|
162
|
+
getActionReview: () => getActionReview,
|
163
|
+
getActionReviewFields: () => getActionReviewFields,
|
164
|
+
getAllAnnotationFields: () => getAllAnnotationFields,
|
149
165
|
getCurrentEventState: () => getCurrentEventState,
|
150
166
|
getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
|
151
|
-
|
167
|
+
getDeclaration: () => getDeclaration,
|
168
|
+
getDeclarationFields: () => getDeclarationFields,
|
169
|
+
getDeclarationPages: () => getDeclarationPages,
|
152
170
|
getFieldValidationErrors: () => getFieldValidationErrors,
|
153
|
-
getFormFields: () => getFormFields,
|
154
|
-
getMetadataForAction: () => getMetadataForAction,
|
155
171
|
getVisiblePagesFormFields: () => getVisiblePagesFormFields,
|
156
172
|
isAddressFieldType: () => isAddressFieldType,
|
157
173
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
@@ -189,7 +205,6 @@ __export(events_exports, {
|
|
189
205
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
190
206
|
not: () => not,
|
191
207
|
or: () => or,
|
192
|
-
resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
|
193
208
|
stripHiddenFields: () => stripHiddenFields,
|
194
209
|
user: () => user,
|
195
210
|
validate: () => validate,
|
@@ -199,7 +214,7 @@ __export(events_exports, {
|
|
199
214
|
module.exports = __toCommonJS(events_exports);
|
200
215
|
|
201
216
|
// ../commons/src/events/ActionConfig.ts
|
202
|
-
var
|
217
|
+
var import_zod9 = require("zod");
|
203
218
|
|
204
219
|
// ../commons/src/events/Conditional.ts
|
205
220
|
var import_zod = require("zod");
|
@@ -227,7 +242,7 @@ var ActionConditional = import_zod.z.discriminatedUnion("type", [
|
|
227
242
|
EnableConditional
|
228
243
|
]);
|
229
244
|
|
230
|
-
// ../commons/src/events/
|
245
|
+
// ../commons/src/events/PageConfig.ts
|
231
246
|
var import_zod6 = require("zod");
|
232
247
|
|
233
248
|
// ../commons/src/events/FieldConfig.ts
|
@@ -579,7 +594,7 @@ var AdministrativeAreas = import_zod5.z.enum([
|
|
579
594
|
]);
|
580
595
|
var AdministrativeAreaConfiguration = import_zod5.z.object({
|
581
596
|
partOf: import_zod5.z.object({
|
582
|
-
$
|
597
|
+
$declaration: import_zod5.z.string()
|
583
598
|
}).optional().describe("Parent location"),
|
584
599
|
type: AdministrativeAreas
|
585
600
|
}).describe("Administrative area options");
|
@@ -614,11 +629,20 @@ var Address = BaseField.extend({
|
|
614
629
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
615
630
|
defaultValue: AddressFieldValue.optional()
|
616
631
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
632
|
+
var DataEntry = import_zod5.z.union([
|
633
|
+
import_zod5.z.object({
|
634
|
+
label: TranslationConfig,
|
635
|
+
value: import_zod5.z.string()
|
636
|
+
}),
|
637
|
+
import_zod5.z.object({
|
638
|
+
fieldId: import_zod5.z.string()
|
639
|
+
})
|
640
|
+
]);
|
617
641
|
var DataField = BaseField.extend({
|
618
642
|
type: import_zod5.z.literal(FieldType.DATA),
|
619
643
|
configuration: import_zod5.z.object({
|
620
644
|
subtitle: TranslationConfig.optional(),
|
621
|
-
data: import_zod5.z.array(
|
645
|
+
data: import_zod5.z.array(DataEntry)
|
622
646
|
})
|
623
647
|
}).describe("Data field for displaying read-only data");
|
624
648
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
@@ -646,21 +670,20 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
646
670
|
DataField
|
647
671
|
]);
|
648
672
|
|
649
|
-
// ../commons/src/events/
|
650
|
-
var
|
651
|
-
|
652
|
-
VERIFICATION: "VERIFICATION"
|
653
|
-
};
|
654
|
-
var FormPage = import_zod6.z.object({
|
673
|
+
// ../commons/src/events/PageConfig.ts
|
674
|
+
var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
|
675
|
+
var PageConfigBase = import_zod6.z.object({
|
655
676
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
656
|
-
type: import_zod6.z.literal(FormPageType.FORM).default(FormPageType.FORM),
|
657
677
|
title: TranslationConfig.describe("Header title of the page"),
|
658
678
|
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
659
679
|
conditional: Conditional().optional().describe(
|
660
680
|
"Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
|
661
681
|
)
|
662
682
|
});
|
663
|
-
var
|
683
|
+
var FormPageConfig = PageConfigBase.extend({
|
684
|
+
type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
|
685
|
+
});
|
686
|
+
var VerificationActionConfig = import_zod6.z.object({
|
664
687
|
verify: import_zod6.z.object({ label: TranslationConfig }),
|
665
688
|
cancel: import_zod6.z.object({
|
666
689
|
label: TranslationConfig,
|
@@ -670,136 +693,176 @@ var VerificationPageConfig = import_zod6.z.object({
|
|
670
693
|
})
|
671
694
|
})
|
672
695
|
}).describe("Actions available on the verification page");
|
673
|
-
var
|
674
|
-
type: import_zod6.z.literal(
|
675
|
-
actions:
|
676
|
-
});
|
677
|
-
var FormPageConfig = import_zod6.z.preprocess(
|
678
|
-
(pageConfig) => ({
|
679
|
-
...pageConfig,
|
680
|
-
type: pageConfig.type ?? FormPageType.FORM
|
681
|
-
// Default type to "FORM" if not provided
|
682
|
-
}),
|
683
|
-
import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
|
684
|
-
);
|
685
|
-
var FormConfig = import_zod6.z.object({
|
686
|
-
label: TranslationConfig.describe("Human readable description of the form"),
|
687
|
-
version: import_zod6.z.object({
|
688
|
-
id: import_zod6.z.string().describe(
|
689
|
-
"Form version. Semantic versioning recommended. Example: 0.0.1"
|
690
|
-
),
|
691
|
-
label: TranslationConfig.describe(
|
692
|
-
"Human readable description of the version"
|
693
|
-
)
|
694
|
-
}),
|
695
|
-
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
696
|
-
pages: import_zod6.z.array(FormPageConfig),
|
697
|
-
review: import_zod6.z.object({
|
698
|
-
title: TranslationConfig.describe(
|
699
|
-
"Title of the form to show in review page"
|
700
|
-
),
|
701
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
|
702
|
-
})
|
696
|
+
var VerificationPageConfig = FormPageConfig.extend({
|
697
|
+
type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
|
698
|
+
actions: VerificationActionConfig
|
703
699
|
});
|
700
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
701
|
+
FormPageConfig,
|
702
|
+
VerificationPageConfig
|
703
|
+
]);
|
704
704
|
|
705
705
|
// ../commons/src/events/ActionType.ts
|
706
|
+
var import_zod7 = require("zod");
|
706
707
|
var ActionType = {
|
708
|
+
// Pre-declaration actions
|
709
|
+
DELETE: "DELETE",
|
707
710
|
CREATE: "CREATE",
|
708
|
-
ASSIGN: "ASSIGN",
|
709
|
-
UNASSIGN: "UNASSIGN",
|
710
|
-
REGISTER: "REGISTER",
|
711
|
-
VALIDATE: "VALIDATE",
|
712
|
-
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
713
|
-
REJECT_CORRECTION: "REJECT_CORRECTION",
|
714
|
-
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
715
|
-
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
716
711
|
NOTIFY: "NOTIFY",
|
712
|
+
// Declaration actions
|
717
713
|
DECLARE: "DECLARE",
|
718
|
-
|
719
|
-
|
720
|
-
|
714
|
+
VALIDATE: "VALIDATE",
|
715
|
+
REGISTER: "REGISTER",
|
716
|
+
// Declaration system actions. Non-configurable.
|
717
|
+
DETECT_DUPLICATE: "DETECT_DUPLICATE",
|
721
718
|
REJECT: "REJECT",
|
719
|
+
// REJECT_DECLARATION
|
722
720
|
MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
|
723
|
-
|
721
|
+
// MARK_AS_DUPLICATE
|
722
|
+
ARCHIVE: "ARCHIVE",
|
723
|
+
// Record actions
|
724
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
725
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
726
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
727
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
728
|
+
// General actions
|
729
|
+
READ: "READ",
|
730
|
+
ASSIGN: "ASSIGN",
|
731
|
+
UNASSIGN: "UNASSIGN"
|
724
732
|
};
|
725
|
-
var
|
733
|
+
var ConfirmableActions = [
|
734
|
+
ActionType.NOTIFY,
|
735
|
+
ActionType.DECLARE,
|
736
|
+
ActionType.VALIDATE,
|
737
|
+
ActionType.REGISTER,
|
738
|
+
ActionType.REJECT,
|
739
|
+
ActionType.ARCHIVE,
|
740
|
+
ActionType.PRINT_CERTIFICATE
|
741
|
+
];
|
742
|
+
var ActionTypes = import_zod7.z.enum([
|
743
|
+
"DELETE",
|
744
|
+
"CREATE",
|
745
|
+
"NOTIFY",
|
746
|
+
"DECLARE",
|
747
|
+
"VALIDATE",
|
748
|
+
"REGISTER",
|
749
|
+
"DETECT_DUPLICATE",
|
750
|
+
"REJECT",
|
751
|
+
"MARKED_AS_DUPLICATE",
|
752
|
+
"ARCHIVE",
|
753
|
+
"PRINT_CERTIFICATE",
|
754
|
+
"REQUEST_CORRECTION",
|
755
|
+
"REJECT_CORRECTION",
|
756
|
+
"APPROVE_CORRECTION",
|
757
|
+
"READ",
|
758
|
+
"ASSIGN",
|
759
|
+
"UNASSIGN"
|
760
|
+
]);
|
761
|
+
var declarationActionValues = [
|
762
|
+
ActionTypes.enum.DECLARE,
|
763
|
+
ActionTypes.enum.VALIDATE,
|
764
|
+
ActionTypes.enum.REGISTER
|
765
|
+
];
|
766
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
767
|
+
var declarationUpdateActionValues = [
|
768
|
+
...declarationActionValues,
|
769
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
770
|
+
];
|
771
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
772
|
+
declarationUpdateActionValues
|
773
|
+
);
|
774
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
775
|
+
|
776
|
+
// ../commons/src/events/FormConfig.ts
|
777
|
+
var import_zod8 = require("zod");
|
778
|
+
var DeclarationFormConfig = import_zod8.z.object({
|
779
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
780
|
+
pages: import_zod8.z.array(FormPageConfig)
|
781
|
+
}).describe("Configuration for a declaration form");
|
782
|
+
var ActionFormConfig = import_zod8.z.object({
|
783
|
+
label: TranslationConfig.describe("Human readable description of the form"),
|
784
|
+
pages: import_zod8.z.array(PageConfig)
|
785
|
+
});
|
786
|
+
var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
|
726
787
|
|
727
788
|
// ../commons/src/events/ActionConfig.ts
|
728
|
-
var ActionConditional2 =
|
789
|
+
var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
|
729
790
|
/** If conditional is defined, the action is shown to the user only if the condition is met */
|
730
791
|
ShowConditional,
|
731
792
|
/** If conditional is defined, the action is enabled only if the condition is met */
|
732
793
|
EnableConditional
|
733
794
|
]);
|
734
|
-
var
|
795
|
+
var DeclarationReviewConfig = import_zod9.z.object({
|
796
|
+
title: TranslationConfig.describe("Title of the review page"),
|
797
|
+
fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
|
798
|
+
}).describe("Configuration for **declaration** review page.");
|
799
|
+
var ActionConfigBase = import_zod9.z.object({
|
735
800
|
label: TranslationConfig,
|
736
|
-
conditionals:
|
737
|
-
draft:
|
738
|
-
forms: import_zod7.z.array(FormConfig)
|
801
|
+
conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
|
802
|
+
draft: import_zod9.z.boolean().optional()
|
739
803
|
});
|
740
804
|
var DeclareConfig = ActionConfigBase.merge(
|
741
|
-
|
742
|
-
type:
|
805
|
+
import_zod9.z.object({
|
806
|
+
type: import_zod9.z.literal(ActionType.DECLARE),
|
807
|
+
review: DeclarationReviewConfig
|
743
808
|
})
|
744
809
|
);
|
745
810
|
var ValidateConfig = ActionConfigBase.merge(
|
746
|
-
|
747
|
-
type:
|
811
|
+
import_zod9.z.object({
|
812
|
+
type: import_zod9.z.literal(ActionType.VALIDATE),
|
813
|
+
review: DeclarationReviewConfig
|
814
|
+
})
|
815
|
+
);
|
816
|
+
var RegisterConfig = ActionConfigBase.merge(
|
817
|
+
import_zod9.z.object({
|
818
|
+
type: import_zod9.z.literal(ActionType.REGISTER),
|
819
|
+
review: DeclarationReviewConfig
|
748
820
|
})
|
749
821
|
);
|
750
822
|
var RejectDeclarationConfig = ActionConfigBase.merge(
|
751
|
-
|
752
|
-
type:
|
823
|
+
import_zod9.z.object({
|
824
|
+
type: import_zod9.z.literal(ActionType.REJECT)
|
753
825
|
})
|
754
826
|
);
|
755
827
|
var MarkedAsDuplicateConfig = ActionConfigBase.merge(
|
756
|
-
|
757
|
-
type:
|
828
|
+
import_zod9.z.object({
|
829
|
+
type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
758
830
|
})
|
759
831
|
);
|
760
832
|
var ArchiveConfig = ActionConfigBase.merge(
|
761
|
-
|
762
|
-
type:
|
763
|
-
})
|
764
|
-
);
|
765
|
-
var RegisterConfig = ActionConfigBase.merge(
|
766
|
-
import_zod7.z.object({
|
767
|
-
type: import_zod7.z.literal(ActionType.REGISTER)
|
833
|
+
import_zod9.z.object({
|
834
|
+
type: import_zod9.z.literal(ActionType.ARCHIVE)
|
768
835
|
})
|
769
836
|
);
|
770
837
|
var DeleteConfig = ActionConfigBase.merge(
|
771
|
-
|
772
|
-
type:
|
838
|
+
import_zod9.z.object({
|
839
|
+
type: import_zod9.z.literal(ActionType.DELETE)
|
773
840
|
})
|
774
841
|
);
|
775
842
|
var PrintCertificateActionConfig = ActionConfigBase.merge(
|
776
|
-
|
777
|
-
type:
|
843
|
+
import_zod9.z.object({
|
844
|
+
type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
|
845
|
+
printForm: ActionFormConfig
|
778
846
|
})
|
779
847
|
);
|
780
848
|
var RequestCorrectionConfig = ActionConfigBase.merge(
|
781
|
-
|
782
|
-
type:
|
783
|
-
onboardingForm:
|
784
|
-
additionalDetailsForm:
|
849
|
+
import_zod9.z.object({
|
850
|
+
type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
|
851
|
+
onboardingForm: import_zod9.z.array(PageConfig),
|
852
|
+
additionalDetailsForm: import_zod9.z.array(PageConfig)
|
785
853
|
})
|
786
854
|
);
|
787
855
|
var RejectCorrectionConfig = ActionConfigBase.merge(
|
788
|
-
|
789
|
-
type:
|
856
|
+
import_zod9.z.object({
|
857
|
+
type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
|
790
858
|
})
|
791
859
|
);
|
792
860
|
var ApproveCorrectionConfig = ActionConfigBase.merge(
|
793
|
-
|
794
|
-
type:
|
795
|
-
})
|
796
|
-
);
|
797
|
-
var CustomConfig = ActionConfigBase.merge(
|
798
|
-
import_zod7.z.object({
|
799
|
-
type: import_zod7.z.literal(ActionType.CUSTOM)
|
861
|
+
import_zod9.z.object({
|
862
|
+
type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
|
800
863
|
})
|
801
864
|
);
|
802
|
-
var ActionConfig =
|
865
|
+
var ActionConfig = import_zod9.z.discriminatedUnion("type", [
|
803
866
|
DeclareConfig,
|
804
867
|
ValidateConfig,
|
805
868
|
RejectDeclarationConfig,
|
@@ -810,102 +873,106 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
|
|
810
873
|
PrintCertificateActionConfig,
|
811
874
|
RequestCorrectionConfig,
|
812
875
|
RejectCorrectionConfig,
|
813
|
-
ApproveCorrectionConfig
|
814
|
-
|
876
|
+
ApproveCorrectionConfig
|
877
|
+
]);
|
878
|
+
var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
|
879
|
+
DeclareConfig,
|
880
|
+
ValidateConfig,
|
881
|
+
RegisterConfig
|
815
882
|
]);
|
816
883
|
|
817
884
|
// ../commons/src/events/offline/CertificateConfig.ts
|
818
|
-
var
|
819
|
-
var FontFamily =
|
820
|
-
normal:
|
821
|
-
bold:
|
822
|
-
italics:
|
823
|
-
bolditalics:
|
885
|
+
var import_zod10 = require("zod");
|
886
|
+
var FontFamily = import_zod10.z.object({
|
887
|
+
normal: import_zod10.z.string(),
|
888
|
+
bold: import_zod10.z.string(),
|
889
|
+
italics: import_zod10.z.string(),
|
890
|
+
bolditalics: import_zod10.z.string()
|
824
891
|
});
|
825
|
-
var CertificateConfig =
|
826
|
-
id:
|
827
|
-
event:
|
892
|
+
var CertificateConfig = import_zod10.z.object({
|
893
|
+
id: import_zod10.z.string(),
|
894
|
+
event: import_zod10.z.string(),
|
828
895
|
label: TranslationConfig,
|
829
|
-
isDefault:
|
830
|
-
fee:
|
831
|
-
onTime:
|
832
|
-
late:
|
833
|
-
delayed:
|
896
|
+
isDefault: import_zod10.z.boolean(),
|
897
|
+
fee: import_zod10.z.object({
|
898
|
+
onTime: import_zod10.z.number(),
|
899
|
+
late: import_zod10.z.number(),
|
900
|
+
delayed: import_zod10.z.number()
|
834
901
|
}),
|
835
|
-
svgUrl:
|
836
|
-
fonts:
|
902
|
+
svgUrl: import_zod10.z.string(),
|
903
|
+
fonts: import_zod10.z.record(FontFamily).optional()
|
837
904
|
});
|
838
905
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
839
|
-
hash:
|
840
|
-
svg:
|
906
|
+
hash: import_zod10.z.string().optional(),
|
907
|
+
svg: import_zod10.z.string()
|
841
908
|
});
|
842
909
|
|
843
910
|
// ../commons/src/events/offline/LanguageConfig.ts
|
844
|
-
var
|
845
|
-
var LanguageConfig =
|
846
|
-
lang:
|
911
|
+
var import_zod11 = require("zod");
|
912
|
+
var LanguageConfig = import_zod11.z.object({
|
913
|
+
lang: import_zod11.z.string(),
|
847
914
|
/**
|
848
915
|
* client.csv contents
|
849
916
|
*/
|
850
|
-
messages:
|
917
|
+
messages: import_zod11.z.record(import_zod11.z.string())
|
851
918
|
});
|
852
919
|
|
853
920
|
// ../commons/src/events/EventConfig.ts
|
854
|
-
var
|
921
|
+
var import_zod20 = require("zod");
|
855
922
|
|
856
923
|
// ../commons/src/events/DeduplicationConfig.ts
|
857
|
-
var
|
858
|
-
var FieldReference =
|
859
|
-
var Matcher =
|
860
|
-
fieldId:
|
861
|
-
options:
|
862
|
-
boost:
|
924
|
+
var import_zod12 = require("zod");
|
925
|
+
var FieldReference = import_zod12.z.string();
|
926
|
+
var Matcher = import_zod12.z.object({
|
927
|
+
fieldId: import_zod12.z.string(),
|
928
|
+
options: import_zod12.z.object({
|
929
|
+
boost: import_zod12.z.number().optional()
|
863
930
|
}).optional().default({})
|
864
931
|
});
|
865
932
|
var FuzzyMatcher = Matcher.extend({
|
866
|
-
type:
|
867
|
-
options:
|
933
|
+
type: import_zod12.z.literal("fuzzy"),
|
934
|
+
options: import_zod12.z.object({
|
868
935
|
/**
|
869
936
|
* Names of length 3 or less characters = 0 edits allowed
|
870
937
|
* Names of length 4 - 6 characters = 1 edit allowed
|
871
938
|
* Names of length >7 characters = 2 edits allowed
|
872
939
|
*/
|
873
|
-
fuzziness:
|
874
|
-
boost:
|
940
|
+
fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
|
941
|
+
boost: import_zod12.z.number().optional().default(1)
|
875
942
|
}).optional().default({})
|
876
943
|
});
|
877
944
|
var StrictMatcher = Matcher.extend({
|
878
|
-
type:
|
879
|
-
options:
|
880
|
-
boost:
|
945
|
+
type: import_zod12.z.literal("strict"),
|
946
|
+
options: import_zod12.z.object({
|
947
|
+
boost: import_zod12.z.number().optional().default(1)
|
881
948
|
}).optional().default({})
|
882
949
|
});
|
883
950
|
var DateRangeMatcher = Matcher.extend({
|
884
|
-
type:
|
885
|
-
options:
|
886
|
-
days:
|
951
|
+
type: import_zod12.z.literal("dateRange"),
|
952
|
+
options: import_zod12.z.object({
|
953
|
+
days: import_zod12.z.number(),
|
887
954
|
origin: FieldReference,
|
888
|
-
boost:
|
955
|
+
boost: import_zod12.z.number().optional().default(1)
|
889
956
|
})
|
890
957
|
});
|
891
958
|
var DateDistanceMatcher = Matcher.extend({
|
892
|
-
type:
|
893
|
-
options:
|
894
|
-
days:
|
959
|
+
type: import_zod12.z.literal("dateDistance"),
|
960
|
+
options: import_zod12.z.object({
|
961
|
+
days: import_zod12.z.number(),
|
895
962
|
origin: FieldReference,
|
896
|
-
boost:
|
963
|
+
boost: import_zod12.z.number().optional().default(1)
|
897
964
|
})
|
898
965
|
});
|
899
|
-
var And =
|
900
|
-
type:
|
901
|
-
clauses:
|
966
|
+
var And = import_zod12.z.object({
|
967
|
+
type: import_zod12.z.literal("and"),
|
968
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
902
969
|
});
|
903
|
-
var Or =
|
904
|
-
type:
|
905
|
-
clauses:
|
970
|
+
var Or = import_zod12.z.object({
|
971
|
+
type: import_zod12.z.literal("or"),
|
972
|
+
clauses: import_zod12.z.lazy(() => Clause.array())
|
906
973
|
});
|
907
|
-
var Clause =
|
908
|
-
() =>
|
974
|
+
var Clause = import_zod12.z.lazy(
|
975
|
+
() => import_zod12.z.discriminatedUnion("type", [
|
909
976
|
And,
|
910
977
|
Or,
|
911
978
|
FuzzyMatcher,
|
@@ -914,37 +981,37 @@ var Clause = import_zod10.z.lazy(
|
|
914
981
|
DateDistanceMatcher
|
915
982
|
])
|
916
983
|
);
|
917
|
-
var DeduplicationConfig =
|
918
|
-
id:
|
984
|
+
var DeduplicationConfig = import_zod12.z.object({
|
985
|
+
id: import_zod12.z.string(),
|
919
986
|
label: TranslationConfig,
|
920
987
|
query: Clause
|
921
988
|
});
|
922
989
|
|
923
990
|
// ../commons/src/events/SummaryConfig.ts
|
924
|
-
var
|
925
|
-
var Field =
|
926
|
-
id:
|
991
|
+
var import_zod13 = require("zod");
|
992
|
+
var Field = import_zod13.z.object({
|
993
|
+
id: import_zod13.z.string().describe("Id of summary field"),
|
927
994
|
value: TranslationConfig.describe(
|
928
995
|
"Summary field value. Can utilise values defined in configuration and EventMetadata"
|
929
996
|
),
|
930
997
|
label: TranslationConfig,
|
931
998
|
emptyValueMessage: TranslationConfig.optional()
|
932
999
|
});
|
933
|
-
var Title =
|
934
|
-
id:
|
1000
|
+
var Title = import_zod13.z.object({
|
1001
|
+
id: import_zod13.z.string(),
|
935
1002
|
label: TranslationConfig.describe("Title content"),
|
936
1003
|
emptyValueMessage: TranslationConfig.optional()
|
937
1004
|
});
|
938
|
-
var SummaryConfig =
|
1005
|
+
var SummaryConfig = import_zod13.z.object({
|
939
1006
|
title: Title.describe("Title of summary view."),
|
940
|
-
fields:
|
1007
|
+
fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
|
941
1008
|
}).describe("Configuration for summary in event.");
|
942
1009
|
|
943
1010
|
// ../commons/src/events/WorkqueueConfig.ts
|
944
|
-
var
|
1011
|
+
var import_zod15 = require("zod");
|
945
1012
|
|
946
1013
|
// ../commons/src/events/EventMetadata.ts
|
947
|
-
var
|
1014
|
+
var import_zod14 = require("zod");
|
948
1015
|
var EventStatus = {
|
949
1016
|
CREATED: "CREATED",
|
950
1017
|
NOTIFIED: "NOTIFIED",
|
@@ -956,18 +1023,19 @@ var EventStatus = {
|
|
956
1023
|
ARCHIVED: "ARCHIVED"
|
957
1024
|
};
|
958
1025
|
var eventStatuses = Object.values(EventStatus);
|
959
|
-
var EventStatuses =
|
960
|
-
var EventMetadata =
|
961
|
-
id:
|
962
|
-
type:
|
1026
|
+
var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
|
1027
|
+
var EventMetadata = import_zod14.z.object({
|
1028
|
+
id: import_zod14.z.string(),
|
1029
|
+
type: import_zod14.z.string(),
|
963
1030
|
status: EventStatuses,
|
964
|
-
createdAt:
|
965
|
-
createdBy:
|
966
|
-
createdAtLocation:
|
967
|
-
modifiedAt:
|
968
|
-
assignedTo:
|
969
|
-
updatedBy:
|
970
|
-
trackingId:
|
1031
|
+
createdAt: import_zod14.z.string().datetime(),
|
1032
|
+
createdBy: import_zod14.z.string(),
|
1033
|
+
createdAtLocation: import_zod14.z.string(),
|
1034
|
+
modifiedAt: import_zod14.z.string().datetime(),
|
1035
|
+
assignedTo: import_zod14.z.string().nullish(),
|
1036
|
+
updatedBy: import_zod14.z.string(),
|
1037
|
+
trackingId: import_zod14.z.string(),
|
1038
|
+
registrationNumber: import_zod14.z.string().nullish()
|
971
1039
|
});
|
972
1040
|
var eventMetadataLabelMap = {
|
973
1041
|
"event.assignedTo": {
|
@@ -1019,28 +1087,33 @@ var eventMetadataLabelMap = {
|
|
1019
1087
|
id: "event.trackingId.label",
|
1020
1088
|
defaultMessage: "Tracking ID",
|
1021
1089
|
description: "Tracking ID"
|
1090
|
+
},
|
1091
|
+
"event.registrationNumber": {
|
1092
|
+
id: "event.registrationNumber.label",
|
1093
|
+
defaultMessage: "Registration Number",
|
1094
|
+
description: "Registration Number"
|
1022
1095
|
}
|
1023
1096
|
};
|
1024
1097
|
|
1025
1098
|
// ../commons/src/events/WorkqueueConfig.ts
|
1026
|
-
var WorkqueueConfig =
|
1027
|
-
id:
|
1028
|
-
filters:
|
1029
|
-
|
1030
|
-
status:
|
1099
|
+
var WorkqueueConfig = import_zod15.z.object({
|
1100
|
+
id: import_zod15.z.string().describe("Unique identifier for workqueue."),
|
1101
|
+
filters: import_zod15.z.array(
|
1102
|
+
import_zod15.z.object({
|
1103
|
+
status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
|
1031
1104
|
})
|
1032
1105
|
).describe("Filters to be applied to workqueue.")
|
1033
1106
|
}).describe("Configuration for workqueue.");
|
1034
1107
|
|
1035
1108
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1036
|
-
var
|
1037
|
-
var AdvancedSearchConfig =
|
1109
|
+
var import_zod16 = require("zod");
|
1110
|
+
var AdvancedSearchConfig = import_zod16.z.object({
|
1038
1111
|
title: TranslationConfig.describe("Advanced search tab title"),
|
1039
|
-
fields:
|
1040
|
-
|
1041
|
-
fieldId:
|
1042
|
-
config:
|
1043
|
-
type:
|
1112
|
+
fields: import_zod16.z.array(
|
1113
|
+
import_zod16.z.object({
|
1114
|
+
fieldId: import_zod16.z.string(),
|
1115
|
+
config: import_zod16.z.object({
|
1116
|
+
type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
|
1044
1117
|
}).optional().describe("Configuration options for the field")
|
1045
1118
|
})
|
1046
1119
|
).optional().default([]).describe("Advanced search fields.")
|
@@ -1050,12 +1123,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
|
|
1050
1123
|
var import_lodash = require("lodash");
|
1051
1124
|
|
1052
1125
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1053
|
-
var
|
1126
|
+
var import_zod18 = require("zod");
|
1054
1127
|
|
1055
1128
|
// ../commons/src/workqueues/defaultColumns.ts
|
1056
|
-
var
|
1057
|
-
var WorkQueueColumnConfig =
|
1058
|
-
id:
|
1129
|
+
var import_zod17 = require("zod");
|
1130
|
+
var WorkQueueColumnConfig = import_zod17.z.object({
|
1131
|
+
id: import_zod17.z.string(),
|
1059
1132
|
label: TranslationConfig
|
1060
1133
|
});
|
1061
1134
|
var defaultColumns = {
|
@@ -1092,16 +1165,16 @@ var defaultColumns = {
|
|
1092
1165
|
}
|
1093
1166
|
}
|
1094
1167
|
};
|
1095
|
-
var DefaultColumnKeys =
|
1168
|
+
var DefaultColumnKeys = import_zod17.z.enum(
|
1096
1169
|
Object.keys(defaultColumns)
|
1097
1170
|
);
|
1098
1171
|
|
1099
1172
|
// ../commons/src/workqueues/WorkqueueConfig.ts
|
1100
|
-
var rootWorkqueueConfig =
|
1101
|
-
id:
|
1173
|
+
var rootWorkqueueConfig = import_zod18.z.object({
|
1174
|
+
id: import_zod18.z.string(),
|
1102
1175
|
title: TranslationConfig,
|
1103
|
-
columns:
|
1104
|
-
defaultColumns:
|
1176
|
+
columns: import_zod18.z.array(WorkQueueColumnConfig),
|
1177
|
+
defaultColumns: import_zod18.z.array(DefaultColumnKeys)
|
1105
1178
|
});
|
1106
1179
|
var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
|
1107
1180
|
|
@@ -1181,7 +1254,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
1181
1254
|
var import_date_fns = require("date-fns");
|
1182
1255
|
|
1183
1256
|
// ../commons/src/events/FieldTypeMapping.ts
|
1184
|
-
var
|
1257
|
+
var import_zod19 = require("zod");
|
1185
1258
|
function mapFieldTypeToZod(type, required) {
|
1186
1259
|
let schema;
|
1187
1260
|
switch (type) {
|
@@ -1234,7 +1307,7 @@ function createValidationSchema(config) {
|
|
1234
1307
|
for (const field2 of config) {
|
1235
1308
|
shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
|
1236
1309
|
}
|
1237
|
-
return
|
1310
|
+
return import_zod19.z.object(shape);
|
1238
1311
|
}
|
1239
1312
|
function mapFieldTypeToMockValue(field2, i) {
|
1240
1313
|
switch (field2.type) {
|
@@ -1401,7 +1474,8 @@ var isDataFieldType = (field2) => {
|
|
1401
1474
|
|
1402
1475
|
// ../commons/src/conditionals/validate.ts
|
1403
1476
|
var ajv = new import_ajv.default({
|
1404
|
-
$data: true
|
1477
|
+
$data: true,
|
1478
|
+
allowUnionTypes: true
|
1405
1479
|
});
|
1406
1480
|
(0, import_ajv_formats.default)(ajv);
|
1407
1481
|
function validate(schema, data) {
|
@@ -1562,14 +1636,6 @@ function validateFieldInput({
|
|
1562
1636
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1563
1637
|
}
|
1564
1638
|
|
1565
|
-
// ../commons/src/utils.ts
|
1566
|
-
function getOrThrow(x, message) {
|
1567
|
-
if (x === void 0 || x === null) {
|
1568
|
-
throw new Error(message);
|
1569
|
-
}
|
1570
|
-
return x;
|
1571
|
-
}
|
1572
|
-
|
1573
1639
|
// ../commons/src/uuid.ts
|
1574
1640
|
var import_uuid = require("uuid");
|
1575
1641
|
function getUUID() {
|
@@ -1578,66 +1644,73 @@ function getUUID() {
|
|
1578
1644
|
|
1579
1645
|
// ../commons/src/events/utils.ts
|
1580
1646
|
var import_date_fns2 = require("date-fns");
|
1581
|
-
|
1582
|
-
|
1647
|
+
|
1648
|
+
// ../commons/src/utils.ts
|
1649
|
+
function getOrThrow(x, message) {
|
1650
|
+
if (x === void 0 || x === null) {
|
1651
|
+
throw new Error(message);
|
1652
|
+
}
|
1653
|
+
return x;
|
1583
1654
|
}
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
)
|
1592
|
-
)
|
1593
|
-
);
|
1655
|
+
|
1656
|
+
// ../commons/src/events/utils.ts
|
1657
|
+
var findAllFields = (config) => {
|
1658
|
+
return (0, import_lodash.flattenDeep)([
|
1659
|
+
...getDeclarationFields(config),
|
1660
|
+
...getAllAnnotationFields(config)
|
1661
|
+
]);
|
1594
1662
|
};
|
1595
|
-
var
|
1596
|
-
return (0, import_lodash.flattenDeep)(
|
1597
|
-
config.actions.map((action) => {
|
1598
|
-
if (action.type === ActionType.REQUEST_CORRECTION) {
|
1599
|
-
return [
|
1600
|
-
...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
|
1601
|
-
...action.onboardingForm.flatMap(({ fields }) => fields),
|
1602
|
-
...action.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1603
|
-
];
|
1604
|
-
}
|
1605
|
-
return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
|
1606
|
-
})
|
1607
|
-
);
|
1663
|
+
var getAllAnnotationFields = (config) => {
|
1664
|
+
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
1608
1665
|
};
|
1609
|
-
var
|
1610
|
-
|
1611
|
-
|
1612
|
-
}) =>
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
|
1624
|
-
if (!pageLabel) {
|
1625
|
-
throw new Error(`Referenced field ${field2.id} does not have a label`);
|
1626
|
-
}
|
1627
|
-
return {
|
1628
|
-
...field2,
|
1629
|
-
label: pageLabel.label
|
1630
|
-
};
|
1631
|
-
});
|
1666
|
+
var getActionAnnotationFields = (actionConfig) => {
|
1667
|
+
if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
|
1668
|
+
return [
|
1669
|
+
...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
|
1670
|
+
...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
|
1671
|
+
];
|
1672
|
+
}
|
1673
|
+
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
1674
|
+
return actionConfig?.printForm.pages.flatMap(({ fields }) => fields) ?? [];
|
1675
|
+
}
|
1676
|
+
if (isDeclarationActionConfig(actionConfig)) {
|
1677
|
+
return actionConfig?.review.fields ?? [];
|
1678
|
+
}
|
1679
|
+
return [];
|
1632
1680
|
};
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
...
|
1637
|
-
|
1681
|
+
var findRecordActionPages = (config, actionType) => {
|
1682
|
+
const action = config.actions.find((a) => a.type === actionType);
|
1683
|
+
if (action?.type === ActionType.REQUEST_CORRECTION) {
|
1684
|
+
return [...action.onboardingForm, ...action.additionalDetailsForm];
|
1685
|
+
}
|
1686
|
+
if (action?.type === ActionType.PRINT_CERTIFICATE) {
|
1687
|
+
return action.printForm.pages;
|
1688
|
+
}
|
1689
|
+
return [];
|
1690
|
+
};
|
1691
|
+
function isDeclarationActionConfig(action) {
|
1692
|
+
return DeclarationActions.safeParse(action.type).success;
|
1693
|
+
}
|
1694
|
+
function getDeclarationFields(configuration) {
|
1695
|
+
return configuration.declaration.pages.flatMap(({ fields }) => fields);
|
1638
1696
|
}
|
1639
|
-
function
|
1640
|
-
return configuration.
|
1697
|
+
function getDeclarationPages(configuration) {
|
1698
|
+
return configuration.declaration.pages;
|
1699
|
+
}
|
1700
|
+
function getDeclaration(configuration) {
|
1701
|
+
return configuration.declaration;
|
1702
|
+
}
|
1703
|
+
function getActionReviewFields(configuration, actionType) {
|
1704
|
+
return getActionReview(configuration, actionType).fields;
|
1705
|
+
}
|
1706
|
+
function getActionReview(configuration, actionType) {
|
1707
|
+
const [actionConfig] = configuration.actions.filter(
|
1708
|
+
(a) => a.type === actionType
|
1709
|
+
);
|
1710
|
+
return getOrThrow(
|
1711
|
+
actionConfig?.review,
|
1712
|
+
`No review config found for ${actionType}`
|
1713
|
+
);
|
1641
1714
|
}
|
1642
1715
|
function validateWorkqueueConfig(workqueueConfigs) {
|
1643
1716
|
workqueueConfigs.map((workqueue) => {
|
@@ -1651,17 +1724,6 @@ function validateWorkqueueConfig(workqueueConfigs) {
|
|
1651
1724
|
}
|
1652
1725
|
});
|
1653
1726
|
}
|
1654
|
-
var findActiveActionForm = (configuration, action) => {
|
1655
|
-
const actionConfig = configuration.actions.find((a) => a.type === action);
|
1656
|
-
const form = actionConfig?.forms.find((f) => f.active);
|
1657
|
-
return form;
|
1658
|
-
};
|
1659
|
-
var findActiveActionFormPages = (configuration, action) => {
|
1660
|
-
return findActiveActionForm(configuration, action)?.pages;
|
1661
|
-
};
|
1662
|
-
var getFormFields = (formConfig) => {
|
1663
|
-
return formConfig.pages.flatMap((p) => p.fields);
|
1664
|
-
};
|
1665
1727
|
function isPageVisible(page, formValues) {
|
1666
1728
|
if (!page.conditional) {
|
1667
1729
|
return true;
|
@@ -1674,63 +1736,26 @@ function isPageVisible(page, formValues) {
|
|
1674
1736
|
var getVisiblePagesFormFields = (formConfig, formData) => {
|
1675
1737
|
return formConfig.pages.filter((p) => isPageVisible(p, formData)).flatMap((p) => p.fields);
|
1676
1738
|
};
|
1677
|
-
var findActiveActionFormFields = (configuration, action) => {
|
1678
|
-
const form = findActiveActionForm(configuration, action);
|
1679
|
-
return form ? getFormFields(form) : void 0;
|
1680
|
-
};
|
1681
|
-
var findActiveActionFields = (configuration, action, formData) => {
|
1682
|
-
const form = findActiveActionForm(configuration, action);
|
1683
|
-
const reviewFields = form?.review.fields;
|
1684
|
-
let formFields = void 0;
|
1685
|
-
if (form) {
|
1686
|
-
formFields = formData ? getVisiblePagesFormFields(form, formData) : getFormFields(form);
|
1687
|
-
}
|
1688
|
-
const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
|
1689
|
-
return allFields;
|
1690
|
-
};
|
1691
|
-
var getActiveActionFormPages = (configuration, action) => {
|
1692
|
-
return getOrThrow(
|
1693
|
-
findActiveActionForm(configuration, action)?.pages,
|
1694
|
-
"Form configuration not found for type: " + configuration.id
|
1695
|
-
);
|
1696
|
-
};
|
1697
|
-
function getActiveActionFields(configuration, action) {
|
1698
|
-
if (LatentActions.some((latentAction) => latentAction === action)) {
|
1699
|
-
return getActiveActionFields(configuration, ActionType.DECLARE);
|
1700
|
-
}
|
1701
|
-
const fields = findActiveActionFields(configuration, action);
|
1702
|
-
if (!fields) {
|
1703
|
-
throw new Error(`No active field config found for action type ${action}`);
|
1704
|
-
}
|
1705
|
-
return fields;
|
1706
|
-
}
|
1707
|
-
function getEventConfiguration(eventConfigurations, type) {
|
1708
|
-
const config = eventConfigurations.find((config2) => config2.id === type);
|
1709
|
-
if (!config) {
|
1710
|
-
throw new Error(`Event configuration not found for type: ${type}`);
|
1711
|
-
}
|
1712
|
-
return config;
|
1713
|
-
}
|
1714
1739
|
function isOptionalUncheckedCheckbox(field2, form) {
|
1715
1740
|
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1716
1741
|
return false;
|
1717
1742
|
}
|
1718
1743
|
return !form[field2.id];
|
1719
1744
|
}
|
1720
|
-
function stripHiddenFields(fields,
|
1721
|
-
return (0, import_lodash.omitBy)(
|
1745
|
+
function stripHiddenFields(fields, declaration) {
|
1746
|
+
return (0, import_lodash.omitBy)(declaration, (_2, fieldId) => {
|
1722
1747
|
const field2 = fields.find((f) => f.id === fieldId);
|
1723
1748
|
if (!field2) {
|
1724
1749
|
return true;
|
1725
1750
|
}
|
1726
|
-
if (isOptionalUncheckedCheckbox(field2,
|
1751
|
+
if (isOptionalUncheckedCheckbox(field2, declaration)) {
|
1727
1752
|
return true;
|
1728
1753
|
}
|
1729
|
-
return !isFieldVisible(field2,
|
1754
|
+
return !isFieldVisible(field2, declaration);
|
1730
1755
|
});
|
1731
1756
|
}
|
1732
1757
|
function findActiveDrafts(event2, drafts) {
|
1733
|
-
const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1758
|
+
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1734
1759
|
const lastAction = actions[actions.length - 1];
|
1735
1760
|
return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
|
1736
1761
|
}
|
@@ -1742,8 +1767,8 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1742
1767
|
transactionId: getUUID(),
|
1743
1768
|
action: {
|
1744
1769
|
type: actionType,
|
1745
|
-
|
1746
|
-
|
1770
|
+
declaration: {},
|
1771
|
+
annotation: {},
|
1747
1772
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
1748
1773
|
createdBy: "@todo",
|
1749
1774
|
createdAtLocation: "@todo"
|
@@ -1751,22 +1776,41 @@ function createEmptyDraft(eventId, draftId, actionType) {
|
|
1751
1776
|
};
|
1752
1777
|
}
|
1753
1778
|
function isVerificationPage(page) {
|
1754
|
-
return page.type ===
|
1779
|
+
return page.type === PageTypes.enum.VERIFICATION;
|
1780
|
+
}
|
1781
|
+
function deepMerge(currentDocument, actionDocument) {
|
1782
|
+
return (0, import_lodash.mergeWith)(
|
1783
|
+
currentDocument,
|
1784
|
+
actionDocument,
|
1785
|
+
(previousValue, incomingValue) => {
|
1786
|
+
if (incomingValue === void 0) {
|
1787
|
+
return previousValue;
|
1788
|
+
}
|
1789
|
+
if ((0, import_lodash.isArray)(incomingValue)) {
|
1790
|
+
return incomingValue;
|
1791
|
+
}
|
1792
|
+
if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
|
1793
|
+
return void 0;
|
1794
|
+
}
|
1795
|
+
return incomingValue;
|
1796
|
+
}
|
1797
|
+
);
|
1755
1798
|
}
|
1756
1799
|
|
1757
1800
|
// ../commons/src/events/EventConfig.ts
|
1758
|
-
var EventConfig =
|
1759
|
-
id:
|
1801
|
+
var EventConfig = import_zod20.z.object({
|
1802
|
+
id: import_zod20.z.string().describe(
|
1760
1803
|
'A machine-readable identifier for the event, e.g. "birth" or "death"'
|
1761
1804
|
),
|
1762
1805
|
summary: SummaryConfig,
|
1763
1806
|
label: TranslationConfig,
|
1764
|
-
actions:
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1807
|
+
actions: import_zod20.z.array(ActionConfig),
|
1808
|
+
declaration: DeclarationFormConfig,
|
1809
|
+
workqueues: import_zod20.z.array(WorkqueueConfig),
|
1810
|
+
deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
|
1811
|
+
advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
|
1768
1812
|
}).superRefine((event2, ctx) => {
|
1769
|
-
const allFields =
|
1813
|
+
const allFields = findAllFields(event2);
|
1770
1814
|
const fieldIds = allFields.map((field2) => field2.id);
|
1771
1815
|
const advancedSearchFields = event2.advancedSearch.flatMap(
|
1772
1816
|
(section) => section.fields.flatMap((field2) => field2.fieldId)
|
@@ -1793,106 +1837,117 @@ var EventConfig = import_zod18.z.object({
|
|
1793
1837
|
});
|
1794
1838
|
|
1795
1839
|
// ../commons/src/events/EventConfigInput.ts
|
1796
|
-
var
|
1840
|
+
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
1841
|
+
var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
|
1842
|
+
var definePage = (page) => PageConfig.parse(page);
|
1797
1843
|
var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
|
1798
1844
|
|
1799
1845
|
// ../commons/src/events/Draft.ts
|
1800
|
-
var
|
1846
|
+
var import_zod23 = require("zod");
|
1801
1847
|
|
1802
1848
|
// ../commons/src/events/ActionDocument.ts
|
1803
|
-
var
|
1804
|
-
var ActionUpdate =
|
1805
|
-
var
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1849
|
+
var import_zod21 = require("zod");
|
1850
|
+
var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
|
1851
|
+
var ActionStatus = {
|
1852
|
+
Requested: "Requested",
|
1853
|
+
Accepted: "Accepted",
|
1854
|
+
Rejected: "Rejected"
|
1855
|
+
};
|
1856
|
+
var ActionBase = import_zod21.z.object({
|
1857
|
+
id: import_zod21.z.string(),
|
1858
|
+
createdAt: import_zod21.z.string().datetime(),
|
1859
|
+
createdBy: import_zod21.z.string(),
|
1860
|
+
declaration: ActionUpdate,
|
1861
|
+
annotation: ActionUpdate.optional(),
|
1862
|
+
createdAtLocation: import_zod21.z.string(),
|
1863
|
+
status: import_zod21.z.enum([
|
1864
|
+
ActionStatus.Requested,
|
1865
|
+
ActionStatus.Accepted,
|
1866
|
+
ActionStatus.Rejected
|
1867
|
+
]),
|
1868
|
+
// If the action is an asynchronous confirmation for another action, we will save the original action id here.
|
1869
|
+
originalActionId: import_zod21.z.string().optional()
|
1812
1870
|
});
|
1813
1871
|
var AssignedAction = ActionBase.merge(
|
1814
|
-
|
1815
|
-
type:
|
1816
|
-
assignedTo:
|
1872
|
+
import_zod21.z.object({
|
1873
|
+
type: import_zod21.z.literal(ActionType.ASSIGN),
|
1874
|
+
assignedTo: import_zod21.z.string()
|
1817
1875
|
})
|
1818
1876
|
);
|
1819
1877
|
var UnassignedAction = ActionBase.merge(
|
1820
|
-
|
1821
|
-
type:
|
1878
|
+
import_zod21.z.object({
|
1879
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN)
|
1822
1880
|
})
|
1823
1881
|
);
|
1824
1882
|
var RegisterAction = ActionBase.merge(
|
1825
|
-
|
1826
|
-
type:
|
1827
|
-
|
1828
|
-
trackingId: import_zod19.z.string(),
|
1829
|
-
registrationNumber: import_zod19.z.string()
|
1830
|
-
})
|
1883
|
+
import_zod21.z.object({
|
1884
|
+
type: import_zod21.z.literal(ActionType.REGISTER),
|
1885
|
+
registrationNumber: import_zod21.z.string().optional()
|
1831
1886
|
})
|
1832
1887
|
);
|
1833
1888
|
var DeclareAction = ActionBase.merge(
|
1834
|
-
|
1835
|
-
type:
|
1889
|
+
import_zod21.z.object({
|
1890
|
+
type: import_zod21.z.literal(ActionType.DECLARE)
|
1836
1891
|
})
|
1837
1892
|
);
|
1838
1893
|
var ValidateAction = ActionBase.merge(
|
1839
|
-
|
1840
|
-
type:
|
1894
|
+
import_zod21.z.object({
|
1895
|
+
type: import_zod21.z.literal(ActionType.VALIDATE)
|
1841
1896
|
})
|
1842
1897
|
);
|
1843
1898
|
var RejectAction = ActionBase.merge(
|
1844
|
-
|
1845
|
-
type:
|
1899
|
+
import_zod21.z.object({
|
1900
|
+
type: import_zod21.z.literal(ActionType.REJECT)
|
1846
1901
|
})
|
1847
1902
|
);
|
1848
1903
|
var MarkAsDuplicateAction = ActionBase.merge(
|
1849
|
-
|
1850
|
-
type:
|
1904
|
+
import_zod21.z.object({
|
1905
|
+
type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
|
1851
1906
|
})
|
1852
1907
|
);
|
1853
1908
|
var ArchiveAction = ActionBase.merge(
|
1854
|
-
|
1855
|
-
type:
|
1909
|
+
import_zod21.z.object({
|
1910
|
+
type: import_zod21.z.literal(ActionType.ARCHIVE)
|
1856
1911
|
})
|
1857
1912
|
);
|
1858
1913
|
var CreatedAction = ActionBase.merge(
|
1859
|
-
|
1860
|
-
type:
|
1914
|
+
import_zod21.z.object({
|
1915
|
+
type: import_zod21.z.literal(ActionType.CREATE)
|
1861
1916
|
})
|
1862
1917
|
);
|
1863
1918
|
var NotifiedAction = ActionBase.merge(
|
1864
|
-
|
1865
|
-
type:
|
1919
|
+
import_zod21.z.object({
|
1920
|
+
type: import_zod21.z.literal(ActionType.NOTIFY)
|
1866
1921
|
})
|
1867
1922
|
);
|
1868
1923
|
var PrintCertificateAction = ActionBase.merge(
|
1869
|
-
|
1870
|
-
type:
|
1924
|
+
import_zod21.z.object({
|
1925
|
+
type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
|
1871
1926
|
})
|
1872
1927
|
);
|
1873
1928
|
var RequestedCorrectionAction = ActionBase.merge(
|
1874
|
-
|
1875
|
-
type:
|
1929
|
+
import_zod21.z.object({
|
1930
|
+
type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
|
1876
1931
|
})
|
1877
1932
|
);
|
1878
1933
|
var ApprovedCorrectionAction = ActionBase.merge(
|
1879
|
-
|
1880
|
-
type:
|
1881
|
-
requestId:
|
1934
|
+
import_zod21.z.object({
|
1935
|
+
type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
|
1936
|
+
requestId: import_zod21.z.string()
|
1882
1937
|
})
|
1883
1938
|
);
|
1884
1939
|
var RejectedCorrectionAction = ActionBase.merge(
|
1885
|
-
|
1886
|
-
type:
|
1887
|
-
requestId:
|
1940
|
+
import_zod21.z.object({
|
1941
|
+
type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
|
1942
|
+
requestId: import_zod21.z.string()
|
1888
1943
|
})
|
1889
1944
|
);
|
1890
|
-
var
|
1891
|
-
|
1892
|
-
type:
|
1945
|
+
var ReadAction = ActionBase.merge(
|
1946
|
+
import_zod21.z.object({
|
1947
|
+
type: import_zod21.z.literal(ActionType.READ)
|
1893
1948
|
})
|
1894
1949
|
);
|
1895
|
-
var ActionDocument =
|
1950
|
+
var ActionDocument = import_zod21.z.discriminatedUnion("type", [
|
1896
1951
|
CreatedAction,
|
1897
1952
|
ValidateAction,
|
1898
1953
|
RejectAction,
|
@@ -1907,108 +1962,123 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
|
|
1907
1962
|
RejectedCorrectionAction,
|
1908
1963
|
UnassignedAction,
|
1909
1964
|
PrintCertificateAction,
|
1910
|
-
|
1965
|
+
ReadAction
|
1911
1966
|
]);
|
1912
|
-
var
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1967
|
+
var AsyncRejectActionDocument = ActionBase.omit({
|
1968
|
+
declaration: true,
|
1969
|
+
annotation: true,
|
1970
|
+
createdBy: true,
|
1971
|
+
createdAtLocation: true
|
1972
|
+
}).merge(
|
1973
|
+
import_zod21.z.object({
|
1974
|
+
type: import_zod21.z.enum(ConfirmableActions),
|
1975
|
+
status: import_zod21.z.literal(ActionStatus.Rejected)
|
1976
|
+
})
|
1977
|
+
);
|
1978
|
+
var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
|
1979
|
+
var ResolvedUser = import_zod21.z.object({
|
1980
|
+
id: import_zod21.z.string(),
|
1981
|
+
role: import_zod21.z.string(),
|
1982
|
+
name: import_zod21.z.array(
|
1983
|
+
import_zod21.z.object({
|
1984
|
+
use: import_zod21.z.string(),
|
1985
|
+
given: import_zod21.z.array(import_zod21.z.string()),
|
1986
|
+
family: import_zod21.z.string()
|
1920
1987
|
})
|
1921
1988
|
)
|
1922
1989
|
});
|
1923
1990
|
|
1924
1991
|
// ../commons/src/events/ActionInput.ts
|
1925
|
-
var
|
1926
|
-
var BaseActionInput =
|
1927
|
-
eventId:
|
1928
|
-
transactionId:
|
1929
|
-
|
1930
|
-
|
1992
|
+
var import_zod22 = require("zod");
|
1993
|
+
var BaseActionInput = import_zod22.z.object({
|
1994
|
+
eventId: import_zod22.z.string(),
|
1995
|
+
transactionId: import_zod22.z.string(),
|
1996
|
+
declaration: ActionUpdate,
|
1997
|
+
annotation: ActionUpdate.optional(),
|
1998
|
+
originalActionId: import_zod22.z.string().optional()
|
1931
1999
|
});
|
1932
2000
|
var CreateActionInput = BaseActionInput.merge(
|
1933
|
-
|
1934
|
-
type:
|
1935
|
-
createdAtLocation:
|
2001
|
+
import_zod22.z.object({
|
2002
|
+
type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
|
2003
|
+
createdAtLocation: import_zod22.z.string()
|
1936
2004
|
})
|
1937
2005
|
);
|
1938
2006
|
var RegisterActionInput = BaseActionInput.merge(
|
1939
|
-
|
1940
|
-
type:
|
1941
|
-
|
1942
|
-
trackingId: import_zod20.z.string(),
|
1943
|
-
registrationNumber: import_zod20.z.string()
|
1944
|
-
})
|
2007
|
+
import_zod22.z.object({
|
2008
|
+
type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
|
2009
|
+
registrationNumber: import_zod22.z.string().optional()
|
1945
2010
|
})
|
1946
2011
|
);
|
1947
2012
|
var ValidateActionInput = BaseActionInput.merge(
|
1948
|
-
|
1949
|
-
type:
|
1950
|
-
duplicates:
|
2013
|
+
import_zod22.z.object({
|
2014
|
+
type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
|
2015
|
+
duplicates: import_zod22.z.array(import_zod22.z.string())
|
1951
2016
|
})
|
1952
2017
|
);
|
1953
2018
|
var NotifyActionInput = BaseActionInput.merge(
|
1954
|
-
|
1955
|
-
type:
|
2019
|
+
import_zod22.z.object({
|
2020
|
+
type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1956
2021
|
})
|
1957
2022
|
);
|
1958
2023
|
var DeclareActionInput = BaseActionInput.merge(
|
1959
|
-
|
1960
|
-
type:
|
2024
|
+
import_zod22.z.object({
|
2025
|
+
type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
1961
2026
|
})
|
1962
2027
|
);
|
1963
2028
|
var PrintCertificateActionInput = BaseActionInput.merge(
|
1964
|
-
|
1965
|
-
type:
|
2029
|
+
import_zod22.z.object({
|
2030
|
+
type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
|
1966
2031
|
})
|
1967
2032
|
);
|
1968
2033
|
var RejectDeclarationActionInput = BaseActionInput.merge(
|
1969
|
-
|
1970
|
-
type:
|
2034
|
+
import_zod22.z.object({
|
2035
|
+
type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
|
1971
2036
|
})
|
1972
2037
|
);
|
1973
2038
|
var MarkedAsDuplicateActionInput = BaseActionInput.merge(
|
1974
|
-
|
1975
|
-
type:
|
2039
|
+
import_zod22.z.object({
|
2040
|
+
type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
|
1976
2041
|
})
|
1977
2042
|
);
|
1978
2043
|
var ArchiveActionInput = BaseActionInput.merge(
|
1979
|
-
|
1980
|
-
type:
|
2044
|
+
import_zod22.z.object({
|
2045
|
+
type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
|
1981
2046
|
})
|
1982
2047
|
);
|
1983
2048
|
var AssignActionInput = BaseActionInput.merge(
|
1984
|
-
|
1985
|
-
type:
|
1986
|
-
assignedTo:
|
2049
|
+
import_zod22.z.object({
|
2050
|
+
type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
|
2051
|
+
assignedTo: import_zod22.z.string()
|
1987
2052
|
})
|
1988
2053
|
);
|
1989
2054
|
var UnassignActionInput = BaseActionInput.merge(
|
1990
|
-
|
1991
|
-
type:
|
2055
|
+
import_zod22.z.object({
|
2056
|
+
type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
|
1992
2057
|
})
|
1993
2058
|
);
|
1994
2059
|
var RequestCorrectionActionInput = BaseActionInput.merge(
|
1995
|
-
|
1996
|
-
type:
|
2060
|
+
import_zod22.z.object({
|
2061
|
+
type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
|
1997
2062
|
})
|
1998
2063
|
);
|
1999
2064
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
2000
|
-
|
2001
|
-
requestId:
|
2002
|
-
type:
|
2065
|
+
import_zod22.z.object({
|
2066
|
+
requestId: import_zod22.z.string(),
|
2067
|
+
type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
2003
2068
|
})
|
2004
2069
|
);
|
2005
2070
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
2006
|
-
|
2007
|
-
requestId:
|
2008
|
-
type:
|
2071
|
+
import_zod22.z.object({
|
2072
|
+
requestId: import_zod22.z.string(),
|
2073
|
+
type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
2074
|
+
})
|
2075
|
+
);
|
2076
|
+
var ReadActionInput = BaseActionInput.merge(
|
2077
|
+
import_zod22.z.object({
|
2078
|
+
type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
|
2009
2079
|
})
|
2010
2080
|
);
|
2011
|
-
var ActionInput =
|
2081
|
+
var ActionInput = import_zod22.z.discriminatedUnion("type", [
|
2012
2082
|
CreateActionInput,
|
2013
2083
|
ValidateActionInput,
|
2014
2084
|
RegisterActionInput,
|
@@ -2022,49 +2092,50 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
|
|
2022
2092
|
PrintCertificateActionInput,
|
2023
2093
|
RequestCorrectionActionInput,
|
2024
2094
|
RejectCorrectionActionInput,
|
2025
|
-
ApproveCorrectionActionInput
|
2095
|
+
ApproveCorrectionActionInput,
|
2096
|
+
ReadActionInput
|
2026
2097
|
]);
|
2027
2098
|
|
2028
2099
|
// ../commons/src/events/Draft.ts
|
2029
|
-
var Draft =
|
2030
|
-
id:
|
2031
|
-
eventId:
|
2032
|
-
transactionId:
|
2033
|
-
createdAt:
|
2100
|
+
var Draft = import_zod23.z.object({
|
2101
|
+
id: import_zod23.z.string(),
|
2102
|
+
eventId: import_zod23.z.string(),
|
2103
|
+
transactionId: import_zod23.z.string(),
|
2104
|
+
createdAt: import_zod23.z.string().datetime(),
|
2034
2105
|
action: ActionBase.extend({
|
2035
|
-
type:
|
2036
|
-
}).omit({ id: true })
|
2106
|
+
type: ActionTypes
|
2107
|
+
}).omit({ id: true, status: true })
|
2037
2108
|
});
|
2038
2109
|
var DraftInput = BaseActionInput.extend({
|
2039
|
-
type:
|
2110
|
+
type: ActionTypes
|
2040
2111
|
});
|
2041
2112
|
|
2042
2113
|
// ../commons/src/events/EventInput.ts
|
2043
|
-
var
|
2044
|
-
var EventInput =
|
2045
|
-
transactionId:
|
2046
|
-
type:
|
2114
|
+
var import_zod24 = require("zod");
|
2115
|
+
var EventInput = import_zod24.z.object({
|
2116
|
+
transactionId: import_zod24.z.string(),
|
2117
|
+
type: import_zod24.z.string()
|
2047
2118
|
});
|
2048
2119
|
|
2049
2120
|
// ../commons/src/events/EventDocument.ts
|
2050
|
-
var
|
2051
|
-
var EventDocument =
|
2052
|
-
id:
|
2053
|
-
type:
|
2054
|
-
createdAt:
|
2055
|
-
updatedAt:
|
2056
|
-
actions:
|
2057
|
-
trackingId:
|
2121
|
+
var import_zod25 = require("zod");
|
2122
|
+
var EventDocument = import_zod25.z.object({
|
2123
|
+
id: import_zod25.z.string(),
|
2124
|
+
type: import_zod25.z.string(),
|
2125
|
+
createdAt: import_zod25.z.string().datetime(),
|
2126
|
+
updatedAt: import_zod25.z.string().datetime(),
|
2127
|
+
actions: import_zod25.z.array(Action),
|
2128
|
+
trackingId: import_zod25.z.string()
|
2058
2129
|
});
|
2059
2130
|
|
2060
2131
|
// ../commons/src/events/EventIndex.ts
|
2061
|
-
var
|
2132
|
+
var import_zod26 = require("zod");
|
2062
2133
|
var EventIndex = EventMetadata.extend({
|
2063
|
-
|
2134
|
+
declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
|
2064
2135
|
});
|
2065
|
-
var EventSearchIndex =
|
2066
|
-
|
2067
|
-
type:
|
2136
|
+
var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
|
2137
|
+
import_zod26.z.object({
|
2138
|
+
type: import_zod26.z.string()
|
2068
2139
|
// Ensures "type" (event-id) exists and is a string
|
2069
2140
|
})
|
2070
2141
|
);
|
@@ -2072,6 +2143,12 @@ var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod
|
|
2072
2143
|
// ../commons/src/events/state/index.ts
|
2073
2144
|
var _ = __toESM(require("lodash"));
|
2074
2145
|
function getStatusFromActions(actions) {
|
2146
|
+
const hasRejectedAction = actions.some(
|
2147
|
+
(a) => a.status === ActionStatus.Rejected
|
2148
|
+
);
|
2149
|
+
if (hasRejectedAction) {
|
2150
|
+
return EventStatus.REJECTED;
|
2151
|
+
}
|
2075
2152
|
return actions.reduce((status, action) => {
|
2076
2153
|
if (action.type === ActionType.CREATE) {
|
2077
2154
|
return EventStatus.CREATED;
|
@@ -2108,7 +2185,7 @@ function getAssignedUserFromActions(actions) {
|
|
2108
2185
|
return user2;
|
2109
2186
|
}, null);
|
2110
2187
|
}
|
2111
|
-
function
|
2188
|
+
function aggregateActionDeclarations(actions) {
|
2112
2189
|
const excludedActions = [
|
2113
2190
|
ActionType.REQUEST_CORRECTION,
|
2114
2191
|
ActionType.PRINT_CERTIFICATE
|
@@ -2122,9 +2199,9 @@ function getData(actions) {
|
|
2122
2199
|
if (!requestAction) {
|
2123
2200
|
return status;
|
2124
2201
|
}
|
2125
|
-
return deepMerge(status, requestAction.
|
2202
|
+
return deepMerge(status, requestAction.declaration);
|
2126
2203
|
}
|
2127
|
-
return deepMerge(status, action.
|
2204
|
+
return deepMerge(status, action.declaration);
|
2128
2205
|
}, {});
|
2129
2206
|
}
|
2130
2207
|
function deepDropNulls(obj) {
|
@@ -2142,27 +2219,14 @@ function deepDropNulls(obj) {
|
|
2142
2219
|
return acc;
|
2143
2220
|
}, {});
|
2144
2221
|
}
|
2145
|
-
function deepMerge(currentDocument, actionDocument) {
|
2146
|
-
return _.mergeWith(
|
2147
|
-
currentDocument,
|
2148
|
-
actionDocument,
|
2149
|
-
(previousValue, incomingValue) => {
|
2150
|
-
if (incomingValue === void 0) {
|
2151
|
-
return previousValue;
|
2152
|
-
}
|
2153
|
-
if (_.isArray(incomingValue)) {
|
2154
|
-
return incomingValue;
|
2155
|
-
}
|
2156
|
-
if (_.isObject(previousValue) && _.isObject(incomingValue)) {
|
2157
|
-
return void 0;
|
2158
|
-
}
|
2159
|
-
return incomingValue;
|
2160
|
-
}
|
2161
|
-
);
|
2162
|
-
}
|
2163
2222
|
function isUndeclaredDraft(status) {
|
2164
2223
|
return status === EventStatus.CREATED;
|
2165
2224
|
}
|
2225
|
+
function getAcceptedActions(event2) {
|
2226
|
+
return event2.actions.filter(
|
2227
|
+
(a) => !a.status || a.status === ActionStatus.Accepted
|
2228
|
+
);
|
2229
|
+
}
|
2166
2230
|
function getCurrentEventState(event2) {
|
2167
2231
|
const creationAction = event2.actions.find(
|
2168
2232
|
(action) => action.type === ActionType.CREATE
|
@@ -2170,7 +2234,12 @@ function getCurrentEventState(event2) {
|
|
2170
2234
|
if (!creationAction) {
|
2171
2235
|
throw new Error(`Event ${event2.id} has no creation action`);
|
2172
2236
|
}
|
2173
|
-
const
|
2237
|
+
const activeActions = getAcceptedActions(event2);
|
2238
|
+
const latestAction = activeActions[activeActions.length - 1];
|
2239
|
+
const registrationAction = activeActions.find(
|
2240
|
+
(a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
|
2241
|
+
);
|
2242
|
+
const registrationNumber = registrationAction?.registrationNumber ?? null;
|
2174
2243
|
return deepDropNulls({
|
2175
2244
|
id: event2.id,
|
2176
2245
|
type: event2.type,
|
@@ -2179,10 +2248,11 @@ function getCurrentEventState(event2) {
|
|
2179
2248
|
createdBy: creationAction.createdBy,
|
2180
2249
|
createdAtLocation: creationAction.createdAtLocation,
|
2181
2250
|
modifiedAt: latestAction.createdAt,
|
2182
|
-
assignedTo: getAssignedUserFromActions(
|
2251
|
+
assignedTo: getAssignedUserFromActions(activeActions),
|
2183
2252
|
updatedBy: latestAction.createdBy,
|
2184
|
-
|
2185
|
-
trackingId: event2.trackingId
|
2253
|
+
declaration: aggregateActionDeclarations(activeActions),
|
2254
|
+
trackingId: event2.trackingId,
|
2255
|
+
registrationNumber
|
2186
2256
|
});
|
2187
2257
|
}
|
2188
2258
|
function getCurrentEventStateWithDrafts(event2, drafts) {
|
@@ -2214,38 +2284,35 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
|
|
2214
2284
|
}
|
2215
2285
|
return {
|
2216
2286
|
...eventIndex,
|
2217
|
-
|
2218
|
-
...eventIndex.
|
2219
|
-
...activeDrafts[activeDrafts.length - 1].
|
2287
|
+
declaration: {
|
2288
|
+
...eventIndex.declaration,
|
2289
|
+
...activeDrafts[activeDrafts.length - 1].declaration
|
2220
2290
|
}
|
2221
2291
|
};
|
2222
2292
|
}
|
2223
|
-
function
|
2293
|
+
function getActionAnnotation({
|
2224
2294
|
event: event2,
|
2225
2295
|
actionType,
|
2226
2296
|
drafts
|
2227
2297
|
}) {
|
2228
|
-
const
|
2298
|
+
const activeActions = getAcceptedActions(event2);
|
2299
|
+
const action = activeActions.find((action2) => actionType === action2.type);
|
2229
2300
|
const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
|
2230
2301
|
const sorted = [
|
2231
2302
|
...action ? [action] : [],
|
2232
2303
|
...eventDrafts.map((draft) => draft.action)
|
2233
2304
|
].sort();
|
2234
|
-
const
|
2235
|
-
return deepMerge(
|
2305
|
+
const annotation = sorted.reduce((annotation2, action2) => {
|
2306
|
+
return deepMerge(annotation2, action2.annotation ?? {});
|
2236
2307
|
}, {});
|
2237
|
-
return deepDropNulls(
|
2308
|
+
return deepDropNulls(annotation);
|
2238
2309
|
}
|
2239
2310
|
|
2240
2311
|
// ../commons/src/events/defineConfig.ts
|
2241
2312
|
var defineConfig = (config) => {
|
2242
2313
|
validateWorkqueueConfig(config.workqueues);
|
2243
2314
|
const input = EventConfig.parse(config);
|
2244
|
-
|
2245
|
-
return EventConfig.parse({
|
2246
|
-
...input,
|
2247
|
-
pageFields
|
2248
|
-
});
|
2315
|
+
return input;
|
2249
2316
|
};
|
2250
2317
|
|
2251
2318
|
// ../commons/src/events/transactions.ts
|
@@ -2351,6 +2418,10 @@ function field(fieldId) {
|
|
2351
2418
|
required: ["$form"]
|
2352
2419
|
});
|
2353
2420
|
return {
|
2421
|
+
/**
|
2422
|
+
* @private Internal property used for field reference tracking.
|
2423
|
+
*/
|
2424
|
+
_returning: fieldId,
|
2354
2425
|
isAfter: () => ({
|
2355
2426
|
days: (days) => ({
|
2356
2427
|
inPast: () => defineConditional(
|
@@ -2375,25 +2446,54 @@ function field(fieldId) {
|
|
2375
2446
|
date: (date) => defineConditional(getDateRange(date, "formatMaximum")),
|
2376
2447
|
now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
|
2377
2448
|
}),
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2449
|
+
// TODO CIHAN: typing
|
2450
|
+
isEqualTo: (value) => {
|
2451
|
+
if (typeof value === "object" && value._returning) {
|
2452
|
+
const comparedFieldId = value._returning;
|
2453
|
+
return defineConditional({
|
2382
2454
|
type: "object",
|
2383
2455
|
properties: {
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
{ type: "
|
2388
|
-
|
2389
|
-
|
2456
|
+
$form: {
|
2457
|
+
type: "object",
|
2458
|
+
properties: {
|
2459
|
+
[fieldId]: { type: ["string", "boolean"] },
|
2460
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
2461
|
+
},
|
2462
|
+
required: [fieldId, comparedFieldId],
|
2463
|
+
allOf: [
|
2464
|
+
{
|
2465
|
+
properties: {
|
2466
|
+
[fieldId]: {
|
2467
|
+
const: { $data: `1/${comparedFieldId}` }
|
2468
|
+
}
|
2469
|
+
}
|
2470
|
+
}
|
2471
|
+
]
|
2390
2472
|
}
|
2391
2473
|
},
|
2392
|
-
required: [
|
2393
|
-
}
|
2394
|
-
}
|
2395
|
-
|
2396
|
-
|
2474
|
+
required: ["$form"]
|
2475
|
+
});
|
2476
|
+
}
|
2477
|
+
return defineConditional({
|
2478
|
+
type: "object",
|
2479
|
+
properties: {
|
2480
|
+
$form: {
|
2481
|
+
type: "object",
|
2482
|
+
properties: {
|
2483
|
+
[fieldId]: {
|
2484
|
+
oneOf: [
|
2485
|
+
{ type: "string", const: value },
|
2486
|
+
{ type: "boolean", const: value }
|
2487
|
+
],
|
2488
|
+
const: value
|
2489
|
+
}
|
2490
|
+
},
|
2491
|
+
required: [fieldId]
|
2492
|
+
}
|
2493
|
+
},
|
2494
|
+
required: ["$form"]
|
2495
|
+
});
|
2496
|
+
},
|
2397
2497
|
/**
|
2398
2498
|
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
2399
2499
|
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
@@ -2481,29 +2581,76 @@ function field(fieldId) {
|
|
2481
2581
|
}
|
2482
2582
|
},
|
2483
2583
|
required: ["$form"]
|
2584
|
+
}),
|
2585
|
+
isValidNationalId: () => defineConditional({
|
2586
|
+
type: "object",
|
2587
|
+
properties: {
|
2588
|
+
$form: {
|
2589
|
+
type: "object",
|
2590
|
+
properties: {
|
2591
|
+
[fieldId]: {
|
2592
|
+
type: "string",
|
2593
|
+
pattern: "^[0-9]{9}$",
|
2594
|
+
description: "The National ID can only be numeric and must be 9 digits long."
|
2595
|
+
}
|
2596
|
+
},
|
2597
|
+
required: [fieldId]
|
2598
|
+
}
|
2599
|
+
},
|
2600
|
+
required: ["$form"]
|
2601
|
+
}),
|
2602
|
+
/**
|
2603
|
+
* Checks if the field value matches a given regular expression pattern.
|
2604
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
2605
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
2606
|
+
*/
|
2607
|
+
matches: (pattern) => defineConditional({
|
2608
|
+
type: "object",
|
2609
|
+
properties: {
|
2610
|
+
$form: {
|
2611
|
+
type: "object",
|
2612
|
+
properties: {
|
2613
|
+
[fieldId]: {
|
2614
|
+
type: "string",
|
2615
|
+
pattern
|
2616
|
+
}
|
2617
|
+
},
|
2618
|
+
required: [fieldId]
|
2619
|
+
}
|
2620
|
+
},
|
2621
|
+
required: ["$form"]
|
2622
|
+
}),
|
2623
|
+
isBetween: (min, max) => defineConditional({
|
2624
|
+
type: "object",
|
2625
|
+
properties: {
|
2626
|
+
$form: {
|
2627
|
+
type: "object",
|
2628
|
+
properties: {
|
2629
|
+
[fieldId]: {
|
2630
|
+
type: "number",
|
2631
|
+
minimum: min,
|
2632
|
+
maximum: max
|
2633
|
+
}
|
2634
|
+
},
|
2635
|
+
required: [fieldId]
|
2636
|
+
}
|
2637
|
+
},
|
2638
|
+
required: ["$form"]
|
2484
2639
|
})
|
2485
2640
|
};
|
2486
2641
|
}
|
2487
2642
|
|
2488
2643
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
2489
|
-
var PRINT_CERTIFICATE_FORM =
|
2644
|
+
var PRINT_CERTIFICATE_FORM = defineActionForm({
|
2490
2645
|
label: {
|
2491
2646
|
id: "v2.event.tennis-club-membership.action.certificate.form.label",
|
2492
2647
|
defaultMessage: "Tennis club membership certificate collector",
|
2493
2648
|
description: "This is what this form is referred as in the system"
|
2494
2649
|
},
|
2495
|
-
version: {
|
2496
|
-
id: "1.0.0",
|
2497
|
-
label: {
|
2498
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
|
2499
|
-
defaultMessage: "Version 1",
|
2500
|
-
description: "This is the first version of the form"
|
2501
|
-
}
|
2502
|
-
},
|
2503
|
-
active: true,
|
2504
2650
|
pages: [
|
2505
2651
|
{
|
2506
2652
|
id: "collector",
|
2653
|
+
type: PageTypes.enum.FORM,
|
2507
2654
|
title: {
|
2508
2655
|
id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
|
2509
2656
|
defaultMessage: "Print certified copy",
|
@@ -2518,7 +2665,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2518
2665
|
defaultMessage: "Requester",
|
2519
2666
|
description: "This is the label for the field"
|
2520
2667
|
},
|
2521
|
-
type:
|
2668
|
+
type: FieldType.SELECT,
|
2522
2669
|
options: [
|
2523
2670
|
{
|
2524
2671
|
value: "INFORMANT",
|
@@ -2595,7 +2742,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2595
2742
|
defaultMessage: "Select Type of ID",
|
2596
2743
|
description: "This is the label for selecting the type of ID"
|
2597
2744
|
},
|
2598
|
-
type:
|
2745
|
+
type: FieldType.SELECT,
|
2599
2746
|
options: [
|
2600
2747
|
{
|
2601
2748
|
value: "PASSPORT",
|
@@ -2696,7 +2843,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2696
2843
|
defaultMessage: "Passport Details",
|
2697
2844
|
description: "Field for entering Passport details"
|
2698
2845
|
},
|
2699
|
-
type:
|
2846
|
+
type: FieldType.TEXT
|
2700
2847
|
},
|
2701
2848
|
{
|
2702
2849
|
id: "collector.DRIVING_LICENSE.details",
|
@@ -2747,7 +2894,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2747
2894
|
defaultMessage: "Driving License Details",
|
2748
2895
|
description: "Field for entering Driving License details"
|
2749
2896
|
},
|
2750
|
-
type:
|
2897
|
+
type: FieldType.TEXT
|
2751
2898
|
},
|
2752
2899
|
{
|
2753
2900
|
id: "collector.REFUGEE_NUMBER.details",
|
@@ -2798,7 +2945,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2798
2945
|
defaultMessage: "Refugee Number Details",
|
2799
2946
|
description: "Field for entering Refugee Number details"
|
2800
2947
|
},
|
2801
|
-
type:
|
2948
|
+
type: FieldType.TEXT
|
2802
2949
|
},
|
2803
2950
|
{
|
2804
2951
|
id: "collector.ALIEN_NUMBER.details",
|
@@ -2849,7 +2996,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2849
2996
|
defaultMessage: "Alien Number Details",
|
2850
2997
|
description: "Field for entering Alien Number details"
|
2851
2998
|
},
|
2852
|
-
type:
|
2999
|
+
type: FieldType.TEXT
|
2853
3000
|
},
|
2854
3001
|
{
|
2855
3002
|
id: "collector.OTHER.idTypeOther",
|
@@ -2900,7 +3047,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2900
3047
|
defaultMessage: "Other ID Type (if applicable)",
|
2901
3048
|
description: 'Field for entering ID type if "Other" is selected'
|
2902
3049
|
},
|
2903
|
-
type:
|
3050
|
+
type: FieldType.TEXT
|
2904
3051
|
},
|
2905
3052
|
{
|
2906
3053
|
id: "collector.OTHER.firstName",
|
@@ -2951,7 +3098,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
2951
3098
|
defaultMessage: "First Name",
|
2952
3099
|
description: "This is the label for the first name field"
|
2953
3100
|
},
|
2954
|
-
type:
|
3101
|
+
type: FieldType.TEXT
|
2955
3102
|
},
|
2956
3103
|
{
|
2957
3104
|
id: "collector.OTHER.lastName",
|
@@ -3002,7 +3149,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3002
3149
|
defaultMessage: "Last Name",
|
3003
3150
|
description: "This is the label for the last name field"
|
3004
3151
|
},
|
3005
|
-
type:
|
3152
|
+
type: FieldType.TEXT
|
3006
3153
|
},
|
3007
3154
|
{
|
3008
3155
|
id: "collector.OTHER.relationshipToMember",
|
@@ -3053,7 +3200,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3053
3200
|
defaultMessage: "Relationship to Member",
|
3054
3201
|
description: "This is the label for the relationship to member field"
|
3055
3202
|
},
|
3056
|
-
type:
|
3203
|
+
type: FieldType.TEXT
|
3057
3204
|
},
|
3058
3205
|
{
|
3059
3206
|
id: "collector.OTHER.signedAffidavit",
|
@@ -3104,13 +3251,13 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3104
3251
|
defaultMessage: "Signed Affidavit (Optional)",
|
3105
3252
|
description: "This is the label for uploading a signed affidavit"
|
3106
3253
|
},
|
3107
|
-
type:
|
3254
|
+
type: FieldType.FILE
|
3108
3255
|
}
|
3109
3256
|
]
|
3110
3257
|
},
|
3111
3258
|
{
|
3112
3259
|
id: "collector.identity.verify",
|
3113
|
-
type:
|
3260
|
+
type: PageTypes.enum.VERIFICATION,
|
3114
3261
|
conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
|
3115
3262
|
title: {
|
3116
3263
|
id: "event.tennis-club-membership.action.print.verifyIdentity",
|
@@ -3147,62 +3294,45 @@ var PRINT_CERTIFICATE_FORM = defineForm({
|
|
3147
3294
|
}
|
3148
3295
|
}
|
3149
3296
|
}
|
3150
|
-
]
|
3151
|
-
review: {
|
3152
|
-
title: {
|
3153
|
-
id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
|
3154
|
-
defaultMessage: "Member certificate collector for {firstname} {surname}",
|
3155
|
-
description: "Title of the form to show in review page"
|
3156
|
-
},
|
3157
|
-
fields: []
|
3158
|
-
}
|
3297
|
+
]
|
3159
3298
|
});
|
3160
|
-
var
|
3161
|
-
|
3162
|
-
id: "v2.event.tennis-club-membership.action.declare.form.
|
3163
|
-
defaultMessage: "
|
3164
|
-
description: "
|
3165
|
-
},
|
3166
|
-
active: true,
|
3167
|
-
version: {
|
3168
|
-
id: "1.0.0",
|
3169
|
-
label: {
|
3170
|
-
id: "v2.event.tennis-club-membership.action.declare.form.version.1",
|
3171
|
-
defaultMessage: "Version 1",
|
3172
|
-
description: "This is the first version of the form"
|
3173
|
-
}
|
3299
|
+
var TENNIS_CLUB_DECLARATION_REVIEW = {
|
3300
|
+
title: {
|
3301
|
+
id: "v2.event.tennis-club-membership.action.declare.form.review.title",
|
3302
|
+
defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
|
3303
|
+
description: "Title of the review page"
|
3174
3304
|
},
|
3175
|
-
|
3176
|
-
|
3177
|
-
id: "
|
3178
|
-
|
3179
|
-
|
3305
|
+
fields: [
|
3306
|
+
{
|
3307
|
+
id: "review.comment",
|
3308
|
+
type: FieldType.TEXTAREA,
|
3309
|
+
label: {
|
3310
|
+
defaultMessage: "Comment",
|
3311
|
+
id: "v2.event.birth.action.declare.form.review.comment.label",
|
3312
|
+
description: "Label for the comment field in the review section"
|
3313
|
+
}
|
3180
3314
|
},
|
3181
|
-
|
3182
|
-
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
description: "Label for the comment field in the review section"
|
3189
|
-
}
|
3315
|
+
{
|
3316
|
+
type: FieldType.SIGNATURE,
|
3317
|
+
id: "review.signature",
|
3318
|
+
label: {
|
3319
|
+
defaultMessage: "Signature of informant",
|
3320
|
+
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3321
|
+
description: "Label for the signature field in the review section"
|
3190
3322
|
},
|
3191
|
-
{
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
defaultMessage: "Signature of informant",
|
3196
|
-
id: "v2.event.birth.action.declare.form.review.signature.label",
|
3197
|
-
description: "Label for the signature field in the review section"
|
3198
|
-
},
|
3199
|
-
signaturePromptLabel: {
|
3200
|
-
id: "v2.signature.upload.modal.title",
|
3201
|
-
defaultMessage: "Draw signature",
|
3202
|
-
description: "Title for the modal to draw signature"
|
3203
|
-
}
|
3323
|
+
signaturePromptLabel: {
|
3324
|
+
id: "v2.signature.upload.modal.title",
|
3325
|
+
defaultMessage: "Draw signature",
|
3326
|
+
description: "Title for the modal to draw signature"
|
3204
3327
|
}
|
3205
|
-
|
3328
|
+
}
|
3329
|
+
]
|
3330
|
+
};
|
3331
|
+
var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
3332
|
+
label: {
|
3333
|
+
id: "v2.event.tennis-club-membership.action.declare.form.label",
|
3334
|
+
defaultMessage: "Tennis club membership application",
|
3335
|
+
description: "This is what this form is referred as in the system"
|
3206
3336
|
},
|
3207
3337
|
pages: [
|
3208
3338
|
{
|
@@ -3215,7 +3345,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3215
3345
|
fields: [
|
3216
3346
|
{
|
3217
3347
|
id: "applicant.firstname",
|
3218
|
-
type:
|
3348
|
+
type: FieldType.TEXT,
|
3219
3349
|
required: true,
|
3220
3350
|
conditionals: [],
|
3221
3351
|
label: {
|
@@ -3226,7 +3356,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3226
3356
|
},
|
3227
3357
|
{
|
3228
3358
|
id: "applicant.surname",
|
3229
|
-
type:
|
3359
|
+
type: FieldType.TEXT,
|
3230
3360
|
required: true,
|
3231
3361
|
conditionals: [],
|
3232
3362
|
label: {
|
@@ -3269,7 +3399,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3269
3399
|
},
|
3270
3400
|
{
|
3271
3401
|
id: "applicant.image",
|
3272
|
-
type:
|
3402
|
+
type: FieldType.FILE,
|
3273
3403
|
required: false,
|
3274
3404
|
label: {
|
3275
3405
|
defaultMessage: "Applicant's profile picture",
|
@@ -3301,7 +3431,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3301
3431
|
fields: [
|
3302
3432
|
{
|
3303
3433
|
id: "senior-pass.id",
|
3304
|
-
type:
|
3434
|
+
type: FieldType.TEXT,
|
3305
3435
|
required: true,
|
3306
3436
|
label: {
|
3307
3437
|
defaultMessage: "Senior pass ID",
|
@@ -3332,7 +3462,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3332
3462
|
},
|
3333
3463
|
{
|
3334
3464
|
id: "recommender.firstname",
|
3335
|
-
type:
|
3465
|
+
type: FieldType.TEXT,
|
3336
3466
|
required: true,
|
3337
3467
|
conditionals: [
|
3338
3468
|
{
|
@@ -3348,7 +3478,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3348
3478
|
},
|
3349
3479
|
{
|
3350
3480
|
id: "recommender.surname",
|
3351
|
-
type:
|
3481
|
+
type: FieldType.TEXT,
|
3352
3482
|
required: true,
|
3353
3483
|
conditionals: [
|
3354
3484
|
{
|
@@ -3364,7 +3494,7 @@ var TENNIS_CLUB_FORM = defineForm({
|
|
3364
3494
|
},
|
3365
3495
|
{
|
3366
3496
|
id: "recommender.id",
|
3367
|
-
type:
|
3497
|
+
type: FieldType.TEXT,
|
3368
3498
|
required: true,
|
3369
3499
|
conditionals: [
|
3370
3500
|
{
|
@@ -3472,7 +3602,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3472
3602
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3473
3603
|
id: "event.tennis-club-membership.action.declare.label"
|
3474
3604
|
},
|
3475
|
-
|
3605
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3476
3606
|
},
|
3477
3607
|
{
|
3478
3608
|
type: ActionType.VALIDATE,
|
@@ -3481,7 +3611,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3481
3611
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3482
3612
|
id: "event.tennis-club-membership.action.validate.label"
|
3483
3613
|
},
|
3484
|
-
|
3614
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3485
3615
|
},
|
3486
3616
|
{
|
3487
3617
|
type: ActionType.REGISTER,
|
@@ -3490,7 +3620,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3490
3620
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3491
3621
|
id: "event.tennis-club-membership.action.register.label"
|
3492
3622
|
},
|
3493
|
-
|
3623
|
+
review: TENNIS_CLUB_DECLARATION_REVIEW
|
3494
3624
|
},
|
3495
3625
|
{
|
3496
3626
|
type: ActionType.REQUEST_CORRECTION,
|
@@ -3499,10 +3629,10 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3499
3629
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
3500
3630
|
id: "event.tennis-club-membership.action.correction.request.label"
|
3501
3631
|
},
|
3502
|
-
forms: [TENNIS_CLUB_FORM],
|
3503
3632
|
onboardingForm: [
|
3504
3633
|
{
|
3505
3634
|
id: "correction-requester",
|
3635
|
+
type: PageTypes.enum.FORM,
|
3506
3636
|
title: {
|
3507
3637
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3508
3638
|
defaultMessage: "Correction requester",
|
@@ -3566,6 +3696,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3566
3696
|
},
|
3567
3697
|
{
|
3568
3698
|
id: "identity-check",
|
3699
|
+
type: PageTypes.enum.FORM,
|
3569
3700
|
title: {
|
3570
3701
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3571
3702
|
defaultMessage: "Verify their identity",
|
@@ -3608,6 +3739,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3608
3739
|
additionalDetailsForm: [
|
3609
3740
|
{
|
3610
3741
|
id: "correction-request.supporting-documents",
|
3742
|
+
type: PageTypes.enum.FORM,
|
3611
3743
|
title: {
|
3612
3744
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
|
3613
3745
|
defaultMessage: "Upload supporting documents",
|
@@ -3625,7 +3757,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3625
3757
|
},
|
3626
3758
|
{
|
3627
3759
|
id: "correction.supportingDocs",
|
3628
|
-
type:
|
3760
|
+
type: FieldType.FILE,
|
3629
3761
|
label: {
|
3630
3762
|
id: "correction.corrector.title",
|
3631
3763
|
defaultMessage: "Upload supporting documents",
|
@@ -3669,6 +3801,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3669
3801
|
},
|
3670
3802
|
{
|
3671
3803
|
id: "correction-request.additional-details",
|
3804
|
+
type: PageTypes.enum.FORM,
|
3672
3805
|
title: {
|
3673
3806
|
id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
|
3674
3807
|
defaultMessage: "Reason for correction",
|
@@ -3677,7 +3810,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3677
3810
|
fields: [
|
3678
3811
|
{
|
3679
3812
|
id: "correction.request.reason",
|
3680
|
-
type:
|
3813
|
+
type: FieldType.TEXT,
|
3681
3814
|
label: {
|
3682
3815
|
id: "correction.reason.title",
|
3683
3816
|
defaultMessage: "Reason for correction?",
|
@@ -3690,7 +3823,6 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3690
3823
|
},
|
3691
3824
|
{
|
3692
3825
|
type: ActionType.APPROVE_CORRECTION,
|
3693
|
-
forms: [TENNIS_CLUB_FORM],
|
3694
3826
|
label: {
|
3695
3827
|
defaultMessage: "Approve correction",
|
3696
3828
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
@@ -3704,7 +3836,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3704
3836
|
defaultMessage: "Print certificate",
|
3705
3837
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3706
3838
|
},
|
3707
|
-
|
3839
|
+
printForm: PRINT_CERTIFICATE_FORM,
|
3708
3840
|
conditionals: [
|
3709
3841
|
{
|
3710
3842
|
type: "SHOW",
|
@@ -3751,8 +3883,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3751
3883
|
id: "v2.event.tennis-club-membership.action.archive.label",
|
3752
3884
|
defaultMessage: "Archive",
|
3753
3885
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3754
|
-
}
|
3755
|
-
forms: [TENNIS_CLUB_FORM]
|
3886
|
+
}
|
3756
3887
|
},
|
3757
3888
|
{
|
3758
3889
|
type: ActionType.REJECT,
|
@@ -3760,8 +3891,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3760
3891
|
id: "v2.event.tennis-club-membership.action.reject.label",
|
3761
3892
|
defaultMessage: "Reject",
|
3762
3893
|
description: "This is shown as the action name anywhere the user can trigger the action from"
|
3763
|
-
}
|
3764
|
-
forms: [TENNIS_CLUB_FORM]
|
3894
|
+
}
|
3765
3895
|
}
|
3766
3896
|
],
|
3767
3897
|
advancedSearch: [
|
@@ -3777,33 +3907,49 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3777
3907
|
}
|
3778
3908
|
]
|
3779
3909
|
}
|
3780
|
-
]
|
3910
|
+
],
|
3911
|
+
declaration: TENNIS_CLUB_DECLARATION_FORM
|
3781
3912
|
});
|
3782
3913
|
|
3783
3914
|
// ../commons/src/events/test.utils.ts
|
3784
|
-
function
|
3785
|
-
|
3786
|
-
const data = fields.reduce(
|
3915
|
+
function fieldConfigsToActionAnnotation(fields) {
|
3916
|
+
return fields.reduce(
|
3787
3917
|
(acc, field2, i) => ({
|
3788
3918
|
...acc,
|
3789
3919
|
[field2.id]: mapFieldTypeToMockValue(field2, i)
|
3790
3920
|
}),
|
3791
3921
|
{}
|
3792
3922
|
);
|
3793
|
-
|
3923
|
+
}
|
3924
|
+
function generateActionInput(configuration, action) {
|
3925
|
+
const parsed = DeclarationUpdateActions.safeParse(action);
|
3926
|
+
if (parsed.success) {
|
3927
|
+
const fields = getDeclarationFields(configuration);
|
3928
|
+
const annotation = fieldConfigsToActionAnnotation(fields);
|
3929
|
+
return stripHiddenFields(fields, annotation);
|
3930
|
+
}
|
3931
|
+
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
3932
|
+
return {};
|
3794
3933
|
}
|
3795
3934
|
function generateActionMetadataInput(configuration, action) {
|
3796
|
-
const
|
3797
|
-
|
3798
|
-
|
3799
|
-
|
3800
|
-
|
3935
|
+
const actionConfig = configuration.actions.find(
|
3936
|
+
(actionConfig2) => actionConfig2.type === action
|
3937
|
+
);
|
3938
|
+
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3939
|
+
const annotation = fieldConfigsToActionAnnotation(annotationFields);
|
3940
|
+
const visibleVerificationPageIds = (findRecordActionPages(configuration, action) ?? []).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id) ?? [];
|
3941
|
+
const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
|
3801
3942
|
(acc, pageId) => ({
|
3802
3943
|
...acc,
|
3803
3944
|
[pageId]: true
|
3804
3945
|
}),
|
3805
3946
|
{}
|
3806
3947
|
);
|
3948
|
+
const fieldBasedPayload = stripHiddenFields(annotationFields, annotation);
|
3949
|
+
return {
|
3950
|
+
...fieldBasedPayload,
|
3951
|
+
...visiblePageVerificationMap
|
3952
|
+
};
|
3807
3953
|
}
|
3808
3954
|
var eventPayloadGenerator = {
|
3809
3955
|
create: (input = {}) => ({
|
@@ -3823,13 +3969,13 @@ var eventPayloadGenerator = {
|
|
3823
3969
|
transactionId: getUUID(),
|
3824
3970
|
action: {
|
3825
3971
|
type: ActionType.REQUEST_CORRECTION,
|
3826
|
-
|
3972
|
+
declaration: {
|
3827
3973
|
"applicant.firstname": "Max",
|
3828
3974
|
"applicant.surname": "McLaren",
|
3829
3975
|
"applicant.dob": "2020-01-02",
|
3830
3976
|
"recommender.none": true
|
3831
3977
|
},
|
3832
|
-
|
3978
|
+
annotation: {
|
3833
3979
|
"correction.requester.relationship": "ANOTHER_AGENT",
|
3834
3980
|
"correction.request.reason": "Child's name was incorrect"
|
3835
3981
|
},
|
@@ -3844,45 +3990,78 @@ var eventPayloadGenerator = {
|
|
3844
3990
|
declare: (eventId, input = {}) => ({
|
3845
3991
|
type: ActionType.DECLARE,
|
3846
3992
|
transactionId: input.transactionId ?? getUUID(),
|
3847
|
-
|
3993
|
+
declaration: input.declaration ?? generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
|
3994
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
3995
|
+
tennisClubMembershipEvent,
|
3996
|
+
ActionType.DECLARE
|
3997
|
+
),
|
3848
3998
|
eventId
|
3849
3999
|
}),
|
4000
|
+
/**
|
4001
|
+
* Notify allows sending incomplete data. Think it as 'partial declare' for now.
|
4002
|
+
*/
|
4003
|
+
notify: (eventId, input = {}) => {
|
4004
|
+
let declaration = input.declaration;
|
4005
|
+
if (!declaration) {
|
4006
|
+
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4007
|
+
generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
|
4008
|
+
import_lodash2.isString
|
4009
|
+
);
|
4010
|
+
declaration = partialDeclaration;
|
4011
|
+
}
|
4012
|
+
return {
|
4013
|
+
type: ActionType.NOTIFY,
|
4014
|
+
transactionId: input.transactionId ?? getUUID(),
|
4015
|
+
declaration,
|
4016
|
+
eventId
|
4017
|
+
};
|
4018
|
+
},
|
3850
4019
|
validate: (eventId, input = {}) => ({
|
3851
4020
|
type: ActionType.VALIDATE,
|
3852
4021
|
transactionId: input.transactionId ?? getUUID(),
|
3853
|
-
|
4022
|
+
declaration: input.declaration ?? generateActionInput(tennisClubMembershipEvent, ActionType.VALIDATE),
|
4023
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
4024
|
+
tennisClubMembershipEvent,
|
4025
|
+
ActionType.VALIDATE
|
4026
|
+
),
|
3854
4027
|
duplicates: [],
|
3855
4028
|
eventId
|
3856
4029
|
}),
|
3857
4030
|
archive: (eventId, input = {}, isDuplicate) => ({
|
3858
4031
|
type: ActionType.ARCHIVE,
|
3859
4032
|
transactionId: input.transactionId ?? getUUID(),
|
3860
|
-
|
3861
|
-
|
4033
|
+
declaration: {},
|
4034
|
+
// @TODO: Check whether generator is needed?
|
4035
|
+
annotation: { isDuplicate: isDuplicate ?? false },
|
3862
4036
|
duplicates: [],
|
3863
4037
|
eventId
|
3864
4038
|
}),
|
3865
4039
|
reject: (eventId, input = {}) => ({
|
3866
4040
|
type: ActionType.REJECT,
|
3867
4041
|
transactionId: input.transactionId ?? getUUID(),
|
3868
|
-
|
4042
|
+
declaration: {},
|
4043
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
4044
|
+
tennisClubMembershipEvent,
|
4045
|
+
ActionType.REJECT
|
4046
|
+
),
|
3869
4047
|
duplicates: [],
|
3870
4048
|
eventId
|
3871
4049
|
}),
|
3872
4050
|
register: (eventId, input = {}) => ({
|
3873
4051
|
type: ActionType.REGISTER,
|
3874
4052
|
transactionId: input.transactionId ?? getUUID(),
|
3875
|
-
|
4053
|
+
declaration: input.declaration ?? generateActionInput(tennisClubMembershipEvent, ActionType.REGISTER),
|
4054
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
4055
|
+
tennisClubMembershipEvent,
|
4056
|
+
ActionType.REGISTER
|
4057
|
+
),
|
3876
4058
|
eventId
|
3877
4059
|
}),
|
3878
4060
|
printCertificate: (eventId, input = {}) => ({
|
3879
4061
|
type: ActionType.PRINT_CERTIFICATE,
|
3880
4062
|
transactionId: input.transactionId ?? getUUID(),
|
3881
|
-
|
3882
|
-
|
3883
|
-
ActionType.PRINT_CERTIFICATE
|
3884
|
-
),
|
3885
|
-
metadata: input.metadata ?? generateActionMetadataInput(
|
4063
|
+
declaration: {},
|
4064
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
3886
4065
|
tennisClubMembershipEvent,
|
3887
4066
|
ActionType.PRINT_CERTIFICATE
|
3888
4067
|
),
|
@@ -3892,17 +4071,21 @@ var eventPayloadGenerator = {
|
|
3892
4071
|
request: (eventId, input = {}) => ({
|
3893
4072
|
type: ActionType.REQUEST_CORRECTION,
|
3894
4073
|
transactionId: input.transactionId ?? getUUID(),
|
3895
|
-
|
4074
|
+
declaration: input.declaration ?? generateActionInput(
|
4075
|
+
tennisClubMembershipEvent,
|
4076
|
+
ActionType.REQUEST_CORRECTION
|
4077
|
+
),
|
4078
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
3896
4079
|
tennisClubMembershipEvent,
|
3897
4080
|
ActionType.REQUEST_CORRECTION
|
3898
4081
|
),
|
3899
|
-
metadata: {},
|
3900
4082
|
eventId
|
3901
4083
|
}),
|
3902
4084
|
approve: (eventId, requestId, input = {}) => ({
|
3903
4085
|
type: ActionType.APPROVE_CORRECTION,
|
3904
4086
|
transactionId: input.transactionId ?? getUUID(),
|
3905
|
-
|
4087
|
+
declaration: {},
|
4088
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
3906
4089
|
tennisClubMembershipEvent,
|
3907
4090
|
ActionType.APPROVE_CORRECTION
|
3908
4091
|
),
|
@@ -3912,7 +4095,8 @@ var eventPayloadGenerator = {
|
|
3912
4095
|
reject: (eventId, requestId, input = {}) => ({
|
3913
4096
|
type: ActionType.REJECT_CORRECTION,
|
3914
4097
|
transactionId: input.transactionId ?? getUUID(),
|
3915
|
-
|
4098
|
+
declaration: {},
|
4099
|
+
annotation: input.annotation ?? generateActionMetadataInput(
|
3916
4100
|
tennisClubMembershipEvent,
|
3917
4101
|
ActionType.REJECT_CORRECTION
|
3918
4102
|
),
|
@@ -3934,9 +4118,10 @@ function generateActionDocument({
|
|
3934
4118
|
createdBy: getUUID(),
|
3935
4119
|
id: getUUID(),
|
3936
4120
|
createdAtLocation: "TODO",
|
3937
|
-
|
3938
|
-
|
3939
|
-
...defaults
|
4121
|
+
declaration: generateActionInput(configuration, action),
|
4122
|
+
annotation: {},
|
4123
|
+
...defaults,
|
4124
|
+
status: ActionStatus.Accepted
|
3940
4125
|
};
|
3941
4126
|
switch (action) {
|
3942
4127
|
case ActionType.DECLARE:
|
@@ -3963,13 +4148,10 @@ function generateActionDocument({
|
|
3963
4148
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3964
4149
|
case ActionType.REJECT_CORRECTION:
|
3965
4150
|
return { ...actionBase, requestId: getUUID(), type: action };
|
3966
|
-
case ActionType.CUSTOM:
|
3967
|
-
return { ...actionBase, type: action };
|
3968
4151
|
case ActionType.REGISTER:
|
3969
4152
|
return {
|
3970
4153
|
...actionBase,
|
3971
|
-
type: action
|
3972
|
-
identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
|
4154
|
+
type: action
|
3973
4155
|
};
|
3974
4156
|
default:
|
3975
4157
|
throw new Error(`Unsupported action type: ${action}`);
|
@@ -3994,7 +4176,7 @@ function generateEventDocument({
|
|
3994
4176
|
updatedAt: new Date(Date.now() - 1e3).toISOString()
|
3995
4177
|
};
|
3996
4178
|
}
|
3997
|
-
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE,
|
4179
|
+
function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
|
3998
4180
|
const action = generateActionDocument({
|
3999
4181
|
configuration: tennisClubMembershipEvent,
|
4000
4182
|
action: actionType
|
@@ -4004,9 +4186,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
|
|
4004
4186
|
transactionId: getUUID(),
|
4005
4187
|
action: {
|
4006
4188
|
...action,
|
4007
|
-
|
4008
|
-
...action.
|
4009
|
-
...
|
4189
|
+
declaration: {
|
4190
|
+
...action.declaration,
|
4191
|
+
...declaration
|
4010
4192
|
}
|
4011
4193
|
},
|
4012
4194
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
@@ -4023,7 +4205,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
4023
4205
|
modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
4024
4206
|
assignedTo: overrides.assignedTo ?? null,
|
4025
4207
|
updatedBy: overrides.updatedBy ?? getUUID(),
|
4026
|
-
|
4208
|
+
declaration: overrides.declaration ?? {
|
4027
4209
|
"recommender.none": true,
|
4028
4210
|
"applicant.firstname": "Danny",
|
4029
4211
|
"applicant.surname": "Doe",
|