@cubejs-client/core 0.29.43 → 0.29.53
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/CHANGELOG.md +40 -0
- package/dist/cubejs-client-core.esm.js +28 -14
- package/dist/cubejs-client-core.esm.js.map +1 -1
- package/dist/cubejs-client-core.js +28 -14
- package/dist/cubejs-client-core.js.map +1 -1
- package/dist/cubejs-client-core.umd.js +41 -27
- package/dist/cubejs-client-core.umd.js.map +1 -1
- package/index.d.ts +24 -16
- package/package.json +2 -2
- package/src/HttpTransport.js +9 -2
- package/src/RequestError.js +2 -1
- package/src/index.js +17 -16
package/index.d.ts
CHANGED
|
@@ -169,6 +169,7 @@ declare module '@cubejs-client/core' {
|
|
|
169
169
|
requestId?: string;
|
|
170
170
|
usedPreAggregations?: Record<string, UsedPreAggregation>;
|
|
171
171
|
transformedQuery?: TransformedQuery;
|
|
172
|
+
total?: number
|
|
172
173
|
};
|
|
173
174
|
|
|
174
175
|
export type LoadResponse<T> = {
|
|
@@ -723,11 +724,11 @@ declare module '@cubejs-client/core' {
|
|
|
723
724
|
|
|
724
725
|
export type Filter = BinaryFilter | UnaryFilter | LogicalOrFilter | LogicalAndFilter;
|
|
725
726
|
export type LogicalAndFilter = {
|
|
726
|
-
and:
|
|
727
|
+
and: Filter[];
|
|
727
728
|
};
|
|
728
729
|
|
|
729
730
|
export type LogicalOrFilter = {
|
|
730
|
-
or:
|
|
731
|
+
or: Filter[];
|
|
731
732
|
};
|
|
732
733
|
|
|
733
734
|
export interface BinaryFilter {
|
|
@@ -754,6 +755,8 @@ declare module '@cubejs-client/core' {
|
|
|
754
755
|
| 'notEquals'
|
|
755
756
|
| 'contains'
|
|
756
757
|
| 'notContains'
|
|
758
|
+
| 'startsWith'
|
|
759
|
+
| 'endsWith'
|
|
757
760
|
| 'gt'
|
|
758
761
|
| 'gte'
|
|
759
762
|
| 'lt'
|
|
@@ -785,19 +788,24 @@ declare module '@cubejs-client/core' {
|
|
|
785
788
|
|
|
786
789
|
export type TimeDimension = TimeDimensionComparison | TimeDimensionRanged;
|
|
787
790
|
|
|
791
|
+
type DeeplyReadonly<T> = {
|
|
792
|
+
readonly [K in keyof T]: DeeplyReadonly<T[K]>;
|
|
793
|
+
};
|
|
794
|
+
|
|
788
795
|
export interface Query {
|
|
789
796
|
measures?: string[];
|
|
790
797
|
dimensions?: string[];
|
|
791
798
|
filters?: Filter[];
|
|
792
799
|
timeDimensions?: TimeDimension[];
|
|
793
800
|
segments?: string[];
|
|
794
|
-
limit?: number;
|
|
801
|
+
limit?: null | number;
|
|
795
802
|
offset?: number;
|
|
796
803
|
order?: TQueryOrderObject | TQueryOrderArray;
|
|
797
804
|
timezone?: string;
|
|
798
805
|
renewQuery?: boolean;
|
|
799
806
|
ungrouped?: boolean;
|
|
800
807
|
responseFormat?: 'compact' | 'default';
|
|
808
|
+
total?: boolean;
|
|
801
809
|
}
|
|
802
810
|
|
|
803
811
|
export class ProgressResult {
|
|
@@ -940,7 +948,7 @@ declare module '@cubejs-client/core' {
|
|
|
940
948
|
* If empty query is provided no filtering is done based on query context and all available members are retrieved.
|
|
941
949
|
* @param query - context query to provide filtering of members available to add to this query
|
|
942
950
|
*/
|
|
943
|
-
membersForQuery(query: Query | null, memberType: MemberType): TCubeMeasure[] | TCubeDimension[] | TCubeMember[];
|
|
951
|
+
membersForQuery(query: DeeplyReadonly<Query> | null, memberType: MemberType): TCubeMeasure[] | TCubeDimension[] | TCubeMember[];
|
|
944
952
|
|
|
945
953
|
/**
|
|
946
954
|
* Get meta information for a cube member
|
|
@@ -975,7 +983,7 @@ declare module '@cubejs-client/core' {
|
|
|
975
983
|
* @order 2
|
|
976
984
|
*/
|
|
977
985
|
export class CubejsApi {
|
|
978
|
-
load(query: Query | Query[]
|
|
986
|
+
load(query: DeeplyReadonly<Query | Query[]>, options?: LoadMethodOptions): Promise<ResultSet>;
|
|
979
987
|
/**
|
|
980
988
|
* Fetch data for the passed `query`.
|
|
981
989
|
*
|
|
@@ -1000,9 +1008,9 @@ declare module '@cubejs-client/core' {
|
|
|
1000
1008
|
* ```
|
|
1001
1009
|
* @param query - [Query object](query-format)
|
|
1002
1010
|
*/
|
|
1003
|
-
load(query: Query | Query[]
|
|
1011
|
+
load(query: DeeplyReadonly<Query | Query[]>, options?: LoadMethodOptions, callback?: LoadMethodCallback<ResultSet>): void;
|
|
1004
1012
|
load(
|
|
1005
|
-
query: Query | Query[]
|
|
1013
|
+
query: DeeplyReadonly<Query | Query[]>,
|
|
1006
1014
|
options?: LoadMethodOptions,
|
|
1007
1015
|
callback?: LoadMethodCallback<ResultSet>,
|
|
1008
1016
|
responseFormat?: string
|
|
@@ -1032,14 +1040,14 @@ declare module '@cubejs-client/core' {
|
|
|
1032
1040
|
* );
|
|
1033
1041
|
* ```
|
|
1034
1042
|
*/
|
|
1035
|
-
subscribe(query: Query | Query[]
|
|
1043
|
+
subscribe(query: DeeplyReadonly<Query | Query[]>, options: LoadMethodOptions | null, callback: LoadMethodCallback<ResultSet>): void;
|
|
1036
1044
|
|
|
1037
|
-
sql(query: Query | Query[]
|
|
1045
|
+
sql(query: DeeplyReadonly<Query | Query[]>, options?: LoadMethodOptions): Promise<SqlQuery>;
|
|
1038
1046
|
/**
|
|
1039
1047
|
* Get generated SQL string for the given `query`.
|
|
1040
1048
|
* @param query - [Query object](query-format)
|
|
1041
1049
|
*/
|
|
1042
|
-
sql(query: Query | Query[]
|
|
1050
|
+
sql(query: DeeplyReadonly<Query | Query[]>, options?: LoadMethodOptions, callback?: LoadMethodCallback<SqlQuery>): void;
|
|
1043
1051
|
|
|
1044
1052
|
meta(options?: LoadMethodOptions): Promise<Meta>;
|
|
1045
1053
|
/**
|
|
@@ -1047,11 +1055,11 @@ declare module '@cubejs-client/core' {
|
|
|
1047
1055
|
*/
|
|
1048
1056
|
meta(options?: LoadMethodOptions, callback?: LoadMethodCallback<Meta>): void;
|
|
1049
1057
|
|
|
1050
|
-
dryRun(query: Query | Query[]
|
|
1058
|
+
dryRun(query: DeeplyReadonly<Query | Query[]>, options?: LoadMethodOptions): Promise<DryRunResponse>;
|
|
1051
1059
|
/**
|
|
1052
1060
|
* Get query related meta without query execution
|
|
1053
1061
|
*/
|
|
1054
|
-
dryRun(query: Query | Query[]
|
|
1062
|
+
dryRun(query: DeeplyReadonly<Query | Query[]>, options: LoadMethodOptions, callback?: LoadMethodCallback<DryRunResponse>): void;
|
|
1055
1063
|
}
|
|
1056
1064
|
|
|
1057
1065
|
/**
|
|
@@ -1113,7 +1121,7 @@ declare module '@cubejs-client/core' {
|
|
|
1113
1121
|
/**
|
|
1114
1122
|
* @hidden
|
|
1115
1123
|
*/
|
|
1116
|
-
export function isQueryPresent(query: Query | Query[] | null | undefined): boolean;
|
|
1124
|
+
export function isQueryPresent(query: DeeplyReadonly<Query | Query[]> | null | undefined): boolean;
|
|
1117
1125
|
export function movePivotItem(
|
|
1118
1126
|
pivotConfig: PivotConfig,
|
|
1119
1127
|
sourceIndex: number,
|
|
@@ -1126,7 +1134,7 @@ declare module '@cubejs-client/core' {
|
|
|
1126
1134
|
*/
|
|
1127
1135
|
export function moveItemInArray<T = any>(list: T[], sourceIndex: number, destinationIndex: number): T[];
|
|
1128
1136
|
|
|
1129
|
-
export function defaultOrder(query: Query): { [key: string]: QueryOrder };
|
|
1137
|
+
export function defaultOrder(query: DeeplyReadonly<Query>): { [key: string]: QueryOrder };
|
|
1130
1138
|
|
|
1131
1139
|
export interface TFlatFilter {
|
|
1132
1140
|
/**
|
|
@@ -1160,9 +1168,9 @@ declare module '@cubejs-client/core' {
|
|
|
1160
1168
|
/**
|
|
1161
1169
|
* @hidden
|
|
1162
1170
|
*/
|
|
1163
|
-
export function getQueryMembers(query: Query): string[];
|
|
1171
|
+
export function getQueryMembers(query: DeeplyReadonly<Query>): string[];
|
|
1164
1172
|
|
|
1165
|
-
export function areQueriesEqual(query1: Query | null, query2: Query | null): boolean;
|
|
1173
|
+
export function areQueriesEqual(query1: DeeplyReadonly<Query> | null, query2: DeeplyReadonly<Query> | null): boolean;
|
|
1166
1174
|
|
|
1167
1175
|
export type ProgressResponse = {
|
|
1168
1176
|
stage: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubejs-client/core",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.53",
|
|
4
4
|
"engines": {},
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"eslint-plugin-node": "^5.2.1",
|
|
47
47
|
"jest": "^26.0.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b2815b43b973199420267695877b57eb6d744978"
|
|
50
50
|
}
|
package/src/HttpTransport.js
CHANGED
|
@@ -40,9 +40,16 @@ class HttpTransport {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
return {
|
|
43
|
+
/* eslint no-unsafe-finally: off */
|
|
43
44
|
async subscribe(callback) {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
let result = {
|
|
46
|
+
error: 'network Error' // add default error message
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
result = await runRequest();
|
|
50
|
+
} finally {
|
|
51
|
+
return callback(result, () => this.subscribe(callback));
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
55
|
}
|
package/src/RequestError.js
CHANGED
package/src/index.js
CHANGED
|
@@ -56,7 +56,7 @@ class CubejsApi {
|
|
|
56
56
|
});
|
|
57
57
|
this.pollInterval = options.pollInterval || 5;
|
|
58
58
|
this.parseDateMeasures = options.parseDateMeasures;
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
this.updateAuthorizationPromise = null;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -73,7 +73,7 @@ class CubejsApi {
|
|
|
73
73
|
callback = options;
|
|
74
74
|
options = undefined;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
options = options || {};
|
|
78
78
|
|
|
79
79
|
const mutexKey = options.mutexKey || 'default';
|
|
@@ -127,11 +127,11 @@ class CubejsApi {
|
|
|
127
127
|
}
|
|
128
128
|
return null;
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
if (options.subscribe && !skipAuthorizationUpdate) {
|
|
132
132
|
await this.updateTransportAuthorization();
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
skipAuthorizationUpdate = false;
|
|
136
136
|
|
|
137
137
|
if (response.status === 502) {
|
|
@@ -162,7 +162,7 @@ class CubejsApi {
|
|
|
162
162
|
await requestInstance.unsubscribe();
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
const error = new RequestError(body.error, body); // TODO error class
|
|
165
|
+
const error = new RequestError(body.error, body, response.status); // TODO error class
|
|
166
166
|
if (callback) {
|
|
167
167
|
callback(error);
|
|
168
168
|
} else {
|
|
@@ -209,7 +209,7 @@ class CubejsApi {
|
|
|
209
209
|
await this.updateAuthorizationPromise;
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
|
|
213
213
|
if (typeof this.apiToken === 'function') {
|
|
214
214
|
this.updateAuthorizationPromise = new Promise(async (resolve, reject) => {
|
|
215
215
|
try {
|
|
@@ -224,7 +224,7 @@ class CubejsApi {
|
|
|
224
224
|
this.updateAuthorizationPromise = null;
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
await this.updateAuthorizationPromise;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -241,7 +241,12 @@ class CubejsApi {
|
|
|
241
241
|
responseFormat === ResultType.COMPACT &&
|
|
242
242
|
query.responseFormat !== ResultType.COMPACT
|
|
243
243
|
) {
|
|
244
|
-
|
|
244
|
+
return {
|
|
245
|
+
...query,
|
|
246
|
+
responseFormat: ResultType.COMPACT,
|
|
247
|
+
};
|
|
248
|
+
} else {
|
|
249
|
+
return query;
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
|
|
@@ -287,11 +292,9 @@ class CubejsApi {
|
|
|
287
292
|
load(query, options, callback, responseFormat = ResultType.DEFAULT) {
|
|
288
293
|
if (responseFormat === ResultType.COMPACT) {
|
|
289
294
|
if (Array.isArray(query)) {
|
|
290
|
-
query.
|
|
291
|
-
this.patchQueryInternal(q, ResultType.COMPACT);
|
|
292
|
-
});
|
|
295
|
+
query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));
|
|
293
296
|
} else {
|
|
294
|
-
this.patchQueryInternal(query, ResultType.COMPACT);
|
|
297
|
+
query = this.patchQueryInternal(query, ResultType.COMPACT);
|
|
295
298
|
}
|
|
296
299
|
}
|
|
297
300
|
return this.loadMethod(
|
|
@@ -318,11 +321,9 @@ class CubejsApi {
|
|
|
318
321
|
subscribe(query, options, callback, responseFormat = ResultType.DEFAULT) {
|
|
319
322
|
if (responseFormat === ResultType.COMPACT) {
|
|
320
323
|
if (Array.isArray(query)) {
|
|
321
|
-
query.
|
|
322
|
-
this.patchQueryInternal(q, ResultType.COMPACT);
|
|
323
|
-
});
|
|
324
|
+
query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));
|
|
324
325
|
} else {
|
|
325
|
-
this.patchQueryInternal(query, ResultType.COMPACT);
|
|
326
|
+
query = this.patchQueryInternal(query, ResultType.COMPACT);
|
|
326
327
|
}
|
|
327
328
|
}
|
|
328
329
|
return this.loadMethod(
|