@orpc/svelte-query 0.0.0-next.fa8d145 → 0.0.0-next.fd13879
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 +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +17 -2
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
-
import { QueryKey, CreateQueryOptions, QueryFunctionContext, CreateInfiniteQueryOptions, CreateMutationOptions, InfiniteData } from '@tanstack/svelte-query';
|
|
2
|
+
import { QueryKey, SkipToken, CreateQueryOptions, QueryFunctionContext, CreateInfiniteQueryOptions, CreateMutationOptions, InfiniteData } from '@tanstack/svelte-query';
|
|
3
3
|
import { PartialDeep, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
|
|
5
5
|
type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
|
|
@@ -23,9 +23,9 @@ interface GeneralUtils<TInput> {
|
|
|
23
23
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
24
24
|
|
|
25
25
|
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = (undefined extends TInput ? {
|
|
26
|
-
input?: TInput;
|
|
26
|
+
input?: TInput | SkipToken;
|
|
27
27
|
} : {
|
|
28
|
-
input: TInput;
|
|
28
|
+
input: TInput | SkipToken;
|
|
29
29
|
}) & (Record<never, never> extends TClientContext ? {
|
|
30
30
|
context?: TClientContext;
|
|
31
31
|
} : {
|
|
@@ -35,9 +35,10 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
35
35
|
queryKey: QueryKey;
|
|
36
36
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
37
37
|
retry?(failureCount: number, error: TError): boolean;
|
|
38
|
+
enabled: boolean;
|
|
38
39
|
}
|
|
39
40
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
40
|
-
input: (pageParam: TPageParam) => TInput;
|
|
41
|
+
input: ((pageParam: TPageParam) => TInput) | SkipToken;
|
|
41
42
|
} & (Record<never, never> extends TClientContext ? {
|
|
42
43
|
context?: TClientContext;
|
|
43
44
|
} : {
|
|
@@ -47,6 +48,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
|
47
48
|
queryKey: QueryKey;
|
|
48
49
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
49
50
|
retry?(failureCount: number, error: TError): boolean;
|
|
51
|
+
enabled: boolean;
|
|
50
52
|
}
|
|
51
53
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
52
54
|
context?: TClientContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
|
-
import { QueryKey, CreateQueryOptions, QueryFunctionContext, CreateInfiniteQueryOptions, CreateMutationOptions, InfiniteData } from '@tanstack/svelte-query';
|
|
2
|
+
import { QueryKey, SkipToken, CreateQueryOptions, QueryFunctionContext, CreateInfiniteQueryOptions, CreateMutationOptions, InfiniteData } from '@tanstack/svelte-query';
|
|
3
3
|
import { PartialDeep, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
|
|
5
5
|
type KeyType = 'query' | 'infinite' | 'mutation' | undefined;
|
|
@@ -23,9 +23,9 @@ interface GeneralUtils<TInput> {
|
|
|
23
23
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
|
24
24
|
|
|
25
25
|
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = (undefined extends TInput ? {
|
|
26
|
-
input?: TInput;
|
|
26
|
+
input?: TInput | SkipToken;
|
|
27
27
|
} : {
|
|
28
|
-
input: TInput;
|
|
28
|
+
input: TInput | SkipToken;
|
|
29
29
|
}) & (Record<never, never> extends TClientContext ? {
|
|
30
30
|
context?: TClientContext;
|
|
31
31
|
} : {
|
|
@@ -35,9 +35,10 @@ interface QueryOptionsBase<TOutput, TError> {
|
|
|
35
35
|
queryKey: QueryKey;
|
|
36
36
|
queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
|
|
37
37
|
retry?(failureCount: number, error: TError): boolean;
|
|
38
|
+
enabled: boolean;
|
|
38
39
|
}
|
|
39
40
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
|
|
40
|
-
input: (pageParam: TPageParam) => TInput;
|
|
41
|
+
input: ((pageParam: TPageParam) => TInput) | SkipToken;
|
|
41
42
|
} & (Record<never, never> extends TClientContext ? {
|
|
42
43
|
context?: TClientContext;
|
|
43
44
|
} : {
|
|
@@ -47,6 +48,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
|
47
48
|
queryKey: QueryKey;
|
|
48
49
|
queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
|
|
49
50
|
retry?(failureCount: number, error: TError): boolean;
|
|
51
|
+
enabled: boolean;
|
|
50
52
|
}
|
|
51
53
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
|
|
52
54
|
context?: TClientContext;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { skipToken } from '@tanstack/svelte-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/svelte-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.fd13879",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
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.fd13879"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@orpc/shared": "0.0.0-next.
|
|
35
|
+
"@orpc/shared": "0.0.0-next.fd13879"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tanstack/vue-query": "^5.72.3",
|