@opencrvs/toolkit 2.1.0 → 2.2.0-rc.ab91cce
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 +2 -2
- package/create-countryconfig/package.json +1 -1
- package/dist/cli.js +294 -1967
- package/dist/commons/events/ActionConfig.d.ts +79 -0
- package/dist/commons/events/EventConfig.d.ts +26 -6
- package/dist/commons/events/eventConfigValidation.d.ts +17 -1
- package/dist/commons/events/test.utils.d.ts +5 -0
- package/dist/commons/events/utils.d.ts +14 -14
- package/dist/environment/derived-variables.d.ts +18 -0
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +22 -1
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +29 -10
- package/dist/events/index.js +171 -60
- package/dist/migrations/add-translations.d.ts +15 -0
- package/dist/migrations/add-translations.d.ts.map +1 -0
- package/dist/migrations/{v2.1/add-translations.js → add-translations.js} +16 -14
- package/dist/migrations/v2.1/index.js +35 -2155
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +3 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -1
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +3 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -1
- package/dist/migrations/v2.2/index.d.ts +6 -0
- package/dist/migrations/v2.2/index.d.ts.map +1 -0
- package/dist/migrations/v2.2/index.js +456 -0
- package/dist/migrations/v2.2/read-declaration-through-helper.d.ts +39 -0
- package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +1 -0
- package/dist/migrations/v2.2/read-declaration-through-helper.js +257 -0
- package/dist/notification/index.js +191 -83
- package/dist/templates/charts-values/traefik/values.yaml +2 -3
- package/opencrvs-toolkit-2.2.0-rc.ab91cce.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/migrations/v2.1/add-translations.d.ts +0 -9
- package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
- package/opencrvs-toolkit-2.1.0.tgz +0 -0
package/dist/events/index.js
CHANGED
|
@@ -482,6 +482,7 @@ __export(events_exports, {
|
|
|
482
482
|
validateFieldInput: () => validateFieldInput,
|
|
483
483
|
validateValue: () => validateValue,
|
|
484
484
|
window: () => window2,
|
|
485
|
+
withDeclaration: () => withDeclaration,
|
|
485
486
|
writeActions: () => writeActions
|
|
486
487
|
});
|
|
487
488
|
module.exports = __toCommonJS(events_exports);
|
|
@@ -3529,6 +3530,9 @@ var DeleteConfig = ActionConfigBase.extend(
|
|
|
3529
3530
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
3530
3531
|
z25.object({
|
|
3531
3532
|
type: z25.literal(ActionType.DECLARE),
|
|
3533
|
+
declaration: DeclarationFormConfig.describe(
|
|
3534
|
+
"Configuration of the form used to gather event data."
|
|
3535
|
+
),
|
|
3532
3536
|
review: DeclarationReviewConfig.describe(
|
|
3533
3537
|
"Configuration of the review page fields."
|
|
3534
3538
|
),
|
|
@@ -6209,14 +6213,22 @@ function ageToDate(age, asOfDate) {
|
|
|
6209
6213
|
const date = plainDateToLocalDate(asOfDate);
|
|
6210
6214
|
return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
|
|
6211
6215
|
}
|
|
6212
|
-
function
|
|
6213
|
-
|
|
6216
|
+
function getDeclaration(configuration) {
|
|
6217
|
+
const declareAction = configuration.actions.find(
|
|
6218
|
+
(action) => action.type === ActionType.DECLARE
|
|
6219
|
+
);
|
|
6220
|
+
if (!declareAction) {
|
|
6221
|
+
throw new Error(
|
|
6222
|
+
`Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
|
|
6223
|
+
);
|
|
6224
|
+
}
|
|
6225
|
+
return declareAction.declaration;
|
|
6214
6226
|
}
|
|
6215
6227
|
function getDeclarationPages(configuration) {
|
|
6216
|
-
return configuration.
|
|
6228
|
+
return getDeclaration(configuration).pages;
|
|
6217
6229
|
}
|
|
6218
|
-
function
|
|
6219
|
-
return configuration.
|
|
6230
|
+
function getDeclarationFields(configuration) {
|
|
6231
|
+
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
6220
6232
|
}
|
|
6221
6233
|
function isActionConfigType(type) {
|
|
6222
6234
|
return actionConfigTypes.has(type);
|
|
@@ -6837,6 +6849,43 @@ function validateActionOrder(event2, ctx) {
|
|
|
6837
6849
|
}
|
|
6838
6850
|
}
|
|
6839
6851
|
}
|
|
6852
|
+
function validateExactlyOneDeclareAction(event2, ctx) {
|
|
6853
|
+
const declareActionCount = event2.actions.filter(
|
|
6854
|
+
(action) => action.type === ActionType.DECLARE
|
|
6855
|
+
).length;
|
|
6856
|
+
if (declareActionCount !== 1) {
|
|
6857
|
+
ctx.addIssue({
|
|
6858
|
+
code: "custom",
|
|
6859
|
+
message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
|
|
6860
|
+
path: ["actions"]
|
|
6861
|
+
});
|
|
6862
|
+
return false;
|
|
6863
|
+
}
|
|
6864
|
+
return true;
|
|
6865
|
+
}
|
|
6866
|
+
function validateDeclarationGivenExactlyOnce(config, ctx) {
|
|
6867
|
+
const declareActionIndex = config.actions.findIndex(
|
|
6868
|
+
(action) => action.type === ActionType.DECLARE
|
|
6869
|
+
);
|
|
6870
|
+
const declareAction = config.actions[declareActionIndex];
|
|
6871
|
+
const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
|
|
6872
|
+
const onTopLevel = !!config.declaration;
|
|
6873
|
+
const declareActionPath = `actions[${declareActionIndex}].declaration`;
|
|
6874
|
+
if (onTopLevel && onDeclareAction) {
|
|
6875
|
+
ctx.addIssue({
|
|
6876
|
+
code: "custom",
|
|
6877
|
+
message: `Event '${config.id}' defines \`declaration\` both at the top level and on the ${ActionType.DECLARE} action (\`${declareActionPath}\`). Define it in only one of these places.`,
|
|
6878
|
+
path: ["declaration"]
|
|
6879
|
+
});
|
|
6880
|
+
}
|
|
6881
|
+
if (!onTopLevel && !onDeclareAction) {
|
|
6882
|
+
ctx.addIssue({
|
|
6883
|
+
code: "custom",
|
|
6884
|
+
message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
|
|
6885
|
+
path: ["declaration"]
|
|
6886
|
+
});
|
|
6887
|
+
}
|
|
6888
|
+
}
|
|
6840
6889
|
|
|
6841
6890
|
// ../commons/src/events/EventConfig.ts
|
|
6842
6891
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
@@ -6861,16 +6910,15 @@ var _EventConfigBase = z35.object({
|
|
|
6861
6910
|
summary: SummaryConfig.describe(
|
|
6862
6911
|
"Summary information displayed in the event overview."
|
|
6863
6912
|
),
|
|
6864
|
-
label: TranslationConfig.describe(
|
|
6913
|
+
label: TranslationConfig.describe(
|
|
6914
|
+
"Human-readable label for the event type."
|
|
6915
|
+
),
|
|
6865
6916
|
actions: z35.array(ActionConfig).describe(
|
|
6866
6917
|
"Configuration of core and custom actions associated with the event."
|
|
6867
6918
|
),
|
|
6868
6919
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
6869
6920
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
6870
6921
|
),
|
|
6871
|
-
declaration: DeclarationFormConfig.describe(
|
|
6872
|
-
"Configuration of the form used to gather event data."
|
|
6873
|
-
),
|
|
6874
6922
|
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
6875
6923
|
"Configuration of fields available in the advanced search feature."
|
|
6876
6924
|
),
|
|
@@ -6885,6 +6933,9 @@ var _EventConfigBase = z35.object({
|
|
|
6885
6933
|
)
|
|
6886
6934
|
});
|
|
6887
6935
|
var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
|
|
6936
|
+
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
6937
|
+
return;
|
|
6938
|
+
}
|
|
6888
6939
|
validateAdvancedSearchConfig(event2, ctx);
|
|
6889
6940
|
validateDateOfEvent(event2, ctx);
|
|
6890
6941
|
validatePlaceOfEvent(event2, ctx);
|
|
@@ -7526,10 +7577,29 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
|
|
|
7526
7577
|
}).brand("EventDocumentOnlyLastAction");
|
|
7527
7578
|
|
|
7528
7579
|
// ../commons/src/events/defineConfig.ts
|
|
7529
|
-
var
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7580
|
+
var z43 = __toESM(require("zod/v4"));
|
|
7581
|
+
function moveDeclarationToDeclareAction({
|
|
7582
|
+
declaration,
|
|
7583
|
+
...config
|
|
7584
|
+
}) {
|
|
7585
|
+
if (declaration) {
|
|
7586
|
+
console.warn(
|
|
7587
|
+
`Event '${config.id}' defines \`declaration\` at the top level, which is deprecated and will be removed in a future release. Define it on the ${ActionType.DECLARE} action instead.`
|
|
7588
|
+
);
|
|
7589
|
+
}
|
|
7590
|
+
return {
|
|
7591
|
+
...config,
|
|
7592
|
+
actions: config.actions.map(
|
|
7593
|
+
(action) => action.type === ActionType.DECLARE && declaration ? { ...action, declaration } : action
|
|
7594
|
+
)
|
|
7595
|
+
};
|
|
7596
|
+
}
|
|
7597
|
+
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
7598
|
+
if (validateExactlyOneDeclareAction(config, ctx)) {
|
|
7599
|
+
validateDeclarationGivenExactlyOnce(config, ctx);
|
|
7600
|
+
}
|
|
7601
|
+
}).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
|
|
7602
|
+
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
7533
7603
|
|
|
7534
7604
|
// ../commons/src/events/transactions.ts
|
|
7535
7605
|
function generateTransactionId() {
|
|
@@ -9523,7 +9593,24 @@ var libraryMembershipEvent = defineConfig({
|
|
|
9523
9593
|
id: "event.library-membership.title"
|
|
9524
9594
|
},
|
|
9525
9595
|
summary: { fields: [] },
|
|
9526
|
-
actions: [
|
|
9596
|
+
actions: [
|
|
9597
|
+
{
|
|
9598
|
+
type: ActionType.DECLARE,
|
|
9599
|
+
label: {
|
|
9600
|
+
defaultMessage: "Declare",
|
|
9601
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
9602
|
+
id: "event.library-membership.action.declare.label"
|
|
9603
|
+
},
|
|
9604
|
+
review: {
|
|
9605
|
+
title: {
|
|
9606
|
+
defaultMessage: "Library membership application",
|
|
9607
|
+
description: "Title of the review page",
|
|
9608
|
+
id: "event.library-membership.action.declare.form.review.title"
|
|
9609
|
+
},
|
|
9610
|
+
fields: []
|
|
9611
|
+
}
|
|
9612
|
+
}
|
|
9613
|
+
],
|
|
9527
9614
|
declaration: libraryMembershipForm
|
|
9528
9615
|
});
|
|
9529
9616
|
|
|
@@ -9969,6 +10056,22 @@ var digitalIdentityEvent = defineConfig({
|
|
|
9969
10056
|
},
|
|
9970
10057
|
summary: { fields: [] },
|
|
9971
10058
|
actions: [
|
|
10059
|
+
{
|
|
10060
|
+
type: ActionType.DECLARE,
|
|
10061
|
+
label: {
|
|
10062
|
+
defaultMessage: "Declare",
|
|
10063
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
10064
|
+
id: "event.digital-identity.action.declare.label"
|
|
10065
|
+
},
|
|
10066
|
+
review: {
|
|
10067
|
+
title: {
|
|
10068
|
+
defaultMessage: "Digital identity issuance",
|
|
10069
|
+
description: "Title of the review page",
|
|
10070
|
+
id: "event.digital-identity.action.declare.form.review.title"
|
|
10071
|
+
},
|
|
10072
|
+
fields: []
|
|
10073
|
+
}
|
|
10074
|
+
},
|
|
9972
10075
|
{
|
|
9973
10076
|
type: ActionType.PRINT_CERTIFICATE,
|
|
9974
10077
|
label: {
|
|
@@ -9983,45 +10086,45 @@ var digitalIdentityEvent = defineConfig({
|
|
|
9983
10086
|
});
|
|
9984
10087
|
|
|
9985
10088
|
// ../commons/src/events/test.utils.ts
|
|
9986
|
-
var
|
|
10089
|
+
var z45 = __toESM(require("zod/v4"));
|
|
9987
10090
|
|
|
9988
10091
|
// ../commons/src/events/locations.ts
|
|
9989
|
-
var
|
|
9990
|
-
var LocationTypeV1 =
|
|
10092
|
+
var z44 = __toESM(require("zod/v4"));
|
|
10093
|
+
var LocationTypeV1 = z44.enum([
|
|
9991
10094
|
"ADMIN_STRUCTURE",
|
|
9992
10095
|
"CRVS_OFFICE",
|
|
9993
10096
|
"HEALTH_FACILITY"
|
|
9994
10097
|
]);
|
|
9995
|
-
var LocationStatus =
|
|
10098
|
+
var LocationStatus = z44.enum(["active", "inactive"]);
|
|
9996
10099
|
var InactiveOfficeError = class extends Error {
|
|
9997
10100
|
constructor(message = "Assigned office is inactive") {
|
|
9998
10101
|
super(message);
|
|
9999
10102
|
this.name = "InactiveOfficeError";
|
|
10000
10103
|
}
|
|
10001
10104
|
};
|
|
10002
|
-
var LocationVersion =
|
|
10105
|
+
var LocationVersion = z44.object({
|
|
10003
10106
|
versionId: UUID,
|
|
10004
|
-
effectiveFrom:
|
|
10005
|
-
name:
|
|
10006
|
-
externalId:
|
|
10107
|
+
effectiveFrom: z44.iso.date(),
|
|
10108
|
+
name: z44.string(),
|
|
10109
|
+
externalId: z44.string().nullish(),
|
|
10007
10110
|
status: LocationStatus
|
|
10008
10111
|
});
|
|
10009
|
-
var AdministrativeArea =
|
|
10112
|
+
var AdministrativeArea = z44.object({
|
|
10010
10113
|
id: UUID,
|
|
10011
|
-
name:
|
|
10012
|
-
externalId:
|
|
10114
|
+
name: z44.string(),
|
|
10115
|
+
externalId: z44.string().nullish(),
|
|
10013
10116
|
parentId: UUID.nullable(),
|
|
10014
10117
|
status: LocationStatus,
|
|
10015
|
-
versions:
|
|
10118
|
+
versions: z44.array(LocationVersion)
|
|
10016
10119
|
});
|
|
10017
|
-
var Location =
|
|
10120
|
+
var Location = z44.object({
|
|
10018
10121
|
id: UUID,
|
|
10019
|
-
name:
|
|
10020
|
-
externalId:
|
|
10122
|
+
name: z44.string(),
|
|
10123
|
+
externalId: z44.string().nullish(),
|
|
10021
10124
|
administrativeAreaId: UUID.nullable(),
|
|
10022
|
-
locationType:
|
|
10125
|
+
locationType: z44.string().nullable(),
|
|
10023
10126
|
status: LocationStatus,
|
|
10024
|
-
versions:
|
|
10127
|
+
versions: z44.array(LocationVersion)
|
|
10025
10128
|
});
|
|
10026
10129
|
var ClientAdministrativeArea = AdministrativeArea.omit({
|
|
10027
10130
|
name: true,
|
|
@@ -10062,22 +10165,22 @@ function validateUniqueIds(versions, ctx) {
|
|
|
10062
10165
|
ctx.addIssue("versions must not repeat a versionId");
|
|
10063
10166
|
}
|
|
10064
10167
|
}
|
|
10065
|
-
var SeededLocationVersions =
|
|
10168
|
+
var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
|
|
10066
10169
|
validateAscendingDates(versions, ctx);
|
|
10067
10170
|
validateUniqueIds(versions, ctx);
|
|
10068
10171
|
});
|
|
10069
|
-
var SetLocationPayload =
|
|
10172
|
+
var SetLocationPayload = z44.object({
|
|
10070
10173
|
id: UUID,
|
|
10071
|
-
name:
|
|
10072
|
-
externalId:
|
|
10174
|
+
name: z44.string(),
|
|
10175
|
+
externalId: z44.string().nullish(),
|
|
10073
10176
|
administrativeAreaId: UUID.nullable(),
|
|
10074
|
-
locationType:
|
|
10177
|
+
locationType: z44.string().nullable(),
|
|
10075
10178
|
versions: SeededLocationVersions.optional()
|
|
10076
10179
|
});
|
|
10077
|
-
var SetAdministrativeAreaPayload =
|
|
10180
|
+
var SetAdministrativeAreaPayload = z44.object({
|
|
10078
10181
|
id: UUID,
|
|
10079
|
-
name:
|
|
10080
|
-
externalId:
|
|
10182
|
+
name: z44.string(),
|
|
10183
|
+
externalId: z44.string().nullish(),
|
|
10081
10184
|
parentId: UUID.nullable(),
|
|
10082
10185
|
versions: SeededLocationVersions.optional()
|
|
10083
10186
|
});
|
|
@@ -10666,7 +10769,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
|
|
|
10666
10769
|
|
|
10667
10770
|
// ../commons/src/events/test.utils.ts
|
|
10668
10771
|
var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
|
|
10669
|
-
var TestUserRole =
|
|
10772
|
+
var TestUserRole = z45.enum([
|
|
10670
10773
|
"FIELD_AGENT",
|
|
10671
10774
|
"LOCAL_REGISTRAR",
|
|
10672
10775
|
"LOCAL_SYSTEM_ADMIN",
|
|
@@ -11498,6 +11601,14 @@ var generateEventConfig = ({
|
|
|
11498
11601
|
]
|
|
11499
11602
|
});
|
|
11500
11603
|
};
|
|
11604
|
+
function withDeclaration(configuration, declaration) {
|
|
11605
|
+
return {
|
|
11606
|
+
...configuration,
|
|
11607
|
+
actions: configuration.actions.map(
|
|
11608
|
+
(action) => action.type === ActionType.DECLARE ? { ...action, declaration } : action
|
|
11609
|
+
)
|
|
11610
|
+
};
|
|
11611
|
+
}
|
|
11501
11612
|
function getLeafAdministrativeAreaIds(administrativeAreas) {
|
|
11502
11613
|
const nonLeafAdministrativeAreaIds = /* @__PURE__ */ new Set();
|
|
11503
11614
|
for (const [, location] of administrativeAreas) {
|
|
@@ -11908,49 +12019,49 @@ function getFilePathsFromEvent(event2) {
|
|
|
11908
12019
|
}
|
|
11909
12020
|
|
|
11910
12021
|
// ../commons/src/events/locationPayloads.ts
|
|
11911
|
-
var
|
|
11912
|
-
var CreateLocationPayload =
|
|
12022
|
+
var z46 = __toESM(require("zod/v4"));
|
|
12023
|
+
var CreateLocationPayload = z46.object({
|
|
11913
12024
|
id: UUID.optional(),
|
|
11914
12025
|
versionId: UUID.optional(),
|
|
11915
|
-
name:
|
|
11916
|
-
externalId:
|
|
12026
|
+
name: z46.string(),
|
|
12027
|
+
externalId: z46.string().nullish(),
|
|
11917
12028
|
administrativeAreaId: UUID.nullable(),
|
|
11918
|
-
locationType:
|
|
11919
|
-
effectiveFrom:
|
|
12029
|
+
locationType: z46.string().nullable(),
|
|
12030
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11920
12031
|
status: LocationStatus.default("active")
|
|
11921
12032
|
});
|
|
11922
|
-
var UpdateLocationPayload =
|
|
12033
|
+
var UpdateLocationPayload = z46.strictObject({
|
|
11923
12034
|
id: UUID,
|
|
11924
12035
|
versionId: UUID.optional(),
|
|
11925
|
-
name:
|
|
11926
|
-
externalId:
|
|
12036
|
+
name: z46.string(),
|
|
12037
|
+
externalId: z46.string().nullish(),
|
|
11927
12038
|
status: LocationStatus,
|
|
11928
|
-
effectiveFrom:
|
|
12039
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11929
12040
|
lastVersionId: UUID
|
|
11930
12041
|
});
|
|
11931
|
-
var WithdrawLocationVersionPayload =
|
|
12042
|
+
var WithdrawLocationVersionPayload = z46.object({
|
|
11932
12043
|
id: UUID,
|
|
11933
12044
|
versionId: UUID
|
|
11934
12045
|
});
|
|
11935
|
-
var CreateAdministrativeAreaPayload =
|
|
12046
|
+
var CreateAdministrativeAreaPayload = z46.object({
|
|
11936
12047
|
id: UUID.optional(),
|
|
11937
12048
|
versionId: UUID.optional(),
|
|
11938
|
-
name:
|
|
11939
|
-
externalId:
|
|
12049
|
+
name: z46.string(),
|
|
12050
|
+
externalId: z46.string().nullish(),
|
|
11940
12051
|
parentId: UUID.nullable(),
|
|
11941
|
-
effectiveFrom:
|
|
12052
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11942
12053
|
status: LocationStatus.default("active")
|
|
11943
12054
|
});
|
|
11944
|
-
var UpdateAdministrativeAreaPayload =
|
|
12055
|
+
var UpdateAdministrativeAreaPayload = z46.strictObject({
|
|
11945
12056
|
id: UUID,
|
|
11946
12057
|
versionId: UUID.optional(),
|
|
11947
|
-
name:
|
|
11948
|
-
externalId:
|
|
12058
|
+
name: z46.string(),
|
|
12059
|
+
externalId: z46.string().nullish(),
|
|
11949
12060
|
status: LocationStatus,
|
|
11950
|
-
effectiveFrom:
|
|
12061
|
+
effectiveFrom: z46.iso.date().optional(),
|
|
11951
12062
|
lastVersionId: UUID
|
|
11952
12063
|
});
|
|
11953
|
-
var WithdrawAdministrativeAreaVersionPayload =
|
|
12064
|
+
var WithdrawAdministrativeAreaVersionPayload = z46.object({
|
|
11954
12065
|
id: UUID,
|
|
11955
12066
|
versionId: UUID
|
|
11956
12067
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CsvFile } from '../csv';
|
|
2
|
+
/**
|
|
3
|
+
* The rows of the template that the local file has no id for, expressed in the
|
|
4
|
+
* local file's columns.
|
|
5
|
+
*/
|
|
6
|
+
export declare function rowsToAdd(local: CsvFile, template: CsvFile): string[];
|
|
7
|
+
/**
|
|
8
|
+
* @param targetVersion the major.minor the country config is upgraded to, e.g. `2.2`.
|
|
9
|
+
*/
|
|
10
|
+
declare function main(targetVersion: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* @knipignore
|
|
13
|
+
*/
|
|
14
|
+
export { main };
|
|
15
|
+
//# sourceMappingURL=add-translations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-translations.d.ts","sourceRoot":"","sources":["../../src/migrations/add-translations.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,OAAO,EAMR,MAAM,QAAQ,CAAA;AAYf;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,CAgBrE;AAqED;;GAEG;AACH,iBAAe,IAAI,CAAC,aAAa,EAAE,MAAM,iBA2BxC;AAED;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -29,8 +29,9 @@ exports.main = main;
|
|
|
29
29
|
* config.
|
|
30
30
|
*
|
|
31
31
|
* Unlike every other codemod, this one carries no list of what it changes, and
|
|
32
|
-
* should not need editing again
|
|
33
|
-
*
|
|
32
|
+
* should not need editing again: every version's upgrade runs it, passing the
|
|
33
|
+
* version it upgrades to. Its input is `client.csv` and `login.csv` from
|
|
34
|
+
* the country config template of that version, fetched from
|
|
34
35
|
* GitHub; whatever rows those files have gained, this adds. A pull request that
|
|
35
36
|
* introduces a translation key therefore only has to add it to the template —
|
|
36
37
|
* `packages/countryconfig-template/src/translations/` — which the
|
|
@@ -45,11 +46,9 @@ exports.main = main;
|
|
|
45
46
|
* empty cell for one it has nothing for.
|
|
46
47
|
*/
|
|
47
48
|
const path_1 = __importDefault(require("path"));
|
|
48
|
-
const csv_1 = require("
|
|
49
|
-
const template_1 = require("
|
|
49
|
+
const csv_1 = require("../csv");
|
|
50
|
+
const template_1 = require("../translations/template");
|
|
50
51
|
const APPLICATIONS = ['client', 'login'];
|
|
51
|
-
/** The version this folder upgrades a country config to. */
|
|
52
|
-
const TARGET_VERSION = '2.1';
|
|
53
52
|
const skipped = [];
|
|
54
53
|
function warnSkipped(message) {
|
|
55
54
|
skipped.push(message);
|
|
@@ -73,7 +72,7 @@ function rowsToAdd(local, template) {
|
|
|
73
72
|
}));
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
|
-
function updateApplication(cwd, refs, application) {
|
|
75
|
+
function updateApplication(cwd, targetVersion, refs, application) {
|
|
77
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
77
|
const relativePath = `src/translations/${application}.csv`;
|
|
79
78
|
const local = (0, csv_1.readCsvFile)(path_1.default.join(cwd, relativePath));
|
|
@@ -83,7 +82,7 @@ function updateApplication(cwd, refs, application) {
|
|
|
83
82
|
}
|
|
84
83
|
const fetched = yield (0, template_1.fetchTemplate)(refs, application);
|
|
85
84
|
if (!fetched) {
|
|
86
|
-
warnSkipped(`No ${application}.csv found in the ${
|
|
85
|
+
warnSkipped(`No ${application}.csv found in the ${targetVersion} country config template on GitHub; ${application}.csv not updated`);
|
|
87
86
|
return;
|
|
88
87
|
}
|
|
89
88
|
const template = readTemplate(fetched.contents);
|
|
@@ -113,26 +112,29 @@ function readTemplate(contents) {
|
|
|
113
112
|
};
|
|
114
113
|
}
|
|
115
114
|
/** Refs to read the template from. Undefined when GitHub cannot be asked. */
|
|
116
|
-
function listRefs() {
|
|
115
|
+
function listRefs(targetVersion) {
|
|
117
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
117
|
try {
|
|
119
|
-
return yield (0, template_1.candidateRefs)(
|
|
118
|
+
return yield (0, template_1.candidateRefs)(targetVersion);
|
|
120
119
|
}
|
|
121
120
|
catch (error) {
|
|
122
|
-
warnSkipped(`Could not list the ${
|
|
121
|
+
warnSkipped(`Could not list the ${targetVersion} refs on GitHub (${error.message}); translations not added`);
|
|
123
122
|
return undefined;
|
|
124
123
|
}
|
|
125
124
|
});
|
|
126
125
|
}
|
|
127
|
-
|
|
126
|
+
/**
|
|
127
|
+
* @param targetVersion the major.minor the country config is upgraded to, e.g. `2.2`.
|
|
128
|
+
*/
|
|
129
|
+
function main(targetVersion) {
|
|
128
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
131
|
const cwd = process.cwd();
|
|
130
132
|
console.log('Adding the translation keys core gained this version...\n');
|
|
131
|
-
const refs = yield listRefs();
|
|
133
|
+
const refs = yield listRefs(targetVersion);
|
|
132
134
|
if (refs) {
|
|
133
135
|
for (const application of APPLICATIONS) {
|
|
134
136
|
try {
|
|
135
|
-
yield updateApplication(cwd, refs, application);
|
|
137
|
+
yield updateApplication(cwd, targetVersion, refs, application);
|
|
136
138
|
}
|
|
137
139
|
catch (error) {
|
|
138
140
|
warnSkipped(`Could not read ${application}.csv from the country config template on GitHub (${error.message}); ${application}.csv not updated`);
|