@opencrvs/toolkit 1.8.0-rc.f8f3eb3 → 1.8.0-rc.faeb298
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/dist/commons/api/router.d.ts +242 -36
- package/dist/commons/events/ActionConfig.d.ts +1597 -387
- package/dist/commons/events/ActionInput.d.ts +0 -84
- package/dist/commons/events/Draft.d.ts +0 -3
- package/dist/commons/events/EventConfig.d.ts +1448 -96
- package/dist/commons/events/EventConfigInput.d.ts +2 -2
- package/dist/commons/events/FieldConfig.d.ts +175 -2
- package/dist/commons/events/FieldType.d.ts +6 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +21 -1
- package/dist/commons/events/FormConfig.d.ts +278 -26
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/defineConfig.d.ts +242 -24
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/utils.d.ts +60 -6
- package/dist/events/index.js +101 -10
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -80,6 +80,9 @@ __export(events_exports, {
|
|
80
80
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
81
81
|
NotifyActionInput: () => NotifyActionInput,
|
82
82
|
NumberFieldValue: () => NumberFieldValue,
|
83
|
+
PageBase: () => PageBase,
|
84
|
+
PageConfig: () => PageConfig,
|
85
|
+
PageType: () => PageType,
|
83
86
|
PrintCertificateActionInput: () => PrintCertificateActionInput,
|
84
87
|
RegisterActionInput: () => RegisterActionInput,
|
85
88
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
@@ -96,16 +99,18 @@ __export(events_exports, {
|
|
96
99
|
UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
|
97
100
|
UrbanAddressValue: () => UrbanAddressValue,
|
98
101
|
ValidateActionInput: () => ValidateActionInput,
|
102
|
+
VerificationPage: () => VerificationPage,
|
99
103
|
WorkqueueConfig: () => WorkqueueConfig,
|
100
104
|
alwaysTrue: () => alwaysTrue,
|
101
105
|
and: () => and,
|
102
106
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
107
|
+
compositeFieldTypes: () => compositeFieldTypes,
|
103
108
|
createValidationSchema: () => createValidationSchema,
|
104
109
|
deepDropNulls: () => deepDropNulls,
|
105
110
|
defineConditional: () => defineConditional,
|
106
111
|
defineConfig: () => defineConfig,
|
107
112
|
defineForm: () => defineForm,
|
108
|
-
|
113
|
+
definePage: () => definePage,
|
109
114
|
event: () => event,
|
110
115
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
111
116
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
@@ -138,11 +143,15 @@ __export(events_exports, {
|
|
138
143
|
isBulletListFieldType: () => isBulletListFieldType,
|
139
144
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
140
145
|
isCountryFieldType: () => isCountryFieldType,
|
146
|
+
isDataFieldType: () => isDataFieldType,
|
141
147
|
isDateFieldType: () => isDateFieldType,
|
142
148
|
isDividerFieldType: () => isDividerFieldType,
|
143
149
|
isEmailFieldType: () => isEmailFieldType,
|
144
150
|
isFacilityFieldType: () => isFacilityFieldType,
|
151
|
+
isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
|
145
152
|
isFieldEnabled: () => isFieldEnabled,
|
153
|
+
isFieldValue: () => isFieldValue,
|
154
|
+
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
146
155
|
isFieldVisible: () => isFieldVisible,
|
147
156
|
isFileFieldType: () => isFileFieldType,
|
148
157
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
@@ -154,6 +163,7 @@ __export(events_exports, {
|
|
154
163
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
155
164
|
isSelectFieldType: () => isSelectFieldType,
|
156
165
|
isSignatureFieldType: () => isSignatureFieldType,
|
166
|
+
isTemplateVariable: () => isTemplateVariable,
|
157
167
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
158
168
|
isTextFieldType: () => isTextFieldType,
|
159
169
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
@@ -240,9 +250,15 @@ var FieldType = {
|
|
240
250
|
ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
|
241
251
|
FACILITY: "FACILITY",
|
242
252
|
OFFICE: "OFFICE",
|
243
|
-
SIGNATURE: "SIGNATURE"
|
253
|
+
SIGNATURE: "SIGNATURE",
|
254
|
+
DATA: "DATA"
|
244
255
|
};
|
245
256
|
var fieldTypes = Object.values(FieldType);
|
257
|
+
var compositeFieldTypes = [
|
258
|
+
FieldType.ADDRESS,
|
259
|
+
FieldType.FILE_WITH_OPTIONS,
|
260
|
+
FieldType.FILE
|
261
|
+
];
|
246
262
|
|
247
263
|
// ../commons/src/events/FieldValue.ts
|
248
264
|
var import_zod4 = require("zod");
|
@@ -526,6 +542,15 @@ var Address = BaseField.extend({
|
|
526
542
|
type: import_zod5.z.literal(FieldType.ADDRESS),
|
527
543
|
defaultValue: AddressFieldValue.optional()
|
528
544
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
545
|
+
var Data = BaseField.extend({
|
546
|
+
type: import_zod5.z.literal(FieldType.DATA),
|
547
|
+
configuration: import_zod5.z.object({
|
548
|
+
title: TranslationConfig.optional(),
|
549
|
+
subtitle: TranslationConfig.optional(),
|
550
|
+
data: import_zod5.z.array(import_zod5.z.object({ fieldId: import_zod5.z.string() }))
|
551
|
+
// todo cihan: can we make this type more specific?
|
552
|
+
})
|
553
|
+
});
|
529
554
|
var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
530
555
|
Address,
|
531
556
|
TextField,
|
@@ -547,15 +572,42 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
|
|
547
572
|
Office,
|
548
573
|
SignatureField,
|
549
574
|
EmailField,
|
550
|
-
FileUploadWithOptions
|
575
|
+
FileUploadWithOptions,
|
576
|
+
Data
|
551
577
|
]);
|
552
578
|
|
553
579
|
// ../commons/src/events/FormConfig.ts
|
554
|
-
var
|
580
|
+
var PageType = /* @__PURE__ */ ((PageType2) => {
|
581
|
+
PageType2["FORM"] = "FORM";
|
582
|
+
PageType2["VERIFICATION"] = "VERIFICATION";
|
583
|
+
return PageType2;
|
584
|
+
})(PageType || {});
|
585
|
+
var PageBase = import_zod6.z.object({
|
555
586
|
id: import_zod6.z.string().describe("Unique identifier for the page"),
|
556
587
|
title: TranslationConfig.describe("Header title of the page"),
|
557
|
-
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
|
588
|
+
fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
|
589
|
+
type: import_zod6.z.enum(["FORM", "VERIFICATION"]).default("FORM")
|
590
|
+
});
|
591
|
+
var FormPage = PageBase.extend({
|
592
|
+
type: import_zod6.z.literal("FORM").optional()
|
593
|
+
});
|
594
|
+
var VerificationPage = PageBase.extend({
|
595
|
+
type: import_zod6.z.literal("VERIFICATION"),
|
596
|
+
actions: import_zod6.z.object({
|
597
|
+
verify: import_zod6.z.object({ label: TranslationConfig }),
|
598
|
+
cancel: import_zod6.z.object({
|
599
|
+
label: TranslationConfig,
|
600
|
+
confirmation: import_zod6.z.object({
|
601
|
+
title: TranslationConfig,
|
602
|
+
body: TranslationConfig
|
603
|
+
})
|
604
|
+
})
|
605
|
+
}).describe("Actions available on the verification page")
|
558
606
|
});
|
607
|
+
var PageConfig = import_zod6.z.discriminatedUnion("type", [
|
608
|
+
FormPage,
|
609
|
+
VerificationPage
|
610
|
+
]);
|
559
611
|
var FormConfig = import_zod6.z.object({
|
560
612
|
label: TranslationConfig.describe("Human readable description of the form"),
|
561
613
|
version: import_zod6.z.object({
|
@@ -567,7 +619,7 @@ var FormConfig = import_zod6.z.object({
|
|
567
619
|
)
|
568
620
|
}),
|
569
621
|
active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
|
570
|
-
pages: import_zod6.z.array(
|
622
|
+
pages: import_zod6.z.array(PageConfig),
|
571
623
|
review: import_zod6.z.object({
|
572
624
|
title: TranslationConfig.describe(
|
573
625
|
"Title of the form to show in review page"
|
@@ -1102,6 +1154,9 @@ function mapFieldTypeToZod(type, required) {
|
|
1102
1154
|
case FieldType.ADDRESS:
|
1103
1155
|
schema = AddressFieldUpdateValue;
|
1104
1156
|
break;
|
1157
|
+
case FieldType.DATA:
|
1158
|
+
schema = import_zod17.z.string();
|
1159
|
+
break;
|
1105
1160
|
}
|
1106
1161
|
return required ? schema : schema.nullish();
|
1107
1162
|
}
|
@@ -1157,6 +1212,8 @@ function mapFieldTypeToMockValue(field2, i) {
|
|
1157
1212
|
};
|
1158
1213
|
case FieldType.FILE_WITH_OPTIONS:
|
1159
1214
|
return null;
|
1215
|
+
case FieldType.DATA:
|
1216
|
+
return {};
|
1160
1217
|
}
|
1161
1218
|
}
|
1162
1219
|
var isParagraphFieldType = (field2) => {
|
@@ -1222,6 +1279,9 @@ var isFacilityFieldType = (field2) => {
|
|
1222
1279
|
var isOfficeFieldType = (field2) => {
|
1223
1280
|
return field2.config.type === FieldType.OFFICE;
|
1224
1281
|
};
|
1282
|
+
var isDataFieldType = (field2) => {
|
1283
|
+
return field2.config.type === FieldType.DATA;
|
1284
|
+
};
|
1225
1285
|
|
1226
1286
|
// ../commons/src/conditionals/validate.ts
|
1227
1287
|
var ajv = new import_ajv.default({
|
@@ -1532,7 +1592,7 @@ var EventConfig = import_zod18.z.object({
|
|
1532
1592
|
|
1533
1593
|
// ../commons/src/events/EventConfigInput.ts
|
1534
1594
|
var defineForm = (form) => FormConfig.parse(form);
|
1535
|
-
var
|
1595
|
+
var definePage = (formPage) => PageConfig.parse(formPage);
|
1536
1596
|
|
1537
1597
|
// ../commons/src/events/Draft.ts
|
1538
1598
|
var import_zod21 = require("zod");
|
@@ -1664,7 +1724,6 @@ var import_zod20 = require("zod");
|
|
1664
1724
|
var BaseActionInput = import_zod20.z.object({
|
1665
1725
|
eventId: import_zod20.z.string(),
|
1666
1726
|
transactionId: import_zod20.z.string(),
|
1667
|
-
incomplete: import_zod20.z.boolean().optional().default(false).describe("Allows action with partial data to be saved"),
|
1668
1727
|
data: ActionUpdate,
|
1669
1728
|
metadata: ActionUpdate.optional()
|
1670
1729
|
});
|
@@ -1691,8 +1750,7 @@ var ValidateActionInput = BaseActionInput.merge(
|
|
1691
1750
|
);
|
1692
1751
|
var NotifyActionInput = BaseActionInput.merge(
|
1693
1752
|
import_zod20.z.object({
|
1694
|
-
type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1695
|
-
createdAtLocation: import_zod20.z.string()
|
1753
|
+
type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
|
1696
1754
|
})
|
1697
1755
|
);
|
1698
1756
|
var DeclareActionInput = BaseActionInput.merge(
|
@@ -1831,6 +1889,9 @@ function getStatusFromActions(actions) {
|
|
1831
1889
|
if (action.type === ActionType.ARCHIVED) {
|
1832
1890
|
return EventStatus.ARCHIVED;
|
1833
1891
|
}
|
1892
|
+
if (action.type === ActionType.NOTIFY) {
|
1893
|
+
return EventStatus.NOTIFIED;
|
1894
|
+
}
|
1834
1895
|
return status;
|
1835
1896
|
}, EventStatus.CREATED);
|
1836
1897
|
}
|
@@ -3657,3 +3718,33 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3657
3718
|
},
|
3658
3719
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3659
3720
|
});
|
3721
|
+
|
3722
|
+
// ../commons/src/events/TemplateConfig.ts
|
3723
|
+
function isTemplateVariable(value) {
|
3724
|
+
return typeof value === "string" && value.startsWith("$");
|
3725
|
+
}
|
3726
|
+
function isFieldValue(value) {
|
3727
|
+
return FieldValue.safeParse(value).success;
|
3728
|
+
}
|
3729
|
+
function isFieldValueWithoutTemplates(value) {
|
3730
|
+
if (isTemplateVariable(value)) {
|
3731
|
+
return false;
|
3732
|
+
}
|
3733
|
+
if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
|
3734
|
+
return false;
|
3735
|
+
}
|
3736
|
+
return true;
|
3737
|
+
}
|
3738
|
+
function isFieldConfigDefaultValue(value) {
|
3739
|
+
if (!value) return false;
|
3740
|
+
if (isFieldValue(value)) {
|
3741
|
+
return true;
|
3742
|
+
}
|
3743
|
+
if (isTemplateVariable(value)) {
|
3744
|
+
return true;
|
3745
|
+
}
|
3746
|
+
if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
|
3747
|
+
return Object.values(value).every((v) => isFieldConfigDefaultValue(v));
|
3748
|
+
}
|
3749
|
+
return false;
|
3750
|
+
}
|