@opencrvs/toolkit 2.0.0-rc.bbc299e → 2.0.0-rc.bc96f3a

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.
@@ -1895,9 +1895,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
1895
1895
  }
1896
1896
  return replacedCount;
1897
1897
  }
1898
- function resolveConfigChain(configObj, path23) {
1898
+ function resolveConfigChain(configObj, path24) {
1899
1899
  let current = configObj;
1900
- for (const key of path23) {
1900
+ for (const key of path24) {
1901
1901
  if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
1902
1902
  const prop = current.getProperty(key);
1903
1903
  if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
@@ -2405,7 +2405,9 @@ var decodeScope = (query) => {
2405
2405
  };
2406
2406
  var DEFAULT_SCOPE_OPTIONS = {
2407
2407
  placeOfEvent: JurisdictionFilter.enum.all,
2408
- accessLevel: JurisdictionFilter.enum.all
2408
+ accessLevel: JurisdictionFilter.enum.all,
2409
+ registeredIn: JurisdictionFilter.enum.all,
2410
+ declaredIn: JurisdictionFilter.enum.all
2409
2411
  };
2410
2412
 
2411
2413
  // ../commons/src/scopes.deprecated.do-not-use.ts
@@ -4843,9 +4845,9 @@ var import_path24 = require("path");
4843
4845
  var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
4844
4846
  var INFRASTRUCTURE_DIR = "infrastructure";
4845
4847
  var BASE_BRANCH = "release-v1.9";
4846
- function gitShowBytes(ref, path23) {
4848
+ function gitShowBytes(ref, path24) {
4847
4849
  try {
4848
- const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path23}`], {
4850
+ const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path24}`], {
4849
4851
  cwd: process.cwd(),
4850
4852
  stdio: ["ignore", "pipe", "pipe"]
4851
4853
  });
@@ -5021,6 +5023,94 @@ async function main26({
5021
5023
  );
5022
5024
  }
5023
5025
 
5026
+ // src/migrations/v2.0/fix-accept-requested-registration-function-type.ts
5027
+ var import_ts_morph22 = require("ts-morph");
5028
+ var import_path26 = __toESM(require("path"));
5029
+ var TARGET_FUNCTION_NAME = "acceptRequestedRegistration";
5030
+ var ACTION_PARAMETER_NAME = "action";
5031
+ var OLD_TYPE = "ActionInput";
5032
+ var NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
5033
+ function isAcceptRequestedRegistrationParameter(parameter) {
5034
+ const functionDeclaration = parameter.getFirstAncestorByKind(
5035
+ import_ts_morph22.SyntaxKind.FunctionDeclaration
5036
+ );
5037
+ if (functionDeclaration?.getName() === TARGET_FUNCTION_NAME) {
5038
+ return true;
5039
+ }
5040
+ const arrowFunction = parameter.getFirstAncestorByKind(
5041
+ import_ts_morph22.SyntaxKind.ArrowFunction
5042
+ );
5043
+ const variableDeclaration = arrowFunction?.getFirstAncestorByKind(
5044
+ import_ts_morph22.SyntaxKind.VariableDeclaration
5045
+ );
5046
+ return variableDeclaration?.getName() === TARGET_FUNCTION_NAME;
5047
+ }
5048
+ function processFile14(filePath, project) {
5049
+ const sourceFile = project.getSourceFile(filePath);
5050
+ if (!sourceFile) return 0;
5051
+ let updatedCount = 0;
5052
+ for (const parameter of sourceFile.getDescendantsOfKind(
5053
+ import_ts_morph22.SyntaxKind.Parameter
5054
+ )) {
5055
+ if (parameter.getName() !== ACTION_PARAMETER_NAME) {
5056
+ continue;
5057
+ }
5058
+ if (!isAcceptRequestedRegistrationParameter(parameter)) {
5059
+ continue;
5060
+ }
5061
+ const typeNode = parameter.getTypeNode();
5062
+ if (!typeNode || typeNode.getText() !== OLD_TYPE) {
5063
+ continue;
5064
+ }
5065
+ parameter.setType(NEW_TYPE);
5066
+ updatedCount++;
5067
+ console.log(
5068
+ ` [${import_path26.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' in ${TARGET_FUNCTION_NAME} to ${NEW_TYPE}`
5069
+ );
5070
+ }
5071
+ return updatedCount;
5072
+ }
5073
+ async function main27() {
5074
+ const srcDir = import_path26.default.join(process.cwd(), "src");
5075
+ console.log(`Scanning for ${TARGET_FUNCTION_NAME} in: ${srcDir}
5076
+ `);
5077
+ const project = new import_ts_morph22.Project({
5078
+ tsConfigFilePath: import_path26.default.resolve(srcDir, "../tsconfig.json"),
5079
+ skipAddingFilesFromTsConfig: false
5080
+ });
5081
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
5082
+ const filePath = sf.getFilePath();
5083
+ return filePath.includes("/src/") && !filePath.includes("/node_modules/");
5084
+ });
5085
+ let totalUpdated = 0;
5086
+ const modifiedFiles = [];
5087
+ for (const sourceFile of sourceFiles) {
5088
+ const filePath = sourceFile.getFilePath();
5089
+ const updated = processFile14(filePath, project);
5090
+ if (updated > 0) {
5091
+ totalUpdated += updated;
5092
+ modifiedFiles.push(filePath);
5093
+ }
5094
+ }
5095
+ if (modifiedFiles.length === 0) {
5096
+ console.log(
5097
+ `No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter in ${TARGET_FUNCTION_NAME} found. Nothing to do.`
5098
+ );
5099
+ return;
5100
+ }
5101
+ console.log(`
5102
+ Saving ${modifiedFiles.length} modified file(s)...`);
5103
+ for (const filePath of modifiedFiles) {
5104
+ const sourceFile = project.getSourceFileOrThrow(filePath);
5105
+ await sourceFile.save();
5106
+ console.log(` Saved: ${import_path26.default.relative(process.cwd(), filePath)}`);
5107
+ }
5108
+ console.log(
5109
+ `
5110
+ Done. Updated ${totalUpdated} parameter type annotation(s) in ${TARGET_FUNCTION_NAME}.`
5111
+ );
5112
+ }
5113
+
5024
5114
  // src/migrations/v2.0/index.ts
5025
5115
  var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
5026
5116
  async function runUpgrade(dockerSwarm) {
@@ -5047,6 +5137,7 @@ async function runUpgrade(dockerSwarm) {
5047
5137
  await main22();
5048
5138
  await main23();
5049
5139
  await main24();
5140
+ await main27();
5050
5141
  await main17();
5051
5142
  if (dockerSwarm) {
5052
5143
  await main25();
@@ -293,7 +293,9 @@ var ScopeType = z2.enum([
293
293
  var EncodedScope = z2.string().brand("EncodedScope");
294
294
  var DEFAULT_SCOPE_OPTIONS = {
295
295
  placeOfEvent: JurisdictionFilter.enum.all,
296
- accessLevel: JurisdictionFilter.enum.all
296
+ accessLevel: JurisdictionFilter.enum.all,
297
+ registeredIn: JurisdictionFilter.enum.all,
298
+ declaredIn: JurisdictionFilter.enum.all
297
299
  };
298
300
 
299
301
  // ../commons/src/authentication.ts
@@ -652,7 +654,10 @@ var ActionConditional = z7.discriminatedUnion("type", [
652
654
  ShowConditional,
653
655
  // Action can be shown to the user in the list but as disabled
654
656
  EnableConditional
655
- ]);
657
+ ]).meta({
658
+ description: "Action conditional configuration",
659
+ id: "ActionConditional"
660
+ });
656
661
  var DisplayOnReviewConditional = z7.object({
657
662
  type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
658
663
  conditional: Conditional
@@ -1303,6 +1308,9 @@ var FlagConfig = z15.object({
1303
1308
  "Indicates if this flag expects an action to be performed to be cleared."
1304
1309
  ),
1305
1310
  label: TranslationConfig.describe("Human readable label of the flag.")
1311
+ }).meta({
1312
+ description: "Flag configuration",
1313
+ id: "FlagConfig"
1306
1314
  });
1307
1315
  var ActionFlagConfig = z15.object({
1308
1316
  id: Flag,
@@ -1310,6 +1318,9 @@ var ActionFlagConfig = z15.object({
1310
1318
  conditional: Conditional.optional().describe(
1311
1319
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1312
1320
  )
1321
+ }).meta({
1322
+ description: "Action flag configuration",
1323
+ id: "ActionFlagConfig"
1313
1324
  });
1314
1325
 
1315
1326
  // ../commons/src/events/EventMetadata.ts
@@ -1651,7 +1662,7 @@ var FieldId = import_v43.default.string().superRefine((val, ctx) => {
1651
1662
  }
1652
1663
  }).describe("Unique identifier for the field");
1653
1664
  var FieldReference = import_v43.default.object({
1654
- $$field: FieldId,
1665
+ $$field: FieldId.describe("Id of the field to reference"),
1655
1666
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1656
1667
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1657
1668
  )
@@ -2364,10 +2375,10 @@ var VerificationPageConfig = FormPageConfig.extend({
2364
2375
  type: z21.literal(PageTypes.enum.VERIFICATION),
2365
2376
  actions: VerificationActionConfig
2366
2377
  });
2367
- var PageConfig = z21.discriminatedUnion("type", [
2368
- FormPageConfig,
2369
- VerificationPageConfig
2370
- ]);
2378
+ var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2379
+ description: "Page configuration",
2380
+ id: "PageConfig"
2381
+ });
2371
2382
 
2372
2383
  // ../commons/src/events/FormConfig.ts
2373
2384
  var DeclarationFormConfig = z22.object({
@@ -3667,7 +3678,7 @@ var _EventConfigBase = z33.object({
3667
3678
  ),
3668
3679
  label: TranslationConfig.describe("Human-readable label for the event type."),
3669
3680
  actions: z33.array(ActionConfig).describe(
3670
- "Configuration of system-defined actions associated with the event."
3681
+ "Configuration of core and custom actions associated with the event."
3671
3682
  ),
3672
3683
  actionOrder: z33.array(z33.string()).optional().describe(
3673
3684
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
@@ -3679,7 +3690,7 @@ var _EventConfigBase = z33.object({
3679
3690
  "Configuration of fields available in the advanced search feature."
3680
3691
  ),
3681
3692
  flags: z33.array(FlagConfig).optional().default([]).describe(
3682
- "Configuration of flags associated with the actions of this event type."
3693
+ "Configuration of custom flags associated with the actions of this event type."
3683
3694
  ),
3684
3695
  analytics: z33.boolean().optional().default(true).describe(
3685
3696
  "Indicates whether the records of this event type are included in analytics"
@@ -4117,18 +4128,11 @@ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
4117
4128
  query: true,
4118
4129
  columns: true
4119
4130
  });
4120
- var WorkqueueConfigInput = z37.object({
4121
- slug: z37.string().describe("Determines the url of the workqueue."),
4122
- name: TranslationConfig.describe(
4123
- "Title of the workflow (both in navigation and on the page)"
4124
- ),
4125
- query: CountryConfigQueryInputType,
4126
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4127
- "Workqueue call-to-action button configuration. This determines the quick action button shown on each event card and the action taken when the button is clicked."
4128
- ),
4129
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4130
- icon: AvailableIcons,
4131
- emptyMessage: TranslationConfig.optional()
4131
+ var WorkqueueConfigInput = WorkqueueConfig.extend({
4132
+ query: CountryConfigQueryInputType
4133
+ }).meta({
4134
+ description: "Workqueue configuration",
4135
+ id: "WorkqueueConfig"
4132
4136
  });
4133
4137
  var WorkqueueCountInput = z37.array(
4134
4138
  z37.object({ slug: z37.string(), query: QueryType })
@@ -365,7 +365,9 @@ var decodeScope = (query) => {
365
365
  };
366
366
  var DEFAULT_SCOPE_OPTIONS = {
367
367
  placeOfEvent: JurisdictionFilter.enum.all,
368
- accessLevel: JurisdictionFilter.enum.all
368
+ accessLevel: JurisdictionFilter.enum.all,
369
+ registeredIn: JurisdictionFilter.enum.all,
370
+ declaredIn: JurisdictionFilter.enum.all
369
371
  };
370
372
  function getScopeOptionValue(scope, option) {
371
373
  const options = "options" in scope ? scope.options : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.bbc299e",
3
+ "version": "2.0.0-rc.bc96f3a",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/add-resend-invite-notification.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/delete-infrastructure-directory.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/merge-infrastructure-directory.ts","./src/migrations/v2.0/migrate-application-config-url.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-fhir-url-helpers.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-old-statistics-service.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/remove-unused-environment-variables.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/migrations/v2.0/update-package-json.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
1
+ {"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/add-resend-invite-notification.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/delete-infrastructure-directory.ts","./src/migrations/v2.0/fix-accept-requested-registration-function-type.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/merge-infrastructure-directory.ts","./src/migrations/v2.0/migrate-application-config-url.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-fhir-url-helpers.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-old-statistics-service.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/remove-unused-environment-variables.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/migrations/v2.0/update-package-json.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}