@cubejs-client/react 0.28.33 → 0.28.38
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 +41 -0
- package/dist/cubejs-client-react.esm.js +34 -23
- package/dist/cubejs-client-react.esm.js.map +1 -1
- package/dist/cubejs-client-react.js +34 -22
- package/dist/cubejs-client-react.js.map +1 -1
- package/dist/cubejs-client-react.umd.js +37 -25
- package/dist/cubejs-client-react.umd.js.map +1 -1
- package/index.d.ts +5 -0
- package/package.json +3 -3
- package/src/hooks/cube-fetch.js +11 -10
- package/src/hooks/cube-meta.js +5 -0
- package/src/hooks/dry-run.js +2 -2
- package/src/index.js +1 -0
- package/src/utils.js +11 -1
package/index.d.ts
CHANGED
|
@@ -318,6 +318,7 @@ declare module '@cubejs-client/react' {
|
|
|
318
318
|
timeDimensions: AvailableCube<TCubeDimension>[];
|
|
319
319
|
};
|
|
320
320
|
|
|
321
|
+
// todo: CubeMember
|
|
321
322
|
export type AvailableCube<T = any> = {
|
|
322
323
|
cubeName: string;
|
|
323
324
|
cubeTitle: string;
|
|
@@ -459,6 +460,8 @@ declare module '@cubejs-client/react' {
|
|
|
459
460
|
*/
|
|
460
461
|
type CubeFetchOptions = {
|
|
461
462
|
skip?: boolean;
|
|
463
|
+
cubejsApi?: CubejsApi;
|
|
464
|
+
query?: Query;
|
|
462
465
|
};
|
|
463
466
|
|
|
464
467
|
/**
|
|
@@ -502,6 +505,8 @@ declare module '@cubejs-client/react' {
|
|
|
502
505
|
sql: string;
|
|
503
506
|
};
|
|
504
507
|
|
|
508
|
+
export function useCubeMeta(options?: Omit<CubeFetchOptions, 'query'>): CubeFetchResult<Meta>;
|
|
509
|
+
|
|
505
510
|
/**
|
|
506
511
|
* @hidden
|
|
507
512
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubejs-client/react",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.38",
|
|
4
4
|
"author": "Cube Dev, Inc.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.1.2",
|
|
27
|
-
"@cubejs-client/core": "^0.28.
|
|
27
|
+
"@cubejs-client/core": "^0.28.38",
|
|
28
28
|
"anser": "^2.0.1",
|
|
29
29
|
"core-js": "^3.6.5",
|
|
30
30
|
"html-entities": "^2.3.2",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=16.10.2"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b6ac84b0ec679a40886a19e85d24619e0ca6a2ec"
|
|
48
48
|
}
|
package/src/hooks/cube-fetch.js
CHANGED
|
@@ -22,22 +22,23 @@ export function useCubeFetch(method, options = {}) {
|
|
|
22
22
|
const cubejsApi = options.cubejsApi || context?.cubejsApi;
|
|
23
23
|
const query = loadOptions.query || options.query;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
throw new Error('Cube.js API client is not provided');
|
|
27
|
-
}
|
|
25
|
+
const queryCondition = method === 'meta' ? true : query && isQueryPresent(query);
|
|
28
26
|
|
|
29
|
-
if ((ignoreSkip || !skip) &&
|
|
27
|
+
if (cubejsApi && (ignoreSkip || !skip) && queryCondition) {
|
|
30
28
|
setError(null);
|
|
31
29
|
setResponse({
|
|
32
30
|
isLoading: true,
|
|
33
31
|
response: null,
|
|
34
32
|
});
|
|
35
33
|
|
|
34
|
+
const coreOptions = {
|
|
35
|
+
mutexObj: mutexRef.current,
|
|
36
|
+
mutexKey: method,
|
|
37
|
+
};
|
|
38
|
+
const args = method === 'meta' ? [coreOptions] : [query, coreOptions];
|
|
39
|
+
|
|
36
40
|
try {
|
|
37
|
-
const response = await cubejsApi[method](
|
|
38
|
-
mutexObj: mutexRef.current,
|
|
39
|
-
mutexKey: method,
|
|
40
|
-
});
|
|
41
|
+
const response = await cubejsApi[method](...args);
|
|
41
42
|
|
|
42
43
|
if (isMounted()) {
|
|
43
44
|
setResponse({
|
|
@@ -45,9 +46,9 @@ export function useCubeFetch(method, options = {}) {
|
|
|
45
46
|
isLoading: false,
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
} catch (
|
|
49
|
+
} catch (error) {
|
|
49
50
|
if (isMounted()) {
|
|
50
|
-
setError(
|
|
51
|
+
setError(error);
|
|
51
52
|
setResponse({
|
|
52
53
|
isLoading: false,
|
|
53
54
|
response: null,
|
package/src/hooks/dry-run.js
CHANGED
package/src/index.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -77,9 +77,19 @@ export function generateAnsiHTML(txt) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export function removeEmpty(obj) {
|
|
80
|
+
if (typeof obj !== 'object') {
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
return Object.fromEntries(
|
|
81
85
|
Object.entries(obj)
|
|
82
86
|
.filter(([, v]) => v != null)
|
|
83
|
-
.map(([k, v]) =>
|
|
87
|
+
.map(([k, v]) => {
|
|
88
|
+
if (Array.isArray(v)) {
|
|
89
|
+
return [k, v.map(removeEmpty)];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return [k, typeof v === 'object' ? removeEmpty(v) : v];
|
|
93
|
+
})
|
|
84
94
|
);
|
|
85
95
|
}
|