@opencrvs/toolkit 2.1.0 → 2.2.0-rc.ab91cce

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 (36) hide show
  1. package/build.sh +2 -2
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/cli.js +294 -1967
  4. package/dist/commons/events/ActionConfig.d.ts +79 -0
  5. package/dist/commons/events/EventConfig.d.ts +26 -6
  6. package/dist/commons/events/eventConfigValidation.d.ts +17 -1
  7. package/dist/commons/events/test.utils.d.ts +5 -0
  8. package/dist/commons/events/utils.d.ts +14 -14
  9. package/dist/environment/derived-variables.d.ts +18 -0
  10. package/dist/environment/derived-variables.d.ts.map +1 -1
  11. package/dist/environment/derived-variables.js +22 -1
  12. package/dist/environment/setup-environment.d.ts.map +1 -1
  13. package/dist/environment/setup-environment.js +29 -10
  14. package/dist/events/index.js +171 -60
  15. package/dist/migrations/add-translations.d.ts +15 -0
  16. package/dist/migrations/add-translations.d.ts.map +1 -0
  17. package/dist/migrations/{v2.1/add-translations.js → add-translations.js} +16 -14
  18. package/dist/migrations/v2.1/index.js +35 -2155
  19. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +3 -0
  20. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -1
  21. package/dist/migrations/v2.1/upgrade-tilt.d.ts +3 -0
  22. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -1
  23. package/dist/migrations/v2.2/index.d.ts +6 -0
  24. package/dist/migrations/v2.2/index.d.ts.map +1 -0
  25. package/dist/migrations/v2.2/index.js +456 -0
  26. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts +39 -0
  27. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +1 -0
  28. package/dist/migrations/v2.2/read-declaration-through-helper.js +257 -0
  29. package/dist/notification/index.js +191 -83
  30. package/dist/templates/charts-values/traefik/values.yaml +2 -3
  31. package/opencrvs-toolkit-2.2.0-rc.ab91cce.tgz +0 -0
  32. package/package.json +1 -1
  33. package/tsconfig.build.tsbuildinfo +1 -1
  34. package/dist/migrations/v2.1/add-translations.d.ts +0 -9
  35. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  36. package/opencrvs-toolkit-2.1.0.tgz +0 -0
@@ -30,6 +30,60 @@ export declare const ActionConfigBase: z.ZodObject<{
30
30
  conditional: z.ZodAny;
31
31
  }, z.core.$strip>], "type">>>;
32
32
  }, z.core.$strip>;
33
+ declare const DeclareConfig: z.ZodObject<{
34
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
35
+ flags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
36
+ id: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
37
+ readonly INCOMPLETE: 'incomplete';
38
+ readonly REJECTED: 'rejected';
39
+ readonly CORRECTION_REQUESTED: 'correction-requested';
40
+ readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
41
+ readonly EDIT_IN_PROGRESS: 'edit-in-progress';
42
+ }>]>, z.ZodString]>;
43
+ operation: z.ZodEnum<{
44
+ add: "add";
45
+ remove: "remove";
46
+ }>;
47
+ conditional: z.ZodOptional<z.ZodAny>;
48
+ }, z.core.$strip>>>>;
49
+ supportingCopy: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>>;
50
+ icon: z.ZodOptional<z.ZodString>;
51
+ conditionals: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
52
+ type: z.ZodLiteral<"SHOW">;
53
+ conditional: z.ZodAny;
54
+ }, z.core.$strip>, z.ZodObject<{
55
+ type: z.ZodLiteral<"ENABLE">;
56
+ conditional: z.ZodAny;
57
+ }, z.core.$strip>], "type">>>;
58
+ deduplication: z.ZodOptional<z.ZodObject<{
59
+ id: z.ZodString;
60
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
61
+ query: z.ZodType<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput, z.core.$ZodTypeInternals<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput>>;
62
+ }, z.core.$strip>>;
63
+ type: z.ZodLiteral<"DECLARE">;
64
+ declaration: z.ZodObject<{
65
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
66
+ pages: z.ZodArray<z.ZodObject<{
67
+ id: z.ZodString;
68
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
69
+ requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
70
+ showClearButton: z.ZodOptional<z.ZodBoolean>;
71
+ fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
72
+ conditional: z.ZodOptional<z.ZodAny>;
73
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
74
+ }, z.core.$strip>>;
75
+ }, z.core.$strip>;
76
+ review: z.ZodObject<{
77
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
78
+ fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
79
+ }, z.core.$strip>;
80
+ form: z.ZodOptional<z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>>;
81
+ dialogCopy: z.ZodOptional<z.ZodObject<{
82
+ notify: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
83
+ declare: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
84
+ register: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
85
+ }, z.core.$strip>>;
86
+ }, z.core.$strip>;
33
87
  declare const CustomActionConfig: z.ZodObject<{
34
88
  label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
35
89
  flags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -182,6 +236,18 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
182
236
  query: z.ZodType<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput, z.core.$ZodTypeInternals<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput>>;
183
237
  }, z.core.$strip>>;
184
238
  type: z.ZodLiteral<"DECLARE">;
239
+ declaration: z.ZodObject<{
240
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
241
+ pages: z.ZodArray<z.ZodObject<{
242
+ id: z.ZodString;
243
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
244
+ requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
245
+ showClearButton: z.ZodOptional<z.ZodBoolean>;
246
+ fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
247
+ conditional: z.ZodOptional<z.ZodAny>;
248
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
249
+ }, z.core.$strip>>;
250
+ }, z.core.$strip>;
185
251
  review: z.ZodObject<{
186
252
  title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
187
253
  fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
@@ -606,6 +672,7 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
606
672
  auditHistoryLabel: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
607
673
  }, z.core.$strip>], "type">;
608
674
  export type ActionConfig = z.infer<typeof ActionConfig>;
675
+ export type DeclareActionConfig = z.infer<typeof DeclareConfig>;
609
676
  export declare const actionConfigTypes: Set<ActionConfigTypes>;
610
677
  /**
611
678
  * Action types that come specifically from the country configuration.
@@ -647,6 +714,18 @@ export declare const DeclarationActionConfig: z.ZodDiscriminatedUnion<[z.ZodObje
647
714
  query: z.ZodType<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput, z.core.$ZodTypeInternals<import("./DeduplicationConfig").ClauseOutput, import("./DeduplicationConfig").ClauseInput>>;
648
715
  }, z.core.$strip>>;
649
716
  type: z.ZodLiteral<"DECLARE">;
717
+ declaration: z.ZodObject<{
718
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
719
+ pages: z.ZodArray<z.ZodObject<{
720
+ id: z.ZodString;
721
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
722
+ requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
723
+ showClearButton: z.ZodOptional<z.ZodBoolean>;
724
+ fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
725
+ conditional: z.ZodOptional<z.ZodAny>;
726
+ type: z.ZodDefault<z.ZodLiteral<"FORM">>;
727
+ }, z.core.$strip>>;
728
+ }, z.core.$strip>;
650
729
  review: z.ZodObject<{
651
730
  title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
652
731
  fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
@@ -3,11 +3,12 @@ import { ActionConfig } from './ActionConfig';
3
3
  import { SummaryConfig } from './SummaryConfig';
4
4
  import { TranslationConfig } from './TranslationConfig';
5
5
  import { AdvancedSearchConfig } from './AdvancedSearchConfig';
6
- import { DeclarationFormConfig, DeclarationFormConfigInput } from './FormConfig';
6
+ import { DeclarationFormConfigInput } from './FormConfig';
7
7
  import { FieldReference } from './FieldConfig';
8
8
  import { FlagConfig } from './Flag';
9
9
  import type { JSONSchema } from '../conditionals/conditionals';
10
10
  import { AvailableIcons } from '../icons';
11
+ import { ActionType } from './ActionType';
11
12
  export declare const EventFieldReference: z.ZodObject<{
12
13
  $$event: z.ZodEnum<{
13
14
  createdAt: "createdAt";
@@ -30,20 +31,39 @@ export type EventConfig = {
30
31
  label: TranslationConfig;
31
32
  actions: ActionConfig[];
32
33
  actionOrder?: string[];
33
- declaration: DeclarationFormConfig;
34
34
  advancedSearch: AdvancedSearchConfig[];
35
35
  flags: FlagConfig[];
36
36
  analytics: boolean;
37
37
  icon?: Partial<Record<AvailableIcons, JSONSchema>>;
38
38
  };
39
- export type EventConfigInput = Omit<EventConfig, 'advancedSearch' | 'flags' | 'declaration' | 'actions' | 'dateOfEvent' | 'placeOfEvent' | 'analytics'> & {
39
+ type ActionConfigInput = z.input<typeof ActionConfig>;
40
+ type DeclareActionConfigInput = Extract<ActionConfigInput, {
41
+ type: typeof ActionType.DECLARE;
42
+ }>;
43
+ /**
44
+ * Input accepted by `EventConfig.parse`. `declaration` lives only on the DECLARE action.
45
+ */
46
+ type EventConfigSchemaInput = Omit<EventConfig, 'advancedSearch' | 'flags' | 'actions' | 'dateOfEvent' | 'placeOfEvent' | 'analytics'> & {
40
47
  dateOfEvent?: z.input<typeof FieldReference> | z.infer<typeof EventFieldReference>;
41
48
  placeOfEvent?: z.input<typeof FieldReference>;
42
49
  advancedSearch?: AdvancedSearchConfig[];
43
50
  flags?: FlagConfig[];
44
- declaration: DeclarationFormConfigInput;
45
- actions: z.input<typeof ActionConfig>[];
51
+ actions: ActionConfigInput[];
46
52
  analytics?: boolean;
47
53
  };
48
- export declare const EventConfig: z.ZodType<EventConfig, EventConfigInput>;
54
+ /**
55
+ * Input accepted by `defineConfig`.
56
+ * `declaration` may be given at the top level (kept for backwards compatibility)
57
+ * or on the DECLARE action.
58
+ * `defineConfig` checks at runtime that it is given in exactly one of these places.
59
+ */
60
+ export type EventConfigInput = Omit<EventConfigSchemaInput, 'actions'> & {
61
+ /** @deprecated Define `declaration` on the DECLARE action instead. */
62
+ declaration?: DeclarationFormConfigInput;
63
+ actions: Array<Exclude<ActionConfigInput, DeclareActionConfigInput> | (Omit<DeclareActionConfigInput, 'declaration'> & {
64
+ declaration?: DeclarationFormConfigInput;
65
+ })>;
66
+ };
67
+ export declare const EventConfig: z.ZodType<EventConfig, EventConfigSchemaInput>;
68
+ export {};
49
69
  //# sourceMappingURL=EventConfig.d.ts.map
@@ -1,8 +1,24 @@
1
1
  import * as z from 'zod/v4';
2
- import { EventConfig } from './EventConfig';
2
+ import { EventConfig, EventConfigInput } from './EventConfig';
3
3
  export declare function validateAdvancedSearchConfig(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
4
4
  export declare function validateDateOfEvent(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
5
5
  export declare function validatePlaceOfEvent(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
6
6
  export declare function validateActionFlags(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
7
7
  export declare function validateActionOrder(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
8
+ /**
9
+ * Runs on both the `defineConfig` input and the parsed `EventConfig`.
10
+ *
11
+ * @returns whether the event has exactly one DECLARE action.
12
+ */
13
+ export declare function validateExactlyOneDeclareAction<T extends {
14
+ id: string;
15
+ actions: Array<{
16
+ type: string;
17
+ }>;
18
+ }>(event: T, ctx: z.RefinementCtx<T>): boolean;
19
+ /**
20
+ * `declaration` must be given exactly once: at the top level (kept for backwards
21
+ * compatibility) or on the DECLARE action.
22
+ */
23
+ export declare function validateDeclarationGivenExactlyOnce(config: EventConfigInput, ctx: z.RefinementCtx<EventConfigInput>): void;
8
24
  //# sourceMappingURL=eventConfigValidation.d.ts.map
@@ -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';
@@ -328,6 +329,10 @@ export declare const generateEventConfig: ({ id, fields, placeOfEventId, dateOfE
328
329
  /** Extra actions appended to the default READ + DECLARE pair, e.g. a REQUEST_CORRECTION action with its own correctionForm. */
329
330
  actions?: EventConfigInput['actions'];
330
331
  }) => EventConfig;
332
+ /**
333
+ * @returns a copy of the configuration with the DECLARE action's declaration replaced.
334
+ */
335
+ export declare function withDeclaration(configuration: EventConfig, declaration: DeclarationFormConfig): EventConfig;
331
336
  /**
332
337
  * Get the leaf administrative area IDs from a list of administrative areas.
333
338
  *
@@ -12,20 +12,6 @@ import { 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,20 @@ 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
49
  export declare function isActionConfigType(type: ActionType): type is ActionConfigTypes;
50
50
  export declare function getActionConfig({ eventConfiguration, actionType, customActionType }: {
51
51
  eventConfiguration: EventConfig;
@@ -112,11 +112,29 @@ 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';
121
139
  }];
122
140
  //# 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;a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AU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;EAEd,CAAA"}
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,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,kCAAkC;aACxC,UAAU,EAAE,kCAAkC;aAC9C,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,WAAW;aACjB,UAAU,EAAE,WAAW;aACvB,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,kCAAkC;aACxC,UAAU,EAAE,kCAAkC;aAC9C,SAAS,EAAE,QAAQ;aACnB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,wBAAwB;aAC9B,UAAU,EAAE,wBAAwB;aACpC,SAAS,EAAE,QAAQ;aACnB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,iBAAiB;aACvB,UAAU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AChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,0BAA0B;aAChC,UAAU,EAAE,0BAA0B;aACtC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,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;EAEd,CAAA"}
@@ -145,11 +145,32 @@ 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'
154
- }
168
+ },
169
+ {
170
+ name: 'TWO_FA_ENABLED',
171
+ valueLabel: 'TWO_FA_ENABLED',
172
+ valueType: 'VARIABLE',
173
+ type: 'disabled',
174
+ scope: 'ENVIRONMENT'
175
+ },
155
176
  ];
@@ -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":"AAwSA,wBAAsB,mBAAmB,kBA+nCxC"}
@@ -239,16 +239,6 @@ function runSetupEnvironment() {
239
239
  ]
240
240
  });
241
241
  }
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
242
  const environment_exists = existingEnvironments
253
243
  .map((e) => e.trim())
254
244
  .includes(environment);
@@ -277,6 +267,18 @@ function runSetupEnvironment() {
277
267
  .bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
278
268
  yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
279
269
  }
270
+ (0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
271
+ const existingTwoFaEnabled = (0, utils_1.findExistingValue)('TWO_FA_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
272
+ const twoFaDefault = process.env.TWO_FA_ENABLED || (existingTwoFaEnabled === null || existingTwoFaEnabled === void 0 ? void 0 : existingTwoFaEnabled.value);
273
+ const two_fa_enabled = yield confirm({
274
+ message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
275
+ default: twoFaDefault
276
+ ? twoFaDefault === 'true'
277
+ : environment_type === 'production'
278
+ });
279
+ if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
280
+ (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.');
281
+ }
280
282
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
281
283
  yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
282
284
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
@@ -396,6 +398,7 @@ function runSetupEnvironment() {
396
398
  });
397
399
  restoreType = yield select({
398
400
  message: `Select ${kleur_1.default.yellow().bold(restoreEnvironmentName)} environment backup mode`,
401
+ default: restoreType,
399
402
  choices: [
400
403
  {
401
404
  name: 'Full dump (daily full database backup)',
@@ -467,6 +470,14 @@ function runSetupEnvironment() {
467
470
  value: findExistingOrDefine('NOTIFICATION_TRANSPORT', 'VARIABLE', 'ENVIRONMENT', 'email'),
468
471
  scope: 'ENVIRONMENT'
469
472
  });
473
+ derivedUpdates.push({
474
+ name: 'TWO_FA_ENABLED',
475
+ type: 'VARIABLE',
476
+ didExist: existingTwoFaEnabled,
477
+ // Always stored, so the next run defaults to the current answer
478
+ value: two_fa_enabled ? 'true' : 'false',
479
+ scope: 'ENVIRONMENT'
480
+ });
470
481
  derivedUpdates.push(...ssl_answers);
471
482
  if (configureBackup) {
472
483
  derivedUpdates.push({
@@ -582,6 +593,14 @@ function runSetupEnvironment() {
582
593
  value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
583
594
  didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
584
595
  scope: 'ENVIRONMENT'
596
+ },
597
+ {
598
+ type: 'VARIABLE',
599
+ name: 'RESTORE_ENVIRONMENT_MODE',
600
+ // Only persist the mode when restore is configured
601
+ value: restoreEnvironmentName ? restoreType : '',
602
+ didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues),
603
+ scope: 'ENVIRONMENT'
585
604
  }
586
605
  ];
587
606
  if (enableEncryption) {