@dishantlangayan/sc-cli-core 0.1.0 → 0.1.2
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/lib/config/env-vars.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare enum EnvironmentVariable {
|
|
2
2
|
'SC_ACCESS_TOKEN' = "SC_ACCESS_TOKEN",
|
|
3
3
|
'SC_API_VERSION' = "SC_API_VERSION",
|
|
4
|
-
'SC_BASE_URL' = "SC_BASE_URL"
|
|
4
|
+
'SC_BASE_URL' = "SC_BASE_URL",
|
|
5
|
+
'SEMP_API_VERSION' = "SEMP_API_VERSION"
|
|
5
6
|
}
|
|
6
7
|
export declare const DefaultBaseUrl = "https://api.solace.cloud";
|
|
7
8
|
/**
|
package/lib/config/env-vars.js
CHANGED
|
@@ -3,6 +3,7 @@ export var EnvironmentVariable;
|
|
|
3
3
|
EnvironmentVariable["SC_ACCESS_TOKEN"] = "SC_ACCESS_TOKEN";
|
|
4
4
|
EnvironmentVariable["SC_API_VERSION"] = "SC_API_VERSION";
|
|
5
5
|
EnvironmentVariable["SC_BASE_URL"] = "SC_BASE_URL";
|
|
6
|
+
EnvironmentVariable["SEMP_API_VERSION"] = "SEMP_API_VERSION";
|
|
6
7
|
})(EnvironmentVariable || (EnvironmentVariable = {}));
|
|
7
8
|
export const DefaultBaseUrl = 'https://api.solace.cloud';
|
|
8
9
|
/**
|
package/lib/sc-command.js
CHANGED
|
@@ -48,7 +48,7 @@ export class ScCommand extends Command {
|
|
|
48
48
|
// Check if Access Token is set
|
|
49
49
|
const value = envVars.getString(EnvironmentVariable.SC_ACCESS_TOKEN);
|
|
50
50
|
if (!value) {
|
|
51
|
-
|
|
51
|
+
this.error(`Environment variable ${EnvironmentVariable.SC_ACCESS_TOKEN} is not set and required for any API operations.`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -2,7 +2,7 @@ import { AxiosRequestConfig } from 'axios';
|
|
|
2
2
|
export declare class ScConnection {
|
|
3
3
|
private axiosInstance;
|
|
4
4
|
private endpointUrl;
|
|
5
|
-
constructor(baseURL?: string, accessToken?: string, timeout?: number);
|
|
5
|
+
constructor(baseURL?: string, accessToken?: string, timeout?: number, semp?: boolean);
|
|
6
6
|
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
7
7
|
get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
8
8
|
patch<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
|
|
@@ -3,13 +3,16 @@ import { DefaultBaseUrl, EnvironmentVariable, envVars } from '../config/env-vars
|
|
|
3
3
|
export class ScConnection {
|
|
4
4
|
axiosInstance;
|
|
5
5
|
endpointUrl = '';
|
|
6
|
-
constructor(baseURL = envVars.getString(EnvironmentVariable.SC_BASE_URL, DefaultBaseUrl), accessToken = envVars.getString(EnvironmentVariable.SC_ACCESS_TOKEN, ''), timeout = 10_000) {
|
|
6
|
+
constructor(baseURL = envVars.getString(EnvironmentVariable.SC_BASE_URL, DefaultBaseUrl), accessToken = envVars.getString(EnvironmentVariable.SC_ACCESS_TOKEN, ''), timeout = 10_000, semp = false) {
|
|
7
7
|
const apiVersion = envVars.getString(EnvironmentVariable.SC_API_VERSION, 'v2');
|
|
8
|
-
|
|
8
|
+
const sempApiVersion = envVars.getString(EnvironmentVariable.SEMP_API_VERSION, 'v2');
|
|
9
|
+
this.endpointUrl = semp
|
|
10
|
+
? this.joinPaths(baseURL, `/SEMP/${sempApiVersion}`)
|
|
11
|
+
: this.joinPaths(baseURL, `/api/${apiVersion}`);
|
|
9
12
|
this.axiosInstance = axios.create({
|
|
10
13
|
baseURL: this.endpointUrl,
|
|
11
14
|
headers: {
|
|
12
|
-
Authorization: `Bearer ${accessToken}`,
|
|
15
|
+
Authorization: semp ? `Basic ${accessToken}` : `Bearer ${accessToken}`,
|
|
13
16
|
'Content-Type': 'application/json',
|
|
14
17
|
},
|
|
15
18
|
timeout,
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dishantlangayan/sc-cli-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Base library for the Solace Cloud CLI and plugins",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Dishant Langayan",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"oclif",
|
|
9
|
+
"solace",
|
|
10
|
+
"cli",
|
|
11
|
+
"sc"
|
|
12
|
+
],
|
|
7
13
|
"type": "module",
|
|
8
14
|
"exports": {
|
|
9
15
|
"./ScCommand.js": "./lib/ScCommand.js",
|