@orpc/svelte-query 0.0.0-next.f4d410a → 0.0.0-next.f81b4a2
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 +11 -0
- package/dist/index.d.mts +41 -9
- package/dist/index.d.ts +41 -9
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
57
|
- [@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
58
|
- [@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
59
|
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
@@ -60,6 +61,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
60
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
61
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
62
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
63
66
|
|
|
64
67
|
## `@orpc/svelte-query`
|
|
65
68
|
|
|
@@ -107,6 +110,14 @@ export function Example() {
|
|
|
107
110
|
}
|
|
108
111
|
```
|
|
109
112
|
|
|
113
|
+
## Sponsors
|
|
114
|
+
|
|
115
|
+
<p align="center">
|
|
116
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
|
117
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
|
118
|
+
</a>
|
|
119
|
+
</p>
|
|
120
|
+
|
|
110
121
|
## License
|
|
111
122
|
|
|
112
123
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -13,11 +13,16 @@ declare function buildKey<TType extends KeyType, TInput>(path: string[], options
|
|
|
13
13
|
* Utils at any level (procedure or router)
|
|
14
14
|
*/
|
|
15
15
|
interface GeneralUtils<TInput> {
|
|
16
|
+
/**
|
|
17
|
+
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
20
|
+
*/
|
|
16
21
|
key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
|
|
17
22
|
}
|
|
18
23
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
19
24
|
|
|
20
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
25
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = (undefined extends TInput ? {
|
|
21
26
|
input?: TInput;
|
|
22
27
|
} : {
|
|
23
28
|
input: TInput;
|
|
@@ -26,40 +31,60 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
26
31
|
} : {
|
|
27
32
|
context: TClientContext;
|
|
28
33
|
}) & SetOptional<CreateQueryOptions<TOutput, TError, TSelectData>, 'queryKey'>;
|
|
29
|
-
interface QueryOptionsBase<TOutput, TError
|
|
34
|
+
interface QueryOptionsBase<TOutput, TError> {
|
|
30
35
|
queryKey: QueryKey;
|
|
31
36
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
32
37
|
retry?(failureCount: number, error: TError): boolean;
|
|
33
38
|
}
|
|
34
|
-
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
39
|
+
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
35
40
|
input: (pageParam: TPageParam) => TInput;
|
|
36
41
|
} & (Record<never, never> extends TClientContext ? {
|
|
37
42
|
context?: TClientContext;
|
|
38
43
|
} : {
|
|
39
44
|
context: TClientContext;
|
|
40
45
|
}) & SetOptional<CreateInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
|
|
41
|
-
interface InfiniteOptionsBase<TOutput, TError
|
|
46
|
+
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
42
47
|
queryKey: QueryKey;
|
|
43
48
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
44
49
|
retry?(failureCount: number, error: TError): boolean;
|
|
45
50
|
}
|
|
46
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
51
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
47
52
|
context?: TClientContext;
|
|
48
53
|
} : {
|
|
49
54
|
context: TClientContext;
|
|
50
55
|
}) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
|
|
51
|
-
type MutationOptions<TInput, TOutput, TError
|
|
56
|
+
type MutationOptions<TInput, TOutput, TError, TMutationContext> = CreateMutationOptions<TOutput, TError, TInput, TMutationContext>;
|
|
52
57
|
|
|
53
|
-
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
58
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
59
|
+
/**
|
|
60
|
+
* Calling corresponding procedure client
|
|
61
|
+
*
|
|
62
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
63
|
+
*/
|
|
54
64
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
65
|
+
/**
|
|
66
|
+
* Generate options used for createQuery/prefetchQuery/...
|
|
67
|
+
*
|
|
68
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
69
|
+
*/
|
|
55
70
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
71
|
+
/**
|
|
72
|
+
* Generate options used for createInfiniteQuery/prefetchInfiniteQuery/...
|
|
73
|
+
*
|
|
74
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
75
|
+
*/
|
|
56
76
|
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>>;
|
|
77
|
+
/**
|
|
78
|
+
* Generate options used for createMutation/...
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#mutation-options Tanstack Mutation Options Docs}
|
|
81
|
+
*/
|
|
57
82
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
58
83
|
}
|
|
59
84
|
interface CreateProcedureUtilsOptions {
|
|
60
85
|
path: string[];
|
|
61
86
|
}
|
|
62
|
-
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
87
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
63
88
|
|
|
64
89
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
|
65
90
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
|
@@ -67,6 +92,13 @@ type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientCo
|
|
|
67
92
|
interface CreateRouterUtilsOptions {
|
|
68
93
|
path?: string[];
|
|
69
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a router utils from a client.
|
|
97
|
+
*
|
|
98
|
+
* @info Both client-side and server-side clients are supported.
|
|
99
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/svelte Tanstack Query Svelte Docs}
|
|
100
|
+
*/
|
|
70
101
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
71
102
|
|
|
72
|
-
export {
|
|
103
|
+
export { buildKey, createGeneralUtils, createRouterUtils as createORPCSvelteQueryUtils, createProcedureUtils, createRouterUtils };
|
|
104
|
+
export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,11 +13,16 @@ declare function buildKey<TType extends KeyType, TInput>(path: string[], options
|
|
|
13
13
|
* Utils at any level (procedure or router)
|
|
14
14
|
*/
|
|
15
15
|
interface GeneralUtils<TInput> {
|
|
16
|
+
/**
|
|
17
|
+
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
20
|
+
*/
|
|
16
21
|
key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
|
|
17
22
|
}
|
|
18
23
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
19
24
|
|
|
20
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
25
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = (undefined extends TInput ? {
|
|
21
26
|
input?: TInput;
|
|
22
27
|
} : {
|
|
23
28
|
input: TInput;
|
|
@@ -26,40 +31,60 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
26
31
|
} : {
|
|
27
32
|
context: TClientContext;
|
|
28
33
|
}) & SetOptional<CreateQueryOptions<TOutput, TError, TSelectData>, 'queryKey'>;
|
|
29
|
-
interface QueryOptionsBase<TOutput, TError
|
|
34
|
+
interface QueryOptionsBase<TOutput, TError> {
|
|
30
35
|
queryKey: QueryKey;
|
|
31
36
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
32
37
|
retry?(failureCount: number, error: TError): boolean;
|
|
33
38
|
}
|
|
34
|
-
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
39
|
+
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
35
40
|
input: (pageParam: TPageParam) => TInput;
|
|
36
41
|
} & (Record<never, never> extends TClientContext ? {
|
|
37
42
|
context?: TClientContext;
|
|
38
43
|
} : {
|
|
39
44
|
context: TClientContext;
|
|
40
45
|
}) & SetOptional<CreateInfiniteQueryOptions<TOutput, TError, TSelectData, TOutput, QueryKey, TPageParam>, 'queryKey'>;
|
|
41
|
-
interface InfiniteOptionsBase<TOutput, TError
|
|
46
|
+
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
42
47
|
queryKey: QueryKey;
|
|
43
48
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
44
49
|
retry?(failureCount: number, error: TError): boolean;
|
|
45
50
|
}
|
|
46
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
51
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
47
52
|
context?: TClientContext;
|
|
48
53
|
} : {
|
|
49
54
|
context: TClientContext;
|
|
50
55
|
}) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
|
|
51
|
-
type MutationOptions<TInput, TOutput, TError
|
|
56
|
+
type MutationOptions<TInput, TOutput, TError, TMutationContext> = CreateMutationOptions<TOutput, TError, TInput, TMutationContext>;
|
|
52
57
|
|
|
53
|
-
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
58
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
59
|
+
/**
|
|
60
|
+
* Calling corresponding procedure client
|
|
61
|
+
*
|
|
62
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#calling-procedure-clients Tanstack Calling Procedure Client Docs}
|
|
63
|
+
*/
|
|
54
64
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
65
|
+
/**
|
|
66
|
+
* Generate options used for createQuery/prefetchQuery/...
|
|
67
|
+
*
|
|
68
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
|
|
69
|
+
*/
|
|
55
70
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
71
|
+
/**
|
|
72
|
+
* Generate options used for createInfiniteQuery/prefetchInfiniteQuery/...
|
|
73
|
+
*
|
|
74
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#infinite-query-options-utility Tanstack Infinite Query Options Utility Docs}
|
|
75
|
+
*/
|
|
56
76
|
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>>;
|
|
77
|
+
/**
|
|
78
|
+
* Generate options used for createMutation/...
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#mutation-options Tanstack Mutation Options Docs}
|
|
81
|
+
*/
|
|
57
82
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
|
58
83
|
}
|
|
59
84
|
interface CreateProcedureUtilsOptions {
|
|
60
85
|
path: string[];
|
|
61
86
|
}
|
|
62
|
-
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
|
87
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
63
88
|
|
|
64
89
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
|
65
90
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
|
@@ -67,6 +92,13 @@ type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientCo
|
|
|
67
92
|
interface CreateRouterUtilsOptions {
|
|
68
93
|
path?: string[];
|
|
69
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a router utils from a client.
|
|
97
|
+
*
|
|
98
|
+
* @info Both client-side and server-side clients are supported.
|
|
99
|
+
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/svelte Tanstack Query Svelte Docs}
|
|
100
|
+
*/
|
|
70
101
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
71
102
|
|
|
72
|
-
export {
|
|
103
|
+
export { buildKey, createGeneralUtils, createRouterUtils as createORPCSvelteQueryUtils, createProcedureUtils, createRouterUtils };
|
|
104
|
+
export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/svelte-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.f81b4a2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -27,14 +27,15 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@tanstack/svelte-query": ">=5.
|
|
30
|
+
"@tanstack/svelte-query": ">=5.55.0",
|
|
31
31
|
"svelte": ">=4.2.0",
|
|
32
|
-
"@orpc/client": "0.0.0-next.
|
|
32
|
+
"@orpc/client": "0.0.0-next.f81b4a2"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/shared": "0.0.0-next.
|
|
35
|
+
"@orpc/shared": "0.0.0-next.f81b4a2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@tanstack/vue-query": "^5.72.3",
|
|
38
39
|
"zod": "^3.24.2"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|