@skillswaveca/nova-shared-libraries 4.19.1 → 4.20.0

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": "4.19.0",
4
+ "version": "4.19.1",
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": "@skillswaveca/nova-router",
10
- "version": "4.19.0",
10
+ "version": "4.19.1",
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": "4.19.0",
16
+ "version": "4.19.1",
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": "4.19.0",
22
+ "version": "4.19.1",
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": "4.19.0",
28
+ "version": "4.19.1",
29
29
  "description": "Some helper drivers for AWS services",
30
30
  "docsPath": "./drivers/index.html"
31
31
  }
package/index.js CHANGED
@@ -10,7 +10,6 @@ export * from './packages/drivers/src/nova-driver.js';
10
10
  export * from './packages/drivers/src/kraken-driver.js';
11
11
  export * from './packages/drivers/src/http.js';
12
12
  export * from './packages/drivers/src/config.js';
13
- export * from './packages/drivers/src/base-driver.js';
14
13
  export * from './packages/nova-model/src/stream/nova-stream-task-router.js';
15
14
  export * from './packages/nova-model/src/repo/nova-model-repo.js';
16
15
  export * from './packages/nova-model/src/repo/api-token.js';
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": "4.19.1",
6
+ "version": "4.20.0",
7
7
  "main": "index.js",
8
8
  "license": "MIT",
9
9
  "keywords": [],
@@ -4,7 +4,6 @@ export * from './src/nova-driver.js';
4
4
  export * from './src/kraken-driver.js';
5
5
  export * from './src/http.js';
6
6
  export * from './src/config.js';
7
- export * from './src/base-driver.js';
8
7
  export * from './src/aws/sqs.js';
9
8
  export * from './src/aws/secrets-manager.js';
10
9
  export * from './src/aws/parameter-store.js';
@@ -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": "4.19.1",
6
+ "version": "4.20.0",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -1,5 +1,5 @@
1
1
  import xray from 'aws-xray-sdk-core';
2
- import { BaseDriver } from '../base-driver.js';
2
+ import { NovaDriver } from '../nova-driver.js';
3
3
 
4
4
  /**
5
5
  * Base driver for AWS services. You can extend this driver with any AWS service to set the client and automatically capture AWS X-Ray traces.
@@ -13,7 +13,7 @@ import { BaseDriver } from '../base-driver.js';
13
13
  * }
14
14
  * }
15
15
  */
16
- export class AwsBaseDriver extends BaseDriver {
16
+ export class AwsBaseDriver extends NovaDriver {
17
17
 
18
18
  /**
19
19
  * Constructor for the AWS base driver.
@@ -1,27 +1,32 @@
1
- import { BaseDriver } from './base-driver.js';
2
-
3
- import { secretsManager } from './aws/secrets-manager.js';
1
+ import { DEFAULT_CONFIG } from './config.js';
4
2
 
5
3
  /**
6
4
  * NovaDriver class to provide a common interface for all drivers.
7
5
 
8
6
  */
9
- export class NovaDriver extends BaseDriver {
7
+ export class NovaDriver {
10
8
 
11
9
  /**
12
10
  * NovaDriver constructor.
13
11
  * @param {Object} configOverrides - Configuration overrides for the Nova driver.
14
12
  */
15
13
  constructor(configOverrides = {}) {
16
- super(configOverrides);
14
+ this.config = { ...DEFAULT_CONFIG, ...configOverrides };
15
+ this.log = this.config.logger;
16
+ this.enabled = this.config.enabled;
17
+ this.novaRequestId = null;
17
18
  }
18
19
 
19
- async getSecret() {
20
- if (!this.secretKey) {
21
- return undefined;
22
- }
23
-
24
- const secret = await secretsManager.getSecret(this.secretKey, this.secretKeyId, this.region, this.rootEnvironmentAwsAccountId);
25
- return secret;
20
+ /**
21
+ * Provides a way to override the context of the driver. Specifically useful for logging
22
+ * and sending requests making use of the `distributedLoggingMiddleware` and it's reliance
23
+ * on the http header `x-nova-request-id`
24
+ *
25
+ * @param novaRequestId - The unique id of the request to send to external services
26
+ * @param log - The provided logger to use
27
+ */
28
+ useContext({ novaRequestId, log }) {
29
+ this.novaRequestId = novaRequestId;
30
+ this.log = log || this.log;
26
31
  }
27
32
  }
@@ -4,6 +4,8 @@ import { HttpDriver } from './http.js';
4
4
  import { ApiToken } from '../../nova-model/src/model/api-token.js';
5
5
  import { apiTokenRepo } from '../../nova-model/src/repo/api-token.js';
6
6
 
7
+ import { secretsManager } from './aws/secrets-manager.js';
8
+
7
9
  const TOKEN_EXPIRATION_WINDOW_SECONDS = 60;
8
10
 
9
11
  /**
@@ -53,6 +55,8 @@ export class OAuthDriver extends HttpDriver {
53
55
  this.secretKey = oauth.client.secret;
54
56
  this.secretKeyId = oauth.client.secretKeyId;
55
57
 
58
+ this.region = configuration.region;
59
+ this.rootEnvironmentAwsAccountId = configuration.rootEnvironmentAwsAccountId
56
60
  }
57
61
 
58
62
  /**
@@ -143,7 +147,7 @@ export class OAuthDriver extends HttpDriver {
143
147
  if (this.clientCredentialsInstance) {
144
148
  return this.clientCredentialsInstance;
145
149
  }
146
- if (this.secretKey) this.clientConfig.client.secret = await this.getSecret();
150
+ if (this.secretKey) this.clientConfig.client.secret = await secretsManager.getSecret(this.secretKey, this.secretKeyId, this.region, this.rootEnvironmentAwsAccountId);
147
151
  delete this.clientConfig.client.secretKeyId;
148
152
  this.clientCredentialsInstance = new ClientCredentials(this.clientConfig);
149
153
  return this.clientCredentialsInstance;
@@ -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": "4.19.1",
6
+ "version": "4.20.0",
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": "4.19.1",
6
+ "version": "4.20.0",
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-router",
4
4
  "description": "An extended Koa router that enables better validation",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "4.19.1",
6
+ "version": "4.20.0",
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": "4.19.1",
6
+ "version": "4.20.0",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -1,27 +0,0 @@
1
- import { DEFAULT_CONFIG } from './config.js';
2
-
3
- export class BaseDriver {
4
-
5
- constructor(configOverrides = {}) {
6
- this.config = { ...DEFAULT_CONFIG, ...configOverrides };
7
- this.log = this.config.logger;
8
- this.enabled = this.config.enabled;
9
- this.novaRequestId = null;
10
- this.region = this.config.aws.region;
11
- this.rootEnvironmentAwsAccountId = this.config.rootEnvironmentAwsAccountId;
12
- }
13
-
14
- /**
15
- * Provides a way to override the context of the driver. Specifically useful for logging
16
- * and sending requests making use of the `distributedLoggingMiddleware` and it's reliance
17
- * on the http header `x-nova-request-id`
18
- *
19
- * @param novaRequestId - The unique id of the request to send to external services
20
- * @param log - The provided logger to use
21
- */
22
- useContext({ novaRequestId, log }) {
23
- this.novaRequestId = novaRequestId;
24
- this.log = log || this.log;
25
- }
26
-
27
- }