@opencrvs/toolkit 2.1.0 → 2.2.0-rc.3af310b

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 (136) hide show
  1. package/build.sh +2 -12
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +36 -4
  4. package/dist/authentication/index.js +14 -2
  5. package/dist/cli.js +961 -2033
  6. package/dist/commons/api/router.d.ts +1374 -71
  7. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  8. package/dist/commons/events/ActionConfig.d.ts +146 -20
  9. package/dist/commons/events/ActionDocument.d.ts +88 -0
  10. package/dist/commons/events/ActionInput.d.ts +52 -0
  11. package/dist/commons/events/ActionType.d.ts +11 -1
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/AuditLog.d.ts +4 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventConfig.d.ts +36 -6
  17. package/dist/commons/events/EventDocument.d.ts +88 -0
  18. package/dist/commons/events/EventIndex.d.ts +41 -4
  19. package/dist/commons/events/EventMetadata.d.ts +23 -1
  20. package/dist/commons/events/EventStatus.d.ts +1 -0
  21. package/dist/commons/events/FieldConfig.d.ts +10 -0
  22. package/dist/commons/events/Flag.d.ts +0 -6
  23. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  24. package/dist/commons/events/eventConfigValidation.d.ts +26 -1
  25. package/dist/commons/events/notificationFormFallback.d.ts +10 -0
  26. package/dist/commons/events/scopes.d.ts +2 -0
  27. package/dist/commons/events/state/flags.d.ts +1 -1
  28. package/dist/commons/events/state/index.d.ts +10 -2
  29. package/dist/commons/events/state/utils.d.ts +11 -1
  30. package/dist/commons/events/test.utils.d.ts +31 -1
  31. package/dist/commons/events/utils.d.ts +53 -20
  32. package/dist/conditionals/index.js +14 -2
  33. package/dist/environment/derived-variables.d.ts +24 -0
  34. package/dist/environment/derived-variables.d.ts.map +1 -1
  35. package/dist/environment/derived-variables.js +28 -0
  36. package/dist/environment/dockerhub.d.ts +15 -0
  37. package/dist/environment/dockerhub.d.ts.map +1 -0
  38. package/dist/environment/dockerhub.js +104 -0
  39. package/dist/environment/questions.js +1 -1
  40. package/dist/environment/setup-environment.d.ts.map +1 -1
  41. package/dist/environment/setup-environment.js +70 -12
  42. package/dist/environment/templates.d.ts.map +1 -1
  43. package/dist/events/index.js +461 -83
  44. package/dist/migrations/index.d.ts +9 -0
  45. package/dist/migrations/index.d.ts.map +1 -0
  46. package/dist/migrations/index.js +847 -0
  47. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  48. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  49. package/dist/migrations/move-declaration-to-declare-action.js +377 -0
  50. package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
  51. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  52. package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
  53. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  54. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  55. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  56. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  57. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  58. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  59. package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
  60. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  61. package/dist/migrations/read-declaration-through-helper.js +257 -0
  62. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  63. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  64. package/dist/migrations/replace-incomplete-flag.js +126 -0
  65. package/dist/notification/index.js +401 -100
  66. package/dist/scopes/index.d.ts +29 -39
  67. package/dist/scopes/index.js +14 -2
  68. package/dist/templates/charts-values/dependencies/values.yaml +1 -1
  69. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -2
  70. package/dist/templates/charts-values/traefik/values.yaml +4 -3
  71. package/opencrvs-toolkit-2.2.0-rc.3af310b.tgz +0 -0
  72. package/package.json +1 -1
  73. package/tsconfig.build.tsbuildinfo +1 -1
  74. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  75. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  76. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  77. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  78. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  79. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  80. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  81. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  82. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  83. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  84. package/dist/migrations/v2.1/index.d.ts +0 -6
  85. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  86. package/dist/migrations/v2.1/index.js +0 -2170
  87. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
  88. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  89. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  90. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  91. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  92. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  93. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  94. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  95. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  96. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  97. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  98. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  99. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  100. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  101. package/dist/migrations/v2.1/template-files.js +0 -49
  102. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
  103. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  104. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  105. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  106. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  107. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  108. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  109. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  110. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  111. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  112. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  113. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  114. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  115. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  116. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  117. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  118. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  119. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  120. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  121. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  122. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  123. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  124. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  125. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  126. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  127. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  128. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  129. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  130. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  131. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  132. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  133. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  134. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  135. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  136. package/opencrvs-toolkit-2.1.0.tgz +0 -0
@@ -1,4 +1,5 @@
1
1
  import { Action } from '../ActionDocument';
2
+ import { EventStatus } from '../EventMetadata';
2
3
  /**
3
4
  * Returns the creation metadata of the last update action (Requested or Accepted).
4
5
  * Requested actions are included so that async flows (202) correctly reflect the
@@ -29,7 +30,7 @@ export declare function getActionUpdateMetadata(actions: Action[]): Pick<{
29
30
  * @returns the legal statuses of the event. Event is considered legal if it has been accepted.
30
31
  * @see EventIndex for the description of the returned object.
31
32
  */
32
- export declare function getLegalStatuses(actions: Action[]): {
33
+ export declare function getLegalStatuses(actions: Action[], status: EventStatus): {
33
34
  NOTIFIED: {
34
35
  createdAt: string;
35
36
  createdBy: string;
@@ -57,5 +58,14 @@ export declare function getLegalStatuses(actions: Action[]): {
57
58
  createdByRole: string | undefined;
58
59
  registrationNumber: string | null | undefined;
59
60
  } | null;
61
+ REVOKED: {
62
+ createdAt: string;
63
+ createdBy: string;
64
+ createdByUserType: "system" | "user";
65
+ createdAtLocation: (string & import("zod").$brand<"UUID">) | null | undefined;
66
+ acceptedAt: string;
67
+ createdByRole: string | undefined;
68
+ registrationNumber: string | null | undefined;
69
+ } | null;
60
70
  };
61
71
  //# sourceMappingURL=utils.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { UUID } from '../uuid';
2
2
  import { ActionDocument, ActionUpdate } from './ActionDocument';
3
3
  import { ValidatorContext } from '../conditionals/validate';
4
- import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, EditActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnarchiveActionInput, UnassignActionInput } from './ActionInput';
4
+ import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, EditActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnarchiveActionInput, UnassignActionInput, RevokeRegistrationActionInput, ReinstateRegistrationActionInput } from './ActionInput';
5
5
  import { ActionType } from './ActionType';
6
6
  import { Draft } from './Draft';
7
7
  import { EventConfig, EventConfigInput } from './EventConfig';
@@ -10,6 +10,7 @@ import { EventIndex } from './EventIndex';
10
10
  import { EventInput } from './EventInput';
11
11
  import { TranslationConfig } from './TranslationConfig';
12
12
  import { FieldConfig } from './FieldConfig';
13
+ import { DeclarationFormConfig } from './FormConfig';
13
14
  import { LocationVersion, SetLocationPayload, SetAdministrativeAreaPayload, ClientAdministrativeArea } from './locations';
14
15
  import { WorkqueueConfig } from './WorkqueueConfig';
15
16
  import * as z from 'zod/v4';
@@ -158,6 +159,28 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
158
159
  annotation: {};
159
160
  eventId: string;
160
161
  };
162
+ revokeRegistration: (eventId: string, input?: Partial<Pick<RevokeRegistrationActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
163
+ keepAssignment?: boolean | undefined;
164
+ keepAssignmentIfAccepted?: boolean | undefined;
165
+ keepAssignmentIfRejected?: boolean | undefined;
166
+ waitFor?: boolean | undefined;
167
+ type: "REVOKE_REGISTRATION";
168
+ transactionId: string;
169
+ declaration: {};
170
+ annotation: {};
171
+ eventId: string;
172
+ };
173
+ reinstateRegistration: (eventId: string, input?: Partial<Pick<ReinstateRegistrationActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
174
+ keepAssignment?: boolean | undefined;
175
+ keepAssignmentIfAccepted?: boolean | undefined;
176
+ keepAssignmentIfRejected?: boolean | undefined;
177
+ waitFor?: boolean | undefined;
178
+ type: "REINSTATE_REGISTRATION";
179
+ transactionId: string;
180
+ declaration: {};
181
+ annotation: {};
182
+ eventId: string;
183
+ };
161
184
  reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfAccepted' | 'keepAssignmentIfRejected' | 'waitFor'>>) => {
162
185
  keepAssignment?: boolean | undefined;
163
186
  keepAssignmentIfAccepted?: boolean | undefined;
@@ -328,6 +351,13 @@ export declare const generateEventConfig: ({ id, fields, placeOfEventId, dateOfE
328
351
  /** Extra actions appended to the default READ + DECLARE pair, e.g. a REQUEST_CORRECTION action with its own correctionForm. */
329
352
  actions?: EventConfigInput['actions'];
330
353
  }) => EventConfig;
354
+ /**
355
+ * The notification form is dropped, since it may refer to fields of the replaced declaration.
356
+ * `getNotificationForm` then derives it from the new declaration.
357
+ *
358
+ * @returns a copy of the configuration with the DECLARE action's declaration replaced.
359
+ */
360
+ export declare function withDeclaration(configuration: EventConfig, declaration: DeclarationFormConfig): EventConfig;
331
361
  /**
332
362
  * Get the leaf administrative area IDs from a list of administrative areas.
333
363
  *
@@ -8,24 +8,10 @@ import { Draft } from './Draft';
8
8
  import { EventDocument } from './EventDocument';
9
9
  import { UUID } from '../uuid';
10
10
  import { ActionConfig, ActionConfigTypes } from './ActionConfig';
11
- import { FormConfig } from './FormConfig';
11
+ import { DeclarationFormConfig, FormConfig } from './FormConfig';
12
12
  import { PlainDate, SelectDateRangeValue } from './FieldValue';
13
13
  import { EventIndex } from './EventIndex';
14
14
  export declare function ageToDate(age: number, asOfDate: PlainDate): string & import("zod").$brand<"PlainDate">;
15
- export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
16
- export declare function getDeclarationPages(configuration: EventConfig): {
17
- id: string;
18
- title: {
19
- id: string;
20
- defaultMessage: string;
21
- description: string;
22
- };
23
- requireCompletionToContinue: boolean;
24
- showClearButton?: boolean | undefined;
25
- fields: FieldConfig[];
26
- conditional?: any;
27
- type: "FORM";
28
- }[];
29
15
  export declare function getDeclaration(configuration: EventConfig): {
30
16
  label: {
31
17
  id: string;
@@ -46,6 +32,29 @@ export declare function getDeclaration(configuration: EventConfig): {
46
32
  type: "FORM";
47
33
  }[];
48
34
  };
35
+ export declare function getDeclarationPages(configuration: EventConfig): {
36
+ id: string;
37
+ title: {
38
+ id: string;
39
+ defaultMessage: string;
40
+ description: string;
41
+ };
42
+ requireCompletionToContinue: boolean;
43
+ showClearButton?: boolean | undefined;
44
+ fields: FieldConfig[];
45
+ conditional?: any;
46
+ type: "FORM";
47
+ }[];
48
+ export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
49
+ /**
50
+ * @returns the notification form of the event: the one configured on the NOTIFY action,
51
+ * or the declaration with every field optional when none is configured.
52
+ *
53
+ * The fallback is derived here rather than in `defineConfig`, so that it is not part of the
54
+ * served event configuration.
55
+ */
56
+ export declare function getNotificationForm(configuration: EventConfig): DeclarationFormConfig;
57
+ export declare function getNotificationFields(configuration: EventConfig): FieldConfig[];
49
58
  export declare function isActionConfigType(type: ActionType): type is ActionConfigTypes;
50
59
  export declare function getActionConfig({ eventConfiguration, actionType, customActionType }: {
51
60
  eventConfiguration: EventConfig;
@@ -55,10 +64,6 @@ export declare function getActionConfig({ eventConfiguration, actionType, custom
55
64
  export declare function getCustomActionFields(eventConfiguration: EventConfig, customActionType: string): FieldConfig[];
56
65
  /**
57
66
  * Returns the fields configured for an action's confirmation dialog.
58
- *
59
- * Unlike review fields and supporting copy, NOTIFY does NOT fall back to the
60
- * DECLARE config here: dialog fields always come from the action's own
61
- * configuration entry.
62
67
  */
63
68
  export declare function getActionFormFields(eventConfiguration: EventConfig, actionType: ActionType, customActionType?: string): FieldConfig[];
64
69
  export declare function getPrintCertificatePages(configuration: EventConfig): ({
@@ -277,6 +282,34 @@ export declare function findLastAssignmentAction(actions: Action[]): {
277
282
  status: "Accepted" | "Rejected" | "Requested";
278
283
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
279
284
  type: "UNARCHIVE";
285
+ } | {
286
+ id: string & import("zod").$brand<"UUID">;
287
+ transactionId: string;
288
+ createdByUserType: "system" | "user";
289
+ createdAt: string;
290
+ createdBy: string;
291
+ createdByRole?: string | undefined;
292
+ createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
293
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
294
+ declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
295
+ annotation?: Record<string, import("./FieldValue").FieldUpdateValue> | null | undefined;
296
+ status: "Accepted" | "Rejected" | "Requested";
297
+ originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
298
+ type: "REVOKE_REGISTRATION";
299
+ } | {
300
+ id: string & import("zod").$brand<"UUID">;
301
+ transactionId: string;
302
+ createdByUserType: "system" | "user";
303
+ createdAt: string;
304
+ createdBy: string;
305
+ createdByRole?: string | undefined;
306
+ createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
307
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
308
+ declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
309
+ annotation?: Record<string, import("./FieldValue").FieldUpdateValue> | null | undefined;
310
+ status: "Accepted" | "Rejected" | "Requested";
311
+ originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
312
+ type: "REINSTATE_REGISTRATION";
280
313
  } | {
281
314
  id: string & import("zod").$brand<"UUID">;
282
315
  transactionId: string;
@@ -472,7 +505,7 @@ export declare function findLastAssignmentAction(actions: Action[]): {
472
505
  createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
473
506
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
474
507
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
475
- type: "APPROVE_CORRECTION" | "ARCHIVE" | "CUSTOM" | "DECLARE" | "EDIT" | "NOTIFY" | "PRINT_CERTIFICATE" | "REGISTER" | "REJECT" | "REJECT_CORRECTION" | "REQUEST_CORRECTION" | "UNARCHIVE";
508
+ type: "APPROVE_CORRECTION" | "ARCHIVE" | "CUSTOM" | "DECLARE" | "EDIT" | "NOTIFY" | "PRINT_CERTIFICATE" | "REGISTER" | "REINSTATE_REGISTRATION" | "REJECT" | "REJECT_CORRECTION" | "REQUEST_CORRECTION" | "REVOKE_REGISTRATION" | "UNARCHIVE";
476
509
  status: "Rejected";
477
510
  } | undefined;
478
511
  /**
@@ -162,6 +162,8 @@ var ActionType = {
162
162
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
163
163
  REJECT_CORRECTION: "REJECT_CORRECTION",
164
164
  APPROVE_CORRECTION: "APPROVE_CORRECTION",
165
+ REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
166
+ REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
165
167
  // General actions
166
168
  READ: "READ",
167
169
  ASSIGN: "ASSIGN",
@@ -181,6 +183,8 @@ var ConfirmableActions = [
181
183
  ActionType.REQUEST_CORRECTION,
182
184
  ActionType.APPROVE_CORRECTION,
183
185
  ActionType.REJECT_CORRECTION,
186
+ ActionType.REVOKE_REGISTRATION,
187
+ ActionType.REINSTATE_REGISTRATION,
184
188
  ActionType.CUSTOM
185
189
  ];
186
190
  var ActionTypes = z6.enum([
@@ -200,6 +204,8 @@ var ActionTypes = z6.enum([
200
204
  "REQUEST_CORRECTION",
201
205
  "REJECT_CORRECTION",
202
206
  "APPROVE_CORRECTION",
207
+ "REVOKE_REGISTRATION",
208
+ "REINSTATE_REGISTRATION",
203
209
  "READ",
204
210
  "ASSIGN",
205
211
  "UNASSIGN",
@@ -238,7 +244,9 @@ var WorkqueueActionType = ActionTypes.extract([
238
244
  ActionType.ARCHIVE,
239
245
  ActionType.UNARCHIVE,
240
246
  ActionType.PRINT_CERTIFICATE,
241
- ActionType.REQUEST_CORRECTION
247
+ ActionType.REQUEST_CORRECTION,
248
+ ActionType.REVOKE_REGISTRATION,
249
+ ActionType.REINSTATE_REGISTRATION
242
250
  ]);
243
251
  var META_ACTIONS = [
244
252
  ActionType.ASSIGN,
@@ -323,7 +331,6 @@ var FieldConditional = z8.discriminatedUnion("type", [
323
331
 
324
332
  // ../commons/src/events/Flag.ts
325
333
  var InherentFlags = {
326
- INCOMPLETE: "incomplete",
327
334
  REJECTED: "rejected",
328
335
  CORRECTION_REQUESTED: "correction-requested",
329
336
  POTENTIAL_DUPLICATE: "potential-duplicate",
@@ -390,6 +397,7 @@ var EventStatus = z10.enum([
390
397
  "NOTIFIED",
391
398
  "DECLARED",
392
399
  "REGISTERED",
400
+ "REVOKED",
393
401
  "ARCHIVED"
394
402
  ]);
395
403
 
@@ -413,6 +421,8 @@ var RecordScopeTypeV2 = z11.enum([
413
421
  "record.print-certified-copies",
414
422
  "record.request-correction",
415
423
  "record.correct",
424
+ "record.revoke-registration",
425
+ "record.reinstate-registration",
416
426
  "record.unassign-others",
417
427
  "record.custom-action",
418
428
  "record.action.accept",
@@ -539,6 +549,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
539
549
  "record.read",
540
550
  "record.request-correction",
541
551
  "record.correct",
552
+ "record.revoke-registration",
553
+ "record.reinstate-registration",
542
554
  "record.unassign-others",
543
555
  "record.review-duplicates"
544
556
  ]);
@@ -112,11 +112,35 @@ export declare const derivedVariables: readonly [{
112
112
  readonly valueType: 'VARIABLE';
113
113
  readonly type: 'disabled';
114
114
  readonly scope: 'ENVIRONMENT';
115
+ }, {
116
+ readonly name: 'RESTORE_ENVIRONMENT_MODE';
117
+ readonly valueLabel: 'RESTORE_ENVIRONMENT_MODE';
118
+ readonly valueType: 'VARIABLE';
119
+ readonly type: 'disabled';
120
+ readonly scope: 'ENVIRONMENT';
121
+ }, {
122
+ readonly name: 'RESTORE_HOST';
123
+ readonly valueLabel: 'RESTORE_HOST';
124
+ readonly valueType: 'VARIABLE';
125
+ readonly type: 'disabled';
126
+ readonly scope: 'ENVIRONMENT';
115
127
  }, {
116
128
  readonly name: 'NOTIFICATION_TRANSPORT';
117
129
  readonly valueLabel: 'NOTIFICATION_TRANSPORT';
118
130
  readonly valueType: 'VARIABLE';
119
131
  readonly type: 'disabled';
120
132
  readonly scope: 'ENVIRONMENT';
133
+ }, {
134
+ readonly name: 'TWO_FA_ENABLED';
135
+ readonly valueLabel: 'TWO_FA_ENABLED';
136
+ readonly valueType: 'VARIABLE';
137
+ readonly type: 'disabled';
138
+ readonly scope: 'ENVIRONMENT';
139
+ }, {
140
+ readonly name: 'MONITORING_ENABLED';
141
+ readonly valueLabel: 'MONITORING_ENABLED';
142
+ readonly valueType: 'VARIABLE';
143
+ readonly type: 'disabled';
144
+ readonly scope: 'ENVIRONMENT';
121
145
  }];
122
146
  //# sourceMappingURL=derived-variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"derived-variables.d.ts","sourceRoot":"","sources":["../../src/environment/derived-variables.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB;aAEzB,IAAI,EAAE,gBAAgB;aACtB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,qBAAqB;aAC3B,UAAU,EAAE,qBAAqB;aACjC,SAAS,EAAE,UAAU;aACrB,IAAI,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EAAE,0BAA0B;aAChC,UAAU,EAAE,0BAA0B;aACtC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,cAAc;aACpB,UAAU,EAAE,cAAc;aAC1B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,wBAAwB;aAC9B,UAAU,EAAE,wBAAwB;aACpC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,gBAAgB;aACtB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,oBAAoB;aAC1B,UAAU,EAAE,oBAAoB;aAChC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;EAEd,CAAA"}
@@ -145,11 +145,39 @@ exports.derivedVariables = [
145
145
  type: 'disabled',
146
146
  scope: 'ENVIRONMENT'
147
147
  },
148
+ {
149
+ name: 'RESTORE_ENVIRONMENT_MODE',
150
+ valueLabel: 'RESTORE_ENVIRONMENT_MODE',
151
+ valueType: 'VARIABLE',
152
+ type: 'disabled',
153
+ scope: 'ENVIRONMENT'
154
+ },
155
+ {
156
+ name: 'RESTORE_HOST',
157
+ valueLabel: 'RESTORE_HOST',
158
+ valueType: 'VARIABLE',
159
+ type: 'disabled',
160
+ scope: 'ENVIRONMENT'
161
+ },
148
162
  {
149
163
  name: 'NOTIFICATION_TRANSPORT',
150
164
  valueLabel: 'NOTIFICATION_TRANSPORT',
151
165
  valueType: 'VARIABLE',
152
166
  type: 'disabled',
153
167
  scope: 'ENVIRONMENT'
168
+ },
169
+ {
170
+ name: 'TWO_FA_ENABLED',
171
+ valueLabel: 'TWO_FA_ENABLED',
172
+ valueType: 'VARIABLE',
173
+ type: 'disabled',
174
+ scope: 'ENVIRONMENT'
175
+ },
176
+ {
177
+ name: 'MONITORING_ENABLED',
178
+ valueLabel: 'MONITORING_ENABLED',
179
+ valueType: 'VARIABLE',
180
+ type: 'disabled',
181
+ scope: 'ENVIRONMENT'
154
182
  }
155
183
  ];
@@ -0,0 +1,15 @@
1
+ type DockerHubValidationResult = {
2
+ status: 'valid' | 'skipped' | 'invalid-credentials' | 'repository-not-found' | 'unreachable';
3
+ reason?: string;
4
+ };
5
+ /**
6
+ * Checks that the username/token pair is accepted by Docker Hub and that the
7
+ * organisation/repository exists and is visible to that account. An empty
8
+ * repository is fine, only its existence matters.
9
+ *
10
+ * Existing GitHub secrets cannot be read back, so when any value is missing
11
+ * (kept from an existing secret) the check is skipped.
12
+ */
13
+ export declare function validateDockerHubCredentials(organisation: string | undefined, repository: string | undefined, username: string | undefined, token: string | undefined): Promise<DockerHubValidationResult>;
14
+ export {};
15
+ //# sourceMappingURL=dockerhub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dockerhub.d.ts","sourceRoot":"","sources":["../../src/environment/dockerhub.ts"],"names":[],"mappings":"AAcA,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EACF,OAAO,GAEP,SAAS,GACT,qBAAqB,GACrB,sBAAsB,GAEtB,aAAa,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,4BAA4B,CAChD,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAAC,yBAAyB,CAAC,CAoFpC"}
@@ -0,0 +1,104 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.validateDockerHubCredentials = validateDockerHubCredentials;
23
+ const DOCKER_HUB_API = 'https://hub.docker.com/v2';
24
+ const REQUEST_TIMEOUT_MS = 10000;
25
+ /**
26
+ * Checks that the username/token pair is accepted by Docker Hub and that the
27
+ * organisation/repository exists and is visible to that account. An empty
28
+ * repository is fine, only its existence matters.
29
+ *
30
+ * Existing GitHub secrets cannot be read back, so when any value is missing
31
+ * (kept from an existing secret) the check is skipped.
32
+ */
33
+ function validateDockerHubCredentials(organisation, repository, username, token) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ var _a;
36
+ if (!organisation || !repository || !username || !token) {
37
+ return {
38
+ status: 'skipped',
39
+ reason: 'Some values are kept from existing GitHub secrets, which cannot be read back'
40
+ };
41
+ }
42
+ try {
43
+ const login = yield fetch(`${DOCKER_HUB_API}/auth/token`, {
44
+ method: 'POST',
45
+ headers: { 'Content-Type': 'application/json' },
46
+ body: JSON.stringify({ identifier: username, secret: token }),
47
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
48
+ });
49
+ if (login.status === 401 || login.status === 403) {
50
+ return {
51
+ status: 'invalid-credentials',
52
+ reason: 'Docker Hub rejected the username or token. Check DOCKER_USERNAME and DOCKER_TOKEN'
53
+ };
54
+ }
55
+ if (!login.ok) {
56
+ return {
57
+ status: 'unreachable',
58
+ reason: `Docker Hub login responded with HTTP ${login.status}`
59
+ };
60
+ }
61
+ const body = (yield login.json());
62
+ const accessToken = (_a = body.access_token) !== null && _a !== void 0 ? _a : body.token;
63
+ if (!accessToken) {
64
+ return {
65
+ status: 'unreachable',
66
+ reason: 'Docker Hub login response did not contain an access token'
67
+ };
68
+ }
69
+ const repositoryResponse = yield fetch(`${DOCKER_HUB_API}/repositories/${encodeURIComponent(organisation)}/${encodeURIComponent(repository)}/`, {
70
+ headers: { Authorization: `Bearer ${accessToken}` },
71
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
72
+ });
73
+ if (repositoryResponse.ok) {
74
+ return { status: 'valid' };
75
+ }
76
+ // Docker Hub answers 404 for private repositories the account cannot see
77
+ if (repositoryResponse.status === 404) {
78
+ return {
79
+ status: 'repository-not-found',
80
+ reason: `Login succeeded, but repository ${organisation}/${repository} was not found or is not accessible with this token. Check DOCKERHUB_ACCOUNT and DOCKERHUB_REPO`
81
+ };
82
+ }
83
+ if (repositoryResponse.status === 401 ||
84
+ repositoryResponse.status === 403) {
85
+ return {
86
+ status: 'invalid-credentials',
87
+ reason: `Login succeeded, but the token is not allowed to read repository ${organisation}/${repository}`
88
+ };
89
+ }
90
+ return {
91
+ status: 'unreachable',
92
+ reason: `Docker Hub repository lookup responded with HTTP ${repositoryResponse.status}`
93
+ };
94
+ }
95
+ catch (err) {
96
+ if (!(err instanceof Error)) {
97
+ return { status: 'unreachable', reason: String(err) };
98
+ }
99
+ // fetch only reports "fetch failed", the real error (e.g. ENOTFOUND) is its cause
100
+ const cause = err.cause instanceof Error ? `: ${err.cause.message}` : '';
101
+ return { status: 'unreachable', reason: `${err.message}${cause}` };
102
+ }
103
+ });
104
+ }
@@ -201,7 +201,7 @@ exports.infrastructureQuestions = [
201
201
  valueLabel: 'KUBE_API_ALLOWED_CIDRS',
202
202
  initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
203
203
  scope: 'ENVIRONMENT'
204
- },
204
+ }
205
205
  ];
206
206
  exports.staticSSLCertQuestions = [
207
207
  {
@@ -1 +1 @@
1
- {"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AAwSA,wBAAsB,mBAAmB,kBAkmCxC"}
1
+ {"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AAiUA,wBAAsB,mBAAmB,kBA2pCxC"}
@@ -65,6 +65,7 @@ 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 dockerhub_1 = require("./dockerhub");
68
69
  const manage_users_1 = require("./manage-users");
69
70
  const paths_1 = require("./paths");
70
71
  function questionToPrompt(_a) {
@@ -175,6 +176,23 @@ function promptAndStoreAnswer(questions, existingValues) {
175
176
  return Object.assign(Object.assign({}, Object.fromEntries(existingValuesForQuestions)), result);
176
177
  });
177
178
  }
179
+ function promptAndValidateDockerhub(existingValues) {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ const answers = yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
182
+ const result = yield (0, dockerhub_1.validateDockerHubCredentials)(answers.dockerhubOrganisation, answers.dockerhubRepository, answers.dockerhubUsername, answers.dockerhubToken);
183
+ if (result.status === 'valid' || result.status === 'skipped') {
184
+ return;
185
+ }
186
+ (0, logger_1.error)(`\n${result.status}: ${result.reason || 'Generic error'}\n`);
187
+ const continueNotValidated = yield confirm({
188
+ message: 'Docker Hub credentials are not validated. Continue anyway?',
189
+ default: false
190
+ });
191
+ if (!continueNotValidated) {
192
+ process.exit(1);
193
+ }
194
+ });
195
+ }
178
196
  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);
179
197
  function runSetupEnvironment() {
180
198
  return __awaiter(this, void 0, void 0, function* () {
@@ -239,16 +257,6 @@ function runSetupEnvironment() {
239
257
  ]
240
258
  });
241
259
  }
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
260
  const environment_exists = existingEnvironments
253
261
  .map((e) => e.trim())
254
262
  .includes(environment);
@@ -277,8 +285,20 @@ function runSetupEnvironment() {
277
285
  .bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
278
286
  yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
279
287
  }
288
+ (0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
289
+ const existingTwoFaEnabled = (0, utils_1.findExistingValue)('TWO_FA_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
290
+ const twoFaDefault = process.env.TWO_FA_ENABLED || (existingTwoFaEnabled === null || existingTwoFaEnabled === void 0 ? void 0 : existingTwoFaEnabled.value);
291
+ const two_fa_enabled = yield confirm({
292
+ message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
293
+ default: twoFaDefault
294
+ ? twoFaDefault === 'true'
295
+ : environment_type === 'production'
296
+ });
297
+ if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
298
+ (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.');
299
+ }
280
300
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
281
- yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
301
+ yield promptAndValidateDockerhub(existingValues);
282
302
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
283
303
  const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
284
304
  const kubeWorkerNodes = infrastructure.kubeWorkerNodes
@@ -396,6 +416,7 @@ function runSetupEnvironment() {
396
416
  });
397
417
  restoreType = yield select({
398
418
  message: `Select ${kleur_1.default.yellow().bold(restoreEnvironmentName)} environment backup mode`,
419
+ default: restoreType,
399
420
  choices: [
400
421
  {
401
422
  name: 'Full dump (daily full database backup)',
@@ -416,7 +437,18 @@ function runSetupEnvironment() {
416
437
  (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
417
438
  }
418
439
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Monitoring'));
419
- yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
440
+ const existingMonitoringEnabled = (0, utils_1.findExistingValue)('MONITORING_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
441
+ const monitoringDefault = process.env.MONITORING_ENABLED || (existingMonitoringEnabled === null || existingMonitoringEnabled === void 0 ? void 0 : existingMonitoringEnabled.value);
442
+ const monitoring_enabled = yield confirm({
443
+ message: 'Enable monitoring (Kibana, APM, Filebeat, Metricbeat, Elastalert, OpenTelemetry Collector and tracing)? Disable it if this environment does not need its own monitoring stack.',
444
+ default: monitoringDefault ? monitoringDefault === 'true' : true
445
+ });
446
+ if (monitoring_enabled) {
447
+ yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
448
+ }
449
+ else {
450
+ (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Monitoring is disabled'));
451
+ }
420
452
  const sentryDSNExists = (0, utils_1.findExistingValue)('SENTRY_DSN', 'SECRET', 'ENVIRONMENT', existingValues);
421
453
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Sentry'));
422
454
  if (sentryDSNExists) {
@@ -467,6 +499,23 @@ function runSetupEnvironment() {
467
499
  value: findExistingOrDefine('NOTIFICATION_TRANSPORT', 'VARIABLE', 'ENVIRONMENT', 'email'),
468
500
  scope: 'ENVIRONMENT'
469
501
  });
502
+ derivedUpdates.push({
503
+ name: 'TWO_FA_ENABLED',
504
+ type: 'VARIABLE',
505
+ didExist: existingTwoFaEnabled,
506
+ // Always stored, so the next run defaults to the current answer
507
+ value: two_fa_enabled ? 'true' : 'false',
508
+ scope: 'ENVIRONMENT'
509
+ });
510
+ // Read by the deployment workflows (vars.MONITORING_ENABLED) to decide
511
+ // whether the OpenTelemetry Collector is installed
512
+ derivedUpdates.push({
513
+ name: 'MONITORING_ENABLED',
514
+ type: 'VARIABLE',
515
+ didExist: existingMonitoringEnabled,
516
+ value: monitoring_enabled ? 'true' : 'false',
517
+ scope: 'ENVIRONMENT'
518
+ });
470
519
  derivedUpdates.push(...ssl_answers);
471
520
  if (configureBackup) {
472
521
  derivedUpdates.push({
@@ -582,6 +631,14 @@ function runSetupEnvironment() {
582
631
  value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
583
632
  didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
584
633
  scope: 'ENVIRONMENT'
634
+ },
635
+ {
636
+ type: 'VARIABLE',
637
+ name: 'RESTORE_ENVIRONMENT_MODE',
638
+ // Only persist the mode when restore is configured
639
+ value: restoreEnvironmentName ? restoreType : '',
640
+ didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues),
641
+ scope: 'ENVIRONMENT'
585
642
  }
586
643
  ];
587
644
  if (enableEncryption) {
@@ -753,6 +810,7 @@ function runSetupEnvironment() {
753
810
  env: environment,
754
811
  environment_type: environment_type,
755
812
  two_fa_enabled,
813
+ monitoring_enabled,
756
814
  traefik_mode: traefikConfOption,
757
815
  restore_enabled: restoreEnvironmentName ? true : false,
758
816
  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"}