@vizzly/api-client 0.0.45 → 0.0.46

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.
@@ -4,11 +4,13 @@ export declare class Authentication {
4
4
  constructor(authParams: AuthParams);
5
5
  updateAuthParams(authParams: Partial<AuthParams>): void;
6
6
  clearAuthParams(): void;
7
+ getQueryEngineApiKey(): string;
7
8
  getQueryEngineAccessToken(): string;
8
9
  getProjectAdminOverrideToken(): string | undefined;
9
10
  getDashboardAccessToken(): string;
10
11
  getAppSessionToken(): string | undefined;
11
- getDataAccessToken(): string;
12
+ hasDataAccessToken(): boolean;
13
+ getDataAccessToken(): string | undefined;
12
14
  getProjectApiKey(): string;
13
15
  getProjectAccessToken(): string;
14
16
  buildAuthHeaders(acceptedAuthParams: Request<{}>['acceptedAuthParams']): {
@@ -13,6 +13,11 @@ class Authentication {
13
13
  clearAuthParams() {
14
14
  this.authParams = {};
15
15
  }
16
+ getQueryEngineApiKey() {
17
+ if (!this.authParams.queryEngineApiKey)
18
+ throw new MissingAuthParameter_1.MissingAuthParameter('queryEngineApiKey');
19
+ return this.authParams.queryEngineApiKey;
20
+ }
16
21
  getQueryEngineAccessToken() {
17
22
  if (!this.authParams.queryEngineAccessToken)
18
23
  throw new MissingAuthParameter_1.MissingAuthParameter('queryEngineAccessToken');
@@ -29,8 +34,11 @@ class Authentication {
29
34
  getAppSessionToken() {
30
35
  return this.authParams.appSessionToken;
31
36
  }
37
+ hasDataAccessToken() {
38
+ return !!this.authParams.dataAccessToken;
39
+ }
32
40
  getDataAccessToken() {
33
- if (!this.authParams.dataAccessToken)
41
+ if (!this.hasDataAccessToken())
34
42
  throw new MissingAuthParameter_1.MissingAuthParameter('dataAccessToken');
35
43
  return this.authParams.dataAccessToken;
36
44
  }
@@ -51,6 +59,11 @@ class Authentication {
51
59
  auth: `Bearer ${usableAuthParams.dashboardAccessToken}`,
52
60
  };
53
61
  }
62
+ if (usableAuthParams.queryEngineApiKey) {
63
+ return {
64
+ 'Config-Api-Key': usableAuthParams.queryEngineApiKey,
65
+ };
66
+ }
54
67
  // If a project access token has been set on the config, use that instead
55
68
  // of fetching one. This is most likely used on the managed query-engine where we
56
69
  // pass the project access token through in a request header.
@@ -1,6 +1,8 @@
1
1
  import { Api } from './Api';
2
2
  import { Authentication } from './Authentication';
3
3
  import { nVizzlyQueryEngine, Request, extraHeaders, CreateDashboardParams, UpdateDashboardParams, UpdateGlobalLibraryParams, GlobalLibrary, CreateGlobalLibraryParams, GlobalLibraryPermissionFromAPI, RequestParams } from '../types';
4
+ import { nSemanticLayer } from '@vizzly/semantic-layer-public';
5
+ import { SQLSchema } from '@vizzly/sqlbuilder-public';
4
6
  export declare class VizzlyQueryEngineApi extends Api {
5
7
  constructor(auth: Authentication, host: string, extraHeaders?: extraHeaders);
6
8
  buildCreateDashboardRequest(params: RequestParams<CreateDashboardParams>): Request<CreateDashboardParams & {
@@ -23,8 +25,19 @@ export declare class VizzlyQueryEngineApi extends Api {
23
25
  }>): Request<{}>;
24
26
  createConfigFromUpload(createConfigFromUploadParams: RequestParams<nVizzlyQueryEngine.CreateConfigFromUploadParams>): Promise<import("../types").Response<unknown>>;
25
27
  private buildCreateConfigFromUploadRequest;
26
- createResults(params: RequestParams<nVizzlyQueryEngine.CreateResultsParams>): Promise<import("../types").Response<unknown>>;
28
+ createResults(params: RequestParams<nVizzlyQueryEngine.CreateResultsParams>, versionOverride?: 'v1' | 'v2'): Promise<import("../types").Response<{
29
+ results: Array<nSemanticLayer.Result>;
30
+ }>>;
27
31
  private buildCreateResultsRequest;
32
+ collectSchema(params: RequestParams<nVizzlyQueryEngine.CollectSchemaParams>): Promise<import("../types").Response<{
33
+ schemaByConnection: {
34
+ [connectionId: string]: {
35
+ /** ID of the connection */
36
+ id: string;
37
+ } & SQLSchema;
38
+ };
39
+ }>>;
40
+ private buildCollectSchemaRequest;
28
41
  createSqlPreview(params: RequestParams<nVizzlyQueryEngine.CreateSqlPreviewParams>): Promise<import("../types").Response<{
29
42
  message: string;
30
43
  }>>;
@@ -88,21 +88,41 @@ class VizzlyQueryEngineApi extends Api_1.Api {
88
88
  },
89
89
  };
90
90
  }
91
- createResults(params) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- return yield this.execute(this.buildCreateResultsRequest(params));
91
+ createResults(params_1) {
92
+ return __awaiter(this, arguments, void 0, function* (params, versionOverride = 'v2') {
93
+ return yield this.execute(this.buildCreateResultsRequest(params, versionOverride));
94
94
  });
95
95
  }
96
- buildCreateResultsRequest(params) {
96
+ buildCreateResultsRequest(params, versionOverride) {
97
97
  return {
98
- path: `/api/v1/create-results`,
98
+ path: `/api/${versionOverride}/create-results`,
99
99
  method: 'post',
100
100
  abortSignal: params.abortSignal,
101
101
  body: {
102
102
  queries: params.queries,
103
+ dynamicConfig: params.dynamicConfig,
104
+ identityConfigIntegritySignature: this.auth.hasDataAccessToken() ? this.auth.getDataAccessToken() : undefined,
105
+ secureFilters: params.secureFilters,
103
106
  virtualFields: {},
104
- identityConfigIntegritySignature: this.auth.getDataAccessToken(),
105
107
  },
108
+ acceptedAuthParams: ['queryEngineApiKey', 'dashboardAccessToken'],
109
+ };
110
+ }
111
+ collectSchema(params) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ return yield this.execute(this.buildCollectSchemaRequest(params));
114
+ });
115
+ }
116
+ buildCollectSchemaRequest(params) {
117
+ return {
118
+ path: `/api/v1/schema`,
119
+ method: 'post',
120
+ abortSignal: params.abortSignal,
121
+ body: {
122
+ allowedConfigOrigins: params.allowedConfigOrigins,
123
+ dynamicConfig: params.dynamicConfig,
124
+ },
125
+ acceptedAuthParams: ['queryEngineApiKey'],
106
126
  };
107
127
  }
108
128
  createSqlPreview(params) {
package/dist/types.d.ts CHANGED
@@ -7,6 +7,8 @@ export * from './types/dashboard';
7
7
  export * from './types/project';
8
8
  export * from './types/team';
9
9
  export * from './types/user';
10
+ import { DataAccessConfig } from '@vizzly/auth';
11
+ import { nSemanticLayer, OriginId } from '@vizzly/semantic-layer-public';
10
12
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
11
13
  export type UpdateDashboardResponseBody = {
12
14
  dashboard: DashboardFromAPI;
@@ -86,6 +88,7 @@ export type AuthParams = {
86
88
  dataAccessToken?: string;
87
89
  projectApiKey?: string;
88
90
  appSessionToken?: string;
91
+ queryEngineApiKey?: string;
89
92
  };
90
93
  export declare namespace nVizzlyQueryEngine {
91
94
  type CreateConfigFromUploadParams = {
@@ -94,6 +97,12 @@ export declare namespace nVizzlyQueryEngine {
94
97
  };
95
98
  type CreateResultsParams = {
96
99
  queries: any;
100
+ dynamicConfig?: nSemanticLayer.Config;
101
+ secureFilters?: DataAccessConfig['secureFilters'];
102
+ };
103
+ type CollectSchemaParams = {
104
+ allowedConfigOrigins: OriginId[];
105
+ dynamicConfig?: nSemanticLayer.Config;
97
106
  };
98
107
  type CreateSqlPreviewParams = {
99
108
  sql: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",
@@ -14,7 +14,7 @@
14
14
  "@types/jest": "^29.5.12",
15
15
  "@types/lodash": "^4.17.0",
16
16
  "@types/uuid": "^9.0.8",
17
- "@vizzly/auth": "^0.2.8",
17
+ "@vizzly/auth": "^0.2.16",
18
18
  "jest": "^29.6.0",
19
19
  "lodash": "^4.17.21",
20
20
  "nock": "^13.5.4",
@@ -33,6 +33,8 @@
33
33
  "prepublish": "yarn build"
34
34
  },
35
35
  "dependencies": {
36
+ "@vizzly/semantic-layer-public": "^0.0.228",
37
+ "@vizzly/sqlbuilder-public": "^0.1.33",
36
38
  "cross-fetch": "^4.0.0"
37
39
  }
38
40
  }