@opencrvs/toolkit 2.1.0-rc.982e0ae → 2.1.0-rc.9a83eed

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 (64) hide show
  1. package/README.md +2 -12
  2. package/create-countryconfig/index.js +133 -2
  3. package/dist/application-config/index.js +17 -18
  4. package/dist/authentication/index.js +7 -6
  5. package/dist/cli.js +458 -204
  6. package/dist/commons/api/router.d.ts +6 -42
  7. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  8. package/dist/commons/conditionals/validate.d.ts +1 -1
  9. package/dist/commons/events/ActionConfig.d.ts +4 -0
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -12
  11. package/dist/commons/events/FieldConfig.d.ts +16 -15
  12. package/dist/commons/events/FormConfig.d.ts +6 -0
  13. package/dist/commons/events/PageConfig.d.ts +4 -0
  14. package/dist/commons/events/locations.d.ts +4 -0
  15. package/dist/commons/events/test.utils.d.ts +18 -1
  16. package/dist/commons/events/utils.d.ts +15 -0
  17. package/dist/conditionals/index.js +7 -6
  18. package/dist/environment/manage-users.js +1 -1
  19. package/dist/environment/setup-environment.js +44 -26
  20. package/dist/environment/templates.d.ts +0 -1
  21. package/dist/environment/templates.d.ts.map +1 -1
  22. package/dist/environment/templates.js +3 -8
  23. package/dist/environment/update-workflows.d.ts.map +1 -1
  24. package/dist/environment/update-workflows.js +4 -0
  25. package/dist/environment/utils.d.ts +0 -12
  26. package/dist/environment/utils.d.ts.map +1 -1
  27. package/dist/environment/utils.js +1 -28
  28. package/dist/events/index.js +1901 -1792
  29. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  30. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +1 -1
  31. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -1
  32. package/dist/migrations/v2.1/add-explicit-correction-flags.js +34 -6
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +1 -1
  34. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -1
  35. package/dist/migrations/v2.1/add-recovery-link-notifications.js +2 -7
  36. package/dist/migrations/v2.1/add-translations.d.ts +1 -1
  37. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  38. package/dist/migrations/v2.1/add-translations.js +1 -6
  39. package/dist/migrations/v2.1/enable-telemetry.d.ts +1 -1
  40. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  41. package/dist/migrations/v2.1/enable-telemetry.js +1 -6
  42. package/dist/migrations/v2.1/index.d.ts +14 -1
  43. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  44. package/dist/migrations/v2.1/index.js +96 -84
  45. package/dist/notification/index.js +155 -152
  46. package/dist/scopes/index.d.ts +109 -5
  47. package/dist/scopes/index.js +7 -6
  48. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  49. package/dist/translations/check.d.ts +2 -0
  50. package/dist/translations/check.d.ts.map +1 -1
  51. package/dist/translations/check.js +9 -4
  52. package/dist/verify/endpoints.d.ts +18 -1
  53. package/dist/verify/endpoints.d.ts.map +1 -1
  54. package/dist/verify/endpoints.js +12 -4
  55. package/dist/verify/scopes.d.ts +13 -0
  56. package/dist/verify/scopes.d.ts.map +1 -0
  57. package/dist/verify/scopes.js +131 -0
  58. package/dist/verify/upgrade.d.ts +14 -0
  59. package/dist/verify/upgrade.d.ts.map +1 -0
  60. package/dist/verify/upgrade.js +111 -0
  61. package/opencrvs-toolkit-2.1.0-rc.9a83eed.tgz +0 -0
  62. package/package.json +2 -2
  63. package/tsconfig.build.tsbuildinfo +1 -1
  64. package/opencrvs-toolkit-2.1.0-rc.982e0ae.tgz +0 -0
@@ -38,6 +38,7 @@ module.exports = __toCommonJS(v2_exports);
38
38
  // src/migrations/v2.1/add-explicit-correction-flags.ts
39
39
  var import_ts_morph = require("ts-morph");
40
40
  var import_path = __toESM(require("path"));
41
+ var import_fs = require("fs");
41
42
  var DEFINE_CONFIG_NAME = "defineConfig";
42
43
  var ACTIONS_PROPERTY_NAME = "actions";
43
44
  var TYPE_PROPERTY_NAME = "type";
@@ -45,6 +46,11 @@ var FLAGS_PROPERTY_NAME = "flags";
45
46
  var CONDITIONALS_PROPERTY_NAME = "conditionals";
46
47
  var ACTION_TYPE_ENUM_NAME = "ActionType";
47
48
  var REQUEST_CORRECTION_TYPE = "REQUEST_CORRECTION";
49
+ var skipped = [];
50
+ function warnSkipped(message) {
51
+ skipped.push(message);
52
+ console.warn(` \u26A0\uFE0F ${message}`);
53
+ }
48
54
  var CORRECTION_ACTIONS_TO_ADD = [
49
55
  {
50
56
  actionType: "APPROVE_CORRECTION",
@@ -110,8 +116,9 @@ function buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText)
110
116
  }
111
117
  function processFile(filePath, project) {
112
118
  const sourceFile = project.getSourceFile(filePath);
113
- if (!sourceFile) return 0;
119
+ if (!sourceFile) return { changes: 0, defineConfigs: 0 };
114
120
  let changes = 0;
121
+ let defineConfigs = 0;
115
122
  const relPath = import_path.default.relative(process.cwd(), filePath);
116
123
  const callExpressions = sourceFile.getDescendantsOfKind(
117
124
  import_ts_morph.SyntaxKind.CallExpression
@@ -121,6 +128,7 @@ function processFile(filePath, project) {
121
128
  if (!import_ts_morph.Node.isIdentifier(expression) || expression.getText() !== DEFINE_CONFIG_NAME) {
122
129
  continue;
123
130
  }
131
+ defineConfigs++;
124
132
  const args = call.getArguments();
125
133
  if (args.length === 0) continue;
126
134
  const configArg = args[0];
@@ -167,14 +175,21 @@ function processFile(filePath, project) {
167
175
  );
168
176
  }
169
177
  }
170
- return changes;
178
+ return { changes, defineConfigs };
171
179
  }
172
180
  async function main() {
173
181
  const srcDir = import_path.default.join(process.cwd(), "src");
182
+ const tsConfigFilePath = import_path.default.resolve(srcDir, "../tsconfig.json");
174
183
  console.log(`Scanning for defineConfig calls in: ${srcDir}
175
184
  `);
185
+ if (!(0, import_fs.existsSync)(tsConfigFilePath)) {
186
+ warnSkipped(
187
+ `tsconfig.json not found next to ${srcDir}, so no source could be read; add APPROVE_CORRECTION/REJECT_CORRECTION action configs by hand wherever REQUEST_CORRECTION sets flags or conditionals`
188
+ );
189
+ return skipped;
190
+ }
176
191
  const project = new import_ts_morph.Project({
177
- tsConfigFilePath: import_path.default.resolve(srcDir, "../tsconfig.json"),
192
+ tsConfigFilePath,
178
193
  skipAddingFilesFromTsConfig: false
179
194
  });
180
195
  const sourceFiles = project.getSourceFiles().filter((sf) => {
@@ -184,20 +199,28 @@ async function main() {
184
199
  console.log(`Found ${sourceFiles.length} source file(s) to analyse.
185
200
  `);
186
201
  let totalChanges = 0;
202
+ let totalDefineConfigs = 0;
187
203
  const modifiedFiles = [];
188
204
  for (const sourceFile of sourceFiles) {
189
205
  const filePath = sourceFile.getFilePath();
190
- const changes = processFile(filePath, project);
206
+ const { changes, defineConfigs } = processFile(filePath, project);
207
+ totalDefineConfigs += defineConfigs;
191
208
  if (changes > 0) {
192
209
  totalChanges += changes;
193
210
  modifiedFiles.push(filePath);
194
211
  }
195
212
  }
213
+ if (totalDefineConfigs === 0) {
214
+ warnSkipped(
215
+ "No defineConfig call was found under src/, so no event configuration could be inspected; check by hand that any flags or conditionals on REQUEST_CORRECTION are repeated on APPROVE_CORRECTION and REJECT_CORRECTION"
216
+ );
217
+ return skipped;
218
+ }
196
219
  if (modifiedFiles.length === 0) {
197
220
  console.log(
198
- "No REQUEST_CORRECTION actions with flags/conditionals found. Nothing to do."
221
+ `No REQUEST_CORRECTION actions with flags/conditionals found across ${totalDefineConfigs} defineConfig call(s). Nothing to do.`
199
222
  );
200
- return;
223
+ return skipped;
201
224
  }
202
225
  console.log(`
203
226
  Saving ${modifiedFiles.length} modified file(s)...`);
@@ -210,15 +233,16 @@ Saving ${modifiedFiles.length} modified file(s)...`);
210
233
  `
211
234
  Done. Added ${totalChanges} correction action config(s) across ${modifiedFiles.length} file(s).`
212
235
  );
236
+ return skipped;
213
237
  }
214
238
 
215
239
  // src/migrations/v2.1/add-recovery-link-notifications.ts
216
240
  var import_ts_morph2 = require("ts-morph");
217
- var import_fs2 = require("fs");
241
+ var import_fs3 = require("fs");
218
242
  var import_path2 = __toESM(require("path"));
219
243
 
220
244
  // src/csv.ts
221
- var import_fs = require("fs");
245
+ var import_fs2 = require("fs");
222
246
  function parseCsvLine(line) {
223
247
  const values = [];
224
248
  let value = "";
@@ -258,10 +282,10 @@ function idOf(line) {
258
282
  return comma === -1 ? line : line.slice(0, comma);
259
283
  }
260
284
  function readCsvFile(path5) {
261
- if (!(0, import_fs.existsSync)(path5)) {
285
+ if (!(0, import_fs2.existsSync)(path5)) {
262
286
  return void 0;
263
287
  }
264
- const contents = (0, import_fs.readFileSync)(path5, "utf8");
288
+ const contents = (0, import_fs2.readFileSync)(path5, "utf8");
265
289
  const newline = contents.includes("\r\n") ? "\r\n" : "\n";
266
290
  const trailingNewline = /\r?\n$/.test(contents);
267
291
  const lines = contents.replace(/\r?\n$/, "").split(/\r?\n/);
@@ -269,7 +293,7 @@ function readCsvFile(path5) {
269
293
  return { header: lines[0], body, newline, trailingNewline };
270
294
  }
271
295
  function writeCsvFile(path5, file) {
272
- (0, import_fs.writeFileSync)(
296
+ (0, import_fs2.writeFileSync)(
273
297
  path5,
274
298
  [file.header, ...file.body].join(file.newline) + (file.trailingNewline ? file.newline : "")
275
299
  );
@@ -344,9 +368,9 @@ var LOGIN_CSV_ROWS = [
344
368
  `resetCredentials.recoveryLinkLanding.expired.link,Link back to the forgotten item form shown on an expired/invalid recovery link,Start again,Recommencer`,
345
369
  `resetCredentials.recoveryLinkLanding.expired.title,"Title shown when a recovery link is invalid, expired, or already used",This link has expired,Ce lien a expir\xE9`
346
370
  ];
347
- var skipped = [];
348
- function warnSkipped(message) {
349
- skipped.push(message);
371
+ var skipped2 = [];
372
+ function warnSkipped2(message) {
373
+ skipped2.push(message);
350
374
  console.warn(` \u26A0\uFE0F ${message}`);
351
375
  }
352
376
  function findObjectLiteral(declaration) {
@@ -401,14 +425,14 @@ function renderKeyFor(sourceFile, objectName, key, constant) {
401
425
  function updateEmailTemplates(project, cwd) {
402
426
  const sourceFile = project.getSourceFile(import_path2.default.join(cwd, EMAIL_TEMPLATES_FILE));
403
427
  if (!sourceFile) {
404
- warnSkipped(`${EMAIL_TEMPLATES_FILE} not found; email templates not wired`);
428
+ warnSkipped2(`${EMAIL_TEMPLATES_FILE} not found; email templates not wired`);
405
429
  return;
406
430
  }
407
431
  const missingObject = [TRIGGER_VARIABLE_OBJECT, TEMPLATES_OBJECT].find(
408
432
  (objectName) => !findObjectLiteral(sourceFile.getVariableDeclaration(objectName))
409
433
  );
410
434
  if (missingObject) {
411
- warnSkipped(
435
+ warnSkipped2(
412
436
  `Could not find '${missingObject}' in ${EMAIL_TEMPLATES_FILE}; email templates not wired`
413
437
  );
414
438
  return;
@@ -465,7 +489,7 @@ function updateEmailTemplates(project, cwd) {
465
489
  function updateSmsService(project, cwd) {
466
490
  const sourceFile = project.getSourceFile(import_path2.default.join(cwd, SMS_SERVICE_FILE));
467
491
  if (!sourceFile) {
468
- warnSkipped(`${SMS_SERVICE_FILE} not found; SMS templates not wired`);
492
+ warnSkipped2(`${SMS_SERVICE_FILE} not found; SMS templates not wired`);
469
493
  return;
470
494
  }
471
495
  const missingObject = [
@@ -475,7 +499,7 @@ function updateSmsService(project, cwd) {
475
499
  (objectName) => !findObjectLiteral(sourceFile.getVariableDeclaration(objectName))
476
500
  );
477
501
  if (missingObject) {
478
- warnSkipped(
502
+ warnSkipped2(
479
503
  `Could not find '${missingObject}' in ${SMS_SERVICE_FILE}; SMS templates not wired`
480
504
  );
481
505
  return;
@@ -516,13 +540,13 @@ function updateSmsService(project, cwd) {
516
540
  function updateHandler(project, cwd) {
517
541
  const sourceFile = project.getSourceFile(import_path2.default.join(cwd, HANDLER_FILE));
518
542
  if (!sourceFile) {
519
- warnSkipped(`${HANDLER_FILE} not found; payload conversion not wired`);
543
+ warnSkipped2(`${HANDLER_FILE} not found; payload conversion not wired`);
520
544
  return;
521
545
  }
522
546
  const convertPayload = sourceFile.getFunction(CONVERT_PAYLOAD_FUNCTION);
523
547
  const caseBlock = convertPayload?.getFirstDescendantByKind(import_ts_morph2.SyntaxKind.SwitchStatement)?.getCaseBlock();
524
548
  if (!caseBlock) {
525
- warnSkipped(
549
+ warnSkipped2(
526
550
  `Could not find a switch inside '${CONVERT_PAYLOAD_FUNCTION}' in ${HANDLER_FILE}; payload conversion not wired`
527
551
  );
528
552
  return;
@@ -533,7 +557,7 @@ function updateHandler(project, cwd) {
533
557
  if (missing.length === 0) return;
534
558
  const existingClauses = caseBlock.getClauses();
535
559
  if (existingClauses.length === 0) {
536
- warnSkipped(
560
+ warnSkipped2(
537
561
  `The switch inside '${CONVERT_PAYLOAD_FUNCTION}' in ${HANDLER_FILE} has no cases; payload conversion not wired`
538
562
  );
539
563
  return;
@@ -570,13 +594,13 @@ ${lines.map((line) => `${indent}${line}`).join("\n")}`
570
594
  function updateRoutes(project, cwd) {
571
595
  const sourceFile = project.getSourceFile(import_path2.default.join(cwd, ROUTES_FILE));
572
596
  if (!sourceFile) {
573
- warnSkipped(`${ROUTES_FILE} not found; trigger routes not registered`);
597
+ warnSkipped2(`${ROUTES_FILE} not found; trigger routes not registered`);
574
598
  return;
575
599
  }
576
600
  const routesFunction = sourceFile.getFunction(ROUTES_FUNCTION) ?? sourceFile.getFunctions().find((fn) => fn.isDefaultExport());
577
601
  const routesArray = routesFunction?.getFirstDescendantByKind(import_ts_morph2.SyntaxKind.ReturnStatement)?.getExpressionIfKind(import_ts_morph2.SyntaxKind.ArrayLiteralExpression);
578
602
  if (!routesArray) {
579
- warnSkipped(
603
+ warnSkipped2(
580
604
  `Could not find the route array returned by '${ROUTES_FUNCTION}' in ${ROUTES_FILE}; trigger routes not registered`
581
605
  );
582
606
  return;
@@ -674,16 +698,16 @@ Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencr
674
698
  }
675
699
  function writeEmailTemplates(cwd) {
676
700
  const templateDir = import_path2.default.join(cwd, EMAIL_TEMPLATE_DIR);
677
- if (!(0, import_fs2.existsSync)(templateDir)) {
678
- warnSkipped(
701
+ if (!(0, import_fs3.existsSync)(templateDir)) {
702
+ warnSkipped2(
679
703
  `${EMAIL_TEMPLATE_DIR} not found; recovery email bodies not written`
680
704
  );
681
705
  return;
682
706
  }
683
707
  for (const event of RECOVERY_EVENTS) {
684
708
  const templatePath = import_path2.default.join(templateDir, `${event.id}.html`);
685
- if ((0, import_fs2.existsSync)(templatePath)) continue;
686
- (0, import_fs2.writeFileSync)(templatePath, renderEmailTemplate(event));
709
+ if ((0, import_fs3.existsSync)(templatePath)) continue;
710
+ (0, import_fs3.writeFileSync)(templatePath, renderEmailTemplate(event));
687
711
  console.log(` \u2713 ${EMAIL_TEMPLATE_DIR}/${event.id}.html`);
688
712
  }
689
713
  }
@@ -691,7 +715,7 @@ function addCsvRows(cwd, relativePath, rows) {
691
715
  const csvPath = import_path2.default.join(cwd, relativePath);
692
716
  const file = readCsvFile(csvPath);
693
717
  if (!file) {
694
- warnSkipped(`${relativePath} not found; translations not added`);
718
+ warnSkipped2(`${relativePath} not found; translations not added`);
695
719
  return;
696
720
  }
697
721
  const added = addRows(file, rows);
@@ -707,11 +731,11 @@ async function main2() {
707
731
  console.log(
708
732
  "Registering the password-reset-link and username-reminder-link notifications...\n"
709
733
  );
710
- if (!(0, import_fs2.existsSync)(tsConfigFilePath)) {
711
- warnSkipped(
734
+ if (!(0, import_fs3.existsSync)(tsConfigFilePath)) {
735
+ warnSkipped2(
712
736
  `tsconfig.json not found in ${cwd}; notification wiring skipped entirely`
713
737
  );
714
- return;
738
+ return skipped2;
715
739
  }
716
740
  const project = new import_ts_morph2.Project({
717
741
  tsConfigFilePath,
@@ -728,15 +752,7 @@ async function main2() {
728
752
  writeEmailTemplates(cwd);
729
753
  addCsvRows(cwd, NOTIFICATION_CSV, NOTIFICATION_CSV_ROWS);
730
754
  addCsvRows(cwd, LOGIN_CSV, LOGIN_CSV_ROWS);
731
- if (skipped.length > 0) {
732
- console.warn(
733
- `
734
- \u26A0\uFE0F ${skipped.length} step(s) were skipped. Wire the following by hand before upgrading:`
735
- );
736
- for (const message of skipped) {
737
- console.warn(` - ${message}`);
738
- }
739
- }
755
+ return skipped2;
740
756
  }
741
757
 
742
758
  // src/migrations/v2.1/add-translations.ts
@@ -745,9 +761,9 @@ var REPOSITORY = "opencrvs/opencrvs-core";
745
761
  var TEMPLATE_TRANSLATIONS = "packages/countryconfig-template/src/translations";
746
762
  var APPLICATIONS = ["client", "login"];
747
763
  var TARGET_VERSION = "2.1";
748
- var skipped2 = [];
749
- function warnSkipped2(message) {
750
- skipped2.push(message);
764
+ var skipped3 = [];
765
+ function warnSkipped3(message) {
766
+ skipped3.push(message);
751
767
  console.warn(` \u26A0\uFE0F ${message}`);
752
768
  }
753
769
  async function matchingRefs(namespace, prefix) {
@@ -784,7 +800,7 @@ async function fetchTemplate(refs, application) {
784
800
  );
785
801
  }
786
802
  }
787
- warnSkipped2(
803
+ warnSkipped3(
788
804
  `No ${application}.csv found in the ${TARGET_VERSION} country config template on GitHub; ${application}.csv not updated`
789
805
  );
790
806
  return void 0;
@@ -806,7 +822,7 @@ async function updateApplication(cwd, refs, application) {
806
822
  const relativePath = `src/translations/${application}.csv`;
807
823
  const local = readCsvFile(import_path3.default.join(cwd, relativePath));
808
824
  if (!local) {
809
- warnSkipped2(`${relativePath} not found; translations not added`);
825
+ warnSkipped3(`${relativePath} not found; translations not added`);
810
826
  return;
811
827
  }
812
828
  const fetched = await fetchTemplate(refs, application);
@@ -821,7 +837,7 @@ async function updateApplication(cwd, refs, application) {
821
837
  try {
822
838
  writeCsvFile(import_path3.default.join(cwd, relativePath), local);
823
839
  } catch (error) {
824
- warnSkipped2(
840
+ warnSkipped3(
825
841
  `Could not write ${relativePath} (${error.message}); translations not added`
826
842
  );
827
843
  return;
@@ -843,7 +859,7 @@ async function listRefs() {
843
859
  try {
844
860
  return await candidateRefs();
845
861
  } catch (error) {
846
- warnSkipped2(
862
+ warnSkipped3(
847
863
  `Could not list the ${TARGET_VERSION} refs on GitHub (${error.message}); translations not added`
848
864
  );
849
865
  return void 0;
@@ -858,34 +874,26 @@ async function main3() {
858
874
  try {
859
875
  await updateApplication(cwd, refs, application);
860
876
  } catch (error) {
861
- warnSkipped2(
877
+ warnSkipped3(
862
878
  `Could not read ${application}.csv from the country config template on GitHub (${error.message}); ${application}.csv not updated`
863
879
  );
864
880
  }
865
881
  }
866
882
  }
867
- if (skipped2.length > 0) {
868
- console.warn(
869
- `
870
- \u26A0\uFE0F ${skipped2.length} step(s) were skipped. Add the missing translations by hand before upgrading:`
871
- );
872
- for (const message of skipped2) {
873
- console.warn(` - ${message}`);
874
- }
875
- }
883
+ return skipped3;
876
884
  }
877
885
 
878
886
  // src/migrations/v2.1/enable-telemetry.ts
879
887
  var import_ts_morph3 = require("ts-morph");
880
- var import_fs3 = require("fs");
888
+ var import_fs4 = require("fs");
881
889
  var import_path4 = __toESM(require("path"));
882
890
  var HANDLER_FILE2 = "src/api/telemetry/handler.ts";
883
891
  var ENVIRONMENT_FILE = "src/environment.ts";
884
892
  var INDEX_FILE = "src/index.ts";
885
893
  var HANDLER_MODULE = "./api/telemetry/handler";
886
- var skipped3 = [];
887
- function warnSkipped3(message) {
888
- skipped3.push(message);
894
+ var skipped4 = [];
895
+ function warnSkipped4(message) {
896
+ skipped4.push(message);
889
897
  console.warn(` \u26A0\uFE0F ${message}`);
890
898
  }
891
899
  var TELEMETRY_HANDLER_SOURCE = `/*
@@ -1036,12 +1044,12 @@ async function promptTelemetryConfig() {
1036
1044
  }
1037
1045
  function writeTelemetryHandler(cwd) {
1038
1046
  const handlerPath = import_path4.default.join(cwd, HANDLER_FILE2);
1039
- if ((0, import_fs3.existsSync)(handlerPath)) {
1047
+ if ((0, import_fs4.existsSync)(handlerPath)) {
1040
1048
  console.log(` ${HANDLER_FILE2} already present; left unchanged`);
1041
1049
  return;
1042
1050
  }
1043
- (0, import_fs3.mkdirSync)(import_path4.default.dirname(handlerPath), { recursive: true });
1044
- (0, import_fs3.writeFileSync)(handlerPath, TELEMETRY_HANDLER_SOURCE);
1051
+ (0, import_fs4.mkdirSync)(import_path4.default.dirname(handlerPath), { recursive: true });
1052
+ (0, import_fs4.writeFileSync)(handlerPath, TELEMETRY_HANDLER_SOURCE);
1045
1053
  console.log(` \u2713 ${HANDLER_FILE2}`);
1046
1054
  }
1047
1055
  function appendProperty(sourceFile, object, name, valueLines) {
@@ -1057,7 +1065,7 @@ ${entry}`);
1057
1065
  function ensureEnvalidNamedImports(sourceFile, names) {
1058
1066
  const importDeclaration = sourceFile.getImportDeclarations().find((declaration) => declaration.getModuleSpecifierValue() === "envalid");
1059
1067
  if (!importDeclaration) {
1060
- warnSkipped3(
1068
+ warnSkipped4(
1061
1069
  `Could not find the 'envalid' import in ${ENVIRONMENT_FILE}; import { ${names.join(", ")} } by hand`
1062
1070
  );
1063
1071
  return;
@@ -1110,13 +1118,13 @@ function addEnvironmentVariables(project, cwd, config) {
1110
1118
  import_path4.default.join(cwd, ENVIRONMENT_FILE)
1111
1119
  );
1112
1120
  if (!sourceFile) {
1113
- warnSkipped3(
1121
+ warnSkipped4(
1114
1122
  `${ENVIRONMENT_FILE} not found; add the telemetry env vars by hand`
1115
1123
  );
1116
1124
  return;
1117
1125
  }
1118
1126
  if (!getCleanEnvObject(sourceFile)) {
1119
- warnSkipped3(
1127
+ warnSkipped4(
1120
1128
  `Could not find the cleanEnv(...) config object in ${ENVIRONMENT_FILE}; add the telemetry env vars by hand`
1121
1129
  );
1122
1130
  return;
@@ -1160,7 +1168,7 @@ function wireIndex(project, cwd) {
1160
1168
  import_path4.default.join(cwd, INDEX_FILE)
1161
1169
  );
1162
1170
  if (!sourceFile) {
1163
- warnSkipped3(
1171
+ warnSkipped4(
1164
1172
  `${INDEX_FILE} not found; register POST /trigger/telemetry and the startup notice by hand`
1165
1173
  );
1166
1174
  return;
@@ -1183,7 +1191,7 @@ function wireIndex(project, cwd) {
1183
1191
  (statement) => Boolean(statement)
1184
1192
  ).pop();
1185
1193
  if (!lastRouteStatement) {
1186
- warnSkipped3(
1194
+ warnSkipped4(
1187
1195
  `Could not find a server.route(...) call in ${INDEX_FILE}; register POST /trigger/telemetry by hand`
1188
1196
  );
1189
1197
  } else {
@@ -1214,7 +1222,7 @@ ${route}`);
1214
1222
  (statement) => statement.getText().includes("Server successfully started")
1215
1223
  );
1216
1224
  if (!startedLog) {
1217
- warnSkipped3(
1225
+ warnSkipped4(
1218
1226
  `Could not find the startup log in ${INDEX_FILE}; log TELEMETRY_DISABLED_NOTICE when TELEMETRY_ENABLED is false by hand`
1219
1227
  );
1220
1228
  } else {
@@ -1229,7 +1237,7 @@ ${route}`);
1229
1237
  ${notice}`);
1230
1238
  console.log(` \u2713 ${INDEX_FILE}: telemetry-disabled startup notice`);
1231
1239
  if (!sourceFile.getImportDeclarations().some((d) => d.getModuleSpecifierValue() === "./environment")) {
1232
- warnSkipped3(
1240
+ warnSkipped4(
1233
1241
  `The startup notice reads env.TELEMETRY_ENABLED but ${INDEX_FILE} does not import env from './environment'; import it by hand`
1234
1242
  );
1235
1243
  }
@@ -1256,21 +1264,25 @@ Adding daily usage telemetry (${config.enabled ? `enabled for ${config.countryCo
1256
1264
  addEnvironmentVariables(project, cwd, config);
1257
1265
  wireIndex(project, cwd);
1258
1266
  await project.save();
1259
- if (skipped3.length > 0) {
1260
- console.warn(
1261
- `
1262
- \u26A0\uFE0F ${skipped3.length} telemetry step(s) were skipped. Wire the following by hand:`
1263
- );
1264
- for (const message of skipped3) {
1265
- console.warn(` - ${message}`);
1266
- }
1267
- }
1267
+ return skipped4;
1268
1268
  }
1269
1269
 
1270
1270
  // src/migrations/v2.1/index.ts
1271
+ var DOCKER_SWARM_MANUAL_STEPS = [
1272
+ "Remove the `mongo1` and `influxdb` services from your compose files \u2014 MongoDB and InfluxDB are gone in this release.",
1273
+ "Remove the `legacy-data-migration` service from your compose files. It only ever migrated MongoDB data during the v2.0 upgrade, and the migration it ran no longer exists.",
1274
+ "Change the postgres image from `docker.io/chumaky/postgres_mongo_fdw:17.6_fdw5.5.2` back to `postgres:17.6`. The `mongo_fdw` build was only needed for the v2.0 legacy-data migration.",
1275
+ "Run `DROP EXTENSION mongo_fdw CASCADE;` against the events database as a Postgres superuser, if this deployment came through v2.0. It has to be a superuser: the extension is owned by the one that ran the v2.0 legacy migration, not by the role the migrations run as. Until it is dropped, a pg_dump/pg_restore of the database into a v2.1 cluster fails.",
1276
+ "Run `assets/deployment/reindex.sh` after deploying. `deploy.sh` does not call it, and this release adds `legalStatuses.NOTIFIED` to the Elasticsearch mapping, so records indexed before the upgrade carry none of it until a reindex."
1277
+ ];
1271
1278
  async function runUpgrade(dockerSwarm) {
1272
- await main();
1273
- await main2();
1274
- await main3();
1275
- await main4();
1279
+ const outstanding = [];
1280
+ outstanding.push(...await main());
1281
+ outstanding.push(...await main2());
1282
+ outstanding.push(...await main3());
1283
+ outstanding.push(...await main4());
1284
+ if (dockerSwarm) {
1285
+ outstanding.push(...DOCKER_SWARM_MANUAL_STEPS);
1286
+ }
1287
+ return { outstanding };
1276
1288
  }