@orpc/tanstack-query 2.0.0-beta.47 → 2.0.0-beta.49
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/README.md +6 -7
- package/dist/contract-utils.d.ts +37 -0
- package/dist/contract-utils.js +42 -0
- package/dist/index.d.ts +16 -541
- package/dist/index.js +10 -0
- package/dist/key.d.ts +50 -0
- package/dist/key.js +50 -0
- package/dist/live-query.d.ts +4 -0
- package/dist/live-query.js +36 -0
- package/dist/meta.d.ts +42 -0
- package/dist/meta.js +55 -0
- package/dist/plugin.d.ts +51 -0
- package/dist/plugin.js +25 -0
- package/dist/procedure-utils.d.ts +167 -0
- package/dist/procedure-utils.js +411 -0
- package/dist/router-utils.d.ts +67 -0
- package/dist/router-utils.js +69 -0
- package/dist/shared-utils.d.ts +11 -0
- package/dist/shared-utils.js +19 -0
- package/dist/ssr.d.ts +37 -0
- package/dist/ssr.js +45 -0
- package/dist/stream-query.d.ts +38 -0
- package/dist/stream-query.js +52 -0
- package/dist/structural-sharing.d.ts +14 -0
- package/dist/structural-sharing.js +160 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +7 -0
- package/package.json +41 -43
- package/dist/index.d.mts +0 -541
- package/dist/index.mjs +0 -821
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Promisable } from '@orpc/shared';
|
|
2
|
+
import type { QueryFunction, QueryFunctionContext, QueryKey } from '@tanstack/query-core';
|
|
3
|
+
export interface SerializableStreamedQueryOptions {
|
|
4
|
+
/**
|
|
5
|
+
* What a fetch does with existing data once its stream connects.
|
|
6
|
+
* Until then the data stays, so a query with data never returns to `pending`.
|
|
7
|
+
*
|
|
8
|
+
* - `'reset'`: the data becomes `[]`, then each chunk is appended.
|
|
9
|
+
* - `'append'`: the data is kept (trimmed to `maxChunks`), and each chunk is appended.
|
|
10
|
+
*
|
|
11
|
+
* @default 'reset'
|
|
12
|
+
*/
|
|
13
|
+
refetchMode?: 'append' | 'reset' | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Limits the number of data chunks stored in the query result.
|
|
16
|
+
* Older chunks are removed when the limit is reached.
|
|
17
|
+
*
|
|
18
|
+
* @default Number.POSITIVE_INFINITY (unlimited)
|
|
19
|
+
*/
|
|
20
|
+
maxChunks?: number | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface SettleOnFirstDataOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Settles the fetch at its first data (streamed: when the stream connects; live: on the first event)
|
|
25
|
+
* instead of following the stream to its end. The stream is closed and the data kept.
|
|
26
|
+
* Use it only where nothing watches the stream, such as server rendering:
|
|
27
|
+
* a refetch while a query is mounted would also settle, closing its stream.
|
|
28
|
+
*
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
settleOnFirstData?: boolean | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A variant of `streamedQuery` where:
|
|
35
|
+
* - Options are serializable
|
|
36
|
+
* - The output is predictable
|
|
37
|
+
*/
|
|
38
|
+
export declare function serializableStreamedQuery<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>(queryFn: (context: QueryFunctionContext<TQueryKey>) => Promisable<AsyncIterable<TQueryFnData>>, { refetchMode, maxChunks, settleOnFirstData, }?: SerializableStreamedQueryOptions & SettleOnFirstDataOptions): QueryFunction<TQueryFnData[], TQueryKey>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { throwIfAborted } from '@orpc/shared';
|
|
2
|
+
/**
|
|
3
|
+
* A variant of `streamedQuery` where:
|
|
4
|
+
* - Options are serializable
|
|
5
|
+
* - The output is predictable
|
|
6
|
+
*/
|
|
7
|
+
export function serializableStreamedQuery(queryFn, { refetchMode = 'reset', maxChunks = Number.POSITIVE_INFINITY, settleOnFirstData = false, } = {}) {
|
|
8
|
+
return async (context) => {
|
|
9
|
+
const { client, queryKey, signal } = context;
|
|
10
|
+
// a stream cut short (cancelled, or its last observer left) reopens when observed again;
|
|
11
|
+
// marked at abort, so the writes of a fetch that replaces this one clear it
|
|
12
|
+
const markStale = () => client.getQueryCache().find({ queryKey, exact: true })?.invalidate();
|
|
13
|
+
if (signal.aborted) {
|
|
14
|
+
markStale();
|
|
15
|
+
}
|
|
16
|
+
signal.addEventListener('abort', markStale, { once: true });
|
|
17
|
+
try {
|
|
18
|
+
const stream = await queryFn(context);
|
|
19
|
+
// close without reading, so a generator the query no longer wants never starts
|
|
20
|
+
if (signal.aborted) {
|
|
21
|
+
await stream[Symbol.asyncIterator]().return?.();
|
|
22
|
+
throw signal.reason;
|
|
23
|
+
}
|
|
24
|
+
let data = client.setQueryData(queryKey, (current) => refetchMode === 'append' && current ? limitArraySize(current, maxChunks) : []);
|
|
25
|
+
if (settleOnFirstData) {
|
|
26
|
+
await stream[Symbol.asyncIterator]().return?.();
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
for await (const chunk of stream) {
|
|
30
|
+
throwIfAborted(signal);
|
|
31
|
+
// read the cache, so writes made during the stream are kept
|
|
32
|
+
data = client.setQueryData(queryKey, (current = []) => limitArraySize([...current, chunk], maxChunks));
|
|
33
|
+
}
|
|
34
|
+
// the returned data is written again, so return the cache to keep later writes
|
|
35
|
+
const cached = client.getQueryData(queryKey);
|
|
36
|
+
if (cached === undefined) {
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
// only an array is trimmed; another value written after the stream (e.g. `null`) is kept as is
|
|
40
|
+
return Array.isArray(cached) ? limitArraySize(cached, maxChunks) : cached;
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
signal.removeEventListener('abort', markStale);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function limitArraySize(items, maxSize) {
|
|
48
|
+
if (items.length <= maxSize) {
|
|
49
|
+
return items;
|
|
50
|
+
}
|
|
51
|
+
return items.slice(items.length - maxSize);
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RPCJsonSerializer } from '@orpc/client';
|
|
2
|
+
import type { Public } from '@orpc/shared';
|
|
3
|
+
export type StructuralSharing = <T>(oldData: unknown, newData: T) => T;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a `structuralSharing` function that works like TanStack Query's default, but also keeps
|
|
6
|
+
* the previous reference for equal `Date`, `URL`, `Map` and `Set` values, which oRPC's serializer
|
|
7
|
+
* recreates on every response, and for custom types that serialize the same with a type-aware
|
|
8
|
+
* serializer like `RPCJsonSerializer`.
|
|
9
|
+
*
|
|
10
|
+
* Used by default in `.queryOptions`, `.liveOptions` and `.infiniteOptions`, pass `structuralSharing: false` to opt out.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#structural-sharing | TanStack Query Integration - Structural Sharing}
|
|
13
|
+
*/
|
|
14
|
+
export declare function createStructuralSharing(serializer?: Public<RPCJsonSerializer>): StructuralSharing;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { setOwn, stringifyJSON } from '@orpc/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a `structuralSharing` function that works like TanStack Query's default, but also keeps
|
|
4
|
+
* the previous reference for equal `Date`, `URL`, `Map` and `Set` values, which oRPC's serializer
|
|
5
|
+
* recreates on every response, and for custom types that serialize the same with a type-aware
|
|
6
|
+
* serializer like `RPCJsonSerializer`.
|
|
7
|
+
*
|
|
8
|
+
* Used by default in `.queryOptions`, `.liveOptions` and `.infiniteOptions`, pass `structuralSharing: false` to opt out.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#structural-sharing | TanStack Query Integration - Structural Sharing}
|
|
11
|
+
*/
|
|
12
|
+
export function createStructuralSharing(serializer) {
|
|
13
|
+
return (oldData, newData) => replaceEqualDeep(oldData, newData, 0, serializer);
|
|
14
|
+
}
|
|
15
|
+
function replaceEqualDeep(a, b, depth, serializer) {
|
|
16
|
+
if (Object.is(a, b)) {
|
|
17
|
+
return a;
|
|
18
|
+
}
|
|
19
|
+
if (depth > 500 || typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
|
|
20
|
+
return b;
|
|
21
|
+
}
|
|
22
|
+
const proto = Object.getPrototypeOf(a);
|
|
23
|
+
if (proto !== Object.getPrototypeOf(b)) {
|
|
24
|
+
return b;
|
|
25
|
+
}
|
|
26
|
+
if ((proto === Date.prototype ||
|
|
27
|
+
proto === URL.prototype ||
|
|
28
|
+
proto === Set.prototype ||
|
|
29
|
+
proto === Map.prototype) &&
|
|
30
|
+
!hasOwnEnumerableKey(a) &&
|
|
31
|
+
!hasOwnEnumerableKey(b)) {
|
|
32
|
+
return replaceEqualBuiltIn(a, b, proto, depth, serializer);
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(a)) {
|
|
35
|
+
return isPlainArray(a) && isPlainArray(b) ? replaceEqualArray(a, b, depth, serializer) : b;
|
|
36
|
+
}
|
|
37
|
+
// same rule as isPlainObject, but reusing the prototype read above is about 15% faster
|
|
38
|
+
if (proto === Object.prototype || proto === null || !proto.constructor) {
|
|
39
|
+
return replaceEqualObject(a, b, proto, depth, serializer);
|
|
40
|
+
}
|
|
41
|
+
return replaceEqualSerialized(a, b, depth, serializer);
|
|
42
|
+
}
|
|
43
|
+
function replaceEqualArray(a, b, depth, serializer) {
|
|
44
|
+
let copy;
|
|
45
|
+
for (let i = 0; i < b.length; i++) {
|
|
46
|
+
let value = b[i];
|
|
47
|
+
if (i < a.length) {
|
|
48
|
+
const aValue = a[i];
|
|
49
|
+
if (typeof aValue === 'object' && typeof value === 'object') {
|
|
50
|
+
value = replaceEqualDeep(aValue, value, depth + 1, serializer);
|
|
51
|
+
}
|
|
52
|
+
if (copy === undefined && Object.is(value, aValue)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
copy ??= copyArrayPrefix(a, i);
|
|
57
|
+
copy.push(value);
|
|
58
|
+
}
|
|
59
|
+
return copy ?? (a.length === b.length ? a : copyArrayPrefix(a, b.length));
|
|
60
|
+
}
|
|
61
|
+
function copyArrayPrefix(a, end) {
|
|
62
|
+
const copy = [];
|
|
63
|
+
for (let i = 0; i < end; i++) {
|
|
64
|
+
copy.push(a[i]);
|
|
65
|
+
}
|
|
66
|
+
return copy;
|
|
67
|
+
}
|
|
68
|
+
function replaceEqualObject(a, b, proto, depth, serializer) {
|
|
69
|
+
const bKeys = Object.keys(b);
|
|
70
|
+
let copy;
|
|
71
|
+
for (let i = 0; i < bKeys.length; i++) {
|
|
72
|
+
const key = bKeys[i];
|
|
73
|
+
let value = b[key];
|
|
74
|
+
if (Object.hasOwn(a, key)) {
|
|
75
|
+
const aValue = a[key];
|
|
76
|
+
if (typeof aValue === 'object' && typeof value === 'object') {
|
|
77
|
+
value = replaceEqualDeep(aValue, value, depth + 1, serializer);
|
|
78
|
+
}
|
|
79
|
+
if (copy === undefined && Object.is(value, aValue)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
copy ??= copyObjectPrefix(a, bKeys, i, proto);
|
|
84
|
+
assign(copy, key, value);
|
|
85
|
+
}
|
|
86
|
+
return (copy ??
|
|
87
|
+
(Object.keys(a).length === bKeys.length ? a : copyObjectPrefix(a, bKeys, bKeys.length, proto)));
|
|
88
|
+
}
|
|
89
|
+
function copyObjectPrefix(a, keys, end, proto) {
|
|
90
|
+
const copy = proto === Object.prototype ? {} : Object.create(proto);
|
|
91
|
+
for (let i = 0; i < end; i++) {
|
|
92
|
+
assign(copy, keys[i], a[keys[i]]);
|
|
93
|
+
}
|
|
94
|
+
return copy;
|
|
95
|
+
}
|
|
96
|
+
function assign(object, key, value) {
|
|
97
|
+
// same as always calling setOwn, but a plain assignment keeps the copy loops about 30% faster
|
|
98
|
+
if (key === '__proto__') {
|
|
99
|
+
setOwn(object, key, value);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
object[key] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function replaceEqualBuiltIn(a, b, proto, depth, serializer) {
|
|
106
|
+
if (proto === Date.prototype) {
|
|
107
|
+
return Object.is(a.getTime(), b.getTime()) ? a : b;
|
|
108
|
+
}
|
|
109
|
+
if (proto === URL.prototype) {
|
|
110
|
+
return a.href === b.href ? a : b;
|
|
111
|
+
}
|
|
112
|
+
if (a.size !== b.size) {
|
|
113
|
+
return b;
|
|
114
|
+
}
|
|
115
|
+
if (proto === Set.prototype) {
|
|
116
|
+
const aValues = a.values();
|
|
117
|
+
for (const bValue of b.values()) {
|
|
118
|
+
const aValue = aValues.next().value;
|
|
119
|
+
if (!Object.is(replaceEqualDeep(aValue, bValue, depth + 1, serializer), aValue)) {
|
|
120
|
+
return b;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return a;
|
|
124
|
+
}
|
|
125
|
+
const aKeys = a.keys();
|
|
126
|
+
const aValues = a.values();
|
|
127
|
+
const bValues = b.values();
|
|
128
|
+
for (const bKey of b.keys()) {
|
|
129
|
+
const aKey = aKeys.next().value;
|
|
130
|
+
const aValue = aValues.next().value;
|
|
131
|
+
if (!Object.is(replaceEqualDeep(aKey, bKey, depth + 1, serializer), aKey) ||
|
|
132
|
+
!Object.is(replaceEqualDeep(aValue, bValues.next().value, depth + 1, serializer), aValue)) {
|
|
133
|
+
return b;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return a;
|
|
137
|
+
}
|
|
138
|
+
function replaceEqualSerialized(a, b, depth, serializer) {
|
|
139
|
+
const aSerialized = serializer?.serializeJson(a);
|
|
140
|
+
if (!aSerialized?.meta?.length) {
|
|
141
|
+
return b;
|
|
142
|
+
}
|
|
143
|
+
const bSerialized = serializer.serializeJson(b);
|
|
144
|
+
return stringifyJSON(aSerialized.meta) === stringifyJSON(bSerialized.meta) &&
|
|
145
|
+
Object.is(replaceEqualDeep(aSerialized.json, bSerialized.json, depth + 1, serializer), aSerialized.json)
|
|
146
|
+
? a
|
|
147
|
+
: b;
|
|
148
|
+
}
|
|
149
|
+
function hasOwnEnumerableKey(value) {
|
|
150
|
+
// for...in avoids the array allocation of Object.keys, which matters on this hot path
|
|
151
|
+
for (const key in value) {
|
|
152
|
+
if (Object.hasOwn(value, key)) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
function isPlainArray(value) {
|
|
159
|
+
return value.length === Object.keys(value).length;
|
|
160
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ClientContext } from '@orpc/client';
|
|
2
|
+
import type { DataTag, InfiniteData, InfiniteQueryObserverOptions, MutationObserverOptions, QueryFunction, QueryKey, QueryObserverOptions, SkipToken } from '@tanstack/query-core';
|
|
3
|
+
import type { SerializableStreamedQueryOptions, SettleOnFirstDataOptions } from './stream-query.ts';
|
|
4
|
+
export type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
5
|
+
export type InferLiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
6
|
+
export type OperationType = 'query' | 'streamed' | 'live' | 'infinite' | 'mutation';
|
|
7
|
+
/**
|
|
8
|
+
* The symbol under which TanStack Query utils attach operation details
|
|
9
|
+
* (key and operation type) to the client context.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#client-context | TanStack Query Integration - Client Context}
|
|
12
|
+
*/
|
|
13
|
+
export declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
14
|
+
/**
|
|
15
|
+
* A client context automatically populated by TanStack Query utils,
|
|
16
|
+
* exposing the operation key and type of the calling operation.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#client-context | TanStack Query Integration - Client Context}
|
|
19
|
+
*/
|
|
20
|
+
export interface OperationContext {
|
|
21
|
+
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
22
|
+
key: QueryKey;
|
|
23
|
+
type: OperationType;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export type QueryKeyOptions<TInput> = (undefined extends TInput ? {
|
|
27
|
+
input?: TInput | SkipToken;
|
|
28
|
+
} : {
|
|
29
|
+
input: TInput | SkipToken;
|
|
30
|
+
}) | {
|
|
31
|
+
queryKey: QueryKey;
|
|
32
|
+
};
|
|
33
|
+
export type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = (undefined extends TInput ? {
|
|
34
|
+
input?: TInput | SkipToken;
|
|
35
|
+
} : {
|
|
36
|
+
input: TInput | SkipToken;
|
|
37
|
+
}) & (object extends TClientContext ? {
|
|
38
|
+
context?: TClientContext | undefined;
|
|
39
|
+
} : {
|
|
40
|
+
context: TClientContext;
|
|
41
|
+
}) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey' | '_defaulted' | '_optimisticResults'> & {
|
|
42
|
+
queryKey?: QueryKey | undefined;
|
|
43
|
+
initialData?: TInitialData;
|
|
44
|
+
};
|
|
45
|
+
export type QueryOptionsOut<TOutput, TError, TSelectData, TInitialData> = Pick<QueryObserverOptions<TOutput, TError, TSelectData, TOutput, DataTag<QueryKey, TOutput, TError>>, 'queryKey' | 'throwOnError' | 'select' | 'retryDelay'> & (undefined extends TInitialData ? object : {
|
|
46
|
+
initialData: TInitialData;
|
|
47
|
+
}) & {
|
|
48
|
+
queryFn: QueryFunction<TOutput, DataTag<QueryKey, TOutput, TError>>;
|
|
49
|
+
};
|
|
50
|
+
export type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
51
|
+
input?: TInput | SkipToken;
|
|
52
|
+
} : {
|
|
53
|
+
input: TInput | SkipToken;
|
|
54
|
+
}) & {
|
|
55
|
+
queryFnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
56
|
+
}) | {
|
|
57
|
+
queryKey: QueryKey;
|
|
58
|
+
};
|
|
59
|
+
export type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & {
|
|
60
|
+
queryFnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
61
|
+
} & SettleOnFirstDataOptions;
|
|
62
|
+
export type StreamedOptionsOut<TOutput, TError, TSelectData, TInitialData> = QueryOptionsOut<TOutput, TError, TSelectData, TInitialData>;
|
|
63
|
+
export type LiveOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & SettleOnFirstDataOptions;
|
|
64
|
+
export type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
|
|
65
|
+
queryKey: QueryKey;
|
|
66
|
+
};
|
|
67
|
+
export type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam, TInitialData> = {
|
|
68
|
+
input: ((pageParam: TPageParam) => TInput) | SkipToken;
|
|
69
|
+
initialData?: TInitialData;
|
|
70
|
+
queryKey?: QueryKey | undefined;
|
|
71
|
+
} & (object extends TClientContext ? {
|
|
72
|
+
context?: TClientContext | undefined;
|
|
73
|
+
} : {
|
|
74
|
+
context: TClientContext;
|
|
75
|
+
}) & Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | '_defaulted' | '_optimisticResults'>;
|
|
76
|
+
export type InfiniteOptionsOut<TOutput, TError, TSelectData, TPageParam, TInitialData> = Pick<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, DataTag<QueryKey, InfiniteData<TOutput, TPageParam>, TError>, TPageParam>, 'queryKey' | 'select' | 'throwOnError' | 'retryDelay' | 'initialPageParam' | 'getNextPageParam' | 'getPreviousPageParam'> & (undefined extends TInitialData ? object : {
|
|
77
|
+
initialData: TInitialData;
|
|
78
|
+
}) & {
|
|
79
|
+
queryFn: QueryFunction<TOutput, DataTag<QueryKey, InfiniteData<TOutput, TPageParam>, TError>, TPageParam>;
|
|
80
|
+
};
|
|
81
|
+
export type MutationKeyOptions = Pick<MutationOptionsIn<any, any, any, any, any>, 'mutationKey'>;
|
|
82
|
+
export type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (object extends TClientContext ? {
|
|
83
|
+
context?: TClientContext | undefined;
|
|
84
|
+
} : {
|
|
85
|
+
context: TClientContext;
|
|
86
|
+
}) & MutationOptionsOut<TInput, TOutput, TError, TMutationContext>;
|
|
87
|
+
export type MutationOptionsOut<TInput, TOutput, TError, TMutationContext> = MutationObserverOptions<TOutput, TError, TInput, TMutationContext>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The symbol under which TanStack Query utils attach operation details
|
|
3
|
+
* (key and operation type) to the client context.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#client-context | TanStack Query Integration - Client Context}
|
|
6
|
+
*/
|
|
7
|
+
export const OPERATION_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for('ORPC_TANSTACK_QUERY_OPERATION_CONTEXT');
|
package/package.json
CHANGED
|
@@ -1,67 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/tanstack-query",
|
|
3
|
-
"
|
|
4
|
-
"version": "2.0.0-beta.47",
|
|
3
|
+
"version": "2.0.0-beta.49",
|
|
5
4
|
"description": "TanStack Query integration for oRPC: typesafe queries, mutations, streaming, and SSR for React, Vue, Solid, Svelte, and Angular",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular-query",
|
|
7
|
+
"mutation",
|
|
8
|
+
"orpc",
|
|
9
|
+
"query",
|
|
10
|
+
"react-query",
|
|
11
|
+
"solid-query",
|
|
12
|
+
"ssr",
|
|
13
|
+
"svelte-query",
|
|
14
|
+
"tanstack-query",
|
|
15
|
+
"typesafe",
|
|
16
|
+
"typescript",
|
|
17
|
+
"vue-query"
|
|
10
18
|
],
|
|
11
19
|
"homepage": "https://orpc.dev",
|
|
20
|
+
"license": "MIT",
|
|
12
21
|
"repository": {
|
|
13
22
|
"type": "git",
|
|
14
23
|
"url": "git+https://github.com/middleapi/orpc.git",
|
|
15
24
|
"directory": "packages/tanstack-query"
|
|
16
25
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"react-query",
|
|
21
|
-
"vue-query",
|
|
22
|
-
"solid-query",
|
|
23
|
-
"svelte-query",
|
|
24
|
-
"angular-query",
|
|
25
|
-
"query",
|
|
26
|
-
"mutation",
|
|
27
|
-
"ssr",
|
|
28
|
-
"typescript",
|
|
29
|
-
"typesafe"
|
|
26
|
+
"funding": [
|
|
27
|
+
"https://github.com/sponsors/dinwwwh",
|
|
28
|
+
"https://opencollective.com/middleapi"
|
|
30
29
|
],
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
31
34
|
"sideEffects": false,
|
|
32
35
|
"exports": {
|
|
33
36
|
"./package.json": "./package.json",
|
|
34
37
|
".": {
|
|
35
|
-
"types": "./dist/index.d.
|
|
36
|
-
"import": "./dist/index.
|
|
37
|
-
"default": "./dist/index.
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js",
|
|
40
|
+
"default": "./dist/index.js"
|
|
38
41
|
}
|
|
39
42
|
},
|
|
40
|
-
"files": [
|
|
41
|
-
"dist"
|
|
42
|
-
],
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"@tanstack/query-core": ">=5.89.0"
|
|
45
|
-
},
|
|
46
43
|
"dependencies": {
|
|
47
|
-
"@orpc/client": "2.0.0-beta.
|
|
48
|
-
"@orpc/contract": "2.0.0-beta.
|
|
49
|
-
"@orpc/openapi": "2.0.0-beta.
|
|
50
|
-
"@orpc/shared": "2.0.0-beta.
|
|
44
|
+
"@orpc/client": "2.0.0-beta.49",
|
|
45
|
+
"@orpc/contract": "2.0.0-beta.49",
|
|
46
|
+
"@orpc/openapi": "2.0.0-beta.49",
|
|
47
|
+
"@orpc/shared": "2.0.0-beta.49"
|
|
51
48
|
},
|
|
52
49
|
"devDependencies": {
|
|
53
|
-
"@angular/core": "^22.2.
|
|
54
|
-
"@tanstack/angular-query-experimental": "^5.
|
|
55
|
-
"@tanstack/query-core": "^5.
|
|
56
|
-
"@tanstack/react-query": "^5.
|
|
57
|
-
"@tanstack/solid-query": "^5.
|
|
58
|
-
"@tanstack/svelte-query": "^6.3.
|
|
59
|
-
"@tanstack/vue-query": "^5.
|
|
60
|
-
"svelte": "^5.57.
|
|
50
|
+
"@angular/core": "^22.2.4",
|
|
51
|
+
"@tanstack/angular-query-experimental": "^5.105.3",
|
|
52
|
+
"@tanstack/query-core": "^5.105.3",
|
|
53
|
+
"@tanstack/react-query": "^5.105.3",
|
|
54
|
+
"@tanstack/solid-query": "^5.105.3",
|
|
55
|
+
"@tanstack/svelte-query": "^6.3.9",
|
|
56
|
+
"@tanstack/vue-query": "^5.105.3",
|
|
57
|
+
"svelte": "^5.57.3",
|
|
61
58
|
"vue": "^3.5.44",
|
|
62
59
|
"zod": "^4.6.7"
|
|
63
60
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
}
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@tanstack/query-core": ">=5.105.0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {}
|
|
67
65
|
}
|