@orpc/tanstack-query 2.0.0-beta.48 → 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 +4 -4
- package/dist/contract-utils.d.ts +37 -0
- package/dist/contract-utils.js +42 -0
- package/dist/index.d.ts +16 -0
- 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 +39 -41
- package/dist/contract-utils.d.mts +0 -35
- package/dist/contract-utils.mjs +0 -23
- package/dist/index.d.mts +0 -16
- package/dist/index.mjs +0 -10
- package/dist/key.d.mts +0 -62
- package/dist/key.mjs +0 -30
- package/dist/live-query.d.mts +0 -6
- package/dist/live-query.mjs +0 -16
- package/dist/meta.d.mts +0 -55
- package/dist/meta.mjs +0 -37
- package/dist/plugin.d.mts +0 -51
- package/dist/plugin.mjs +0 -25
- package/dist/procedure-utils.d.mts +0 -232
- package/dist/procedure-utils.mjs +0 -406
- package/dist/router-utils.d.mts +0 -57
- package/dist/router-utils.mjs +0 -51
- package/dist/shared-utils.d.mts +0 -11
- package/dist/shared-utils.mjs +0 -17
- package/dist/ssr.d.mts +0 -38
- package/dist/ssr.mjs +0 -57
- package/dist/stream-query.d.mts +0 -30
- package/dist/stream-query.mjs +0 -58
- package/dist/structural-sharing.d.mts +0 -14
- package/dist/structural-sharing.mjs +0 -140
- package/dist/types.d.mts +0 -138
- package/dist/types.mjs +0 -2
package/dist/live-query.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { stringifyJSON, throwIfAborted } from "@orpc/shared";
|
|
2
|
-
export function liveQuery(queryFn) {
|
|
3
|
-
return async (context) => {
|
|
4
|
-
const stream = await queryFn(context);
|
|
5
|
-
let last;
|
|
6
|
-
for await (const chunk of stream) {
|
|
7
|
-
throwIfAborted(context.signal);
|
|
8
|
-
last = { chunk };
|
|
9
|
-
context.client.setQueryData(context.queryKey, chunk);
|
|
10
|
-
}
|
|
11
|
-
if (!last) {
|
|
12
|
-
throw new TypeError(`Live query for ${stringifyJSON(context.queryKey)} did not yield any data. Ensure the query function returns an AsyncIterable with at least one chunk.`);
|
|
13
|
-
}
|
|
14
|
-
return last.chunk;
|
|
15
|
-
};
|
|
16
|
-
}
|
package/dist/meta.d.mts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { AnyNestedClient, ClientContext, InferClientContext, InferClientError } from "@orpc/client";
|
|
2
|
-
import type { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, Meta, MetaPlugin, ORPCErrorFromErrorMap, RouterContract } from "@orpc/contract";
|
|
3
|
-
import type { ThrowableError } from "@orpc/shared";
|
|
4
|
-
import type { OperationKeyBaseOptions } from "./key.mjs";
|
|
5
|
-
import type { RouterUtilsPlugin } from "./plugin.mjs";
|
|
6
|
-
import type { ProcedureUtilsOptions } from "./procedure-utils.mjs";
|
|
7
|
-
export type TanstackQueryMetaOptions<
|
|
8
|
-
TClientContext extends ClientContext,
|
|
9
|
-
TInput,
|
|
10
|
-
TOutput,
|
|
11
|
-
TError
|
|
12
|
-
> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
|
|
13
|
-
export interface TanstackQueryMetaPlugin<
|
|
14
|
-
TInputSchema extends AnySchema,
|
|
15
|
-
TOutputSchema extends AnySchema,
|
|
16
|
-
TErrorMap extends ErrorMap
|
|
17
|
-
> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
18
|
-
name: "~tanstack-query";
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Define base TanStack Query options and interceptors on a procedure contract.
|
|
22
|
-
* Applied multiple times, later options are spread-merged with higher priority
|
|
23
|
-
* while interceptors are concatenated. A key explicitly set to `undefined`
|
|
24
|
-
* resets the value from earlier applications instead of merging.
|
|
25
|
-
*
|
|
26
|
-
* Apply them to router utils with {@link ContractOptionsUtilsPlugin}.
|
|
27
|
-
*
|
|
28
|
-
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#contract-options-plugin | TanStack Query Integration - Contract Options Plugin}
|
|
29
|
-
*/
|
|
30
|
-
export declare function tanstackQuery<
|
|
31
|
-
TInputSchema extends AnySchema,
|
|
32
|
-
TOutputSchema extends AnySchema,
|
|
33
|
-
TErrorMap extends ErrorMap
|
|
34
|
-
>(options: TanstackQueryMetaOptions<ClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>): TanstackQueryMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>;
|
|
35
|
-
export declare function getTanstackQueryMeta(procedureOrLazy: {
|
|
36
|
-
"~orpc": {
|
|
37
|
-
meta: Meta;
|
|
38
|
-
};
|
|
39
|
-
}): TanstackQueryMetaOptions<ClientContext, unknown, unknown, ThrowableError> | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Router utils plugin that applies base options defined via {@link tanstackQuery}
|
|
42
|
-
* on the given router contract. Meta options act as the base layer: options defined
|
|
43
|
-
* on the utils override them, and utils interceptors run after meta interceptors.
|
|
44
|
-
*
|
|
45
|
-
* The contract shape must match the client the utils are created from,
|
|
46
|
-
* so pass the root router contract when utils paths start from the root.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#contract-options-plugin | TanStack Query Integration - Contract Options Plugin}
|
|
49
|
-
*/
|
|
50
|
-
export declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
51
|
-
private readonly contract;
|
|
52
|
-
readonly name = "~contract-options";
|
|
53
|
-
constructor(contract: RouterContract);
|
|
54
|
-
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
55
|
-
}
|
package/dist/meta.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getRouterContract, ProcedureContract } from "@orpc/contract";
|
|
2
|
-
import { mergeProcedureUtilsOptions } from "./procedure-utils.mjs";
|
|
3
|
-
|
|
4
|
-
export function tanstackQuery(options) {
|
|
5
|
-
return {
|
|
6
|
-
name: "~tanstack-query",
|
|
7
|
-
init(meta) {
|
|
8
|
-
const current = meta["~tanstack-query"];
|
|
9
|
-
return {
|
|
10
|
-
...meta,
|
|
11
|
-
"~tanstack-query": current ? mergeProcedureUtilsOptions(current, options) : options
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function getTanstackQueryMeta(procedureOrLazy) {
|
|
17
|
-
return procedureOrLazy["~orpc"].meta["~tanstack-query"];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ContractOptionsUtilsPlugin {
|
|
21
|
-
contract;
|
|
22
|
-
name = "~contract-options";
|
|
23
|
-
constructor(contract) {
|
|
24
|
-
this.contract = contract;
|
|
25
|
-
}
|
|
26
|
-
initProcedureOptions(path, options) {
|
|
27
|
-
const procedure = getRouterContract(this.contract, path);
|
|
28
|
-
if (!(procedure instanceof ProcedureContract)) {
|
|
29
|
-
return options;
|
|
30
|
-
}
|
|
31
|
-
const base = getTanstackQueryMeta(procedure);
|
|
32
|
-
if (!base) {
|
|
33
|
-
return options;
|
|
34
|
-
}
|
|
35
|
-
return mergeProcedureUtilsOptions(base, options);
|
|
36
|
-
}
|
|
37
|
-
}
|
package/dist/plugin.d.mts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { AnyNestedClient, InferClientContext, InferClientError } from "@orpc/client";
|
|
2
|
-
import type { OrderablePlugin } from "@orpc/shared";
|
|
3
|
-
import type { ProcedureUtilsOptions } from "./procedure-utils.mjs";
|
|
4
|
-
import type { RouterUtilsOptions } from "./router-utils.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* Plugin that packages reusable defaults and interceptors for router utils.
|
|
7
|
-
*
|
|
8
|
-
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#plugins | TanStack Query Integration - Plugins}
|
|
9
|
-
*/
|
|
10
|
-
export interface RouterUtilsPlugin<T extends AnyNestedClient> extends OrderablePlugin {
|
|
11
|
-
/**
|
|
12
|
-
* Initializes the router utils plugin and returns updated router utils options.
|
|
13
|
-
* Called once per plugin instance during composition.
|
|
14
|
-
*
|
|
15
|
-
* This method allows plugins to wrap, extend, or transform router utils options,
|
|
16
|
-
* such as interceptors or configuration.
|
|
17
|
-
*
|
|
18
|
-
* @param options - The current router utils options from previous plugins or base configuration
|
|
19
|
-
* @returns Transformed router utils options with this plugin's modifications applied
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* init(options) {
|
|
24
|
-
* return {
|
|
25
|
-
* ...options,
|
|
26
|
-
* mutationInterceptors: [...(options.mutationInterceptors ?? []), myInterceptor]
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
init?(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Initializes per-procedure router utils options and returns updated options.
|
|
34
|
-
* Called once per procedure utils instance during composition.
|
|
35
|
-
*
|
|
36
|
-
* This method allows plugins to customize merged procedure-specific defaults,
|
|
37
|
-
* such as query or mutation options, for the current path.
|
|
38
|
-
*
|
|
39
|
-
* @param path - The current procedure path
|
|
40
|
-
* @param options - The merged procedure utils options for the current procedure
|
|
41
|
-
* @returns Transformed procedure utils options with this plugin's modifications applied
|
|
42
|
-
*/
|
|
43
|
-
initProcedureOptions?(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
44
|
-
}
|
|
45
|
-
export declare class CompositeRouterUtilsPlugin<T extends AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
46
|
-
protected readonly plugins: RouterUtilsPlugin<T>[];
|
|
47
|
-
readonly name = "~composite";
|
|
48
|
-
constructor(plugins?: RouterUtilsPlugin<T>[]);
|
|
49
|
-
init(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
|
|
50
|
-
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
51
|
-
}
|
package/dist/plugin.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { sortPlugins } from "@orpc/shared";
|
|
2
|
-
export class CompositeRouterUtilsPlugin {
|
|
3
|
-
plugins;
|
|
4
|
-
name = "~composite";
|
|
5
|
-
constructor(plugins = []) {
|
|
6
|
-
this.plugins = plugins;
|
|
7
|
-
this.plugins = sortPlugins(plugins);
|
|
8
|
-
}
|
|
9
|
-
init(options) {
|
|
10
|
-
for (const plugin of this.plugins) {
|
|
11
|
-
if (plugin.init) {
|
|
12
|
-
options = plugin.init(options);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return options;
|
|
16
|
-
}
|
|
17
|
-
initProcedureOptions(path, options) {
|
|
18
|
-
for (const plugin of this.plugins) {
|
|
19
|
-
if (plugin.initProcedureOptions) {
|
|
20
|
-
options = plugin.initProcedureOptions(path, options);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import type { Client, ClientContext } from "@orpc/client";
|
|
2
|
-
import type { Interceptor, MaybeOptionalOptions, PromiseWithError } from "@orpc/shared";
|
|
3
|
-
import type { DataTag, InfiniteData, MutationFunctionContext, QueryFunctionContext, QueryKey, SkipToken } from "@tanstack/query-core";
|
|
4
|
-
import type { OperationKeyBaseOptions } from "./key.mjs";
|
|
5
|
-
import type { InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut } from "./types.mjs";
|
|
6
|
-
import { SharedUtils } from "./shared-utils.mjs";
|
|
7
|
-
export interface ProcedureUtilsQueryInterceptorOptions<
|
|
8
|
-
TClientContext extends ClientContext,
|
|
9
|
-
TInput
|
|
10
|
-
> {
|
|
11
|
-
path: string[];
|
|
12
|
-
context: TClientContext & OperationContext;
|
|
13
|
-
input: TInput | SkipToken;
|
|
14
|
-
fnContext: QueryFunctionContext;
|
|
15
|
-
}
|
|
16
|
-
export type ProcedureUtilsQueryInterceptor<
|
|
17
|
-
TClientContext extends ClientContext,
|
|
18
|
-
TInput,
|
|
19
|
-
TOutput,
|
|
20
|
-
TError
|
|
21
|
-
> = Interceptor<ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
|
|
22
|
-
export interface ProcedureUtilsStreamedInterceptorOptions<
|
|
23
|
-
TClientContext extends ClientContext,
|
|
24
|
-
TInput
|
|
25
|
-
> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {}
|
|
26
|
-
export type ProcedureUtilsStreamedInterceptor<
|
|
27
|
-
TClientContext extends ClientContext,
|
|
28
|
-
TInput,
|
|
29
|
-
TOutput,
|
|
30
|
-
TError
|
|
31
|
-
> = Interceptor<ProcedureUtilsStreamedInterceptorOptions<TClientContext, TInput>, PromiseWithError<InferStreamedQueryOutput<TOutput>, TError>>;
|
|
32
|
-
export interface ProcedureUtilsLiveInterceptorOptions<
|
|
33
|
-
TClientContext extends ClientContext,
|
|
34
|
-
TInput
|
|
35
|
-
> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {}
|
|
36
|
-
export type ProcedureUtilsLiveInterceptor<
|
|
37
|
-
TClientContext extends ClientContext,
|
|
38
|
-
TInput,
|
|
39
|
-
TOutput,
|
|
40
|
-
TError
|
|
41
|
-
> = Interceptor<ProcedureUtilsLiveInterceptorOptions<TClientContext, TInput>, PromiseWithError<InferLiveQueryOutput<TOutput>, TError>>;
|
|
42
|
-
export interface ProcedureUtilsInfiniteInterceptorOptions<
|
|
43
|
-
TClientContext extends ClientContext,
|
|
44
|
-
TInput
|
|
45
|
-
> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {
|
|
46
|
-
fnContext: QueryFunctionContext<QueryKey, any>;
|
|
47
|
-
}
|
|
48
|
-
export type ProcedureUtilsInfiniteInterceptor<
|
|
49
|
-
TClientContext extends ClientContext,
|
|
50
|
-
TInput,
|
|
51
|
-
TOutput,
|
|
52
|
-
TError
|
|
53
|
-
> = Interceptor<ProcedureUtilsInfiniteInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
|
|
54
|
-
export interface ProcedureUtilsMutationInterceptorOptions<
|
|
55
|
-
TClientContext extends ClientContext,
|
|
56
|
-
TInput
|
|
57
|
-
> extends Omit<ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput>, "input" | "fnContext"> {
|
|
58
|
-
input: TInput;
|
|
59
|
-
fnContext: MutationFunctionContext;
|
|
60
|
-
}
|
|
61
|
-
export type ProcedureUtilsMutationInterceptor<
|
|
62
|
-
TClientContext extends ClientContext,
|
|
63
|
-
TInput,
|
|
64
|
-
TOutput,
|
|
65
|
-
TError
|
|
66
|
-
> = Interceptor<ProcedureUtilsMutationInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
|
|
67
|
-
/**
|
|
68
|
-
* Can be partial options for spread-merged options,
|
|
69
|
-
* or a function that receives per-call options and returns overridden this.options.
|
|
70
|
-
*/
|
|
71
|
-
export type ProcedureUtilsModifier<T extends object> = Partial<T> | ((options: T) => T);
|
|
72
|
-
export interface ProcedureUtilsOptions<
|
|
73
|
-
TClientContext extends ClientContext,
|
|
74
|
-
TInput,
|
|
75
|
-
TOutput,
|
|
76
|
-
TError
|
|
77
|
-
> extends OperationKeyBaseOptions {
|
|
78
|
-
/**
|
|
79
|
-
* Key options modifier for .queryKey and .queryOptions
|
|
80
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
81
|
-
*/
|
|
82
|
-
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Interceptors that intercept queryFn inside .queryOptions, guaranteed to be executed.
|
|
85
|
-
*/
|
|
86
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* Options modifier for .queryOptions
|
|
89
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
90
|
-
*/
|
|
91
|
-
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>> | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Key options modifier for .streamedKey and .streamedOptions
|
|
94
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
95
|
-
*/
|
|
96
|
-
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Interceptors that intercept queryFn inside .streamedOptions, guaranteed to be executed.
|
|
99
|
-
*/
|
|
100
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* Options modifier for .streamedOptions
|
|
103
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
104
|
-
*/
|
|
105
|
-
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* Key options modifier for .liveKey and .liveOptions
|
|
108
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
109
|
-
*/
|
|
110
|
-
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Interceptors that intercept queryFn inside .liveOptions, guaranteed to be executed.
|
|
113
|
-
*/
|
|
114
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Options modifier for .liveOptions
|
|
117
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
118
|
-
*/
|
|
119
|
-
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
|
|
120
|
-
/**
|
|
121
|
-
* Key options modifier for .infiniteKey and .infiniteOptions
|
|
122
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
123
|
-
*/
|
|
124
|
-
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
|
|
125
|
-
/**
|
|
126
|
-
* Interceptors that intercept queryFn inside .infiniteOptions, guaranteed to be executed.
|
|
127
|
-
*/
|
|
128
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* Options modifier for .infiniteOptions
|
|
131
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
132
|
-
*/
|
|
133
|
-
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown>> | undefined;
|
|
134
|
-
/**
|
|
135
|
-
* Key options modifier for .mutationKey and .mutationOptions
|
|
136
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
137
|
-
*/
|
|
138
|
-
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions> | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Interceptors that intercept mutationFn inside .mutationOptions, guaranteed to be executed.
|
|
141
|
-
*/
|
|
142
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* Options modifier for .mutationOptions
|
|
145
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
146
|
-
*/
|
|
147
|
-
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>> | undefined;
|
|
148
|
-
}
|
|
149
|
-
export declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
150
|
-
/**
|
|
151
|
-
* Merge two procedure utils options where `override` takes priority.
|
|
152
|
-
* A key explicitly set to `undefined` in `override` resets the base value.
|
|
153
|
-
* When both sides define a key, interceptors are concatenated (base ones run first) and
|
|
154
|
-
* modifiers are combined so that, for object values, per-call options beat `override`,
|
|
155
|
-
* which beats `base`. A function modifier receives the merged options and its result wins.
|
|
156
|
-
*/
|
|
157
|
-
export declare function mergeProcedureUtilsOptions<
|
|
158
|
-
TClientContext extends ClientContext,
|
|
159
|
-
TInput,
|
|
160
|
-
TOutput,
|
|
161
|
-
TError
|
|
162
|
-
>(base: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, override: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>): ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>;
|
|
163
|
-
export declare class ProcedureUtils<
|
|
164
|
-
TClientContext extends ClientContext,
|
|
165
|
-
TInput,
|
|
166
|
-
TOutput,
|
|
167
|
-
TError
|
|
168
|
-
> extends SharedUtils<TInput> {
|
|
169
|
-
protected readonly options: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>;
|
|
170
|
-
/**
|
|
171
|
-
* Calling corresponding procedure client
|
|
172
|
-
*/
|
|
173
|
-
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
174
|
-
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>);
|
|
175
|
-
/**
|
|
176
|
-
* Generate a **full matching** key for [Query Options](https://orpc.dev/docs/integrations/tanstack-query#query-options).
|
|
177
|
-
*/
|
|
178
|
-
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, TOutput, TError>;
|
|
179
|
-
/**
|
|
180
|
-
* Generate options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
181
|
-
*/
|
|
182
|
-
queryOptions<
|
|
183
|
-
USelectData = TOutput,
|
|
184
|
-
UInitialData = undefined
|
|
185
|
-
>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UInitialData>>): NoInfer<QueryOptionsOut<TOutput, TError, USelectData, UInitialData>>;
|
|
186
|
-
/**
|
|
187
|
-
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options).
|
|
188
|
-
*/
|
|
189
|
-
streamedKey(...rest: MaybeOptionalOptions<StreamedKeyOptions<TInput>>): DataTag<QueryKey, InferStreamedQueryOutput<TOutput>, TError>;
|
|
190
|
-
/**
|
|
191
|
-
* Configure queries for [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object).
|
|
192
|
-
* This is built on [TanStack Query streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
193
|
-
* and works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
194
|
-
*/
|
|
195
|
-
streamedOptions<
|
|
196
|
-
USelectData = InferStreamedQueryOutput<TOutput>,
|
|
197
|
-
UInitialData = undefined
|
|
198
|
-
>(...rest: MaybeOptionalOptions<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, USelectData, UInitialData>>): NoInfer<StreamedOptionsOut<InferStreamedQueryOutput<TOutput>, TError, USelectData, UInitialData>>;
|
|
199
|
-
/**
|
|
200
|
-
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/tanstack-query#live-query-options).
|
|
201
|
-
*/
|
|
202
|
-
liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, InferLiveQueryOutput<TOutput>, TError>;
|
|
203
|
-
/**
|
|
204
|
-
* Configure live queries for [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object).
|
|
205
|
-
* Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
|
|
206
|
-
* Works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
207
|
-
*/
|
|
208
|
-
liveOptions<
|
|
209
|
-
USelectData = InferLiveQueryOutput<TOutput>,
|
|
210
|
-
UInitialData = undefined
|
|
211
|
-
>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, USelectData, UInitialData>>): NoInfer<QueryOptionsOut<InferLiveQueryOutput<TOutput>, TError, USelectData, UInitialData>>;
|
|
212
|
-
/**
|
|
213
|
-
* Generate a **full matching** key for [Infinite Query Options](https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options).
|
|
214
|
-
*/
|
|
215
|
-
infiniteKey<UPageParam>(optionsIn: InfiniteKeyOptions<TInput, UPageParam>): DataTag<QueryKey, InfiniteData<TOutput, UPageParam>, TError>;
|
|
216
|
-
/**
|
|
217
|
-
* Generate options used for useInfiniteQuery/useSuspenseInfiniteQuery/prefetchInfiniteQuery/...
|
|
218
|
-
*/
|
|
219
|
-
infiniteOptions<
|
|
220
|
-
UPageParam,
|
|
221
|
-
USelectData = InfiniteData<TOutput, UPageParam>,
|
|
222
|
-
UInitialData = undefined
|
|
223
|
-
>(optionsIn: InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam, UInitialData>): NoInfer<InfiniteOptionsOut<TOutput, TError, USelectData, UPageParam, UInitialData>>;
|
|
224
|
-
/**
|
|
225
|
-
* Generate a **full matching** key for [Mutation Options](https://orpc.dev/docs/integrations/tanstack-query#mutation-options).
|
|
226
|
-
*/
|
|
227
|
-
mutationKey(optionsIn?: MutationKeyOptions): DataTag<QueryKey, TOutput, TError>;
|
|
228
|
-
/**
|
|
229
|
-
* Generate options used for useMutation/...
|
|
230
|
-
*/
|
|
231
|
-
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptionsOut<TInput, TOutput, TError, UMutationContext>>;
|
|
232
|
-
}
|