@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
@@ -1,15 +1,27 @@
1
1
  declare const notEmpty: (value: string | number) => "Please enter a value" | true;
2
2
  declare function validateCIDRs(input: string): true | string;
3
- export declare const dockerhubQuestions: {
3
+ declare function validateRegistryHost(input: string): true | string;
4
+ export declare const registryQuestions: ({
5
+ name: string;
6
+ type: 'text';
7
+ message: string;
8
+ valueType: 'VARIABLE';
9
+ valueLabel: string;
10
+ validate: typeof validateRegistryHost;
11
+ initial: string;
12
+ scope: 'REPOSITORY';
13
+ legacyValueLabel?: undefined;
14
+ } | {
4
15
  name: string;
5
16
  type: 'text';
6
17
  message: string;
7
18
  valueType: 'SECRET';
8
19
  valueLabel: string;
20
+ legacyValueLabel: string;
9
21
  validate: typeof notEmpty;
10
22
  initial: string | undefined;
11
23
  scope: 'REPOSITORY';
12
- }[];
24
+ })[];
13
25
  export declare const githubQuestions: {
14
26
  name: string;
15
27
  type: 'text';
@@ -18,7 +30,21 @@ export declare const githubQuestions: {
18
30
  initial: string;
19
31
  scope: 'REPOSITORY';
20
32
  }[];
21
- export declare const githubOtherQuestions: ({
33
+ export declare const githubApprovalRequiredQuestion: {
34
+ name: string;
35
+ type: 'select';
36
+ message: string;
37
+ choices: {
38
+ title: string;
39
+ value: string;
40
+ }[];
41
+ valueType: 'VARIABLE';
42
+ validate: typeof notEmpty;
43
+ valueLabel: string;
44
+ initial: string | undefined;
45
+ scope: 'ENVIRONMENT';
46
+ };
47
+ export declare const githubApproversQuestion: {
22
48
  name: string;
23
49
  type: 'text';
24
50
  message: string;
@@ -26,9 +52,8 @@ export declare const githubOtherQuestions: ({
26
52
  valueType: 'VARIABLE';
27
53
  valueLabel: string;
28
54
  scope: 'REPOSITORY';
29
- choices?: undefined;
30
- validate?: undefined;
31
- } | {
55
+ };
56
+ export declare const githubOtherQuestions: ({
32
57
  name: string;
33
58
  type: 'select';
34
59
  message: string;
@@ -41,6 +66,14 @@ export declare const githubOtherQuestions: ({
41
66
  valueLabel: string;
42
67
  initial: string | undefined;
43
68
  scope: 'ENVIRONMENT';
69
+ } | {
70
+ name: string;
71
+ type: 'text';
72
+ message: string;
73
+ initial: string | undefined;
74
+ valueType: 'VARIABLE';
75
+ valueLabel: string;
76
+ scope: 'REPOSITORY';
44
77
  })[];
45
78
  export declare const githubTokenQuestion: {
46
79
  name: string;
@@ -71,7 +104,6 @@ export declare const infrastructureQuestions: ({
71
104
  initial: string | undefined;
72
105
  scope: 'ENVIRONMENT';
73
106
  } | {
74
- validate?: undefined;
75
107
  name: string;
76
108
  type: 'text';
77
109
  message: string;
@@ -79,6 +111,7 @@ export declare const infrastructureQuestions: ({
79
111
  valueLabel: string;
80
112
  initial: string | undefined;
81
113
  scope: 'ENVIRONMENT';
114
+ validate?: undefined;
82
115
  } | {
83
116
  name: string;
84
117
  type: 'text';
@@ -100,7 +133,6 @@ export declare const staticSSLCertQuestions: {
100
133
  scope: 'ENVIRONMENT';
101
134
  }[];
102
135
  export declare const backupQuestions: ({
103
- choices?: undefined;
104
136
  validate?: undefined;
105
137
  name: string;
106
138
  type: 'text';
@@ -109,8 +141,8 @@ export declare const backupQuestions: ({
109
141
  valueLabel: string;
110
142
  initial: string;
111
143
  scope: 'ENVIRONMENT';
112
- } | {
113
144
  choices?: undefined;
145
+ } | {
114
146
  name: string;
115
147
  type: 'text';
116
148
  message: string;
@@ -119,6 +151,7 @@ export declare const backupQuestions: ({
119
151
  valueLabel: string;
120
152
  initial: string;
121
153
  scope: 'ENVIRONMENT';
154
+ choices?: undefined;
122
155
  } | {
123
156
  name: string;
124
157
  type: 'select';
@@ -1 +1 @@
1
- {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.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AU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;UAId,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;;UAsBd,MAAM;;eAED,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;;UAGzB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,eAAe;;;UAGlB,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;;UAId,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;;UAId,QAAQ;;;;;;eAYH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,aAAa;;UAGhB,MAAM;;eAID,UAAU;;;;WAId,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,8BAA8B;;UAGjC,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,cAAc;;;UAGjB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAkCd,QAAQ;;;;;;eAYH,QAAQ;;;;WAIZ,aAAa;IAuBvB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;eAEpB,QAAQ;;UAEb,MAAM;;;WAIL,aAAa;;GAYvB,CAAA"}
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.metabaseAdminQuestions = exports.sentryQuestions = exports.emailQuestions = exports.databaseAndMonitoringQuestions = exports.diskQuestions = exports.backupQuestions = exports.staticSSLCertQuestions = exports.infrastructureQuestions = exports.countryQuestions = exports.githubTokenQuestion = exports.githubOtherQuestions = exports.githubQuestions = exports.dockerhubQuestions = void 0;
16
+ exports.metabaseAdminQuestions = exports.sentryQuestions = exports.emailQuestions = exports.databaseAndMonitoringQuestions = exports.diskQuestions = exports.backupQuestions = exports.staticSSLCertQuestions = exports.infrastructureQuestions = exports.countryQuestions = exports.githubTokenQuestion = exports.githubOtherQuestions = exports.githubApproversQuestion = exports.githubApprovalRequiredQuestion = exports.githubQuestions = exports.registryQuestions = void 0;
17
17
  const kleur_1 = __importDefault(require("kleur"));
18
18
  const utils_1 = require("./utils");
19
19
  const git_1 = require("./git");
@@ -40,45 +40,66 @@ function validateCIDRs(input) {
40
40
  }
41
41
  return true;
42
42
  }
43
- exports.dockerhubQuestions = [
43
+ // A host with an optional port, without protocol or path (e.g. docker.io, ghcr.io, registry.example.org:5000)
44
+ function validateRegistryHost(input) {
45
+ return /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]+)?$/i.test(input)
46
+ ? true
47
+ : 'Please enter a registry host without protocol or path (e.g. docker.io, ghcr.io)';
48
+ }
49
+ // The DOCKER_* and DOCKERHUB_* secrets are the previous names of the REGISTRY_* secrets
50
+ exports.registryQuestions = [
44
51
  {
45
- name: 'dockerhubOrganisation',
52
+ name: 'registryHost',
46
53
  type: 'text',
47
- message: 'What is the name of your Docker Hub organisation?',
54
+ message: 'What is the host of your container registry? (e.g. docker.io, ghcr.io)',
55
+ valueType: 'VARIABLE',
56
+ valueLabel: 'REGISTRY_HOST',
57
+ validate: validateRegistryHost,
58
+ initial: process.env.REGISTRY_HOST || 'docker.io',
59
+ scope: 'REPOSITORY'
60
+ },
61
+ {
62
+ name: 'registryOrganisation',
63
+ type: 'text',
64
+ message: 'What is the name of your organisation (or user) in the container registry?',
48
65
  valueType: 'SECRET',
49
- valueLabel: 'DOCKERHUB_ACCOUNT',
66
+ valueLabel: 'REGISTRY_ORGANISATION',
67
+ legacyValueLabel: 'DOCKERHUB_ACCOUNT',
50
68
  validate: notEmpty,
51
- initial: process.env.DOCKER_ORGANISATION,
69
+ initial: process.env.REGISTRY_ORGANISATION,
52
70
  scope: 'REPOSITORY'
53
71
  },
54
72
  {
55
- name: 'dockerhubRepository',
73
+ name: 'registryRepository',
56
74
  type: 'text',
57
- message: 'What is the name of your private Docker Hub repository?',
75
+ message: 'What is the name of your private container repository?',
58
76
  valueType: 'SECRET',
59
- valueLabel: 'DOCKERHUB_REPO',
77
+ valueLabel: 'REGISTRY_REPOSITORY',
78
+ legacyValueLabel: 'DOCKERHUB_REPO',
60
79
  validate: notEmpty,
61
- initial: process.env.DOCKER_REPO,
80
+ initial: process.env.REGISTRY_REPOSITORY,
62
81
  scope: 'REPOSITORY'
63
82
  },
64
83
  {
65
- name: 'dockerhubUsername',
84
+ name: 'registryUsername',
66
85
  type: 'text',
67
- message: 'What is the Docker Hub username the the target server should be using?',
86
+ message: 'What is the container registry username the target server should be using?',
68
87
  valueType: 'SECRET',
69
- valueLabel: 'DOCKER_USERNAME',
88
+ valueLabel: 'REGISTRY_USERNAME',
89
+ legacyValueLabel: 'DOCKER_USERNAME',
70
90
  validate: notEmpty,
71
- initial: process.env.DOCKER_USERNAME,
91
+ initial: process.env.REGISTRY_USERNAME,
72
92
  scope: 'REPOSITORY'
73
93
  },
74
94
  {
75
- name: 'dockerhubToken',
95
+ name: 'registryToken',
76
96
  type: 'text',
77
- message: 'What is the token of this Docker Hub account?',
97
+ message: 'What is the token of this container registry account?',
78
98
  valueType: 'SECRET',
79
- valueLabel: 'DOCKER_TOKEN',
99
+ valueLabel: 'REGISTRY_TOKEN',
100
+ legacyValueLabel: 'DOCKER_TOKEN',
80
101
  validate: notEmpty,
81
- initial: process.env.DOCKER_TOKEN,
102
+ initial: process.env.REGISTRY_TOKEN,
82
103
  scope: 'REPOSITORY'
83
104
  }
84
105
  ];
@@ -100,36 +121,38 @@ exports.githubQuestions = [
100
121
  scope: 'REPOSITORY'
101
122
  }
102
123
  ];
124
+ exports.githubApprovalRequiredQuestion = {
125
+ name: 'approvalRequired',
126
+ type: 'select',
127
+ message: 'Would you like to enable approvals process for GitHub action workflows?',
128
+ choices: [
129
+ {
130
+ title: 'True',
131
+ value: 'true'
132
+ },
133
+ {
134
+ title: 'False',
135
+ value: 'false'
136
+ }
137
+ ],
138
+ valueType: 'VARIABLE',
139
+ validate: notEmpty,
140
+ valueLabel: 'APPROVAL_REQUIRED',
141
+ initial: process.env.APPROVAL_REQUIRED,
142
+ scope: 'ENVIRONMENT'
143
+ };
144
+ exports.githubApproversQuestion = {
145
+ name: 'githubApprovers',
146
+ type: 'text',
147
+ message: 'Please provide/update list of approvers?',
148
+ initial: process.env.GH_APPROVERS,
149
+ valueType: 'VARIABLE',
150
+ valueLabel: 'GH_APPROVERS',
151
+ scope: 'REPOSITORY'
152
+ };
103
153
  exports.githubOtherQuestions = [
104
- {
105
- name: 'githubApprovers',
106
- type: 'text',
107
- message: 'Please provide/update list of production approvers?',
108
- initial: process.env.GH_APPROVERS,
109
- valueType: 'VARIABLE',
110
- valueLabel: 'GH_APPROVERS',
111
- scope: 'REPOSITORY'
112
- },
113
- {
114
- name: 'approvalRequired',
115
- type: 'select',
116
- message: 'Would you like to enable approvals process for GitHub action workflows?',
117
- choices: [
118
- {
119
- title: 'True',
120
- value: 'true'
121
- },
122
- {
123
- title: 'False',
124
- value: 'false'
125
- }
126
- ],
127
- valueType: 'VARIABLE',
128
- validate: notEmpty,
129
- valueLabel: 'APPROVAL_REQUIRED',
130
- initial: process.env.APPROVAL_REQUIRED,
131
- scope: 'ENVIRONMENT'
132
- }
154
+ exports.githubApprovalRequiredQuestion,
155
+ exports.githubApproversQuestion
133
156
  ];
134
157
  exports.githubTokenQuestion = [
135
158
  {
@@ -201,7 +224,7 @@ exports.infrastructureQuestions = [
201
224
  valueLabel: 'KUBE_API_ALLOWED_CIDRS',
202
225
  initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
203
226
  scope: 'ENVIRONMENT'
204
- },
227
+ }
205
228
  ];
206
229
  exports.staticSSLCertQuestions = [
207
230
  {
@@ -0,0 +1,15 @@
1
+ type RegistryValidationResult = {
2
+ status: 'valid' | 'skipped' | 'invalid-credentials' | 'repository-not-found' | 'unreachable';
3
+ reason?: string;
4
+ };
5
+ /**
6
+ * Checks, using the OCI Distribution (Docker Registry HTTP API v2) that every
7
+ * registry implements, that the username/token pair is accepted by the registry
8
+ * and that the organisation/repository is visible to that account.
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 validateRegistryCredentials(registry: string | undefined, organisation: string | undefined, repository: string | undefined, username: string | undefined, token: string | undefined): Promise<RegistryValidationResult>;
14
+ export {};
15
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/environment/registry.ts"],"names":[],"mappings":"AAaA,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EACF,OAAO,GAEP,SAAS,GACT,qBAAqB,GACrB,sBAAsB,GAEtB,aAAa,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAyCD;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,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,wBAAwB,CAAC,CA0DnC"}
@@ -0,0 +1,112 @@
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.validateRegistryCredentials = validateRegistryCredentials;
23
+ const REQUEST_TIMEOUT_MS = 10000;
24
+ // Docker Hub serves its registry API from registry-1.docker.io, docker.io is the website
25
+ function registryApiHost(registry) {
26
+ const host = registry.trim().toLowerCase();
27
+ return host === 'docker.io' || host === 'index.docker.io'
28
+ ? 'registry-1.docker.io'
29
+ : host;
30
+ }
31
+ function request(url, authorization) {
32
+ return fetch(url, {
33
+ headers: authorization ? { Authorization: authorization } : {},
34
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
35
+ });
36
+ }
37
+ function failure(registry, step, response) {
38
+ const reason = `${registry} ${step} responded with HTTP ${response.status}`;
39
+ switch (response.status) {
40
+ case 401:
41
+ case 403:
42
+ return {
43
+ status: 'invalid-credentials',
44
+ reason: `${reason}. Check REGISTRY_USERNAME, REGISTRY_TOKEN, REGISTRY_ORGANISATION and REGISTRY_REPOSITORY`
45
+ };
46
+ case 404:
47
+ // The API cannot tell an empty repository from one that does not exist
48
+ return {
49
+ status: 'repository-not-found',
50
+ reason: `${reason}. This is also the answer for an empty repository. Check REGISTRY_ORGANISATION and REGISTRY_REPOSITORY`
51
+ };
52
+ default:
53
+ return { status: 'unreachable', reason };
54
+ }
55
+ }
56
+ /**
57
+ * Checks, using the OCI Distribution (Docker Registry HTTP API v2) that every
58
+ * registry implements, that the username/token pair is accepted by the registry
59
+ * and that the organisation/repository is visible to that account.
60
+ *
61
+ * Existing GitHub secrets cannot be read back, so when any value is missing
62
+ * (kept from an existing secret) the check is skipped.
63
+ */
64
+ function validateRegistryCredentials(registry, organisation, repository, username, token) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ var _a, _b;
67
+ var _c, _d;
68
+ if (!registry || !organisation || !repository || !username || !token) {
69
+ return {
70
+ status: 'skipped',
71
+ reason: 'Some values are kept from existing GitHub secrets, which cannot be read back'
72
+ };
73
+ }
74
+ const host = registryApiHost(registry);
75
+ const name = `${organisation}/${repository}`;
76
+ const basic = `Basic ${Buffer.from(`${username}:${token}`).toString('base64')}`;
77
+ try {
78
+ // A registry that wants a token names its token service in the challenge.
79
+ // For any other answer the credentials are sent as they are.
80
+ const challenge = (_c = (yield request(`https://${host}/v2/`, undefined)).headers.get('www-authenticate')) !== null && _c !== void 0 ? _c : '';
81
+ const realm = (_a = challenge.match(/realm="([^"]*)"/i)) === null || _a === void 0 ? void 0 : _a[1];
82
+ const service = (_b = challenge.match(/service="([^"]*)"/i)) === null || _b === void 0 ? void 0 : _b[1];
83
+ let authorization = basic;
84
+ if (/^\s*bearer/i.test(challenge) && realm) {
85
+ const tokenUrl = new URL(realm);
86
+ if (service) {
87
+ tokenUrl.searchParams.set('service', service);
88
+ }
89
+ tokenUrl.searchParams.set('scope', `repository:${name}:pull`);
90
+ const login = yield request(tokenUrl, basic);
91
+ if (!login.ok) {
92
+ return failure(registry, 'login', login);
93
+ }
94
+ const body = (yield login.json());
95
+ authorization = `Bearer ${(_d = body.token) !== null && _d !== void 0 ? _d : body.access_token}`;
96
+ }
97
+ const path = name.split('/').map(encodeURIComponent).join('/');
98
+ const response = yield request(`https://${host}/v2/${path}/tags/list?n=1`, authorization);
99
+ return response.ok
100
+ ? { status: 'valid' }
101
+ : failure(registry, `lookup of repository ${name}`, response);
102
+ }
103
+ catch (err) {
104
+ if (!(err instanceof Error)) {
105
+ return { status: 'unreachable', reason: String(err) };
106
+ }
107
+ // fetch only reports "fetch failed", the real error (e.g. ENOTFOUND) is its cause
108
+ const cause = err.cause instanceof Error ? `: ${err.cause.message}` : '';
109
+ return { status: 'unreachable', reason: `${err.message}${cause}` };
110
+ }
111
+ });
112
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AAwSA,wBAAsB,mBAAmB,kBAgnCxC"}
1
+ {"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AA8aA,wBAAsB,mBAAmB,kBAosCxC"}