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