@opencrvs/toolkit 2.2.0-rc.3af310b → 2.2.0-rc.3de6f63
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/application-config/index.js +5 -5
- package/dist/authentication/index.d.ts +1 -0
- package/dist/authentication/index.js +16 -4
- package/dist/cli.js +586 -303
- package/dist/commons/api/router.d.ts +246 -246
- package/dist/commons/application-config/index.d.ts +2 -2
- package/dist/commons/conditionals/index.d.ts +1 -0
- package/dist/commons/conditionals/validate.d.ts +5 -0
- package/dist/commons/events/ActionConfig.d.ts +2 -2
- package/dist/commons/events/ActionDocument.d.ts +1 -0
- package/dist/commons/events/ActionInput.d.ts +4 -4
- package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
- package/dist/commons/events/EventConfig.d.ts +1 -10
- package/dist/commons/events/EventIndex.d.ts +2 -2
- package/dist/commons/events/FieldConfig.d.ts +1 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +6 -6
- package/dist/commons/events/Flag.d.ts +1 -1
- package/dist/commons/events/PlainDate.d.ts +1 -0
- package/dist/commons/events/eventConfigValidation.d.ts +1 -1
- package/dist/commons/events/field.d.ts +5 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/test.utils.d.ts +2 -3
- package/dist/commons/events/toNotificationForm.d.ts +17 -0
- package/dist/commons/events/utils.d.ts +26 -5
- package/dist/conditionals/index.js +2 -2
- package/dist/environment/custom-types.d.ts +1 -0
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts +6 -4
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +6 -4
- package/dist/environment/questions.d.ts +14 -2
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +39 -18
- package/dist/environment/registry.d.ts +15 -0
- package/dist/environment/registry.d.ts.map +1 -0
- package/dist/environment/registry.js +112 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +76 -28
- package/dist/events/index.js +197 -143
- package/dist/migrations/add-notify-config.d.ts +40 -0
- package/dist/migrations/add-notify-config.d.ts.map +1 -0
- package/dist/migrations/add-notify-config.js +249 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +345 -143
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
- package/dist/migrations/move-declaration-to-declare-action.js +27 -144
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
- package/dist/migrations/read-declaration-through-helper.js +3 -61
- package/dist/migrations/utils.d.ts +61 -0
- package/dist/migrations/utils.d.ts.map +1 -0
- package/dist/migrations/utils.js +218 -0
- package/dist/notification/index.js +267 -81
- package/dist/scopes/index.d.ts +54 -51
- package/dist/scopes/index.js +12 -4
- package/dist/templates/charts-values/opencrvs-services/values.yaml +3 -4
- package/opencrvs-toolkit-2.2.0-rc.3de6f63.tgz +0 -0
- package/package.json +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/commons/events/notificationFormFallback.d.ts +0 -10
- package/dist/environment/dockerhub.d.ts +0 -15
- package/dist/environment/dockerhub.d.ts.map +0 -1
- package/dist/environment/dockerhub.js +0 -104
- package/opencrvs-toolkit-2.2.0-rc.3af310b.tgz +0 -0
|
@@ -40,6 +40,9 @@ __export(notification_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(notification_exports);
|
|
41
41
|
var z48 = __toESM(require("zod/v4"));
|
|
42
42
|
|
|
43
|
+
// ../commons/src/events/index.ts
|
|
44
|
+
var import_compile = require("zod/compile");
|
|
45
|
+
|
|
43
46
|
// ../commons/src/events/AuditLog.ts
|
|
44
47
|
var z9 = __toESM(require("zod/v4"));
|
|
45
48
|
|
|
@@ -186,7 +189,7 @@ var ActionStatus = {
|
|
|
186
189
|
};
|
|
187
190
|
|
|
188
191
|
// ../commons/src/events/Flag.ts
|
|
189
|
-
var z5 = __toESM(require("zod
|
|
192
|
+
var z5 = __toESM(require("zod"));
|
|
190
193
|
|
|
191
194
|
// ../commons/src/events/TranslationConfig.ts
|
|
192
195
|
var z3 = __toESM(require("zod/v4"));
|
|
@@ -282,7 +285,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
|
|
|
282
285
|
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
283
286
|
InherentFlags
|
|
284
287
|
).join(", ")}`
|
|
285
|
-
}).refine((val) => !ActionFlag.
|
|
288
|
+
}).refine((val) => !ActionFlag.validate(val), {
|
|
286
289
|
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
287
290
|
}).describe("Custom flag identifier defined by the country config.");
|
|
288
291
|
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
@@ -996,7 +999,7 @@ var z14 = __toESM(require("zod/v4"));
|
|
|
996
999
|
// ../commons/src/documents.ts
|
|
997
1000
|
var z11 = __toESM(require("zod/v4"));
|
|
998
1001
|
var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
|
|
999
|
-
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://
|
|
1002
|
+
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://s3.opencrvs.com/bucket-name/document-id.jpg"
|
|
1000
1003
|
);
|
|
1001
1004
|
var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
1002
1005
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
@@ -1006,7 +1009,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
|
|
|
1006
1009
|
);
|
|
1007
1010
|
|
|
1008
1011
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
1009
|
-
var z12 = __toESM(require("zod
|
|
1012
|
+
var z12 = __toESM(require("zod"));
|
|
1010
1013
|
var AddressType = {
|
|
1011
1014
|
DOMESTIC: "DOMESTIC",
|
|
1012
1015
|
INTERNATIONAL: "INTERNATIONAL"
|
|
@@ -1211,7 +1214,7 @@ function safeUnion(schemas) {
|
|
|
1211
1214
|
);
|
|
1212
1215
|
return z14.any().superRefine((val, ctx) => {
|
|
1213
1216
|
for (const schema of sortedSchemas) {
|
|
1214
|
-
if (schema.
|
|
1217
|
+
if (schema.validate(val)) {
|
|
1215
1218
|
return;
|
|
1216
1219
|
}
|
|
1217
1220
|
}
|
|
@@ -2907,11 +2910,11 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
2907
2910
|
var NotifyConfig = ActionConfigBase.extend(
|
|
2908
2911
|
z25.object({
|
|
2909
2912
|
type: z25.literal(ActionType.NOTIFY),
|
|
2910
|
-
notificationForm: DeclarationFormConfig.
|
|
2911
|
-
"Notification form configuration. Its fields must be a subset of the declaration form fields, with matching types. The values submitted on the notification form pre-fill the declaration.
|
|
2913
|
+
notificationForm: DeclarationFormConfig.describe(
|
|
2914
|
+
"Notification form configuration. Its fields must be a subset of the declaration form fields, with matching types. The values submitted on the notification form pre-fill the declaration."
|
|
2912
2915
|
),
|
|
2913
2916
|
review: DeclarationReviewConfig.describe(
|
|
2914
|
-
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation.
|
|
2917
|
+
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
|
|
2915
2918
|
),
|
|
2916
2919
|
form: actionConfirmationForm
|
|
2917
2920
|
}).shape
|
|
@@ -3457,7 +3460,10 @@ var SearchQueryParams = z30.object({
|
|
|
3457
3460
|
}).catchall(FieldValue);
|
|
3458
3461
|
var FieldConfigSchema = BaseField3.extend({
|
|
3459
3462
|
fieldId: z30.string(),
|
|
3460
|
-
fieldType: z30.literal("field")
|
|
3463
|
+
fieldType: z30.literal("field"),
|
|
3464
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
3465
|
+
`Value the field opens with in advanced search. Omitted or true uses the declaration form's defaultValue, false opens the field empty, and any other value opens it with that value. Only text, number and date fields take a value; every other field type, and date fields searched as a range, only accept true or false.`
|
|
3466
|
+
)
|
|
3461
3467
|
});
|
|
3462
3468
|
var EventFieldIdInput = z30.enum([
|
|
3463
3469
|
"trackingId",
|
|
@@ -3520,6 +3526,144 @@ var z32 = __toESM(require("zod/v4"));
|
|
|
3520
3526
|
|
|
3521
3527
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
3522
3528
|
var z31 = __toESM(require("zod/v4"));
|
|
3529
|
+
function getDynamicNameValue(field3) {
|
|
3530
|
+
const nameConfiguration = field3.configuration?.name;
|
|
3531
|
+
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
3532
|
+
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
3533
|
+
return z31.object({
|
|
3534
|
+
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
3535
|
+
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
3536
|
+
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
function getDynamicAddressFieldValue(field3) {
|
|
3540
|
+
const schema = field3.required ? AddressFieldValue : AddressFieldUpdateValue;
|
|
3541
|
+
const configIds = field3.configuration?.streetAddressForm?.map((a) => a.id) ?? [];
|
|
3542
|
+
return schema.refine((arg) => {
|
|
3543
|
+
if (!arg) {
|
|
3544
|
+
return true;
|
|
3545
|
+
}
|
|
3546
|
+
const submittedKeys = Object.keys(arg.streetLevelDetails ?? {});
|
|
3547
|
+
const invalidKeys = submittedKeys.filter((k) => !configIds.includes(k));
|
|
3548
|
+
if (invalidKeys.length) {
|
|
3549
|
+
console.log(
|
|
3550
|
+
"Invalid streetLevelDetails: unknown keys",
|
|
3551
|
+
JSON.stringify(invalidKeys, null, 2)
|
|
3552
|
+
);
|
|
3553
|
+
return false;
|
|
3554
|
+
}
|
|
3555
|
+
return true;
|
|
3556
|
+
});
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
// ../commons/src/events/FieldTypeMapping.ts
|
|
3560
|
+
function mapFieldTypeToZod(field3, actionType) {
|
|
3561
|
+
let schema;
|
|
3562
|
+
switch (field3.type) {
|
|
3563
|
+
case FieldType.FIELD_GROUP: {
|
|
3564
|
+
schema = z32.object(
|
|
3565
|
+
field3.fields.reduce((acc, subfield) => {
|
|
3566
|
+
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
3567
|
+
return acc;
|
|
3568
|
+
}, {})
|
|
3569
|
+
);
|
|
3570
|
+
break;
|
|
3571
|
+
}
|
|
3572
|
+
case FieldType.DATE:
|
|
3573
|
+
schema = PlainDate;
|
|
3574
|
+
break;
|
|
3575
|
+
case FieldType.AGE:
|
|
3576
|
+
schema = AgeValue;
|
|
3577
|
+
break;
|
|
3578
|
+
case FieldType.TIME:
|
|
3579
|
+
schema = TimeValue;
|
|
3580
|
+
break;
|
|
3581
|
+
case FieldType.EMAIL:
|
|
3582
|
+
schema = EmailValue;
|
|
3583
|
+
break;
|
|
3584
|
+
case FieldType.DATE_RANGE:
|
|
3585
|
+
schema = DateRangeFieldValue;
|
|
3586
|
+
break;
|
|
3587
|
+
case FieldType.SELECT_DATE_RANGE:
|
|
3588
|
+
schema = SelectDateRangeValue;
|
|
3589
|
+
break;
|
|
3590
|
+
case FieldType.TEXT:
|
|
3591
|
+
case FieldType.TEXTAREA:
|
|
3592
|
+
case FieldType.DIVIDER:
|
|
3593
|
+
case FieldType.BULLET_LIST:
|
|
3594
|
+
case FieldType.PAGE_HEADER:
|
|
3595
|
+
case FieldType.LOCATION:
|
|
3596
|
+
case FieldType.SELECT:
|
|
3597
|
+
case FieldType.COUNTRY:
|
|
3598
|
+
case FieldType.RADIO_GROUP:
|
|
3599
|
+
case FieldType.PARAGRAPH:
|
|
3600
|
+
case FieldType.HEADING:
|
|
3601
|
+
case FieldType.IMAGE_VIEW:
|
|
3602
|
+
case FieldType.ADMINISTRATIVE_AREA:
|
|
3603
|
+
case FieldType.FACILITY:
|
|
3604
|
+
case FieldType.OFFICE:
|
|
3605
|
+
case FieldType.PHONE:
|
|
3606
|
+
case FieldType.LINK_BUTTON:
|
|
3607
|
+
case FieldType.VERIFICATION_STATUS:
|
|
3608
|
+
case FieldType.ID:
|
|
3609
|
+
case FieldType.LOADER:
|
|
3610
|
+
case FieldType.ALPHA_HIDDEN:
|
|
3611
|
+
case FieldType.USER_ROLE:
|
|
3612
|
+
schema = field3.required ? NonEmptyTextValue : TextValue;
|
|
3613
|
+
break;
|
|
3614
|
+
case FieldType.NUMBER:
|
|
3615
|
+
schema = NumberFieldValue;
|
|
3616
|
+
break;
|
|
3617
|
+
case FieldType.NUMBER_WITH_UNIT:
|
|
3618
|
+
schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
|
|
3619
|
+
break;
|
|
3620
|
+
case FieldType.CHECKBOX:
|
|
3621
|
+
schema = CheckboxFieldValue;
|
|
3622
|
+
break;
|
|
3623
|
+
case FieldType.SIGNATURE:
|
|
3624
|
+
case FieldType.FILE:
|
|
3625
|
+
schema = FileFieldValue;
|
|
3626
|
+
break;
|
|
3627
|
+
case FieldType.FILE_WITH_OPTIONS:
|
|
3628
|
+
schema = field3.required ? FileFieldWithOptionValue.min(1) : FileFieldWithOptionValue;
|
|
3629
|
+
break;
|
|
3630
|
+
case FieldType.ADDRESS:
|
|
3631
|
+
schema = getDynamicAddressFieldValue(field3);
|
|
3632
|
+
break;
|
|
3633
|
+
case FieldType.DATA:
|
|
3634
|
+
schema = DataFieldValue;
|
|
3635
|
+
break;
|
|
3636
|
+
case FieldType.NAME:
|
|
3637
|
+
schema = actionType === ActionType.NOTIFY ? NameFieldUpdateValue : getDynamicNameValue(field3);
|
|
3638
|
+
break;
|
|
3639
|
+
case FieldType.BUTTON:
|
|
3640
|
+
schema = ButtonFieldValue;
|
|
3641
|
+
break;
|
|
3642
|
+
case FieldType.ALPHA_PRINT_BUTTON:
|
|
3643
|
+
schema = TextValue;
|
|
3644
|
+
break;
|
|
3645
|
+
case FieldType.AUTOCOMPLETE:
|
|
3646
|
+
schema = AutocompleteValue;
|
|
3647
|
+
break;
|
|
3648
|
+
case FieldType.HTTP:
|
|
3649
|
+
case FieldType.SEARCH:
|
|
3650
|
+
schema = HttpFieldUpdateValue;
|
|
3651
|
+
break;
|
|
3652
|
+
case FieldType.QUERY_PARAM_READER:
|
|
3653
|
+
schema = QueryParamReaderFieldUpdateValue;
|
|
3654
|
+
break;
|
|
3655
|
+
case FieldType.QR_READER:
|
|
3656
|
+
schema = QrReaderFieldValue;
|
|
3657
|
+
break;
|
|
3658
|
+
case FieldType.ID_READER:
|
|
3659
|
+
schema = IdReaderFieldValue;
|
|
3660
|
+
break;
|
|
3661
|
+
case FieldType._EXPERIMENTAL_CUSTOM:
|
|
3662
|
+
schema = CustomFieldValue;
|
|
3663
|
+
break;
|
|
3664
|
+
}
|
|
3665
|
+
return field3.required ? schema : schema.nullish();
|
|
3666
|
+
}
|
|
3523
3667
|
|
|
3524
3668
|
// ../commons/src/events/state/index.ts
|
|
3525
3669
|
var import_lodash3 = require("lodash");
|
|
@@ -4376,25 +4520,6 @@ function isOnline() {
|
|
|
4376
4520
|
return true;
|
|
4377
4521
|
}
|
|
4378
4522
|
|
|
4379
|
-
// ../commons/src/events/notificationFormFallback.ts
|
|
4380
|
-
function toOptionalField(field3) {
|
|
4381
|
-
const { validation: _validation, ...rest } = field3;
|
|
4382
|
-
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
4383
|
-
return {
|
|
4384
|
-
...rest,
|
|
4385
|
-
required: false,
|
|
4386
|
-
fields: rest.fields.map(toOptionalField)
|
|
4387
|
-
};
|
|
4388
|
-
}
|
|
4389
|
-
return { ...rest, required: false };
|
|
4390
|
-
}
|
|
4391
|
-
function generateNotifyReview(declareReview) {
|
|
4392
|
-
return {
|
|
4393
|
-
...declareReview,
|
|
4394
|
-
fields: declareReview.fields.map(toOptionalField)
|
|
4395
|
-
};
|
|
4396
|
-
}
|
|
4397
|
-
|
|
4398
4523
|
// ../commons/src/events/utils.ts
|
|
4399
4524
|
var import_date_fns3 = require("date-fns");
|
|
4400
4525
|
function getDeclaration(configuration) {
|
|
@@ -4414,7 +4539,7 @@ function getDeclarationPages(configuration) {
|
|
|
4414
4539
|
function getDeclarationFields(configuration) {
|
|
4415
4540
|
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
4416
4541
|
}
|
|
4417
|
-
function
|
|
4542
|
+
function findNotificationForm(configuration) {
|
|
4418
4543
|
const notifyAction = configuration.actions.find(
|
|
4419
4544
|
(action) => action.type === ActionType.NOTIFY
|
|
4420
4545
|
);
|
|
@@ -4437,10 +4562,7 @@ function getAllAnnotationFields(config) {
|
|
|
4437
4562
|
var findAllFields = (config) => {
|
|
4438
4563
|
return (0, import_lodash4.flattenDeep)([
|
|
4439
4564
|
...getDeclarationFields(config),
|
|
4440
|
-
|
|
4441
|
-
...getConfiguredNotificationForm(config)?.pages.flatMap(
|
|
4442
|
-
({ fields }) => fields
|
|
4443
|
-
) ?? [],
|
|
4565
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
4444
4566
|
...getAllAnnotationFields(config)
|
|
4445
4567
|
]);
|
|
4446
4568
|
};
|
|
@@ -4451,6 +4573,20 @@ var EXCLUDED_ACTIONS = [
|
|
|
4451
4573
|
];
|
|
4452
4574
|
|
|
4453
4575
|
// ../commons/src/events/eventConfigValidation.ts
|
|
4576
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
4577
|
+
FieldType.TEXT,
|
|
4578
|
+
FieldType.TEXTAREA,
|
|
4579
|
+
FieldType.EMAIL,
|
|
4580
|
+
FieldType.PHONE,
|
|
4581
|
+
FieldType.ID,
|
|
4582
|
+
FieldType.SELECT,
|
|
4583
|
+
FieldType.RADIO_GROUP,
|
|
4584
|
+
FieldType.COUNTRY,
|
|
4585
|
+
FieldType.LOCATION,
|
|
4586
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
4587
|
+
FieldType.NUMBER,
|
|
4588
|
+
FieldType.DATE
|
|
4589
|
+
];
|
|
4454
4590
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
4455
4591
|
const allFields = findAllFields(event2);
|
|
4456
4592
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -4482,6 +4618,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
4482
4618
|
path: ["advancedSearch"]
|
|
4483
4619
|
});
|
|
4484
4620
|
}
|
|
4621
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
4622
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
4623
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
4624
|
+
return;
|
|
4625
|
+
}
|
|
4626
|
+
const path = [
|
|
4627
|
+
"advancedSearch",
|
|
4628
|
+
sectionIndex,
|
|
4629
|
+
"fields",
|
|
4630
|
+
fieldIndex,
|
|
4631
|
+
"defaultValue"
|
|
4632
|
+
];
|
|
4633
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
4634
|
+
ctx.addIssue({
|
|
4635
|
+
code: "custom",
|
|
4636
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
4637
|
+
path
|
|
4638
|
+
});
|
|
4639
|
+
return;
|
|
4640
|
+
}
|
|
4641
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
4642
|
+
return;
|
|
4643
|
+
}
|
|
4644
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
4645
|
+
if (!formField) {
|
|
4646
|
+
return;
|
|
4647
|
+
}
|
|
4648
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
4649
|
+
(type) => type === formField.type
|
|
4650
|
+
)) {
|
|
4651
|
+
ctx.addIssue({
|
|
4652
|
+
code: "custom",
|
|
4653
|
+
message: `Advanced search field ${searchField.fieldId} is a ${formField.type} field, which does not support a defaultValue value, only true or false. Field types that support a defaultValue value: ${SEARCH_DEFAULT_VALUE_FIELD_TYPES.join(", ")}.`,
|
|
4654
|
+
path
|
|
4655
|
+
});
|
|
4656
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
4657
|
+
ctx.addIssue({
|
|
4658
|
+
code: "custom",
|
|
4659
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
4660
|
+
path
|
|
4661
|
+
});
|
|
4662
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
4663
|
+
ctx.addIssue({
|
|
4664
|
+
code: "custom",
|
|
4665
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
4666
|
+
path
|
|
4667
|
+
});
|
|
4668
|
+
}
|
|
4669
|
+
});
|
|
4670
|
+
});
|
|
4485
4671
|
}
|
|
4486
4672
|
function validateDateOfEvent(event2, ctx) {
|
|
4487
4673
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -4606,9 +4792,11 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
|
4606
4792
|
}
|
|
4607
4793
|
}
|
|
4608
4794
|
function validateNotificationForm(event2, ctx) {
|
|
4609
|
-
const declarationFields =
|
|
4795
|
+
const declarationFields = getDeclarationPages(event2).flatMap(
|
|
4796
|
+
(page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
|
|
4797
|
+
);
|
|
4610
4798
|
event2.actions.forEach((action, actionIndex) => {
|
|
4611
|
-
if (action.type !== ActionType.NOTIFY
|
|
4799
|
+
if (action.type !== ActionType.NOTIFY) {
|
|
4612
4800
|
return;
|
|
4613
4801
|
}
|
|
4614
4802
|
action.notificationForm.pages.forEach((page, pageIndex) => {
|
|
@@ -4623,7 +4811,7 @@ function validateNotificationForm(event2, ctx) {
|
|
|
4623
4811
|
fieldIndex
|
|
4624
4812
|
];
|
|
4625
4813
|
const matchingFields = declarationFields.filter(
|
|
4626
|
-
(
|
|
4814
|
+
(declarationField) => declarationField.field.id === field3.id
|
|
4627
4815
|
);
|
|
4628
4816
|
if (matchingFields.length === 0) {
|
|
4629
4817
|
ctx.addIssue({
|
|
@@ -4633,10 +4821,13 @@ function validateNotificationForm(event2, ctx) {
|
|
|
4633
4821
|
});
|
|
4634
4822
|
return;
|
|
4635
4823
|
}
|
|
4636
|
-
if (!matchingFields.some(
|
|
4824
|
+
if (!matchingFields.some(
|
|
4825
|
+
(declarationField) => declarationField.field.type === field3.type
|
|
4826
|
+
)) {
|
|
4827
|
+
const [declarationField] = matchingFields;
|
|
4637
4828
|
ctx.addIssue({
|
|
4638
4829
|
code: "custom",
|
|
4639
|
-
message: `Notification form field '${field3.id}' is of type ${field3.type}, but the declaration form field with the same id in event '${event2.id}' is of type ${
|
|
4830
|
+
message: `Notification form field '${field3.id}' on page '${page.id}' is of type ${field3.type}, but the declaration form field with the same id in event '${event2.id}' (${ActionType.DECLARE} declaration, page '${declarationField.pageId}') is of type ${declarationField.field.type}.`,
|
|
4640
4831
|
path
|
|
4641
4832
|
});
|
|
4642
4833
|
}
|
|
@@ -4775,7 +4966,7 @@ function createSearchConfig(baseField) {
|
|
|
4775
4966
|
|
|
4776
4967
|
// ../commons/src/event-config/event-configuration.ts
|
|
4777
4968
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
4778
|
-
return !EventFieldIdInput.
|
|
4969
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
4779
4970
|
}
|
|
4780
4971
|
function createEventFieldConfig(fieldId) {
|
|
4781
4972
|
const baseField = {
|
|
@@ -5106,6 +5297,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
5106
5297
|
var NotifyActionInput = BaseActionInput.extend(
|
|
5107
5298
|
z39.object({
|
|
5108
5299
|
type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
|
|
5300
|
+
declaration: BaseActionInput.shape.declaration.describe(
|
|
5301
|
+
"Values for fields of the notification form, keyed by field id. Fields outside the notification form are rejected. Only these values become part of the record declaration, so any id that needs to be searchable must be a declaration field."
|
|
5302
|
+
),
|
|
5303
|
+
annotation: BaseActionInput.shape.annotation.describe(
|
|
5304
|
+
"Values for notify-only fields (NOTIFY review and form fields), keyed by field id. These are stored on the NOTIFY action, not in the record declaration."
|
|
5305
|
+
),
|
|
5109
5306
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
5110
5307
|
createdAtLocation: UUID.nullish().describe(
|
|
5111
5308
|
"A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
|
|
@@ -5348,57 +5545,44 @@ function moveDeclarationToDeclareAction({
|
|
|
5348
5545
|
)
|
|
5349
5546
|
};
|
|
5350
5547
|
}
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
(
|
|
5354
|
-
);
|
|
5355
|
-
const notifyAction = config.actions.find(
|
|
5356
|
-
(action) => action.type === ActionType.NOTIFY
|
|
5357
|
-
);
|
|
5358
|
-
if (!notifyAction?.notificationForm) {
|
|
5359
|
-
console.warn(
|
|
5360
|
-
`Event '${config.id}' has no ${ActionType.NOTIFY} form. Using the ${ActionType.DECLARE} form with all fields optional. Configure \`actions[${ActionType.NOTIFY}].notificationForm\`. This fallback will be removed in a future release.`
|
|
5361
|
-
);
|
|
5362
|
-
}
|
|
5363
|
-
if (notifyAction?.review) {
|
|
5364
|
-
return config;
|
|
5365
|
-
}
|
|
5366
|
-
if (!declareAction?.declaration) {
|
|
5367
|
-
throw new Error(
|
|
5368
|
-
`Event '${config.id}' has no ${ActionType.DECLARE} form. Configure \`actions[${ActionType.DECLARE}].declaration\`.`
|
|
5369
|
-
);
|
|
5548
|
+
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
5549
|
+
if (validateExactlyOneDeclareAction(config, ctx)) {
|
|
5550
|
+
validateDeclarationGivenExactlyOnce(config, ctx);
|
|
5370
5551
|
}
|
|
5371
|
-
|
|
5372
|
-
|
|
5552
|
+
}).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
|
|
5553
|
+
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
5554
|
+
|
|
5555
|
+
// ../commons/src/events/toNotificationForm.ts
|
|
5556
|
+
function toOptionalField(field3) {
|
|
5557
|
+
const { validation: _validation, ...rest } = field3;
|
|
5558
|
+
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
5373
5559
|
return {
|
|
5374
|
-
...
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
)
|
|
5560
|
+
...rest,
|
|
5561
|
+
required: false,
|
|
5562
|
+
fields: rest.fields.map(toOptionalField)
|
|
5378
5563
|
};
|
|
5379
5564
|
}
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5565
|
+
return { ...rest, required: false };
|
|
5566
|
+
}
|
|
5567
|
+
function toNotificationForm(declaration) {
|
|
5568
|
+
return {
|
|
5569
|
+
...declaration,
|
|
5570
|
+
pages: declaration.pages.map((page) => ({
|
|
5571
|
+
...page,
|
|
5572
|
+
fields: page.fields.map(
|
|
5573
|
+
toOptionalField
|
|
5574
|
+
)
|
|
5575
|
+
}))
|
|
5388
5576
|
};
|
|
5577
|
+
}
|
|
5578
|
+
function toNotificationReview(review) {
|
|
5389
5579
|
return {
|
|
5390
|
-
...
|
|
5391
|
-
|
|
5392
|
-
|
|
5580
|
+
...review,
|
|
5581
|
+
fields: review.fields.map(
|
|
5582
|
+
toOptionalField
|
|
5393
5583
|
)
|
|
5394
5584
|
};
|
|
5395
5585
|
}
|
|
5396
|
-
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
5397
|
-
if (validateExactlyOneDeclareAction(config, ctx)) {
|
|
5398
|
-
validateDeclarationGivenExactlyOnce(config, ctx);
|
|
5399
|
-
}
|
|
5400
|
-
}).transform(moveDeclarationToDeclareAction).transform(generateNotificationFormFallback).pipe(EventConfig);
|
|
5401
|
-
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
5402
5586
|
|
|
5403
5587
|
// ../commons/src/events/test.utils.ts
|
|
5404
5588
|
var import_lodash5 = require("lodash");
|
|
@@ -6707,6 +6891,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
6707
6891
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
6708
6892
|
id: "event.tennis-club-membership.action.notify.label"
|
|
6709
6893
|
},
|
|
6894
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
6895
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
6710
6896
|
flags: [
|
|
6711
6897
|
{
|
|
6712
6898
|
id: "health-worker-notified",
|