@skillswaveca/nova-shared-libraries 3.14.0 → 3.15.1

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.
@@ -1,31 +1,31 @@
1
1
  export const packageInfo = [
2
2
  {
3
3
  "name": "@skillswaveca/nova-utils",
4
- "version": "3.13.0",
4
+ "version": "3.15.0",
5
5
  "description": "A collection of random utils used in nova repos",
6
6
  "docsPath": "./nova-utils/index.html"
7
7
  },
8
8
  {
9
9
  "name": "nova-router",
10
- "version": "3.13.0",
10
+ "version": "3.15.0",
11
11
  "description": "An extended Koa router that enables better validation",
12
12
  "docsPath": "./nova-router/index.html"
13
13
  },
14
14
  {
15
15
  "name": "@skillswaveca/nova-model",
16
- "version": "3.13.0",
16
+ "version": "3.15.0",
17
17
  "description": "Nova model stuff",
18
18
  "docsPath": "./nova-model/index.html"
19
19
  },
20
20
  {
21
21
  "name": "@skillswaveca/nova-middleware",
22
- "version": "3.13.0",
22
+ "version": "3.15.0",
23
23
  "description": "A collection of middleware used by nova projects",
24
24
  "docsPath": "./nova-middleware/index.html"
25
25
  },
26
26
  {
27
27
  "name": "@skillswaveca/nova-drivers",
28
- "version": "3.13.0",
28
+ "version": "3.15.0",
29
29
  "description": "Some helper drivers for AWS services",
30
30
  "docsPath": "./drivers/index.html"
31
31
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-shared-libraries",
4
4
  "description": "A monorepo of shared libraries for Nova projects.",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.14.0",
6
+ "version": "3.15.1",
7
7
  "main": "index.js",
8
8
  "license": "MIT",
9
9
  "keywords": [],
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-drivers",
4
4
  "description": "Some helper drivers for AWS services",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.14.0",
6
+ "version": "3.15.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -147,4 +147,33 @@ export class OAuthDriver extends HttpDriver {
147
147
  this.clientCredentialsInstance = new ClientCredentials(this.clientConfig);
148
148
  return this.clientCredentialsInstance;
149
149
  }
150
+
151
+ /**
152
+ * Retrieves the health of the service protected by OAuth.
153
+ *
154
+ * @returns {Promise<{message, status: string}|*|{message: string, status: string}>}
155
+ */
156
+ async health() {
157
+ try {
158
+ const response = await super.get('/api/v2/health');
159
+ const { success, body, error, statusCode } = response;
160
+
161
+ this.log.trace({ baseUrl: this.baseUrl, success, error, statusCode, body } , 'Checking the health of the service');
162
+
163
+ if (success) return body;
164
+
165
+ if (statusCode === 404) {
166
+ this.log.warn({ baseUrl: this.baseUrl, statusCode }, 'Health check endpoint not found');
167
+ return { status: 'unknown', message: 'No health check endpoint found' };
168
+ }
169
+
170
+ this.log.error({ baseUrl: this.baseUrl, error, statusCode }, 'Service health check failed');
171
+
172
+ return { status: 'error', message: error || 'An unknown error occurred during health check' };
173
+ } catch (err) {
174
+ this.log.error({ baseUrl: this.baseUrl, error: err }, 'Unexpected error during health check');
175
+ return { status: 'error', message: 'Unexpected error occurred while checking service health' };
176
+ }
177
+ }
178
+
150
179
  }
@@ -99,7 +99,7 @@ export class WaveDriver extends OAuthDriver {
99
99
  return body;
100
100
  } else {
101
101
  this.log.error({ 'response': { success, error } }, 'Failed to retrieve tenant SSO from wave');
102
- throw new Error(`Failed to retrieve tenant from Wave: ${error}`);
102
+ throw new Error(`Failed to retrieve tenant SSO from Wave: ${error}`);
103
103
  }
104
104
  }
105
105
 
@@ -108,19 +108,19 @@ export class WaveDriver extends OAuthDriver {
108
108
  *
109
109
  * @returns {*}
110
110
  */
111
- getAllTenants() {
111
+ async getAllTenants() {
112
112
  const url = '/api/v2/tenants';
113
113
  this.log.debug({ url }, 'Getting all tenants from Wave');
114
- const response = this.get(url, {});
114
+ const response = await this.get(url, {});
115
115
 
116
- const { success, body, error } = response;
116
+ const { success, body, error, statusCode } = response;
117
117
 
118
118
  if (response.success) {
119
119
  this.log.info({ 'response': { success, body } }, 'Tenants retrieved from wave');
120
120
  return body;
121
121
  } else {
122
- this.log.error({ 'response': { success, error } }, 'Failed to retrieve tenants from wave');
123
- throw new Error(`Failed to retrieve tenants from Wave: ${error}`);
122
+ this.log.error({ 'response': { success, error, statusCode } }, 'Failed to retrieve tenants from wave');
123
+ throw new Error(`Failed to retrieve tenants from Wave: ${error}, statusCode: ${statusCode}`);
124
124
  }
125
125
  }
126
126
 
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-middleware",
4
4
  "description": "A collection of middleware used by nova projects",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.14.0",
6
+ "version": "3.15.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-model",
4
4
  "description": "Nova model stuff",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.14.0",
6
+ "version": "3.15.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -3,7 +3,7 @@
3
3
  "name": "nova-router",
4
4
  "description": "An extended Koa router that enables better validation",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.14.0",
6
+ "version": "3.15.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-utils",
4
4
  "description": "A collection of random utils used in nova repos",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.14.0",
6
+ "version": "3.15.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -125,7 +125,7 @@ export const getOauthDriverConfig = driverName => {
125
125
  return disabledConfig;
126
126
  }
127
127
  // Check for essential configuration components
128
- const requiredFields = ['enabled', 'baseUrl', 'audience', 'clientId', 'clientSecretName', 'tokenHost', 'tokenPath'];
128
+ const requiredFields = ['enabled', 'audience', 'clientId', 'clientSecretName', 'tokenHost', 'tokenPath'];
129
129
  const missingFields = requiredFields.filter(field => typeof driverConfig[field] === 'undefined' && typeof authConfig[field] === 'undefined');
130
130
 
131
131
  if (missingFields.length > 0) {