@vizzly/api-client 0.0.55 → 0.0.57

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.
@@ -48,10 +48,14 @@ export declare class VizzlyApi extends Api {
48
48
  permissions: Array<GlobalLibraryPermissionFromAPI>;
49
49
  }>;
50
50
  buildCreateGlobalLibraryRequest(params: RequestParams<CreateGlobalLibraryParams>): Request<{}>;
51
- getProjects(params?: RequestParams): Promise<{
51
+ getProjects(params?: RequestParams<{
52
+ withParentDashboards?: boolean;
53
+ }>): Promise<{
52
54
  projects: Array<ProjectFromAPI>;
53
55
  }>;
54
- buildGetProjectsRequest(params?: RequestParams): Request<{}>;
56
+ buildGetProjectsRequest(params?: RequestParams<{
57
+ withParentDashboards?: boolean;
58
+ }>): Request<{}>;
55
59
  createProjectApiKey(params: RequestParams<nVizzlyApi.CreateProjectApiKeyParams>): Promise<Response<{
56
60
  api_key: string;
57
61
  }>>;
@@ -156,8 +156,9 @@ class VizzlyApi extends Api_1.Api {
156
156
  });
157
157
  }
158
158
  buildGetProjectsRequest(params) {
159
+ const queryString = (params === null || params === void 0 ? void 0 : params.withParentDashboards) ? '?with_parent_dashboards=true' : '';
159
160
  return {
160
- path: `/api/v2/projects`,
161
+ path: `/api/v2/projects${queryString}`,
161
162
  method: 'get',
162
163
  abortSignal: params === null || params === void 0 ? void 0 : params.abortSignal,
163
164
  };
@@ -262,7 +263,7 @@ class VizzlyApi extends Api_1.Api {
262
263
  dashboardIds: params.dashboardIds,
263
264
  },
264
265
  abortSignal: params.abortSignal,
265
- acceptedAuthParams: ['projectApiKey']
266
+ acceptedAuthParams: ['projectApiKey'],
266
267
  };
267
268
  }
268
269
  /**
@@ -329,8 +330,9 @@ class VizzlyApi extends Api_1.Api {
329
330
  });
330
331
  }
331
332
  buildGetProjectRequest(params) {
333
+ const queryString = params.withParentDashboards ? '?with_parent_dashboards=true' : '';
332
334
  return {
333
- path: `/api/v3/project/${params.projectId}`,
335
+ path: `/api/v3/project/${params.projectId}${queryString}`,
334
336
  method: 'get',
335
337
  abortSignal: params.abortSignal,
336
338
  acceptedAuthParams: ['projectApiKey', 'projectAccessToken', 'appSessionToken'],
@@ -1,6 +1,6 @@
1
1
  import { Api } from './Api';
2
2
  import { Authentication } from './Authentication';
3
- import { nVizzlyQueryEngine, Request, extraHeaders, CreateDashboardParams, UpdateDashboardParams, UpdateGlobalLibraryParams, GlobalLibrary, CreateGlobalLibraryParams, GlobalLibraryPermissionFromAPI, RequestParams } from '../types';
3
+ import { nVizzlyQueryEngine, Request, extraHeaders, CreateDashboardParams, UpdateDashboardParams, UpdateGlobalLibraryParams, GlobalLibrary, CreateGlobalLibraryParams, GlobalLibraryPermissionFromAPI, RequestParams, DataOptimiser } from '../types';
4
4
  import { nSemanticLayer } from '@vizzly/semantic-layer-public';
5
5
  import { SQLSchema } from '@vizzly/sqlbuilder-public';
6
6
  export declare class VizzlyQueryEngineApi extends Api {
@@ -94,6 +94,11 @@ export declare class VizzlyQueryEngineApi extends Api {
94
94
  buildUpdateQueryEngineUserRequest(params: RequestParams<nVizzlyQueryEngine.UpdateQueryEngineUserParams>): Request<{}>;
95
95
  uploadDataToVizzlyCloud(params: RequestParams<nVizzlyQueryEngine.UploadDataToVizzlyCloudParams>): Promise<import("../types").Response<unknown>>;
96
96
  buildUploadDataToVizzlyCloudRequest(params: RequestParams<nVizzlyQueryEngine.UploadDataToVizzlyCloudParams>): Request<{}>;
97
+ /**
98
+ * Create snowflake & AWS infrastructure for a new company
99
+ * & return the bucket & role and snowflake connection
100
+ * information.
101
+ * */
97
102
  createCompanyInfrastructure(params: RequestParams<{
98
103
  companyId: string;
99
104
  }>): Promise<import("../types").Response<{
@@ -110,5 +115,76 @@ export declare class VizzlyQueryEngineApi extends Api {
110
115
  username: string;
111
116
  };
112
117
  }>>;
118
+ /** Get the status of a create company infrastructure call */
119
+ getCreateCompanyInfrastructureStatus(params: RequestParams<{
120
+ companyId: string;
121
+ }>): Promise<import("../types").Response<DataOptimiser.StatusResponse<{
122
+ create_database_action: DataOptimiser.ActionStatus<{}>;
123
+ create_aws_infra_action: DataOptimiser.ActionStatus<{}>;
124
+ }>>>;
113
125
  private buildCreateCompanyInfrastructureRequest;
126
+ /** Send request to ingest data */
127
+ ingestDatasource(params: RequestParams<{
128
+ dataSourceId: string;
129
+ ingestFields: DataOptimiser.DataSourceFields;
130
+ internalCompanyConnection: DataOptimiser.QueryEngineConnection;
131
+ externalSnowflakeConnection: DataOptimiser.QueryEngineConnection;
132
+ }>): Promise<import("../types").Response<DataOptimiser.ExecuteResponse<{
133
+ setup_export_data_integration: DataOptimiser.ActionResult<{}>;
134
+ ingest_to_s3: DataOptimiser.ActionResult<{
135
+ toBucket: string;
136
+ toPath: string;
137
+ fromSnowflakeTableAddress: string[];
138
+ }>;
139
+ ingest_s3_storage_to_snowflake: DataOptimiser.ActionResult<{
140
+ destinationAddress: string[];
141
+ }>;
142
+ }>>>;
143
+ /** Get the status of a call to ingest data for a data source. */
144
+ getIngestDatasourceStatus(params: RequestParams<{
145
+ dataSourceId: string;
146
+ ingestFields: DataOptimiser.DataSourceFields;
147
+ internalCompanyConnection: DataOptimiser.QueryEngineConnection;
148
+ externalSnowflakeConnection: DataOptimiser.QueryEngineConnection;
149
+ }>): Promise<import("../types").Response<DataOptimiser.StatusResponse<{
150
+ setup_export_data_integration: DataOptimiser.ActionStatus<{}>;
151
+ ingest_to_s3: DataOptimiser.ActionStatus<{
152
+ s3Bucket: {
153
+ path: string;
154
+ bucket: string;
155
+ };
156
+ }>;
157
+ ingest_s3_storage_to_snowflake: DataOptimiser.ActionStatus<{
158
+ destinationAddress: string[];
159
+ destinationFields: DataOptimiser.DataSourceFields;
160
+ }>;
161
+ }>>>;
162
+ private buildIngestDatasourceRequest;
163
+ /** Get the status of a call to ingest data for a data source. */
164
+ getCreateSnapshotStatus(params: RequestParams<{
165
+ ingestDataSourceId: string;
166
+ snapshotDataSourceId: string;
167
+ ingestFields: DataOptimiser.DataSourceFields;
168
+ cascadingInstructions: DataOptimiser.CascadingInstructions;
169
+ internalCompanyConnection: DataOptimiser.QueryEngineConnection;
170
+ primaryDateFieldId?: string | undefined;
171
+ }>): Promise<import("../types").Response<DataOptimiser.StatusResponse<{
172
+ create_snapshot: DataOptimiser.ActionStatus<{
173
+ snapshotDataOptimiser: DataOptimiser.DataSourceFields;
174
+ }>;
175
+ }>>>;
176
+ /** Send request to create a snapshot */
177
+ createSnapshot(params: RequestParams<{
178
+ ingestDataSourceId: string;
179
+ snapshotDataSourceId: string;
180
+ ingestFields: DataOptimiser.DataSourceFields;
181
+ cascadingInstructions: DataOptimiser.CascadingInstructions;
182
+ internalCompanyConnection: DataOptimiser.QueryEngineConnection;
183
+ primaryDateFieldId?: string | undefined;
184
+ }>): Promise<import("../types").Response<DataOptimiser.ExecuteResponse<{
185
+ create_snapshot: DataOptimiser.ActionResult<{
186
+ snapshotFields: DataOptimiser.DataSourceFields;
187
+ }>;
188
+ }>>>;
189
+ private buildCreateSnapshotRequest;
114
190
  }
@@ -16,6 +16,7 @@ const FailedToResolveDataSets_1 = require("../errors/FailedToResolveDataSets");
16
16
  const FailedToSetupProject_1 = require("../errors/FailedToSetupProject");
17
17
  const errors_1 = require("../errors");
18
18
  const DashboardRepository_1 = require("./DashboardRepository");
19
+ const Path_1 = require("./Path");
19
20
  class VizzlyQueryEngineApi extends Api_1.Api {
20
21
  constructor(auth, host, extraHeaders) {
21
22
  super(auth, host, extraHeaders);
@@ -435,20 +436,88 @@ class VizzlyQueryEngineApi extends Api_1.Api {
435
436
  },
436
437
  };
437
438
  }
439
+ /**
440
+ * Create snowflake & AWS infrastructure for a new company
441
+ * & return the bucket & role and snowflake connection
442
+ * information.
443
+ * */
438
444
  createCompanyInfrastructure(params) {
439
445
  return __awaiter(this, void 0, void 0, function* () {
440
446
  return yield this.execute(this.buildCreateCompanyInfrastructureRequest(params));
441
447
  });
442
448
  }
443
- buildCreateCompanyInfrastructureRequest(params) {
449
+ /** Get the status of a create company infrastructure call */
450
+ getCreateCompanyInfrastructureStatus(params) {
451
+ return __awaiter(this, void 0, void 0, function* () {
452
+ return yield this.execute(this.buildCreateCompanyInfrastructureRequest(params, { statusOnly: true }));
453
+ });
454
+ }
455
+ buildCreateCompanyInfrastructureRequest(params, options) {
456
+ const maybeStatusRoutePath = (options === null || options === void 0 ? void 0 : options.statusOnly) ? '/status' : '';
444
457
  return {
445
- path: `/api/v1/data-optimiser/company`,
458
+ path: Path_1.Path.buildPath(`/api/v1/data-optimiser/company`, maybeStatusRoutePath),
446
459
  method: 'post',
447
460
  abortSignal: params.abortSignal,
448
461
  body: {
449
462
  company: { id: params.companyId },
450
463
  },
451
- acceptedAuthParams: ['queryEngineApiKey']
464
+ acceptedAuthParams: ['queryEngineApiKey'],
465
+ };
466
+ }
467
+ /** Send request to ingest data */
468
+ ingestDatasource(params) {
469
+ return __awaiter(this, void 0, void 0, function* () {
470
+ return yield this.execute(this.buildIngestDatasourceRequest(params, { statusOnly: false }));
471
+ });
472
+ }
473
+ /** Get the status of a call to ingest data for a data source. */
474
+ getIngestDatasourceStatus(params) {
475
+ return __awaiter(this, void 0, void 0, function* () {
476
+ return yield this.execute(this.buildIngestDatasourceRequest(params, { statusOnly: true }));
477
+ });
478
+ }
479
+ buildIngestDatasourceRequest(params, options) {
480
+ const maybeStatusRoutePath = (options === null || options === void 0 ? void 0 : options.statusOnly) ? '/status' : '';
481
+ return {
482
+ path: Path_1.Path.buildPath(`/api/v1/data-optimiser/ingest`, maybeStatusRoutePath),
483
+ method: 'post',
484
+ abortSignal: params.abortSignal,
485
+ body: {
486
+ dataSourceId: params.dataSourceId,
487
+ ingestFields: params.ingestFields,
488
+ internalCompanyConnection: params.internalCompanyConnection,
489
+ externalSnowflakeConnection: params.externalSnowflakeConnection,
490
+ },
491
+ acceptedAuthParams: ['queryEngineApiKey'],
492
+ };
493
+ }
494
+ /** Get the status of a call to ingest data for a data source. */
495
+ getCreateSnapshotStatus(params) {
496
+ return __awaiter(this, void 0, void 0, function* () {
497
+ return yield this.execute(this.buildCreateSnapshotRequest(params, { statusOnly: true }));
498
+ });
499
+ }
500
+ /** Send request to create a snapshot */
501
+ createSnapshot(params) {
502
+ return __awaiter(this, void 0, void 0, function* () {
503
+ return yield this.execute(this.buildCreateSnapshotRequest(params, { statusOnly: false }));
504
+ });
505
+ }
506
+ buildCreateSnapshotRequest(params, options) {
507
+ const maybeStatusRoutePath = (options === null || options === void 0 ? void 0 : options.statusOnly) ? '/status' : '';
508
+ return {
509
+ path: Path_1.Path.buildPath(`/api/v1/data-optimiser/snapshot`, maybeStatusRoutePath),
510
+ method: 'post',
511
+ abortSignal: params.abortSignal,
512
+ body: {
513
+ ingestDataSourceId: params.ingestDataSourceId,
514
+ snapshotDataSourceId: params.snapshotDataSourceId,
515
+ ingestFields: params.ingestFields,
516
+ cascadingInstructions: params.cascadingInstructions,
517
+ primaryDateFieldId: params.primaryDateFieldId,
518
+ internalCompanyConnection: params.internalCompanyConnection,
519
+ },
520
+ acceptedAuthParams: ['queryEngineApiKey'],
452
521
  };
453
522
  }
454
523
  }
@@ -8,7 +8,13 @@ export type ProjectFromAPI = {
8
8
  type: ProjectType;
9
9
  created_at: Date;
10
10
  share_links?: ShareLink[];
11
- parent_dashboards: DashboardFromAPI[];
11
+ /**
12
+ * To include parent dashboards, use the withParentDashboards param.
13
+ * However only do this when strictly necessary as it inceases
14
+ * load on the Vizzly API for projects that create many parent dashboards, like
15
+ * the GTi next gen application.
16
+ * */
17
+ parent_dashboards: DashboardFromAPI[] | null;
12
18
  parent_global_libraries: GlobalLibrary[];
13
19
  key_pairs: RawKeyPair[];
14
20
  encrypted_encryption_secret: string | null;
package/dist/types.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from './types/team';
9
9
  export * from './types/user';
10
10
  import { DataAccessConfig } from '@vizzly/auth';
11
11
  import { nSemanticLayer, OriginId } from '@vizzly/semantic-layer-public';
12
+ import { SnowflakeConnection } from '@vizzly/sqlbuilder-public';
12
13
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
13
14
  export type UpdateDashboardResponseBody = {
14
15
  dashboard: DashboardFromAPI;
@@ -220,6 +221,7 @@ export declare namespace nVizzlyApi {
220
221
  };
221
222
  type GetProjectParams = {
222
223
  projectId: string;
224
+ withParentDashboards?: boolean;
223
225
  };
224
226
  type GetManagedQueryEngineKeyPairParams = {
225
227
  managedProjectId: string;
@@ -466,3 +468,75 @@ export type GlobalLibraryPermissionFromAPI = {
466
468
  token: string;
467
469
  scope: 'read' | 'read_write';
468
470
  };
471
+ export declare namespace DataOptimiser {
472
+ type DataSourceFields = Array<{
473
+ id: string;
474
+ address: string[];
475
+ data_type: string;
476
+ }>;
477
+ type EphemeralDataSourceFields = Array<Omit<DataSourceFields[number], 'id'>>;
478
+ type DimensionFieldsMapping = Array<{
479
+ field_id: string;
480
+ gti_dimension_key: 'brands' | 'regions' | 'media_channels';
481
+ dimension_values_mappings: Array<{
482
+ gti_dimension_value_key: string;
483
+ label_override?: string;
484
+ data_source_original_value: string;
485
+ }>;
486
+ }>;
487
+ /**
488
+ * We can send a list of instructions to the data optimiser, which
489
+ * will combine them depending on their order which signifies their
490
+ * importance.
491
+ *
492
+ * The first set of instructions will be overridden by the next set,
493
+ * if it makes sense.
494
+ *
495
+ * This means that we can send the instructions for the data source &
496
+ * snapshot in the same request without doing any logic, and the data
497
+ * optimiser will pick what it needs.
498
+ */
499
+ type CascadingInstructions = Array<{
500
+ datasourceDimensionFieldMapping: DimensionFieldsMapping;
501
+ dataStartDate: string | null;
502
+ dataEndDate: string | null;
503
+ }>;
504
+ type ActionResultStatus = 'success' | 'failure' | 'no_action_taken' | 'started_in_background';
505
+ type ActionStatus<PlannedOutcome> = {
506
+ name: string;
507
+ status: ActionResultStatus;
508
+ plannedOutcome: PlannedOutcome;
509
+ };
510
+ type ActionResult<Content> = {
511
+ status: ActionResultStatus;
512
+ content: Content;
513
+ };
514
+ type StatusResponse<Status extends {
515
+ [actionId: string]: {
516
+ name: string;
517
+ status: ActionResultStatus;
518
+ plannedOutcome: any;
519
+ };
520
+ }> = {
521
+ dataConnections: {
522
+ dataTeamSnowflake: boolean | null;
523
+ gtiCommonSnowflake: boolean | null;
524
+ gtiAdminSnowflake: boolean | null;
525
+ };
526
+ status: Status;
527
+ };
528
+ type ExecuteResponse<ActionResult extends {
529
+ [actionId: string]: {
530
+ status: ActionResultStatus;
531
+ content: any;
532
+ };
533
+ }> = {
534
+ actionResults: {
535
+ [actionId: string]: ActionResult;
536
+ };
537
+ };
538
+ type QueryEngineConnection = {
539
+ encryptedCredentials: string;
540
+ unencryptedCredentials?: Partial<SnowflakeConnection>;
541
+ };
542
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",