@orpc/vue-query 0.0.0-next.fea68c1 → 0.0.0-next.ff68fdb

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
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 />
2
+ <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
3
3
  </div>
4
4
 
5
5
  <h1></h1>
@@ -32,7 +32,7 @@
32
32
  - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
33
  - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
34
  - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
35
+ - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
36
  - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
37
  - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
38
  - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
@@ -55,6 +55,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
55
55
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
56
  - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
57
57
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
58
+ - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
59
+ - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
58
60
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
61
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
62
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
@@ -0,0 +1,92 @@
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';
4
+ import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
5
+
6
+ type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
7
+ interface BuildKeyOptions<TType extends KeyType, TInput> {
8
+ type?: TType;
9
+ input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
10
+ }
11
+ declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
12
+
13
+ interface GeneralUtils<TInput> {
14
+ key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
15
+ }
16
+ declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
17
+
18
+ /**
19
+ * Since `@tanstack/vue-query` is not exporting the type `MaybeRefDeep` we need to copy it from the source code.
20
+ * https://github.com/TanStack/query/blob/7ff544e12e79388e513b1cd886aeb946f80f0153/packages/vue-query/src/types.ts#L19C1-L27C2
21
+ */
22
+ type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
23
+ [Property in keyof T]: MaybeRefDeep<T[Property]>;
24
+ } : T>;
25
+ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
26
+ input?: MaybeRefDeep<TInput>;
27
+ } : {
28
+ input: MaybeRefDeep<TInput>;
29
+ }) & (Record<never, never> extends TClientContext ? {
30
+ context?: MaybeRefDeep<TClientContext>;
31
+ } : {
32
+ context: MaybeRefDeep<TClientContext>;
33
+ }) & {
34
+ [P in keyof Omit<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>, 'queryKey' | 'enabled'>]: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>[P]>;
35
+ } & {
36
+ enabled?: MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['enabled']>;
37
+ queryKey?: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['queryKey']>;
38
+ shallow?: MaybeRef<boolean>;
39
+ };
40
+ interface QueryOptionsBase<TOutput, TError extends Error> {
41
+ queryKey: ComputedRef<QueryKey>;
42
+ queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
43
+ retry?(failureCount: number, error: TError): boolean;
44
+ }
45
+ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
46
+ input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
47
+ } & (Record<never, never> extends TClientContext ? {
48
+ context?: MaybeRefDeep<TClientContext>;
49
+ } : {
50
+ context: MaybeRefDeep<TClientContext>;
51
+ }) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
52
+ interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam> {
53
+ queryKey: ComputedRef<QueryKey>;
54
+ queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
55
+ retry?(failureCount: number, error: TError): boolean;
56
+ }
57
+ type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TMutationContext> = (Record<never, never> extends TClientContext ? {
58
+ context?: TClientContext;
59
+ } : {
60
+ context: TClientContext;
61
+ }) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
62
+ type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext> = {
63
+ [P in keyof MutationObserverOptions<TOutput, TError, TInput, TMutationContext>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput, TMutationContext>[P]>;
64
+ } & {
65
+ shallow?: MaybeRef<boolean>;
66
+ };
67
+
68
+ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
69
+ call: Client<TClientContext, TInput, TOutput, TError>;
70
+ queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
71
+ 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>>;
72
+ mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
73
+ }
74
+ interface CreateProcedureUtilsOptions {
75
+ path: string[];
76
+ }
77
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
78
+
79
+ type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
80
+ [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
81
+ } & GeneralUtils<unknown>;
82
+ interface CreateRouterUtilsOptions {
83
+ path?: string[];
84
+ }
85
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
86
+
87
+ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
88
+ [K in keyof T]: UnrefDeep<T[K]>;
89
+ } : T;
90
+ declare function unrefDeep<T>(value: T): UnrefDeep<T>;
91
+
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 };
@@ -0,0 +1,92 @@
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';
4
+ import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
5
+
6
+ type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
7
+ interface BuildKeyOptions<TType extends KeyType, TInput> {
8
+ type?: TType;
9
+ input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
10
+ }
11
+ declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
12
+
13
+ interface GeneralUtils<TInput> {
14
+ key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
15
+ }
16
+ declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
17
+
18
+ /**
19
+ * Since `@tanstack/vue-query` is not exporting the type `MaybeRefDeep` we need to copy it from the source code.
20
+ * https://github.com/TanStack/query/blob/7ff544e12e79388e513b1cd886aeb946f80f0153/packages/vue-query/src/types.ts#L19C1-L27C2
21
+ */
22
+ type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
23
+ [Property in keyof T]: MaybeRefDeep<T[Property]>;
24
+ } : T>;
25
+ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
26
+ input?: MaybeRefDeep<TInput>;
27
+ } : {
28
+ input: MaybeRefDeep<TInput>;
29
+ }) & (Record<never, never> extends TClientContext ? {
30
+ context?: MaybeRefDeep<TClientContext>;
31
+ } : {
32
+ context: MaybeRefDeep<TClientContext>;
33
+ }) & {
34
+ [P in keyof Omit<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>, 'queryKey' | 'enabled'>]: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>[P]>;
35
+ } & {
36
+ enabled?: MaybeRefOrGetter<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['enabled']>;
37
+ queryKey?: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>['queryKey']>;
38
+ shallow?: MaybeRef<boolean>;
39
+ };
40
+ interface QueryOptionsBase<TOutput, TError extends Error> {
41
+ queryKey: ComputedRef<QueryKey>;
42
+ queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
43
+ retry?(failureCount: number, error: TError): boolean;
44
+ }
45
+ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
46
+ input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
47
+ } & (Record<never, never> extends TClientContext ? {
48
+ context?: MaybeRefDeep<TClientContext>;
49
+ } : {
50
+ context: MaybeRefDeep<TClientContext>;
51
+ }) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
52
+ interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam> {
53
+ queryKey: ComputedRef<QueryKey>;
54
+ queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
55
+ retry?(failureCount: number, error: TError): boolean;
56
+ }
57
+ type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TMutationContext> = (Record<never, never> extends TClientContext ? {
58
+ context?: TClientContext;
59
+ } : {
60
+ context: TClientContext;
61
+ }) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
62
+ type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext> = {
63
+ [P in keyof MutationObserverOptions<TOutput, TError, TInput, TMutationContext>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput, TMutationContext>[P]>;
64
+ } & {
65
+ shallow?: MaybeRef<boolean>;
66
+ };
67
+
68
+ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
69
+ call: Client<TClientContext, TInput, TOutput, TError>;
70
+ queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
71
+ 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>>;
72
+ mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
73
+ }
74
+ interface CreateProcedureUtilsOptions {
75
+ path: string[];
76
+ }
77
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
78
+
79
+ type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
80
+ [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
81
+ } & GeneralUtils<unknown>;
82
+ interface CreateRouterUtilsOptions {
83
+ path?: string[];
84
+ }
85
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
86
+
87
+ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
88
+ [K in keyof T]: UnrefDeep<T[K]>;
89
+ } : T;
90
+ declare function unrefDeep<T>(value: T): UnrefDeep<T>;
91
+
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 };
@@ -1,4 +1,6 @@
1
- // src/key.ts
1
+ import { isRef, computed } from 'vue';
2
+ import { isObject } from '@orpc/shared';
3
+
2
4
  function buildKey(path, options) {
3
5
  const withInput = options?.input !== void 0 ? { input: options?.input } : {};
4
6
  const withType = options?.type !== void 0 ? { type: options?.type } : {};
@@ -8,7 +10,6 @@ function buildKey(path, options) {
8
10
  }];
9
11
  }
10
12
 
11
- // src/general-utils.ts
12
13
  function createGeneralUtils(path) {
13
14
  return {
14
15
  key(options) {
@@ -17,12 +18,6 @@ function createGeneralUtils(path) {
17
18
  };
18
19
  }
19
20
 
20
- // src/procedure-utils.ts
21
- import { computed } from "vue";
22
-
23
- // src/utils.ts
24
- import { isObject } from "@orpc/shared";
25
- import { isRef } from "vue";
26
21
  function unrefDeep(value) {
27
22
  if (isRef(value)) {
28
23
  return unrefDeep(value.value);
@@ -39,42 +34,41 @@ function unrefDeep(value) {
39
34
  return value;
40
35
  }
41
36
 
42
- // src/procedure-utils.ts
43
- function createProcedureUtils(client, path) {
37
+ function createProcedureUtils(client, options) {
44
38
  return {
45
39
  call: client,
46
- queryOptions(...[{ input, context, ...rest } = {}]) {
40
+ queryOptions(...[optionsIn = {}]) {
47
41
  return {
48
- queryKey: computed(() => buildKey(path, { type: "query", input: unrefDeep(input) })),
49
- queryFn: ({ signal }) => client(unrefDeep(input), { signal, context: unrefDeep(context) }),
50
- ...rest
42
+ queryKey: computed(() => buildKey(options.path, { type: "query", input: unrefDeep(optionsIn.input) })),
43
+ queryFn: ({ signal }) => client(unrefDeep(optionsIn.input), { signal, context: unrefDeep(optionsIn.context) }),
44
+ ...optionsIn
51
45
  };
52
46
  },
53
- infiniteOptions({ input, context, ...rest }) {
47
+ infiniteOptions(optionsIn) {
54
48
  return {
55
49
  queryKey: computed(() => {
56
- return buildKey(path, { type: "infinite", input: unrefDeep(input(unrefDeep(rest.initialPageParam))) });
50
+ return buildKey(options.path, { type: "infinite", input: unrefDeep(optionsIn.input(unrefDeep(optionsIn.initialPageParam))) });
57
51
  }),
58
52
  queryFn: ({ pageParam, signal }) => {
59
- return client(unrefDeep(input(pageParam)), { signal, context: unrefDeep(context) });
53
+ return client(unrefDeep(optionsIn.input(pageParam)), { signal, context: unrefDeep(optionsIn.context) });
60
54
  },
61
- ...rest
55
+ ...optionsIn
62
56
  };
63
57
  },
64
- mutationOptions(...[{ context, ...rest } = {}]) {
58
+ mutationOptions(...[optionsIn = {}]) {
65
59
  return {
66
- mutationKey: buildKey(path, { type: "mutation" }),
67
- mutationFn: (input) => client(input, { context: unrefDeep(context) }),
68
- ...rest
60
+ mutationKey: buildKey(options.path, { type: "mutation" }),
61
+ mutationFn: (input) => client(input, { context: unrefDeep(optionsIn.context) }),
62
+ ...optionsIn
69
63
  };
70
64
  }
71
65
  };
72
66
  }
73
67
 
74
- // src/router-utils.ts
75
- function createRouterUtils(client, path = []) {
68
+ function createRouterUtils(client, options = {}) {
69
+ const path = options.path ?? [];
76
70
  const generalUtils = createGeneralUtils(path);
77
- const procedureUtils = createProcedureUtils(client, path);
71
+ const procedureUtils = createProcedureUtils(client, { path });
78
72
  const recursive = new Proxy({
79
73
  ...generalUtils,
80
74
  ...procedureUtils
@@ -84,7 +78,7 @@ function createRouterUtils(client, path = []) {
84
78
  if (typeof prop !== "string") {
85
79
  return value;
86
80
  }
87
- const nextUtils = createRouterUtils(client[prop], [...path, prop]);
81
+ const nextUtils = createRouterUtils(client[prop], { ...options, path: [...path, prop] });
88
82
  if (typeof value !== "function") {
89
83
  return nextUtils;
90
84
  }
@@ -98,13 +92,4 @@ function createRouterUtils(client, path = []) {
98
92
  return recursive;
99
93
  }
100
94
 
101
- // src/index.ts
102
- var createORPCVueQueryUtils = createRouterUtils;
103
- export {
104
- buildKey,
105
- createGeneralUtils,
106
- createORPCVueQueryUtils,
107
- createProcedureUtils,
108
- createRouterUtils
109
- };
110
- //# sourceMappingURL=index.js.map
95
+ export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
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.fea68c1",
4
+ "version": "0.0.0-next.ff68fdb",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -18,29 +18,24 @@
18
18
  ],
19
19
  "exports": {
20
20
  ".": {
21
- "types": "./dist/src/index.d.ts",
22
- "import": "./dist/index.js",
23
- "default": "./dist/index.js"
24
- },
25
- "./🔒/*": {
26
- "types": "./dist/src/*.d.ts"
21
+ "types": "./dist/index.d.mts",
22
+ "import": "./dist/index.mjs",
23
+ "default": "./dist/index.mjs"
27
24
  }
28
25
  },
29
26
  "files": [
30
- "!**/*.map",
31
- "!**/*.tsbuildinfo",
32
27
  "dist"
33
28
  ],
34
29
  "peerDependencies": {
35
30
  "@tanstack/vue-query": ">=5.50.0",
36
31
  "vue": ">=3.3.0",
37
- "@orpc/client": "0.0.0-next.fea68c1"
32
+ "@orpc/client": "0.0.0-next.ff68fdb"
38
33
  },
39
34
  "dependencies": {
40
- "@orpc/shared": "0.0.0-next.fea68c1"
35
+ "@orpc/shared": "0.0.0-next.ff68fdb"
41
36
  },
42
37
  "scripts": {
43
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
38
+ "build": "unbuild",
44
39
  "build:watch": "pnpm run build --watch",
45
40
  "type:check": "tsc -b"
46
41
  }
@@ -1,7 +0,0 @@
1
- import type { QueryKey } from '@tanstack/vue-query';
2
- import type { BuildKeyOptions, KeyType } from './key';
3
- export interface GeneralUtils<TInput> {
4
- key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
5
- }
6
- export declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
7
- //# sourceMappingURL=general-utils.d.ts.map
@@ -1,8 +0,0 @@
1
- import { createRouterUtils } from './router-utils';
2
- export * from './general-utils';
3
- export * from './key';
4
- export * from './procedure-utils';
5
- export * from './router-utils';
6
- export * from './types';
7
- export declare const createORPCVueQueryUtils: typeof createRouterUtils;
8
- //# sourceMappingURL=index.d.ts.map
package/dist/src/key.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { PartialDeep } from '@orpc/shared';
2
- import type { QueryKey } from '@tanstack/vue-query';
3
- export type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
4
- export interface BuildKeyOptions<TType extends KeyType, TInput> {
5
- type?: TType;
6
- input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
7
- }
8
- export declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
9
- //# sourceMappingURL=key.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { Client, ClientContext } from '@orpc/client';
2
- import type { MaybeOptionalOptions } from '@orpc/shared';
3
- import type { InfiniteData } from '@tanstack/vue-query';
4
- import type { InfiniteOptionsBase, InfiniteOptionsIn, MutationOptionsBase, MutationOptionsIn, QueryOptionsBase, QueryOptionsIn } from './types';
5
- export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
6
- call: Client<TClientContext, TInput, TOutput, TError>;
7
- queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & QueryOptionsBase<TOutput, TError>>;
8
- infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>;
9
- mutationOptions<U>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError>>): NoInfer<U & MutationOptionsBase<TInput, TOutput, TError>>;
10
- }
11
- export declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
12
- //# sourceMappingURL=procedure-utils.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { Client, NestedClient } from '@orpc/client';
2
- import { type GeneralUtils } from './general-utils';
3
- import { type ProcedureUtils } from './procedure-utils';
4
- export type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
5
- [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
6
- } & GeneralUtils<unknown>;
7
- /**
8
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
9
- * @param path - The base path for query key, when it it will be prefix to all keys
10
- */
11
- export declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
12
- //# sourceMappingURL=router-utils.d.ts.map
@@ -1,58 +0,0 @@
1
- import type { ClientContext } from '@orpc/client';
2
- import type { AnyFunction, SetOptional } from '@orpc/shared';
3
- import type { Enabled, MutationObserverOptions, QueryFunctionContext, QueryKey, QueryObserverOptions, UseInfiniteQueryOptions } from '@tanstack/vue-query';
4
- import type { ComputedRef, MaybeRef, MaybeRefOrGetter } from 'vue';
5
- /**
6
- * Since `@tanstack/vue-query` is not exporting the type `MaybeRefDeep` we need to copy it from the source code.
7
- * https://github.com/TanStack/query/blob/7ff544e12e79388e513b1cd886aeb946f80f0153/packages/vue-query/src/types.ts#L19C1-L27C2
8
- */
9
- export type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
10
- [Property in keyof T]: MaybeRefDeep<T[Property]>;
11
- } : T>;
12
- export type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData> = (undefined extends TInput ? {
13
- input?: MaybeRefDeep<TInput>;
14
- } : {
15
- input: MaybeRefDeep<TInput>;
16
- }) & (Record<never, never> extends TClientContext ? {
17
- context?: MaybeRefDeep<TClientContext>;
18
- } : {
19
- context: MaybeRefDeep<TClientContext>;
20
- }) & {
21
- [P in keyof Omit<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>, 'queryKey' | 'enabled'>]: MaybeRefDeep<QueryObserverOptions<TOutput, TError, TSelectData, TOutput>[P]>;
22
- } & {
23
- enabled?: MaybeRefOrGetter<Enabled<TOutput, TError, TSelectData>>;
24
- queryKey?: MaybeRefDeep<QueryKey>;
25
- shallow?: boolean;
26
- };
27
- export interface QueryOptionsBase<TOutput, TError extends Error> {
28
- queryKey: ComputedRef<QueryKey>;
29
- queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
30
- retry?(failureCount: number, error: TError): boolean;
31
- }
32
- export type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TSelectData, TPageParam> = {
33
- input: (pageParam: TPageParam) => MaybeRefDeep<TInput>;
34
- } & (Record<never, never> extends TClientContext ? {
35
- context?: MaybeRefDeep<TClientContext>;
36
- } : {
37
- context: MaybeRefDeep<TClientContext>;
38
- }) & SetOptional<UseInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
39
- export interface InfiniteOptionsBase<TOutput, TError extends Error, TPageParam> {
40
- queryKey: ComputedRef<QueryKey>;
41
- queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
42
- retry?(failureCount: number, error: TError): boolean;
43
- }
44
- export type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (Record<never, never> extends TClientContext ? {
45
- context?: TClientContext;
46
- } : {
47
- context: TClientContext;
48
- }) & {
49
- [P in keyof MutationObserverOptions<TOutput, TError, TInput>]: MaybeRefDeep<MutationObserverOptions<TOutput, TError, TInput>[P]>;
50
- } & {
51
- shallow?: MaybeRef<boolean>;
52
- };
53
- export interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
54
- mutationKey: QueryKey;
55
- mutationFn(input: TInput): Promise<TOutput>;
56
- retry?(failureCount: number, error: TError): boolean;
57
- }
58
- //# sourceMappingURL=types.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import { type AnyFunction } from '@orpc/shared';
3
- export type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
4
- [K in keyof T]: UnrefDeep<T[K]>;
5
- } : T;
6
- export declare function unrefDeep<T>(value: T): UnrefDeep<T>;
7
- //# sourceMappingURL=utils.d.ts.map