@opencrvs/toolkit 2.2.0-rc.1a111f2 → 2.2.0-rc.25c3c81
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/build.sh +15 -2
- package/dist/application-config/index.js +16 -5
- package/dist/authentication/index.d.ts +1 -1
- package/dist/authentication/index.js +4 -8
- package/dist/cli.js +1109 -25
- package/dist/commons/api/router.d.ts +13 -0
- package/dist/commons/application-config/index.d.ts +1 -1
- package/dist/commons/conditionals/conditionals.d.ts +4 -4
- package/dist/commons/conditionals/validate.d.ts +1 -1
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/EventConfig.d.ts +66 -5
- package/dist/commons/events/EventDocument.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +1 -0
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +1 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/PlainDate.d.ts +5 -0
- package/dist/commons/events/defineConfig.d.ts +1 -1
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +1 -1
- package/dist/commons/events/state/index.d.ts +1 -0
- package/dist/commons/events/test.utils.d.ts +2 -1
- package/dist/commons/events/utils.d.ts +15 -2
- package/dist/commons/users/Role.d.ts +23 -0
- package/dist/commons/users/User.d.ts +263 -0
- package/dist/commons/users/authentication.d.ts +67 -0
- package/dist/commons/users/index.d.ts +5 -0
- package/dist/commons/users/roleValidations.d.ts +15 -0
- package/dist/commons/users/scopes.d.ts +1402 -0
- package/dist/commons/users/userReferences.d.ts +176 -0
- package/dist/conditionals/index.js +3 -3
- package/dist/configurator/index.d.ts +24 -0
- package/dist/configurator/index.d.ts.map +1 -0
- package/dist/configurator/index.js +161 -0
- package/dist/configurator/layout.d.ts +28 -0
- package/dist/configurator/layout.d.ts.map +1 -0
- package/dist/configurator/layout.js +78 -0
- package/dist/configurator/paths.d.ts +13 -0
- package/dist/configurator/paths.d.ts.map +1 -0
- package/dist/configurator/paths.js +48 -0
- package/dist/configurator/server/environments.d.ts +20 -0
- package/dist/configurator/server/environments.d.ts.map +1 -0
- package/dist/configurator/server/environments.js +143 -0
- package/dist/configurator/server/files.d.ts +11 -0
- package/dist/configurator/server/files.d.ts.map +1 -0
- package/dist/configurator/server/files.js +67 -0
- package/dist/configurator/server/github.d.ts +56 -0
- package/dist/configurator/server/github.d.ts.map +1 -0
- package/dist/configurator/server/github.js +239 -0
- package/dist/configurator/server/plugin.d.ts +39 -0
- package/dist/configurator/server/plugin.d.ts.map +1 -0
- package/dist/configurator/server/plugin.js +298 -0
- package/dist/configurator/server/seal.d.ts +2 -0
- package/dist/configurator/server/seal.d.ts.map +1 -0
- package/dist/configurator/server/seal.js +36 -0
- package/dist/configurator/server/sshKeys.d.ts +5 -0
- package/dist/configurator/server/sshKeys.d.ts.map +1 -0
- package/dist/configurator/server/sshKeys.js +28 -0
- package/dist/configurator/server/start.d.ts +12 -0
- package/dist/configurator/server/start.d.ts.map +1 -0
- package/dist/configurator/server/start.js +91 -0
- package/dist/configurator/testing.d.ts +11 -0
- package/dist/configurator/testing.d.ts.map +1 -0
- package/dist/configurator/testing.js +74 -0
- package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
- package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/bindings.js +5 -0
- package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
- package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/parsers.js +85 -0
- package/dist/configurator/ui/form/users.d.ts +11 -0
- package/dist/configurator/ui/form/users.d.ts.map +1 -0
- package/dist/configurator/ui/form/users.js +33 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
- package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
- package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
- package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
- package/dist/configurator/ui/plan/templateValues.js +70 -0
- package/dist/configurator/workflows.d.ts +53 -0
- package/dist/configurator/workflows.d.ts.map +1 -0
- package/dist/configurator/workflows.js +161 -0
- package/dist/configurator-assets/forms/bindings.yml +263 -0
- package/dist/configurator-assets/templates/README.md +18 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +99 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
- package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
- package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
- package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
- package/dist/configurator-assets/ui/assets/index-Bf3eC7uO.js +169 -0
- package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
- package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
- package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
- package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
- package/dist/configurator-assets/ui/index.html +25 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +6 -0
- package/dist/events/index.js +188 -65
- package/dist/notification/index.js +124 -48
- package/dist/roles/index.d.ts +2 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +730 -0
- package/dist/scopes/index.d.ts +0 -10
- package/dist/scopes/index.js +3 -7
- package/dist/templates/charts-values/dependencies/values.yaml +2 -0
- package/opencrvs-toolkit-2.2.0-rc.25c3c81.tgz +0 -0
- package/package.json +15 -3
- package/tsconfig.build.json +11 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +15 -6
- package/opencrvs-toolkit-2.2.0-rc.1a111f2.tgz +0 -0
|
@@ -46,11 +46,11 @@ var import_compile = require("zod/compile");
|
|
|
46
46
|
// ../commons/src/events/AuditLog.ts
|
|
47
47
|
var z9 = __toESM(require("zod/v4"));
|
|
48
48
|
|
|
49
|
-
// ../commons/src/authentication.ts
|
|
49
|
+
// ../commons/src/users/authentication.ts
|
|
50
50
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
51
51
|
var z8 = __toESM(require("zod/v4"));
|
|
52
52
|
|
|
53
|
-
// ../commons/src/scopes.ts
|
|
53
|
+
// ../commons/src/users/scopes.ts
|
|
54
54
|
var z7 = __toESM(require("zod/v4"));
|
|
55
55
|
var qs = __toESM(require("qs"));
|
|
56
56
|
|
|
@@ -330,7 +330,7 @@ var EventStatus = z6.enum([
|
|
|
330
330
|
"ARCHIVED"
|
|
331
331
|
]);
|
|
332
332
|
|
|
333
|
-
// ../commons/src/scopes.ts
|
|
333
|
+
// ../commons/src/users/scopes.ts
|
|
334
334
|
var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
|
|
335
335
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
336
336
|
);
|
|
@@ -603,7 +603,7 @@ var DEFAULT_SCOPE_OPTIONS = {
|
|
|
603
603
|
registeredIn: JurisdictionFilter.enum.all
|
|
604
604
|
};
|
|
605
605
|
|
|
606
|
-
// ../commons/src/authentication.ts
|
|
606
|
+
// ../commons/src/users/authentication.ts
|
|
607
607
|
var TokenUserType = z8.enum(["user", "system"]);
|
|
608
608
|
var TokenWithBearer = z8.string().regex(/^Bearer\s/);
|
|
609
609
|
|
|
@@ -1108,6 +1108,26 @@ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
|
|
|
1108
1108
|
// ../commons/src/events/PlainDate.ts
|
|
1109
1109
|
var import_zod = require("zod");
|
|
1110
1110
|
var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
|
|
1111
|
+
var dateFormats = /* @__PURE__ */ new Map();
|
|
1112
|
+
function getDateFormat(timeZone) {
|
|
1113
|
+
let format2 = dateFormats.get(timeZone);
|
|
1114
|
+
if (!format2) {
|
|
1115
|
+
format2 = new Intl.DateTimeFormat("en-US", {
|
|
1116
|
+
timeZone,
|
|
1117
|
+
year: "numeric",
|
|
1118
|
+
month: "2-digit",
|
|
1119
|
+
day: "2-digit"
|
|
1120
|
+
});
|
|
1121
|
+
dateFormats.set(timeZone, format2);
|
|
1122
|
+
}
|
|
1123
|
+
return format2;
|
|
1124
|
+
}
|
|
1125
|
+
function toPlainDateInTimeZone(date, timeZone) {
|
|
1126
|
+
const parts = Object.fromEntries(
|
|
1127
|
+
getDateFormat(timeZone).formatToParts(date).map(({ type, value }) => [type, value])
|
|
1128
|
+
);
|
|
1129
|
+
return `${parts.year}-${parts.month}-${parts.day}`;
|
|
1130
|
+
}
|
|
1111
1131
|
|
|
1112
1132
|
// ../commons/src/events/FieldValue.ts
|
|
1113
1133
|
var TextValue = z14.string();
|
|
@@ -1544,6 +1564,9 @@ var LegalStatuses = z17.object({
|
|
|
1544
1564
|
var EventMetadata = z17.object({
|
|
1545
1565
|
id: UUID,
|
|
1546
1566
|
type: z17.string().describe("The type of event, such as birth, death, or marriage."),
|
|
1567
|
+
configVersionId: z17.string().describe(
|
|
1568
|
+
"Id of the event configuration version the record was created under. Records created before versioning have 'initial'."
|
|
1569
|
+
),
|
|
1547
1570
|
status: EventStatus,
|
|
1548
1571
|
legalStatuses: LegalStatuses.describe(
|
|
1549
1572
|
"Metadata related to the legal registration of the event, such as who registered it and when."
|
|
@@ -3099,7 +3122,7 @@ var ActionConfig = z25.discriminatedUnion("type", [
|
|
|
3099
3122
|
}),
|
|
3100
3123
|
NotifyConfig.meta({
|
|
3101
3124
|
id: "NotifyActionConfig",
|
|
3102
|
-
description: "Configuration for the notify action
|
|
3125
|
+
description: "Configuration for the notify action: the notification form and its review page. An event without a NOTIFY action cannot be notified."
|
|
3103
3126
|
}),
|
|
3104
3127
|
DeclareConfig.meta({
|
|
3105
3128
|
id: "DeclareActionConfig",
|
|
@@ -3367,7 +3390,7 @@ var ReferenceField = BaseField2.extend({
|
|
|
3367
3390
|
var Field = BaseField2.extend({
|
|
3368
3391
|
id: z29.string().describe("Identifier of the summary field."),
|
|
3369
3392
|
value: TranslationConfig.describe(
|
|
3370
|
-
'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}").'
|
|
3393
|
+
'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}"). "{event.configVersionLabel}" gives the label of the configuration version that the record was created under.'
|
|
3371
3394
|
),
|
|
3372
3395
|
label: TranslationConfig
|
|
3373
3396
|
}).describe("Custom field defined for the summary view.");
|
|
@@ -3514,6 +3537,38 @@ var AdvancedSearchConfig = z30.object({
|
|
|
3514
3537
|
description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
|
|
3515
3538
|
});
|
|
3516
3539
|
|
|
3540
|
+
// ../commons/src/utils.ts
|
|
3541
|
+
var z31 = __toESM(require("zod/v4"));
|
|
3542
|
+
var _ = __toESM(require("lodash"));
|
|
3543
|
+
function getOrThrow(x, message) {
|
|
3544
|
+
if (x === void 0 || x === null) {
|
|
3545
|
+
throw new Error(message);
|
|
3546
|
+
}
|
|
3547
|
+
return x;
|
|
3548
|
+
}
|
|
3549
|
+
var FullNameV1 = z31.array(
|
|
3550
|
+
z31.object({
|
|
3551
|
+
use: z31.string(),
|
|
3552
|
+
family: z31.string(),
|
|
3553
|
+
given: z31.array(z31.string())
|
|
3554
|
+
})
|
|
3555
|
+
);
|
|
3556
|
+
function omitKeyDeep(obj, keyToRemove) {
|
|
3557
|
+
if (Array.isArray(obj)) {
|
|
3558
|
+
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
3559
|
+
}
|
|
3560
|
+
if (obj === null || typeof obj !== "object") {
|
|
3561
|
+
return obj;
|
|
3562
|
+
}
|
|
3563
|
+
const newObj = {};
|
|
3564
|
+
for (const key of Object.keys(obj)) {
|
|
3565
|
+
if (key !== keyToRemove) {
|
|
3566
|
+
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
return newObj;
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3517
3572
|
// ../commons/src/events/utils.ts
|
|
3518
3573
|
var import_lodash4 = require("lodash");
|
|
3519
3574
|
|
|
@@ -3524,15 +3579,15 @@ var z34 = __toESM(require("zod/v4"));
|
|
|
3524
3579
|
var import_date_fns2 = require("date-fns");
|
|
3525
3580
|
|
|
3526
3581
|
// ../commons/src/events/FieldTypeMapping.ts
|
|
3527
|
-
var
|
|
3582
|
+
var z33 = __toESM(require("zod/v4"));
|
|
3528
3583
|
|
|
3529
3584
|
// ../commons/src/events/DynamicFieldValue.ts
|
|
3530
|
-
var
|
|
3585
|
+
var z32 = __toESM(require("zod/v4"));
|
|
3531
3586
|
function getDynamicNameValue(field3) {
|
|
3532
3587
|
const nameConfiguration = field3.configuration?.name;
|
|
3533
3588
|
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
3534
3589
|
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
3535
|
-
return
|
|
3590
|
+
return z32.object({
|
|
3536
3591
|
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
3537
3592
|
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
3538
3593
|
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
@@ -3563,7 +3618,7 @@ function mapFieldTypeToZod(field3, actionType) {
|
|
|
3563
3618
|
let schema;
|
|
3564
3619
|
switch (field3.type) {
|
|
3565
3620
|
case FieldType.FIELD_GROUP: {
|
|
3566
|
-
schema =
|
|
3621
|
+
schema = z33.object(
|
|
3567
3622
|
field3.fields.reduce((acc, subfield) => {
|
|
3568
3623
|
acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
|
|
3569
3624
|
return acc;
|
|
@@ -3670,32 +3725,6 @@ function mapFieldTypeToZod(field3, actionType) {
|
|
|
3670
3725
|
// ../commons/src/events/state/index.ts
|
|
3671
3726
|
var import_lodash3 = require("lodash");
|
|
3672
3727
|
|
|
3673
|
-
// ../commons/src/utils.ts
|
|
3674
|
-
var z33 = __toESM(require("zod/v4"));
|
|
3675
|
-
var _ = __toESM(require("lodash"));
|
|
3676
|
-
var FullNameV1 = z33.array(
|
|
3677
|
-
z33.object({
|
|
3678
|
-
use: z33.string(),
|
|
3679
|
-
family: z33.string(),
|
|
3680
|
-
given: z33.array(z33.string())
|
|
3681
|
-
})
|
|
3682
|
-
);
|
|
3683
|
-
function omitKeyDeep(obj, keyToRemove) {
|
|
3684
|
-
if (Array.isArray(obj)) {
|
|
3685
|
-
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
3686
|
-
}
|
|
3687
|
-
if (obj === null || typeof obj !== "object") {
|
|
3688
|
-
return obj;
|
|
3689
|
-
}
|
|
3690
|
-
const newObj = {};
|
|
3691
|
-
for (const key of Object.keys(obj)) {
|
|
3692
|
-
if (key !== keyToRemove) {
|
|
3693
|
-
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
3694
|
-
}
|
|
3695
|
-
}
|
|
3696
|
-
return newObj;
|
|
3697
|
-
}
|
|
3698
|
-
|
|
3699
3728
|
// ../commons/src/events/state/utils.ts
|
|
3700
3729
|
var import_lodash = require("lodash");
|
|
3701
3730
|
var updateActions = new Set(
|
|
@@ -4992,23 +5021,26 @@ function validateEventConfig(event2, ctx) {
|
|
|
4992
5021
|
validateActionFlags(event2, ctx);
|
|
4993
5022
|
validateActionOrder(event2, ctx);
|
|
4994
5023
|
}
|
|
4995
|
-
var
|
|
5024
|
+
var EventConfig2 = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
4996
5025
|
id: "EventConfig",
|
|
4997
5026
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
4998
5027
|
});
|
|
4999
|
-
var
|
|
5028
|
+
var INITIAL_EVENT_CONFIG_VERSION_ID = "initial";
|
|
5000
5029
|
var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
|
|
5001
5030
|
var _EventConfigVersion = z35.object({
|
|
5002
5031
|
id: z35.string().describe(
|
|
5003
5032
|
'Identifier of the version, unique within the event (e.g. "birth-v2").'
|
|
5004
5033
|
),
|
|
5034
|
+
label: TranslationConfig.describe(
|
|
5035
|
+
'Name of the version, which the UI shows wherever it names the version. For example, "{event.configVersionLabel}" in the event summary.'
|
|
5036
|
+
),
|
|
5005
5037
|
effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
|
|
5006
5038
|
`Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
|
|
5007
5039
|
),
|
|
5008
5040
|
...versionFields
|
|
5009
5041
|
});
|
|
5010
5042
|
var resolvedConfigs = /* @__PURE__ */ new WeakMap();
|
|
5011
|
-
function
|
|
5043
|
+
function toEventConfig(config, version) {
|
|
5012
5044
|
let resolvedVersions = resolvedConfigs.get(config);
|
|
5013
5045
|
if (!resolvedVersions) {
|
|
5014
5046
|
resolvedVersions = /* @__PURE__ */ new WeakMap();
|
|
@@ -5018,7 +5050,12 @@ function getEventConfigOfVersion(config, version) {
|
|
|
5018
5050
|
if (cached) {
|
|
5019
5051
|
return cached;
|
|
5020
5052
|
}
|
|
5021
|
-
const {
|
|
5053
|
+
const {
|
|
5054
|
+
id: _id,
|
|
5055
|
+
label: _label,
|
|
5056
|
+
effectiveFrom: _effectiveFrom,
|
|
5057
|
+
...fields
|
|
5058
|
+
} = version;
|
|
5022
5059
|
const resolved = {
|
|
5023
5060
|
...fields,
|
|
5024
5061
|
id: config.id,
|
|
@@ -5028,8 +5065,29 @@ function getEventConfigOfVersion(config, version) {
|
|
|
5028
5065
|
resolvedVersions.set(version, resolved);
|
|
5029
5066
|
return resolved;
|
|
5030
5067
|
}
|
|
5068
|
+
function byEffectiveFrom(a, b) {
|
|
5069
|
+
return a.effectiveFrom.localeCompare(b.effectiveFrom);
|
|
5070
|
+
}
|
|
5071
|
+
function getVersionsInEffectOn(config, date) {
|
|
5072
|
+
return config.versions.filter(({ effectiveFrom }) => effectiveFrom <= date).sort(byEffectiveFrom);
|
|
5073
|
+
}
|
|
5074
|
+
function findVersionInEffectOn(config, date) {
|
|
5075
|
+
return getVersionsInEffectOn(config, date).at(-1);
|
|
5076
|
+
}
|
|
5077
|
+
function resolveEventConfigOnDate(config, date) {
|
|
5078
|
+
return toEventConfig(
|
|
5079
|
+
config,
|
|
5080
|
+
getOrThrow(
|
|
5081
|
+
findVersionInEffectOn(config, date),
|
|
5082
|
+
`Event '${config.id}' has no version in effect on ${date}`
|
|
5083
|
+
)
|
|
5084
|
+
);
|
|
5085
|
+
}
|
|
5086
|
+
function resolveEventConfigInTimeZone(config, timeZone, now2 = /* @__PURE__ */ new Date()) {
|
|
5087
|
+
return resolveEventConfigOnDate(config, toPlainDateInTimeZone(now2, timeZone));
|
|
5088
|
+
}
|
|
5031
5089
|
function resolveEventConfig(config) {
|
|
5032
|
-
return
|
|
5090
|
+
return resolveEventConfigInTimeZone(config, "UTC");
|
|
5033
5091
|
}
|
|
5034
5092
|
function validateVersionList(config, ctx) {
|
|
5035
5093
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -5083,18 +5141,16 @@ function validateEachVersion(ctx, events, validate2) {
|
|
|
5083
5141
|
validate2(event2, { value: event2, addIssue });
|
|
5084
5142
|
});
|
|
5085
5143
|
}
|
|
5086
|
-
var
|
|
5144
|
+
var VersionedEventConfig2 = z35.object({
|
|
5087
5145
|
...eventLevelFields,
|
|
5088
5146
|
versions: z35.array(_EventConfigVersion).min(1).describe(
|
|
5089
|
-
`Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${
|
|
5147
|
+
`Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${INITIAL_EVENT_CONFIG_VERSION_ID}' and \`effectiveFrom\` '${DEFAULT_EFFECTIVE_FROM}'.`
|
|
5090
5148
|
)
|
|
5091
5149
|
}).superRefine((config, ctx) => {
|
|
5092
5150
|
validateVersionList(config, ctx);
|
|
5093
5151
|
validateEachVersion(
|
|
5094
5152
|
ctx,
|
|
5095
|
-
config.versions.map(
|
|
5096
|
-
(version) => getEventConfigOfVersion(config, version)
|
|
5097
|
-
),
|
|
5153
|
+
config.versions.map((version) => toEventConfig(config, version)),
|
|
5098
5154
|
validateEventConfig
|
|
5099
5155
|
);
|
|
5100
5156
|
}).meta({
|
|
@@ -5721,6 +5777,9 @@ var EventInput = z41.object({
|
|
|
5721
5777
|
type: z41.string(),
|
|
5722
5778
|
createdAtLocation: UUID.nullish().describe(
|
|
5723
5779
|
"Location where the event occurred. Required for system users."
|
|
5780
|
+
),
|
|
5781
|
+
configVersionId: z41.string().optional().describe(
|
|
5782
|
+
"Id of the event configuration version the client created the record under, e.g. while offline. Must be configured and not take effect in the future. Defaults to the version in effect when the server receives the record."
|
|
5724
5783
|
)
|
|
5725
5784
|
}).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
|
|
5726
5785
|
|
|
@@ -5736,6 +5795,9 @@ var EventDocument = z42.object({
|
|
|
5736
5795
|
actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
|
|
5737
5796
|
trackingId: z42.string().describe(
|
|
5738
5797
|
"System-generated tracking identifier used to look up the event."
|
|
5798
|
+
),
|
|
5799
|
+
configVersionId: z42.string().describe(
|
|
5800
|
+
"Id of the event configuration version the record was created under. Every action on the record uses that version. Records created before versioning have 'initial'."
|
|
5739
5801
|
)
|
|
5740
5802
|
}).meta({ id: "EventDocument" });
|
|
5741
5803
|
var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
@@ -5791,9 +5853,23 @@ function toVersionedInput(config) {
|
|
|
5791
5853
|
id,
|
|
5792
5854
|
label,
|
|
5793
5855
|
advancedSearch,
|
|
5794
|
-
versions: [{ ...version, id:
|
|
5856
|
+
versions: [{ ...version, id: INITIAL_EVENT_CONFIG_VERSION_ID, label }]
|
|
5795
5857
|
};
|
|
5796
5858
|
}
|
|
5859
|
+
var WESTERNMOST_TIME_ZONE = "Etc/GMT+12";
|
|
5860
|
+
function validateVersionInEffectToday(config, ctx) {
|
|
5861
|
+
const today = toPlainDateInTimeZone(/* @__PURE__ */ new Date(), WESTERNMOST_TIME_ZONE);
|
|
5862
|
+
const isAnyVersionInEffect = config.versions.some(
|
|
5863
|
+
({ effectiveFrom }) => effectiveFrom <= today
|
|
5864
|
+
);
|
|
5865
|
+
if (!isAnyVersionInEffect) {
|
|
5866
|
+
ctx.addIssue({
|
|
5867
|
+
code: "custom",
|
|
5868
|
+
message: `Event '${config.id}' has no version in effect today (${today}, UTC\u221212, the last time zone to begin the day). At least one version must omit \`effectiveFrom\` or take effect on or before that date.`,
|
|
5869
|
+
path: ["versions"]
|
|
5870
|
+
});
|
|
5871
|
+
}
|
|
5872
|
+
}
|
|
5797
5873
|
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
5798
5874
|
if ("versions" in config) {
|
|
5799
5875
|
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
@@ -5803,7 +5879,7 @@ var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
|
5803
5879
|
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
5804
5880
|
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
5805
5881
|
}
|
|
5806
|
-
}).transform(toVersionedInput).pipe(
|
|
5882
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig2).superRefine(validateVersionInEffectToday);
|
|
5807
5883
|
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
5808
5884
|
|
|
5809
5885
|
// ../commons/src/events/toNotificationForm.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAaA,cAAc,8BAA8B,CAAA"}
|