@opencrvs/toolkit 2.0.0-rc.ca1536b → 2.0.0-rc.cb67c16

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/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, path23) {
1886
+ function resolveConfigChain(configObj, path24) {
1887
1887
  let current = configObj;
1888
- for (const key of path23) {
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;
@@ -2393,7 +2393,9 @@ var decodeScope = (query) => {
2393
2393
  };
2394
2394
  var DEFAULT_SCOPE_OPTIONS = {
2395
2395
  placeOfEvent: JurisdictionFilter.enum.all,
2396
- accessLevel: JurisdictionFilter.enum.all
2396
+ accessLevel: JurisdictionFilter.enum.all,
2397
+ registeredIn: JurisdictionFilter.enum.all,
2398
+ declaredIn: JurisdictionFilter.enum.all
2397
2399
  };
2398
2400
 
2399
2401
  // ../commons/src/scopes.deprecated.do-not-use.ts
@@ -4831,9 +4833,9 @@ var import_path24 = require("path");
4831
4833
  var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
4832
4834
  var INFRASTRUCTURE_DIR = "infrastructure";
4833
4835
  var BASE_BRANCH = "release-v1.9";
4834
- function gitShowBytes(ref, path23) {
4836
+ function gitShowBytes(ref, path24) {
4835
4837
  try {
4836
- const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path23}`], {
4838
+ const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path24}`], {
4837
4839
  cwd: process.cwd(),
4838
4840
  stdio: ["ignore", "pipe", "pipe"]
4839
4841
  });
@@ -5009,6 +5011,94 @@ async function main26({
5009
5011
  );
5010
5012
  }
5011
5013
 
5014
+ // src/migrations/v2.0/fix-accept-requested-registration-function-type.ts
5015
+ var import_ts_morph22 = require("ts-morph");
5016
+ var import_path26 = __toESM(require("path"));
5017
+ var TARGET_FUNCTION_NAME = "acceptRequestedRegistration";
5018
+ var ACTION_PARAMETER_NAME = "action";
5019
+ var OLD_TYPE = "ActionInput";
5020
+ var NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
5021
+ function isAcceptRequestedRegistrationParameter(parameter) {
5022
+ const functionDeclaration = parameter.getFirstAncestorByKind(
5023
+ import_ts_morph22.SyntaxKind.FunctionDeclaration
5024
+ );
5025
+ if (functionDeclaration?.getName() === TARGET_FUNCTION_NAME) {
5026
+ return true;
5027
+ }
5028
+ const arrowFunction = parameter.getFirstAncestorByKind(
5029
+ import_ts_morph22.SyntaxKind.ArrowFunction
5030
+ );
5031
+ const variableDeclaration = arrowFunction?.getFirstAncestorByKind(
5032
+ import_ts_morph22.SyntaxKind.VariableDeclaration
5033
+ );
5034
+ return variableDeclaration?.getName() === TARGET_FUNCTION_NAME;
5035
+ }
5036
+ function processFile14(filePath, project) {
5037
+ const sourceFile = project.getSourceFile(filePath);
5038
+ if (!sourceFile) return 0;
5039
+ let updatedCount = 0;
5040
+ for (const parameter of sourceFile.getDescendantsOfKind(
5041
+ import_ts_morph22.SyntaxKind.Parameter
5042
+ )) {
5043
+ if (parameter.getName() !== ACTION_PARAMETER_NAME) {
5044
+ continue;
5045
+ }
5046
+ if (!isAcceptRequestedRegistrationParameter(parameter)) {
5047
+ continue;
5048
+ }
5049
+ const typeNode = parameter.getTypeNode();
5050
+ if (!typeNode || typeNode.getText() !== OLD_TYPE) {
5051
+ continue;
5052
+ }
5053
+ parameter.setType(NEW_TYPE);
5054
+ updatedCount++;
5055
+ console.log(
5056
+ ` [${import_path26.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' in ${TARGET_FUNCTION_NAME} to ${NEW_TYPE}`
5057
+ );
5058
+ }
5059
+ return updatedCount;
5060
+ }
5061
+ async function main27() {
5062
+ const srcDir = import_path26.default.join(process.cwd(), "src");
5063
+ console.log(`Scanning for ${TARGET_FUNCTION_NAME} in: ${srcDir}
5064
+ `);
5065
+ const project = new import_ts_morph22.Project({
5066
+ tsConfigFilePath: import_path26.default.resolve(srcDir, "../tsconfig.json"),
5067
+ skipAddingFilesFromTsConfig: false
5068
+ });
5069
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
5070
+ const filePath = sf.getFilePath();
5071
+ return filePath.includes("/src/") && !filePath.includes("/node_modules/");
5072
+ });
5073
+ let totalUpdated = 0;
5074
+ const modifiedFiles = [];
5075
+ for (const sourceFile of sourceFiles) {
5076
+ const filePath = sourceFile.getFilePath();
5077
+ const updated = processFile14(filePath, project);
5078
+ if (updated > 0) {
5079
+ totalUpdated += updated;
5080
+ modifiedFiles.push(filePath);
5081
+ }
5082
+ }
5083
+ if (modifiedFiles.length === 0) {
5084
+ console.log(
5085
+ `No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter in ${TARGET_FUNCTION_NAME} found. Nothing to do.`
5086
+ );
5087
+ return;
5088
+ }
5089
+ console.log(`
5090
+ Saving ${modifiedFiles.length} modified file(s)...`);
5091
+ for (const filePath of modifiedFiles) {
5092
+ const sourceFile = project.getSourceFileOrThrow(filePath);
5093
+ await sourceFile.save();
5094
+ console.log(` Saved: ${import_path26.default.relative(process.cwd(), filePath)}`);
5095
+ }
5096
+ console.log(
5097
+ `
5098
+ Done. Updated ${totalUpdated} parameter type annotation(s) in ${TARGET_FUNCTION_NAME}.`
5099
+ );
5100
+ }
5101
+
5012
5102
  // src/migrations/v2.0/index.ts
5013
5103
  var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
5014
5104
  async function runUpgrade(dockerSwarm) {
@@ -5035,6 +5125,7 @@ async function runUpgrade(dockerSwarm) {
5035
5125
  await main22();
5036
5126
  await main23();
5037
5127
  await main24();
5128
+ await main27();
5038
5129
  await main17();
5039
5130
  if (dockerSwarm) {
5040
5131
  await main25();
@@ -5069,7 +5160,7 @@ Options:
5069
5160
  'infrastructure/' directory is deleted (default).
5070
5161
  -h, --help Show this message.
5071
5162
  `.trim();
5072
- function main27() {
5163
+ function main28() {
5073
5164
  const command = args[0];
5074
5165
  if (!command || command === "--help" || command === "-h") {
5075
5166
  console.log(USAGE);
@@ -5144,4 +5235,4 @@ function handleCheckTranslations() {
5144
5235
  console.warn("This command is not implemented yet!");
5145
5236
  process.exit(1);
5146
5237
  }
5147
- main27();
5238
+ main28();