@opencrvs/toolkit 2.0.0-rc.754b1d1 → 2.0.0-rc.764c76e

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.
Files changed (80) hide show
  1. package/dist/application-config/index.js +11 -39
  2. package/dist/cli.js +317 -1656
  3. package/dist/commons/api/router.d.ts +54 -55
  4. package/dist/commons/application-config/index.d.ts +4 -16
  5. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  6. package/dist/commons/events/FieldConfig.d.ts +0 -5
  7. package/dist/commons/events/locations.d.ts +1 -17
  8. package/dist/conditionals/index.js +7 -35
  9. package/dist/events/index.js +7 -73
  10. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  11. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +39 -63
  12. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -19
  13. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  14. package/dist/migrations/v2.0/checkout-upstream-files.js +13 -17
  15. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  16. package/dist/migrations/v2.0/convert-config-files-to-ts.js +5 -4
  17. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  18. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +5 -4
  19. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  20. package/dist/migrations/v2.0/create-events-index.js +2 -1
  21. package/dist/migrations/v2.0/index.d.ts +4 -8
  22. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  23. package/dist/migrations/v2.0/index.js +314 -1624
  24. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  25. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +7 -95
  26. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/migrate-scopes.js +7 -6
  28. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  29. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +4 -3
  30. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  31. package/dist/migrations/v2.0/migrate-workqueue-configs.js +4 -3
  32. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  33. package/dist/migrations/v2.0/remove-delete-actions.js +4 -3
  34. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  35. package/dist/migrations/v2.0/remove-demo-scope.js +3 -2
  36. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  37. package/dist/migrations/v2.0/remove-deprecated-imports.js +4 -3
  38. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  39. package/dist/migrations/v2.0/remove-hearth-migrations.js +2 -1
  40. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  41. package/dist/migrations/v2.0/remove-pending-certification-flag.js +4 -3
  42. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  43. package/dist/migrations/v2.0/remove-review-from-register-action.js +4 -3
  44. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  45. package/dist/migrations/v2.0/rename-api-paths.js +4 -3
  46. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  47. package/dist/migrations/v2.0/rename-location-parent-id.js +4 -3
  48. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  49. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +2 -1
  50. package/dist/notification/index.js +7 -35
  51. package/dist/scopes/index.d.ts +10 -82
  52. package/dist/scopes/index.js +8 -41
  53. package/opencrvs-toolkit-2.0.0-rc.764c76e.tgz +0 -0
  54. package/package.json +1 -1
  55. package/tsconfig.tsbuildinfo +1 -1
  56. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  57. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  58. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  59. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -3
  60. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  61. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -77
  62. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -3
  63. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  64. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -221
  65. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  66. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  67. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -342
  68. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  69. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  70. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  71. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  72. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  73. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  74. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  75. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  76. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  77. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  78. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  79. package/dist/migrations/v2.0/update-package-json.js +0 -105
  80. package/opencrvs-toolkit-2.0.0-rc.754b1d1.tgz +0 -0
@@ -243,8 +243,6 @@ __export(events_exports, {
243
243
  areConditionsMet: () => areConditionsMet,
244
244
  buildFormState: () => buildFormState,
245
245
  canAccessEventWithScope: () => canAccessEventWithScope,
246
- canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
247
- canAccessUserWithScope: () => canAccessUserWithScope,
248
246
  compositeFieldTypes: () => compositeFieldTypes,
249
247
  createEmptyDraft: () => createEmptyDraft,
250
248
  createFieldConditionals: () => createFieldConditionals,
@@ -491,10 +489,6 @@ var scopeByEvent = z2.preprocess(
491
489
  (val) => val === void 0 ? void 0 : [val].flat(),
492
490
  z2.array(z2.string()).optional()
493
491
  ).describe("Event type, e.g. birth, death");
494
- var userRole = z2.preprocess(
495
- (val) => val === void 0 ? void 0 : [val].flat(),
496
- z2.array(z2.string()).optional()
497
- ).describe("User role, e.g. admin, field agent");
498
492
  var scopeOptionsPlaceEvent = z2.object({
499
493
  event: scopeByEvent,
500
494
  placeOfEvent: JurisdictionFilter.optional()
@@ -518,9 +512,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
518
512
  var AccessLevelOptions = z2.object({
519
513
  accessLevel: JurisdictionFilter.optional()
520
514
  });
521
- var AllUserScopeOptions = AccessLevelOptions.extend({
522
- role: userRole.optional()
523
- });
524
515
  var WorkqueueOrDashboardOptions = z2.object({
525
516
  ids: z2.preprocess(
526
517
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -530,7 +521,6 @@ var WorkqueueOrDashboardOptions = z2.object({
530
521
  var AllScopeOptions = z2.object({
531
522
  ...AllRecordScopeOptions.shape,
532
523
  ...AccessLevelOptions.shape,
533
- ...AllUserScopeOptions.shape,
534
524
  ...WorkqueueOrDashboardOptions.shape
535
525
  });
536
526
  var ScopeOptionKey = AllScopeOptions.keyof();
@@ -603,31 +593,6 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
603
593
  ]).describe(
604
594
  "Scopes used to check user's permission to perform actions on a record."
605
595
  );
606
- var SystemScopeType = z2.enum([
607
- "organisation.read-locations",
608
- "user.read",
609
- "user.create",
610
- "user.edit"
611
- ]);
612
- var UserScopeType = SystemScopeType.extract([
613
- "user.read",
614
- "user.create",
615
- "user.edit"
616
- ]);
617
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
618
- var UserScopeV2 = z2.discriminatedUnion("type", [
619
- z2.object({
620
- type: ScopesWithRoleOption,
621
- options: AllUserScopeOptions.optional()
622
- }),
623
- z2.object({
624
- type: UserScopeType.extract(["user.read"]),
625
- options: AccessLevelOptions.optional()
626
- })
627
- ]);
628
- function scopeUsesRoleOptions(scope) {
629
- return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
630
- }
631
596
  function scopeUsesDeclaredOptions(scope) {
632
597
  return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
633
598
  }
@@ -660,14 +625,16 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
660
625
  }).optional()
661
626
  })
662
627
  ]).describe("Resolved scope with location/user IDs instead of filters.");
628
+ var SystemScopeType = z2.enum([
629
+ "organisation.read-locations",
630
+ "user.read",
631
+ "user.create",
632
+ "user.edit"
633
+ ]);
663
634
  var Scope = z2.discriminatedUnion("type", [
664
635
  z2.object({ type: PlainScopeType }),
665
636
  ...RecordScopeV2.options,
666
- ...UserScopeV2.options,
667
- z2.object({
668
- type: z2.literal("organisation.read-locations"),
669
- options: AccessLevelOptions.optional()
670
- }),
637
+ z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
671
638
  z2.object({
672
639
  type: z2.literal("workqueue"),
673
640
  options: WorkqueueOrDashboardOptions
@@ -9963,39 +9930,6 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
9963
9930
  }
9964
9931
  return true;
9965
9932
  }
9966
- function canAccessUserWithScope({
9967
- userToAccess,
9968
- scope,
9969
- user: user2
9970
- }) {
9971
- const opts = scope.options;
9972
- const hasSameOffice = user2.primaryOfficeId === userToAccess.primaryOfficeId;
9973
- if (opts?.accessLevel === JurisdictionFilter.enum.location && !hasSameOffice) {
9974
- return false;
9975
- }
9976
- const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
9977
- (id) => user2.administrativeAreaId === id
9978
- ) || user2.administrativeAreaId === null;
9979
- if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
9980
- return false;
9981
- }
9982
- if (scopeUsesRoleOptions(scope)) {
9983
- const { options } = scope;
9984
- if (options?.role && !options.role.includes(userToAccess.role)) {
9985
- return false;
9986
- }
9987
- }
9988
- return true;
9989
- }
9990
- function canAccessOtherUserWithScopes({
9991
- scopes,
9992
- userToAccess,
9993
- user: user2
9994
- }) {
9995
- return scopes.some(
9996
- (scope) => canAccessUserWithScope({ userToAccess, scope, user: user2 })
9997
- );
9998
- }
9999
9933
  function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
10000
9934
  return scopes.some(
10001
9935
  (scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
@@ -1 +1 @@
1
- {"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"AAycA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"AA6aA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -24,17 +24,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.main = main;
26
26
  /**
27
- * Codemod: Add `pending-first-certificate-issuance` flag to event configs and workqueues.
27
+ * Codemod: Add `pending-first-certificate-issuance` flag to birth event configs and workqueues.
28
28
  *
29
29
  * Usage:
30
30
  * ts-node -r tsconfig-paths/register src/migrations/v2.0/add-birth-certificate-issuance-flag.ts
31
31
  *
32
32
  * What it does:
33
- * defineConfig (every event type — birth, death, marriage, custom, etc.):
33
+ * defineConfig (birth type only):
34
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`.
35
+ * flag definition
38
36
  * - Ensures every `REGISTER` action has
39
37
  * `flags: [{ id: 'pending-first-certificate-issuance', operation: 'add' }]`
40
38
  * - Ensures every `PRINT_CERTIFICATE` action has
@@ -50,6 +48,7 @@ exports.main = main;
50
48
  */
51
49
  const ts_morph_1 = require("ts-morph");
52
50
  const path_1 = __importDefault(require("path"));
51
+ const _1 = require(".");
53
52
  const DEFINE_CONFIG_NAME = 'defineConfig';
54
53
  const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
55
54
  const ACTIONS_PROPERTY_NAME = 'actions';
@@ -57,27 +56,20 @@ const ACTION_PROPERTY_NAME = 'action';
57
56
  const FLAGS_PROPERTY_NAME = 'flags';
58
57
  const QUERY_PROPERTY_NAME = 'query';
59
58
  const TYPE_PROPERTY_NAME = 'type';
60
- const ID_PROPERTY_NAME = 'id';
61
59
  const CLAUSES_PROPERTY_NAME = 'clauses';
62
60
  const ANY_OF_PROPERTY_NAME = 'anyOf';
63
61
  const FLAG_ID = 'pending-first-certificate-issuance';
64
62
  const REGISTER_TYPE = 'REGISTER';
65
63
  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 `{
64
+ const FLAG_DEFINITION_INITIALIZER = `{
72
65
  id: '${FLAG_ID}',
73
66
  label: {
74
- id: 'event.${eventType}.flag.${FLAG_ID}',
67
+ id: 'event.birth.flag.${FLAG_ID}',
75
68
  defaultMessage: 'Pending first certificate issuance',
76
69
  description: 'Flag label for first certificate issuance'
77
70
  },
78
71
  requiresAction: true
79
72
  }`;
80
- }
81
73
  // ─── Generic helpers ──────────────────────────────────────────────────────────
82
74
  /**
83
75
  * Returns true if the object's `type` property matches the given type name.
@@ -99,36 +91,23 @@ function isActionOfType(obj, typeName) {
99
91
  return false;
100
92
  }
101
93
  /**
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.
94
+ * Returns true when the `defineConfig` root config object describes a birth event.
95
+ * Handles both `'birth'` string literal and `EventType.BIRTH` enum access.
115
96
  */
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
- }
97
+ function isBirthConfig(configArg) {
98
+ const typeProperty = configArg.getProperty(TYPE_PROPERTY_NAME);
99
+ if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
100
+ return false;
101
+ const initializer = typeProperty.getInitializer();
102
+ if (!initializer)
103
+ return false;
104
+ if (ts_morph_1.Node.isStringLiteral(initializer)) {
105
+ return initializer.getLiteralValue().toLowerCase() === 'birth';
106
+ }
107
+ if (ts_morph_1.Node.isPropertyAccessExpression(initializer)) {
108
+ return initializer.getName().toLowerCase() === 'birth';
130
109
  }
131
- return null;
110
+ return false;
132
111
  }
133
112
  /**
134
113
  * Returns true if an array literal contains an object literal with `id: <id>`.
@@ -151,19 +130,17 @@ function hasElementWithId(array, id) {
151
130
  }
152
131
  // ─── defineConfig helpers ─────────────────────────────────────────────────────
153
132
  /**
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.…`).
133
+ * Ensures the top-level `flags` array in a birth `defineConfig` contains the
134
+ * `pending-first-certificate-issuance` flag definition.
157
135
  */
158
- function ensureTopLevelFlagDefinition(configArg, eventType) {
159
- const initializer = flagDefinitionInitializer(eventType);
136
+ function ensureTopLevelFlagDefinition(configArg) {
160
137
  const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME);
161
138
  if (flagsProp && ts_morph_1.Node.isPropertyAssignment(flagsProp)) {
162
139
  const flagsInit = flagsProp.getInitializer();
163
140
  if (flagsInit && ts_morph_1.Node.isArrayLiteralExpression(flagsInit)) {
164
141
  if (hasElementWithId(flagsInit, FLAG_ID))
165
142
  return false;
166
- flagsInit.addElement(initializer);
143
+ flagsInit.addElement(FLAG_DEFINITION_INITIALIZER);
167
144
  return true;
168
145
  }
169
146
  return false;
@@ -171,7 +148,7 @@ function ensureTopLevelFlagDefinition(configArg, eventType) {
171
148
  // No `flags` property at all — create it
172
149
  configArg.addPropertyAssignment({
173
150
  name: FLAGS_PROPERTY_NAME,
174
- initializer: `[\n ${initializer}\n]`
151
+ initializer: `[\n ${FLAG_DEFINITION_INITIALIZER}\n]`
175
152
  });
176
153
  return true;
177
154
  }
@@ -198,15 +175,15 @@ function ensureActionOperationFlag(action, operation) {
198
175
  return true;
199
176
  }
200
177
  /**
201
- * Processes a `defineConfig` object: ensures top-level flag definition,
178
+ * Processes a birth defineConfig object: ensures top-level flag definition,
202
179
  * REGISTER action flags, and PRINT_CERTIFICATE action flags.
203
180
  * Returns the number of changes made.
204
181
  */
205
- function processConfig(configArg, eventType, relPath) {
182
+ function processBirthConfig(configArg, relPath) {
206
183
  let changes = 0;
207
- if (ensureTopLevelFlagDefinition(configArg, eventType)) {
184
+ if (ensureTopLevelFlagDefinition(configArg)) {
208
185
  changes++;
209
- console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' to top-level flags`);
186
+ console.log(` [${relPath}] Added '${FLAG_ID}' to top-level flags`);
210
187
  }
211
188
  const actionsProp = configArg.getProperty(ACTIONS_PROPERTY_NAME);
212
189
  if (!actionsProp || !ts_morph_1.Node.isPropertyAssignment(actionsProp))
@@ -221,13 +198,13 @@ function processConfig(configArg, eventType, relPath) {
221
198
  if (isActionOfType(element, REGISTER_TYPE)) {
222
199
  if (ensureActionOperationFlag(element, 'add')) {
223
200
  changes++;
224
- console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' add-flag to REGISTER action`);
201
+ console.log(` [${relPath}] Added '${FLAG_ID}' add-flag to REGISTER action`);
225
202
  }
226
203
  }
227
204
  if (isActionOfType(element, PRINT_CERTIFICATE_TYPE)) {
228
205
  if (ensureActionOperationFlag(element, 'remove')) {
229
206
  changes++;
230
- console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`);
207
+ console.log(` [${relPath}] Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`);
231
208
  }
232
209
  }
233
210
  }
@@ -341,7 +318,7 @@ function processFile(filePath, project) {
341
318
  if (!sourceFile)
342
319
  return 0;
343
320
  let totalChanges = 0;
344
- const relPath = path_1.default.relative(process.cwd(), filePath);
321
+ const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
345
322
  const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
346
323
  for (const call of callExpressions) {
347
324
  const expression = call.getExpression();
@@ -356,10 +333,9 @@ function processFile(filePath, project) {
356
333
  const configArg = args[0];
357
334
  if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
358
335
  continue;
359
- const eventType = getEventType(configArg);
360
- if (!eventType)
336
+ if (!isBirthConfig(configArg))
361
337
  continue;
362
- totalChanges += processConfig(configArg, eventType, relPath);
338
+ totalChanges += processBirthConfig(configArg, relPath);
363
339
  }
364
340
  // ── defineWorkqueues ──────────────────────────────────────────────────────
365
341
  if (calleeName === DEFINE_WORKQUEUES_NAME) {
@@ -393,8 +369,8 @@ function processFile(filePath, project) {
393
369
  // ─── Entry point ─────────────────────────────────────────────────────────────
394
370
  function main() {
395
371
  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`);
372
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
373
+ console.log(`Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
398
374
  const project = new ts_morph_1.Project({
399
375
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
400
376
  skipAddingFilesFromTsConfig: false
@@ -415,14 +391,14 @@ function main() {
415
391
  }
416
392
  }
417
393
  if (modifiedFiles.length === 0) {
418
- console.log('No event configs or PRINT_CERTIFICATE workqueues found. Nothing to do.');
394
+ console.log('No birth configs or PRINT_CERTIFICATE workqueues found. Nothing to do.');
419
395
  return;
420
396
  }
421
397
  console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
422
398
  for (const filePath of modifiedFiles) {
423
399
  const sourceFile = project.getSourceFileOrThrow(filePath);
424
400
  yield sourceFile.save();
425
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
401
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
426
402
  }
427
403
  console.log(`\nDone. Applied ${totalChanges} change(s) across ${modifiedFiles.length} file(s).`);
428
404
  });
@@ -1,22 +1,3 @@
1
- export declare const UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
2
- export declare const UPSTREAM_BRANCH = "develop";
3
- /**
4
- * Runs a git command in the country config working directory.
5
- *
6
- * By default stderr is inherited so the user sees progress output from
7
- * long-running commands (e.g. `git fetch`). Pass `silent: true` to suppress
8
- * both stdout and stderr when you only care about the exit code.
9
- */
10
- export declare function runGit(args: string[], { silent }?: {
11
- silent?: boolean;
12
- }): string;
13
- /**
14
- * Runs a git command and returns true on success, false on failure.
15
- * Stderr/stdout are suppressed — use only when the exit code is the only
16
- * signal you care about.
17
- */
18
- export declare function tryGit(args: string[]): boolean;
19
- export declare function assertIsGitRepo(): void;
20
1
  declare function main(): Promise<void>;
21
2
  export { main };
22
3
  //# sourceMappingURL=checkout-upstream-files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAG1D,eAAO,MAAM,eAAe,YAAY,CAAA;AAcxC;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA0GA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -19,10 +19,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
19
  });
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.UPSTREAM_BRANCH = exports.UPSTREAM_URL = void 0;
23
- exports.runGit = runGit;
24
- exports.tryGit = tryGit;
25
- exports.assertIsGitRepo = assertIsGitRepo;
26
22
  exports.main = main;
27
23
  /**
28
24
  * Codemod: Replace selected files with their upstream v2.0 versions from
@@ -58,16 +54,16 @@ exports.main = main;
58
54
  * - Requires the country config working directory to be a git repo.
59
55
  */
60
56
  const child_process_1 = require("child_process");
61
- exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
57
+ const _1 = require(".");
58
+ const UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
62
59
  // @TODO: This needs to be changed to 'release-v2.0.0' once the branch is created
63
- exports.UPSTREAM_BRANCH = 'develop';
60
+ const UPSTREAM_BRANCH = 'develop';
64
61
  // Remote name used only for the duration of this codemod. Prefixed to avoid
65
62
  // clashing with remotes the user may have (origin, upstream, etc.).
66
63
  const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
67
64
  const FILES_TO_CHECKOUT = [
68
- 'src/analytics/analytics.ts',
69
- 'Dockerfile',
70
- 'Dockerfile.assets'
65
+ 'infrastructure/postgres/setup-analytics.sh',
66
+ 'src/analytics/analytics.ts'
71
67
  ];
72
68
  // ─── Git helpers ─────────────────────────────────────────────────────────────
73
69
  /**
@@ -79,7 +75,7 @@ const FILES_TO_CHECKOUT = [
79
75
  */
80
76
  function runGit(args, { silent = false } = {}) {
81
77
  return (0, child_process_1.execFileSync)('git', args, {
82
- cwd: process.cwd(),
78
+ cwd: (0, _1.getCwd)(),
83
79
  encoding: 'utf8',
84
80
  stdio: silent ? ['ignore', 'pipe', 'pipe'] : ['ignore', 'pipe', 'inherit']
85
81
  });
@@ -100,22 +96,22 @@ function tryGit(args) {
100
96
  }
101
97
  function assertIsGitRepo() {
102
98
  if (!tryGit(['rev-parse', '--is-inside-work-tree'])) {
103
- throw new Error(`${process.cwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`);
99
+ throw new Error(`checkout-upstream-files: ${(0, _1.getCwd)()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`);
104
100
  }
105
101
  }
106
102
  // ─── Entry point ─────────────────────────────────────────────────────────────
107
103
  function main() {
108
104
  return __awaiter(this, void 0, void 0, function* () {
109
- console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${exports.UPSTREAM_URL}@${exports.UPSTREAM_BRANCH}...\n`);
105
+ console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${UPSTREAM_URL}@${UPSTREAM_BRANCH}...\n`);
110
106
  assertIsGitRepo();
111
107
  // Best-effort cleanup of a stale temp remote from a previous aborted run.
112
108
  tryGit(['remote', 'remove', TEMP_REMOTE]);
113
109
  try {
114
- console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${exports.UPSTREAM_URL}`);
115
- runGit(['remote', 'add', TEMP_REMOTE, exports.UPSTREAM_URL], { silent: true });
116
- console.log(` Fetching ${TEMP_REMOTE}/${exports.UPSTREAM_BRANCH} (depth 1)...`);
117
- runGit(['fetch', '--depth=1', TEMP_REMOTE, exports.UPSTREAM_BRANCH]);
118
- const ref = `${TEMP_REMOTE}/${exports.UPSTREAM_BRANCH}`;
110
+ console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${UPSTREAM_URL}`);
111
+ runGit(['remote', 'add', TEMP_REMOTE, UPSTREAM_URL], { silent: true });
112
+ console.log(` Fetching ${TEMP_REMOTE}/${UPSTREAM_BRANCH} (depth 1)...`);
113
+ runGit(['fetch', '--depth=1', TEMP_REMOTE, UPSTREAM_BRANCH]);
114
+ const ref = `${TEMP_REMOTE}/${UPSTREAM_BRANCH}`;
119
115
  const missing = [];
120
116
  let checkedOut = 0;
121
117
  for (const file of FILES_TO_CHECKOUT) {
@@ -1 +1 @@
1
- {"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AAuuBA,wBAAsB,IAAI,kBAyPzB"}
1
+ {"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AAyuBA,wBAAsB,IAAI,kBAyPzB"}
@@ -87,6 +87,7 @@ exports.main = main;
87
87
  const fs = __importStar(require("fs"));
88
88
  const ts_morph_1 = require("ts-morph");
89
89
  const path_1 = __importDefault(require("path"));
90
+ const _1 = require(".");
90
91
  // ─── Schema-valid keys per config type ───────────────────────────────────────
91
92
  const CLIENT_VALID_KEYS = new Set([
92
93
  'COUNTRY',
@@ -633,8 +634,8 @@ function ensureJoinImport(sf) {
633
634
  function main() {
634
635
  return __awaiter(this, void 0, void 0, function* () {
635
636
  var _a;
636
- const srcDir = path_1.default.join(process.cwd(), 'src');
637
- const relCwd = (fp) => path_1.default.relative(process.cwd(), fp);
637
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
638
+ const relCwd = (fp) => path_1.default.relative((0, _1.getCwd)(), fp);
638
639
  // ── Phase 1: Convert JS config files to TypeScript ────────────────────────
639
640
  console.log('Phase 1: Converting JS config files to TypeScript...\n');
640
641
  let convertedCount = 0;
@@ -740,7 +741,7 @@ function main() {
740
741
  if (/\bjoin\s*\(/.test(adjustedValue)) {
741
742
  ensureJoinImport(sf);
742
743
  }
743
- console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative(process.cwd(), sf.getFilePath())}`);
744
+ console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
744
745
  filesToSaveAfterInlining.add(sf);
745
746
  madeReplacement = true;
746
747
  break; // restart — tree has changed
@@ -751,7 +752,7 @@ function main() {
751
752
  // Persist files that received inline replacements
752
753
  for (const sf of Array.from(filesToSaveAfterInlining)) {
753
754
  yield sf.save();
754
- console.log(` Saved (inlined): ${path_1.default.relative(process.cwd(), sf.getFilePath())}`);
755
+ console.log(` Saved (inlined): ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
755
756
  }
756
757
  // Remove in reverse order to avoid index shifting
757
758
  for (const prop of [...propsToRemove].reverse()) {
@@ -1 +1 @@
1
- {"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"AAsJA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"AAwJA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -42,6 +42,7 @@ exports.main = main;
42
42
  */
43
43
  const ts_morph_1 = require("ts-morph");
44
44
  const path_1 = __importDefault(require("path"));
45
+ const _1 = require(".");
45
46
  const FIELD_TYPE_ENUM_NAME = 'FieldType';
46
47
  const PARAGRAPH_MEMBER_NAME = 'PARAGRAPH';
47
48
  const HEADING_MEMBER_NAME = 'HEADING';
@@ -111,18 +112,18 @@ function processFile(filePath, project) {
111
112
  const result = transformParagraphField(obj);
112
113
  if (result === 'converted-to-heading') {
113
114
  changedCount++;
114
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`);
115
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`);
115
116
  }
116
117
  else if (result === 'removed-font-variant') {
117
118
  changedCount++;
118
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`);
119
+ console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`);
119
120
  }
120
121
  }
121
122
  return changedCount;
122
123
  }
123
124
  function main() {
124
125
  return __awaiter(this, void 0, void 0, function* () {
125
- const srcDir = path_1.default.join(process.cwd(), 'src');
126
+ const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
126
127
  console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}\n`);
127
128
  const project = new ts_morph_1.Project({
128
129
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -151,7 +152,7 @@ function main() {
151
152
  for (const filePath of modifiedFiles) {
152
153
  const sourceFile = project.getSourceFileOrThrow(filePath);
153
154
  yield sourceFile.save();
154
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
155
+ console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
155
156
  }
156
157
  console.log(`\nDone. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
157
158
  });
@@ -1 +1 @@
1
- {"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"AAmTA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"AAqTA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -63,6 +63,7 @@ exports.main = main;
63
63
  const ts_morph_1 = require("ts-morph");
64
64
  const fs_1 = __importDefault(require("fs"));
65
65
  const path_1 = __importDefault(require("path"));
66
+ const _1 = require(".");
66
67
  const DEFINE_CONFIG_NAME = 'defineConfig';
67
68
  const HANDLER_FUNCTION_NAMES = new Set([
68
69
  'getCustomEventsHandler',
@@ -273,7 +274,7 @@ function modifyHandler(sourceFile, exportNames) {
273
274
  // ─── Entry point ─────────────────────────────────────────────────────────────
274
275
  function main() {
275
276
  return __awaiter(this, void 0, void 0, function* () {
276
- const cwd = process.cwd();
277
+ const cwd = (0, _1.getCwd)();
277
278
  const srcDir = path_1.default.join(cwd, 'src');
278
279
  console.log(`Scanning for defineConfig event exports in: ${srcDir}\n`);
279
280
  const project = new ts_morph_1.Project({
@@ -1,11 +1,7 @@
1
+ export declare function getCwd(): string;
1
2
  /**
2
- * Run the upgrade process for the country config in the current working
3
- * directory.
4
- *
5
- * @param dockerSwarm - When true, the local `infrastructure/` directory is
6
- * merged with upstream changes (Docker Swarm deployments still need it).
7
- * When false (the default), `infrastructure/` is deleted entirely, since
8
- * non-Swarm deployments no longer ship it.
3
+ * Run the upgrade process for a given country config directory.
4
+ * @param ccwd - The country config working directory.
9
5
  */
10
- export declare function runUpgrade(dockerSwarm: boolean): Promise<void>;
6
+ export declare function runUpgrade(ccwd: string | undefined): Promise<void>;
11
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AAqCA;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBA+BpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA+BA,wBAAgB,MAAM,WAMrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,iBA8BxD"}