@legendapp/state 3.0.0-beta.1 → 3.0.0-beta.12

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.
Files changed (43) hide show
  1. package/index.d.mts +2 -0
  2. package/index.d.ts +2 -0
  3. package/index.js +9 -3
  4. package/index.mjs +9 -3
  5. package/package.json +7 -1
  6. package/persist-plugins/async-storage.js +17 -9
  7. package/persist-plugins/async-storage.mjs +17 -9
  8. package/react-reactive/enableReactComponents.d.mts +3 -2
  9. package/react-reactive/enableReactComponents.d.ts +3 -2
  10. package/react-reactive/enableReactComponents.js +7 -2
  11. package/react-reactive/enableReactComponents.mjs +7 -2
  12. package/react-reactive/enableReactNativeComponents.d.mts +3 -20
  13. package/react-reactive/enableReactNativeComponents.d.ts +3 -20
  14. package/react-reactive/enableReactNativeComponents.js +8 -3
  15. package/react-reactive/enableReactNativeComponents.mjs +8 -3
  16. package/react-reactive/enableReactive.js +7 -2
  17. package/react-reactive/enableReactive.mjs +7 -2
  18. package/react-reactive/enableReactive.native.js +8 -3
  19. package/react-reactive/enableReactive.native.mjs +8 -3
  20. package/react-reactive/enableReactive.web.js +8 -3
  21. package/react-reactive/enableReactive.web.mjs +8 -3
  22. package/react.d.mts +9 -7
  23. package/react.d.ts +9 -7
  24. package/sync-plugins/crud.d.mts +5 -2
  25. package/sync-plugins/crud.d.ts +5 -2
  26. package/sync-plugins/crud.js +22 -24
  27. package/sync-plugins/crud.mjs +22 -24
  28. package/sync-plugins/keel.js +1 -1
  29. package/sync-plugins/keel.mjs +1 -1
  30. package/sync-plugins/supabase.js +14 -6
  31. package/sync-plugins/supabase.mjs +14 -6
  32. package/sync-plugins/tanstack-query.d.mts +5 -5
  33. package/sync-plugins/tanstack-query.d.ts +5 -5
  34. package/sync-plugins/tanstack-query.js +17 -2
  35. package/sync-plugins/tanstack-query.mjs +17 -2
  36. package/sync-plugins/tanstack-react-query.d.mts +4 -2
  37. package/sync-plugins/tanstack-react-query.d.ts +4 -2
  38. package/sync.js +114 -91
  39. package/sync.mjs +114 -91
  40. package/trace.js +5 -6
  41. package/trace.mjs +5 -6
  42. package/types/reactive-native.d.ts +19 -0
  43. package/types/reactive-web.d.ts +7 -0
@@ -5,11 +5,13 @@ type CrudAsOption = 'Map' | 'object' | 'value' | 'array';
5
5
  type CrudResult<T> = T;
6
6
  interface SyncedCrudPropsSingle<TRemote extends object, TLocal> {
7
7
  get?: (params: SyncedGetParams<TRemote>) => Promise<CrudResult<TRemote | null>> | CrudResult<TRemote | null>;
8
+ list?: never | undefined;
8
9
  initial?: InitialValue<TLocal, 'value'>;
9
10
  as?: never | 'value';
10
11
  }
11
12
  interface SyncedCrudPropsMany<TRemote extends object, TLocal, TAsOption extends CrudAsOption> {
12
13
  list?: (params: SyncedGetParams<TRemote>) => Promise<CrudResult<TRemote[] | null>> | CrudResult<TRemote[] | null>;
14
+ get?: never | undefined;
13
15
  as?: TAsOption;
14
16
  initial?: InitialValue<TLocal, TAsOption>;
15
17
  }
@@ -45,7 +47,8 @@ type SyncedCrudReturnType<TLocal, TAsOption extends CrudAsOption> = TAsOption ex
45
47
  } ? number : string, TLocal> : TAsOption extends 'object' ? Record<TLocal extends {
46
48
  id: number;
47
49
  } ? number : string, TLocal> : TAsOption extends 'value' ? TLocal : TLocal[];
48
- declare function syncedCrud<TRemote extends object, TLocal = TRemote>(props: SyncedCrudPropsBase<TRemote, TLocal> & SyncedCrudPropsSingle<TRemote, TLocal>): SyncedCrudReturnType<TLocal, 'value'>;
49
- declare function syncedCrud<TRemote extends object, TLocal = TRemote, TAsOption extends CrudAsOption = 'object'>(props: SyncedCrudPropsBase<TRemote, TLocal> & SyncedCrudPropsMany<TRemote, TLocal, TAsOption>): SyncedCrudReturnType<TLocal, Exclude<TAsOption, 'value'>>;
50
+ declare function syncedCrud<TRemote extends object, TLocal = TRemote>(props: SyncedCrudPropsSingle<TRemote, TLocal> & SyncedCrudPropsBase<TRemote, TLocal>): SyncedCrudReturnType<TLocal, 'value'>;
51
+ declare function syncedCrud<TRemote extends object, TLocal = TRemote, TAsOption extends CrudAsOption = 'object'>(props: SyncedCrudPropsMany<TRemote, TLocal, TAsOption> & SyncedCrudPropsBase<TRemote, TLocal>): SyncedCrudReturnType<TLocal, Exclude<TAsOption, 'value'>>;
52
+ declare function syncedCrud<TRemote extends object, TLocal = TRemote, TAsOption extends CrudAsOption = 'object'>(props: (SyncedCrudPropsSingle<TRemote, TLocal> | SyncedCrudPropsMany<TRemote, TLocal, TAsOption>) & SyncedCrudPropsBase<TRemote, TLocal>): SyncedCrudReturnType<TLocal, TAsOption>;
50
53
 
51
54
  export { type CrudAsOption, type CrudResult, type SyncedCrudOnSavedParams, type SyncedCrudPropsBase, type SyncedCrudPropsMany, type SyncedCrudPropsSingle, type SyncedCrudReturnType, type WaitForSetCrudFnParams, syncedCrud };
@@ -256,40 +256,38 @@ function syncedCrud(props) {
256
256
  const saveResult = async (itemKey, input, data, isCreate) => {
257
257
  var _a;
258
258
  if (data) {
259
- const saved = (transform == null ? void 0 : transform.load) ? await transform.load(data, "set") : data;
259
+ let saved = (transform == null ? void 0 : transform.load) ? await transform.load(data, "set") : data;
260
260
  const isChild = itemKey !== "undefined" && asType !== "value";
261
261
  const currentPeeked = state.getNodeValue(node);
262
262
  const currentValue = isChild ? (_a = asType === "array" && state.isArray(currentPeeked) ? currentPeeked.find((v) => v[fieldId] === itemKey) : void 0) != null ? _a : currentPeeked[itemKey] : currentPeeked;
263
- const dataOnSaved = {
264
- saved,
265
- input,
266
- currentValue,
267
- isCreate,
268
- props
269
- };
270
- let savedOut = saved;
271
- if (savedOut && !state.isNullOrUndefined(currentValue)) {
272
- savedOut = clone(savedOut);
273
- Object.keys(savedOut).forEach((key) => {
263
+ if (saved && !state.isNullOrUndefined(currentValue)) {
264
+ if (onSaved) {
265
+ const ret = onSaved({
266
+ saved,
267
+ input,
268
+ currentValue,
269
+ isCreate,
270
+ props
271
+ });
272
+ if (ret) {
273
+ saved = ret;
274
+ }
275
+ }
276
+ saved = clone(saved);
277
+ Object.keys(saved).forEach((key) => {
274
278
  const i = input[key];
275
279
  const c = currentValue[key];
276
280
  if (
277
281
  // value is already the new value, can ignore
278
- savedOut[key] === c || // user has changed local value
279
- key !== "id" && i !== c
282
+ saved[key] === c || // user has changed local value
283
+ key !== fieldId && i !== c
280
284
  ) {
281
- delete savedOut[key];
285
+ delete saved[key];
282
286
  }
283
287
  });
284
- if (onSaved) {
285
- const ret = onSaved(dataOnSaved);
286
- if (ret) {
287
- savedOut = ret;
288
- }
289
- }
290
- const createdAt = fieldCreatedAt ? savedOut[fieldCreatedAt] : void 0;
291
- const updatedAt = fieldUpdatedAt ? savedOut[fieldUpdatedAt] : void 0;
292
- const value2 = itemKey !== "undefined" && asType !== "value" ? { [itemKey]: savedOut } : savedOut;
288
+ const createdAt = fieldCreatedAt ? saved[fieldCreatedAt] : void 0;
289
+ const updatedAt = fieldUpdatedAt ? saved[fieldUpdatedAt] : void 0;
290
+ const value2 = itemKey !== "undefined" && asType !== "value" ? { [itemKey]: saved } : saved;
293
291
  update({
294
292
  value: value2,
295
293
  lastSync: updatedAt || createdAt ? +new Date(updatedAt || createdAt) : void 0,
@@ -254,40 +254,38 @@ function syncedCrud(props) {
254
254
  const saveResult = async (itemKey, input, data, isCreate) => {
255
255
  var _a;
256
256
  if (data) {
257
- const saved = (transform == null ? void 0 : transform.load) ? await transform.load(data, "set") : data;
257
+ let saved = (transform == null ? void 0 : transform.load) ? await transform.load(data, "set") : data;
258
258
  const isChild = itemKey !== "undefined" && asType !== "value";
259
259
  const currentPeeked = getNodeValue(node);
260
260
  const currentValue = isChild ? (_a = asType === "array" && isArray(currentPeeked) ? currentPeeked.find((v) => v[fieldId] === itemKey) : void 0) != null ? _a : currentPeeked[itemKey] : currentPeeked;
261
- const dataOnSaved = {
262
- saved,
263
- input,
264
- currentValue,
265
- isCreate,
266
- props
267
- };
268
- let savedOut = saved;
269
- if (savedOut && !isNullOrUndefined(currentValue)) {
270
- savedOut = clone(savedOut);
271
- Object.keys(savedOut).forEach((key) => {
261
+ if (saved && !isNullOrUndefined(currentValue)) {
262
+ if (onSaved) {
263
+ const ret = onSaved({
264
+ saved,
265
+ input,
266
+ currentValue,
267
+ isCreate,
268
+ props
269
+ });
270
+ if (ret) {
271
+ saved = ret;
272
+ }
273
+ }
274
+ saved = clone(saved);
275
+ Object.keys(saved).forEach((key) => {
272
276
  const i = input[key];
273
277
  const c = currentValue[key];
274
278
  if (
275
279
  // value is already the new value, can ignore
276
- savedOut[key] === c || // user has changed local value
277
- key !== "id" && i !== c
280
+ saved[key] === c || // user has changed local value
281
+ key !== fieldId && i !== c
278
282
  ) {
279
- delete savedOut[key];
283
+ delete saved[key];
280
284
  }
281
285
  });
282
- if (onSaved) {
283
- const ret = onSaved(dataOnSaved);
284
- if (ret) {
285
- savedOut = ret;
286
- }
287
- }
288
- const createdAt = fieldCreatedAt ? savedOut[fieldCreatedAt] : void 0;
289
- const updatedAt = fieldUpdatedAt ? savedOut[fieldUpdatedAt] : void 0;
290
- const value2 = itemKey !== "undefined" && asType !== "value" ? { [itemKey]: savedOut } : savedOut;
286
+ const createdAt = fieldCreatedAt ? saved[fieldCreatedAt] : void 0;
287
+ const updatedAt = fieldUpdatedAt ? saved[fieldUpdatedAt] : void 0;
288
+ const value2 = itemKey !== "undefined" && asType !== "value" ? { [itemKey]: saved } : saved;
291
289
  update({
292
290
  value: value2,
293
291
  lastSync: updatedAt || createdAt ? +new Date(updatedAt || createdAt) : void 0,
@@ -274,6 +274,7 @@ function syncedKeel(props) {
274
274
  } : subscribeParam;
275
275
  return crud.syncedCrud({
276
276
  ...rest,
277
+ // Workaround for type errors
277
278
  as: asType,
278
279
  mode: mode || "merge",
279
280
  list,
@@ -299,7 +300,6 @@ function syncedKeel(props) {
299
300
  updatePartial: true,
300
301
  subscribe,
301
302
  generateId: generateKeelId,
302
- // @ts-expect-error This errors because of the get/list union type
303
303
  get
304
304
  });
305
305
  }
@@ -268,6 +268,7 @@ function syncedKeel(props) {
268
268
  } : subscribeParam;
269
269
  return syncedCrud({
270
270
  ...rest,
271
+ // Workaround for type errors
271
272
  as: asType,
272
273
  mode: mode || "merge",
273
274
  list,
@@ -293,7 +294,6 @@ function syncedKeel(props) {
293
294
  updatePartial: true,
294
295
  subscribe,
295
296
  generateId: generateKeelId,
296
- // @ts-expect-error This errors because of the get/list union type
297
297
  get
298
298
  });
299
299
  }
@@ -36,9 +36,9 @@ function syncedSupabase(props) {
36
36
  schema,
37
37
  filter,
38
38
  actions,
39
- fieldCreatedAt: fieldCreatedAtParam,
40
- fieldUpdatedAt: fieldUpdatedAtParam,
41
- fieldDeleted: fieldDeletedParam,
39
+ fieldCreatedAt,
40
+ fieldUpdatedAt,
41
+ fieldDeleted,
42
42
  realtime,
43
43
  changesSince,
44
44
  transform: transformParam,
@@ -54,9 +54,17 @@ function syncedSupabase(props) {
54
54
  ...rest
55
55
  } = props;
56
56
  const client = supabase;
57
- const fieldCreatedAt = fieldCreatedAtParam || (changesSince === "last-sync" ? "created_at" : void 0);
58
- const fieldUpdatedAt = fieldUpdatedAtParam || (changesSince === "last-sync" ? "updated_at" : void 0);
59
- const fieldDeleted = fieldDeletedParam || (changesSince === "last-sync" ? "deleted" : void 0);
57
+ if (process.env.NODE_ENV === "development" && changesSince === "last-sync") {
58
+ if (!fieldCreatedAt) {
59
+ console.warn("[legend-state] fieldCreatedAt is required when using last-sync mode");
60
+ }
61
+ if (!fieldUpdatedAt) {
62
+ console.warn("[legend-state] fieldUpdatedAt is required when using last-sync mode");
63
+ }
64
+ if (!fieldDeleted) {
65
+ console.warn("[legend-state] fieldDeleted is required when using last-sync mode");
66
+ }
67
+ }
60
68
  const list = !actions || actions.includes("read") ? listParam ? wrapSupabaseFn(listParam) : async (params) => {
61
69
  const { lastSync } = params;
62
70
  const clientSchema = schema ? client.schema(schema) : client;
@@ -34,9 +34,9 @@ function syncedSupabase(props) {
34
34
  schema,
35
35
  filter,
36
36
  actions,
37
- fieldCreatedAt: fieldCreatedAtParam,
38
- fieldUpdatedAt: fieldUpdatedAtParam,
39
- fieldDeleted: fieldDeletedParam,
37
+ fieldCreatedAt,
38
+ fieldUpdatedAt,
39
+ fieldDeleted,
40
40
  realtime,
41
41
  changesSince,
42
42
  transform: transformParam,
@@ -52,9 +52,17 @@ function syncedSupabase(props) {
52
52
  ...rest
53
53
  } = props;
54
54
  const client = supabase;
55
- const fieldCreatedAt = fieldCreatedAtParam || (changesSince === "last-sync" ? "created_at" : void 0);
56
- const fieldUpdatedAt = fieldUpdatedAtParam || (changesSince === "last-sync" ? "updated_at" : void 0);
57
- const fieldDeleted = fieldDeletedParam || (changesSince === "last-sync" ? "deleted" : void 0);
55
+ if (process.env.NODE_ENV === "development" && changesSince === "last-sync") {
56
+ if (!fieldCreatedAt) {
57
+ console.warn("[legend-state] fieldCreatedAt is required when using last-sync mode");
58
+ }
59
+ if (!fieldUpdatedAt) {
60
+ console.warn("[legend-state] fieldUpdatedAt is required when using last-sync mode");
61
+ }
62
+ if (!fieldDeleted) {
63
+ console.warn("[legend-state] fieldDeleted is required when using last-sync mode");
64
+ }
65
+ }
58
66
  const list = !actions || actions.includes("read") ? listParam ? wrapSupabaseFn(listParam) : async (params) => {
59
67
  const { lastSync } = params;
60
68
  const clientSchema = schema ? client.schema(schema) : client;
@@ -1,14 +1,14 @@
1
- import { SyncedOptions } from '@legendapp/state/sync';
1
+ import { SyncedOptions, Synced } from '@legendapp/state/sync';
2
2
  import { QueryKey, QueryObserverOptions, QueryClient, MutationObserverOptions, DefaultError } from '@tanstack/query-core';
3
3
 
4
- interface ObservableQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey'> {
4
+ interface ObservableQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<QueryObserverOptions<TQueryFnData, TError, TData, TData, TQueryKey>, 'queryKey'> {
5
5
  queryKey?: TQueryKey | (() => TQueryKey);
6
6
  }
7
- interface SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<SyncedOptions<TData>, 'get' | 'set'> {
7
+ interface SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<SyncedOptions<TData>, 'get' | 'set' | 'retry'> {
8
8
  queryClient: QueryClient;
9
9
  query: ObservableQueryOptions<TQueryFnData, TError, TData, TQueryKey>;
10
- mutation?: MutationObserverOptions<TData, TError, void>;
10
+ mutation?: MutationObserverOptions<TQueryFnData, TError, TData>;
11
11
  }
12
- declare function syncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>): TData;
12
+ declare function syncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>): Synced<TData>;
13
13
 
14
14
  export { type ObservableQueryOptions, type SyncedQueryParams, syncedQuery };
@@ -1,14 +1,14 @@
1
- import { SyncedOptions } from '@legendapp/state/sync';
1
+ import { SyncedOptions, Synced } from '@legendapp/state/sync';
2
2
  import { QueryKey, QueryObserverOptions, QueryClient, MutationObserverOptions, DefaultError } from '@tanstack/query-core';
3
3
 
4
- interface ObservableQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey'> {
4
+ interface ObservableQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<QueryObserverOptions<TQueryFnData, TError, TData, TData, TQueryKey>, 'queryKey'> {
5
5
  queryKey?: TQueryKey | (() => TQueryKey);
6
6
  }
7
- interface SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<SyncedOptions<TData>, 'get' | 'set'> {
7
+ interface SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey extends QueryKey> extends Omit<SyncedOptions<TData>, 'get' | 'set' | 'retry'> {
8
8
  queryClient: QueryClient;
9
9
  query: ObservableQueryOptions<TQueryFnData, TError, TData, TQueryKey>;
10
- mutation?: MutationObserverOptions<TData, TError, void>;
10
+ mutation?: MutationObserverOptions<TQueryFnData, TError, TData>;
11
11
  }
12
- declare function syncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>): TData;
12
+ declare function syncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>): Synced<TData>;
13
13
 
14
14
  export { type ObservableQueryOptions, type SyncedQueryParams, syncedQuery };
@@ -5,8 +5,14 @@ var sync = require('@legendapp/state/sync');
5
5
  var queryCore = require('@tanstack/query-core');
6
6
 
7
7
  // src/sync-plugins/tanstack-query.ts
8
+ var nextMutationKey = 0;
8
9
  function syncedQuery(params) {
9
- const { query: options, mutation: mutationOptions, queryClient, ...rest } = params;
10
+ const { query: options, mutation: mutationOptions, queryClient, initial: initialParam, ...rest } = params;
11
+ if (initialParam !== void 0) {
12
+ const initialValue = state.isFunction(initialParam) ? initialParam() : initialParam;
13
+ options.initialData = initialValue;
14
+ }
15
+ const initial = options.initialData;
10
16
  const Observer = queryCore.QueryObserver;
11
17
  const defaultedOptions = queryClient.defaultQueryOptions(
12
18
  options
@@ -66,8 +72,16 @@ function syncedQuery(params) {
66
72
  };
67
73
  let set = void 0;
68
74
  if (mutationOptions) {
69
- const mutator = new queryCore.MutationObserver(queryClient, mutationOptions);
75
+ const options2 = {
76
+ mutationKey: ["LS-mutation", nextMutationKey++],
77
+ ...mutationOptions
78
+ };
79
+ const mutator = new queryCore.MutationObserver(queryClient, options2);
70
80
  set = ({ value }) => {
81
+ const mutationCache = queryClient.getMutationCache();
82
+ mutationCache.findAll({ mutationKey: options2.mutationKey }).forEach((mutation) => {
83
+ mutationCache.remove(mutation);
84
+ });
71
85
  return mutator.mutate(value);
72
86
  };
73
87
  }
@@ -75,6 +89,7 @@ function syncedQuery(params) {
75
89
  get,
76
90
  set,
77
91
  subscribe,
92
+ initial,
78
93
  ...rest
79
94
  });
80
95
  }
@@ -3,8 +3,14 @@ import { synced } from '@legendapp/state/sync';
3
3
  import { MutationObserver, QueryObserver, notifyManager } from '@tanstack/query-core';
4
4
 
5
5
  // src/sync-plugins/tanstack-query.ts
6
+ var nextMutationKey = 0;
6
7
  function syncedQuery(params) {
7
- const { query: options, mutation: mutationOptions, queryClient, ...rest } = params;
8
+ const { query: options, mutation: mutationOptions, queryClient, initial: initialParam, ...rest } = params;
9
+ if (initialParam !== void 0) {
10
+ const initialValue = isFunction(initialParam) ? initialParam() : initialParam;
11
+ options.initialData = initialValue;
12
+ }
13
+ const initial = options.initialData;
8
14
  const Observer = QueryObserver;
9
15
  const defaultedOptions = queryClient.defaultQueryOptions(
10
16
  options
@@ -64,8 +70,16 @@ function syncedQuery(params) {
64
70
  };
65
71
  let set = void 0;
66
72
  if (mutationOptions) {
67
- const mutator = new MutationObserver(queryClient, mutationOptions);
73
+ const options2 = {
74
+ mutationKey: ["LS-mutation", nextMutationKey++],
75
+ ...mutationOptions
76
+ };
77
+ const mutator = new MutationObserver(queryClient, options2);
68
78
  set = ({ value }) => {
79
+ const mutationCache = queryClient.getMutationCache();
80
+ mutationCache.findAll({ mutationKey: options2.mutationKey }).forEach((mutation) => {
81
+ mutationCache.remove(mutation);
82
+ });
69
83
  return mutator.mutate(value);
70
84
  };
71
85
  }
@@ -73,6 +87,7 @@ function syncedQuery(params) {
73
87
  get,
74
88
  set,
75
89
  subscribe,
90
+ initial,
76
91
  ...rest
77
92
  });
78
93
  }
@@ -1,8 +1,10 @@
1
1
  import { SyncedQueryParams } from '@legendapp/state/sync-plugins/tanstack-query';
2
- import { DefaultError, QueryKey } from '@tanstack/query-core';
2
+ import { DefaultError, QueryKey, QueryClient } from '@tanstack/query-core';
3
3
  import { Observable } from '@legendapp/state';
4
4
  import { Synced } from '@legendapp/state/sync';
5
5
 
6
- declare function useObservableSyncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>): Observable<Synced<TData>>;
6
+ declare function useObservableSyncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: Omit<SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>, 'queryClient'> & {
7
+ queryClient?: QueryClient;
8
+ }): Observable<Synced<TData>>;
7
9
 
8
10
  export { useObservableSyncedQuery };
@@ -1,8 +1,10 @@
1
1
  import { SyncedQueryParams } from '@legendapp/state/sync-plugins/tanstack-query';
2
- import { DefaultError, QueryKey } from '@tanstack/query-core';
2
+ import { DefaultError, QueryKey, QueryClient } from '@tanstack/query-core';
3
3
  import { Observable } from '@legendapp/state';
4
4
  import { Synced } from '@legendapp/state/sync';
5
5
 
6
- declare function useObservableSyncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>): Observable<Synced<TData>>;
6
+ declare function useObservableSyncedQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(params: Omit<SyncedQueryParams<TQueryFnData, TError, TData, TQueryKey>, 'queryClient'> & {
7
+ queryClient?: QueryClient;
8
+ }): Observable<Synced<TData>>;
7
9
 
8
10
  export { useObservableSyncedQuery };