@skillswaveca/nova-shared-libraries 4.20.0 → 4.22.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.
package/README.md CHANGED
@@ -47,7 +47,7 @@ pnpm run test
47
47
  ```
48
48
 
49
49
  ## Developing locally
50
- If you want to change this package simultaenously with a related Nova repo, you can do that using `npm link` ([docs](https://docs.npmjs.com/cli/v10/commands/npm-link)).
50
+ If you want to change this package simultaneously with a related Nova repo, you can do that using `npm link` ([docs](https://docs.npmjs.com/cli/v10/commands/npm-link)).
51
51
 
52
52
  The basic steps are:
53
53
  1. At the root of this repo, run `npm link`
@@ -1,31 +1,31 @@
1
1
  export const packageInfo = [
2
2
  {
3
3
  "name": "@skillswaveca/nova-utils",
4
- "version": "4.19.1",
4
+ "version": "4.21.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.19.1",
10
+ "version": "4.21.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.19.1",
16
+ "version": "4.21.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.19.1",
22
+ "version": "4.21.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.19.1",
28
+ "version": "4.21.0",
29
29
  "description": "Some helper drivers for AWS services",
30
30
  "docsPath": "./drivers/index.html"
31
31
  }
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './packages/nova-utils/src/tenant-utils.js';
2
2
  export * from './packages/nova-utils/src/logger.js';
3
+ export * from './packages/nova-utils/src/general.js';
3
4
  export * from './packages/nova-utils/src/config.js';
4
5
  export * from './packages/nova-router/src/nova-router.js';
5
6
  export * from './packages/nova-middleware/src/oauth-middleware.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.20.0",
6
+ "version": "4.22.0",
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": "4.20.0",
6
+ "version": "4.22.0",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -1,5 +1,6 @@
1
1
  import { usersBelongToSameTenant } from '../../nova-utils/index.js';
2
2
  import { OAuthDriver } from './oauth.js';
3
+ import {createUrlWithParams} from "../../nova-utils/src/general.js";
3
4
 
4
5
  /**
5
6
  * WaveDriver class to simplify making HTTP requests to a Wave API.
@@ -124,6 +125,40 @@ export class WaveDriver extends OAuthDriver {
124
125
  }
125
126
  }
126
127
 
128
+ async fetchTasks(filters = {}) {
129
+ const url = createUrlWithParams('/api/v2/tasks/find', filters);
130
+ const response = await this.get(url);
131
+ const { success, body, error, statusCode } = response;
132
+ if (response.success) {
133
+ this.log.info({ 'response': { success, body } }, 'Tasks retrieved from wave');
134
+ return body;
135
+ } else {
136
+ this.log.error({ response: { success, error, statusCode} }, 'Failed to retrieve tasks from wave');
137
+ throw new Error(`Failed to retrieve tasks from Wave: ${error}`);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Standardizes the SSO configuration for a tenant in the Wave platform.
143
+ *
144
+ * @param tenantId
145
+ * @param params
146
+ * @returns {Promise<void>}
147
+ */
148
+ async standardizeSSOConfig(tenantId, params) {
149
+ const url = `/api/v2/tenants/${tenantId}/standardize-sso`;
150
+ const response = await this.put(url, params);
151
+
152
+ const { success, body, error, statusCode } = response;
153
+ if (response.success) {
154
+ this.log.info({ response: { success, body, tenantId, params } }, 'Tenant SSO configuration standardized in wave');
155
+ return body;
156
+ } else {
157
+ this.log.error({ response: { success, error, statusCode } }, 'Failed to standardize tenant SSO configuration in wave');
158
+ throw new Error(`Failed to standardize tenant SSO configuration in Wave: ${error}, statusCode: ${statusCode}`);
159
+ }
160
+ }
161
+
127
162
  _deleteUser(guid) {
128
163
  const url = `/api/v2/users/${guid}`;
129
164
  this.log.debug({ guid, url }, 'Deleting user from Wave');
@@ -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.20.0",
6
+ "version": "4.22.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.20.0",
6
+ "version": "4.22.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.20.0",
6
+ "version": "4.22.0",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -1,3 +1,4 @@
1
1
  export * from './src/tenant-utils.js';
2
2
  export * from './src/logger.js';
3
+ export * from './src/general.js';
3
4
  export * from './src/config.js';
@@ -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.20.0",
6
+ "version": "4.22.0",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -234,7 +234,7 @@ export class NovaStageConfig {
234
234
  * any stage-specific overrides.
235
235
  */
236
236
  createConfigForStage(stage, region) {
237
- const baseConfig = this.baseConfig(stage);
237
+ const baseConfig = this.baseConfig(stage, region);
238
238
  const stageConfig = this.stages[stage] || this.stages.dev;
239
239
  const appEnvironment = stageConfig?.appEnvironment || baseConfig?.appEnvironment || stageConfig?.awsAccount || baseConfig?.awsAccount;
240
240
  const accountConfig = this.accounts ? this.accounts[appEnvironment] : {};
@@ -0,0 +1,10 @@
1
+ export const createUrlWithParams = (baseUrl, data) => {
2
+ const params = Object.keys(data).map(key => {
3
+ if (data[key] !== undefined && data[key] !== null) {
4
+ const value = typeof data[key] === 'object' ? JSON.stringify(data[key]) : data[key];
5
+ return [key, value].map(encodeURIComponent).join('=');
6
+ }
7
+ return null;
8
+ }).filter(Boolean).join('&').toString();
9
+ return params.length <= 0 ? baseUrl : `${baseUrl}?${params}`;
10
+ };