@opencrvs/toolkit 1.9.12-rc.d89c437 → 1.9.12-rc.d93dd68
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 +8 -0
- package/dist/application-config/index.js +2045 -41
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +3237 -0
- package/dist/commons/api/router.d.ts +106 -75
- package/dist/commons/application-config/index.d.ts +13 -16
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/ActionDocument.d.ts +198 -198
- package/dist/commons/events/ActionInput.d.ts +113 -113
- package/dist/commons/events/ActionType.d.ts +3 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +16 -10
- package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
- package/dist/commons/events/CountryConfigQueryInput.d.ts +443 -172
- package/dist/commons/events/Draft.d.ts +15 -15
- package/dist/commons/events/DynamicFieldValue.d.ts +37 -19
- package/dist/commons/events/EventConfig.d.ts +1 -1
- package/dist/commons/events/EventDocument.d.ts +81 -81
- package/dist/commons/events/EventIndex.d.ts +35 -27
- package/dist/commons/events/EventInput.d.ts +1 -1
- package/dist/commons/events/EventMetadata.d.ts +24 -24
- package/dist/commons/events/FieldConfig.d.ts +155 -44
- package/dist/commons/events/FieldType.d.ts +2 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +98 -72
- package/dist/commons/events/FieldValue.d.ts +54 -26
- package/dist/commons/events/PlainDate.d.ts +1 -1
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +16 -16
- package/dist/commons/events/WorkqueueConfig.d.ts +438 -194
- package/dist/commons/events/defineConfig.d.ts +0 -4
- package/dist/commons/events/locations.d.ts +4 -4
- package/dist/commons/events/state/index.d.ts +2 -2
- package/dist/commons/events/state/utils.d.ts +3 -3
- package/dist/commons/events/utils.d.ts +5 -177
- package/dist/conditionals/index.js +13 -5
- package/dist/events/index.js +142 -33
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +405 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +829 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +159 -0
- package/dist/migrations/v2.0/index.d.ts +7 -0
- package/dist/migrations/v2.0/index.d.ts.map +1 -0
- package/dist/migrations/v2.0/index.js +3176 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +344 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-scopes.js +282 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +268 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +237 -0
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-delete-actions.js +157 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-demo-scope.js +75 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.js +97 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.js +78 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +110 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.js +164 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
- package/dist/migrations/v2.0/rename-api-paths.js +188 -0
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
- package/dist/migrations/v2.0/rename-location-parent-id.js +181 -0
- package/dist/notification/index.js +73 -23
- package/dist/scopes/index.d.ts +31 -10
- package/dist/scopes/index.js +17 -5
- package/opencrvs-toolkit-1.9.12-rc.d93dd68.tgz +0 -0
- package/package.json +11 -7
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-1.9.12-rc.d89c437.tgz +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
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: Rename Hapi route `path` values inside route configuration objects.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/rename-api-paths.ts
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans all TypeScript files under `src/`
|
|
34
|
+
* - Finds every object literal that looks like a Hapi route config, i.e. one that
|
|
35
|
+
* has both a `method` property whose value is a recognised HTTP verb (or an array
|
|
36
|
+
* of them) and a `path` property whose value is a string literal
|
|
37
|
+
* - Applies every rename listed in PATH_RENAMES to the `path` value
|
|
38
|
+
* - Saves the modified files in-place
|
|
39
|
+
*
|
|
40
|
+
* Adding new renames:
|
|
41
|
+
* Add an entry to the PATH_RENAMES map below. Keys are the old path strings,
|
|
42
|
+
* values are the new path strings. Exact string matching is used — no wildcards.
|
|
43
|
+
*/
|
|
44
|
+
const ts_morph_1 = require("ts-morph");
|
|
45
|
+
const path_1 = __importDefault(require("path"));
|
|
46
|
+
const _1 = require(".");
|
|
47
|
+
// ─── Path rename table ────────────────────────────────────────────────────────
|
|
48
|
+
// Add new renames here as further API paths are changed between versions.
|
|
49
|
+
const PATH_RENAMES = {
|
|
50
|
+
'/events': '/config/events',
|
|
51
|
+
'/application-config': '/config/application',
|
|
52
|
+
'/workqueue': '/config/workqueues',
|
|
53
|
+
'/locations': '/config/locations',
|
|
54
|
+
'/users': '/config/users',
|
|
55
|
+
'/roles': '/config/roles'
|
|
56
|
+
};
|
|
57
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
58
|
+
const METHOD_PROPERTY_NAME = 'method';
|
|
59
|
+
const PATH_PROPERTY_NAME = 'path';
|
|
60
|
+
const HTTP_VERBS = new Set([
|
|
61
|
+
'GET',
|
|
62
|
+
'POST',
|
|
63
|
+
'PUT',
|
|
64
|
+
'PATCH',
|
|
65
|
+
'DELETE',
|
|
66
|
+
'OPTIONS',
|
|
67
|
+
'HEAD',
|
|
68
|
+
'*'
|
|
69
|
+
]);
|
|
70
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
71
|
+
/**
|
|
72
|
+
* Returns true when the given object literal looks like a Hapi route config.
|
|
73
|
+
*
|
|
74
|
+
* A route config must have:
|
|
75
|
+
* - a `method` property whose value is either a recognised HTTP verb string
|
|
76
|
+
* literal, or an array literal whose elements are all recognised verb strings
|
|
77
|
+
* - a `path` property whose value is a string literal
|
|
78
|
+
*/
|
|
79
|
+
function isRouteConfig(obj) {
|
|
80
|
+
// ── method check ────────────────────────────────────────────────────────────
|
|
81
|
+
const methodProp = obj.getProperty(METHOD_PROPERTY_NAME);
|
|
82
|
+
if (!methodProp || !ts_morph_1.Node.isPropertyAssignment(methodProp))
|
|
83
|
+
return false;
|
|
84
|
+
const methodInit = methodProp.getInitializer();
|
|
85
|
+
if (!methodInit)
|
|
86
|
+
return false;
|
|
87
|
+
if (ts_morph_1.Node.isStringLiteral(methodInit)) {
|
|
88
|
+
if (!HTTP_VERBS.has(methodInit.getLiteralValue().toUpperCase()))
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
else if (ts_morph_1.Node.isArrayLiteralExpression(methodInit)) {
|
|
92
|
+
const allVerbs = methodInit
|
|
93
|
+
.getElements()
|
|
94
|
+
.every((el) => ts_morph_1.Node.isStringLiteral(el) &&
|
|
95
|
+
HTTP_VERBS.has(el.getLiteralValue().toUpperCase()));
|
|
96
|
+
if (!allVerbs)
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
// ── path check ──────────────────────────────────────────────────────────────
|
|
103
|
+
const pathProp = obj.getProperty(PATH_PROPERTY_NAME);
|
|
104
|
+
if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
|
|
105
|
+
return false;
|
|
106
|
+
const pathInit = pathProp.getInitializer();
|
|
107
|
+
return !!pathInit && ts_morph_1.Node.isStringLiteral(pathInit);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Applies PATH_RENAMES to the `path` property of a confirmed route config object.
|
|
111
|
+
* Returns the new path string if a rename was applied, or null if no change was made.
|
|
112
|
+
*/
|
|
113
|
+
function renameRoutePath(obj) {
|
|
114
|
+
const pathProp = obj.getProperty(PATH_PROPERTY_NAME);
|
|
115
|
+
if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
|
|
116
|
+
return null;
|
|
117
|
+
const pathInit = pathProp.getInitializer();
|
|
118
|
+
if (!pathInit || !ts_morph_1.Node.isStringLiteral(pathInit))
|
|
119
|
+
return null;
|
|
120
|
+
const oldPath = pathInit.getLiteralValue();
|
|
121
|
+
const newPath = PATH_RENAMES[oldPath];
|
|
122
|
+
if (!newPath)
|
|
123
|
+
return null;
|
|
124
|
+
pathInit.replaceWithText(`'${newPath}'`);
|
|
125
|
+
return newPath;
|
|
126
|
+
}
|
|
127
|
+
// ─── File processor ──────────────────────────────────────────────────────────
|
|
128
|
+
function processFile(filePath, project) {
|
|
129
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
130
|
+
if (!sourceFile)
|
|
131
|
+
return 0;
|
|
132
|
+
let renamedCount = 0;
|
|
133
|
+
const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
|
|
134
|
+
// Collect candidates first to avoid iterating a mutating tree
|
|
135
|
+
const candidates = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
136
|
+
for (const obj of candidates) {
|
|
137
|
+
if (!isRouteConfig(obj))
|
|
138
|
+
continue;
|
|
139
|
+
const newPath = renameRoutePath(obj);
|
|
140
|
+
if (newPath) {
|
|
141
|
+
renamedCount++;
|
|
142
|
+
console.log(` [${relPath}] Renamed route path → '${newPath}'`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return renamedCount;
|
|
146
|
+
}
|
|
147
|
+
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
148
|
+
function main() {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
151
|
+
console.log(`Scanning for Hapi route configs in: ${srcDir}\n`);
|
|
152
|
+
console.log('Active path renames:');
|
|
153
|
+
for (const [from, to] of Object.entries(PATH_RENAMES)) {
|
|
154
|
+
console.log(` '${from}' → '${to}'`);
|
|
155
|
+
}
|
|
156
|
+
console.log();
|
|
157
|
+
const project = new ts_morph_1.Project({
|
|
158
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
159
|
+
skipAddingFilesFromTsConfig: false
|
|
160
|
+
});
|
|
161
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
162
|
+
const fp = sf.getFilePath();
|
|
163
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
164
|
+
});
|
|
165
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
166
|
+
let totalRenamed = 0;
|
|
167
|
+
const modifiedFiles = [];
|
|
168
|
+
for (const sourceFile of sourceFiles) {
|
|
169
|
+
const filePath = sourceFile.getFilePath();
|
|
170
|
+
const renamed = processFile(filePath, project);
|
|
171
|
+
if (renamed > 0) {
|
|
172
|
+
totalRenamed += renamed;
|
|
173
|
+
modifiedFiles.push(filePath);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (modifiedFiles.length === 0) {
|
|
177
|
+
console.log('No matching route paths found. Nothing to do.');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
181
|
+
for (const filePath of modifiedFiles) {
|
|
182
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
183
|
+
yield sourceFile.save();
|
|
184
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
185
|
+
}
|
|
186
|
+
console.log(`\nDone. Renamed ${totalRenamed} route path(s).`);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"AAqJA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,181 @@
|
|
|
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: Rename `parentId` to `administrativeAreaId` on `Location` typed expressions.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/rename-location-parent-id.ts
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans all TypeScript files under `src/`
|
|
34
|
+
* - Finds every property access expression whose property name is `parentId`
|
|
35
|
+
* - Uses the TypeScript type checker to resolve the type of the object being accessed
|
|
36
|
+
* - Only renames to `administrativeAreaId` when the type (or any union constituent) is
|
|
37
|
+
* the OpenCRVS `Location` type, identified via three strategies in order:
|
|
38
|
+
* 1. Alias symbol name equals 'Location' (works when TypeScript preserves alias info)
|
|
39
|
+
* 2. Direct symbol name equals 'Location'
|
|
40
|
+
* 3. Structural fallback: the type is an object with the property set that uniquely
|
|
41
|
+
* identifies the OpenCRVS Location shape (id, name, externalId, locationType, and
|
|
42
|
+
* either administrativeAreaId or parentId)
|
|
43
|
+
* - Skips `parentId` accesses on any other type (e.g. plain objects, other interfaces)
|
|
44
|
+
* - Saves the modified files in-place
|
|
45
|
+
*/
|
|
46
|
+
const ts_morph_1 = require("ts-morph");
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
48
|
+
const _1 = require(".");
|
|
49
|
+
const OLD_PROPERTY_NAME = 'parentId';
|
|
50
|
+
const NEW_PROPERTY_NAME = 'administrativeAreaId';
|
|
51
|
+
const LOCATION_TYPE_NAME = 'Location';
|
|
52
|
+
// Properties that together uniquely identify the OpenCRVS Location type.
|
|
53
|
+
// Used as a structural fallback when TypeScript loses the alias name through
|
|
54
|
+
// re-export chains (e.g. z.infer<…> re-exported via @opencrvs/toolkit/events).
|
|
55
|
+
const LOCATION_STRUCTURAL_PROPS = [
|
|
56
|
+
'id',
|
|
57
|
+
'name',
|
|
58
|
+
'externalId',
|
|
59
|
+
'locationType'
|
|
60
|
+
];
|
|
61
|
+
// At least one of these must also be present (old name or new name)
|
|
62
|
+
const LOCATION_AREA_ID_PROPS = ['administrativeAreaId', 'parentId'];
|
|
63
|
+
// ─── Type helpers ─────────────────────────────────────────────────────────────
|
|
64
|
+
/**
|
|
65
|
+
* Returns true if a single (non-union) type resolves to the OpenCRVS Location type.
|
|
66
|
+
*
|
|
67
|
+
* Three strategies are tried in order so that the check remains robust across
|
|
68
|
+
* different TypeScript/ts-morph resolution paths:
|
|
69
|
+
*
|
|
70
|
+
* 1. Alias symbol name — works when TypeScript preserves the `type Location =
|
|
71
|
+
* z.infer<typeof Location>` alias through the re-export chain.
|
|
72
|
+
* 2. Direct symbol name — works when the type is represented by a named interface
|
|
73
|
+
* or class rather than an alias.
|
|
74
|
+
* 3. Structural match — fallback for when both symbol lookups fail (e.g. the
|
|
75
|
+
* alias is lost because the type was re-exported through a barrel or because
|
|
76
|
+
* z.infer<…> fully unwraps the alias). Checks for the combination of
|
|
77
|
+
* properties that uniquely identify the OpenCRVS Location shape.
|
|
78
|
+
*/
|
|
79
|
+
function isSingleLocationType(t) {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
// Strategy 1: alias symbol (zod-inferred type aliases surface here)
|
|
82
|
+
if (((_a = t.getAliasSymbol()) === null || _a === void 0 ? void 0 : _a.getName()) === LOCATION_TYPE_NAME)
|
|
83
|
+
return true;
|
|
84
|
+
// Strategy 2: direct symbol (plain interface / class)
|
|
85
|
+
if (((_b = t.getSymbol()) === null || _b === void 0 ? void 0 : _b.getName()) === LOCATION_TYPE_NAME)
|
|
86
|
+
return true;
|
|
87
|
+
// Strategy 3: structural fallback
|
|
88
|
+
if (t.isObject()) {
|
|
89
|
+
const propNames = new Set(t.getProperties().map((p) => p.getName()));
|
|
90
|
+
const hasCorePropNames = LOCATION_STRUCTURAL_PROPS.every((p) => propNames.has(p));
|
|
91
|
+
const hasAreaIdProp = LOCATION_AREA_ID_PROPS.some((p) => propNames.has(p));
|
|
92
|
+
if (hasCorePropNames && hasAreaIdProp)
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns true when the type of `node` is (or has a union constituent that is)
|
|
99
|
+
* the OpenCRVS Location type.
|
|
100
|
+
* Handles:
|
|
101
|
+
* - `Location`
|
|
102
|
+
* - `Location | undefined` (optional / nullable)
|
|
103
|
+
* - `Location | null | undefined`
|
|
104
|
+
*/
|
|
105
|
+
function isLocationType(node) {
|
|
106
|
+
let type;
|
|
107
|
+
try {
|
|
108
|
+
type = node.getType();
|
|
109
|
+
}
|
|
110
|
+
catch (_a) {
|
|
111
|
+
// getType() can throw on malformed/unresolvable nodes — skip them
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (isSingleLocationType(type))
|
|
115
|
+
return true;
|
|
116
|
+
// Walk union constituents (Location | undefined, Location | null, …)
|
|
117
|
+
for (const constituent of type.getUnionTypes()) {
|
|
118
|
+
if (isSingleLocationType(constituent))
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
// ─── File processor ──────────────────────────────────────────────────────────
|
|
124
|
+
function processFile(filePath, project) {
|
|
125
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
126
|
+
if (!sourceFile)
|
|
127
|
+
return 0;
|
|
128
|
+
let renamedCount = 0;
|
|
129
|
+
// Collect all matching nodes first to avoid mutating the tree while iterating
|
|
130
|
+
const candidates = sourceFile
|
|
131
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyAccessExpression)
|
|
132
|
+
.filter((propAccess) => propAccess.getName() === OLD_PROPERTY_NAME);
|
|
133
|
+
for (const propAccess of candidates) {
|
|
134
|
+
const obj = propAccess.getExpression();
|
|
135
|
+
if (!isLocationType(obj))
|
|
136
|
+
continue;
|
|
137
|
+
// Rename only the identifier node (the part after the dot) to preserve
|
|
138
|
+
// surrounding whitespace and optional-chain tokens (?.)
|
|
139
|
+
propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
|
|
140
|
+
renamedCount++;
|
|
141
|
+
console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} → Location.${NEW_PROPERTY_NAME}`);
|
|
142
|
+
}
|
|
143
|
+
return renamedCount;
|
|
144
|
+
}
|
|
145
|
+
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
146
|
+
function main() {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
149
|
+
console.log(`Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}\n`);
|
|
150
|
+
const project = new ts_morph_1.Project({
|
|
151
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
152
|
+
skipAddingFilesFromTsConfig: false
|
|
153
|
+
});
|
|
154
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
155
|
+
const fp = sf.getFilePath();
|
|
156
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
157
|
+
});
|
|
158
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
159
|
+
let totalRenamed = 0;
|
|
160
|
+
const modifiedFiles = [];
|
|
161
|
+
for (const sourceFile of sourceFiles) {
|
|
162
|
+
const filePath = sourceFile.getFilePath();
|
|
163
|
+
const renamed = processFile(filePath, project);
|
|
164
|
+
if (renamed > 0) {
|
|
165
|
+
totalRenamed += renamed;
|
|
166
|
+
modifiedFiles.push(filePath);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (modifiedFiles.length === 0) {
|
|
170
|
+
console.log(`No Location.${OLD_PROPERTY_NAME} references found. Nothing to do.`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
174
|
+
for (const filePath of modifiedFiles) {
|
|
175
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
176
|
+
yield sourceFile.save();
|
|
177
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
178
|
+
}
|
|
179
|
+
console.log(`\nDone. Renamed ${totalRenamed} Location.${OLD_PROPERTY_NAME} reference(s) to Location.${NEW_PROPERTY_NAME}.`);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
@@ -133,16 +133,16 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
133
133
|
var AccessLevelOptions = z2.object({
|
|
134
134
|
accessLevel: JurisdictionFilter.optional()
|
|
135
135
|
});
|
|
136
|
-
var
|
|
136
|
+
var WorkqueueOrDashboardOptions = z2.object({
|
|
137
137
|
ids: z2.preprocess(
|
|
138
138
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
139
139
|
z2.array(z2.string())
|
|
140
|
-
).describe("Must contain a list of workqueue ids.")
|
|
140
|
+
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
141
141
|
});
|
|
142
142
|
var AllScopeOptions = z2.object({
|
|
143
143
|
...AllRecordScopeOptions.shape,
|
|
144
144
|
...AccessLevelOptions.shape,
|
|
145
|
-
...
|
|
145
|
+
...WorkqueueOrDashboardOptions.shape
|
|
146
146
|
});
|
|
147
147
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
148
148
|
var ResolvedScopeOptionsPlaceEvent = z2.object({
|
|
@@ -244,13 +244,21 @@ var Scope = z2.discriminatedUnion("type", [
|
|
|
244
244
|
z2.object({ type: PlainScopeType }),
|
|
245
245
|
...RecordScopeV2.options,
|
|
246
246
|
z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
247
|
-
z2.object({
|
|
247
|
+
z2.object({
|
|
248
|
+
type: z2.literal("workqueue"),
|
|
249
|
+
options: WorkqueueOrDashboardOptions
|
|
250
|
+
}),
|
|
251
|
+
z2.object({
|
|
252
|
+
type: z2.literal("dashboard.view"),
|
|
253
|
+
options: WorkqueueOrDashboardOptions
|
|
254
|
+
})
|
|
248
255
|
]);
|
|
249
256
|
var ScopeType = z2.enum([
|
|
250
257
|
...SystemScopeType.options,
|
|
251
258
|
...RecordScopeTypeV2.options,
|
|
252
259
|
...PlainScopeType.options,
|
|
253
|
-
"workqueue"
|
|
260
|
+
"workqueue",
|
|
261
|
+
"dashboard.view"
|
|
254
262
|
]);
|
|
255
263
|
var EncodedScope = z2.string().brand("EncodedScope");
|
|
256
264
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
@@ -673,6 +681,7 @@ var FieldType = {
|
|
|
673
681
|
SIGNATURE: "SIGNATURE",
|
|
674
682
|
DATA: "DATA",
|
|
675
683
|
BUTTON: "BUTTON",
|
|
684
|
+
AUTOCOMPLETE: "AUTOCOMPLETE",
|
|
676
685
|
SEARCH: "SEARCH",
|
|
677
686
|
ALPHA_PRINT_BUTTON: "ALPHA_PRINT_BUTTON",
|
|
678
687
|
HTTP: "HTTP",
|
|
@@ -850,6 +859,11 @@ var AgeValue = z12.object({
|
|
|
850
859
|
asOfDateRef: z12.string()
|
|
851
860
|
});
|
|
852
861
|
var AgeUpdateValue = AgeValue.optional().nullable();
|
|
862
|
+
var AutocompleteValue = z12.object({
|
|
863
|
+
label: z12.string(),
|
|
864
|
+
value: z12.string()
|
|
865
|
+
});
|
|
866
|
+
var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
|
|
853
867
|
var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
|
|
854
868
|
var DatetimeValue = z12.iso.datetime();
|
|
855
869
|
var SelectDateRangeValue = z12.enum([
|
|
@@ -896,7 +910,9 @@ var LeafFieldValues = z12.union([
|
|
|
896
910
|
IdReaderFieldValue,
|
|
897
911
|
NumberWithUnitFieldValue,
|
|
898
912
|
NumberWithUnitFieldUpdateValue,
|
|
899
|
-
CustomFieldValue
|
|
913
|
+
CustomFieldValue,
|
|
914
|
+
AutocompleteValue,
|
|
915
|
+
AutocompleteUpdateValue
|
|
900
916
|
]);
|
|
901
917
|
var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
|
|
902
918
|
var DataFieldValue = z12.object({
|
|
@@ -978,7 +994,8 @@ var FieldUpdateValue = safeUnion([
|
|
|
978
994
|
HttpFieldUpdateValue.describe("HttpFieldUpdateValue"),
|
|
979
995
|
QueryParamReaderFieldUpdateValue.describe("QueryParamReaderFieldUpdateValue"),
|
|
980
996
|
CustomFieldValue.describe("CustomFieldValue"),
|
|
981
|
-
HiddenFieldValue.describe("HiddenFieldValue")
|
|
997
|
+
HiddenFieldValue.describe("HiddenFieldValue"),
|
|
998
|
+
AutocompleteUpdateValue.describe("AutocompleteUpdateValue")
|
|
982
999
|
]);
|
|
983
1000
|
|
|
984
1001
|
// ../commons/src/events/serializers/user/serializer.ts
|
|
@@ -1475,8 +1492,8 @@ var QueryExpression = import_v4.z.object({
|
|
|
1475
1492
|
"legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
|
|
1476
1493
|
"legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
|
|
1477
1494
|
"legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
|
|
1478
|
-
createdAtLocation: import_v4.z.optional(Within),
|
|
1479
|
-
updatedAtLocation: import_v4.z.optional(Within),
|
|
1495
|
+
createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
1496
|
+
updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
|
|
1480
1497
|
assignedTo: import_v4.z.optional(Exact),
|
|
1481
1498
|
createdByUserType: import_v4.z.optional(ExactUserType),
|
|
1482
1499
|
updatedByUserRole: import_v4.z.optional(Exact),
|
|
@@ -1813,17 +1830,14 @@ var ImageViewField = BaseField.extend({
|
|
|
1813
1830
|
}).describe("A read-only image component for form pages");
|
|
1814
1831
|
var Paragraph = BaseField.extend({
|
|
1815
1832
|
type: import_v43.default.literal(FieldType.PARAGRAPH),
|
|
1816
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
1817
1833
|
configuration: ParagraphConfiguration
|
|
1818
1834
|
}).describe("A read-only HTML <p> paragraph");
|
|
1819
1835
|
var Heading = BaseField.extend({
|
|
1820
1836
|
type: import_v43.default.literal(FieldType.HEADING),
|
|
1821
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
1822
1837
|
configuration: HeadingConfiguration
|
|
1823
1838
|
}).describe("A read-only heading component for form pages");
|
|
1824
1839
|
var PageHeader = BaseField.extend({
|
|
1825
|
-
type: import_v43.default.literal(FieldType.PAGE_HEADER)
|
|
1826
|
-
defaultValue: NonEmptyTextValue.optional()
|
|
1840
|
+
type: import_v43.default.literal(FieldType.PAGE_HEADER)
|
|
1827
1841
|
}).describe("A read-only header component for form pages");
|
|
1828
1842
|
var File = BaseField.extend({
|
|
1829
1843
|
type: import_v43.default.literal(FieldType.FILE),
|
|
@@ -1873,7 +1887,6 @@ var RadioGroup = BaseField.extend({
|
|
|
1873
1887
|
}).describe("Grouped radio options");
|
|
1874
1888
|
var BulletList = BaseField.extend({
|
|
1875
1889
|
type: import_v43.default.literal(FieldType.BULLET_LIST),
|
|
1876
|
-
defaultValue: TextValue.optional(),
|
|
1877
1890
|
items: import_v43.default.array(TranslationConfig).describe("A list of items"),
|
|
1878
1891
|
configuration: import_v43.default.object({
|
|
1879
1892
|
styles: import_v43.default.object({
|
|
@@ -2055,16 +2068,32 @@ var DataField = BaseField.extend({
|
|
|
2055
2068
|
data: import_v43.default.array(DataEntry)
|
|
2056
2069
|
})
|
|
2057
2070
|
}).describe("Data field for displaying read-only data");
|
|
2071
|
+
var ButtonSize = import_v43.default.enum(["small", "medium", "large"]);
|
|
2072
|
+
var ButtonType = import_v43.default.enum([
|
|
2073
|
+
"primary",
|
|
2074
|
+
"secondary",
|
|
2075
|
+
"tertiary",
|
|
2076
|
+
"positive",
|
|
2077
|
+
"negative",
|
|
2078
|
+
"secondaryNegative",
|
|
2079
|
+
"icon",
|
|
2080
|
+
"iconPrimary"
|
|
2081
|
+
]);
|
|
2082
|
+
var TextColor = import_v43.default.enum(["primary", "copy"]);
|
|
2083
|
+
var TextVariant = import_v43.default.enum(["bold14", "reg14"]);
|
|
2084
|
+
var ButtonConfiguration = import_v43.default.object({
|
|
2085
|
+
icon: import_v43.default.string().optional().describe("Icon for the button. You can find icons from OpenCRVS UI-Kit."),
|
|
2086
|
+
loading: import_v43.default.boolean().optional().describe("Whether the button is in a loading state and shows a spinner"),
|
|
2087
|
+
buttonSize: ButtonSize.optional().describe("Size of the button."),
|
|
2088
|
+
buttonType: ButtonType.optional().describe("Type of the button."),
|
|
2089
|
+
textColor: TextColor.optional().describe("Color of the text."),
|
|
2090
|
+
textVariant: TextVariant.optional().describe("Variant of the text."),
|
|
2091
|
+
text: TranslationConfig.describe("Text to display on the button")
|
|
2092
|
+
});
|
|
2058
2093
|
var ButtonField = BaseField.extend({
|
|
2059
2094
|
type: import_v43.default.literal(FieldType.BUTTON),
|
|
2060
2095
|
defaultValue: ButtonFieldValue.optional(),
|
|
2061
|
-
configuration:
|
|
2062
|
-
icon: import_v43.default.string().optional().describe(
|
|
2063
|
-
"Icon for the button. You can find icons from OpenCRVS UI-Kit."
|
|
2064
|
-
),
|
|
2065
|
-
loading: import_v43.default.boolean().optional().describe("Whether the button is in a loading state and shows a spinner"),
|
|
2066
|
-
text: TranslationConfig.describe("Text to display on the button")
|
|
2067
|
-
})
|
|
2096
|
+
configuration: ButtonConfiguration
|
|
2068
2097
|
}).describe("Generic button without any built-in functionality");
|
|
2069
2098
|
var FieldGroup = BaseField.extend({
|
|
2070
2099
|
type: import_v43.default.literal(FieldType.FIELD_GROUP),
|
|
@@ -2096,6 +2125,19 @@ var HttpField = BaseField.extend({
|
|
|
2096
2125
|
timeout: import_v43.default.number().default(15e3).describe("Request timeout in milliseconds")
|
|
2097
2126
|
})
|
|
2098
2127
|
}).describe("HTTP request function triggered by a button click or other event");
|
|
2128
|
+
var AutocompleteField = BaseField.extend({
|
|
2129
|
+
type: import_v43.default.literal(FieldType.AUTOCOMPLETE),
|
|
2130
|
+
configuration: import_v43.default.object({
|
|
2131
|
+
url: import_v43.default.string().describe("URL to fetch autocomplete suggestions from").optional(),
|
|
2132
|
+
method: import_v43.default.enum(["GET", "POST"]).default("GET").optional(),
|
|
2133
|
+
defaultOptions: import_v43.default.array(
|
|
2134
|
+
import_v43.default.object({
|
|
2135
|
+
label: import_v43.default.string(),
|
|
2136
|
+
value: import_v43.default.string()
|
|
2137
|
+
})
|
|
2138
|
+
).optional()
|
|
2139
|
+
})
|
|
2140
|
+
}).describe("Autocomplete input field");
|
|
2099
2141
|
var SearchField = HttpField.extend({
|
|
2100
2142
|
type: import_v43.default.literal(FieldType.SEARCH),
|
|
2101
2143
|
configuration: SearchQuery.pick({
|
|
@@ -2181,8 +2223,11 @@ var CustomField = BaseField.extend({
|
|
|
2181
2223
|
src: import_v43.default.string().describe("Module source path for the custom field component"),
|
|
2182
2224
|
configuration: import_v43.default.unknown().optional()
|
|
2183
2225
|
});
|
|
2226
|
+
var FieldStyleVariant = import_v43.default.enum(["default", "highlighted"]);
|
|
2184
2227
|
var LoaderField = BaseField.extend({
|
|
2185
2228
|
type: import_v43.default.literal(FieldType.LOADER),
|
|
2229
|
+
variant: FieldStyleVariant.default("default").optional(),
|
|
2230
|
+
hideLabel: import_v43.default.boolean().default(true).optional().describe("Loader field does not show a label by default"),
|
|
2186
2231
|
configuration: import_v43.default.object({
|
|
2187
2232
|
text: TranslationConfig.describe("Display text above the loading spinner")
|
|
2188
2233
|
})
|
|
@@ -2239,6 +2284,7 @@ var FieldConfig = import_v43.default.discriminatedUnion("type", [
|
|
|
2239
2284
|
ButtonField,
|
|
2240
2285
|
AlphaPrintButton,
|
|
2241
2286
|
HttpField,
|
|
2287
|
+
AutocompleteField,
|
|
2242
2288
|
LinkButtonField,
|
|
2243
2289
|
VerificationStatus,
|
|
2244
2290
|
QrReaderField,
|
|
@@ -3875,8 +3921,12 @@ var SerializedQueryExpression = z35.object({
|
|
|
3875
3921
|
"legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
|
|
3876
3922
|
"legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
|
|
3877
3923
|
"legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
|
|
3878
|
-
createdAtLocation: z35.optional(
|
|
3879
|
-
|
|
3924
|
+
createdAtLocation: z35.optional(
|
|
3925
|
+
z35.union([SerializableWithin, SerializableExact])
|
|
3926
|
+
),
|
|
3927
|
+
updatedAtLocation: z35.optional(
|
|
3928
|
+
z35.union([SerializableWithin, SerializableExact])
|
|
3929
|
+
),
|
|
3880
3930
|
updatedByUserRole: z35.optional(SerializableExact),
|
|
3881
3931
|
assignedTo: z35.optional(SerializableExact),
|
|
3882
3932
|
createdBy: z35.optional(SerializableExact),
|