@orpc/solid-query 0.0.0-next.18dad53 → 0.0.0-next.19c2a69
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/dist/index.d.mts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.mjs +10 -17
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
+
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
3
|
+
export { OperationKeyOptions as BuildKeyOptions, OperationType as KeyType, generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
2
4
|
import { QueryKey, SkipToken, SolidQueryOptions, QueryFunctionContext, experimental_streamedQuery, SolidInfiniteQueryOptions, SolidMutationOptions, InfiniteData } from '@tanstack/solid-query';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type KeyType = 'query' | 'streamed' | 'infinite' | 'mutation' | undefined;
|
|
6
|
-
interface BuildKeyOptions<TType extends KeyType, TInput> {
|
|
7
|
-
type?: TType;
|
|
8
|
-
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
9
|
-
}
|
|
10
|
-
declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
|
|
5
|
+
import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Utils at any level (procedure or router)
|
|
@@ -18,7 +13,7 @@ interface GeneralUtils<TInput> {
|
|
|
18
13
|
*
|
|
19
14
|
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
20
15
|
*/
|
|
21
|
-
key<UType extends
|
|
16
|
+
key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
|
|
22
17
|
}
|
|
23
18
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
24
19
|
|
|
@@ -35,11 +30,14 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
35
30
|
queryKey: QueryKey;
|
|
36
31
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
37
32
|
throwOnError?(error: TError): boolean;
|
|
33
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
38
34
|
enabled: boolean;
|
|
39
35
|
}
|
|
40
36
|
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0]['refetchMode'], 'queryFn'>;
|
|
41
37
|
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
42
|
-
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> &
|
|
38
|
+
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
39
|
+
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
40
|
+
};
|
|
43
41
|
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
44
42
|
}
|
|
45
43
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
@@ -53,6 +51,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
|
53
51
|
queryKey: QueryKey;
|
|
54
52
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
55
53
|
throwOnError?(error: TError): boolean;
|
|
54
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
56
55
|
enabled: boolean;
|
|
57
56
|
}
|
|
58
57
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
@@ -114,5 +113,5 @@ interface CreateRouterUtilsOptions {
|
|
|
114
113
|
*/
|
|
115
114
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
116
115
|
|
|
117
|
-
export {
|
|
118
|
-
export type {
|
|
116
|
+
export { createGeneralUtils, createRouterUtils as createORPCSolidQueryUtils, createProcedureUtils, createRouterUtils };
|
|
117
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
+
import { OperationType, OperationKeyOptions } from '@orpc/tanstack-query';
|
|
3
|
+
export { OperationKeyOptions as BuildKeyOptions, OperationType as KeyType, generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
2
4
|
import { QueryKey, SkipToken, SolidQueryOptions, QueryFunctionContext, experimental_streamedQuery, SolidInfiniteQueryOptions, SolidMutationOptions, InfiniteData } from '@tanstack/solid-query';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type KeyType = 'query' | 'streamed' | 'infinite' | 'mutation' | undefined;
|
|
6
|
-
interface BuildKeyOptions<TType extends KeyType, TInput> {
|
|
7
|
-
type?: TType;
|
|
8
|
-
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
9
|
-
}
|
|
10
|
-
declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
|
|
5
|
+
import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Utils at any level (procedure or router)
|
|
@@ -18,7 +13,7 @@ interface GeneralUtils<TInput> {
|
|
|
18
13
|
*
|
|
19
14
|
* @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
20
15
|
*/
|
|
21
|
-
key<UType extends
|
|
16
|
+
key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
|
|
22
17
|
}
|
|
23
18
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
24
19
|
|
|
@@ -35,11 +30,14 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
35
30
|
queryKey: QueryKey;
|
|
36
31
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
37
32
|
throwOnError?(error: TError): boolean;
|
|
33
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
38
34
|
enabled: boolean;
|
|
39
35
|
}
|
|
40
36
|
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0]['refetchMode'], 'queryFn'>;
|
|
41
37
|
type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
42
|
-
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> &
|
|
38
|
+
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
39
|
+
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
40
|
+
};
|
|
43
41
|
interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
|
|
44
42
|
}
|
|
45
43
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
@@ -53,6 +51,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
|
53
51
|
queryKey: QueryKey;
|
|
54
52
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
55
53
|
throwOnError?(error: TError): boolean;
|
|
54
|
+
retryDelay?: (count: number, error: TError) => number;
|
|
56
55
|
enabled: boolean;
|
|
57
56
|
}
|
|
58
57
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
@@ -114,5 +113,5 @@ interface CreateRouterUtilsOptions {
|
|
|
114
113
|
*/
|
|
115
114
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
116
115
|
|
|
117
|
-
export {
|
|
118
|
-
export type {
|
|
116
|
+
export { createGeneralUtils, createRouterUtils as createORPCSolidQueryUtils, createProcedureUtils, createRouterUtils };
|
|
117
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
+
import { generateOperationKey } from '@orpc/tanstack-query';
|
|
2
|
+
export { generateOperationKey as buildKey } from '@orpc/tanstack-query';
|
|
1
3
|
import { isAsyncIteratorObject } from '@orpc/shared';
|
|
2
4
|
import { skipToken, experimental_streamedQuery } from '@tanstack/solid-query';
|
|
3
5
|
|
|
4
|
-
function buildKey(path, options) {
|
|
5
|
-
const withInput = options?.input !== void 0 ? { input: options?.input } : {};
|
|
6
|
-
const withType = options?.type !== void 0 ? { type: options?.type } : {};
|
|
7
|
-
return [path, {
|
|
8
|
-
...withInput,
|
|
9
|
-
...withType
|
|
10
|
-
}];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
6
|
function createGeneralUtils(path) {
|
|
14
7
|
return {
|
|
15
8
|
key(options) {
|
|
16
|
-
return
|
|
9
|
+
return generateOperationKey(path, options);
|
|
17
10
|
}
|
|
18
11
|
};
|
|
19
12
|
}
|
|
@@ -23,7 +16,7 @@ function createProcedureUtils(client, options) {
|
|
|
23
16
|
call: client,
|
|
24
17
|
queryOptions(...[optionsIn = {}]) {
|
|
25
18
|
return {
|
|
26
|
-
queryKey:
|
|
19
|
+
queryKey: generateOperationKey(options.path, { type: "query", input: optionsIn.input }),
|
|
27
20
|
queryFn: ({ signal }) => {
|
|
28
21
|
if (optionsIn.input === skipToken) {
|
|
29
22
|
throw new Error("queryFn should not be called with skipToken used as input");
|
|
@@ -37,9 +30,8 @@ function createProcedureUtils(client, options) {
|
|
|
37
30
|
experimental_streamedOptions(...[optionsIn = {}]) {
|
|
38
31
|
return {
|
|
39
32
|
enabled: optionsIn.input !== skipToken,
|
|
40
|
-
queryKey:
|
|
33
|
+
queryKey: generateOperationKey(options.path, { type: "streamed", input: optionsIn.input, fnOptions: optionsIn.queryFnOptions }),
|
|
41
34
|
queryFn: experimental_streamedQuery({
|
|
42
|
-
...optionsIn,
|
|
43
35
|
queryFn: async ({ signal }) => {
|
|
44
36
|
if (optionsIn.input === skipToken) {
|
|
45
37
|
throw new Error("queryFn should not be called with skipToken used as input");
|
|
@@ -49,14 +41,15 @@ function createProcedureUtils(client, options) {
|
|
|
49
41
|
throw new Error("streamedQuery requires an event iterator output");
|
|
50
42
|
}
|
|
51
43
|
return output;
|
|
52
|
-
}
|
|
44
|
+
},
|
|
45
|
+
...optionsIn.queryFnOptions
|
|
53
46
|
}),
|
|
54
47
|
...optionsIn
|
|
55
48
|
};
|
|
56
49
|
},
|
|
57
50
|
infiniteOptions(optionsIn) {
|
|
58
51
|
return {
|
|
59
|
-
queryKey:
|
|
52
|
+
queryKey: generateOperationKey(options.path, {
|
|
60
53
|
type: "infinite",
|
|
61
54
|
input: optionsIn.input === skipToken ? skipToken : optionsIn.input(optionsIn.initialPageParam)
|
|
62
55
|
}),
|
|
@@ -72,7 +65,7 @@ function createProcedureUtils(client, options) {
|
|
|
72
65
|
},
|
|
73
66
|
mutationOptions(...[optionsIn = {}]) {
|
|
74
67
|
return {
|
|
75
|
-
mutationKey:
|
|
68
|
+
mutationKey: generateOperationKey(options.path, { type: "mutation" }),
|
|
76
69
|
mutationFn: (input) => client(input, { context: optionsIn.context }),
|
|
77
70
|
...optionsIn
|
|
78
71
|
};
|
|
@@ -107,4 +100,4 @@ function createRouterUtils(client, options = {}) {
|
|
|
107
100
|
return recursive;
|
|
108
101
|
}
|
|
109
102
|
|
|
110
|
-
export {
|
|
103
|
+
export { createGeneralUtils, createRouterUtils as createORPCSolidQueryUtils, createProcedureUtils, createRouterUtils };
|
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.19c2a69",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
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.19c2a69"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/
|
|
35
|
+
"@orpc/tanstack-query": "0.0.0-next.19c2a69",
|
|
36
|
+
"@orpc/shared": "0.0.0-next.19c2a69"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@tanstack/
|
|
39
|
+
"@tanstack/solid-query": "^5.77.2",
|
|
39
40
|
"zod": "^3.25.11"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|