@orpc/pinia-colada 2.0.0-beta.47 → 2.0.0-beta.48

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 CHANGED
@@ -191,15 +191,14 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
191
191
  <td align="center"><a href="https://kellychan.im/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
192
192
  <td align="center"><a href="https://guyariely.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&amp;v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
193
193
  <td align="center"><a href="https://paulsenon.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&amp;v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
194
- <td align="center"><a href="https://nakasyou.how/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&amp;v=4" width="139" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
194
+ <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
195
195
  </tr>
196
196
  <tr>
197
- <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
198
197
  <td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&amp;v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
199
198
  </tr>
200
199
  </table>
201
200
 
202
- With thanks to [39 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
201
+ With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
203
202
 
204
203
  ## Open Source Programs
205
204
 
@@ -0,0 +1,35 @@
1
+ import type { ClientContext } from "@orpc/client";
2
+ import type { ContractClientFactory, RouterContract, RouterContractClient } from "@orpc/contract";
3
+ import type { ContractJsonifiedClientFactory, JsonifiedClient } from "@orpc/openapi";
4
+ import type { RouterUtils, RouterUtilsOptions } from "./router-utils.mjs";
5
+ export interface ContractUtilsFactory<TClientContext extends ClientContext> {
6
+ <T extends RouterContract>(contract: T): RouterUtils<RouterContractClient<T, TClientContext>>;
7
+ }
8
+ export interface ContractUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<RouterContractClient<RouterContract, TClientContext>>, "path"> {}
9
+ /**
10
+ * Creates a factory that builds Pinia Colada utils directly from a contract,
11
+ * using the given contract client factory. Useful for scaling large projects
12
+ * where each part only needs a slice of the router.
13
+ *
14
+ * @remarks
15
+ * **Note**: The contract must define a `path` meta matching its position in the root router contract.
16
+ *
17
+ * @see {@link https://orpc.dev/docs/contract/client-factory#pinia-colada-integration | Contract Client Factory - Pinia Colada Integration}
18
+ */
19
+ export declare function createContractUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractUtilsFactoryOptions<TClientContext>): ContractUtilsFactory<TClientContext>;
20
+ export interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
21
+ <T extends RouterContract>(contract: T): RouterUtils<JsonifiedClient<RouterContractClient<T, TClientContext>>>;
22
+ }
23
+ export interface ContractJsonifiedUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, "path"> {}
24
+ /**
25
+ * Like `createContractUtilsFactory`, but for clients whose types are wrapped in `JsonifiedClient`,
26
+ * such as clients using OpenAPI Link.
27
+ *
28
+ * @remarks
29
+ * Takes a client factory created by `createContractJsonifiedClientFactory` from `@orpc/openapi`.
30
+ *
31
+ * **Note**: The contract must define a `path` meta matching its position in the root router contract.
32
+ *
33
+ * @see {@link https://orpc.dev/docs/contract/client-factory#pinia-colada-integration | Contract Client Factory - Pinia Colada Integration}
34
+ */
35
+ export declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractJsonifiedClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
@@ -0,0 +1,23 @@
1
+ import { resolveBasePathMeta } from "@orpc/contract";
2
+ import { get } from "@orpc/shared";
3
+ import { createRouterUtils } from "./router-utils.mjs";
4
+
5
+ export function createContractUtilsFactory(clientFactory, options) {
6
+ const factory = (contract) => {
7
+ const client = clientFactory(contract);
8
+ const path = resolveBasePathMeta(contract);
9
+ if (path === undefined) {
10
+ throw new TypeError("ContractUtilsFactory: procedure contract must define `meta.path` that matches its path in the root router contract.");
11
+ }
12
+ return createRouterUtils(client, {
13
+ ...options,
14
+ path,
15
+ scoped: get(options.scoped, path)
16
+ });
17
+ };
18
+ return factory;
19
+ }
20
+
21
+ export function createContractJsonifiedUtilsFactory(clientFactory, options) {
22
+ return createContractUtilsFactory(clientFactory, options);
23
+ }
package/dist/index.d.mts CHANGED
@@ -1,501 +1,19 @@
1
- import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
2
- export { AnyNestedClient } from '@orpc/client';
3
- import { RouterContract, RouterContractClient, ContractClientFactory, AnySchema, ErrorMap, MetaPlugin, Meta, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap } from '@orpc/contract';
4
- import { JsonifiedClient, ContractJsonifiedClientFactory } from '@orpc/openapi';
5
- import { Public, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, ThrowableError } from '@orpc/shared';
6
- export { Public } from '@orpc/shared';
7
- import { EntryKey, UseQueryOptions, DefineQueryOptions, UseInfiniteQueryData, DefineInfiniteQueryOptions, UseMutationOptions, UseMutationOptionsGlobal, DefineQueryOptionsTagged, DefineInfiniteQueryOptionsTagged, DefineMutationOptionsTagged, UseInfiniteQueryFnContext, EntryKeyTagged, _EmptyObject } from '@pinia/colada';
8
-
9
- type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
10
- type InferLiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
11
- type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
12
- /**
13
- * The context passed to the mutation function, including the merged
14
- * `UseMutationGlobalContext` values provided by a global `onMutate` hook.
15
- */
16
- type UseMutationFnContext = Parameters<NonNullable<UseMutationOptionsGlobal['onSuccess']>>[2];
17
- /**
18
- * The symbol under which Pinia Colada utils attach operation details
19
- * (key and operation type) to the client context.
20
- *
21
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#client-context | Pinia Colada Integration - Client Context}
22
- */
23
- declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
24
- type OperationType = 'query' | 'streamed' | 'live' | 'infinite' | 'mutation';
25
- /**
26
- * A client context automatically populated by Pinia Colada utils,
27
- * exposing the operation key and type of the calling operation.
28
- *
29
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#client-context | Pinia Colada Integration - Client Context}
30
- */
31
- interface OperationContext {
32
- [OPERATION_CONTEXT_SYMBOL]?: {
33
- key: EntryKey;
34
- type: OperationType;
35
- };
36
- }
37
- type QueryKeyOptions<TInput> = (undefined extends TInput ? {
38
- input?: TInput;
39
- } : {
40
- input: TInput;
41
- }) | {
42
- key: EntryKey;
43
- };
44
- type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TInitialData extends TOutput | undefined> = (undefined extends TInput ? {
45
- input?: TInput;
46
- } : {
47
- input: TInput;
48
- }) & (object extends TClientContext ? {
49
- context?: TClientContext | undefined;
50
- } : {
51
- context: TClientContext;
52
- }) & Omit<DefineQueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'> & Partial<Pick<DefineQueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>>;
53
- type QueryOptionsOut<TOutput, TError, TInitialData extends TOutput | undefined> = DefineQueryOptionsTagged<TOutput, TError, TInitialData>;
54
- type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
55
- input?: TInput;
56
- } : {
57
- input: TInput;
58
- }) & {
59
- fnOptions?: SerializableStreamedQueryOptions | undefined;
60
- }) | {
61
- key: EntryKey;
62
- };
63
- type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TInitialData extends TOutput | undefined> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TInitialData> & {
64
- fnOptions?: SerializableStreamedQueryOptions | undefined;
65
- };
66
- type StreamedOptionsOut<TOutput, TError, TInitialData extends TOutput | undefined> = QueryOptionsOut<TOutput, TError, TInitialData>;
67
- type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
68
- key: EntryKey;
69
- };
70
- type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TPageParam, TInitialData extends UseInfiniteQueryData<TOutput, TPageParam> | undefined> = {
71
- input: (pageParam: TPageParam) => TInput;
72
- } & (object extends TClientContext ? {
73
- context?: TClientContext | undefined;
74
- } : {
75
- context: TClientContext;
76
- }) & Omit<DefineInfiniteQueryOptions<TOutput, TError, TPageParam, TInitialData>, 'key' | 'query'> & Partial<Pick<DefineInfiniteQueryOptions<TOutput, TError, TPageParam, TInitialData>, 'key' | 'query'>>;
77
- type InfiniteOptionsOut<TOutput, TError, TPageParam, TInitialData extends UseInfiniteQueryData<TOutput, TPageParam> | undefined> = DefineInfiniteQueryOptionsTagged<TOutput, TError, TPageParam, TInitialData>;
78
- type MutationKeyOptions<TInput> = Pick<MutationOptionsIn<any, TInput, any, any, any>, 'key'>;
79
- type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext extends Record<any, any>> = (object extends TClientContext ? {
80
- context?: TClientContext | undefined;
81
- } : {
82
- context: TClientContext;
83
- }) & Omit<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'> & Partial<Pick<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>>;
84
- type MutationOptionsOut<TInput, TOutput, TError, TMutationContext extends Record<any, any>> = DefineMutationOptionsTagged<TOutput, TInput, TError, TMutationContext>;
85
-
86
- interface SerializableStreamedQueryOptions {
87
- /**
88
- * Determines how data is handled when the query is fetched again
89
- *
90
- * - `'reset'`: Clears existing data and returns the query to a pending state.
91
- * - `'append'`: Adds new streamed chunks to the existing data.
92
- * - `'replace'`: Buffers streamed data and replaces the cache after the stream completes.
93
- *
94
- * @default 'reset'
95
- */
96
- refetchMode?: 'append' | 'reset' | 'replace' | undefined;
97
- /**
98
- * Limits the number of data chunks stored in the query result.
99
- * Older chunks are removed when the limit is reached.
100
- *
101
- * @default Number.POSITIVE_INFINITY (unlimited)
102
- */
103
- maxChunks?: number | undefined;
104
- }
105
-
106
- interface OperationKeyPrefixOptions {
107
- /**
108
- * Prepended as the first element of the key when present.
109
- * Use this to avoid key conflicts when multiple router utils share the same client.
110
- */
111
- prefix?: string | undefined;
112
- }
113
- interface OperationKeyBaseOptions extends OperationKeyPrefixOptions {
114
- /**
115
- * Serializes inputs into JSON-compatible values when building keys.
116
- * Pass the serializer your link uses so custom types produce consistent keys.
117
- *
118
- * @default new RPCJsonSerializer()
119
- */
120
- serializer?: Public<RPCJsonSerializer> | undefined;
121
- }
122
- type OperationKeyOptions<TType extends OperationType, TInput> = OperationKeyBaseOptions & {
123
- type?: TType | undefined;
124
- input?: PartialDeep<TInput> | undefined;
125
- fnOptions?: (TType extends 'streamed' ? SerializableStreamedQueryOptions : never) | undefined;
126
- };
127
- type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions> & {
128
- /**
129
- * Serializer types of non-JSON values in `input`, keyed by their JSON-encoded path,
130
- * so inputs with the same JSON form (like a `Date` and its ISO string) produce different keys.
131
- * Keyed by path (not a list) so partial keys still match.
132
- */
133
- inputMeta?: Record<string, string[]> | undefined;
134
- };
135
- type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>]);
136
-
137
- declare class SharedUtils<TInput> {
138
- protected readonly path: string[];
139
- protected readonly options: OperationKeyBaseOptions;
140
- constructor(path: string[], options: OperationKeyBaseOptions);
141
- /**
142
- * Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
143
- *
144
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
145
- */
146
- key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions>): OperationKey<TType, TInput>;
147
- }
148
-
149
- interface ProcedureUtilsQueryInterceptorOptions<TClientContext extends ClientContext, TInput> {
150
- path: string[];
151
- context: TClientContext & OperationContext;
152
- input: TInput;
153
- fnContext: UseQueryFnContext;
154
- }
155
- type ProcedureUtilsQueryInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
156
- interface ProcedureUtilsStreamedInterceptorOptions<TClientContext extends ClientContext, TInput> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {
157
- }
158
- type ProcedureUtilsStreamedInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsStreamedInterceptorOptions<TClientContext, TInput>, PromiseWithError<InferStreamedQueryOutput<TOutput>, TError>>;
159
- interface ProcedureUtilsLiveInterceptorOptions<TClientContext extends ClientContext, TInput> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {
160
- }
161
- type ProcedureUtilsLiveInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsLiveInterceptorOptions<TClientContext, TInput>, PromiseWithError<InferLiveQueryOutput<TOutput>, TError>>;
162
- interface ProcedureUtilsInfiniteInterceptorOptions<TClientContext extends ClientContext, TInput> {
163
- path: string[];
164
- context: TClientContext & OperationContext;
165
- input: TInput;
166
- fnContext: UseInfiniteQueryFnContext<any, any, any, any>;
167
- }
168
- type ProcedureUtilsInfiniteInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsInfiniteInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
169
- interface ProcedureUtilsMutationInterceptorOptions<TClientContext extends ClientContext, TInput> {
170
- path: string[];
171
- context: TClientContext & OperationContext;
172
- input: TInput;
173
- fnContext: UseMutationFnContext;
174
- }
175
- type ProcedureUtilsMutationInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsMutationInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
176
- /**
177
- * Can be partial options for spread-merged options,
178
- * or a function that receives per-call options and returns overridden this.options.
179
- */
180
- type ProcedureUtilsModifier<T extends object> = Partial<T> | ((options: T) => T);
181
- interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends OperationKeyBaseOptions {
182
- /**
183
- * Key options modifier for .queryKey and .queryOptions
184
- * Can be partial options or a function that receives per-call options and returns override this.options.
185
- */
186
- queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
187
- /**
188
- * Interceptors that intercept query inside .queryOptions, guaranteed to be executed.
189
- */
190
- queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
191
- /**
192
- * Options modifier for .queryOptions
193
- * Can be partial options or a function that receives per-call options and returns override this.options.
194
- */
195
- queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, TOutput | undefined>> | undefined;
196
- /**
197
- * Key options modifier for .streamedKey and .streamedOptions
198
- * Can be partial options or a function that receives per-call options and returns override this.options.
199
- */
200
- streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
201
- /**
202
- * Interceptors that intercept query inside .streamedOptions, guaranteed to be executed.
203
- */
204
- streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
205
- /**
206
- * Options modifier for .streamedOptions
207
- * Can be partial options or a function that receives per-call options and returns override this.options.
208
- */
209
- streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, InferStreamedQueryOutput<TOutput> | undefined>> | undefined;
210
- /**
211
- * Key options modifier for .liveKey and .liveOptions
212
- * Can be partial options or a function that receives per-call options and returns override this.options.
213
- */
214
- liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
215
- /**
216
- * Interceptors that intercept query inside .liveOptions, guaranteed to be executed.
217
- */
218
- liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
219
- /**
220
- * Options modifier for .liveOptions
221
- * Can be partial options or a function that receives per-call options and returns override this.options.
222
- */
223
- liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, InferLiveQueryOutput<TOutput> | undefined>> | undefined;
224
- /**
225
- * Key options modifier for .infiniteKey and .infiniteOptions
226
- * Can be partial options or a function that receives per-call options and returns override this.options.
227
- */
228
- infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
229
- /**
230
- * Interceptors that intercept query inside .infiniteOptions, guaranteed to be executed.
231
- */
232
- infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
233
- /**
234
- * Options modifier for .infiniteOptions
235
- * Can be partial options or a function that receives per-call options and returns override this.options.
236
- */
237
- infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, UseInfiniteQueryData<TOutput, unknown> | undefined>> | undefined;
238
- /**
239
- * Key options modifier for .mutationKey and .mutationOptions
240
- * Can be partial options or a function that receives per-call options and returns override this.options.
241
- */
242
- mutationKey?: ProcedureUtilsModifier<MutationKeyOptions<TInput>> | undefined;
243
- /**
244
- * Interceptors that intercept mutation inside .mutationOptions, guaranteed to be executed.
245
- */
246
- mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
247
- /**
248
- * Options modifier for .mutationOptions
249
- * Can be partial options or a function that receives per-call options and returns override this.options.
250
- */
251
- mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any>>> | undefined;
252
- }
253
- /**
254
- * Merge two procedure utils options where `override` takes priority.
255
- * A key explicitly set to `undefined` in `override` resets the base value.
256
- * When both sides define a key, interceptors are concatenated (base ones run first) and
257
- * modifiers are combined so that, for object values, per-call options beat `override`,
258
- * which beats `base`. A function modifier receives the merged options and its result wins.
259
- */
260
- declare function mergeProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError>(base: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, override: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>): ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>;
261
- declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> extends SharedUtils<TInput> {
262
- protected readonly options: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>;
263
- /**
264
- * Calling corresponding procedure client
265
- *
266
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients | Pinia Colada Integration - Calling Procedure Clients}
267
- */
268
- call: Client<TClientContext, TInput, TOutput, TError>;
269
- constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>);
270
- /**
271
- * Generate a **full matching** key for useQuery/...
272
- *
273
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
274
- */
275
- queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): EntryKeyTagged<TOutput, TError>;
276
- /**
277
- * Generate options used for useQuery/...
278
- *
279
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility | Pinia Colada Integration - Query Options Utility}
280
- */
281
- queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): NoInfer<QueryOptionsOut<TOutput, TError, UInitialData>>;
282
- /**
283
- * Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/pinia-colada#streamed-query-options-utility).
284
- *
285
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
286
- */
287
- streamedKey(...rest: MaybeOptionalOptions<StreamedKeyOptions<TInput>>): EntryKeyTagged<InferStreamedQueryOutput<TOutput>, TError>;
288
- /**
289
- * Configure queries for [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object).
290
- * The resulting data is an array of chunks, and each new chunk is appended as it arrives.
291
- * Works with `useQuery` and any other API that accepts query options.
292
- */
293
- streamedOptions<UInitialData extends InferStreamedQueryOutput<TOutput> | undefined = undefined>(...rest: MaybeOptionalOptions<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, UInitialData>>): NoInfer<StreamedOptionsOut<InferStreamedQueryOutput<TOutput>, TError, UInitialData>>;
294
- /**
295
- * Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/pinia-colada#live-query-options-utility).
296
- *
297
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
298
- */
299
- liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): EntryKeyTagged<InferLiveQueryOutput<TOutput>, TError>;
300
- /**
301
- * Configure live queries for [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object).
302
- * Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
303
- * Works with `useQuery` and any other API that accepts query options.
304
- */
305
- liveOptions<UInitialData extends InferLiveQueryOutput<TOutput> | undefined = undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, UInitialData>>): NoInfer<QueryOptionsOut<InferLiveQueryOutput<TOutput>, TError, UInitialData>>;
306
- /**
307
- * Generate a **full matching** key for useInfiniteQuery/...
308
- *
309
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
310
- */
311
- infiniteKey<UPageParam>(optionsIn: InfiniteKeyOptions<TInput, UPageParam>): EntryKeyTagged<UseInfiniteQueryData<TOutput, UPageParam>, TError>;
312
- /**
313
- * Generate options used for useInfiniteQuery/...
314
- *
315
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility | Pinia Colada Integration - Infinite Query Options Utility}
316
- */
317
- infiniteOptions<UPageParam, UInitialData extends UseInfiniteQueryData<TOutput, UPageParam> | undefined = undefined>(optionsIn: InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, UPageParam, UInitialData>): NoInfer<InfiniteOptionsOut<TOutput, TError, UPageParam, UInitialData>>;
318
- /**
319
- * Generate a **full matching** key for useMutation/...
320
- *
321
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
322
- */
323
- mutationKey(...rest: MaybeOptionalOptions<MutationKeyOptions<TInput>>): MutationOptionsOut<TInput, TOutput, TError, _EmptyObject>['key'];
324
- /**
325
- * Generate options used for useMutation/...
326
- *
327
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options | Pinia Colada Integration - Mutation Options}
328
- */
329
- mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptionsOut<TInput, TOutput, TError, UMutationContext>>;
330
- }
331
-
332
- interface RouterUtilsPlugin<T extends AnyNestedClient> extends OrderablePlugin {
333
- /**
334
- * Initializes the router utils plugin and returns updated router utils options.
335
- * Called once per plugin instance during composition.
336
- *
337
- * This method allows plugins to wrap, extend, or transform router utils options,
338
- * such as interceptors or configuration.
339
- *
340
- * @param options - The current router utils options from previous plugins or base configuration
341
- * @returns Transformed router utils options with this plugin's modifications applied
342
- *
343
- * @example
344
- * ```ts
345
- * init(options) {
346
- * return {
347
- * ...options,
348
- * mutationInterceptors: [...(options.mutationInterceptors ?? []), myInterceptor]
349
- * }
350
- * }
351
- * ```
352
- */
353
- init?(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
354
- /**
355
- * Initializes per-procedure router utils options and returns updated options.
356
- * Called once per procedure utils instance during composition.
357
- *
358
- * This method allows plugins to customize merged procedure-specific defaults,
359
- * such as query or mutation options, for the current path.
360
- *
361
- * @param path - The current procedure path
362
- * @param options - The merged procedure utils options for the current procedure
363
- * @returns Transformed procedure utils options with this plugin's modifications applied
364
- */
365
- initProcedureOptions?(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
366
- }
367
-
368
- /**
369
- * The utils shape derived from a client: procedure clients map to procedure
370
- * utils, and routers map recursively to nested utils.
371
- *
372
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada | Pinia Colada Integration}
373
- */
374
- type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : {
375
- [K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
376
- } & Public<SharedUtils<unknown>>;
377
- type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
378
- [K in keyof T]?: (T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never) | undefined;
379
- };
380
- interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyBaseOptions {
381
- /**
382
- * Base path for all query keys.
383
- *
384
- * @internal
385
- */
386
- path?: string[] | undefined;
387
- /**
388
- * Interceptors that intercept query inside .queryOptions
389
- */
390
- queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
391
- /**
392
- * Interceptors that intercept query inside .streamedOptions
393
- */
394
- streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
395
- /**
396
- * Interceptors that intercept query inside .liveOptions
397
- */
398
- liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
399
- /**
400
- * Interceptors that intercept query inside .infiniteOptions
401
- */
402
- infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
403
- /**
404
- * Interceptors that intercept mutation inside .mutationOptions
405
- */
406
- mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
407
- /**
408
- * Per-procedure options following the shape of the router.
409
- * Allows fine-grained configuration of individual procedure utils
410
- * without affecting the rest of the router.
411
- */
412
- scoped?: RouterUtilsScoped<T> | undefined;
413
- /**
414
- * Plugins to extend router utils behavior.
415
- */
416
- plugins?: RouterUtilsPlugin<T>[] | undefined;
417
- }
418
- /**
419
- * Creates Pinia Colada utils from a client, exposing query/mutation
420
- * option builders for every procedure in the router.
421
- *
422
- * @remarks
423
- * **Note**: Both client-side and server-side clients are supported.
424
- *
425
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada | Pinia Colada Integration}
426
- */
427
- declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: NoInfer<RouterUtilsOptions<T>>): RouterUtils<T>;
428
-
429
- interface ContractUtilsFactory<TClientContext extends ClientContext> {
430
- <T extends RouterContract>(contract: T): RouterUtils<RouterContractClient<T, TClientContext>>;
431
- }
432
- interface ContractUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<RouterContractClient<RouterContract, TClientContext>>, 'path'> {
433
- }
434
- /**
435
- * Creates a factory that builds Pinia Colada utils directly from a contract,
436
- * using the given contract client factory. Useful for scaling large projects
437
- * where each part only needs a slice of the router.
438
- *
439
- * @remarks
440
- * **Note**: The contract must define a `path` meta matching its position in the root router contract.
441
- *
442
- * @see {@link https://orpc.dev/docs/contract/client-factory#pinia-colada-integration | Contract Client Factory - Pinia Colada Integration}
443
- */
444
- declare function createContractUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractUtilsFactoryOptions<TClientContext>): ContractUtilsFactory<TClientContext>;
445
- interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
446
- <T extends RouterContract>(contract: T): RouterUtils<JsonifiedClient<RouterContractClient<T, TClientContext>>>;
447
- }
448
- interface ContractJsonifiedUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'path'> {
449
- }
450
- /**
451
- * Like `createContractUtilsFactory`, but for clients whose types are wrapped in `JsonifiedClient`,
452
- * such as clients using OpenAPI Link.
453
- *
454
- * @remarks
455
- * Takes a client factory created by `createContractJsonifiedClientFactory` from `@orpc/openapi`.
456
- *
457
- * **Note**: The contract must define a `path` meta matching its position in the root router contract.
458
- *
459
- * @see {@link https://orpc.dev/docs/contract/client-factory#pinia-colada-integration | Contract Client Factory - Pinia Colada Integration}
460
- */
461
- declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractJsonifiedClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
462
-
463
- type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
464
- interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
465
- name: '~pinia-colada';
466
- }
467
- /**
468
- * Define base Pinia Colada options and interceptors on a procedure contract.
469
- * Applied multiple times, later options are spread-merged with higher priority
470
- * while interceptors are concatenated. A key explicitly set to `undefined`
471
- * resets the value from earlier applications instead of merging.
472
- *
473
- * Apply them to router utils with {@link ContractOptionsUtilsPlugin}.
474
- *
475
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin | Pinia Colada Integration - Contract Options Plugin}
476
- */
477
- declare function piniaColada<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(options: PiniaColadaMetaOptions<ClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>): PiniaColadaMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>;
478
- declare function getPiniaColadaMeta(procedureOrLazy: {
479
- '~orpc': {
480
- meta: Meta;
481
- };
482
- }): PiniaColadaMetaOptions<ClientContext, unknown, unknown, ThrowableError> | undefined;
483
- /**
484
- * Router utils plugin that applies base options defined via {@link piniaColada}
485
- * on the given router contract. Meta options act as the base layer: options defined
486
- * on the utils override them, and utils interceptors run after meta interceptors.
487
- *
488
- * The contract shape must match the client the utils are created from,
489
- * so pass the root router contract when utils paths start from the root.
490
- *
491
- * @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin | Pinia Colada Integration - Contract Options Plugin}
492
- */
493
- declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
494
- private readonly contract;
495
- readonly name = "~contract-options";
496
- constructor(contract: RouterContract);
497
- initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
498
- }
499
-
500
- export { ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createORPCVueColadaUtils, createRouterUtils as createPiniaColadaUtils, createRouterUtils, getPiniaColadaMeta, mergeProcedureUtilsOptions, piniaColada };
501
- export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyBaseOptions, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, PiniaColadaMetaOptions, PiniaColadaMetaPlugin, OperationContext as PiniaColadaOperationContext, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, UseMutationFnContext, UseQueryFnContext };
1
+ export * from "./contract-utils.mjs";
2
+ export type { OperationKey, OperationKeyBaseOptions, OperationKeyOptions, OperationKeyPrefixOptions } from "./key.mjs";
3
+ export * from "./meta.mjs";
4
+ export type { RouterUtilsPlugin } from "./plugin.mjs";
5
+ export { mergeProcedureUtilsOptions, ProcedureUtils } from "./procedure-utils.mjs";
6
+ export type { ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions } from "./procedure-utils.mjs";
7
+ export * from "./router-utils.mjs";
8
+ export {
9
+ /**
10
+ * @deprecated Use `createRouterUtils` instead.
11
+ */
12
+ createRouterUtils as createORPCVueColadaUtils } from "./router-utils.mjs";
13
+ export { createRouterUtils as createPiniaColadaUtils } from "./router-utils.mjs";
14
+ export { SharedUtils } from "./shared-utils.mjs";
15
+ export type { SerializableStreamedQueryOptions } from "./stream-query.mjs";
16
+ export * from "./types.mjs";
17
+ export { OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, type OperationContext as PiniaColadaOperationContext } from "./types.mjs";
18
+ export type { AnyNestedClient } from "@orpc/client";
19
+ export type { Public } from "@orpc/shared";