@opencrvs/toolkit 2.0.1 → 2.1.0-beta
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/README.md +16 -0
- package/build.sh +14 -5
- package/create-countryconfig/index.js +293 -103
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +5 -2
- package/dist/application-config/index.js +369 -282
- package/dist/authentication/index.d.ts +67 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +750 -0
- package/dist/cli.js +4343 -4788
- package/dist/commons/api/router.d.ts +4120 -2946
- package/dist/commons/application-config/index.d.ts +6 -6
- package/dist/commons/conditionals/conditionals.d.ts +32 -323
- package/dist/commons/conditionals/validate.d.ts +16 -5
- package/dist/commons/events/ActionConfig.d.ts +302 -71
- package/dist/commons/events/ActionDocument.d.ts +159 -121
- package/dist/commons/events/ActionInput.d.ts +30 -10
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/ActionType.d.ts +63 -58
- package/dist/commons/events/AdvancedSearchConfig.d.ts +531 -501
- package/dist/commons/events/AuditLog.d.ts +189 -40
- package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
- package/dist/commons/events/Conditional.d.ts +3 -3
- package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
- package/dist/commons/events/Draft.d.ts +38 -36
- package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
- package/dist/commons/events/EventConfig.d.ts +8 -3
- package/dist/commons/events/EventDocument.d.ts +537 -47
- package/dist/commons/events/EventIndex.d.ts +61 -59
- package/dist/commons/events/EventMetadata.d.ts +59 -43
- package/dist/commons/events/EventStatus.d.ts +19 -0
- package/dist/commons/events/FieldConfig.d.ts +424 -384
- package/dist/commons/events/FieldType.d.ts +51 -51
- package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
- package/dist/commons/events/FieldValue.d.ts +14 -14
- package/dist/commons/events/Flag.d.ts +57 -15
- package/dist/commons/events/FormConfig.d.ts +0 -6
- package/dist/commons/events/PageConfig.d.ts +0 -4
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/TemplateConfig.d.ts +1 -1
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
- package/dist/commons/events/WorkqueueConfig.d.ts +835 -790
- package/dist/commons/events/deduplication.d.ts +1 -1
- package/dist/commons/events/event.d.ts +14 -2
- package/dist/commons/events/field.d.ts +69 -198
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +248 -14
- package/dist/commons/events/mocks.test.utils.d.ts +48 -4
- package/dist/commons/events/scopes.d.ts +5 -4
- package/dist/commons/events/state/index.d.ts +23 -15
- package/dist/commons/events/state/utils.d.ts +15 -6
- package/dist/commons/events/test.utils.d.ts +68 -42
- package/dist/commons/events/utils.d.ts +139 -110
- package/dist/commons/notification/UserNotifications.d.ts +38 -18
- package/dist/commons/notification/dispatch.d.ts +10 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +341 -68
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/environment/custom-types.d.ts +33 -0
- package/dist/environment/custom-types.d.ts.map +1 -0
- package/dist/environment/custom-types.js +12 -0
- package/dist/environment/derived-variables.d.ts +122 -0
- package/dist/environment/derived-variables.d.ts.map +1 -0
- package/dist/environment/derived-variables.js +155 -0
- package/dist/environment/editor-questions.d.ts +4 -0
- package/dist/environment/editor-questions.d.ts.map +1 -0
- package/dist/environment/editor-questions.js +67 -0
- package/dist/environment/git.d.ts +5 -0
- package/dist/environment/git.d.ts.map +1 -0
- package/dist/environment/git.js +38 -0
- package/dist/environment/github.d.ts +26 -0
- package/dist/environment/github.d.ts.map +1 -0
- package/dist/environment/github.js +247 -0
- package/dist/environment/index.d.ts +6 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +81 -0
- package/dist/environment/logger.d.ts +18 -0
- package/dist/environment/logger.d.ts.map +1 -0
- package/dist/environment/logger.js +25 -0
- package/dist/environment/manage-users.d.ts +11 -0
- package/dist/environment/manage-users.d.ts.map +1 -0
- package/dist/environment/manage-users.js +507 -0
- package/dist/environment/paths.d.ts +7 -0
- package/dist/environment/paths.d.ts.map +1 -0
- package/dist/environment/paths.js +72 -0
- package/dist/environment/questions-helper.d.ts +15 -0
- package/dist/environment/questions-helper.d.ts.map +1 -0
- package/dist/environment/questions-helper.js +70 -0
- package/dist/environment/questions.d.ts +200 -0
- package/dist/environment/questions.d.ts.map +1 -0
- package/dist/environment/questions.js +418 -0
- package/dist/environment/setup-environment.d.ts +2 -0
- package/dist/environment/setup-environment.d.ts.map +1 -0
- package/dist/environment/setup-environment.js +795 -0
- package/dist/environment/ssh-keygen.d.ts +5 -0
- package/dist/environment/ssh-keygen.d.ts.map +1 -0
- package/dist/environment/ssh-keygen.js +21 -0
- package/dist/environment/swarm-to-k8s.d.ts +2 -0
- package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
- package/dist/environment/swarm-to-k8s.js +183 -0
- package/dist/environment/templates.d.ts +27 -0
- package/dist/environment/templates.d.ts.map +1 -0
- package/dist/environment/templates.js +164 -0
- package/dist/environment/update-workflows.d.ts +2 -0
- package/dist/environment/update-workflows.d.ts.map +1 -0
- package/dist/environment/update-workflows.js +191 -0
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +82 -0
- package/dist/environment/users.d.ts +2 -0
- package/dist/environment/users.d.ts.map +1 -0
- package/dist/environment/users.js +120 -0
- package/dist/environment/utils.d.ts +18 -0
- package/dist/environment/utils.d.ts.map +1 -0
- package/dist/environment/utils.js +110 -0
- package/dist/events/deduplication.d.ts +1 -1
- package/dist/events/index.js +8104 -7408
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
- package/dist/migrations/v2.0/index.js +88 -5143
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
- package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +213 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +438 -0
- package/dist/migrations/v2.1/index.d.ts +6 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -0
- package/dist/migrations/v2.1/index.js +1276 -0
- package/dist/notification/index.js +2010 -1451
- package/dist/scopes/index.d.ts +512 -231
- package/dist/scopes/index.js +342 -68
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +39 -0
- package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +82 -0
- package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +78 -0
- package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
- package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/templates/charts-values/traefik/values.yaml +129 -0
- package/dist/templates/inventory/inventory.template.yml +98 -0
- package/dist/translations/check.d.ts +19 -0
- package/dist/translations/check.d.ts.map +1 -0
- package/dist/translations/check.js +127 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +25 -25
- package/opencrvs-toolkit-2.1.0-beta.tgz +0 -0
- package/package.json +25 -6
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/opencrvs-toolkit-2.0.1.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -56,7 +56,7 @@ exports.main = main;
|
|
|
56
56
|
* so `git merge-base HEAD upstream/develop` typically returns nothing.
|
|
57
57
|
* - With no merge-base, a 3-way merge degenerates to a 2-way diff against
|
|
58
58
|
* an empty file — every line that differs becomes a conflict.
|
|
59
|
-
* - `release
|
|
59
|
+
* - `release-v1.9` is the latest 1.9.x release line on upstream and is a
|
|
60
60
|
* near-perfect representation of "what `infrastructure/` looked like
|
|
61
61
|
* before v2.0", regardless of whether the fork's git history reaches it.
|
|
62
62
|
* - For files the country config never modified relative to that baseline,
|
|
@@ -81,7 +81,7 @@ exports.main = main;
|
|
|
81
81
|
* sides changed a binary file, the result will be invalid and a warning
|
|
82
82
|
* is printed.
|
|
83
83
|
* - Forks that are on a much older 1.9.x and never merged later 1.9 patches
|
|
84
|
-
* may see a few extra conflicts on files where 1.9.x → release
|
|
84
|
+
* may see a few extra conflicts on files where 1.9.x → release-v1.9
|
|
85
85
|
* patches and v1.9 → v2.0 changes textually overlap.
|
|
86
86
|
*/
|
|
87
87
|
const child_process_1 = require("child_process");
|
|
@@ -97,7 +97,7 @@ const INFRASTRUCTURE_DIR = 'infrastructure';
|
|
|
97
97
|
// Synthetic merge-base: the tip of upstream's latest 1.9.x release line.
|
|
98
98
|
// We use this branch's content as the "common ancestor" for every file,
|
|
99
99
|
// since most country forks don't share git history with upstream.
|
|
100
|
-
const BASE_BRANCH = 'release
|
|
100
|
+
const BASE_BRANCH = 'release-v1.9';
|
|
101
101
|
/**
|
|
102
102
|
* Reads `git show <ref>:<path>` as a Uint8Array (binary-safe).
|
|
103
103
|
* Returns `null` if the path doesn't exist at that ref.
|
|
@@ -92,9 +92,10 @@ const FUNCTION_LIKE_KINDS = [
|
|
|
92
92
|
* Falls back to `<anonymous>` when nothing useful can be derived.
|
|
93
93
|
*/
|
|
94
94
|
function describeFunction(node) {
|
|
95
|
-
var _a
|
|
95
|
+
var _a;
|
|
96
|
+
var _b, _c;
|
|
96
97
|
if (ts_morph_1.Node.isFunctionDeclaration(node) || ts_morph_1.Node.isMethodDeclaration(node)) {
|
|
97
|
-
return (
|
|
98
|
+
return (_b = node.getName()) !== null && _b !== void 0 ? _b : '<anonymous>';
|
|
98
99
|
}
|
|
99
100
|
// FunctionExpression / ArrowFunction: try to pick up the assignment target.
|
|
100
101
|
const parent = node.getParent();
|
|
@@ -106,7 +107,7 @@ function describeFunction(node) {
|
|
|
106
107
|
}
|
|
107
108
|
if (ts_morph_1.Node.isFunctionExpression(node) &&
|
|
108
109
|
node.getNameNode() !== undefined) {
|
|
109
|
-
return (_c = (
|
|
110
|
+
return (_c = (_a = node.getNameNode()) === null || _a === void 0 ? void 0 : _a.getText()) !== null && _c !== void 0 ? _c : '<anonymous>';
|
|
110
111
|
}
|
|
111
112
|
return '<anonymous>';
|
|
112
113
|
}
|
|
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
25
25
|
}) : function(o, v) {
|
|
26
26
|
o["default"] = v;
|
|
27
27
|
});
|
|
28
|
-
var __importStar = (this && this.__importStar) || function (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
35
45
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
46
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
47
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-explicit-correction-flags.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/add-explicit-correction-flags.ts"],"names":[],"mappings":"AAyPA,iBAAe,IAAI,kBA+ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.main = main;
|
|
26
|
+
/**
|
|
27
|
+
* Codemod: Add explicit `APPROVE_CORRECTION` / `REJECT_CORRECTION` action
|
|
28
|
+
* configs when `REQUEST_CORRECTION` has `flags` and/or `conditionals`.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.1/add-explicit-correction-flags.ts
|
|
32
|
+
*
|
|
33
|
+
* Why:
|
|
34
|
+
* `getActionConfig()` used to alias `APPROVE_CORRECTION` and
|
|
35
|
+
* `REJECT_CORRECTION` to whatever was configured on `REQUEST_CORRECTION`
|
|
36
|
+
* (label, flags, conditionals). As of v2.1, each resolves to its own
|
|
37
|
+
* independent config, so `flags`/`conditionals` configured only on
|
|
38
|
+
* `REQUEST_CORRECTION` would silently stop applying when an
|
|
39
|
+
* `APPROVE_CORRECTION`/`REJECT_CORRECTION` action is accepted. See
|
|
40
|
+
* CHANGELOG.md ("APPROVE_CORRECTION / REJECT_CORRECTION no longer inherit
|
|
41
|
+
* REQUEST_CORRECTION's config").
|
|
42
|
+
*
|
|
43
|
+
* What it does:
|
|
44
|
+
* - Scans all TypeScript files under `src/`
|
|
45
|
+
* - Finds every `defineConfig({ ... })` call expression
|
|
46
|
+
* - Inside the `actions` array, locates the `REQUEST_CORRECTION` action
|
|
47
|
+
* - If it has a non-empty `flags` and/or `conditionals` array, inserts
|
|
48
|
+
* sibling `APPROVE_CORRECTION` and `REJECT_CORRECTION` action objects
|
|
49
|
+
* (carrying over the same `flags`/`conditionals`) immediately after it,
|
|
50
|
+
* unless an action of that type already exists in the array
|
|
51
|
+
* - Saves the modified files in-place
|
|
52
|
+
*/
|
|
53
|
+
const ts_morph_1 = require("ts-morph");
|
|
54
|
+
const path_1 = __importDefault(require("path"));
|
|
55
|
+
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
56
|
+
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
57
|
+
const TYPE_PROPERTY_NAME = 'type';
|
|
58
|
+
const FLAGS_PROPERTY_NAME = 'flags';
|
|
59
|
+
const CONDITIONALS_PROPERTY_NAME = 'conditionals';
|
|
60
|
+
const ACTION_TYPE_ENUM_NAME = 'ActionType';
|
|
61
|
+
const REQUEST_CORRECTION_TYPE = 'REQUEST_CORRECTION';
|
|
62
|
+
const CORRECTION_ACTIONS_TO_ADD = [
|
|
63
|
+
{
|
|
64
|
+
actionType: 'APPROVE_CORRECTION',
|
|
65
|
+
labelId: 'v2.events.correction.approve.label',
|
|
66
|
+
defaultMessage: 'Approve correction',
|
|
67
|
+
description: 'Label for the approve correction action'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
actionType: 'REJECT_CORRECTION',
|
|
71
|
+
labelId: 'v2.events.correction.reject.label',
|
|
72
|
+
defaultMessage: 'Reject correction',
|
|
73
|
+
description: 'Label for the reject correction action'
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* Returns true if the object's `type` property matches the given type name.
|
|
78
|
+
* Handles both `ActionType.X` and the string literal `'X'` forms.
|
|
79
|
+
*/
|
|
80
|
+
function isActionOfType(obj, typeName) {
|
|
81
|
+
const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
|
|
82
|
+
if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
|
|
83
|
+
return false;
|
|
84
|
+
const typeInit = typeProperty.getInitializer();
|
|
85
|
+
if (!typeInit)
|
|
86
|
+
return false;
|
|
87
|
+
if (ts_morph_1.Node.isPropertyAccessExpression(typeInit)) {
|
|
88
|
+
return (typeInit.getExpression().getText() === ACTION_TYPE_ENUM_NAME &&
|
|
89
|
+
typeInit.getName() === typeName);
|
|
90
|
+
}
|
|
91
|
+
if (ts_morph_1.Node.isStringLiteral(typeInit)) {
|
|
92
|
+
return typeInit.getLiteralValue() === typeName;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns whether `type` is written as `ActionType.X` (enum access) or as a
|
|
98
|
+
* bare string literal, so newly inserted actions can mirror the same style.
|
|
99
|
+
*/
|
|
100
|
+
function getTypeInitializerStyle(obj) {
|
|
101
|
+
const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
|
|
102
|
+
if (typeProperty && ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
|
|
103
|
+
const typeInit = typeProperty.getInitializer();
|
|
104
|
+
if (typeInit && ts_morph_1.Node.isPropertyAccessExpression(typeInit))
|
|
105
|
+
return 'enum';
|
|
106
|
+
}
|
|
107
|
+
return 'string';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the source text of `obj[propName]` if it's an array literal with
|
|
111
|
+
* at least one element, otherwise undefined.
|
|
112
|
+
*/
|
|
113
|
+
function getNonEmptyArrayPropertyText(obj, propName) {
|
|
114
|
+
const prop = obj.getProperty(propName);
|
|
115
|
+
if (!prop || !ts_morph_1.Node.isPropertyAssignment(prop))
|
|
116
|
+
return undefined;
|
|
117
|
+
const init = prop.getInitializer();
|
|
118
|
+
if (!init || !ts_morph_1.Node.isArrayLiteralExpression(init))
|
|
119
|
+
return undefined;
|
|
120
|
+
if (init.getElements().length === 0)
|
|
121
|
+
return undefined;
|
|
122
|
+
return init.getText();
|
|
123
|
+
}
|
|
124
|
+
function buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText) {
|
|
125
|
+
const typeText = typeStyle === 'enum'
|
|
126
|
+
? `${ACTION_TYPE_ENUM_NAME}.${spec.actionType}`
|
|
127
|
+
: `'${spec.actionType}'`;
|
|
128
|
+
const lines = [
|
|
129
|
+
`type: ${typeText}`,
|
|
130
|
+
`label: {
|
|
131
|
+
id: '${spec.labelId}',
|
|
132
|
+
defaultMessage: '${spec.defaultMessage}',
|
|
133
|
+
description: '${spec.description}'
|
|
134
|
+
}`
|
|
135
|
+
];
|
|
136
|
+
if (flagsText) {
|
|
137
|
+
lines.push(`${FLAGS_PROPERTY_NAME}: ${flagsText}`);
|
|
138
|
+
}
|
|
139
|
+
if (conditionalsText) {
|
|
140
|
+
lines.push(`${CONDITIONALS_PROPERTY_NAME}: ${conditionalsText}`);
|
|
141
|
+
}
|
|
142
|
+
return `{\n ${lines.join(',\n ')}\n}`;
|
|
143
|
+
}
|
|
144
|
+
function processFile(filePath, project) {
|
|
145
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
146
|
+
if (!sourceFile)
|
|
147
|
+
return 0;
|
|
148
|
+
let changes = 0;
|
|
149
|
+
const relPath = path_1.default.relative(process.cwd(), filePath);
|
|
150
|
+
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
151
|
+
for (const call of callExpressions) {
|
|
152
|
+
const expression = call.getExpression();
|
|
153
|
+
if (!ts_morph_1.Node.isIdentifier(expression) ||
|
|
154
|
+
expression.getText() !== DEFINE_CONFIG_NAME) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const args = call.getArguments();
|
|
158
|
+
if (args.length === 0)
|
|
159
|
+
continue;
|
|
160
|
+
const configArg = args[0];
|
|
161
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
|
|
162
|
+
continue;
|
|
163
|
+
const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
|
|
164
|
+
if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
|
|
165
|
+
continue;
|
|
166
|
+
const actionsInitializer = actionsProperty.getInitializer();
|
|
167
|
+
if (!actionsInitializer ||
|
|
168
|
+
!ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
|
|
169
|
+
continue;
|
|
170
|
+
const elements = actionsInitializer.getElements();
|
|
171
|
+
const requestCorrectionIndex = elements.findIndex((el) => ts_morph_1.Node.isObjectLiteralExpression(el) &&
|
|
172
|
+
isActionOfType(el, REQUEST_CORRECTION_TYPE));
|
|
173
|
+
if (requestCorrectionIndex === -1)
|
|
174
|
+
continue;
|
|
175
|
+
const requestCorrection = elements[requestCorrectionIndex];
|
|
176
|
+
const flagsText = getNonEmptyArrayPropertyText(requestCorrection, FLAGS_PROPERTY_NAME);
|
|
177
|
+
const conditionalsText = getNonEmptyArrayPropertyText(requestCorrection, CONDITIONALS_PROPERTY_NAME);
|
|
178
|
+
// Nothing on REQUEST_CORRECTION that approve/reject would need to inherit.
|
|
179
|
+
if (!flagsText && !conditionalsText)
|
|
180
|
+
continue;
|
|
181
|
+
const typeStyle = getTypeInitializerStyle(requestCorrection);
|
|
182
|
+
let insertAt = requestCorrectionIndex + 1;
|
|
183
|
+
for (const spec of CORRECTION_ACTIONS_TO_ADD) {
|
|
184
|
+
const alreadyPresent = actionsInitializer
|
|
185
|
+
.getElements()
|
|
186
|
+
.some((el) => ts_morph_1.Node.isObjectLiteralExpression(el) &&
|
|
187
|
+
isActionOfType(el, spec.actionType));
|
|
188
|
+
if (alreadyPresent)
|
|
189
|
+
continue;
|
|
190
|
+
const text = buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText);
|
|
191
|
+
actionsInitializer.insertElement(insertAt, text);
|
|
192
|
+
insertAt++;
|
|
193
|
+
changes++;
|
|
194
|
+
console.log(` [${relPath}] Added ${spec.actionType} action carrying over REQUEST_CORRECTION's flags/conditionals`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return changes;
|
|
198
|
+
}
|
|
199
|
+
function main() {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
202
|
+
console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
|
|
203
|
+
const project = new ts_morph_1.Project({
|
|
204
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
205
|
+
skipAddingFilesFromTsConfig: false
|
|
206
|
+
});
|
|
207
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
208
|
+
const fp = sf.getFilePath();
|
|
209
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
210
|
+
});
|
|
211
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
212
|
+
let totalChanges = 0;
|
|
213
|
+
const modifiedFiles = [];
|
|
214
|
+
for (const sourceFile of sourceFiles) {
|
|
215
|
+
const filePath = sourceFile.getFilePath();
|
|
216
|
+
const changes = processFile(filePath, project);
|
|
217
|
+
if (changes > 0) {
|
|
218
|
+
totalChanges += changes;
|
|
219
|
+
modifiedFiles.push(filePath);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (modifiedFiles.length === 0) {
|
|
223
|
+
console.log('No REQUEST_CORRECTION actions with flags/conditionals found. Nothing to do.');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
227
|
+
for (const filePath of modifiedFiles) {
|
|
228
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
229
|
+
yield sourceFile.save();
|
|
230
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
231
|
+
}
|
|
232
|
+
console.log(`\nDone. Added ${totalChanges} correction action config(s) across ${modifiedFiles.length} file(s).`);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-recovery-link-notifications.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/add-recovery-link-notifications.ts"],"names":[],"mappings":"AAopBA,iBAAe,IAAI,kBA0ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|