@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
package/dist/events/index.js
CHANGED
|
@@ -339,6 +339,7 @@ __export(events_exports, {
|
|
|
339
339
|
getActionAnnotation: () => getActionAnnotation,
|
|
340
340
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
|
341
341
|
getActionConfig: () => getActionConfig,
|
|
342
|
+
getActionForm: () => getActionForm,
|
|
342
343
|
getActionFormFields: () => getActionFormFields,
|
|
343
344
|
getActionReview: () => getActionReview,
|
|
344
345
|
getActionReviewFields: () => getActionReviewFields,
|
|
@@ -379,10 +380,12 @@ __export(events_exports, {
|
|
|
379
380
|
hasAnyOfScopes: () => hasAnyOfScopes,
|
|
380
381
|
isActionAvailable: () => isActionAvailable,
|
|
381
382
|
isActionConfigType: () => isActionConfigType,
|
|
383
|
+
isActionDocument: () => isActionDocument,
|
|
382
384
|
isActionEnabled: () => isActionEnabled,
|
|
383
385
|
isActionInScope: () => isActionInScope,
|
|
384
386
|
isActionVisible: () => isActionVisible,
|
|
385
387
|
isAddressFieldType: () => isAddressFieldType,
|
|
388
|
+
isAddressFieldValue: () => isAddressFieldValue,
|
|
386
389
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
|
387
390
|
isAgeFieldType: () => isAgeFieldType,
|
|
388
391
|
isAutocompleteFieldType: () => isAutocompleteFieldType,
|
|
@@ -397,6 +400,7 @@ __export(events_exports, {
|
|
|
397
400
|
isDateFieldType: () => isDateFieldType,
|
|
398
401
|
isDateRangeFieldType: () => isDateRangeFieldType,
|
|
399
402
|
isDividerFieldType: () => isDividerFieldType,
|
|
403
|
+
isDomesticAddressFieldValue: () => isDomesticAddressFieldValue,
|
|
400
404
|
isEmailFieldType: () => isEmailFieldType,
|
|
401
405
|
isEventFieldReference: () => isEventFieldReference,
|
|
402
406
|
isFacilityFieldType: () => isFacilityFieldType,
|
|
@@ -410,7 +414,9 @@ __export(events_exports, {
|
|
|
410
414
|
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
|
411
415
|
isFieldVisible: () => isFieldVisible,
|
|
412
416
|
isFileFieldType: () => isFileFieldType,
|
|
417
|
+
isFileFieldValue: () => isFileFieldValue,
|
|
413
418
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
|
419
|
+
isFileFieldWithOptionValue: () => isFileFieldWithOptionValue,
|
|
414
420
|
isHeadingFieldType: () => isHeadingFieldType,
|
|
415
421
|
isHiddenFieldType: () => isHiddenFieldType,
|
|
416
422
|
isHttpFieldType: () => isHttpFieldType,
|
|
@@ -431,6 +437,7 @@ __export(events_exports, {
|
|
|
431
437
|
isPageVisible: () => isPageVisible,
|
|
432
438
|
isParagraphFieldType: () => isParagraphFieldType,
|
|
433
439
|
isPhoneFieldType: () => isPhoneFieldType,
|
|
440
|
+
isPlainDate: () => isPlainDate,
|
|
434
441
|
isPotentialDuplicate: () => isPotentialDuplicate,
|
|
435
442
|
isPrintButtonFieldType: () => isPrintButtonFieldType,
|
|
436
443
|
isQrReaderFieldType: () => isQrReaderFieldType,
|
|
@@ -479,6 +486,8 @@ __export(events_exports, {
|
|
|
479
486
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
|
480
487
|
toClientAdministrativeArea: () => toClientAdministrativeArea,
|
|
481
488
|
toClientLocation: () => toClientLocation,
|
|
489
|
+
toNotificationForm: () => toNotificationForm,
|
|
490
|
+
toNotificationReview: () => toNotificationReview,
|
|
482
491
|
toPlainDate: () => toPlainDate,
|
|
483
492
|
todayISO: () => todayISO,
|
|
484
493
|
user: () => user,
|
|
@@ -492,6 +501,9 @@ __export(events_exports, {
|
|
|
492
501
|
});
|
|
493
502
|
module.exports = __toCommonJS(events_exports);
|
|
494
503
|
|
|
504
|
+
// ../commons/src/events/index.ts
|
|
505
|
+
var import_compile = require("zod/compile");
|
|
506
|
+
|
|
495
507
|
// ../commons/src/events/AuditLog.ts
|
|
496
508
|
var z9 = __toESM(require("zod/v4"));
|
|
497
509
|
|
|
@@ -510,6 +522,12 @@ var UUID = z.uuid().brand("UUID");
|
|
|
510
522
|
function getUUID() {
|
|
511
523
|
return (0, import_uuid.v4)();
|
|
512
524
|
}
|
|
525
|
+
function isUUID(id) {
|
|
526
|
+
return UUID.validate(id);
|
|
527
|
+
}
|
|
528
|
+
function maybeUuid(value) {
|
|
529
|
+
return isUUID(value) ? value : void 0;
|
|
530
|
+
}
|
|
513
531
|
|
|
514
532
|
// ../commons/src/events/ActionType.ts
|
|
515
533
|
var z2 = __toESM(require("zod/v4"));
|
|
@@ -641,7 +659,7 @@ var ActionStatus = {
|
|
|
641
659
|
};
|
|
642
660
|
|
|
643
661
|
// ../commons/src/events/Flag.ts
|
|
644
|
-
var z5 = __toESM(require("zod
|
|
662
|
+
var z5 = __toESM(require("zod"));
|
|
645
663
|
|
|
646
664
|
// ../commons/src/events/TranslationConfig.ts
|
|
647
665
|
var z3 = __toESM(require("zod/v4"));
|
|
@@ -737,7 +755,7 @@ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).inclu
|
|
|
737
755
|
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
738
756
|
InherentFlags
|
|
739
757
|
).join(", ")}`
|
|
740
|
-
}).refine((val) => !ActionFlag.
|
|
758
|
+
}).refine((val) => !ActionFlag.validate(val), {
|
|
741
759
|
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
742
760
|
}).describe("Custom flag identifier defined by the country config.");
|
|
743
761
|
var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
|
|
@@ -1510,7 +1528,7 @@ var z14 = __toESM(require("zod/v4"));
|
|
|
1510
1528
|
// ../commons/src/documents.ts
|
|
1511
1529
|
var z11 = __toESM(require("zod/v4"));
|
|
1512
1530
|
var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
|
|
1513
|
-
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://
|
|
1531
|
+
"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"
|
|
1514
1532
|
);
|
|
1515
1533
|
var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
|
|
1516
1534
|
"A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
|
|
@@ -1520,7 +1538,7 @@ var DocumentPath = z11.string().brand("DocumentPath").describe(
|
|
|
1520
1538
|
);
|
|
1521
1539
|
|
|
1522
1540
|
// ../commons/src/events/CompositeFieldValue.ts
|
|
1523
|
-
var z12 = __toESM(require("zod
|
|
1541
|
+
var z12 = __toESM(require("zod"));
|
|
1524
1542
|
var GeographicalArea = {
|
|
1525
1543
|
URBAN: "URBAN",
|
|
1526
1544
|
RURAL: "RURAL"
|
|
@@ -1534,6 +1552,9 @@ var FileFieldValue = z12.object({
|
|
|
1534
1552
|
originalFilename: z12.string(),
|
|
1535
1553
|
type: z12.string()
|
|
1536
1554
|
});
|
|
1555
|
+
function isFileFieldValue(value) {
|
|
1556
|
+
return FileFieldValue.validate(value);
|
|
1557
|
+
}
|
|
1537
1558
|
var NameFieldValue = z12.object({
|
|
1538
1559
|
firstname: z12.string(),
|
|
1539
1560
|
surname: z12.string(),
|
|
@@ -1558,6 +1579,9 @@ var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
|
|
|
1558
1579
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1559
1580
|
administrativeArea: z12.string().uuid()
|
|
1560
1581
|
});
|
|
1582
|
+
function isDomesticAddressFieldValue(value) {
|
|
1583
|
+
return DomesticAddressFieldValue.validate(value);
|
|
1584
|
+
}
|
|
1561
1585
|
var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
|
|
1562
1586
|
addressType: z12.literal(AddressType.INTERNATIONAL)
|
|
1563
1587
|
});
|
|
@@ -1565,6 +1589,9 @@ var AddressFieldValue = z12.discriminatedUnion("addressType", [
|
|
|
1565
1589
|
DomesticAddressFieldValue,
|
|
1566
1590
|
InternationalAddressFieldValue
|
|
1567
1591
|
]);
|
|
1592
|
+
function isAddressFieldValue(value) {
|
|
1593
|
+
return AddressFieldValue.validate(value);
|
|
1594
|
+
}
|
|
1568
1595
|
var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
|
|
1569
1596
|
addressType: z12.literal(AddressType.DOMESTIC),
|
|
1570
1597
|
administrativeArea: z12.string().uuid().nullish()
|
|
@@ -1586,6 +1613,9 @@ var FileFieldValueWithOption = z12.object({
|
|
|
1586
1613
|
option: z12.string()
|
|
1587
1614
|
});
|
|
1588
1615
|
var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
|
|
1616
|
+
function isFileFieldWithOptionValue(value) {
|
|
1617
|
+
return FileFieldWithOptionValue.validate(value);
|
|
1618
|
+
}
|
|
1589
1619
|
var HttpFieldValue = z12.object({
|
|
1590
1620
|
loading: z12.boolean(),
|
|
1591
1621
|
error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
|
|
@@ -1621,6 +1651,7 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
|
|
|
1621
1651
|
// ../commons/src/events/PlainDate.ts
|
|
1622
1652
|
var import_zod = require("zod");
|
|
1623
1653
|
var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
|
|
1654
|
+
var isPlainDate = (date) => PlainDate.validate(date);
|
|
1624
1655
|
function toPlainDate(dateTime) {
|
|
1625
1656
|
return dateTime.split("T")[0];
|
|
1626
1657
|
}
|
|
@@ -1736,7 +1767,7 @@ function safeUnion(schemas) {
|
|
|
1736
1767
|
);
|
|
1737
1768
|
return z14.any().superRefine((val, ctx) => {
|
|
1738
1769
|
for (const schema of sortedSchemas) {
|
|
1739
|
-
if (schema.
|
|
1770
|
+
if (schema.validate(val)) {
|
|
1740
1771
|
return;
|
|
1741
1772
|
}
|
|
1742
1773
|
}
|
|
@@ -2025,6 +2056,7 @@ var ActionDocument = z16.discriminatedUnion("type", [
|
|
|
2025
2056
|
]).meta({
|
|
2026
2057
|
id: "ActionDocument"
|
|
2027
2058
|
});
|
|
2059
|
+
var isActionDocument = (a) => ActionDocument.validate(a);
|
|
2028
2060
|
var AsyncRejectActionDocument = ActionBase.omit({
|
|
2029
2061
|
declaration: true,
|
|
2030
2062
|
annotation: true
|
|
@@ -3517,11 +3549,11 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
3517
3549
|
var NotifyConfig = ActionConfigBase.extend(
|
|
3518
3550
|
z25.object({
|
|
3519
3551
|
type: z25.literal(ActionType.NOTIFY),
|
|
3520
|
-
notificationForm: DeclarationFormConfig.
|
|
3521
|
-
"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.
|
|
3552
|
+
notificationForm: DeclarationFormConfig.describe(
|
|
3553
|
+
"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."
|
|
3522
3554
|
),
|
|
3523
3555
|
review: DeclarationReviewConfig.describe(
|
|
3524
|
-
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation.
|
|
3556
|
+
"Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation."
|
|
3525
3557
|
),
|
|
3526
3558
|
form: actionConfirmationForm
|
|
3527
3559
|
}).shape
|
|
@@ -4067,7 +4099,10 @@ var SearchQueryParams = z30.object({
|
|
|
4067
4099
|
}).catchall(FieldValue);
|
|
4068
4100
|
var FieldConfigSchema = BaseField3.extend({
|
|
4069
4101
|
fieldId: z30.string(),
|
|
4070
|
-
fieldType: z30.literal("field")
|
|
4102
|
+
fieldType: z30.literal("field"),
|
|
4103
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
4104
|
+
`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.`
|
|
4105
|
+
)
|
|
4071
4106
|
});
|
|
4072
4107
|
var EventFieldIdInput = z30.enum([
|
|
4073
4108
|
"trackingId",
|
|
@@ -5547,35 +5582,24 @@ function resolveDateOfEvent(eventIndex, declaration, config) {
|
|
|
5547
5582
|
if (!config.dateOfEvent) {
|
|
5548
5583
|
return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
|
|
5549
5584
|
}
|
|
5550
|
-
|
|
5551
|
-
|
|
5585
|
+
if (isFieldReference(config.dateOfEvent)) {
|
|
5586
|
+
const fieldDate = declaration[config.dateOfEvent.$$field];
|
|
5587
|
+
return ZodDate.validate(fieldDate) ? extractDateString(fieldDate) : void 0;
|
|
5588
|
+
}
|
|
5589
|
+
const eventDate = getMixedPath(
|
|
5590
|
+
eventIndex,
|
|
5591
|
+
config.dateOfEvent.$$event
|
|
5552
5592
|
);
|
|
5553
|
-
return
|
|
5593
|
+
return ZodDateTime.validate(eventDate) ? extractDateString(eventDate) : void 0;
|
|
5554
5594
|
}
|
|
5555
5595
|
var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
|
|
5556
|
-
function getParsedUUID(value, oldValue) {
|
|
5557
|
-
const parsed = UUID.safeParse(value);
|
|
5558
|
-
return parsed.success ? parsed.data : oldValue;
|
|
5559
|
-
}
|
|
5560
5596
|
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
5561
|
-
let placeOfEvent =
|
|
5597
|
+
let placeOfEvent = maybeUuid(
|
|
5562
5598
|
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
5563
5599
|
);
|
|
5564
5600
|
if (config.placeOfEvent) {
|
|
5565
|
-
const addressFieldValue =
|
|
5566
|
-
|
|
5567
|
-
);
|
|
5568
|
-
if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
|
|
5569
|
-
placeOfEvent = getParsedUUID(
|
|
5570
|
-
addressFieldValue.data.administrativeArea,
|
|
5571
|
-
placeOfEvent
|
|
5572
|
-
);
|
|
5573
|
-
} else {
|
|
5574
|
-
placeOfEvent = getParsedUUID(
|
|
5575
|
-
declaration[config.placeOfEvent.$$field],
|
|
5576
|
-
placeOfEvent
|
|
5577
|
-
);
|
|
5578
|
-
}
|
|
5601
|
+
const addressFieldValue = declaration[config.placeOfEvent.$$field];
|
|
5602
|
+
placeOfEvent = isDomesticAddressFieldValue(addressFieldValue) ? maybeUuid(addressFieldValue.administrativeArea) ?? placeOfEvent : maybeUuid(declaration[config.placeOfEvent.$$field]) ?? placeOfEvent;
|
|
5579
5603
|
}
|
|
5580
5604
|
return placeOfEvent;
|
|
5581
5605
|
}
|
|
@@ -5860,7 +5884,7 @@ function precompileActionSchemas(eventConfigurations) {
|
|
|
5860
5884
|
}
|
|
5861
5885
|
}
|
|
5862
5886
|
function isAgeValue(value) {
|
|
5863
|
-
return
|
|
5887
|
+
return AgeValue.validate(value);
|
|
5864
5888
|
}
|
|
5865
5889
|
function mergeWithBaseFormState(values, context) {
|
|
5866
5890
|
return { ...context.baseFormState, ...values };
|
|
@@ -5890,15 +5914,13 @@ function validate(schema, data) {
|
|
|
5890
5914
|
return [key, value];
|
|
5891
5915
|
}
|
|
5892
5916
|
const age = value.age;
|
|
5893
|
-
const
|
|
5917
|
+
const asOf = data.$form[value.asOfDateRef];
|
|
5918
|
+
const asOfDate = isPlainDate(asOf) ? asOf : PlainDate.parse(data.$now);
|
|
5894
5919
|
return [
|
|
5895
5920
|
key,
|
|
5896
5921
|
{
|
|
5897
5922
|
age,
|
|
5898
|
-
dob: ageToDate(
|
|
5899
|
-
age,
|
|
5900
|
-
maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
|
|
5901
|
-
)
|
|
5923
|
+
dob: ageToDate(age, asOfDate)
|
|
5902
5924
|
}
|
|
5903
5925
|
];
|
|
5904
5926
|
});
|
|
@@ -6061,6 +6083,11 @@ var errorMessages = {
|
|
|
6061
6083
|
description: "Error message when field is not expected",
|
|
6062
6084
|
id: "error.unexpectedField"
|
|
6063
6085
|
},
|
|
6086
|
+
notInNotifyForm: {
|
|
6087
|
+
defaultMessage: "Field is not part of the notify form. Notify-only data belongs in annotation",
|
|
6088
|
+
description: "Error message when a notify declaration contains a field outside the notify form",
|
|
6089
|
+
id: "error.notInNotifyForm"
|
|
6090
|
+
},
|
|
6064
6091
|
correctionNotAllowed: {
|
|
6065
6092
|
defaultMessage: "Correction not allowed for field",
|
|
6066
6093
|
description: "Error message when correction is not allowed for field",
|
|
@@ -6274,34 +6301,6 @@ function areCertificateConditionsMet(conditions, values) {
|
|
|
6274
6301
|
});
|
|
6275
6302
|
}
|
|
6276
6303
|
|
|
6277
|
-
// ../commons/src/events/notificationFormFallback.ts
|
|
6278
|
-
function toOptionalField(field3) {
|
|
6279
|
-
const { validation: _validation, ...rest } = field3;
|
|
6280
|
-
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
6281
|
-
return {
|
|
6282
|
-
...rest,
|
|
6283
|
-
required: false,
|
|
6284
|
-
fields: rest.fields.map(toOptionalField)
|
|
6285
|
-
};
|
|
6286
|
-
}
|
|
6287
|
-
return { ...rest, required: false };
|
|
6288
|
-
}
|
|
6289
|
-
function deriveNotificationForm(declaration) {
|
|
6290
|
-
return {
|
|
6291
|
-
...declaration,
|
|
6292
|
-
pages: declaration.pages.map((page) => ({
|
|
6293
|
-
...page,
|
|
6294
|
-
fields: page.fields.map(toOptionalField)
|
|
6295
|
-
}))
|
|
6296
|
-
};
|
|
6297
|
-
}
|
|
6298
|
-
function generateNotifyReview(declareReview) {
|
|
6299
|
-
return {
|
|
6300
|
-
...declareReview,
|
|
6301
|
-
fields: declareReview.fields.map(toOptionalField)
|
|
6302
|
-
};
|
|
6303
|
-
}
|
|
6304
|
-
|
|
6305
6304
|
// ../commons/src/events/utils.ts
|
|
6306
6305
|
var import_date_fns3 = require("date-fns");
|
|
6307
6306
|
function ageToDate(age, asOfDate) {
|
|
@@ -6325,31 +6324,29 @@ function getDeclarationPages(configuration) {
|
|
|
6325
6324
|
function getDeclarationFields(configuration) {
|
|
6326
6325
|
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
6327
6326
|
}
|
|
6328
|
-
function
|
|
6327
|
+
function findNotificationForm(configuration) {
|
|
6329
6328
|
const notifyAction = configuration.actions.find(
|
|
6330
6329
|
(action) => action.type === ActionType.NOTIFY
|
|
6331
6330
|
);
|
|
6332
6331
|
return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
|
|
6333
6332
|
}
|
|
6334
|
-
var derivedNotificationForms = /* @__PURE__ */ new WeakMap();
|
|
6335
6333
|
function getNotificationForm(configuration) {
|
|
6336
|
-
const
|
|
6337
|
-
if (
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
if (cached) {
|
|
6342
|
-
return cached;
|
|
6334
|
+
const notificationForm = findNotificationForm(configuration);
|
|
6335
|
+
if (!notificationForm) {
|
|
6336
|
+
throw new Error(
|
|
6337
|
+
`Event '${configuration.id}' has no ${ActionType.NOTIFY} action.`
|
|
6338
|
+
);
|
|
6343
6339
|
}
|
|
6344
|
-
|
|
6345
|
-
derivedNotificationForms.set(configuration, derived);
|
|
6346
|
-
return derived;
|
|
6340
|
+
return notificationForm;
|
|
6347
6341
|
}
|
|
6348
6342
|
function getNotificationFields(configuration) {
|
|
6349
6343
|
return getNotificationForm(configuration).pages.flatMap(
|
|
6350
6344
|
({ fields }) => fields
|
|
6351
6345
|
);
|
|
6352
6346
|
}
|
|
6347
|
+
function getActionForm(configuration, actionType) {
|
|
6348
|
+
return actionType === ActionType.NOTIFY ? getNotificationForm(configuration) : getDeclaration(configuration);
|
|
6349
|
+
}
|
|
6353
6350
|
function isActionConfigType(type) {
|
|
6354
6351
|
return actionConfigTypes.has(type);
|
|
6355
6352
|
}
|
|
@@ -6605,15 +6602,12 @@ function flattenFieldReference(ref) {
|
|
|
6605
6602
|
return [ref.$$field, ...ref.$$subfield];
|
|
6606
6603
|
}
|
|
6607
6604
|
function isWriteAction(actionType) {
|
|
6608
|
-
return writeActions.
|
|
6605
|
+
return writeActions.validate(actionType);
|
|
6609
6606
|
}
|
|
6610
6607
|
var findAllFields = (config) => {
|
|
6611
6608
|
return (0, import_lodash4.flattenDeep)([
|
|
6612
6609
|
...getDeclarationFields(config),
|
|
6613
|
-
|
|
6614
|
-
...getConfiguredNotificationForm(config)?.pages.flatMap(
|
|
6615
|
-
({ fields }) => fields
|
|
6616
|
-
) ?? [],
|
|
6610
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
6617
6611
|
...getAllAnnotationFields(config)
|
|
6618
6612
|
]);
|
|
6619
6613
|
};
|
|
@@ -6853,6 +6847,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
|
|
|
6853
6847
|
}
|
|
6854
6848
|
|
|
6855
6849
|
// ../commons/src/events/eventConfigValidation.ts
|
|
6850
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
6851
|
+
FieldType.TEXT,
|
|
6852
|
+
FieldType.TEXTAREA,
|
|
6853
|
+
FieldType.EMAIL,
|
|
6854
|
+
FieldType.PHONE,
|
|
6855
|
+
FieldType.ID,
|
|
6856
|
+
FieldType.SELECT,
|
|
6857
|
+
FieldType.RADIO_GROUP,
|
|
6858
|
+
FieldType.COUNTRY,
|
|
6859
|
+
FieldType.LOCATION,
|
|
6860
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
6861
|
+
FieldType.NUMBER,
|
|
6862
|
+
FieldType.DATE
|
|
6863
|
+
];
|
|
6856
6864
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
6857
6865
|
const allFields = findAllFields(event2);
|
|
6858
6866
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -6884,6 +6892,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
6884
6892
|
path: ["advancedSearch"]
|
|
6885
6893
|
});
|
|
6886
6894
|
}
|
|
6895
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
6896
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
6897
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
6898
|
+
return;
|
|
6899
|
+
}
|
|
6900
|
+
const path = [
|
|
6901
|
+
"advancedSearch",
|
|
6902
|
+
sectionIndex,
|
|
6903
|
+
"fields",
|
|
6904
|
+
fieldIndex,
|
|
6905
|
+
"defaultValue"
|
|
6906
|
+
];
|
|
6907
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
6908
|
+
ctx.addIssue({
|
|
6909
|
+
code: "custom",
|
|
6910
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
6911
|
+
path
|
|
6912
|
+
});
|
|
6913
|
+
return;
|
|
6914
|
+
}
|
|
6915
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
6916
|
+
return;
|
|
6917
|
+
}
|
|
6918
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
6919
|
+
if (!formField) {
|
|
6920
|
+
return;
|
|
6921
|
+
}
|
|
6922
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
6923
|
+
(type) => type === formField.type
|
|
6924
|
+
)) {
|
|
6925
|
+
ctx.addIssue({
|
|
6926
|
+
code: "custom",
|
|
6927
|
+
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(", ")}.`,
|
|
6928
|
+
path
|
|
6929
|
+
});
|
|
6930
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
6931
|
+
ctx.addIssue({
|
|
6932
|
+
code: "custom",
|
|
6933
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
6934
|
+
path
|
|
6935
|
+
});
|
|
6936
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
6937
|
+
ctx.addIssue({
|
|
6938
|
+
code: "custom",
|
|
6939
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
6940
|
+
path
|
|
6941
|
+
});
|
|
6942
|
+
}
|
|
6943
|
+
});
|
|
6944
|
+
});
|
|
6887
6945
|
}
|
|
6888
6946
|
function validateDateOfEvent(event2, ctx) {
|
|
6889
6947
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -7008,9 +7066,11 @@ function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
|
7008
7066
|
}
|
|
7009
7067
|
}
|
|
7010
7068
|
function validateNotificationForm(event2, ctx) {
|
|
7011
|
-
const declarationFields =
|
|
7069
|
+
const declarationFields = getDeclarationPages(event2).flatMap(
|
|
7070
|
+
(page) => page.fields.map((field3) => ({ field: field3, pageId: page.id }))
|
|
7071
|
+
);
|
|
7012
7072
|
event2.actions.forEach((action, actionIndex) => {
|
|
7013
|
-
if (action.type !== ActionType.NOTIFY
|
|
7073
|
+
if (action.type !== ActionType.NOTIFY) {
|
|
7014
7074
|
return;
|
|
7015
7075
|
}
|
|
7016
7076
|
action.notificationForm.pages.forEach((page, pageIndex) => {
|
|
@@ -7025,7 +7085,7 @@ function validateNotificationForm(event2, ctx) {
|
|
|
7025
7085
|
fieldIndex
|
|
7026
7086
|
];
|
|
7027
7087
|
const matchingFields = declarationFields.filter(
|
|
7028
|
-
(
|
|
7088
|
+
(declarationField) => declarationField.field.id === field3.id
|
|
7029
7089
|
);
|
|
7030
7090
|
if (matchingFields.length === 0) {
|
|
7031
7091
|
ctx.addIssue({
|
|
@@ -7035,10 +7095,13 @@ function validateNotificationForm(event2, ctx) {
|
|
|
7035
7095
|
});
|
|
7036
7096
|
return;
|
|
7037
7097
|
}
|
|
7038
|
-
if (!matchingFields.some(
|
|
7098
|
+
if (!matchingFields.some(
|
|
7099
|
+
(declarationField) => declarationField.field.type === field3.type
|
|
7100
|
+
)) {
|
|
7101
|
+
const [declarationField] = matchingFields;
|
|
7039
7102
|
ctx.addIssue({
|
|
7040
7103
|
code: "custom",
|
|
7041
|
-
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 ${
|
|
7104
|
+
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}.`,
|
|
7042
7105
|
path
|
|
7043
7106
|
});
|
|
7044
7107
|
}
|
|
@@ -7178,7 +7241,7 @@ function createSearchConfig(baseField) {
|
|
|
7178
7241
|
|
|
7179
7242
|
// ../commons/src/event-config/event-configuration.ts
|
|
7180
7243
|
function isNonSearchableEventMetadataTimeFieldId(fieldId) {
|
|
7181
|
-
return !EventFieldIdInput.
|
|
7244
|
+
return !EventFieldIdInput.validate(fieldId);
|
|
7182
7245
|
}
|
|
7183
7246
|
function createEventFieldConfig(fieldId) {
|
|
7184
7247
|
const baseField = {
|
|
@@ -7530,6 +7593,12 @@ var RegisterActionInput = BaseActionInput.extend(
|
|
|
7530
7593
|
var NotifyActionInput = BaseActionInput.extend(
|
|
7531
7594
|
z39.object({
|
|
7532
7595
|
type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
|
|
7596
|
+
declaration: BaseActionInput.shape.declaration.describe(
|
|
7597
|
+
"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."
|
|
7598
|
+
),
|
|
7599
|
+
annotation: BaseActionInput.shape.annotation.describe(
|
|
7600
|
+
"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."
|
|
7601
|
+
),
|
|
7533
7602
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
7534
7603
|
createdAtLocation: UUID.nullish().describe(
|
|
7535
7604
|
"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."
|
|
@@ -7772,57 +7841,44 @@ function moveDeclarationToDeclareAction({
|
|
|
7772
7841
|
)
|
|
7773
7842
|
};
|
|
7774
7843
|
}
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
(
|
|
7778
|
-
);
|
|
7779
|
-
const notifyAction = config.actions.find(
|
|
7780
|
-
(action) => action.type === ActionType.NOTIFY
|
|
7781
|
-
);
|
|
7782
|
-
if (!notifyAction?.notificationForm) {
|
|
7783
|
-
console.warn(
|
|
7784
|
-
`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.`
|
|
7785
|
-
);
|
|
7786
|
-
}
|
|
7787
|
-
if (notifyAction?.review) {
|
|
7788
|
-
return config;
|
|
7789
|
-
}
|
|
7790
|
-
if (!declareAction?.declaration) {
|
|
7791
|
-
throw new Error(
|
|
7792
|
-
`Event '${config.id}' has no ${ActionType.DECLARE} form. Configure \`actions[${ActionType.DECLARE}].declaration\`.`
|
|
7793
|
-
);
|
|
7844
|
+
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
7845
|
+
if (validateExactlyOneDeclareAction(config, ctx)) {
|
|
7846
|
+
validateDeclarationGivenExactlyOnce(config, ctx);
|
|
7794
7847
|
}
|
|
7795
|
-
|
|
7796
|
-
|
|
7848
|
+
}).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
|
|
7849
|
+
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
7850
|
+
|
|
7851
|
+
// ../commons/src/events/toNotificationForm.ts
|
|
7852
|
+
function toOptionalField(field3) {
|
|
7853
|
+
const { validation: _validation, ...rest } = field3;
|
|
7854
|
+
if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
|
|
7797
7855
|
return {
|
|
7798
|
-
...
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
)
|
|
7856
|
+
...rest,
|
|
7857
|
+
required: false,
|
|
7858
|
+
fields: rest.fields.map(toOptionalField)
|
|
7802
7859
|
};
|
|
7803
7860
|
}
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7861
|
+
return { ...rest, required: false };
|
|
7862
|
+
}
|
|
7863
|
+
function toNotificationForm(declaration) {
|
|
7864
|
+
return {
|
|
7865
|
+
...declaration,
|
|
7866
|
+
pages: declaration.pages.map((page) => ({
|
|
7867
|
+
...page,
|
|
7868
|
+
fields: page.fields.map(
|
|
7869
|
+
toOptionalField
|
|
7870
|
+
)
|
|
7871
|
+
}))
|
|
7812
7872
|
};
|
|
7873
|
+
}
|
|
7874
|
+
function toNotificationReview(review) {
|
|
7813
7875
|
return {
|
|
7814
|
-
...
|
|
7815
|
-
|
|
7816
|
-
|
|
7876
|
+
...review,
|
|
7877
|
+
fields: review.fields.map(
|
|
7878
|
+
toOptionalField
|
|
7817
7879
|
)
|
|
7818
7880
|
};
|
|
7819
7881
|
}
|
|
7820
|
-
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
7821
|
-
if (validateExactlyOneDeclareAction(config, ctx)) {
|
|
7822
|
-
validateDeclarationGivenExactlyOnce(config, ctx);
|
|
7823
|
-
}
|
|
7824
|
-
}).transform(moveDeclarationToDeclareAction).transform(generateNotificationFormFallback).pipe(EventConfig);
|
|
7825
|
-
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
7826
7882
|
|
|
7827
7883
|
// ../commons/src/events/transactions.ts
|
|
7828
7884
|
function generateTransactionId() {
|
|
@@ -9139,6 +9195,8 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
9139
9195
|
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
9140
9196
|
id: "event.tennis-club-membership.action.notify.label"
|
|
9141
9197
|
},
|
|
9198
|
+
notificationForm: toNotificationForm(TENNIS_CLUB_DECLARATION_FORM),
|
|
9199
|
+
review: toNotificationReview(TENNIS_CLUB_DECLARATION_REVIEW),
|
|
9142
9200
|
flags: [
|
|
9143
9201
|
{
|
|
9144
9202
|
id: "health-worker-notified",
|
|
@@ -10606,8 +10664,8 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
|
10606
10664
|
}
|
|
10607
10665
|
function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
|
|
10608
10666
|
const collectedLocations = [];
|
|
10609
|
-
const
|
|
10610
|
-
let current =
|
|
10667
|
+
const maybeAdministrativeAreaId = maybeUuid(administrativeAreaId);
|
|
10668
|
+
let current = maybeAdministrativeAreaId ? administrativeAreas.get(maybeAdministrativeAreaId) : null;
|
|
10611
10669
|
while (current) {
|
|
10612
10670
|
collectedLocations.push(current);
|
|
10613
10671
|
if (!current.parentId) {
|
|
@@ -11207,11 +11265,10 @@ function fieldConfigsToActionPayload(fields, rng, administrativeHierarchy) {
|
|
|
11207
11265
|
);
|
|
11208
11266
|
}
|
|
11209
11267
|
function generateActionDeclarationInput(configuration, action, rng, overrides, administrativeHierarchy) {
|
|
11210
|
-
const parsed = DeclarationUpdateActions.safeParse(action);
|
|
11211
11268
|
if ((0, import_lodash5.isEmpty)(overrides) && typeof overrides === "object") {
|
|
11212
11269
|
return {};
|
|
11213
11270
|
}
|
|
11214
|
-
if (
|
|
11271
|
+
if (DeclarationUpdateActions.validate(action)) {
|
|
11215
11272
|
const fields = getDeclarationFields(configuration);
|
|
11216
11273
|
const declarationConfig = getDeclaration(configuration);
|
|
11217
11274
|
const declaration = fieldConfigsToActionPayload(
|
|
@@ -11850,8 +11907,7 @@ function withDeclaration(configuration, declaration) {
|
|
|
11850
11907
|
return { ...action, declaration };
|
|
11851
11908
|
}
|
|
11852
11909
|
if (action.type === ActionType.NOTIFY) {
|
|
11853
|
-
|
|
11854
|
-
return notifyAction;
|
|
11910
|
+
return { ...action, notificationForm: toNotificationForm(declaration) };
|
|
11855
11911
|
}
|
|
11856
11912
|
return action;
|
|
11857
11913
|
})
|
|
@@ -11918,7 +11974,7 @@ function isTemplateVariable(value) {
|
|
|
11918
11974
|
return typeof value === "string" && value.startsWith("$");
|
|
11919
11975
|
}
|
|
11920
11976
|
function isFieldValue(value) {
|
|
11921
|
-
return FieldValue.
|
|
11977
|
+
return FieldValue.validate(value);
|
|
11922
11978
|
}
|
|
11923
11979
|
function isFieldValueWithoutTemplates(value) {
|
|
11924
11980
|
if (isTemplateVariable(value)) {
|
|
@@ -12270,13 +12326,11 @@ function getFilePathsFromEvent(event2) {
|
|
|
12270
12326
|
...declarationValues,
|
|
12271
12327
|
...annotationValues
|
|
12272
12328
|
].flatMap((value) => {
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
return [fileParsed.data.path];
|
|
12329
|
+
if (isFileFieldValue(value)) {
|
|
12330
|
+
return [value.path];
|
|
12276
12331
|
}
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
return fileOptionParsed.data.map((val) => val.path);
|
|
12332
|
+
if (isFileFieldWithOptionValue(value)) {
|
|
12333
|
+
return value.map((val) => val.path);
|
|
12280
12334
|
}
|
|
12281
12335
|
return [];
|
|
12282
12336
|
});
|