@opencrvs/toolkit 2.1.2 → 2.2.0-rc.1a111f2

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 (163) hide show
  1. package/build.sh +2 -12
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +41 -9
  4. package/dist/authentication/index.d.ts +1 -0
  5. package/dist/authentication/index.js +30 -6
  6. package/dist/cli.js +1489 -2020
  7. package/dist/commons/api/router.d.ts +1551 -248
  8. package/dist/commons/application-config/index.d.ts +2 -2
  9. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  10. package/dist/commons/conditionals/index.d.ts +1 -0
  11. package/dist/commons/conditionals/validate.d.ts +5 -0
  12. package/dist/commons/events/ActionConfig.d.ts +146 -20
  13. package/dist/commons/events/ActionDocument.d.ts +89 -0
  14. package/dist/commons/events/ActionInput.d.ts +56 -4
  15. package/dist/commons/events/ActionType.d.ts +13 -1
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +15 -0
  17. package/dist/commons/events/AuditLog.d.ts +4 -0
  18. package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  20. package/dist/commons/events/Draft.d.ts +36 -1
  21. package/dist/commons/events/EventConfig.d.ts +412 -6
  22. package/dist/commons/events/EventDocument.d.ts +88 -0
  23. package/dist/commons/events/EventIndex.d.ts +43 -6
  24. package/dist/commons/events/EventMetadata.d.ts +23 -1
  25. package/dist/commons/events/EventStatus.d.ts +1 -0
  26. package/dist/commons/events/FieldConfig.d.ts +11 -1
  27. package/dist/commons/events/FieldTypeMapping.d.ts +6 -6
  28. package/dist/commons/events/Flag.d.ts +1 -7
  29. package/dist/commons/events/PlainDate.d.ts +1 -0
  30. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  31. package/dist/commons/events/defineConfig.d.ts +7 -2
  32. package/dist/commons/events/event.d.ts +4 -1
  33. package/dist/commons/events/eventConfigValidation.d.ts +26 -1
  34. package/dist/commons/events/field.d.ts +5 -0
  35. package/dist/commons/events/index.d.ts +3 -0
  36. package/dist/commons/events/scopes.d.ts +3 -0
  37. package/dist/commons/events/state/flags.d.ts +1 -1
  38. package/dist/commons/events/state/index.d.ts +10 -2
  39. package/dist/commons/events/state/utils.d.ts +11 -1
  40. package/dist/commons/events/test.utils.d.ts +87 -6
  41. package/dist/commons/events/toNotificationForm.d.ts +17 -0
  42. package/dist/commons/events/utils.d.ts +75 -8
  43. package/dist/conditionals/index.js +16 -4
  44. package/dist/environment/custom-types.d.ts +1 -0
  45. package/dist/environment/custom-types.d.ts.map +1 -1
  46. package/dist/environment/derived-variables.d.ts +24 -4
  47. package/dist/environment/derived-variables.d.ts.map +1 -1
  48. package/dist/environment/derived-variables.js +27 -4
  49. package/dist/environment/questions.d.ts +42 -9
  50. package/dist/environment/questions.d.ts.map +1 -1
  51. package/dist/environment/questions.js +71 -48
  52. package/dist/environment/registry.d.ts +15 -0
  53. package/dist/environment/registry.d.ts.map +1 -0
  54. package/dist/environment/registry.js +112 -0
  55. package/dist/environment/setup-environment.d.ts.map +1 -1
  56. package/dist/environment/setup-environment.js +159 -35
  57. package/dist/environment/templates.d.ts.map +1 -1
  58. package/dist/events/index.js +944 -214
  59. package/dist/migrations/add-notify-config.d.ts +40 -0
  60. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  61. package/dist/migrations/add-notify-config.js +249 -0
  62. package/dist/migrations/index.d.ts +9 -0
  63. package/dist/migrations/index.d.ts.map +1 -0
  64. package/dist/migrations/index.js +1306 -0
  65. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  66. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  67. package/dist/migrations/move-declaration-to-declare-action.js +260 -0
  68. package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
  69. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  70. package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
  71. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  72. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  73. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  74. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  75. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  76. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  77. package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
  78. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  79. package/dist/migrations/read-declaration-through-helper.js +199 -0
  80. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  81. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  82. package/dist/migrations/replace-incomplete-flag.js +126 -0
  83. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  84. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  85. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  86. package/dist/migrations/utils.d.ts +61 -0
  87. package/dist/migrations/utils.d.ts.map +1 -0
  88. package/dist/migrations/utils.js +218 -0
  89. package/dist/notification/index.js +887 -129
  90. package/dist/scopes/index.d.ts +83 -90
  91. package/dist/scopes/index.js +26 -6
  92. package/dist/templates/charts-values/dependencies/values.yaml +3 -2
  93. package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -7
  94. package/dist/templates/charts-values/traefik/values.yaml +4 -3
  95. package/dist/verify/endpoints.d.ts +11 -0
  96. package/dist/verify/endpoints.d.ts.map +1 -1
  97. package/dist/verify/endpoints.js +21 -27
  98. package/opencrvs-toolkit-2.2.0-rc.1a111f2.tgz +0 -0
  99. package/package.json +3 -2
  100. package/tsconfig.build.tsbuildinfo +1 -1
  101. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  102. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  103. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  104. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  105. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  106. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  107. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  108. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  109. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  110. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  111. package/dist/migrations/v2.1/index.d.ts +0 -6
  112. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  113. package/dist/migrations/v2.1/index.js +0 -2170
  114. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
  115. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  116. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  117. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  118. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  119. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  120. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  121. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  122. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  123. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  124. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  125. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  126. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  127. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  128. package/dist/migrations/v2.1/template-files.js +0 -49
  129. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
  130. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  131. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  132. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  133. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  134. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  135. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  136. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  137. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  138. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  139. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  140. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  141. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  142. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  143. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  144. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  145. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  146. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  147. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  148. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  149. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  150. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  151. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  152. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  153. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  154. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  155. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  156. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  157. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  158. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  159. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  160. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  161. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  162. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  163. package/opencrvs-toolkit-2.1.2.tgz +0 -0
@@ -65,10 +65,11 @@ const update_workflows_1 = require("./update-workflows");
65
65
  const questions_1 = require("./questions");
66
66
  const editor_questions_1 = require("./editor-questions");
67
67
  const questions_helper_1 = require("./questions-helper");
68
+ const registry_1 = require("./registry");
68
69
  const manage_users_1 = require("./manage-users");
69
70
  const paths_1 = require("./paths");
70
71
  function questionToPrompt(_a) {
71
- var { valueType, valueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "scope"]);
72
+ var { valueType, valueLabel, legacyValueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "legacyValueLabel", "scope"]);
72
73
  return promptOptions;
73
74
  }
74
75
  const ALL_QUESTIONS = [];
@@ -112,6 +113,14 @@ function getAnswers(existingValues) {
112
113
  });
113
114
  });
114
115
  }
116
+ // The value of a variable that exists, as the initial value of its question.
117
+ // A select question takes the index of the choice.
118
+ function getInitialValue(question, variable) {
119
+ if (question.type === 'select' && Array.isArray(question.choices)) {
120
+ return (0, questions_helper_1.getIndexFromChoices)(question.choices, variable.value);
121
+ }
122
+ return variable.value;
123
+ }
115
124
  function promptAndStoreAnswer(questions, existingValues) {
116
125
  return __awaiter(this, void 0, void 0, function* () {
117
126
  (0, logger_1.log)('');
@@ -122,13 +131,15 @@ function promptAndStoreAnswer(questions, existingValues) {
122
131
  }
123
132
  if (questionWithVariableLabel.valueType === 'VARIABLE') {
124
133
  const existingVariable = (0, utils_1.findExistingValue)(questionWithVariableLabel.valueLabel, 'VARIABLE', questionWithVariableLabel.scope, existingValues);
134
+ // Unlike a secret, the value of a variable can be read, so one that only exists
135
+ // under its previous name is the default of the question
136
+ const legacyVariable = !existingVariable && questionWithVariableLabel.legacyValueLabel
137
+ ? (0, utils_1.findExistingValue)(questionWithVariableLabel.legacyValueLabel, 'VARIABLE', questionWithVariableLabel.scope, existingValues)
138
+ : undefined;
139
+ if (legacyVariable) {
140
+ return Object.assign(Object.assign({}, questionWithVariableLabel), { message: `${questionWithVariableLabel.message} ${kleur_1.default.gray(`(default taken from ${legacyVariable.name}, the previous name of this variable)`)}`, initial: getInitialValue(questionWithVariableLabel, legacyVariable) });
141
+ }
125
142
  if (existingVariable) {
126
- let initial_value = existingVariable.value;
127
- // Get correct initial value for select questions
128
- if (questionWithVariableLabel.type === 'select' &&
129
- Array.isArray(questionWithVariableLabel.choices)) {
130
- initial_value = (0, questions_helper_1.getIndexFromChoices)(questionWithVariableLabel.choices, existingVariable.value);
131
- }
132
143
  return [
133
144
  {
134
145
  name: 'overWrite' + questionWithVariableLabel.name,
@@ -136,12 +147,30 @@ function promptAndStoreAnswer(questions, existingValues) {
136
147
  scope: questionWithVariableLabel.scope,
137
148
  message: `${kleur_1.default.yellow(`Variable ${kleur_1.default.cyan(existingVariable.name)} already exists in Github. Do you want to update it?`)}`
138
149
  },
139
- Object.assign(Object.assign({}, questionWithVariableLabel), { type: ((prev) => prev ? questionWithVariableLabel.type : null), initial: initial_value })
150
+ Object.assign(Object.assign({}, questionWithVariableLabel), { type: ((prev) => prev ? questionWithVariableLabel.type : null), initial: getInitialValue(questionWithVariableLabel, existingVariable) })
140
151
  ];
141
152
  }
142
153
  }
143
154
  if (questionWithVariableLabel.valueType === 'SECRET') {
144
155
  const existingSecret = (0, utils_1.findExistingValue)(questionWithVariableLabel.valueLabel, 'SECRET', questionWithVariableLabel.scope, existingValues);
156
+ // The value of a secret that only exists under its previous name can't be read, so
157
+ // it is left to the secrets migration workflow, unless a new value is entered here
158
+ const legacySecret = !existingSecret && questionWithVariableLabel.legacyValueLabel
159
+ ? (0, utils_1.findExistingValue)(questionWithVariableLabel.legacyValueLabel, 'SECRET', questionWithVariableLabel.scope, existingValues)
160
+ : undefined;
161
+ if (legacySecret) {
162
+ return [
163
+ {
164
+ name: 'overWrite' + questionWithVariableLabel.name,
165
+ type: 'confirm',
166
+ scope: questionWithVariableLabel.scope,
167
+ message: `${kleur_1.default.yellow(`${legacySecret.scope === 'REPOSITORY'
168
+ ? 'Repository secret'
169
+ : 'Secret'} ${kleur_1.default.cyan(legacySecret.name)} already exists in Github under the previous name of ${kleur_1.default.cyan(questionWithVariableLabel.valueLabel)}. The secrets migration workflow copies it. Do you want to enter a new value instead?`)}`
170
+ },
171
+ Object.assign(Object.assign({}, questionWithVariableLabel), { type: ((prev) => prev ? questionWithVariableLabel.type : null) })
172
+ ];
173
+ }
145
174
  if (existingSecret) {
146
175
  return [
147
176
  {
@@ -175,7 +204,47 @@ function promptAndStoreAnswer(questions, existingValues) {
175
204
  return Object.assign(Object.assign({}, Object.fromEntries(existingValuesForQuestions)), result);
176
205
  });
177
206
  }
178
- ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.dockerhubQuestions, ...questions_1.diskQuestions, ...questions_1.infrastructureQuestions, ...questions_1.backupQuestions, ...questions_1.countryQuestions, ...questions_1.databaseAndMonitoringQuestions, ...questions_1.emailQuestions, ...questions_1.sentryQuestions, ...derived_variables_1.derivedVariables, ...questions_1.metabaseAdminQuestions);
207
+ /**
208
+ * The value of a secret or variable that is generated rather than asked for, or
209
+ * null when it exists. One that only exists under its previous name counts as
210
+ * existing: the secrets migration workflow copies it, and a generated value
211
+ * would replace the credential that is in use.
212
+ */
213
+ function defineIfMissing(existingValues, name, type, scope, newValue) {
214
+ var _a;
215
+ if ((0, utils_1.findExistingValue)(name, type, scope, existingValues)) {
216
+ return null;
217
+ }
218
+ const legacyName = (_a = ALL_QUESTIONS.find((question) => question.valueLabel === name &&
219
+ question.valueType === type &&
220
+ question.scope === scope)) === null || _a === void 0 ? void 0 : _a.legacyValueLabel;
221
+ if (legacyName &&
222
+ (0, utils_1.findExistingValue)(legacyName, type, scope, existingValues)) {
223
+ (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default
224
+ .bold()
225
+ .yellow(`${legacyName} exists, the secrets migration workflow copies it to ${name}`));
226
+ return null;
227
+ }
228
+ return process.env[name] || newValue;
229
+ }
230
+ function promptAndValidateRegistry(existingValues) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const answers = yield promptAndStoreAnswer(questions_1.registryQuestions, existingValues);
233
+ const result = yield (0, registry_1.validateRegistryCredentials)(answers.registryHost, answers.registryOrganisation, answers.registryRepository, answers.registryUsername, answers.registryToken);
234
+ if (result.status === 'valid' || result.status === 'skipped') {
235
+ return;
236
+ }
237
+ (0, logger_1.error)(`\n${result.status}: ${result.reason || 'Generic error'}\n`);
238
+ const continueNotValidated = yield confirm({
239
+ message: 'Container registry credentials are not validated. Continue anyway?',
240
+ default: false
241
+ });
242
+ if (!continueNotValidated) {
243
+ process.exit(1);
244
+ }
245
+ });
246
+ }
247
+ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.registryQuestions, ...questions_1.diskQuestions, ...questions_1.infrastructureQuestions, ...questions_1.backupQuestions, ...questions_1.countryQuestions, ...questions_1.databaseAndMonitoringQuestions, ...questions_1.emailQuestions, ...questions_1.sentryQuestions, ...derived_variables_1.derivedVariables, ...questions_1.metabaseAdminQuestions);
179
248
  function runSetupEnvironment() {
180
249
  return __awaiter(this, void 0, void 0, function* () {
181
250
  var _a, _b, _c, _d;
@@ -239,16 +308,6 @@ function runSetupEnvironment() {
239
308
  ]
240
309
  });
241
310
  }
242
- (0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
243
- const two_fa_enabled = yield confirm({
244
- message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
245
- default: process.env.TWO_FA_ENABLED
246
- ? process.env.TWO_FA_ENABLED === 'true'
247
- : environment_type === 'production'
248
- });
249
- if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
250
- (0, logger_1.warn)('2FA is disabled on a production-like environment. Logins will accept the fixed test code 000000, exposing real citizen data. Only do this if you know what you are doing.');
251
- }
252
311
  const environment_exists = existingEnvironments
253
312
  .map((e) => e.trim())
254
313
  .includes(environment);
@@ -275,10 +334,30 @@ function runSetupEnvironment() {
275
334
  (0, logger_1.log)('\n', kleur_1.default
276
335
  .yellow()
277
336
  .bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
278
- yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
279
337
  }
280
- (0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
281
- yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
338
+ (0, logger_1.log)('\n', kleur_1.default.bold().underline('Workflow approvals'));
339
+ // The workflows require approval unless APPROVAL_REQUIRED is 'false'
340
+ const { approvalRequired } = yield promptAndStoreAnswer([
341
+ Object.assign(Object.assign({}, questions_1.githubApprovalRequiredQuestion), { initial: (0, questions_helper_1.getIndexFromChoices)(questions_1.githubApprovalRequiredQuestion.choices, process.env.APPROVAL_REQUIRED ||
342
+ (environment_type === 'production' ? 'true' : 'false')) })
343
+ ], existingValues);
344
+ if (approvalRequired !== 'false') {
345
+ yield promptAndStoreAnswer([questions_1.githubApproversQuestion], existingValues);
346
+ }
347
+ (0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
348
+ const existingTwoFaEnabled = (0, utils_1.findExistingValue)('TWO_FA_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
349
+ const twoFaDefault = process.env.TWO_FA_ENABLED || (existingTwoFaEnabled === null || existingTwoFaEnabled === void 0 ? void 0 : existingTwoFaEnabled.value);
350
+ const two_fa_enabled = yield confirm({
351
+ message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
352
+ default: twoFaDefault
353
+ ? twoFaDefault === 'true'
354
+ : environment_type === 'production'
355
+ });
356
+ if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
357
+ (0, logger_1.warn)('2FA is disabled on a production-like environment. Logins will accept the fixed test code 000000, exposing real citizen data. Only do this if you know what you are doing.');
358
+ }
359
+ (0, logger_1.log)('\n', kleur_1.default.bold().underline('Container registry'));
360
+ yield promptAndValidateRegistry(existingValues);
282
361
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
283
362
  const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
284
363
  const kubeWorkerNodes = infrastructure.kubeWorkerNodes
@@ -340,6 +419,15 @@ function runSetupEnvironment() {
340
419
  .yellow('Variable DISK_SPACE is read-only, allocated space:'), DISK_SPACE === null || DISK_SPACE === void 0 ? void 0 : DISK_SPACE.value);
341
420
  }
342
421
  }
422
+ // Where RustFS keeps its data. A new environment starts on RustFS in
423
+ // /data/rustfs. An environment that already exists ran MinIO, so RustFS takes over
424
+ // /data/minio in place. The directory is not renamed, because the running MinIO
425
+ // would lose it before the deployment replaces it. The value is decided once and
426
+ // read back on the next run, otherwise an environment created on RustFS would
427
+ // look like an existing one from then on.
428
+ const existingRustfsHostDataPath = (0, utils_1.findExistingValue)('RUSTFS_HOST_DATA_PATH', 'VARIABLE', 'ENVIRONMENT', existingValues);
429
+ const rustfs_host_data_path = (existingRustfsHostDataPath === null || existingRustfsHostDataPath === void 0 ? void 0 : existingRustfsHostDataPath.value) ||
430
+ (environment_exists ? '/data/minio' : '/data/rustfs');
343
431
  // Backup and restore configuration
344
432
  let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
345
433
  let backupType = '';
@@ -417,7 +505,18 @@ function runSetupEnvironment() {
417
505
  (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
418
506
  }
419
507
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Monitoring'));
420
- yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
508
+ const existingMonitoringEnabled = (0, utils_1.findExistingValue)('MONITORING_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
509
+ const monitoringDefault = process.env.MONITORING_ENABLED || (existingMonitoringEnabled === null || existingMonitoringEnabled === void 0 ? void 0 : existingMonitoringEnabled.value);
510
+ const monitoring_enabled = yield confirm({
511
+ message: 'Enable monitoring (Kibana, APM, Filebeat, Metricbeat, Elastalert, OpenTelemetry Collector and tracing)? Disable it if this environment does not need its own monitoring stack.',
512
+ default: monitoringDefault ? monitoringDefault === 'true' : true
513
+ });
514
+ if (monitoring_enabled) {
515
+ yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
516
+ }
517
+ else {
518
+ (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Monitoring is disabled'));
519
+ }
421
520
  const sentryDSNExists = (0, utils_1.findExistingValue)('SENTRY_DSN', 'SECRET', 'ENVIRONMENT', existingValues);
422
521
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Sentry'));
423
522
  if (sentryDSNExists) {
@@ -447,11 +546,7 @@ function runSetupEnvironment() {
447
546
  * Variables the user doesn't need to set manually
448
547
  */
449
548
  const answerOrExisting = (variable, existingValue, fn) => fn(variable || (existingValue === null || existingValue === void 0 ? void 0 : existingValue.value)) || '';
450
- function findExistingOrDefine(name, type, scope, newValue) {
451
- return (0, utils_1.findExistingValue)(name, type, scope, existingValues)
452
- ? null
453
- : process.env[name] || newValue;
454
- }
549
+ const findExistingOrDefine = (name, type, scope, newValue) => defineIfMissing(existingValues, name, type, scope, newValue);
455
550
  const derivedUpdates = [
456
551
  {
457
552
  name: 'GH_ENCRYPTION_PASSWORD',
@@ -468,6 +563,32 @@ function runSetupEnvironment() {
468
563
  value: findExistingOrDefine('NOTIFICATION_TRANSPORT', 'VARIABLE', 'ENVIRONMENT', 'email'),
469
564
  scope: 'ENVIRONMENT'
470
565
  });
566
+ derivedUpdates.push({
567
+ name: 'TWO_FA_ENABLED',
568
+ type: 'VARIABLE',
569
+ didExist: existingTwoFaEnabled,
570
+ // Always stored, so the next run defaults to the current answer
571
+ value: two_fa_enabled ? 'true' : 'false',
572
+ scope: 'ENVIRONMENT'
573
+ });
574
+ // Read by the deployment workflows (vars.MONITORING_ENABLED) to decide
575
+ // whether the OpenTelemetry Collector is installed
576
+ derivedUpdates.push({
577
+ name: 'MONITORING_ENABLED',
578
+ type: 'VARIABLE',
579
+ didExist: existingMonitoringEnabled,
580
+ value: monitoring_enabled ? 'true' : 'false',
581
+ scope: 'ENVIRONMENT'
582
+ });
583
+ // Read back on the next run, to keep the volume of MinIO for an environment
584
+ // that migrated
585
+ derivedUpdates.push({
586
+ name: 'RUSTFS_HOST_DATA_PATH',
587
+ type: 'VARIABLE',
588
+ didExist: existingRustfsHostDataPath,
589
+ value: rustfs_host_data_path,
590
+ scope: 'ENVIRONMENT'
591
+ });
471
592
  derivedUpdates.push(...ssl_answers);
472
593
  if (configureBackup) {
473
594
  derivedUpdates.push({
@@ -494,17 +615,17 @@ function runSetupEnvironment() {
494
615
  scope: 'ENVIRONMENT'
495
616
  },
496
617
  {
497
- name: 'MINIO_ROOT_USER',
618
+ name: 'S3_ADMIN_ACCESS_KEY',
498
619
  type: 'SECRET',
499
- didExist: (0, utils_1.findExistingValue)('MINIO_ROOT_USER', 'SECRET', 'ENVIRONMENT', existingValues),
500
- value: findExistingOrDefine('MINIO_ROOT_USER', 'SECRET', 'ENVIRONMENT', (0, utils_1.generateLongPassword)()),
620
+ didExist: (0, utils_1.findExistingValue)('S3_ADMIN_ACCESS_KEY', 'SECRET', 'ENVIRONMENT', existingValues),
621
+ value: findExistingOrDefine('S3_ADMIN_ACCESS_KEY', 'SECRET', 'ENVIRONMENT', (0, utils_1.generateLongPassword)()),
501
622
  scope: 'ENVIRONMENT'
502
623
  },
503
624
  {
504
- name: 'MINIO_ROOT_PASSWORD',
625
+ name: 'S3_ADMIN_SECRET_KEY',
505
626
  type: 'SECRET',
506
- didExist: (0, utils_1.findExistingValue)('MINIO_ROOT_PASSWORD', 'SECRET', 'ENVIRONMENT', existingValues),
507
- value: findExistingOrDefine('MINIO_ROOT_PASSWORD', 'SECRET', 'ENVIRONMENT', (0, utils_1.generateLongPassword)()),
627
+ didExist: (0, utils_1.findExistingValue)('S3_ADMIN_SECRET_KEY', 'SECRET', 'ENVIRONMENT', existingValues),
628
+ value: findExistingOrDefine('S3_ADMIN_SECRET_KEY', 'SECRET', 'ENVIRONMENT', (0, utils_1.generateLongPassword)()),
508
629
  scope: 'ENVIRONMENT'
509
630
  },
510
631
  {
@@ -633,7 +754,8 @@ function runSetupEnvironment() {
633
754
  const newVariables = updates.filter((update) => update.type === 'VARIABLE' && !update.didExist);
634
755
  const updatedVariables = updates.filter((update) => update.type === 'VARIABLE' && Boolean(update.didExist));
635
756
  const unknownVariables = existingValues.filter((value) => {
636
- return !ALL_QUESTIONS.find((question) => question.valueLabel === value.name &&
757
+ return !ALL_QUESTIONS.find((question) => (question.valueLabel === value.name ||
758
+ question.legacyValueLabel === value.name) &&
637
759
  question.valueType === value.type &&
638
760
  question.scope === value.scope);
639
761
  });
@@ -762,6 +884,8 @@ function runSetupEnvironment() {
762
884
  env: environment,
763
885
  environment_type: environment_type,
764
886
  two_fa_enabled,
887
+ monitoring_enabled,
888
+ rustfs_host_data_path,
765
889
  traefik_mode: traefikConfOption,
766
890
  restore_enabled: restoreEnvironmentName ? true : false,
767
891
  restore_environment_name: restoreEnvironmentName || '',
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAepD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAepD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAyBzE"}