@skillswaveca/nova-shared-libraries 4.18.2 → 4.19.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.
- package/docs-base/package-info.js +5 -5
- package/index.js +1 -0
- package/package.json +1 -1
- package/packages/drivers/index.js +1 -0
- package/packages/drivers/package.json +1 -1
- package/packages/drivers/src/aws/aws-base-driver.js +2 -2
- package/packages/drivers/src/base-driver.js +27 -0
- package/packages/drivers/src/http.js +3 -1
- package/packages/drivers/src/nova-driver.js +12 -17
- package/packages/drivers/src/oauth.js +1 -5
- package/packages/nova-middleware/package.json +1 -1
- package/packages/nova-model/package.json +1 -1
- package/packages/nova-router/package.json +1 -1
- package/packages/nova-utils/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
export const packageInfo = [
|
|
2
2
|
{
|
|
3
3
|
"name": "@skillswaveca/nova-utils",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.19.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": "@skillswaveca/nova-router",
|
|
10
|
-
"version": "4.
|
|
10
|
+
"version": "4.19.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": "4.
|
|
16
|
+
"version": "4.19.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": "4.
|
|
22
|
+
"version": "4.19.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": "4.
|
|
28
|
+
"version": "4.19.0",
|
|
29
29
|
"description": "Some helper drivers for AWS services",
|
|
30
30
|
"docsPath": "./drivers/index.html"
|
|
31
31
|
}
|
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ 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';
|
|
13
14
|
export * from './packages/nova-model/src/stream/nova-stream-task-router.js';
|
|
14
15
|
export * from './packages/nova-model/src/repo/nova-model-repo.js';
|
|
15
16
|
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.
|
|
6
|
+
"version": "4.19.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"keywords": [],
|
|
@@ -4,6 +4,7 @@ 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';
|
|
7
8
|
export * from './src/aws/sqs.js';
|
|
8
9
|
export * from './src/aws/secrets-manager.js';
|
|
9
10
|
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.
|
|
6
|
+
"version": "4.19.1",
|
|
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 {
|
|
2
|
+
import { BaseDriver } from '../base-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 { NovaDriver } from '../nova-driver.js';
|
|
|
13
13
|
* }
|
|
14
14
|
* }
|
|
15
15
|
*/
|
|
16
|
-
export class AwsBaseDriver extends
|
|
16
|
+
export class AwsBaseDriver extends BaseDriver {
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Constructor for the AWS base driver.
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -106,7 +106,9 @@ export class HttpDriver extends NovaDriver {
|
|
|
106
106
|
|
|
107
107
|
if (success) {
|
|
108
108
|
this.log.trace({ url: url, method: options.method, status: response.status }, 'HTTP request successful');
|
|
109
|
-
|
|
109
|
+
if (response.status !== 204) {
|
|
110
|
+
body = await response.json();
|
|
111
|
+
}
|
|
110
112
|
} else {
|
|
111
113
|
this.log.error({ url: url, method: options.method, status: response.status }, 'HTTP request failed');
|
|
112
114
|
error = await response.text();
|
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseDriver } from './base-driver.js';
|
|
2
|
+
|
|
3
|
+
import { secretsManager } from './aws/secrets-manager.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* NovaDriver class to provide a common interface for all drivers.
|
|
5
7
|
|
|
6
8
|
*/
|
|
7
|
-
export class NovaDriver {
|
|
9
|
+
export class NovaDriver extends BaseDriver {
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* NovaDriver constructor.
|
|
11
13
|
* @param {Object} configOverrides - Configuration overrides for the Nova driver.
|
|
12
14
|
*/
|
|
13
15
|
constructor(configOverrides = {}) {
|
|
14
|
-
|
|
15
|
-
this.log = this.config.logger;
|
|
16
|
-
this.enabled = this.config.enabled;
|
|
17
|
-
this.novaRequestId = null;
|
|
16
|
+
super(configOverrides);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
useContext({ novaRequestId, log }) {
|
|
29
|
-
this.novaRequestId = novaRequestId;
|
|
30
|
-
this.log = log || this.log;
|
|
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;
|
|
31
26
|
}
|
|
32
27
|
}
|
|
@@ -4,8 +4,6 @@ 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
|
-
|
|
9
7
|
const TOKEN_EXPIRATION_WINDOW_SECONDS = 60;
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -55,8 +53,6 @@ export class OAuthDriver extends HttpDriver {
|
|
|
55
53
|
this.secretKey = oauth.client.secret;
|
|
56
54
|
this.secretKeyId = oauth.client.secretKeyId;
|
|
57
55
|
|
|
58
|
-
this.region = configuration.region;
|
|
59
|
-
this.rootEnvironmentAwsAccountId = configuration.rootEnvironmentAwsAccountId
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
/**
|
|
@@ -147,7 +143,7 @@ export class OAuthDriver extends HttpDriver {
|
|
|
147
143
|
if (this.clientCredentialsInstance) {
|
|
148
144
|
return this.clientCredentialsInstance;
|
|
149
145
|
}
|
|
150
|
-
if (this.secretKey) this.clientConfig.client.secret = await
|
|
146
|
+
if (this.secretKey) this.clientConfig.client.secret = await this.getSecret();
|
|
151
147
|
delete this.clientConfig.client.secretKeyId;
|
|
152
148
|
this.clientCredentialsInstance = new ClientCredentials(this.clientConfig);
|
|
153
149
|
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.
|
|
6
|
+
"version": "4.19.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": "4.
|
|
6
|
+
"version": "4.19.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-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.
|
|
6
|
+
"version": "4.19.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": "4.
|
|
6
|
+
"version": "4.19.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|