@orpc/pinia-colada 2.0.0-beta.23 → 2.0.0-beta.25
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 -1
- package/dist/index.d.mts +48 -17
- package/dist/index.d.ts +48 -17
- package/dist/index.mjs +33 -30
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
44
44
|
|
|
45
45
|
- [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher): Pub/Sub with memory, Redis, and Upstash adapters.
|
|
46
46
|
- [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit): Rate limiting with memory, Redis, and Upstash adapters.
|
|
47
|
+
- [@orpc/hibernation](https://www.npmjs.com/package/@orpc/hibernation): Leverage Hibernation APIs like [Cloudflare's Hibernation WebSocket](https://developers.cloudflare.com/durable-objects/best-practices/websockets/#durable-objects-hibernation-websocket-api).
|
|
47
48
|
- [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema): Smart coercion for OpenAPI requests.
|
|
48
49
|
|
|
49
50
|
**Framework & ecosystem integrations**
|
|
@@ -114,6 +115,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
114
115
|
</tr>
|
|
115
116
|
<tr>
|
|
116
117
|
<td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="139" alt="shota"/><br />shota</a></td>
|
|
118
|
+
<td align="center"><a href="https://github.com/ellis-driscoll?ref=orpc" target="_blank" rel="noopener" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&v=4" width="139" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
|
|
117
119
|
</tr>
|
|
118
120
|
</table>
|
|
119
121
|
|
|
@@ -139,8 +141,9 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
139
141
|
<td align="center"><a href="https://github.com/mr-kelly?ref=orpc" target="_blank" rel="noopener" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&v=4" width="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
|
|
140
142
|
</tr>
|
|
141
143
|
<tr>
|
|
144
|
+
<td align="center"><a href="https://github.com/guyariely?ref=orpc" target="_blank" rel="noopener" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&v=4" width="119" alt="Guy Ariely"/><br />Guy Ariely</a></td>
|
|
142
145
|
<td align="center"><a href="https://github.com/piscis?ref=orpc" target="_blank" rel="noopener" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="119" alt="Alex"/><br />Alex</a></td>
|
|
143
|
-
<td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=
|
|
146
|
+
<td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&v=4" width="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
144
147
|
</tr>
|
|
145
148
|
</table>
|
|
146
149
|
|
package/dist/index.d.mts
CHANGED
|
@@ -12,8 +12,20 @@ type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
|
|
|
12
12
|
* `UseMutationGlobalContext` values provided by a global `onMutate` hook.
|
|
13
13
|
*/
|
|
14
14
|
type UseMutationFnContext = Parameters<NonNullable<UseMutationOptionsGlobal['onSuccess']>>[2];
|
|
15
|
+
/**
|
|
16
|
+
* The symbol under which Pinia Colada utils attach operation details
|
|
17
|
+
* (key and operation type) to the client context.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#client-context | Pinia Colada Integration - Client Context}
|
|
20
|
+
*/
|
|
15
21
|
declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
16
22
|
type OperationType = 'query' | 'streamed' | 'live' | 'infinite' | 'mutation';
|
|
23
|
+
/**
|
|
24
|
+
* A client context automatically populated by Pinia Colada utils,
|
|
25
|
+
* exposing the operation key and type of the calling operation.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#client-context | Pinia Colada Integration - Client Context}
|
|
28
|
+
*/
|
|
17
29
|
interface OperationContext {
|
|
18
30
|
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
19
31
|
key: EntryKey;
|
|
@@ -117,7 +129,7 @@ type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: stri
|
|
|
117
129
|
* The input is serialized to JSON-compatible values because Pinia Colada
|
|
118
130
|
* requires entry keys to be serializable.
|
|
119
131
|
*
|
|
120
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
132
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
121
133
|
*/
|
|
122
134
|
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
123
135
|
|
|
@@ -128,7 +140,7 @@ declare class SharedUtils<TInput> {
|
|
|
128
140
|
/**
|
|
129
141
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
130
142
|
*
|
|
131
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
143
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
132
144
|
*/
|
|
133
145
|
key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, 'prefix'>): OperationKey<TType, TInput>;
|
|
134
146
|
}
|
|
@@ -251,26 +263,26 @@ declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutp
|
|
|
251
263
|
/**
|
|
252
264
|
* Calling corresponding procedure client
|
|
253
265
|
*
|
|
254
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure
|
|
266
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients | Pinia Colada Integration - Calling Procedure Clients}
|
|
255
267
|
*/
|
|
256
268
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
257
269
|
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>);
|
|
258
270
|
/**
|
|
259
271
|
* Generate a **full matching** key for useQuery/...
|
|
260
272
|
*
|
|
261
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
273
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
262
274
|
*/
|
|
263
275
|
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): EntryKeyTagged<TOutput, TError>;
|
|
264
276
|
/**
|
|
265
277
|
* Generate options used for useQuery/...
|
|
266
278
|
*
|
|
267
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility Pinia Colada Query Options Utility
|
|
279
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility | Pinia Colada Integration - Query Options Utility}
|
|
268
280
|
*/
|
|
269
281
|
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): NoInfer<QueryOptionsOut<TOutput, TError, UInitialData>>;
|
|
270
282
|
/**
|
|
271
283
|
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/pinia-colada#streamed-query-options-utility).
|
|
272
284
|
*
|
|
273
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
285
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
274
286
|
*/
|
|
275
287
|
streamedKey(...rest: MaybeOptionalOptions<StreamedKeyOptions<TInput>>): EntryKeyTagged<InferStreamedQueryOutput<TOutput>, TError>;
|
|
276
288
|
/**
|
|
@@ -282,7 +294,7 @@ declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutp
|
|
|
282
294
|
/**
|
|
283
295
|
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/pinia-colada#live-query-options-utility).
|
|
284
296
|
*
|
|
285
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
297
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
286
298
|
*/
|
|
287
299
|
liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): EntryKeyTagged<InferLiveQueryOutput<TOutput>, TError>;
|
|
288
300
|
/**
|
|
@@ -294,25 +306,25 @@ declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutp
|
|
|
294
306
|
/**
|
|
295
307
|
* Generate a **full matching** key for useInfiniteQuery/...
|
|
296
308
|
*
|
|
297
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
309
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
298
310
|
*/
|
|
299
311
|
infiniteKey<UPageParam>(optionsIn: InfiniteKeyOptions<TInput, UPageParam>): EntryKeyTagged<UseInfiniteQueryData<TOutput, UPageParam>, TError>;
|
|
300
312
|
/**
|
|
301
313
|
* Generate options used for useInfiniteQuery/...
|
|
302
314
|
*
|
|
303
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility Pinia Colada Infinite Query Options Utility
|
|
315
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility | Pinia Colada Integration - Infinite Query Options Utility}
|
|
304
316
|
*/
|
|
305
317
|
infiniteOptions<UPageParam, UInitialData extends UseInfiniteQueryData<TOutput, UPageParam> | undefined = undefined>(optionsIn: InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, UPageParam, UInitialData>): NoInfer<InfiniteOptionsOut<TOutput, TError, UPageParam, UInitialData>>;
|
|
306
318
|
/**
|
|
307
319
|
* Generate a **full matching** key for useMutation/...
|
|
308
320
|
*
|
|
309
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
321
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
310
322
|
*/
|
|
311
323
|
mutationKey(...rest: MaybeOptionalOptions<MutationKeyOptions<TInput>>): MutationOptionsOut<TInput, TOutput, TError, _EmptyObject>['key'];
|
|
312
324
|
/**
|
|
313
325
|
* Generate options used for useMutation/...
|
|
314
326
|
*
|
|
315
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options Pinia Colada Mutation Options
|
|
327
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options | Pinia Colada Integration - Mutation Options}
|
|
316
328
|
*/
|
|
317
329
|
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptionsOut<TInput, TOutput, TError, UMutationContext>>;
|
|
318
330
|
}
|
|
@@ -360,6 +372,12 @@ declare class CompositeRouterUtilsPlugin<T extends AnyNestedClient> implements R
|
|
|
360
372
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
361
373
|
}
|
|
362
374
|
|
|
375
|
+
/**
|
|
376
|
+
* The utils shape derived from a client: procedure clients map to procedure
|
|
377
|
+
* utils, and routers map recursively to nested utils.
|
|
378
|
+
*
|
|
379
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada | Pinia Colada Integration}
|
|
380
|
+
*/
|
|
363
381
|
type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : {
|
|
364
382
|
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
365
383
|
} & Public<SharedUtils<unknown>>;
|
|
@@ -405,10 +423,13 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
|
|
|
405
423
|
plugins?: RouterUtilsPlugin<T>[] | undefined;
|
|
406
424
|
}
|
|
407
425
|
/**
|
|
408
|
-
*
|
|
426
|
+
* Creates Pinia Colada utils from a client, exposing query/mutation
|
|
427
|
+
* option builders for every procedure in the router.
|
|
409
428
|
*
|
|
410
|
-
* @
|
|
411
|
-
*
|
|
429
|
+
* @remarks
|
|
430
|
+
* **Note**: Both client-side and server-side clients are supported.
|
|
431
|
+
*
|
|
432
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada | Pinia Colada Integration}
|
|
412
433
|
*/
|
|
413
434
|
declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: NoInfer<RouterUtilsOptions<T>>): RouterUtils<T>;
|
|
414
435
|
|
|
@@ -417,6 +438,16 @@ interface ContractUtilsFactory<TClientContext extends ClientContext> {
|
|
|
417
438
|
}
|
|
418
439
|
interface ContractUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<RouterContractClient<RouterContract, TClientContext>>, 'path'> {
|
|
419
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates a factory that builds Pinia Colada utils directly from a contract,
|
|
443
|
+
* using the given contract client factory. Useful for scaling large projects
|
|
444
|
+
* where each part only needs a slice of the router.
|
|
445
|
+
*
|
|
446
|
+
* @remarks
|
|
447
|
+
* **Note**: The contract must define a `path` meta matching its position in the root router contract.
|
|
448
|
+
*
|
|
449
|
+
* @see {@link https://orpc.dev/docs/advanced/scaling-large-projects#pinia-colada-integration | Scaling Large Projects - Pinia Colada Integration}
|
|
450
|
+
*/
|
|
420
451
|
declare function createContractUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractUtilsFactoryOptions<TClientContext>): ContractUtilsFactory<TClientContext>;
|
|
421
452
|
interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
|
|
422
453
|
<T extends RouterContract>(contract: T): RouterUtils<JsonifiedClient<RouterContractClient<T, TClientContext>>>;
|
|
@@ -443,7 +474,7 @@ interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema ex
|
|
|
443
474
|
*
|
|
444
475
|
* Apply them to router utils with {@link ContractOptionsUtilsPlugin}.
|
|
445
476
|
*
|
|
446
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin Pinia Colada Contract Options Plugin
|
|
477
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin | Pinia Colada Integration - Contract Options Plugin}
|
|
447
478
|
*/
|
|
448
479
|
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>;
|
|
449
480
|
declare function getPiniaColadaMeta(procedureOrLazy: {
|
|
@@ -459,7 +490,7 @@ declare function getPiniaColadaMeta(procedureOrLazy: {
|
|
|
459
490
|
* The contract shape must match the client the utils are created from,
|
|
460
491
|
* so pass the root router contract when utils paths start from the root.
|
|
461
492
|
*
|
|
462
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin Pinia Colada Contract Options Plugin
|
|
493
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin | Pinia Colada Integration - Contract Options Plugin}
|
|
463
494
|
*/
|
|
464
495
|
declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
465
496
|
private readonly contract;
|
|
@@ -468,5 +499,5 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
468
499
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
469
500
|
}
|
|
470
501
|
|
|
471
|
-
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
502
|
+
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createORPCVueColadaUtils, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
472
503
|
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,20 @@ type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
|
|
|
12
12
|
* `UseMutationGlobalContext` values provided by a global `onMutate` hook.
|
|
13
13
|
*/
|
|
14
14
|
type UseMutationFnContext = Parameters<NonNullable<UseMutationOptionsGlobal['onSuccess']>>[2];
|
|
15
|
+
/**
|
|
16
|
+
* The symbol under which Pinia Colada utils attach operation details
|
|
17
|
+
* (key and operation type) to the client context.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#client-context | Pinia Colada Integration - Client Context}
|
|
20
|
+
*/
|
|
15
21
|
declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
16
22
|
type OperationType = 'query' | 'streamed' | 'live' | 'infinite' | 'mutation';
|
|
23
|
+
/**
|
|
24
|
+
* A client context automatically populated by Pinia Colada utils,
|
|
25
|
+
* exposing the operation key and type of the calling operation.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#client-context | Pinia Colada Integration - Client Context}
|
|
28
|
+
*/
|
|
17
29
|
interface OperationContext {
|
|
18
30
|
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
19
31
|
key: EntryKey;
|
|
@@ -117,7 +129,7 @@ type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: stri
|
|
|
117
129
|
* The input is serialized to JSON-compatible values because Pinia Colada
|
|
118
130
|
* requires entry keys to be serializable.
|
|
119
131
|
*
|
|
120
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
132
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
121
133
|
*/
|
|
122
134
|
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
123
135
|
|
|
@@ -128,7 +140,7 @@ declare class SharedUtils<TInput> {
|
|
|
128
140
|
/**
|
|
129
141
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
130
142
|
*
|
|
131
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
143
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
132
144
|
*/
|
|
133
145
|
key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, 'prefix'>): OperationKey<TType, TInput>;
|
|
134
146
|
}
|
|
@@ -251,26 +263,26 @@ declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutp
|
|
|
251
263
|
/**
|
|
252
264
|
* Calling corresponding procedure client
|
|
253
265
|
*
|
|
254
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure
|
|
266
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients | Pinia Colada Integration - Calling Procedure Clients}
|
|
255
267
|
*/
|
|
256
268
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
257
269
|
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>);
|
|
258
270
|
/**
|
|
259
271
|
* Generate a **full matching** key for useQuery/...
|
|
260
272
|
*
|
|
261
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
273
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
262
274
|
*/
|
|
263
275
|
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): EntryKeyTagged<TOutput, TError>;
|
|
264
276
|
/**
|
|
265
277
|
* Generate options used for useQuery/...
|
|
266
278
|
*
|
|
267
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility Pinia Colada Query Options Utility
|
|
279
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility | Pinia Colada Integration - Query Options Utility}
|
|
268
280
|
*/
|
|
269
281
|
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): NoInfer<QueryOptionsOut<TOutput, TError, UInitialData>>;
|
|
270
282
|
/**
|
|
271
283
|
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/pinia-colada#streamed-query-options-utility).
|
|
272
284
|
*
|
|
273
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
285
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
274
286
|
*/
|
|
275
287
|
streamedKey(...rest: MaybeOptionalOptions<StreamedKeyOptions<TInput>>): EntryKeyTagged<InferStreamedQueryOutput<TOutput>, TError>;
|
|
276
288
|
/**
|
|
@@ -282,7 +294,7 @@ declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutp
|
|
|
282
294
|
/**
|
|
283
295
|
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/pinia-colada#live-query-options-utility).
|
|
284
296
|
*
|
|
285
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
297
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
286
298
|
*/
|
|
287
299
|
liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): EntryKeyTagged<InferLiveQueryOutput<TOutput>, TError>;
|
|
288
300
|
/**
|
|
@@ -294,25 +306,25 @@ declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutp
|
|
|
294
306
|
/**
|
|
295
307
|
* Generate a **full matching** key for useInfiniteQuery/...
|
|
296
308
|
*
|
|
297
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
309
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
298
310
|
*/
|
|
299
311
|
infiniteKey<UPageParam>(optionsIn: InfiniteKeyOptions<TInput, UPageParam>): EntryKeyTagged<UseInfiniteQueryData<TOutput, UPageParam>, TError>;
|
|
300
312
|
/**
|
|
301
313
|
* Generate options used for useInfiniteQuery/...
|
|
302
314
|
*
|
|
303
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility Pinia Colada Infinite Query Options Utility
|
|
315
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility | Pinia Colada Integration - Infinite Query Options Utility}
|
|
304
316
|
*/
|
|
305
317
|
infiniteOptions<UPageParam, UInitialData extends UseInfiniteQueryData<TOutput, UPageParam> | undefined = undefined>(optionsIn: InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, UPageParam, UInitialData>): NoInfer<InfiniteOptionsOut<TOutput, TError, UPageParam, UInitialData>>;
|
|
306
318
|
/**
|
|
307
319
|
* Generate a **full matching** key for useMutation/...
|
|
308
320
|
*
|
|
309
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
321
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
310
322
|
*/
|
|
311
323
|
mutationKey(...rest: MaybeOptionalOptions<MutationKeyOptions<TInput>>): MutationOptionsOut<TInput, TOutput, TError, _EmptyObject>['key'];
|
|
312
324
|
/**
|
|
313
325
|
* Generate options used for useMutation/...
|
|
314
326
|
*
|
|
315
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options Pinia Colada Mutation Options
|
|
327
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options | Pinia Colada Integration - Mutation Options}
|
|
316
328
|
*/
|
|
317
329
|
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptionsOut<TInput, TOutput, TError, UMutationContext>>;
|
|
318
330
|
}
|
|
@@ -360,6 +372,12 @@ declare class CompositeRouterUtilsPlugin<T extends AnyNestedClient> implements R
|
|
|
360
372
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
361
373
|
}
|
|
362
374
|
|
|
375
|
+
/**
|
|
376
|
+
* The utils shape derived from a client: procedure clients map to procedure
|
|
377
|
+
* utils, and routers map recursively to nested utils.
|
|
378
|
+
*
|
|
379
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada | Pinia Colada Integration}
|
|
380
|
+
*/
|
|
363
381
|
type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : {
|
|
364
382
|
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
365
383
|
} & Public<SharedUtils<unknown>>;
|
|
@@ -405,10 +423,13 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
|
|
|
405
423
|
plugins?: RouterUtilsPlugin<T>[] | undefined;
|
|
406
424
|
}
|
|
407
425
|
/**
|
|
408
|
-
*
|
|
426
|
+
* Creates Pinia Colada utils from a client, exposing query/mutation
|
|
427
|
+
* option builders for every procedure in the router.
|
|
409
428
|
*
|
|
410
|
-
* @
|
|
411
|
-
*
|
|
429
|
+
* @remarks
|
|
430
|
+
* **Note**: Both client-side and server-side clients are supported.
|
|
431
|
+
*
|
|
432
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada | Pinia Colada Integration}
|
|
412
433
|
*/
|
|
413
434
|
declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: NoInfer<RouterUtilsOptions<T>>): RouterUtils<T>;
|
|
414
435
|
|
|
@@ -417,6 +438,16 @@ interface ContractUtilsFactory<TClientContext extends ClientContext> {
|
|
|
417
438
|
}
|
|
418
439
|
interface ContractUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<RouterContractClient<RouterContract, TClientContext>>, 'path'> {
|
|
419
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates a factory that builds Pinia Colada utils directly from a contract,
|
|
443
|
+
* using the given contract client factory. Useful for scaling large projects
|
|
444
|
+
* where each part only needs a slice of the router.
|
|
445
|
+
*
|
|
446
|
+
* @remarks
|
|
447
|
+
* **Note**: The contract must define a `path` meta matching its position in the root router contract.
|
|
448
|
+
*
|
|
449
|
+
* @see {@link https://orpc.dev/docs/advanced/scaling-large-projects#pinia-colada-integration | Scaling Large Projects - Pinia Colada Integration}
|
|
450
|
+
*/
|
|
420
451
|
declare function createContractUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractUtilsFactoryOptions<TClientContext>): ContractUtilsFactory<TClientContext>;
|
|
421
452
|
interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
|
|
422
453
|
<T extends RouterContract>(contract: T): RouterUtils<JsonifiedClient<RouterContractClient<T, TClientContext>>>;
|
|
@@ -443,7 +474,7 @@ interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema ex
|
|
|
443
474
|
*
|
|
444
475
|
* Apply them to router utils with {@link ContractOptionsUtilsPlugin}.
|
|
445
476
|
*
|
|
446
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin Pinia Colada Contract Options Plugin
|
|
477
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin | Pinia Colada Integration - Contract Options Plugin}
|
|
447
478
|
*/
|
|
448
479
|
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>;
|
|
449
480
|
declare function getPiniaColadaMeta(procedureOrLazy: {
|
|
@@ -459,7 +490,7 @@ declare function getPiniaColadaMeta(procedureOrLazy: {
|
|
|
459
490
|
* The contract shape must match the client the utils are created from,
|
|
460
491
|
* so pass the root router contract when utils paths start from the root.
|
|
461
492
|
*
|
|
462
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin Pinia Colada Contract Options Plugin
|
|
493
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#contract-options-plugin | Pinia Colada Integration - Contract Options Plugin}
|
|
463
494
|
*/
|
|
464
495
|
declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
465
496
|
private readonly contract;
|
|
@@ -468,5 +499,5 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
468
499
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
469
500
|
}
|
|
470
501
|
|
|
471
|
-
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
502
|
+
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createORPCVueColadaUtils, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
472
503
|
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveBasePathMeta, getRouterContract, ProcedureContract } from '@orpc/contract';
|
|
2
|
-
import { sortPlugins, stringifyJSON, resolveMaybeOptionalOptions, intercept, isTypescriptObject, isAsyncIteratorObject, toArray, bindMethods,
|
|
2
|
+
import { sortPlugins, stringifyJSON, resolveMaybeOptionalOptions, intercept, isTypescriptObject, isAsyncIteratorObject, toArray, bindMethods, get } from '@orpc/shared';
|
|
3
3
|
import { RPCJsonSerializer, RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
|
|
4
4
|
|
|
5
5
|
class CompositeRouterUtilsPlugin {
|
|
@@ -68,7 +68,7 @@ class SharedUtils {
|
|
|
68
68
|
/**
|
|
69
69
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
70
70
|
*
|
|
71
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
71
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
72
72
|
*/
|
|
73
73
|
key(options = {}) {
|
|
74
74
|
return generateOperationKey(this.path, { ...options, prefix: this.options.prefix });
|
|
@@ -183,7 +183,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
183
183
|
/**
|
|
184
184
|
* Calling corresponding procedure client
|
|
185
185
|
*
|
|
186
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure
|
|
186
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#calling-procedure-clients | Pinia Colada Integration - Calling Procedure Clients}
|
|
187
187
|
*/
|
|
188
188
|
call;
|
|
189
189
|
constructor(path, client, options = {}) {
|
|
@@ -193,7 +193,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
193
193
|
/**
|
|
194
194
|
* Generate a **full matching** key for useQuery/...
|
|
195
195
|
*
|
|
196
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
196
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
197
197
|
*/
|
|
198
198
|
queryKey(...rest) {
|
|
199
199
|
let optionsIn = resolveMaybeOptionalOptions(rest);
|
|
@@ -208,7 +208,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
208
208
|
/**
|
|
209
209
|
* Generate options used for useQuery/...
|
|
210
210
|
*
|
|
211
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility Pinia Colada Query Options Utility
|
|
211
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-options-utility | Pinia Colada Integration - Query Options Utility}
|
|
212
212
|
*/
|
|
213
213
|
queryOptions(...rest) {
|
|
214
214
|
let optionsIn = resolveMaybeOptionalOptions(rest);
|
|
@@ -250,7 +250,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
250
250
|
/**
|
|
251
251
|
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/pinia-colada#streamed-query-options-utility).
|
|
252
252
|
*
|
|
253
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
253
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
254
254
|
*/
|
|
255
255
|
streamedKey(...rest) {
|
|
256
256
|
let optionsIn = resolveMaybeOptionalOptions(rest);
|
|
@@ -316,7 +316,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
316
316
|
/**
|
|
317
317
|
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/pinia-colada#live-query-options-utility).
|
|
318
318
|
*
|
|
319
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
319
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
320
320
|
*/
|
|
321
321
|
liveKey(...rest) {
|
|
322
322
|
let optionsIn = resolveMaybeOptionalOptions(rest);
|
|
@@ -379,7 +379,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
379
379
|
/**
|
|
380
380
|
* Generate a **full matching** key for useInfiniteQuery/...
|
|
381
381
|
*
|
|
382
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
382
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
383
383
|
*/
|
|
384
384
|
infiniteKey(optionsIn) {
|
|
385
385
|
if (typeof this.options.infiniteKey === "function") {
|
|
@@ -399,7 +399,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
399
399
|
/**
|
|
400
400
|
* Generate options used for useInfiniteQuery/...
|
|
401
401
|
*
|
|
402
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility Pinia Colada Infinite Query Options Utility
|
|
402
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#infinite-query-options-utility | Pinia Colada Integration - Infinite Query Options Utility}
|
|
403
403
|
*/
|
|
404
404
|
infiniteOptions(optionsIn) {
|
|
405
405
|
if (typeof this.options.infiniteOptions === "function") {
|
|
@@ -440,7 +440,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
440
440
|
/**
|
|
441
441
|
* Generate a **full matching** key for useMutation/...
|
|
442
442
|
*
|
|
443
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key
|
|
443
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#query-mutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
444
444
|
*/
|
|
445
445
|
mutationKey(...rest) {
|
|
446
446
|
let optionsIn = resolveMaybeOptionalOptions(rest);
|
|
@@ -455,7 +455,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
455
455
|
/**
|
|
456
456
|
* Generate options used for useMutation/...
|
|
457
457
|
*
|
|
458
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options Pinia Colada Mutation Options
|
|
458
|
+
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#mutation-options | Pinia Colada Integration - Mutation Options}
|
|
459
459
|
*/
|
|
460
460
|
mutationOptions(...rest) {
|
|
461
461
|
let optionsIn = resolveMaybeOptionalOptions(rest);
|
|
@@ -517,30 +517,33 @@ function createRouterUtilsInternal(client, options, plugin) {
|
|
|
517
517
|
},
|
|
518
518
|
options.scoped ?? {}
|
|
519
519
|
))
|
|
520
|
-
)) : bindMethods(new SharedUtils(path, options));
|
|
520
|
+
), { unbound: ["call"] }) : bindMethods(new SharedUtils(path, options));
|
|
521
|
+
const cache = /* @__PURE__ */ new Map();
|
|
521
522
|
const recursive = new Proxy(utils, {
|
|
522
523
|
get(target, prop) {
|
|
523
|
-
const value =
|
|
524
|
-
const nextClient = client
|
|
524
|
+
const value = Reflect.get(target, prop);
|
|
525
|
+
const nextClient = Reflect.get(client, prop);
|
|
525
526
|
if (typeof prop !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop) || !isTypescriptObject(nextClient)) {
|
|
526
527
|
return value;
|
|
527
528
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
529
|
+
let result = cache.get(prop);
|
|
530
|
+
if (result === void 0) {
|
|
531
|
+
const nextUtils = createRouterUtilsInternal(nextClient, {
|
|
532
|
+
...options,
|
|
533
|
+
path: [...path, prop],
|
|
534
|
+
scoped: options.scoped?.[prop]
|
|
535
|
+
}, plugin);
|
|
536
|
+
result = typeof value !== "function" ? nextUtils : new Proxy(value, {
|
|
537
|
+
get(target2, prop2) {
|
|
538
|
+
if (typeof prop2 !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop2)) {
|
|
539
|
+
return Reflect.get(target2, prop2);
|
|
540
|
+
}
|
|
541
|
+
return Reflect.get(nextUtils, prop2);
|
|
540
542
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
543
|
+
});
|
|
544
|
+
cache.set(prop, result);
|
|
545
|
+
}
|
|
546
|
+
return result;
|
|
544
547
|
}
|
|
545
548
|
});
|
|
546
549
|
return recursive;
|
|
@@ -596,4 +599,4 @@ class ContractOptionsUtilsPlugin {
|
|
|
596
599
|
}
|
|
597
600
|
}
|
|
598
601
|
|
|
599
|
-
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
602
|
+
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createORPCVueColadaUtils, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/pinia-colada",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.25",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"vue": ">=3.5.17"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/client": "2.0.0-beta.
|
|
36
|
-
"@orpc/
|
|
37
|
-
"@orpc/
|
|
38
|
-
"@orpc/contract": "2.0.0-beta.
|
|
35
|
+
"@orpc/client": "2.0.0-beta.25",
|
|
36
|
+
"@orpc/openapi": "2.0.0-beta.25",
|
|
37
|
+
"@orpc/shared": "2.0.0-beta.25",
|
|
38
|
+
"@orpc/contract": "2.0.0-beta.25"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@pinia/colada": "^1.4.2",
|