@opencrvs/toolkit 2.0.0-rc.26c1189 → 2.0.0-rc.28e4d24
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/dist/application-config/index.js +20 -12
- package/dist/cli.js +95 -6
- package/dist/commons/api/router.d.ts +12151 -399
- package/dist/commons/events/ActionInput.d.ts +0 -36
- package/dist/commons/events/Draft.d.ts +0 -1
- package/dist/events/index.js +20 -13
- package/dist/migrations/v2.0/fix-action-confirmation-handler-type.d.ts +3 -0
- package/dist/migrations/v2.0/fix-action-confirmation-handler-type.d.ts.map +1 -0
- package/dist/migrations/v2.0/fix-action-confirmation-handler-type.js +113 -0
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +93 -4
- package/dist/notification/index.js +20 -13
- package/opencrvs-toolkit-2.0.0-rc.28e4d24.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.26c1189.tgz +0 -0
|
@@ -418,20 +418,28 @@ function schemaPriority(schema) {
|
|
|
418
418
|
return idx === -1 ? 9999 : idx;
|
|
419
419
|
}
|
|
420
420
|
function safeUnion(schemas) {
|
|
421
|
-
const sortedSchemas = [...schemas].sort(
|
|
422
|
-
(a, b) => schemaPriority(a) - schemaPriority(b)
|
|
423
|
-
);
|
|
424
421
|
return z7.any().superRefine((val, ctx) => {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
422
|
+
const successful = schemas.filter((s) => s.safeParse(val).success);
|
|
423
|
+
if (successful.length === 1) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (successful.length === 0) {
|
|
427
|
+
ctx.addIssue({
|
|
428
|
+
code: "invalid_type",
|
|
429
|
+
expected: "custom",
|
|
430
|
+
message: "Value does not match any schema"
|
|
431
|
+
});
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
|
|
435
|
+
const best = successful[0];
|
|
436
|
+
if (!best.safeParse(val).success) {
|
|
437
|
+
ctx.addIssue({
|
|
438
|
+
expected: "custom",
|
|
439
|
+
code: "invalid_type",
|
|
440
|
+
message: "Value did not match the best schema"
|
|
441
|
+
});
|
|
429
442
|
}
|
|
430
|
-
ctx.addIssue({
|
|
431
|
-
code: "invalid_type",
|
|
432
|
-
expected: "custom",
|
|
433
|
-
message: "Value does not match any schema"
|
|
434
|
-
});
|
|
435
443
|
}).meta({
|
|
436
444
|
description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
|
|
437
445
|
});
|
package/dist/cli.js
CHANGED
|
@@ -1883,9 +1883,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
return replacedCount;
|
|
1885
1885
|
}
|
|
1886
|
-
function resolveConfigChain(configObj,
|
|
1886
|
+
function resolveConfigChain(configObj, path24) {
|
|
1887
1887
|
let current = configObj;
|
|
1888
|
-
for (const key of
|
|
1888
|
+
for (const key of path24) {
|
|
1889
1889
|
if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
|
|
1890
1890
|
const prop = current.getProperty(key);
|
|
1891
1891
|
if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
|
|
@@ -4697,9 +4697,9 @@ var import_path24 = require("path");
|
|
|
4697
4697
|
var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
|
|
4698
4698
|
var INFRASTRUCTURE_DIR = "infrastructure";
|
|
4699
4699
|
var BASE_BRANCH = "release-v1.9";
|
|
4700
|
-
function gitShowBytes(ref,
|
|
4700
|
+
function gitShowBytes(ref, path24) {
|
|
4701
4701
|
try {
|
|
4702
|
-
const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${
|
|
4702
|
+
const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path24}`], {
|
|
4703
4703
|
cwd: process.cwd(),
|
|
4704
4704
|
stdio: ["ignore", "pipe", "pipe"]
|
|
4705
4705
|
});
|
|
@@ -4838,6 +4838,94 @@ async function main26() {
|
|
|
4838
4838
|
);
|
|
4839
4839
|
}
|
|
4840
4840
|
|
|
4841
|
+
// src/migrations/v2.0/fix-action-confirmation-handler-type.ts
|
|
4842
|
+
var import_ts_morph22 = require("ts-morph");
|
|
4843
|
+
var import_path26 = __toESM(require("path"));
|
|
4844
|
+
var TARGET_FUNCTION_NAME = "acceptRequestedRegistration";
|
|
4845
|
+
var ACTION_PARAMETER_NAME = "action";
|
|
4846
|
+
var OLD_TYPE = "ActionInput";
|
|
4847
|
+
var NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
|
|
4848
|
+
function isTargetFunctionParameter(parameter) {
|
|
4849
|
+
const functionDeclaration = parameter.getFirstAncestorByKind(
|
|
4850
|
+
import_ts_morph22.SyntaxKind.FunctionDeclaration
|
|
4851
|
+
);
|
|
4852
|
+
if (functionDeclaration?.getName() === TARGET_FUNCTION_NAME) {
|
|
4853
|
+
return true;
|
|
4854
|
+
}
|
|
4855
|
+
const arrowFunction = parameter.getFirstAncestorByKind(
|
|
4856
|
+
import_ts_morph22.SyntaxKind.ArrowFunction
|
|
4857
|
+
);
|
|
4858
|
+
const variableDeclaration = arrowFunction?.getFirstAncestorByKind(
|
|
4859
|
+
import_ts_morph22.SyntaxKind.VariableDeclaration
|
|
4860
|
+
);
|
|
4861
|
+
return variableDeclaration?.getName() === TARGET_FUNCTION_NAME;
|
|
4862
|
+
}
|
|
4863
|
+
function processFile14(filePath, project) {
|
|
4864
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
4865
|
+
if (!sourceFile) return 0;
|
|
4866
|
+
let updatedCount = 0;
|
|
4867
|
+
const parameters = sourceFile.getDescendantsOfKind(import_ts_morph22.SyntaxKind.Parameter);
|
|
4868
|
+
for (const parameter of parameters) {
|
|
4869
|
+
if (parameter.getName() !== ACTION_PARAMETER_NAME) {
|
|
4870
|
+
continue;
|
|
4871
|
+
}
|
|
4872
|
+
if (!isTargetFunctionParameter(parameter)) {
|
|
4873
|
+
continue;
|
|
4874
|
+
}
|
|
4875
|
+
const typeNode = parameter.getTypeNode();
|
|
4876
|
+
if (!typeNode) continue;
|
|
4877
|
+
if (typeNode.getText() !== OLD_TYPE) {
|
|
4878
|
+
continue;
|
|
4879
|
+
}
|
|
4880
|
+
parameter.setType(NEW_TYPE);
|
|
4881
|
+
updatedCount++;
|
|
4882
|
+
console.log(
|
|
4883
|
+
` [${import_path26.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' parameter type to ${NEW_TYPE}`
|
|
4884
|
+
);
|
|
4885
|
+
}
|
|
4886
|
+
return updatedCount;
|
|
4887
|
+
}
|
|
4888
|
+
async function main27() {
|
|
4889
|
+
const srcDir = import_path26.default.join(process.cwd(), "src");
|
|
4890
|
+
console.log(`Scanning for action confirmation handler types in: ${srcDir}
|
|
4891
|
+
`);
|
|
4892
|
+
const project = new import_ts_morph22.Project({
|
|
4893
|
+
tsConfigFilePath: import_path26.default.resolve(srcDir, "../tsconfig.json"),
|
|
4894
|
+
skipAddingFilesFromTsConfig: false
|
|
4895
|
+
});
|
|
4896
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
4897
|
+
const filePath = sf.getFilePath();
|
|
4898
|
+
return filePath.includes("/src/") && !filePath.includes("/node_modules/");
|
|
4899
|
+
});
|
|
4900
|
+
let totalUpdated = 0;
|
|
4901
|
+
const modifiedFiles = [];
|
|
4902
|
+
for (const sourceFile of sourceFiles) {
|
|
4903
|
+
const filePath = sourceFile.getFilePath();
|
|
4904
|
+
const updated = processFile14(filePath, project);
|
|
4905
|
+
if (updated > 0) {
|
|
4906
|
+
totalUpdated += updated;
|
|
4907
|
+
modifiedFiles.push(filePath);
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
if (modifiedFiles.length === 0) {
|
|
4911
|
+
console.log(
|
|
4912
|
+
`No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter signatures found. Nothing to do.`
|
|
4913
|
+
);
|
|
4914
|
+
return;
|
|
4915
|
+
}
|
|
4916
|
+
console.log(`
|
|
4917
|
+
Saving ${modifiedFiles.length} modified file(s)...`);
|
|
4918
|
+
for (const filePath of modifiedFiles) {
|
|
4919
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
4920
|
+
await sourceFile.save();
|
|
4921
|
+
console.log(` Saved: ${import_path26.default.relative(process.cwd(), filePath)}`);
|
|
4922
|
+
}
|
|
4923
|
+
console.log(
|
|
4924
|
+
`
|
|
4925
|
+
Done. Updated ${totalUpdated} '${ACTION_PARAMETER_NAME}' parameter type annotation(s).`
|
|
4926
|
+
);
|
|
4927
|
+
}
|
|
4928
|
+
|
|
4841
4929
|
// src/migrations/v2.0/index.ts
|
|
4842
4930
|
async function runUpgrade(dockerSwarm) {
|
|
4843
4931
|
await main18();
|
|
@@ -4860,6 +4948,7 @@ async function runUpgrade(dockerSwarm) {
|
|
|
4860
4948
|
await main19();
|
|
4861
4949
|
await main20();
|
|
4862
4950
|
await main21();
|
|
4951
|
+
await main27();
|
|
4863
4952
|
await main22();
|
|
4864
4953
|
await main23();
|
|
4865
4954
|
await main24();
|
|
@@ -4896,7 +4985,7 @@ Options:
|
|
|
4896
4985
|
'infrastructure/' directory is deleted (default).
|
|
4897
4986
|
-h, --help Show this message.
|
|
4898
4987
|
`.trim();
|
|
4899
|
-
function
|
|
4988
|
+
function main28() {
|
|
4900
4989
|
const command = args[0];
|
|
4901
4990
|
if (!command || command === "--help" || command === "-h") {
|
|
4902
4991
|
console.log(USAGE);
|
|
@@ -4971,4 +5060,4 @@ function handleCheckTranslations() {
|
|
|
4971
5060
|
console.warn("This command is not implemented yet!");
|
|
4972
5061
|
process.exit(1);
|
|
4973
5062
|
}
|
|
4974
|
-
|
|
5063
|
+
main28();
|