@orpc/vue-query 0.0.0-next.e710b76 → 0.0.0-next.e77ba7d
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 +7 -2
- package/dist/index.d.mts +4 -18
- package/dist/index.d.ts +4 -18
- package/dist/index.mjs +4 -25
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -30,7 +33,8 @@
|
|
|
30
33
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
34
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
35
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
-
|
|
36
|
+
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
34
38
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
39
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
40
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -38,7 +42,6 @@
|
|
|
38
42
|
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
43
|
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
44
|
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
-
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
@@ -50,9 +53,11 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
50
53
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
51
54
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
55
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
56
|
+
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
|
|
53
57
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
54
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
55
59
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
56
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
57
62
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
58
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
3
3
|
export { OperationKeyOptions as BuildKeyOptions, OperationType as KeyType, generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
4
|
-
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext,
|
|
4
|
+
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
5
5
|
import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
6
|
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
7
7
|
|
|
@@ -42,14 +42,7 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
42
42
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
43
43
|
throwOnError?(error: TError): boolean;
|
|
44
44
|
retryDelay?: (count: number, error: TError) => number;
|
|
45
|
-
enabled: ComputedRef<boolean>;
|
|
46
|
-
}
|
|
47
|
-
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
48
|
-
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
49
|
-
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
50
|
-
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
51
|
-
};
|
|
52
|
-
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
45
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
53
46
|
}
|
|
54
47
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
55
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
@@ -68,7 +61,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
|
68
61
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
69
62
|
throwOnError?(error: TError): boolean;
|
|
70
63
|
retryDelay?: (count: number, error: TError) => number;
|
|
71
|
-
enabled: ComputedRef<boolean>;
|
|
64
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
72
65
|
}
|
|
73
66
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
74
67
|
context?: TClientContext;
|
|
@@ -94,13 +87,6 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
94
87
|
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
95
88
|
*/
|
|
96
89
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
97
|
-
/**
|
|
98
|
-
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
|
|
99
|
-
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
100
|
-
*
|
|
101
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
|
|
102
|
-
*/
|
|
103
|
-
experimental_streamedOptions<U, USelectData = experimental_InferStreamedOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>>;
|
|
104
90
|
/**
|
|
105
91
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
106
92
|
*
|
|
@@ -139,4 +125,4 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
139
125
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
140
126
|
|
|
141
127
|
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
142
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep
|
|
128
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
3
3
|
export { OperationKeyOptions as BuildKeyOptions, OperationType as KeyType, generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
4
|
-
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext,
|
|
4
|
+
import { QueryKey, SkipToken, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
|
|
5
5
|
import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
6
|
import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
|
|
7
7
|
|
|
@@ -42,14 +42,7 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
42
42
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
43
43
|
throwOnError?(error: TError): boolean;
|
|
44
44
|
retryDelay?: (count: number, error: TError) => number;
|
|
45
|
-
enabled: ComputedRef<boolean>;
|
|
46
|
-
}
|
|
47
|
-
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
48
|
-
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
49
|
-
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
50
|
-
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
51
|
-
};
|
|
52
|
-
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
45
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
53
46
|
}
|
|
54
47
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
|
|
55
48
|
context?: MaybeRefDeep<TClientContext>;
|
|
@@ -68,7 +61,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
|
68
61
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
69
62
|
throwOnError?(error: TError): boolean;
|
|
70
63
|
retryDelay?: (count: number, error: TError) => number;
|
|
71
|
-
enabled: ComputedRef<boolean>;
|
|
64
|
+
enabled: ComputedRef<boolean | undefined>;
|
|
72
65
|
}
|
|
73
66
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
74
67
|
context?: TClientContext;
|
|
@@ -94,13 +87,6 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
94
87
|
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
95
88
|
*/
|
|
96
89
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
97
|
-
/**
|
|
98
|
-
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
|
|
99
|
-
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
100
|
-
*
|
|
101
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query-old/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
|
|
102
|
-
*/
|
|
103
|
-
experimental_streamedOptions<U, USelectData = experimental_InferStreamedOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>>;
|
|
104
90
|
/**
|
|
105
91
|
* Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
|
|
106
92
|
*
|
|
@@ -139,4 +125,4 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
|
|
|
139
125
|
declare function unrefDeep<T>(value: T): UnrefDeep<T>;
|
|
140
126
|
|
|
141
127
|
export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
|
|
142
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep
|
|
128
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { generateOperationKey } from '@orpc/tanstack-query';
|
|
2
2
|
export { generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
3
|
-
import {
|
|
4
|
-
import { skipToken, experimental_streamedQuery } from '@tanstack/vue-query';
|
|
3
|
+
import { skipToken } from '@tanstack/vue-query';
|
|
5
4
|
import { isRef, computed } from 'vue';
|
|
5
|
+
import { isObject } from '@orpc/shared';
|
|
6
6
|
|
|
7
7
|
function createGeneralUtils(path) {
|
|
8
8
|
return {
|
|
@@ -41,28 +41,7 @@ function createProcedureUtils(client, options) {
|
|
|
41
41
|
}
|
|
42
42
|
return client(input, { signal, context: unrefDeep(optionsIn.context) });
|
|
43
43
|
},
|
|
44
|
-
enabled: computed(() => unrefDeep(optionsIn.input)
|
|
45
|
-
...optionsIn
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
experimental_streamedOptions(...[optionsIn = {}]) {
|
|
49
|
-
return {
|
|
50
|
-
enabled: computed(() => unrefDeep(optionsIn.input) !== skipToken),
|
|
51
|
-
queryKey: computed(() => generateOperationKey(options.path, { type: "streamed", input: unrefDeep(optionsIn.input), fnOptions: optionsIn.queryFnOptions })),
|
|
52
|
-
queryFn: experimental_streamedQuery({
|
|
53
|
-
queryFn: async ({ signal }) => {
|
|
54
|
-
const input = unrefDeep(optionsIn.input);
|
|
55
|
-
if (input === skipToken) {
|
|
56
|
-
throw new Error("queryFn should not be called with skipToken used as input");
|
|
57
|
-
}
|
|
58
|
-
const output = await client(input, { signal, context: unrefDeep(optionsIn.context) });
|
|
59
|
-
if (!isAsyncIteratorObject(output)) {
|
|
60
|
-
throw new Error("streamedQuery requires an event iterator output");
|
|
61
|
-
}
|
|
62
|
-
return output;
|
|
63
|
-
},
|
|
64
|
-
...optionsIn.queryFnOptions
|
|
65
|
-
}),
|
|
44
|
+
enabled: computed(() => unrefDeep(optionsIn.input) === skipToken ? false : void 0),
|
|
66
45
|
...optionsIn
|
|
67
46
|
};
|
|
68
47
|
},
|
|
@@ -82,7 +61,7 @@ function createProcedureUtils(client, options) {
|
|
|
82
61
|
}
|
|
83
62
|
return client(unrefDeep(input(pageParam)), { signal, context: unrefDeep(optionsIn.context) });
|
|
84
63
|
},
|
|
85
|
-
enabled: computed(() => unrefDeep(optionsIn.input)
|
|
64
|
+
enabled: computed(() => unrefDeep(optionsIn.input) === skipToken ? false : void 0),
|
|
86
65
|
...optionsIn
|
|
87
66
|
};
|
|
88
67
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/vue-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.e77ba7d",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@tanstack/vue-query": ">=5.80.2",
|
|
31
31
|
"vue": ">=3.3.0",
|
|
32
|
-
"@orpc/client": "0.0.0-next.
|
|
32
|
+
"@orpc/client": "0.0.0-next.e77ba7d"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/shared": "0.0.0-next.
|
|
36
|
-
"@orpc/tanstack-query": "0.0.0-next.
|
|
35
|
+
"@orpc/shared": "0.0.0-next.e77ba7d",
|
|
36
|
+
"@orpc/tanstack-query": "0.0.0-next.e77ba7d"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@tanstack/vue-query": "^5.
|
|
39
|
+
"@tanstack/vue-query": "^5.91.2"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild",
|