@cubejs-client/react 1.7.12 → 1.7.14
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/dist/CubeContext.d.ts +35 -0
- package/dist/CubeContext.d.ts.map +1 -0
- package/dist/CubeProvider.d.ts +31 -0
- package/dist/CubeProvider.d.ts.map +1 -0
- package/dist/QueryBuilder.d.ts +135 -0
- package/dist/QueryBuilder.d.ts.map +1 -0
- package/dist/QueryRenderer.d.ts +34 -0
- package/dist/QueryRenderer.d.ts.map +1 -0
- package/dist/QueryRendererWithTotals.d.ts +4 -0
- package/dist/QueryRendererWithTotals.d.ts.map +1 -0
- package/dist/cubejs-client-react.cjs.js +248 -23
- package/dist/cubejs-client-react.cjs.js.map +1 -1
- package/dist/cubejs-client-react.esm.js +253 -31
- package/dist/cubejs-client-react.esm.js.map +1 -1
- package/dist/cubejs-client-react.umd.js +248 -23
- package/dist/cubejs-client-react.umd.js.map +1 -1
- package/dist/hooks/cube-fetch.d.ts +6 -0
- package/dist/hooks/cube-fetch.d.ts.map +1 -0
- package/dist/hooks/cube-meta.d.ts +4 -0
- package/dist/hooks/cube-meta.d.ts.map +1 -0
- package/dist/hooks/cube-query.d.ts +39 -0
- package/dist/hooks/cube-query.d.ts.map +1 -0
- package/dist/hooks/cube-sql.d.ts +12 -0
- package/dist/hooks/cube-sql.d.ts.map +1 -0
- package/dist/hooks/deep-compare-memoize.d.ts +2 -0
- package/dist/hooks/deep-compare-memoize.d.ts.map +1 -0
- package/dist/hooks/dry-run.d.ts +7 -0
- package/dist/hooks/dry-run.d.ts.map +1 -0
- package/dist/hooks/lazy-dry-run.d.ts +7 -0
- package/dist/hooks/lazy-dry-run.d.ts.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/types.d.ts +765 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +14 -10
- package/src/CubeContext.ts +37 -0
- package/src/CubeProvider.tsx +42 -0
- package/src/{QueryBuilder.jsx → QueryBuilder.tsx} +238 -89
- package/src/{QueryRenderer.jsx → QueryRenderer.tsx} +39 -14
- package/src/QueryRendererWithTotals.tsx +24 -0
- package/src/hooks/cube-fetch.ts +98 -0
- package/src/hooks/cube-meta.ts +8 -0
- package/src/hooks/{cube-query.js → cube-query.ts} +90 -14
- package/src/hooks/cube-sql.ts +22 -0
- package/src/hooks/{deep-compare-memoize.js → deep-compare-memoize.ts} +2 -2
- package/src/hooks/dry-run.ts +17 -0
- package/src/hooks/lazy-dry-run.ts +24 -0
- package/src/index.ts +77 -0
- package/src/types.ts +837 -0
- package/src/{utils.js → utils.ts} +3 -3
- package/index.d.ts +0 -697
- package/src/CubeContext.js +0 -3
- package/src/CubeProvider.jsx +0 -14
- package/src/QueryRendererWithTotals.jsx +0 -20
- package/src/hooks/cube-fetch.js +0 -66
- package/src/hooks/cube-meta.js +0 -5
- package/src/hooks/cube-sql.js +0 -8
- package/src/hooks/dry-run.js +0 -8
- package/src/hooks/lazy-dry-run.js +0 -11
- package/src/index.js +0 -18
package/src/CubeProvider.jsx
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import CubeContext from './CubeContext';
|
|
3
|
-
|
|
4
|
-
export default function CubeProvider({ cubeApi, children, options = {} }) {
|
|
5
|
-
return (
|
|
6
|
-
<CubeContext.Provider value={{
|
|
7
|
-
cubeApi,
|
|
8
|
-
options
|
|
9
|
-
}}
|
|
10
|
-
>
|
|
11
|
-
{children}
|
|
12
|
-
</CubeContext.Provider>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import QueryRenderer from './QueryRenderer.jsx';
|
|
3
|
-
|
|
4
|
-
const QueryRendererWithTotals = ({ query, ...restProps }) => (
|
|
5
|
-
<QueryRenderer
|
|
6
|
-
queries={{
|
|
7
|
-
totals: {
|
|
8
|
-
...query,
|
|
9
|
-
dimensions: [],
|
|
10
|
-
timeDimensions: query.timeDimensions
|
|
11
|
-
? query.timeDimensions.map(td => ({ ...td, granularity: null }))
|
|
12
|
-
: undefined
|
|
13
|
-
},
|
|
14
|
-
main: query
|
|
15
|
-
}}
|
|
16
|
-
{...restProps}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export default QueryRendererWithTotals;
|
package/src/hooks/cube-fetch.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { isQueryPresent } from '@cubejs-client/core';
|
|
3
|
-
|
|
4
|
-
import CubeContext from '../CubeContext';
|
|
5
|
-
import useDeepCompareMemoize from './deep-compare-memoize';
|
|
6
|
-
|
|
7
|
-
export function useCubeFetch(method, options = {}) {
|
|
8
|
-
const context = useContext(CubeContext);
|
|
9
|
-
const mutexRef = useRef({});
|
|
10
|
-
|
|
11
|
-
const [response, setResponse] = useState({
|
|
12
|
-
isLoading: false,
|
|
13
|
-
response: null,
|
|
14
|
-
});
|
|
15
|
-
const [error, setError] = useState(null);
|
|
16
|
-
|
|
17
|
-
const { skip = false } = options;
|
|
18
|
-
|
|
19
|
-
async function load(loadOptions = {}, ignoreSkip = false) {
|
|
20
|
-
const cubeApi = options.cubeApi || context?.cubeApi;
|
|
21
|
-
const query = loadOptions.query || options.query;
|
|
22
|
-
|
|
23
|
-
const queryCondition =
|
|
24
|
-
method === 'meta' ? true : query && isQueryPresent(query);
|
|
25
|
-
|
|
26
|
-
if (cubeApi && (ignoreSkip || !skip) && queryCondition) {
|
|
27
|
-
setError(null);
|
|
28
|
-
setResponse({
|
|
29
|
-
isLoading: true,
|
|
30
|
-
response: null,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const coreOptions = {
|
|
34
|
-
mutexObj: mutexRef.current,
|
|
35
|
-
mutexKey: method,
|
|
36
|
-
...(options.baseRequestId ? { baseRequestId: options.baseRequestId } : {})
|
|
37
|
-
};
|
|
38
|
-
const args = method === 'meta' ? [coreOptions] : [query, coreOptions];
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const response = await cubeApi[method](...args);
|
|
42
|
-
|
|
43
|
-
setResponse({
|
|
44
|
-
response,
|
|
45
|
-
isLoading: false,
|
|
46
|
-
});
|
|
47
|
-
} catch (error) {
|
|
48
|
-
setError(error);
|
|
49
|
-
setResponse({
|
|
50
|
-
isLoading: false,
|
|
51
|
-
response: null,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
load();
|
|
59
|
-
}, useDeepCompareMemoize([Object.keys(options.query?.order || {}), options, context]));
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
...response,
|
|
63
|
-
error,
|
|
64
|
-
refetch: (options) => load(options, true),
|
|
65
|
-
};
|
|
66
|
-
}
|
package/src/hooks/cube-meta.js
DELETED
package/src/hooks/cube-sql.js
DELETED
package/src/hooks/dry-run.js
DELETED
package/src/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import QueryRenderer from './QueryRenderer.jsx';
|
|
2
|
-
import QueryRendererWithTotals from './QueryRendererWithTotals.jsx';
|
|
3
|
-
import QueryBuilder from './QueryBuilder.jsx';
|
|
4
|
-
import CubeProvider from './CubeProvider.jsx';
|
|
5
|
-
import CubeContext from './CubeContext';
|
|
6
|
-
|
|
7
|
-
export * from './hooks/cube-sql';
|
|
8
|
-
export * from './hooks/dry-run';
|
|
9
|
-
export * from './hooks/lazy-dry-run';
|
|
10
|
-
export * from './hooks/cube-query';
|
|
11
|
-
export * from './hooks/cube-meta';
|
|
12
|
-
export {
|
|
13
|
-
QueryRenderer,
|
|
14
|
-
QueryRendererWithTotals,
|
|
15
|
-
QueryBuilder,
|
|
16
|
-
CubeContext,
|
|
17
|
-
CubeProvider,
|
|
18
|
-
};
|