@opencrvs/toolkit 2.1.0-rc.d1b9774 → 2.1.0-rc.d235243
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 +2 -12
- package/build.sh +15 -5
- package/create-countryconfig/index.js +164 -4
- package/dist/application-config/index.js +36 -25
- package/dist/authentication/index.d.ts +8 -9
- package/dist/authentication/index.js +23 -8
- package/dist/cli.js +1981 -2823
- package/dist/commons/api/router.d.ts +252 -290
- package/dist/commons/application-config/index.d.ts +0 -2
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +19 -4
- package/dist/commons/events/ActionConfig.d.ts +5 -14
- package/dist/commons/events/ActionDocument.d.ts +30 -4
- package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
- package/dist/commons/events/AuditLog.d.ts +1 -0
- package/dist/commons/events/Draft.d.ts +1 -21
- package/dist/commons/events/EventDocument.d.ts +4 -4
- package/dist/commons/events/FieldConfig.d.ts +26 -15
- package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
- package/dist/commons/events/FieldValue.d.ts +1 -0
- package/dist/commons/events/FormConfig.d.ts +6 -0
- package/dist/commons/events/PageConfig.d.ts +4 -0
- package/dist/commons/events/locations.d.ts +4 -0
- package/dist/commons/events/scopes.d.ts +21 -1
- package/dist/commons/events/test.utils.d.ts +71 -22
- package/dist/commons/events/utils.d.ts +37 -2
- package/dist/conditionals/index.js +21 -7
- 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 +21 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +2 -1
- package/dist/environment/manage-users.js +1 -1
- package/dist/environment/questions.d.ts +16 -0
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +27 -2
- package/dist/environment/setup-environment.d.ts +1 -1
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +633 -560
- package/dist/environment/swarm-to-k8s.js +3 -4
- package/dist/environment/templates.d.ts +0 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +3 -8
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +6 -1
- package/dist/environment/utils.d.ts +0 -12
- package/dist/environment/utils.d.ts.map +1 -1
- package/dist/environment/utils.js +1 -28
- package/dist/events/index.js +2115 -1884
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +4 -4
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
- package/dist/migrations/v2.1/add-translations.js +4 -68
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
- package/dist/migrations/v2.1/enable-telemetry.js +30 -13
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +35 -1261
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
- package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-sentry.js +354 -0
- package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
- package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
- package/dist/migrations/v2.1/template-files.d.ts +8 -0
- package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
- package/dist/migrations/v2.1/template-files.js +49 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
- package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
- package/dist/migrations/v2.2/add-e2e-tests.d.ts +19 -0
- package/dist/migrations/v2.2/add-e2e-tests.d.ts.map +1 -0
- package/dist/migrations/v2.2/add-e2e-tests.js +143 -0
- 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 +279 -0
- package/dist/migrations/v2.2/template-files.d.ts +8 -0
- package/dist/migrations/v2.2/template-files.d.ts.map +1 -0
- package/dist/migrations/v2.2/template-files.js +49 -0
- package/dist/migrations/v2.2/upgrade-tilt.d.ts +8 -0
- package/dist/migrations/v2.2/upgrade-tilt.d.ts.map +1 -0
- package/dist/migrations/v2.2/upgrade-tilt.js +139 -0
- package/dist/notification/index.js +249 -207
- package/dist/scopes/index.d.ts +288 -5
- package/dist/scopes/index.js +22 -7
- package/dist/telemetry/index.js +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +8 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
- package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
- package/dist/templates/charts-values/traefik/values.yaml +2 -3
- package/dist/templates/countryconfig-template/.tiltignore +1 -0
- package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
- package/dist/templates/countryconfig-template/Tiltfile +112 -0
- package/dist/templates/countryconfig-template/assets/README.md +1 -0
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
- package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
- package/dist/templates/countryconfig-template/e2e/README.md +36 -0
- package/dist/templates/countryconfig-template/e2e/constants.ts +28 -0
- package/dist/templates/countryconfig-template/e2e/login.e2e.ts +59 -0
- package/dist/templates/countryconfig-template/package.json +153 -0
- package/dist/templates/countryconfig-template/playwright.config.ts +42 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
- package/dist/templates/countryconfig-template/tilt/common.tilt +159 -0
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
- package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
- package/dist/translations/template.d.ts +11 -0
- package/dist/translations/template.d.ts.map +1 -0
- package/dist/translations/template.js +100 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +180 -15
- package/opencrvs-toolkit-2.1.0-rc.d235243.tgz +0 -0
- package/package.json +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
- package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
- package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
- package/dist/migrations/v2.0/create-events-index.js +0 -325
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
- package/dist/migrations/v2.0/index.d.ts +0 -13
- package/dist/migrations/v2.0/index.d.ts.map +0 -1
- package/dist/migrations/v2.0/index.js +0 -103
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-scopes.js +0 -305
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
- package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
- package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
- package/dist/migrations/v2.0/update-package-json.js +0 -105
- package/dist/translations/check.d.ts +0 -19
- package/dist/translations/check.d.ts.map +0 -1
- package/dist/translations/check.js +0 -127
- package/opencrvs-toolkit-2.1.0-rc.d1b9774.tgz +0 -0
|
@@ -1,429 +0,0 @@
|
|
|
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 `pending-first-certificate-issuance` flag to event configs and workqueues.
|
|
28
|
-
*
|
|
29
|
-
* Usage:
|
|
30
|
-
* ts-node -r tsconfig-paths/register src/migrations/v2.0/add-birth-certificate-issuance-flag.ts
|
|
31
|
-
*
|
|
32
|
-
* What it does:
|
|
33
|
-
* defineConfig (every event type — birth, death, marriage, custom, etc.):
|
|
34
|
-
* - Ensures the top-level `flags` array contains the `pending-first-certificate-issuance`
|
|
35
|
-
* flag definition. The flag's i18n `label.id` is event-specific, e.g.
|
|
36
|
-
* `event.birth.flag.pending-first-certificate-issuance`,
|
|
37
|
-
* `event.death.flag.pending-first-certificate-issuance`.
|
|
38
|
-
* - Ensures every `REGISTER` action has
|
|
39
|
-
* `flags: [{ id: 'pending-first-certificate-issuance', operation: 'add' }]`
|
|
40
|
-
* - Ensures every `PRINT_CERTIFICATE` action has
|
|
41
|
-
* `flags: [{ id: 'pending-first-certificate-issuance', operation: 'remove' }]`
|
|
42
|
-
*
|
|
43
|
-
* defineWorkqueues:
|
|
44
|
-
* - Finds workqueues whose `actions` array (or `action` object) contains a
|
|
45
|
-
* `PRINT_CERTIFICATE` type entry
|
|
46
|
-
* - Adds `flags: { anyOf: ['pending-first-certificate-issuance'] }` to every leaf
|
|
47
|
-
* clause in that workqueue's `query` (merging with existing `flags` if present)
|
|
48
|
-
*
|
|
49
|
-
* - Saves the modified files in-place
|
|
50
|
-
*/
|
|
51
|
-
const ts_morph_1 = require("ts-morph");
|
|
52
|
-
const path_1 = __importDefault(require("path"));
|
|
53
|
-
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
54
|
-
const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
|
|
55
|
-
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
56
|
-
const ACTION_PROPERTY_NAME = 'action';
|
|
57
|
-
const FLAGS_PROPERTY_NAME = 'flags';
|
|
58
|
-
const QUERY_PROPERTY_NAME = 'query';
|
|
59
|
-
const TYPE_PROPERTY_NAME = 'type';
|
|
60
|
-
const ID_PROPERTY_NAME = 'id';
|
|
61
|
-
const CLAUSES_PROPERTY_NAME = 'clauses';
|
|
62
|
-
const ANY_OF_PROPERTY_NAME = 'anyOf';
|
|
63
|
-
const FLAG_ID = 'pending-first-certificate-issuance';
|
|
64
|
-
const REGISTER_TYPE = 'REGISTER';
|
|
65
|
-
const PRINT_CERTIFICATE_TYPE = 'PRINT_CERTIFICATE';
|
|
66
|
-
/**
|
|
67
|
-
* Builds the flag-definition object literal for a given event type so the i18n
|
|
68
|
-
* `label.id` is namespaced per event (e.g. `event.death.flag.…`).
|
|
69
|
-
*/
|
|
70
|
-
function flagDefinitionInitializer(eventType) {
|
|
71
|
-
return `{
|
|
72
|
-
id: '${FLAG_ID}',
|
|
73
|
-
label: {
|
|
74
|
-
id: 'event.${eventType}.flag.${FLAG_ID}',
|
|
75
|
-
defaultMessage: 'Pending first certificate issuance',
|
|
76
|
-
description: 'Flag label for first certificate issuance'
|
|
77
|
-
},
|
|
78
|
-
requiresAction: true
|
|
79
|
-
}`;
|
|
80
|
-
}
|
|
81
|
-
// ─── Generic helpers ──────────────────────────────────────────────────────────
|
|
82
|
-
/**
|
|
83
|
-
* Returns true if the object's `type` property matches the given type name.
|
|
84
|
-
* Handles both `ActionType.PRINT_CERTIFICATE` and `'PRINT_CERTIFICATE'` forms.
|
|
85
|
-
*/
|
|
86
|
-
function isActionOfType(obj, typeName) {
|
|
87
|
-
const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
|
|
88
|
-
if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
|
|
89
|
-
return false;
|
|
90
|
-
const typeInit = typeProperty.getInitializer();
|
|
91
|
-
if (!typeInit)
|
|
92
|
-
return false;
|
|
93
|
-
if (ts_morph_1.Node.isPropertyAccessExpression(typeInit)) {
|
|
94
|
-
return typeInit.getName() === typeName;
|
|
95
|
-
}
|
|
96
|
-
if (ts_morph_1.Node.isStringLiteral(typeInit)) {
|
|
97
|
-
return typeInit.getLiteralValue() === typeName;
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Extracts the event type from a `defineConfig` root config object, using the
|
|
103
|
-
* (lower-cased) value of either the `type` or `id` property. Property name has
|
|
104
|
-
* shifted across core/country-config versions, so both are tried.
|
|
105
|
-
*
|
|
106
|
-
* Handles all known shapes:
|
|
107
|
-
* - `type: 'birth'` / `id: 'birth'`
|
|
108
|
-
* - `type: EventType.BIRTH` / `id: Event.Birth`
|
|
109
|
-
*
|
|
110
|
-
* For `PropertyAccessExpression` (enum access), the *member name* is returned
|
|
111
|
-
* lower-cased — this works for the conventional `EventType.BIRTH = 'birth'` and
|
|
112
|
-
* `Event.Birth = 'birth'` mappings used in core and country configs.
|
|
113
|
-
*
|
|
114
|
-
* Returns null when no event type can be determined.
|
|
115
|
-
*/
|
|
116
|
-
function getEventType(configArg) {
|
|
117
|
-
for (const propName of [TYPE_PROPERTY_NAME, ID_PROPERTY_NAME]) {
|
|
118
|
-
const prop = configArg.getProperty(propName);
|
|
119
|
-
if (!prop || !ts_morph_1.Node.isPropertyAssignment(prop))
|
|
120
|
-
continue;
|
|
121
|
-
const initializer = prop.getInitializer();
|
|
122
|
-
if (!initializer)
|
|
123
|
-
continue;
|
|
124
|
-
if (ts_morph_1.Node.isStringLiteral(initializer)) {
|
|
125
|
-
return initializer.getLiteralValue().toLowerCase();
|
|
126
|
-
}
|
|
127
|
-
if (ts_morph_1.Node.isPropertyAccessExpression(initializer)) {
|
|
128
|
-
return initializer.getName().toLowerCase();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Returns true if an array literal contains an object literal with `id: <id>`.
|
|
135
|
-
*/
|
|
136
|
-
function hasElementWithId(array, id) {
|
|
137
|
-
for (const el of array.getElements()) {
|
|
138
|
-
if (!ts_morph_1.Node.isObjectLiteralExpression(el))
|
|
139
|
-
continue;
|
|
140
|
-
const idProp = el.getProperty('id');
|
|
141
|
-
if (!idProp || !ts_morph_1.Node.isPropertyAssignment(idProp))
|
|
142
|
-
continue;
|
|
143
|
-
const idInit = idProp.getInitializer();
|
|
144
|
-
if (idInit &&
|
|
145
|
-
ts_morph_1.Node.isStringLiteral(idInit) &&
|
|
146
|
-
idInit.getLiteralValue() === id) {
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
// ─── defineConfig helpers ─────────────────────────────────────────────────────
|
|
153
|
-
/**
|
|
154
|
-
* Ensures the top-level `flags` array in a `defineConfig` contains the
|
|
155
|
-
* `pending-first-certificate-issuance` flag definition. The flag's i18n
|
|
156
|
-
* `label.id` is namespaced per event type (e.g. `event.death.flag.…`).
|
|
157
|
-
*/
|
|
158
|
-
function ensureTopLevelFlagDefinition(configArg, eventType) {
|
|
159
|
-
const initializer = flagDefinitionInitializer(eventType);
|
|
160
|
-
const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME);
|
|
161
|
-
if (flagsProp && ts_morph_1.Node.isPropertyAssignment(flagsProp)) {
|
|
162
|
-
const flagsInit = flagsProp.getInitializer();
|
|
163
|
-
if (flagsInit && ts_morph_1.Node.isArrayLiteralExpression(flagsInit)) {
|
|
164
|
-
if (hasElementWithId(flagsInit, FLAG_ID))
|
|
165
|
-
return false;
|
|
166
|
-
flagsInit.addElement(initializer);
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
// No `flags` property at all — create it
|
|
172
|
-
configArg.addPropertyAssignment({
|
|
173
|
-
name: FLAGS_PROPERTY_NAME,
|
|
174
|
-
initializer: `[\n ${initializer}\n]`
|
|
175
|
-
});
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Ensures an action object's `flags` array contains `{ id: FLAG_ID, operation }`.
|
|
180
|
-
*/
|
|
181
|
-
function ensureActionOperationFlag(action, operation) {
|
|
182
|
-
const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME);
|
|
183
|
-
const entry = `{ id: '${FLAG_ID}', operation: '${operation}' }`;
|
|
184
|
-
if (flagsProp && ts_morph_1.Node.isPropertyAssignment(flagsProp)) {
|
|
185
|
-
const flagsInit = flagsProp.getInitializer();
|
|
186
|
-
if (flagsInit && ts_morph_1.Node.isArrayLiteralExpression(flagsInit)) {
|
|
187
|
-
if (hasElementWithId(flagsInit, FLAG_ID))
|
|
188
|
-
return false;
|
|
189
|
-
flagsInit.addElement(entry);
|
|
190
|
-
return true;
|
|
191
|
-
}
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
action.addPropertyAssignment({
|
|
195
|
-
name: FLAGS_PROPERTY_NAME,
|
|
196
|
-
initializer: `[${entry}]`
|
|
197
|
-
});
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Processes a `defineConfig` object: ensures top-level flag definition,
|
|
202
|
-
* REGISTER action flags, and PRINT_CERTIFICATE action flags.
|
|
203
|
-
* Returns the number of changes made.
|
|
204
|
-
*/
|
|
205
|
-
function processConfig(configArg, eventType, relPath) {
|
|
206
|
-
let changes = 0;
|
|
207
|
-
if (ensureTopLevelFlagDefinition(configArg, eventType)) {
|
|
208
|
-
changes++;
|
|
209
|
-
console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' to top-level flags`);
|
|
210
|
-
}
|
|
211
|
-
const actionsProp = configArg.getProperty(ACTIONS_PROPERTY_NAME);
|
|
212
|
-
if (!actionsProp || !ts_morph_1.Node.isPropertyAssignment(actionsProp))
|
|
213
|
-
return changes;
|
|
214
|
-
const actionsInit = actionsProp.getInitializer();
|
|
215
|
-
if (!actionsInit || !ts_morph_1.Node.isArrayLiteralExpression(actionsInit)) {
|
|
216
|
-
return changes;
|
|
217
|
-
}
|
|
218
|
-
for (const element of actionsInit.getElements()) {
|
|
219
|
-
if (!ts_morph_1.Node.isObjectLiteralExpression(element))
|
|
220
|
-
continue;
|
|
221
|
-
if (isActionOfType(element, REGISTER_TYPE)) {
|
|
222
|
-
if (ensureActionOperationFlag(element, 'add')) {
|
|
223
|
-
changes++;
|
|
224
|
-
console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' add-flag to REGISTER action`);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (isActionOfType(element, PRINT_CERTIFICATE_TYPE)) {
|
|
228
|
-
if (ensureActionOperationFlag(element, 'remove')) {
|
|
229
|
-
changes++;
|
|
230
|
-
console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return changes;
|
|
235
|
-
}
|
|
236
|
-
// ─── defineWorkqueues helpers ─────────────────────────────────────────────────
|
|
237
|
-
/**
|
|
238
|
-
* Returns true if a workqueue config object contains a PRINT_CERTIFICATE action
|
|
239
|
-
* in either the (deprecated) `actions` array or the `action` singular object.
|
|
240
|
-
*/
|
|
241
|
-
function hasPrintCertificateAction(workqueue) {
|
|
242
|
-
// Deprecated `actions` array
|
|
243
|
-
const actionsProp = workqueue.getProperty(ACTIONS_PROPERTY_NAME);
|
|
244
|
-
if (actionsProp && ts_morph_1.Node.isPropertyAssignment(actionsProp)) {
|
|
245
|
-
const actionsInit = actionsProp.getInitializer();
|
|
246
|
-
if (actionsInit && ts_morph_1.Node.isArrayLiteralExpression(actionsInit)) {
|
|
247
|
-
for (const el of actionsInit.getElements()) {
|
|
248
|
-
if (ts_morph_1.Node.isObjectLiteralExpression(el) &&
|
|
249
|
-
isActionOfType(el, PRINT_CERTIFICATE_TYPE)) {
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// Singular `action` object
|
|
256
|
-
const actionProp = workqueue.getProperty(ACTION_PROPERTY_NAME);
|
|
257
|
-
if (actionProp && ts_morph_1.Node.isPropertyAssignment(actionProp)) {
|
|
258
|
-
const actionInit = actionProp.getInitializer();
|
|
259
|
-
if (actionInit &&
|
|
260
|
-
ts_morph_1.Node.isObjectLiteralExpression(actionInit) &&
|
|
261
|
-
isActionOfType(actionInit, PRINT_CERTIFICATE_TYPE)) {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Adds `FLAG_ID` to `flags.anyOf` on a leaf query clause,
|
|
269
|
-
* merging with any existing `flags` object.
|
|
270
|
-
*/
|
|
271
|
-
function addFlagToQueryClause(clause) {
|
|
272
|
-
const flagsProp = clause.getProperty(FLAGS_PROPERTY_NAME);
|
|
273
|
-
if (flagsProp && ts_morph_1.Node.isPropertyAssignment(flagsProp)) {
|
|
274
|
-
const flagsInit = flagsProp.getInitializer();
|
|
275
|
-
if (flagsInit && ts_morph_1.Node.isObjectLiteralExpression(flagsInit)) {
|
|
276
|
-
const anyOfProp = flagsInit.getProperty(ANY_OF_PROPERTY_NAME);
|
|
277
|
-
if (anyOfProp && ts_morph_1.Node.isPropertyAssignment(anyOfProp)) {
|
|
278
|
-
const anyOfInit = anyOfProp.getInitializer();
|
|
279
|
-
if (anyOfInit && ts_morph_1.Node.isArrayLiteralExpression(anyOfInit)) {
|
|
280
|
-
const alreadyPresent = anyOfInit
|
|
281
|
-
.getElements()
|
|
282
|
-
.some((el) => ts_morph_1.Node.isStringLiteral(el) && el.getLiteralValue() === FLAG_ID);
|
|
283
|
-
if (alreadyPresent)
|
|
284
|
-
return false;
|
|
285
|
-
anyOfInit.addElement(`'${FLAG_ID}'`);
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
// flags exists but has no anyOf — add it
|
|
291
|
-
flagsInit.addPropertyAssignment({
|
|
292
|
-
name: ANY_OF_PROPERTY_NAME,
|
|
293
|
-
initializer: `['${FLAG_ID}']`
|
|
294
|
-
});
|
|
295
|
-
return true;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
clause.addPropertyAssignment({
|
|
301
|
-
name: FLAGS_PROPERTY_NAME,
|
|
302
|
-
initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${FLAG_ID}'] }`
|
|
303
|
-
});
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Recursively walks an `or`/`and` query container, calling `addFlagToQueryClause`
|
|
310
|
-
* on every leaf clause. Returns the number of clauses modified.
|
|
311
|
-
*/
|
|
312
|
-
function walkQueryForFlagAddition(queryObj) {
|
|
313
|
-
const typeProp = queryObj.getProperty(TYPE_PROPERTY_NAME);
|
|
314
|
-
if (typeProp && ts_morph_1.Node.isPropertyAssignment(typeProp)) {
|
|
315
|
-
const typeInit = typeProp.getInitializer();
|
|
316
|
-
if (typeInit &&
|
|
317
|
-
ts_morph_1.Node.isStringLiteral(typeInit) &&
|
|
318
|
-
(typeInit.getLiteralValue() === 'or' ||
|
|
319
|
-
typeInit.getLiteralValue() === 'and')) {
|
|
320
|
-
const clausesProp = queryObj.getProperty(CLAUSES_PROPERTY_NAME);
|
|
321
|
-
if (!clausesProp || !ts_morph_1.Node.isPropertyAssignment(clausesProp))
|
|
322
|
-
return 0;
|
|
323
|
-
const clausesInit = clausesProp.getInitializer();
|
|
324
|
-
if (!clausesInit || !ts_morph_1.Node.isArrayLiteralExpression(clausesInit))
|
|
325
|
-
return 0;
|
|
326
|
-
let changed = 0;
|
|
327
|
-
for (const clause of clausesInit.getElements()) {
|
|
328
|
-
if (ts_morph_1.Node.isObjectLiteralExpression(clause)) {
|
|
329
|
-
changed += walkQueryForFlagAddition(clause);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return changed;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
// Leaf clause
|
|
336
|
-
return addFlagToQueryClause(queryObj) ? 1 : 0;
|
|
337
|
-
}
|
|
338
|
-
// ─── File processor ──────────────────────────────────────────────────────────
|
|
339
|
-
function processFile(filePath, project) {
|
|
340
|
-
const sourceFile = project.getSourceFile(filePath);
|
|
341
|
-
if (!sourceFile)
|
|
342
|
-
return 0;
|
|
343
|
-
let totalChanges = 0;
|
|
344
|
-
const relPath = path_1.default.relative(process.cwd(), filePath);
|
|
345
|
-
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
346
|
-
for (const call of callExpressions) {
|
|
347
|
-
const expression = call.getExpression();
|
|
348
|
-
if (!ts_morph_1.Node.isIdentifier(expression))
|
|
349
|
-
continue;
|
|
350
|
-
const calleeName = expression.getText();
|
|
351
|
-
// ── defineConfig ──────────────────────────────────────────────────────────
|
|
352
|
-
if (calleeName === DEFINE_CONFIG_NAME) {
|
|
353
|
-
const args = call.getArguments();
|
|
354
|
-
if (args.length === 0)
|
|
355
|
-
continue;
|
|
356
|
-
const configArg = args[0];
|
|
357
|
-
if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
|
|
358
|
-
continue;
|
|
359
|
-
const eventType = getEventType(configArg);
|
|
360
|
-
if (!eventType)
|
|
361
|
-
continue;
|
|
362
|
-
totalChanges += processConfig(configArg, eventType, relPath);
|
|
363
|
-
}
|
|
364
|
-
// ── defineWorkqueues ──────────────────────────────────────────────────────
|
|
365
|
-
if (calleeName === DEFINE_WORKQUEUES_NAME) {
|
|
366
|
-
const args = call.getArguments();
|
|
367
|
-
if (args.length === 0)
|
|
368
|
-
continue;
|
|
369
|
-
const workqueuesArg = args[0];
|
|
370
|
-
if (!ts_morph_1.Node.isArrayLiteralExpression(workqueuesArg))
|
|
371
|
-
continue;
|
|
372
|
-
for (const workqueueEl of workqueuesArg.getElements()) {
|
|
373
|
-
if (!ts_morph_1.Node.isObjectLiteralExpression(workqueueEl))
|
|
374
|
-
continue;
|
|
375
|
-
if (!hasPrintCertificateAction(workqueueEl))
|
|
376
|
-
continue;
|
|
377
|
-
const queryProp = workqueueEl.getProperty(QUERY_PROPERTY_NAME);
|
|
378
|
-
if (!queryProp || !ts_morph_1.Node.isPropertyAssignment(queryProp))
|
|
379
|
-
continue;
|
|
380
|
-
const queryInit = queryProp.getInitializer();
|
|
381
|
-
if (!queryInit || !ts_morph_1.Node.isObjectLiteralExpression(queryInit))
|
|
382
|
-
continue;
|
|
383
|
-
const changed = walkQueryForFlagAddition(queryInit);
|
|
384
|
-
if (changed > 0) {
|
|
385
|
-
totalChanges += changed;
|
|
386
|
-
console.log(` [${relPath}] Added '${FLAG_ID}' to flags.anyOf in ${changed} PRINT_CERTIFICATE workqueue clause(s)`);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return totalChanges;
|
|
392
|
-
}
|
|
393
|
-
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
394
|
-
function main() {
|
|
395
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
-
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
397
|
-
console.log(`Scanning for defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
|
|
398
|
-
const project = new ts_morph_1.Project({
|
|
399
|
-
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
400
|
-
skipAddingFilesFromTsConfig: false
|
|
401
|
-
});
|
|
402
|
-
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
403
|
-
const fp = sf.getFilePath();
|
|
404
|
-
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
405
|
-
});
|
|
406
|
-
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
407
|
-
let totalChanges = 0;
|
|
408
|
-
const modifiedFiles = [];
|
|
409
|
-
for (const sourceFile of sourceFiles) {
|
|
410
|
-
const filePath = sourceFile.getFilePath();
|
|
411
|
-
const changes = processFile(filePath, project);
|
|
412
|
-
if (changes > 0) {
|
|
413
|
-
totalChanges += changes;
|
|
414
|
-
modifiedFiles.push(filePath);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
if (modifiedFiles.length === 0) {
|
|
418
|
-
console.log('No event configs or PRINT_CERTIFICATE workqueues found. Nothing to do.');
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
422
|
-
for (const filePath of modifiedFiles) {
|
|
423
|
-
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
424
|
-
yield sourceFile.save();
|
|
425
|
-
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
426
|
-
}
|
|
427
|
-
console.log(`\nDone. Applied ${totalChanges} change(s) across ${modifiedFiles.length} file(s).`);
|
|
428
|
-
});
|
|
429
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-resend-invite-notification.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-resend-invite-notification.ts"],"names":[],"mappings":"AA8ZA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|