@orpc/pinia-colada 2.0.0-beta.45 → 2.0.0-beta.46
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 +47 -16
- package/dist/index.d.mts +16 -35
- package/dist/index.d.ts +16 -35
- package/dist/index.mjs +5 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -21,9 +21,40 @@
|
|
|
21
21
|
</a>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
|
+
**oRPC** is a TypeScript framework for building end-to-end typesafe APIs. Write your API once as plain TypeScript functions, and oRPC gives you a fully typed client, a REST API with an OpenAPI document, and MCP tools for AI agents, with no code generation. It runs on Node.js, Bun, Deno, Cloudflare Workers, and more.
|
|
25
|
+
|
|
26
|
+
Define procedures on the server and serve them with an [RPC handler](https://orpc.dev/docs/rpc/handler):
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { os } from '@orpc/server'
|
|
30
|
+
import * as z from 'zod'
|
|
31
|
+
|
|
32
|
+
export const router = {
|
|
33
|
+
planet: {
|
|
34
|
+
find: os
|
|
35
|
+
.input(z.object({ id: z.number() }))
|
|
36
|
+
.handler(({ input }) => ({ id: input.id, name: 'Earth' })),
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then call them from a client that knows every input and output, without generating anything:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import type { RouterClient } from '@orpc/server'
|
|
45
|
+
import type { router } from './router'
|
|
46
|
+
import { createORPCClient } from '@orpc/client'
|
|
47
|
+
import { RPCLink } from '@orpc/client/fetch'
|
|
48
|
+
|
|
49
|
+
const link = new RPCLink({ origin: 'http://localhost:3000', url: '/rpc' })
|
|
50
|
+
const client: RouterClient<typeof router> = createORPCClient(link)
|
|
51
|
+
|
|
52
|
+
const planet = await client.planet.find({ id: 1 }) // { id: number, name: string }
|
|
53
|
+
```
|
|
54
|
+
|
|
24
55
|
## Documentation
|
|
25
56
|
|
|
26
|
-
|
|
57
|
+
Read the full documentation at [orpc.dev](https://orpc.dev), starting with the [Getting Started guide](https://orpc.dev/docs/getting-started).
|
|
27
58
|
|
|
28
59
|
## Packages
|
|
29
60
|
|
|
@@ -56,21 +87,21 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
56
87
|
|
|
57
88
|
**Framework & ecosystem integrations**
|
|
58
89
|
|
|
59
|
-
| Package
|
|
60
|
-
|
|
|
61
|
-
| [@orpc/next](https://www.npmjs.com/package/@orpc/next)
|
|
62
|
-
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk)
|
|
63
|
-
| [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp)
|
|
64
|
-
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query)
|
|
65
|
-
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada)
|
|
66
|
-
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr)
|
|
67
|
-
| [@orpc/msw](https://www.npmjs.com/package/@orpc/msw)
|
|
68
|
-
| [@orpc/
|
|
69
|
-
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest)
|
|
70
|
-
| [@orpc/node](https://www.npmjs.com/package/@orpc/node)
|
|
71
|
-
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun)
|
|
72
|
-
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare)
|
|
73
|
-
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc)
|
|
90
|
+
| Package | Purpose | Docs |
|
|
91
|
+
| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next) |
|
|
93
|
+
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk) |
|
|
94
|
+
| [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp) | Expose procedures as [MCP](https://modelcontextprotocol.io/) tools. | [MCP](https://orpc.dev/docs/integrations/mcp) |
|
|
95
|
+
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query) |
|
|
96
|
+
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada) |
|
|
97
|
+
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
|
|
98
|
+
| [@orpc/msw](https://www.npmjs.com/package/@orpc/msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
|
|
99
|
+
| [@orpc/effect](https://www.npmjs.com/package/@orpc/effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
|
|
100
|
+
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
|
|
101
|
+
| [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression) |
|
|
102
|
+
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun) | Adapters for [Bun's Redis](https://bun.sh/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock) |
|
|
103
|
+
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare) | Adapters for [Cloudflare Workers](https://developers.cloudflare.com/workers/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock), [Traces](https://orpc.dev/docs/integrations/cloudflare-traces) |
|
|
104
|
+
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc) | Reuse existing [tRPC](https://trpc.io/) routers within oRPC. | [tRPC](https://orpc.dev/docs/integrations/trpc) |
|
|
74
105
|
|
|
75
106
|
**Observability**
|
|
76
107
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
|
|
2
|
+
export { AnyNestedClient } from '@orpc/client';
|
|
2
3
|
import { RouterContract, RouterContractClient, ContractClientFactory, AnySchema, ErrorMap, MetaPlugin, Meta, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
3
|
-
import { JsonifiedClient } from '@orpc/openapi';
|
|
4
|
-
import {
|
|
5
|
-
|
|
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';
|
|
6
8
|
|
|
7
9
|
type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
8
10
|
type InferLiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
@@ -100,15 +102,6 @@ interface SerializableStreamedQueryOptions {
|
|
|
100
102
|
*/
|
|
101
103
|
maxChunks?: number | undefined;
|
|
102
104
|
}
|
|
103
|
-
/**
|
|
104
|
-
* A Pinia Colada query function that accumulates streamed chunks into an array,
|
|
105
|
-
* publishing each chunk to the cache entry as it arrives.
|
|
106
|
-
*
|
|
107
|
-
* Inspired by [TanStack Query streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) where:
|
|
108
|
-
* - Options are serializable
|
|
109
|
-
* - The output is predictable
|
|
110
|
-
*/
|
|
111
|
-
declare function serializableStreamedQuery<T>(queryFn: (context: UseQueryFnContext) => Promisable<AsyncIterable<T>>, { refetchMode, maxChunks }?: SerializableStreamedQueryOptions): (context: UseQueryFnContext) => Promise<T[]>;
|
|
112
105
|
|
|
113
106
|
interface OperationKeyPrefixOptions {
|
|
114
107
|
/**
|
|
@@ -140,15 +133,6 @@ type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKe
|
|
|
140
133
|
inputMeta?: Record<string, string[]> | undefined;
|
|
141
134
|
};
|
|
142
135
|
type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>]);
|
|
143
|
-
/**
|
|
144
|
-
* Generate a Pinia Colada entry key for a procedure.
|
|
145
|
-
*
|
|
146
|
-
* The input is serialized to JSON-compatible values because Pinia Colada
|
|
147
|
-
* requires entry keys to be serializable.
|
|
148
|
-
*
|
|
149
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
150
|
-
*/
|
|
151
|
-
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
152
136
|
|
|
153
137
|
declare class SharedUtils<TInput> {
|
|
154
138
|
protected readonly path: string[];
|
|
@@ -266,7 +250,6 @@ interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TO
|
|
|
266
250
|
*/
|
|
267
251
|
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any>>> | undefined;
|
|
268
252
|
}
|
|
269
|
-
declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
270
253
|
/**
|
|
271
254
|
* Merge two procedure utils options where `override` takes priority.
|
|
272
255
|
* A key explicitly set to `undefined` in `override` resets the base value.
|
|
@@ -381,13 +364,6 @@ interface RouterUtilsPlugin<T extends AnyNestedClient> extends OrderablePlugin {
|
|
|
381
364
|
*/
|
|
382
365
|
initProcedureOptions?(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
383
366
|
}
|
|
384
|
-
declare class CompositeRouterUtilsPlugin<T extends AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
385
|
-
protected readonly plugins: RouterUtilsPlugin<T>[];
|
|
386
|
-
readonly name = "~composite";
|
|
387
|
-
constructor(plugins?: RouterUtilsPlugin<T>[]);
|
|
388
|
-
init(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
|
|
389
|
-
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
390
|
-
}
|
|
391
367
|
|
|
392
368
|
/**
|
|
393
369
|
* The utils shape derived from a client: procedure clients map to procedure
|
|
@@ -471,13 +447,18 @@ interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
|
|
|
471
447
|
}
|
|
472
448
|
interface ContractJsonifiedUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'path'> {
|
|
473
449
|
}
|
|
474
|
-
declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
|
|
475
|
-
|
|
476
450
|
/**
|
|
477
|
-
*
|
|
478
|
-
*
|
|
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}
|
|
479
460
|
*/
|
|
480
|
-
declare function
|
|
461
|
+
declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractJsonifiedClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
|
|
481
462
|
|
|
482
463
|
type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
|
|
483
464
|
interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
@@ -516,5 +497,5 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
516
497
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
517
498
|
}
|
|
518
499
|
|
|
519
|
-
export {
|
|
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 };
|
|
520
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
|
|
2
|
+
export { AnyNestedClient } from '@orpc/client';
|
|
2
3
|
import { RouterContract, RouterContractClient, ContractClientFactory, AnySchema, ErrorMap, MetaPlugin, Meta, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
3
|
-
import { JsonifiedClient } from '@orpc/openapi';
|
|
4
|
-
import {
|
|
5
|
-
|
|
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';
|
|
6
8
|
|
|
7
9
|
type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
8
10
|
type InferLiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
@@ -100,15 +102,6 @@ interface SerializableStreamedQueryOptions {
|
|
|
100
102
|
*/
|
|
101
103
|
maxChunks?: number | undefined;
|
|
102
104
|
}
|
|
103
|
-
/**
|
|
104
|
-
* A Pinia Colada query function that accumulates streamed chunks into an array,
|
|
105
|
-
* publishing each chunk to the cache entry as it arrives.
|
|
106
|
-
*
|
|
107
|
-
* Inspired by [TanStack Query streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) where:
|
|
108
|
-
* - Options are serializable
|
|
109
|
-
* - The output is predictable
|
|
110
|
-
*/
|
|
111
|
-
declare function serializableStreamedQuery<T>(queryFn: (context: UseQueryFnContext) => Promisable<AsyncIterable<T>>, { refetchMode, maxChunks }?: SerializableStreamedQueryOptions): (context: UseQueryFnContext) => Promise<T[]>;
|
|
112
105
|
|
|
113
106
|
interface OperationKeyPrefixOptions {
|
|
114
107
|
/**
|
|
@@ -140,15 +133,6 @@ type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKe
|
|
|
140
133
|
inputMeta?: Record<string, string[]> | undefined;
|
|
141
134
|
};
|
|
142
135
|
type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>]);
|
|
143
|
-
/**
|
|
144
|
-
* Generate a Pinia Colada entry key for a procedure.
|
|
145
|
-
*
|
|
146
|
-
* The input is serialized to JSON-compatible values because Pinia Colada
|
|
147
|
-
* requires entry keys to be serializable.
|
|
148
|
-
*
|
|
149
|
-
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
150
|
-
*/
|
|
151
|
-
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
152
136
|
|
|
153
137
|
declare class SharedUtils<TInput> {
|
|
154
138
|
protected readonly path: string[];
|
|
@@ -266,7 +250,6 @@ interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TO
|
|
|
266
250
|
*/
|
|
267
251
|
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any>>> | undefined;
|
|
268
252
|
}
|
|
269
|
-
declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
270
253
|
/**
|
|
271
254
|
* Merge two procedure utils options where `override` takes priority.
|
|
272
255
|
* A key explicitly set to `undefined` in `override` resets the base value.
|
|
@@ -381,13 +364,6 @@ interface RouterUtilsPlugin<T extends AnyNestedClient> extends OrderablePlugin {
|
|
|
381
364
|
*/
|
|
382
365
|
initProcedureOptions?(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
383
366
|
}
|
|
384
|
-
declare class CompositeRouterUtilsPlugin<T extends AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
385
|
-
protected readonly plugins: RouterUtilsPlugin<T>[];
|
|
386
|
-
readonly name = "~composite";
|
|
387
|
-
constructor(plugins?: RouterUtilsPlugin<T>[]);
|
|
388
|
-
init(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
|
|
389
|
-
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
390
|
-
}
|
|
391
367
|
|
|
392
368
|
/**
|
|
393
369
|
* The utils shape derived from a client: procedure clients map to procedure
|
|
@@ -471,13 +447,18 @@ interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
|
|
|
471
447
|
}
|
|
472
448
|
interface ContractJsonifiedUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'path'> {
|
|
473
449
|
}
|
|
474
|
-
declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
|
|
475
|
-
|
|
476
450
|
/**
|
|
477
|
-
*
|
|
478
|
-
*
|
|
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}
|
|
479
460
|
*/
|
|
480
|
-
declare function
|
|
461
|
+
declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractJsonifiedClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
|
|
481
462
|
|
|
482
463
|
type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
|
|
483
464
|
interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
@@ -516,5 +497,5 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
516
497
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
517
498
|
}
|
|
518
499
|
|
|
519
|
-
export {
|
|
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 };
|
|
520
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -539,8 +539,11 @@ function createRouterUtilsInternal(client, options, plugin) {
|
|
|
539
539
|
const recursive = new Proxy(utils, {
|
|
540
540
|
get(target, prop) {
|
|
541
541
|
const value = Reflect.get(target, prop);
|
|
542
|
+
if (RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop)) {
|
|
543
|
+
return value ?? Reflect.get(Object.prototype, prop);
|
|
544
|
+
}
|
|
542
545
|
const nextClient = Reflect.get(client, prop);
|
|
543
|
-
if (typeof prop !== "string" ||
|
|
546
|
+
if (typeof prop !== "string" || !isTypescriptObject(nextClient)) {
|
|
544
547
|
return value;
|
|
545
548
|
}
|
|
546
549
|
let result = cache.get(prop);
|
|
@@ -616,4 +619,4 @@ class ContractOptionsUtilsPlugin {
|
|
|
616
619
|
}
|
|
617
620
|
}
|
|
618
621
|
|
|
619
|
-
export {
|
|
622
|
+
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 };
|
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.46",
|
|
5
5
|
"description": "Pinia Colada integration for oRPC: typesafe queries and mutations for Vue",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"vue": ">=3.5.17"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@orpc/client": "2.0.0-beta.
|
|
45
|
-
"@orpc/contract": "2.0.0-beta.
|
|
46
|
-
"@orpc/openapi": "2.0.0-beta.
|
|
47
|
-
"@orpc/shared": "2.0.0-beta.
|
|
44
|
+
"@orpc/client": "2.0.0-beta.46",
|
|
45
|
+
"@orpc/contract": "2.0.0-beta.46",
|
|
46
|
+
"@orpc/openapi": "2.0.0-beta.46",
|
|
47
|
+
"@orpc/shared": "2.0.0-beta.46"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@pinia/colada": "^1.4.8",
|