@opencrvs/toolkit 1.9.12-rc.ab1347b → 1.9.12-rc.ab196db

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 +1 -1
  2. package/dist/cli.js +1890 -278
  3. package/dist/commons/api/router.d.ts +175 -163
  4. package/dist/commons/events/AuditLog.d.ts +2 -0
  5. package/dist/commons/events/EventConfig.d.ts +3 -1
  6. package/dist/commons/events/FieldConfig.d.ts +2 -2
  7. package/dist/commons/events/scopes.d.ts +1 -1
  8. package/dist/commons/notification/UserNotifications.d.ts +15 -0
  9. package/dist/events/index.js +18 -4
  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 +3 -4
  12. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  13. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  14. package/dist/migrations/v2.0/add-resend-invite-notification.js +356 -0
  15. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +22 -0
  16. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
  17. package/dist/migrations/v2.0/checkout-upstream-files.js +147 -0
  18. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  19. package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
  20. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  21. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
  22. package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
  23. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
  24. package/dist/migrations/v2.0/create-events-index.js +325 -0
  25. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  26. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  27. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  28. package/dist/migrations/v2.0/index.d.ts +8 -4
  29. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  30. package/dist/migrations/v2.0/index.js +1860 -277
  31. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  32. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +5 -6
  33. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  34. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  35. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  36. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  37. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  38. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  39. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  40. package/dist/migrations/v2.0/migrate-scopes.js +6 -7
  41. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  42. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
  43. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  44. package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
  45. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  46. package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
  47. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  48. package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
  49. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  50. package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
  51. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  52. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  53. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  54. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  55. package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
  56. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  57. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  58. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  59. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  60. package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
  61. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  62. package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
  63. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  64. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  65. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  66. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  67. package/dist/migrations/v2.0/rename-api-paths.js +3 -4
  68. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  69. package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
  70. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
  71. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
  72. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +195 -0
  73. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  74. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  75. package/dist/migrations/v2.0/update-package-json.js +105 -0
  76. package/dist/notification/index.js +11 -2
  77. package/opencrvs-toolkit-1.9.12-rc.ab196db.tgz +0 -0
  78. package/package.json +1 -1
  79. package/tsconfig.tsbuildinfo +1 -1
  80. package/opencrvs-toolkit-1.9.12-rc.ab1347b.tgz +0 -0
@@ -60,6 +60,7 @@ export declare const UserAuditRecordInput: z.ZodDiscriminatedUnion<[z.ZodObject<
60
60
  "user.password_changed": "user.password_changed";
61
61
  "user.password_reset": "user.password_reset";
62
62
  "user.password_reset_by_admin": "user.password_reset_by_admin";
63
+ "user.resend_invite": "user.resend_invite";
63
64
  "user.username_reminder": "user.username_reminder";
64
65
  "user.username_reminder_by_admin": "user.username_reminder_by_admin";
65
66
  }>;
@@ -340,6 +341,7 @@ export declare const AuditLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
340
341
  "user.password_changed": "user.password_changed";
341
342
  "user.password_reset": "user.password_reset";
342
343
  "user.password_reset_by_admin": "user.password_reset_by_admin";
344
+ "user.resend_invite": "user.resend_invite";
343
345
  "user.username_reminder": "user.username_reminder";
344
346
  "user.username_reminder_by_admin": "user.username_reminder_by_admin";
345
347
  }>;
@@ -29,14 +29,16 @@ export type EventConfig = {
29
29
  declaration: DeclarationFormConfig;
30
30
  advancedSearch: AdvancedSearchConfig[];
31
31
  flags: FlagConfig[];
32
+ analytics: boolean;
32
33
  };
33
- export type EventConfigInput = Omit<EventConfig, 'advancedSearch' | 'flags' | 'declaration' | 'actions' | 'dateOfEvent' | 'placeOfEvent'> & {
34
+ export type EventConfigInput = Omit<EventConfig, 'advancedSearch' | 'flags' | 'declaration' | 'actions' | 'dateOfEvent' | 'placeOfEvent' | 'analytics'> & {
34
35
  dateOfEvent?: z.input<typeof FieldReference> | z.infer<typeof EventFieldReference>;
35
36
  placeOfEvent?: z.input<typeof FieldReference>;
36
37
  advancedSearch?: AdvancedSearchConfig[];
37
38
  flags?: FlagConfig[];
38
39
  declaration: DeclarationFormConfigInput;
39
40
  actions: z.input<typeof ActionConfig>[];
41
+ analytics?: boolean;
40
42
  };
41
43
  export declare const EventConfig: z.ZodType<EventConfig, EventConfigInput>;
42
44
  //# sourceMappingURL=EventConfig.d.ts.map
@@ -1799,7 +1799,7 @@ declare const LocationInput: z.ZodObject<{
1799
1799
  }>;
1800
1800
  $location: z.ZodOptional<z.ZodString>;
1801
1801
  }, z.core.$strip>]>>;
1802
- configuration: z.ZodObject<{
1802
+ configuration: z.ZodOptional<z.ZodObject<{
1803
1803
  locationTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1804
1804
  allowedLocations: z.ZodOptional<z.ZodObject<{
1805
1805
  $jurisdiction: z.ZodUnion<[z.ZodEnum<{
@@ -1856,7 +1856,7 @@ declare const LocationInput: z.ZodObject<{
1856
1856
  }>;
1857
1857
  }, z.core.$strip>]>;
1858
1858
  }, z.core.$strip>>;
1859
- }, z.core.$strip>;
1859
+ }, z.core.$strip>>;
1860
1860
  }, z.core.$strip>;
1861
1861
  export type LocationInput = z.infer<typeof LocationInput>;
1862
1862
  declare const FileUploadWithOptions: z.ZodObject<{
@@ -9,7 +9,7 @@ export declare const ACTION_SCOPE_MAP: {
9
9
  NOTIFY: "record.notify"[];
10
10
  DECLARE: ("record.declare" | "record.register")[];
11
11
  EDIT: "record.edit"[];
12
- DELETE: "record.declare"[];
12
+ DELETE: ("record.declare" | "record.notify")[];
13
13
  REGISTER: "record.register"[];
14
14
  PRINT_CERTIFICATE: "record.print-certified-copies"[];
15
15
  REQUEST_CORRECTION: ("record.request-correction" | "record.correct")[];
@@ -5,6 +5,7 @@ export declare const TriggerEvent: {
5
5
  readonly USERNAME_REMINDER: "username-reminder";
6
6
  readonly RESET_PASSWORD: "reset-password";
7
7
  readonly RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin";
8
+ readonly RESEND_INVITE: "resend-invite";
8
9
  readonly TWO_FA: "2fa";
9
10
  readonly ALL_USER_NOTIFICATION: "all-user-notification";
10
11
  readonly CHANGE_PHONE_NUMBER: "change-phone-number";
@@ -112,6 +113,20 @@ export declare const TriggerPayload: {
112
113
  role: z.ZodString;
113
114
  }, z.core.$strip>;
114
115
  }, z.core.$strip>;
116
+ readonly "resend-invite": z.ZodObject<{
117
+ recipient: z.ZodObject<{
118
+ name: z.ZodOptional<z.ZodObject<{
119
+ firstname: z.ZodString;
120
+ surname: z.ZodString;
121
+ middlename: z.ZodOptional<z.ZodString>;
122
+ }, z.core.$strip>>;
123
+ mobile: z.ZodOptional<z.ZodString>;
124
+ email: z.ZodOptional<z.ZodString>;
125
+ bcc: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ }, z.core.$strip>;
127
+ username: z.ZodString;
128
+ temporaryPassword: z.ZodString;
129
+ }, z.core.$strip>;
115
130
  readonly "2fa": z.ZodObject<{
116
131
  recipient: z.ZodObject<{
117
132
  name: z.ZodOptional<z.ZodObject<{
@@ -938,6 +938,7 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
938
938
  "user.password_changed",
939
939
  "user.password_reset",
940
940
  "user.password_reset_by_admin",
941
+ "user.resend_invite",
941
942
  "user.username_reminder",
942
943
  "user.username_reminder_by_admin"
943
944
  ]),
@@ -2500,7 +2501,7 @@ var LocationInput = BaseField.extend({
2500
2501
  configuration: import_v43.default.object({
2501
2502
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2502
2503
  allowedLocations: AllowedLocations
2503
- })
2504
+ }).optional()
2504
2505
  }).describe("Input field for a location");
2505
2506
  var FileUploadWithOptions = BaseField.extend({
2506
2507
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
@@ -4574,7 +4575,16 @@ function aggregateActionDeclarations(event2) {
4574
4575
  if (!requestAction) {
4575
4576
  return declaration;
4576
4577
  }
4577
- return getCompleteActionDeclaration(declaration, event2, requestAction);
4578
+ const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4579
+ declaration,
4580
+ event2,
4581
+ requestAction
4582
+ );
4583
+ return getCompleteActionDeclaration(
4584
+ declarationWithApprovedCorrection,
4585
+ event2,
4586
+ action
4587
+ );
4578
4588
  }
4579
4589
  return getCompleteActionDeclaration(declaration, event2, action);
4580
4590
  }, {});
@@ -5342,6 +5352,9 @@ var _EventConfigBase = z33.object({
5342
5352
  ),
5343
5353
  flags: z33.array(FlagConfig).optional().default([]).describe(
5344
5354
  "Configuration of flags associated with the actions of this event type."
5355
+ ),
5356
+ analytics: z33.boolean().optional().default(true).describe(
5357
+ "Indicates whether the records of this event type are included in analytics"
5345
5358
  )
5346
5359
  });
5347
5360
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -9930,7 +9943,7 @@ var ACTION_SCOPE_MAP = {
9930
9943
  [ActionType.NOTIFY]: ["record.notify"],
9931
9944
  [ActionType.DECLARE]: ["record.declare", "record.register"],
9932
9945
  [ActionType.EDIT]: ["record.edit"],
9933
- [ActionType.DELETE]: ["record.declare"],
9946
+ [ActionType.DELETE]: ["record.declare", "record.notify"],
9934
9947
  [ActionType.REGISTER]: ["record.register"],
9935
9948
  [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
9936
9949
  [ActionType.REQUEST_CORRECTION]: [
@@ -10010,7 +10023,8 @@ function userDeserializer(serializedUserField, user2) {
10010
10023
  `Deserializer for ${serializedUserField.$userField} is not implemented yet`
10011
10024
  );
10012
10025
  }
10013
- return user2[serializedUserField.$userField] ?? void 0;
10026
+ const value = user2[serializedUserField.$userField];
10027
+ return typeof value === "string" ? value : void 0;
10014
10028
  }
10015
10029
  function isDefined(value) {
10016
10030
  return value !== void 0;
@@ -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":"AA6aA,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":"AA2aA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -48,7 +48,6 @@ exports.main = main;
48
48
  */
49
49
  const ts_morph_1 = require("ts-morph");
50
50
  const path_1 = __importDefault(require("path"));
51
- const _1 = require(".");
52
51
  const DEFINE_CONFIG_NAME = 'defineConfig';
53
52
  const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
54
53
  const ACTIONS_PROPERTY_NAME = 'actions';
@@ -318,7 +317,7 @@ function processFile(filePath, project) {
318
317
  if (!sourceFile)
319
318
  return 0;
320
319
  let totalChanges = 0;
321
- const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
320
+ const relPath = path_1.default.relative(process.cwd(), filePath);
322
321
  const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
323
322
  for (const call of callExpressions) {
324
323
  const expression = call.getExpression();
@@ -369,7 +368,7 @@ function processFile(filePath, project) {
369
368
  // ─── Entry point ─────────────────────────────────────────────────────────────
370
369
  function main() {
371
370
  return __awaiter(this, void 0, void 0, function* () {
372
- const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
371
+ const srcDir = path_1.default.join(process.cwd(), 'src');
373
372
  console.log(`Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
374
373
  const project = new ts_morph_1.Project({
375
374
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -398,7 +397,7 @@ function main() {
398
397
  for (const filePath of modifiedFiles) {
399
398
  const sourceFile = project.getSourceFileOrThrow(filePath);
400
399
  yield sourceFile.save();
401
- console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
400
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
402
401
  }
403
402
  console.log(`\nDone. Applied ${totalChanges} change(s) across ${modifiedFiles.length} file(s).`);
404
403
  });
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=add-resend-invite-notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-resend-invite-notification.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-resend-invite-notification.ts"],"names":[],"mappings":"AAgYA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,356 @@
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: Add `TriggerEvent.RESEND_INVITE` wiring to the country config
28
+ * (email schemas, templates, `/triggers/user/resend-invite` route,
29
+ * SMS keys, CSV copy, HTML template).
30
+ *
31
+ * Idempotent: safe to run multiple times; skips edits when markers are
32
+ * already present.
33
+ */
34
+ const fs_1 = require("fs");
35
+ const path_1 = __importDefault(require("path"));
36
+ const ts_morph_1 = require("ts-morph");
37
+ const EMAIL_TEMPLATES_INDEX = 'src/api/notification/email-templates/index.ts';
38
+ const NOTIFICATION_HANDLER = 'src/api/notification/handler.ts';
39
+ const USER_NOTIFICATION_ROUTES = 'src/config/routes/userNotificationRoutes.ts';
40
+ const SMS_SERVICE = 'src/api/notification/sms-service.ts';
41
+ const NOTIFICATION_CSV = 'src/translations/notification.csv';
42
+ const RESEND_INVITE_HTML = 'src/api/notification/email-templates/other/resend-invite.html';
43
+ const RESEND_INVITE_HTML_CONTENT = `<!doctype html>
44
+ <html>
45
+ <head>
46
+ <link
47
+ href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap"
48
+ rel="stylesheet"
49
+ />
50
+ <style type="text/css">
51
+ body {
52
+ font-family: 'Noto Sans', sans-serif;
53
+ color: #222;
54
+ padding: 16px 24px;
55
+ }
56
+
57
+ h1 {
58
+ font-size: 21px;
59
+ margin-top: 32px;
60
+ margin-bottom: 36px;
61
+ font-weight: 700;
62
+ }
63
+
64
+ p {
65
+ font-weight: 400;
66
+ font-size: 16px;
67
+ line-height: 1.8;
68
+ margin-bottom: 24px;
69
+ }
70
+
71
+ i {
72
+ color: #666;
73
+ font-weight: 400;
74
+ font-size: 16px;
75
+ }
76
+ </style>
77
+ </head>
78
+
79
+ <body>
80
+ <img
81
+ src="{{countryLogo}}"
82
+ alt="country_logo"
83
+ style="max-height: 88px; max-width: 100%"
84
+ />
85
+ <h1>Your {{applicationName}} account invitation</h1>
86
+ <p>Hello {{firstname}},</p>
87
+ <p>Your account invitation has been resent. Please use the following credentials to access your account:</p>
88
+ <p>
89
+ Username: <strong>{{username}}</strong><br />
90
+ Password: <strong>{{temporaryPassword}}</strong>
91
+ </p>
92
+ <p>
93
+ Please click the link below to complete your account setup and start using
94
+ {{applicationName}}.
95
+ </p>
96
+
97
+ <div style="margin-top: 32px; margin-bottom: 32px">
98
+ <a href="{{loginURL}}">Complete setup</a>
99
+ </div>
100
+ <br />
101
+ <p>
102
+ Best regards, <br />
103
+ {{applicationName}} Team
104
+ </p>
105
+ </body>
106
+ </html>
107
+ `;
108
+ const CSV_ROW = "resendInviteNotification,The SMS message that is sent when a user invitation is resent,Your OpenCRVS account invitation was resent. Please login with your username: {{username}} and temporary password: {{temporaryPassword}},Votre invitation de compte OpenCRVS a été renvoyée. Veuillez vous connecter avec votre nom d'utilisateur : {{username}} et votre mot de passe temporaire : {{temporaryPassword}}.\n";
109
+ function getObjectLiteralFromConst(declaration) {
110
+ if (!declaration) {
111
+ return;
112
+ }
113
+ const initializer = declaration.getInitializer();
114
+ if (!initializer) {
115
+ return;
116
+ }
117
+ if (ts_morph_1.Node.isObjectLiteralExpression(initializer)) {
118
+ return initializer;
119
+ }
120
+ if (ts_morph_1.Node.isAsExpression(initializer)) {
121
+ const expression = initializer.getExpression();
122
+ if (ts_morph_1.Node.isObjectLiteralExpression(expression)) {
123
+ return expression;
124
+ }
125
+ }
126
+ }
127
+ function patchEmailTemplatesIndex() {
128
+ const full = path_1.default.join(process.cwd(), EMAIL_TEMPLATES_INDEX);
129
+ if (!(0, fs_1.existsSync)(full)) {
130
+ // eslint-disable-next-line no-console
131
+ console.log(` '${EMAIL_TEMPLATES_INDEX}' missing — skipping.`);
132
+ return false;
133
+ }
134
+ const project = new ts_morph_1.Project({
135
+ skipAddingFilesFromTsConfig: true
136
+ });
137
+ const sourceFile = project.addSourceFileAtPath(full);
138
+ let changed = false;
139
+ const triggerVariableObject = getObjectLiteralFromConst(sourceFile.getVariableDeclaration('TriggerVariable'));
140
+ if (triggerVariableObject) {
141
+ const hasResendInviteVariable = triggerVariableObject
142
+ .getProperties()
143
+ .some((prop) => prop.getText().includes('[TriggerEvent.RESEND_INVITE]'));
144
+ if (!hasResendInviteVariable) {
145
+ triggerVariableObject.addPropertyAssignment({
146
+ name: '[TriggerEvent.RESEND_INVITE]',
147
+ initializer: `z.object({
148
+ firstname: z.string(),
149
+ username: z.string(),
150
+ temporaryPassword: z.string(),
151
+ completeSetupUrl: z.string(),
152
+ loginURL: z.string()
153
+ })`
154
+ });
155
+ changed = true;
156
+ }
157
+ }
158
+ const templatesObject = getObjectLiteralFromConst(sourceFile.getVariableDeclaration('templates'));
159
+ if (templatesObject) {
160
+ const hasResendInviteTemplate = templatesObject
161
+ .getProperties()
162
+ .some((prop) => prop
163
+ .getText()
164
+ .includes("readOtherTemplate<TriggerVariable['resend-invite']>"));
165
+ if (!hasResendInviteTemplate) {
166
+ const userCreatedIndex = templatesObject
167
+ .getProperties()
168
+ .findIndex((prop) => prop.getText().includes('[TriggerEvent.USER_CREATED]'));
169
+ templatesObject.insertPropertyAssignment(userCreatedIndex >= 0 ? userCreatedIndex + 1 : templatesObject.getProperties().length, {
170
+ name: '[TriggerEvent.RESEND_INVITE]',
171
+ initializer: `{
172
+ type: 'resend-invite',
173
+ subject: 'Your OpenCRVS account invitation',
174
+ template:
175
+ readOtherTemplate<TriggerVariable['resend-invite']>('resend-invite')
176
+ }`
177
+ });
178
+ changed = true;
179
+ }
180
+ }
181
+ if (changed) {
182
+ sourceFile.saveSync();
183
+ }
184
+ return changed;
185
+ }
186
+ function patchNotificationHandler() {
187
+ const full = path_1.default.join(process.cwd(), NOTIFICATION_HANDLER);
188
+ if (!(0, fs_1.existsSync)(full)) {
189
+ return false;
190
+ }
191
+ const project = new ts_morph_1.Project({ skipAddingFilesFromTsConfig: true });
192
+ const sourceFile = project.addSourceFileAtPath(full);
193
+ const convertFn = sourceFile.getFunction('convertPayloadToVariable');
194
+ if (!convertFn) {
195
+ return false;
196
+ }
197
+ const switchStmt = convertFn.getFirstDescendantByKind(ts_morph_1.SyntaxKind.SwitchStatement);
198
+ if (!switchStmt) {
199
+ return false;
200
+ }
201
+ const clauses = switchStmt.getCaseBlock().getClauses();
202
+ const hasResendInvite = clauses.some((clause) => ts_morph_1.Node.isCaseClause(clause) &&
203
+ clause.getExpression().getText() === 'TriggerEvent.RESEND_INVITE');
204
+ if (hasResendInvite) {
205
+ return false;
206
+ }
207
+ const userCreatedClauseIndex = clauses.findIndex((clause) => ts_morph_1.Node.isCaseClause(clause) &&
208
+ clause.getExpression().getText() === 'TriggerEvent.USER_CREATED');
209
+ if (userCreatedClauseIndex < 0) {
210
+ return false;
211
+ }
212
+ const userCreatedClause = clauses[userCreatedClauseIndex];
213
+ sourceFile.insertText(userCreatedClause.getEnd(), `
214
+
215
+ case TriggerEvent.RESEND_INVITE:
216
+ return {
217
+ firstname,
218
+ username: payload.username,
219
+ temporaryPassword: payload.temporaryPassword,
220
+ completeSetupUrl: LOGIN_URL,
221
+ loginURL: LOGIN_URL
222
+ }`);
223
+ sourceFile.saveSync();
224
+ return true;
225
+ }
226
+ function getReturnedArrayLiteral(functionFilePath, fnName) {
227
+ const project = new ts_morph_1.Project({ skipAddingFilesFromTsConfig: true });
228
+ const sourceFile = project.addSourceFileAtPath(functionFilePath);
229
+ const fn = sourceFile.getFunction(fnName);
230
+ const returnStmt = fn === null || fn === void 0 ? void 0 : fn.getFirstDescendantByKind(ts_morph_1.SyntaxKind.ReturnStatement);
231
+ const expr = returnStmt === null || returnStmt === void 0 ? void 0 : returnStmt.getExpression();
232
+ if (!expr || !ts_morph_1.Node.isArrayLiteralExpression(expr)) {
233
+ return { sourceFile, arrayLiteral: undefined };
234
+ }
235
+ return { sourceFile, arrayLiteral: expr };
236
+ }
237
+ function patchUserNotificationRoutes() {
238
+ const full = path_1.default.join(process.cwd(), USER_NOTIFICATION_ROUTES);
239
+ if (!(0, fs_1.existsSync)(full)) {
240
+ return false;
241
+ }
242
+ const { sourceFile, arrayLiteral } = getReturnedArrayLiteral(full, 'getUserNotificationRoutes');
243
+ if (!arrayLiteral) {
244
+ return false;
245
+ }
246
+ const routeExists = arrayLiteral
247
+ .getElements()
248
+ .some((element) => element.getText().includes(`path: '/triggers/user/resend-invite'`));
249
+ if (routeExists) {
250
+ return false;
251
+ }
252
+ const userCreatedIndex = arrayLiteral
253
+ .getElements()
254
+ .findIndex((element) => element.getText().includes(`path: '/triggers/user/user-created'`));
255
+ arrayLiteral.insertElement(userCreatedIndex >= 0 ? userCreatedIndex + 1 : arrayLiteral.getElements().length, `{
256
+ method: 'POST',
257
+ path: '/triggers/user/resend-invite',
258
+ handler: makeNotificationHandler('resend-invite'),
259
+ options: {
260
+ auth: false,
261
+ tags: ['api'],
262
+ description: 'Handles notification for resent user invite'
263
+ }
264
+ }`);
265
+ sourceFile.saveSync();
266
+ return true;
267
+ }
268
+ function patchSmsService() {
269
+ const full = path_1.default.join(process.cwd(), SMS_SERVICE);
270
+ if (!(0, fs_1.existsSync)(full)) {
271
+ return false;
272
+ }
273
+ const project = new ts_morph_1.Project({ skipAddingFilesFromTsConfig: true });
274
+ const sourceFile = project.addSourceFileAtPath(full);
275
+ let changed = false;
276
+ const otherTemplatesObject = getObjectLiteralFromConst(sourceFile.getVariableDeclaration('otherTemplates'));
277
+ if (otherTemplatesObject) {
278
+ const hasResendTemplate = otherTemplatesObject
279
+ .getProperties()
280
+ .some((prop) => prop.getText().includes('resendInviteNotification'));
281
+ if (!hasResendTemplate) {
282
+ const userCredentialsIndex = otherTemplatesObject
283
+ .getProperties()
284
+ .findIndex((prop) => prop.getText().includes('userCredentialsNotification'));
285
+ otherTemplatesObject.insertPropertyAssignment(userCredentialsIndex >= 0
286
+ ? userCredentialsIndex + 1
287
+ : otherTemplatesObject.getProperties().length, {
288
+ name: 'resendInviteNotification',
289
+ initializer: `'resendInviteNotification'`
290
+ });
291
+ changed = true;
292
+ }
293
+ }
294
+ const triggerToSmsTemplateObject = getObjectLiteralFromConst(sourceFile.getVariableDeclaration('TriggerToSMSTemplate'));
295
+ if (triggerToSmsTemplateObject) {
296
+ const hasResendInviteMap = triggerToSmsTemplateObject
297
+ .getProperties()
298
+ .some((prop) => prop.getText().includes(`['resend-invite']`));
299
+ if (!hasResendInviteMap) {
300
+ const userCreatedIndex = triggerToSmsTemplateObject
301
+ .getProperties()
302
+ .findIndex((prop) => prop.getText().includes(`['user-created']`));
303
+ triggerToSmsTemplateObject.insertPropertyAssignment(userCreatedIndex >= 0
304
+ ? userCreatedIndex + 1
305
+ : triggerToSmsTemplateObject.getProperties().length, {
306
+ name: `['resend-invite']`,
307
+ initializer: `'resendInviteNotification'`
308
+ });
309
+ changed = true;
310
+ }
311
+ }
312
+ if (changed) {
313
+ sourceFile.saveSync();
314
+ }
315
+ return changed;
316
+ }
317
+ function main() {
318
+ return __awaiter(this, void 0, void 0, function* () {
319
+ // eslint-disable-next-line no-console
320
+ console.log('Adding RESEND_INVITE notification wiring…');
321
+ const touched = [];
322
+ if (patchEmailTemplatesIndex())
323
+ touched.push(EMAIL_TEMPLATES_INDEX);
324
+ if (patchNotificationHandler())
325
+ touched.push(NOTIFICATION_HANDLER);
326
+ if (patchUserNotificationRoutes())
327
+ touched.push(USER_NOTIFICATION_ROUTES);
328
+ if (patchSmsService())
329
+ touched.push(SMS_SERVICE);
330
+ /* csv */
331
+ const csvPath = path_1.default.join(process.cwd(), NOTIFICATION_CSV);
332
+ if ((0, fs_1.existsSync)(csvPath)) {
333
+ let t = (0, fs_1.readFileSync)(csvPath, 'utf8');
334
+ if (!/^resendInviteNotification,/m.test(t)) {
335
+ if (!t.endsWith('\n'))
336
+ t += '\n';
337
+ (0, fs_1.writeFileSync)(csvPath, t + CSV_ROW);
338
+ touched.push(NOTIFICATION_CSV);
339
+ }
340
+ }
341
+ /* html */
342
+ const htmlPath = path_1.default.join(process.cwd(), RESEND_INVITE_HTML);
343
+ (0, fs_1.mkdirSync)(path_1.default.dirname(htmlPath), { recursive: true });
344
+ if (!(0, fs_1.existsSync)(htmlPath)) {
345
+ (0, fs_1.writeFileSync)(htmlPath, RESEND_INVITE_HTML_CONTENT);
346
+ touched.push(RESEND_INVITE_HTML);
347
+ }
348
+ if (touched.length === 0) {
349
+ // eslint-disable-next-line no-console
350
+ console.log(' Nothing to update (already present or anchors not found).');
351
+ return;
352
+ }
353
+ // eslint-disable-next-line no-console
354
+ console.log(` Updated:\n${touched.map((f) => ` - ${f}`).join('\n')}`);
355
+ });
356
+ }
@@ -0,0 +1,22 @@
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
+ declare function main(): Promise<void>;
21
+ export { main };
22
+ //# sourceMappingURL=checkout-upstream-files.d.ts.map
@@ -0,0 +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"}