@orpc/vue-query 1.0.0-beta.6 → 1.0.3

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
@@ -21,28 +21,24 @@
21
21
 
22
22
  <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
23
23
 
24
- **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
24
+ **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
25
25
 
26
26
  ---
27
27
 
28
28
  ## Highlights
29
29
 
30
- - **End-to-End Type Safety 🔒**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
31
- - **First-Class OpenAPI 📄**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
32
- - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
- - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
- - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
- - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
- - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
- - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
39
- - **Native Types 📦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
40
- - **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
41
- - **SSE & Streaming 📡**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
42
- - **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
43
- - **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
44
- - **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
45
- - **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
30
+ - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
31
+ - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
32
+ - **📝 Contract-First Development**: Optionally define your API contract before implementation.
33
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
34
+ - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
+ - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
+ - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
37
+ - **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
38
+ - **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
39
+ - **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
40
+ - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
41
+ - **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
46
42
 
47
43
  ## Documentation
48
44
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ClientContext, Client, NestedClient } from '@orpc/client';
2
- import { QueryKey, QueryObserverOptions, QueryFunctionContext, UseInfiniteQueryOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
3
- import { PartialDeep, AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
2
+ import { QueryKey, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
3
+ import { PartialDeep, AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
5
5
 
6
6
  type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
@@ -11,6 +11,11 @@ interface BuildKeyOptions<TType extends KeyType, TInput> {
11
11
  declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
12
12
 
13
13
  interface GeneralUtils<TInput> {
14
+ /**
15
+ * Generate a query/mutation key for checking status, invalidate, set, get, etc.
16
+ *
17
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
18
+ */
14
19
  key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
15
20
  }
16
21
  declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
@@ -35,7 +40,7 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
35
40
  } & {
36
41
  enabled?: MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['enabled']>;
37
42
  queryKey?: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['queryKey']>;
38
- shallow?: MaybeRef<boolean>;
43
+ shallow?: boolean;
39
44
  };
40
45
  interface QueryOptionsBase<TOutput, TError> {
41
46
  queryKey: ComputedRef<QueryKey>;
@@ -48,7 +53,13 @@ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
48
53
  context?: MaybeRefDeep<TClientContext>;
49
54
  } : {
50
55
  context: MaybeRefDeep<TClientContext>;
51
- }) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
56
+ }) & {
57
+ [Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey' | 'enabled'>]: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>[Property]>;
58
+ } & {
59
+ enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['enabled']>;
60
+ queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['queryKey']>;
61
+ shallow?: boolean;
62
+ };
52
63
  interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
53
64
  queryKey: ComputedRef<QueryKey>;
54
65
  queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
@@ -66,9 +77,29 @@ type MutationOptions<TInput, TOutput, TError, TMutationContext> = {
66
77
  };
67
78
 
68
79
  interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
80
+ /**
81
+ * Calling corresponding procedure client
82
+ *
83
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
84
+ */
69
85
  call: Client<TClientContext, TInput, TOutput, TError>;
86
+ /**
87
+ * Generate options used for useQuery/prefetchQuery/...
88
+ *
89
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
90
+ */
70
91
  queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
92
+ /**
93
+ * Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
94
+ *
95
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
96
+ */
71
97
  infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
98
+ /**
99
+ * Generate options used for useMutation/...
100
+ *
101
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#mutation-options Tanstack Mutation Options Docs}
102
+ */
72
103
  mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
73
104
  }
74
105
  interface CreateProcedureUtilsOptions {
@@ -82,6 +113,12 @@ type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientCo
82
113
  interface CreateRouterUtilsOptions {
83
114
  path?: string[];
84
115
  }
116
+ /**
117
+ * Create a router utils from a client.
118
+ *
119
+ * @info Both client-side and server-side clients are supported.
120
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/vue Tanstack Query Vue Docs}
121
+ */
85
122
  declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
86
123
 
87
124
  type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
@@ -89,4 +126,5 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
89
126
  } : T;
90
127
  declare function unrefDeep<T>(value: T): UnrefDeep<T>;
91
128
 
92
- export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, type UnrefDeep, buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
129
+ export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
130
+ export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ClientContext, Client, NestedClient } from '@orpc/client';
2
- import { QueryKey, QueryObserverOptions, QueryFunctionContext, UseInfiniteQueryOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
3
- import { PartialDeep, AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
2
+ import { QueryKey, QueryObserverOptions, QueryFunctionContext, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
3
+ import { PartialDeep, AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
5
5
 
6
6
  type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
@@ -11,6 +11,11 @@ interface BuildKeyOptions<TType extends KeyType, TInput> {
11
11
  declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
12
12
 
13
13
  interface GeneralUtils<TInput> {
14
+ /**
15
+ * Generate a query/mutation key for checking status, invalidate, set, get, etc.
16
+ *
17
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
18
+ */
14
19
  key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
15
20
  }
16
21
  declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
@@ -35,7 +40,7 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
35
40
  } & {
36
41
  enabled?: MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['enabled']>;
37
42
  queryKey?: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['queryKey']>;
38
- shallow?: MaybeRef<boolean>;
43
+ shallow?: boolean;
39
44
  };
40
45
  interface QueryOptionsBase<TOutput, TError> {
41
46
  queryKey: ComputedRef<QueryKey>;
@@ -48,7 +53,13 @@ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
48
53
  context?: MaybeRefDeep<TClientContext>;
49
54
  } : {
50
55
  context: MaybeRefDeep<TClientContext>;
51
- }) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
56
+ }) & {
57
+ [Property in keyof Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey' | 'enabled'>]: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>[Property]>;
58
+ } & {
59
+ enabled?: MaybeRefOrGetter<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['enabled']>;
60
+ queryKey?: MaybeRefDeep<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>['queryKey']>;
61
+ shallow?: boolean;
62
+ };
52
63
  interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
53
64
  queryKey: ComputedRef<QueryKey>;
54
65
  queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
@@ -66,9 +77,29 @@ type MutationOptions<TInput, TOutput, TError, TMutationContext> = {
66
77
  };
67
78
 
68
79
  interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
80
+ /**
81
+ * Calling corresponding procedure client
82
+ *
83
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
84
+ */
69
85
  call: Client<TClientContext, TInput, TOutput, TError>;
86
+ /**
87
+ * Generate options used for useQuery/prefetchQuery/...
88
+ *
89
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
90
+ */
70
91
  queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
92
+ /**
93
+ * Generate options used for useInfiniteQuery/prefetchInfiniteQuery/...
94
+ *
95
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
96
+ */
71
97
  infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
98
+ /**
99
+ * Generate options used for useMutation/...
100
+ *
101
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#mutation-options Tanstack Mutation Options Docs}
102
+ */
72
103
  mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
73
104
  }
74
105
  interface CreateProcedureUtilsOptions {
@@ -82,6 +113,12 @@ type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientCo
82
113
  interface CreateRouterUtilsOptions {
83
114
  path?: string[];
84
115
  }
116
+ /**
117
+ * Create a router utils from a client.
118
+ *
119
+ * @info Both client-side and server-side clients are supported.
120
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/vue Tanstack Query Vue Docs}
121
+ */
85
122
  declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
86
123
 
87
124
  type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
@@ -89,4 +126,5 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
89
126
  } : T;
90
127
  declare function unrefDeep<T>(value: T): UnrefDeep<T>;
91
128
 
92
- export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, type UnrefDeep, buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
129
+ export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
130
+ export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/vue-query",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.6",
4
+ "version": "1.0.3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -27,12 +27,13 @@
27
27
  "dist"
28
28
  ],
29
29
  "peerDependencies": {
30
- "@tanstack/vue-query": ">=5.50.0",
30
+ "@tanstack/vue-query": ">=5.55.0",
31
31
  "vue": ">=3.3.0",
32
- "@orpc/client": "1.0.0-beta.6"
32
+ "@orpc/client": "1.0.3"
33
33
  },
34
34
  "dependencies": {
35
- "@orpc/shared": "1.0.0-beta.6"
35
+ "@tanstack/vue-query": "^5.72.2",
36
+ "@orpc/shared": "1.0.3"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "unbuild",