@sisense/sdk-cli 2.21.0 → 2.23.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,5 +1,5 @@
1
1
  import { trackExecution } from '../tracking.js';
2
- import { getHttpClient, handleHttpClientLogin } from './helpers.js';
2
+ import { getHttpClient } from './helpers.js';
3
3
  import { promptPasswordInteractive } from './prompts.js';
4
4
  const command = 'get-api-token';
5
5
  const describe = 'Get an API token from the given Sisense URL using the provided credentials.';
@@ -29,9 +29,8 @@ const handler = async (options) => {
29
29
  if (username && !password) {
30
30
  ({ maskedPassword: password } = await promptPasswordInteractive(username));
31
31
  }
32
- const httpClient = getHttpClient({ url, username, password });
33
32
  try {
34
- await handleHttpClientLogin(httpClient);
33
+ const httpClient = await getHttpClient({ url, username, password });
35
34
  trackExecution(httpClient, command, options);
36
35
  const response = await httpClient.get('/api/v1/authentication/tokens/api');
37
36
  console.log(response);
@@ -1,5 +1,5 @@
1
1
  import { trackExecution } from '../tracking.js';
2
- import { createDataModel, getFilePathInfo, getHttpClient, handleHttpClientLogin, isSupportedOutputFile, writeFile, } from './helpers.js';
2
+ import { createDataModel, getFilePathInfo, getHttpClient, isSupportedOutputFile, writeFile, } from './helpers.js';
3
3
  import { promptPasswordInteractive } from './prompts.js';
4
4
  const command = 'get-data-model';
5
5
  const describe = 'Write the TypeScript or JavaScript representation of a data model from the given Sisense URL and data source';
@@ -70,9 +70,8 @@ export const getDataModel = async (options, commandName) => {
70
70
  if (username && !password) {
71
71
  ({ maskedPassword: password } = await promptPasswordInteractive(username));
72
72
  }
73
- const httpClient = getHttpClient({ url, username, password, token, wat });
74
73
  try {
75
- await handleHttpClientLogin(httpClient);
74
+ const httpClient = await getHttpClient({ url, username, password, token, wat });
76
75
  trackExecution(httpClient, commandName, options);
77
76
  await createDataModel(httpClient, dataSource).then((model) => {
78
77
  return writeFile(model, outputInfo);
@@ -8,7 +8,7 @@ declare type HttpClientConfig = {
8
8
  token?: string;
9
9
  wat?: string;
10
10
  };
11
- declare function getHttpClient({ url, username, password, token, wat }: HttpClientConfig): HttpClient;
11
+ declare function getHttpClient({ url, username, password, token, wat }: HttpClientConfig): Promise<HttpClient>;
12
12
  export declare const handleHttpClientLogin: (httpClient: HttpClient) => Promise<void>;
13
13
  /**
14
14
  * Create a data model for a Sisense data source
@@ -1,17 +1,28 @@
1
+ import { levenshtein } from '@sisense/sdk-common';
1
2
  import { MetadataTypes } from '@sisense/sdk-data';
2
3
  import { writeJavascript, writeTypescript } from '@sisense/sdk-modeling';
3
4
  import { DimensionalQueryClient } from '@sisense/sdk-query-client';
4
5
  import { getAuthenticator, HttpClient, isBearerAuthenticator, isWatAuthenticator, } from '@sisense/sdk-rest-client';
5
6
  import { trackCliError } from '@sisense/sdk-tracking';
6
- import levenshtein from 'js-levenshtein';
7
7
  import path from 'path';
8
8
  import { PKG_VERSION } from '../package-version.js';
9
- function getHttpClient({ url, username, password, token, wat }) {
9
+ async function getHttpClient({ url, username, password, token, wat }) {
10
10
  const auth = getAuthenticator({ url, username, password, token, wat });
11
11
  if (!auth) {
12
12
  throw new Error('Invalid authentication method');
13
13
  }
14
- return new HttpClient(url, auth, 'sdk-cli' + (PKG_VERSION ? `-${PKG_VERSION}` : ''));
14
+ const env = 'sdk-cli' + (PKG_VERSION ? `-${PKG_VERSION}` : '');
15
+ let httpClient = new HttpClient(url, auth, env);
16
+ await handleHttpClientLogin(httpClient);
17
+ const systemSettings = await httpClient.get('api/v1/settings/system');
18
+ if (systemSettings?.tracking?.apiTelemetry) {
19
+ httpClient = new HttpClient(url, auth, env, {
20
+ 'x-sisense-origin': 'sdk-cli',
21
+ 'x-sisense-sdk': 'csdk-sdk-cli',
22
+ });
23
+ await handleHttpClientLogin(httpClient);
24
+ }
25
+ return httpClient;
15
26
  }
16
27
  export const handleHttpClientLogin = async (httpClient) => {
17
28
  console.log('Logging in... ');
@@ -1 +1 @@
1
- export declare const PKG_VERSION = "2.21.0";
1
+ export declare const PKG_VERSION = "2.23.0";
@@ -1 +1 @@
1
- export const PKG_VERSION = "2.21.0";
1
+ export const PKG_VERSION = "2.23.0";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "Sisense",
12
12
  "Compose SDK"
13
13
  ],
14
- "version": "2.21.0",
14
+ "version": "2.23.0",
15
15
  "type": "module",
16
16
  "exports": "./dist/index.js",
17
17
  "main": "./dist/index.js",
@@ -20,15 +20,14 @@
20
20
  "license": "SEE LICENSE IN LICENSE.md",
21
21
  "bin": "./dist/index.js",
22
22
  "dependencies": {
23
- "@sisense/sdk-common": "2.21.0",
24
- "@sisense/sdk-data": "2.21.0",
25
- "@sisense/sdk-modeling": "2.21.0",
26
- "@sisense/sdk-query-client": "2.21.0",
27
- "@sisense/sdk-rest-client": "2.21.0",
28
- "@sisense/sdk-tracking": "2.21.0",
23
+ "@sisense/sdk-common": "2.23.0",
24
+ "@sisense/sdk-data": "2.23.0",
25
+ "@sisense/sdk-modeling": "2.23.0",
26
+ "@sisense/sdk-query-client": "2.23.0",
27
+ "@sisense/sdk-rest-client": "2.23.0",
28
+ "@sisense/sdk-tracking": "2.23.0",
29
29
  "cross-fetch": "^4.0.0",
30
30
  "inquirer": "^8.1.2",
31
- "js-levenshtein": "^1.1.6",
32
31
  "node-window-polyfill": "^1.0.2",
33
32
  "yargs": "17.7.1"
34
33
  },
@@ -56,7 +55,6 @@
56
55
  "devDependencies": {
57
56
  "@babel/preset-env": "^7.20.2",
58
57
  "@types/inquirer": "8.2.6",
59
- "@types/js-levenshtein": "^1.1.3",
60
58
  "@types/yargs": "^17.0.22",
61
59
  "@vitest/coverage-istanbul": "3.2.4",
62
60
  "eslint": "^8.40.0",