on-zero 0.4.38 → 0.4.41
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/cjs/createUseQuery.cjs +24 -5
- package/dist/cjs/createUseQuery.native.js +26 -5
- package/dist/cjs/createUseQuery.native.js.map +1 -1
- package/dist/cjs/createUseQueryDirect.cjs +17 -17
- package/dist/cjs/createUseQueryDirect.native.js +25 -19
- package/dist/cjs/createUseQueryDirect.native.js.map +1 -1
- package/dist/cjs/createZeroClient.cjs +34 -30
- package/dist/cjs/createZeroClient.native.js +5 -1
- package/dist/cjs/createZeroClient.native.js.map +1 -1
- package/dist/cjs/multiInstanceNested.test.cjs +1 -0
- package/dist/cjs/multiInstanceNested.test.native.js +1 -0
- package/dist/cjs/multiInstanceNested.test.native.js.map +1 -1
- package/dist/cjs/useQuery.empty.test.cjs +70 -0
- package/dist/cjs/useQuery.empty.test.native.js +87 -0
- package/dist/cjs/useQuery.empty.test.native.js.map +1 -0
- package/dist/esm/createUseQuery.mjs +24 -6
- package/dist/esm/createUseQuery.mjs.map +1 -1
- package/dist/esm/createUseQuery.native.js +26 -6
- package/dist/esm/createUseQuery.native.js.map +1 -1
- package/dist/esm/createUseQueryDirect.mjs +18 -18
- package/dist/esm/createUseQueryDirect.mjs.map +1 -1
- package/dist/esm/createUseQueryDirect.native.js +26 -20
- package/dist/esm/createUseQueryDirect.native.js.map +1 -1
- package/dist/esm/createZeroClient.mjs +34 -30
- package/dist/esm/createZeroClient.mjs.map +1 -1
- package/dist/esm/createZeroClient.native.js +5 -1
- package/dist/esm/createZeroClient.native.js.map +1 -1
- package/dist/esm/multiInstanceNested.test.mjs +1 -0
- package/dist/esm/multiInstanceNested.test.mjs.map +1 -1
- package/dist/esm/multiInstanceNested.test.native.js +1 -0
- package/dist/esm/multiInstanceNested.test.native.js.map +1 -1
- package/dist/esm/useQuery.empty.test.mjs +71 -0
- package/dist/esm/useQuery.empty.test.mjs.map +1 -0
- package/dist/esm/useQuery.empty.test.native.js +85 -0
- package/dist/esm/useQuery.empty.test.native.js.map +1 -0
- package/package.json +2 -2
- package/src/createUseQuery.tsx +49 -10
- package/src/createUseQueryDirect.tsx +30 -15
- package/src/createZeroClient.tsx +14 -4
- package/src/multiInstanceNested.test.tsx +3 -0
- package/src/useQuery.empty.test.tsx +98 -0
- package/types/createUseQuery.d.ts +3 -0
- package/types/createUseQuery.d.ts.map +1 -1
- package/types/createUseQueryDirect.d.ts.map +1 -1
- package/types/createZeroClient.d.ts.map +1 -1
- package/types/useQuery.empty.test.d.ts +5 -0
- package/types/useQuery.empty.test.d.ts.map +1 -0
package/src/createUseQuery.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useQuery as zeroUseQuery } from '@rocicorp/zero/react'
|
|
2
|
+
import { addContextToQuery, asQueryInternals } from '@rocicorp/zero/bindings'
|
|
2
3
|
import { useContext, useMemo, useRef, type Context } from 'react'
|
|
3
4
|
|
|
4
5
|
import { useZeroDebug } from './helpers/useZeroDebug'
|
|
@@ -11,7 +12,7 @@ import type {
|
|
|
11
12
|
Schema as ZeroSchema,
|
|
12
13
|
} from '@rocicorp/zero'
|
|
13
14
|
|
|
14
|
-
// false = enabled, 'empty' = disabled (return
|
|
15
|
+
// false = enabled, 'empty' = disabled (return empty), 'last-value' = disabled (return cached)
|
|
15
16
|
export type QueryControlMode = false | 'empty' | 'last-value'
|
|
16
17
|
|
|
17
18
|
export type UseQueryOptions = {
|
|
@@ -39,7 +40,32 @@ export type UseQueryHook<Schema extends ZeroSchema> = {
|
|
|
39
40
|
): QueryResult<TReturn>
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
// shape the "empty" / loading / disabled response to match the typed contract:
|
|
44
|
+
// plural queries get [], singular queries get undefined. returning null for a
|
|
45
|
+
// plural query (the old `EMPTY_RESPONSE` constant) broke callers that do the
|
|
46
|
+
// obvious .filter / .find / .length on the result during the first render.
|
|
47
|
+
const EMPTY_PLURAL = Object.freeze([])
|
|
48
|
+
const RESULT_UNKNOWN = Object.freeze({ type: 'unknown' as const })
|
|
49
|
+
const EMPTY_RESPONSE_PLURAL = Object.freeze([EMPTY_PLURAL, RESULT_UNKNOWN]) as never
|
|
50
|
+
const EMPTY_RESPONSE_SINGULAR = Object.freeze([undefined, RESULT_UNKNOWN]) as never
|
|
51
|
+
|
|
52
|
+
// inspect a resolved query (a Query OR a QueryRequest, i.e. what resolveQuery
|
|
53
|
+
// returns from a defineQueries-registered fn) to find its singular/plural
|
|
54
|
+
// format. QueryRequests carry a `.query.fn({args, ctx})` that materializes
|
|
55
|
+
// the underlying Query — singular vs plural is determined entirely by the
|
|
56
|
+
// user-authored query body (`.one()` vs not), so passing an empty `ctx` is
|
|
57
|
+
// safe here.
|
|
58
|
+
export function emptyResponseFor(queryRequest: unknown): readonly [unknown, { type: string }] {
|
|
59
|
+
try {
|
|
60
|
+
const query = addContextToQuery(queryRequest as any, {} as never)
|
|
61
|
+
const internals = asQueryInternals(query)
|
|
62
|
+
return internals.format.singular ? EMPTY_RESPONSE_SINGULAR : EMPTY_RESPONSE_PLURAL
|
|
63
|
+
} catch {
|
|
64
|
+
// SSG factory / no-resolved-query — default to plural so callers' iteration
|
|
65
|
+
// (.filter / .find / .length / for-of) is always safe.
|
|
66
|
+
return EMPTY_RESPONSE_PLURAL
|
|
67
|
+
}
|
|
68
|
+
}
|
|
43
69
|
|
|
44
70
|
// determine if useQuery-style args are (fn, params, options) or (fn, options)
|
|
45
71
|
export function parseUseQueryArgs(paramsOrOptions: any, optionsArg: any) {
|
|
@@ -63,15 +89,22 @@ export function createUseQuery<Schema extends ZeroSchema>({
|
|
|
63
89
|
DisabledContext: Context<QueryControlMode>
|
|
64
90
|
customQueries: AnyQueryRegistry
|
|
65
91
|
}): UseQueryHook<Schema> {
|
|
92
|
+
// SSG: return an inert hook. on-zero's bundled React copy isn't the same
|
|
93
|
+
// one the SSG build's renderer initialises, so hook dispatch returns null.
|
|
94
|
+
// an empty response matches how the wrapper behaves under DisabledContext
|
|
95
|
+
// anyway, so consumers see the same shape across SSG and the disabled
|
|
96
|
+
// client path. checking here (factory-time) instead of per-call keeps
|
|
97
|
+
// hook order stable so rules-of-hooks stays happy. we default to the plural
|
|
98
|
+
// shape (data = []) because most queries are plural; a singular query under
|
|
99
|
+
// SSG that depends on undefined-vs-[] is exotic enough to handle at the call
|
|
100
|
+
// site.
|
|
101
|
+
if (typeof window === 'undefined') {
|
|
102
|
+
return (() => EMPTY_RESPONSE_PLURAL) as UseQueryHook<Schema>
|
|
103
|
+
}
|
|
104
|
+
|
|
66
105
|
function useQuery(...args: any[]): any {
|
|
67
|
-
// SSG: skip every hook below. on-zero's bundled React copy isn't the same
|
|
68
|
-
// one the SSG build's renderer initialises, so hook dispatch returns null.
|
|
69
|
-
// an empty response matches how the wrapper behaves under DisabledContext
|
|
70
|
-
// anyway, so consumers see the same shape across SSG and the disabled
|
|
71
|
-
// client path.
|
|
72
|
-
if (typeof window === 'undefined') return EMPTY_RESPONSE
|
|
73
106
|
const disableMode = useContext(DisabledContext)
|
|
74
|
-
const lastRef = useRef<any>(
|
|
107
|
+
const lastRef = useRef<any>(EMPTY_RESPONSE_PLURAL)
|
|
75
108
|
const [fn, paramsOrOptions, optionsArg] = args
|
|
76
109
|
|
|
77
110
|
const { queryRequest, options } = useMemo(() => {
|
|
@@ -106,10 +139,16 @@ export function createUseQuery<Schema extends ZeroSchema>({
|
|
|
106
139
|
}
|
|
107
140
|
|
|
108
141
|
if (disableMode === 'last-value') {
|
|
142
|
+
// first render under last-value mode: lastRef is still the plural default —
|
|
143
|
+
// reshape to match this query's actual format so a singular query gets
|
|
144
|
+
// undefined instead of [].
|
|
145
|
+
if (lastRef.current === EMPTY_RESPONSE_PLURAL) {
|
|
146
|
+
return emptyResponseFor(queryRequest)
|
|
147
|
+
}
|
|
109
148
|
return lastRef.current
|
|
110
149
|
}
|
|
111
150
|
|
|
112
|
-
return
|
|
151
|
+
return emptyResponseFor(queryRequest)
|
|
113
152
|
}
|
|
114
153
|
|
|
115
154
|
return useQuery as UseQueryHook<Schema>
|
|
@@ -8,6 +8,7 @@ import { useEmitterValue, type Emitter } from '@take-out/helpers'
|
|
|
8
8
|
import { useContext, useMemo, useRef, useSyncExternalStore, type Context } from 'react'
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
+
emptyResponseFor,
|
|
11
12
|
parseUseQueryArgs,
|
|
12
13
|
type QueryControlMode,
|
|
13
14
|
type UseQueryHook,
|
|
@@ -25,13 +26,10 @@ import type {
|
|
|
25
26
|
// useQuery path via createZeroClient; this exists only for nested providers
|
|
26
27
|
// where a non-innermost instance cannot be selected through react context.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
// see createUseQuery.tsx — empty responses must match the typed contract:
|
|
30
|
+
// plural queries get [], singular get undefined. returning null breaks the
|
|
31
|
+
// obvious .filter / .find / .length on first render.
|
|
29
32
|
const DISABLED_SUBSCRIBE = () => () => {}
|
|
30
|
-
const DISABLED_SNAPSHOT: readonly [undefined, { type: 'unknown' }] = [
|
|
31
|
-
undefined,
|
|
32
|
-
{ type: 'unknown' },
|
|
33
|
-
]
|
|
34
|
-
const getDisabledSnapshot = () => DISABLED_SNAPSHOT
|
|
35
33
|
|
|
36
34
|
type DirectSnapshot = readonly [unknown, { type: string }]
|
|
37
35
|
|
|
@@ -255,13 +253,17 @@ export function createUseQueryDirect<Schema extends ZeroSchema>({
|
|
|
255
253
|
getZero,
|
|
256
254
|
zeroVersion,
|
|
257
255
|
}: Parameters<CreateUseQueryDirect<Schema>>[0]): UseQueryHook<Schema> {
|
|
256
|
+
// SSG: return an inert hook — see createUseQuery for the rationale. default
|
|
257
|
+
// to the plural empty shape (most queries are plural; a singular caller can
|
|
258
|
+
// tolerate [] better than the non-singular caller can tolerate null/undefined).
|
|
259
|
+
if (typeof window === 'undefined') {
|
|
260
|
+
return ((_fn: any) => emptyResponseFor(undefined)) as UseQueryHook<Schema>
|
|
261
|
+
}
|
|
262
|
+
|
|
258
263
|
const directViewStore = new DirectViewStore()
|
|
259
264
|
|
|
260
265
|
function useQueryDirect(...args: any[]): any {
|
|
261
|
-
// SSG: skip every hook below — see createUseQuery for the rationale.
|
|
262
|
-
if (typeof window === 'undefined') return EMPTY_RESPONSE
|
|
263
266
|
const disableMode = useContext(DisabledContext)
|
|
264
|
-
const lastRef = useRef<any>(EMPTY_RESPONSE)
|
|
265
267
|
const [fn, paramsOrOptions, optionsArg] = args
|
|
266
268
|
|
|
267
269
|
const version = useEmitterValue(zeroVersion)
|
|
@@ -278,19 +280,32 @@ export function createUseQueryDirect<Schema extends ZeroSchema>({
|
|
|
278
280
|
|
|
279
281
|
const paramsKey = params === undefined ? '' : JSON.stringify(params)
|
|
280
282
|
|
|
283
|
+
// resolve the query once so we know its singular/plural format up front —
|
|
284
|
+
// the no-zero / disabled snapshot needs to match that format so .filter /
|
|
285
|
+
// .find / .length is safe on first render.
|
|
286
|
+
const queryRequest = useMemo(
|
|
287
|
+
() => resolveQuery({ customQueries, fn, params }),
|
|
288
|
+
// params is keyed by paramsKey
|
|
289
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
290
|
+
[fn, paramsKey],
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
const emptyForQuery = useMemo(() => emptyResponseFor(queryRequest), [queryRequest])
|
|
294
|
+
const lastRef = useRef<any>(emptyForQuery)
|
|
295
|
+
|
|
281
296
|
const view = useMemo((): DirectView | null => {
|
|
282
297
|
const zero = getZero()
|
|
283
298
|
if (!zero) return null
|
|
284
|
-
const queryRequest = resolveQuery({ customQueries, fn, params })
|
|
285
299
|
return directViewStore.getView(zero, queryRequest, enabled, ttl)
|
|
286
|
-
//
|
|
300
|
+
// version re-materializes on a new zero
|
|
287
301
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
288
|
-
}, [
|
|
302
|
+
}, [queryRequest, enabled, ttl, version])
|
|
289
303
|
|
|
304
|
+
const getEmpty = () => emptyForQuery as DirectSnapshot
|
|
290
305
|
const out = useSyncExternalStore(
|
|
291
306
|
view ? view.subscribe : DISABLED_SUBSCRIBE,
|
|
292
|
-
view ? view.getSnapshot :
|
|
293
|
-
view ? view.getSnapshot :
|
|
307
|
+
view ? view.getSnapshot : getEmpty,
|
|
308
|
+
view ? view.getSnapshot : getEmpty,
|
|
294
309
|
)
|
|
295
310
|
|
|
296
311
|
if (!disableMode) {
|
|
@@ -302,7 +317,7 @@ export function createUseQueryDirect<Schema extends ZeroSchema>({
|
|
|
302
317
|
return lastRef.current
|
|
303
318
|
}
|
|
304
319
|
|
|
305
|
-
return
|
|
320
|
+
return emptyForQuery
|
|
306
321
|
}
|
|
307
322
|
|
|
308
323
|
return useQueryDirect as UseQueryHook<Schema>
|
package/src/createZeroClient.tsx
CHANGED
|
@@ -299,15 +299,24 @@ export function createZeroClientInternal<
|
|
|
299
299
|
// permissionStrategy controls client behavior before server responds.
|
|
300
300
|
// built over a query hook so the facade can route permission checks down
|
|
301
301
|
// the same context vs direct path as the table's other queries.
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
// SSG: return an inert hook — see createUseQuery for rationale. checking
|
|
303
|
+
// here (factory-time) instead of per-call keeps hook order stable so
|
|
304
|
+
// rules-of-hooks stays happy.
|
|
305
|
+
const createUsePermission = (useQueryImpl: UseQueryHook<Schema>) => {
|
|
306
|
+
if (typeof window === 'undefined') {
|
|
307
|
+
return (() => null) as (
|
|
308
|
+
table: TableName | (string & {}),
|
|
309
|
+
objOrId: string | Partial<Row<any>> | undefined,
|
|
310
|
+
enabled?: boolean,
|
|
311
|
+
debug?: boolean,
|
|
312
|
+
) => boolean | null
|
|
313
|
+
}
|
|
314
|
+
return function usePermission(
|
|
304
315
|
table: TableName | (string & {}),
|
|
305
316
|
objOrId: string | Partial<Row<any>> | undefined,
|
|
306
317
|
enabled = typeof objOrId !== 'undefined',
|
|
307
318
|
debug = false,
|
|
308
319
|
): boolean | null {
|
|
309
|
-
// SSG: skip every hook below — see createUseQuery for rationale.
|
|
310
|
-
if (typeof window === 'undefined') return null
|
|
311
320
|
const disableMode = useContext(DisabledContext)
|
|
312
321
|
const lastRef = useRef<boolean | null>(null)
|
|
313
322
|
const tableStr = table as string
|
|
@@ -344,6 +353,7 @@ export function createZeroClientInternal<
|
|
|
344
353
|
|
|
345
354
|
return null
|
|
346
355
|
}
|
|
356
|
+
}
|
|
347
357
|
|
|
348
358
|
const usePermission = createUsePermission(useQuery)
|
|
349
359
|
const usePermissionDirect = createUsePermission(useQueryDirect)
|
|
@@ -142,6 +142,9 @@ function ControlUserProbe({ id, ttl }: { id: string; ttl?: number }) {
|
|
|
142
142
|
|
|
143
143
|
function MaterializeProbe() {
|
|
144
144
|
const zero = useZero() as any
|
|
145
|
+
// ProvideZero hands children a stub Zero (no .materialize) until the real
|
|
146
|
+
// instance is created in an effect. skip on the stub render.
|
|
147
|
+
if (typeof zero.materialize !== 'function') return null
|
|
145
148
|
if (!zero.__onZeroMaterializeProbe) {
|
|
146
149
|
zero.__onZeroMaterializeProbe = true
|
|
147
150
|
const materialize = zero.materialize.bind(zero)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
//
|
|
3
|
+
// useQuery's typed contract is `[T[], info]` for plural queries. The empty /
|
|
4
|
+
// loading / disabled response MUST therefore be `[[], info]` — returning
|
|
5
|
+
// `[null, info]` (the old EMPTY_RESPONSE constant) broke any caller that does
|
|
6
|
+
// the obvious .filter / .find / .length / for-of on first render. Singular
|
|
7
|
+
// queries get `[undefined, info]` instead (the established zero-react shape).
|
|
8
|
+
|
|
9
|
+
import { createSchema, number, string, table } from '@rocicorp/zero'
|
|
10
|
+
import { act } from 'react'
|
|
11
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
12
|
+
import { afterEach, beforeEach, expect, test } from 'vitest'
|
|
13
|
+
|
|
14
|
+
import { createZeroClient } from './createZeroClient'
|
|
15
|
+
import { zql } from './zql'
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
// eslint-disable-next-line no-var
|
|
19
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
20
|
+
}
|
|
21
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
|
22
|
+
|
|
23
|
+
const todoTable = table('todo')
|
|
24
|
+
.columns({ id: string(), title: string(), createdAt: number() })
|
|
25
|
+
.primaryKey('id')
|
|
26
|
+
const schema = createSchema({ tables: [todoTable] })
|
|
27
|
+
|
|
28
|
+
// real plain query functions backed by zql so resolveQuery returns a real
|
|
29
|
+
// QueryRequest (asQueryInternals(...).format.singular works).
|
|
30
|
+
const allTodos = (_args: void) =>
|
|
31
|
+
(zql as unknown as { todo: { orderBy: (k: string, d: string) => any } }).todo.orderBy(
|
|
32
|
+
'createdAt',
|
|
33
|
+
'desc',
|
|
34
|
+
)
|
|
35
|
+
const oneTodo = (args: { id: string }) =>
|
|
36
|
+
(zql as unknown as { todo: { where: (k: string, v: string) => any } }).todo
|
|
37
|
+
.where('id', args.id)
|
|
38
|
+
.one()
|
|
39
|
+
|
|
40
|
+
const client = createZeroClient({
|
|
41
|
+
schema,
|
|
42
|
+
models: {},
|
|
43
|
+
groupedQueries: {
|
|
44
|
+
todo: { allTodos, oneTodo },
|
|
45
|
+
},
|
|
46
|
+
instanceName: 'empty-shape-test',
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
let container: HTMLDivElement
|
|
50
|
+
let root: Root
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
container = document.createElement('div')
|
|
54
|
+
root = createRoot(container)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
act(() => root.unmount())
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
function renderWithDisabled<T>(useHook: () => T): T {
|
|
62
|
+
let captured: T | undefined
|
|
63
|
+
const Probe = () => {
|
|
64
|
+
captured = useHook()
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
act(() => {
|
|
68
|
+
// disable=true mounts the stable shell with DisabledContext='empty' + a
|
|
69
|
+
// stub Zero — this is exactly the path that used to return [null, ...]
|
|
70
|
+
// for every query.
|
|
71
|
+
root.render(
|
|
72
|
+
<client.ProvideZero authData={{}} userID="anon" disable>
|
|
73
|
+
<Probe />
|
|
74
|
+
</client.ProvideZero>,
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
if (captured === undefined) throw new Error('Probe did not render')
|
|
78
|
+
return captured
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// regression: previously this returned [null, ...] which crashed downstream
|
|
82
|
+
// .filter / .find / .length. now it must return [[], ...] for plural queries.
|
|
83
|
+
test('useQuery returns [] (not null) for plural queries under DisabledContext', () => {
|
|
84
|
+
const [data, info] = renderWithDisabled(() => client.useQuery(allTodos))
|
|
85
|
+
expect(Array.isArray(data)).toBe(true)
|
|
86
|
+
expect((data as unknown[]).length).toBe(0)
|
|
87
|
+
// method calls that previously crashed must not crash
|
|
88
|
+
expect((data as unknown[]).filter(() => true)).toEqual([])
|
|
89
|
+
expect((data as unknown[]).find(() => true)).toBeUndefined()
|
|
90
|
+
expect(info?.type).toBe('unknown')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('useQuery returns undefined (not null) for singular queries under DisabledContext', () => {
|
|
94
|
+
const [data, info] = renderWithDisabled(() => client.useQuery(oneTodo, { id: 'x' }))
|
|
95
|
+
// singular queries match zero-react: data is undefined while loading/disabled.
|
|
96
|
+
expect(data).toBeUndefined()
|
|
97
|
+
expect(info?.type).toBe('unknown')
|
|
98
|
+
})
|
|
@@ -14,6 +14,9 @@ export type UseQueryHook<Schema extends ZeroSchema> = {
|
|
|
14
14
|
<TArg, TTable extends keyof Schema['tables'] & string, TReturn>(fn: PlainQueryFn<TArg, Query<TTable, Schema, TReturn>>, params: TArg, options?: UseQueryOptions | boolean): QueryResult<TReturn>;
|
|
15
15
|
<TTable extends keyof Schema['tables'] & string, TReturn>(fn: PlainQueryFn<void, Query<TTable, Schema, TReturn>>, options?: UseQueryOptions | boolean): QueryResult<TReturn>;
|
|
16
16
|
};
|
|
17
|
+
export declare function emptyResponseFor(queryRequest: unknown): readonly [unknown, {
|
|
18
|
+
type: string;
|
|
19
|
+
}];
|
|
17
20
|
export declare function parseUseQueryArgs(paramsOrOptions: any, optionsArg: any): {
|
|
18
21
|
params: any;
|
|
19
22
|
options: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseQuery.d.ts","sourceRoot":"","sources":["../src/createUseQuery.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"createUseQuery.d.ts","sourceRoot":"","sources":["../src/createUseQuery.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE/D,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,OAAO,CAAA;AAGjE,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,MAAM,IAAI,UAAU,EACrB,MAAM,gBAAgB,CAAA;AAGvB,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,OAAO,GAAG,YAAY,CAAA;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,GAAG,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;CAC9C,CAAA;AAED,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5D,MAAM,MAAM,WAAW,CAAC,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAA;AAEx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