@cubejs-client/react 0.34.0 → 0.34.9

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/index.d.ts CHANGED
@@ -457,9 +457,15 @@ declare module '@cubejs-client/react' {
457
457
 
458
458
  type UseCubeQueryOptions = {
459
459
  /**
460
+ * @deprecated Use the `cubeApi` option
460
461
  * A `CubejsApi` instance to use. Taken from the context if the param is not passed
461
462
  */
462
463
  cubejsApi?: CubejsApi;
464
+
465
+ /**
466
+ * A `CubejsApi` instance to use. Taken from the context if the param is not passed
467
+ */
468
+ cubeApi?: CubejsApi;
463
469
  /**
464
470
  * Query execution will be skipped when `skip` is set to `true`. You can use this flag to avoid sending incomplete queries.
465
471
  */
@@ -491,6 +497,7 @@ declare module '@cubejs-client/react' {
491
497
  */
492
498
  type CubeFetchOptions = {
493
499
  skip?: boolean;
500
+ cubeApi?: CubejsApi;
494
501
  cubejsApi?: CubejsApi;
495
502
  query?: Query;
496
503
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-client/react",
3
- "version": "0.34.0",
3
+ "version": "0.34.9",
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.34.0",
27
+ "@cubejs-client/core": "^0.34.9",
28
28
  "core-js": "^3.6.5",
29
29
  "ramda": "^0.27.2"
30
30
  },
@@ -42,5 +42,5 @@
42
42
  "peerDependencies": {
43
43
  "react": ">=16.10.2"
44
44
  },
45
- "gitHead": "55e796e52bd276f839c5fa842b9eb821d363e77e"
45
+ "gitHead": "9c2ceb36b8663483a7c97c195f55c42fc1701dc9"
46
46
  }
@@ -1,10 +1,17 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import CubeContext from './CubeContext';
3
3
 
4
- export default function CubeProvider({ cubejsApi, children, options = {} }) {
4
+ export default function CubeProvider({ cubeApi, cubejsApi, children, options = {} }) {
5
+ useEffect(() => {
6
+ if (cubejsApi && !cubeApi) {
7
+ console.warn('"cubejsApi" is deprecated and will be removed in the following version. Use "cubeApi" instead.');
8
+ }
9
+ }, [cubeApi, cubejsApi]);
10
+
5
11
  return (
6
12
  <CubeContext.Provider value={{
7
13
  cubejsApi,
14
+ cubeApi,
8
15
  options
9
16
  }}
10
17
  >
@@ -19,12 +19,12 @@ export function useCubeFetch(method, options = {}) {
19
19
  const { skip = false } = options;
20
20
 
21
21
  async function load(loadOptions = {}, ignoreSkip = false) {
22
- const cubejsApi = options.cubejsApi || context?.cubejsApi;
22
+ const cubeApi = options.cubeApi || options.cubejsApi || context?.cubeApi || context?.cubejsApi;
23
23
  const query = loadOptions.query || options.query;
24
24
 
25
25
  const queryCondition = method === 'meta' ? true : query && isQueryPresent(query);
26
26
 
27
- if (cubejsApi && (ignoreSkip || !skip) && queryCondition) {
27
+ if (cubeApi && (ignoreSkip || !skip) && queryCondition) {
28
28
  setError(null);
29
29
  setResponse({
30
30
  isLoading: true,
@@ -38,7 +38,7 @@ export function useCubeFetch(method, options = {}) {
38
38
  const args = method === 'meta' ? [coreOptions] : [query, coreOptions];
39
39
 
40
40
  try {
41
- const response = await cubejsApi[method](...args);
41
+ const response = await cubeApi[method](...args);
42
42
 
43
43
  if (isMounted()) {
44
44
  setResponse({
@@ -18,12 +18,18 @@ export function useCubeQuery(query, options = {}) {
18
18
  let subscribeRequest = null;
19
19
 
20
20
  const progressCallback = ({ progressResponse }) => setProgress(progressResponse);
21
+
22
+ useEffect(() => {
23
+ if (options.cubejsApi && !options.cubeApi) {
24
+ console.warn('"cubejsApi" is deprecated and will be removed in the following version. Use "cubeApi" instead.');
25
+ }
26
+ }, [options.cubeApi, options.cubejsApi]);
21
27
 
22
28
  async function fetch() {
23
29
  const { resetResultSetOnChange } = options;
24
- const cubejsApi = options.cubejsApi || context?.cubejsApi;
30
+ const cubeApi = options.cubeApi || options.cubejsApi || context?.cubeApi || context?.cubejsApi;
25
31
 
26
- if (!cubejsApi) {
32
+ if (!cubeApi) {
27
33
  throw new Error('Cube API client is not provided');
28
34
  }
29
35
 
@@ -35,7 +41,7 @@ export function useCubeQuery(query, options = {}) {
35
41
  setLoading(true);
36
42
 
37
43
  try {
38
- const response = await cubejsApi.load(query, {
44
+ const response = await cubeApi.load(query, {
39
45
  mutexObj: mutexRef.current,
40
46
  mutexKey: 'query',
41
47
  progressCallback,
@@ -62,9 +68,9 @@ export function useCubeQuery(query, options = {}) {
62
68
  useEffect(() => {
63
69
  const { skip = false, resetResultSetOnChange } = options;
64
70
 
65
- const cubejsApi = options.cubejsApi || context?.cubejsApi;
71
+ const cubeApi = options.cubeApi || options.cubejsApi || context?.cubeApi || context?.cubejsApi;
66
72
 
67
- if (!cubejsApi) {
73
+ if (!cubeApi) {
68
74
  throw new Error('Cube API client is not provided');
69
75
  }
70
76
 
@@ -87,7 +93,7 @@ export function useCubeQuery(query, options = {}) {
87
93
  }
88
94
 
89
95
  if (options.subscribe) {
90
- subscribeRequest = cubejsApi.subscribe(
96
+ subscribeRequest = cubeApi.subscribe(
91
97
  query,
92
98
  {
93
99
  mutexObj: mutexRef.current,