@orpc/solid-query 0.0.0-next.fd13879 → 0.0.0-next.fd6982a

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 CHANGED
@@ -1,13 +1,8 @@
1
1
  import { ClientContext, Client, NestedClient } from '@orpc/client';
2
- import { QueryKey, SkipToken, SolidQueryOptions, QueryFunctionContext, SolidInfiniteQueryOptions, SolidMutationOptions, InfiniteData } from '@tanstack/solid-query';
3
- import { PartialDeep, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
-
5
- type KeyType = 'query' | '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;
2
+ import { OperationType, BuildKeyOptions } from '@orpc/tanstack-query';
3
+ export { BuildKeyOptions, OperationType as KeyType, buildKey } from '@orpc/tanstack-query';
4
+ import { QueryKey, SkipToken, SolidQueryOptions, QueryFunctionContext, experimental_streamedQuery, SolidInfiniteQueryOptions, SolidMutationOptions, InfiniteData } from '@tanstack/solid-query';
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 KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
16
+ key<UType extends OperationType>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
22
17
  }
23
18
  declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
24
19
 
@@ -34,9 +29,14 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
34
29
  interface QueryOptionsBase<TOutput, TError> {
35
30
  queryKey: QueryKey;
36
31
  queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
37
- retry?(failureCount: number, error: TError): boolean;
32
+ throwOnError?(error: TError): boolean;
38
33
  enabled: boolean;
39
34
  }
35
+ type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0]['refetchMode'], 'queryFn'>;
36
+ type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
37
+ type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & experimental_StreamedQueryOptions;
38
+ interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
39
+ }
40
40
  type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
41
41
  input: ((pageParam: TPageParam) => TInput) | SkipToken;
42
42
  } & (Record<never, never> extends TClientContext ? {
@@ -47,7 +47,7 @@ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
47
47
  interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
48
48
  queryKey: QueryKey;
49
49
  queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
50
- retry?(failureCount: number, error: TError): boolean;
50
+ throwOnError?(error: TError): boolean;
51
51
  enabled: boolean;
52
52
  }
53
53
  type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
@@ -70,6 +70,13 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
70
70
  * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
71
71
  */
72
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 [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
75
+ * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
76
+ *
77
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
78
+ */
79
+ experimental_streamedOptions<U, USelectData = experimental_InferStreamedOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>>;
73
80
  /**
74
81
  * Generate options used for createInfiniteQuery/prefetchInfiniteQuery/...
75
82
  *
@@ -102,5 +109,5 @@ interface CreateRouterUtilsOptions {
102
109
  */
103
110
  declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
104
111
 
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 };
112
+ export { createGeneralUtils, createRouterUtils as createORPCSolidQueryUtils, createProcedureUtils, createRouterUtils };
113
+ 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 { QueryKey, SkipToken, SolidQueryOptions, QueryFunctionContext, SolidInfiniteQueryOptions, SolidMutationOptions, InfiniteData } from '@tanstack/solid-query';
3
- import { PartialDeep, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
-
5
- type KeyType = 'query' | '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;
2
+ import { OperationType, BuildKeyOptions } from '@orpc/tanstack-query';
3
+ export { BuildKeyOptions, OperationType as KeyType, buildKey } from '@orpc/tanstack-query';
4
+ import { QueryKey, SkipToken, SolidQueryOptions, QueryFunctionContext, experimental_streamedQuery, SolidInfiniteQueryOptions, SolidMutationOptions, InfiniteData } from '@tanstack/solid-query';
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 KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
16
+ key<UType extends OperationType>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
22
17
  }
23
18
  declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
24
19
 
@@ -34,9 +29,14 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
34
29
  interface QueryOptionsBase<TOutput, TError> {
35
30
  queryKey: QueryKey;
36
31
  queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
37
- retry?(failureCount: number, error: TError): boolean;
32
+ throwOnError?(error: TError): boolean;
38
33
  enabled: boolean;
39
34
  }
35
+ type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0]['refetchMode'], 'queryFn'>;
36
+ type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
37
+ type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & experimental_StreamedQueryOptions;
38
+ interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
39
+ }
40
40
  type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = {
41
41
  input: ((pageParam: TPageParam) => TInput) | SkipToken;
42
42
  } & (Record<never, never> extends TClientContext ? {
@@ -47,7 +47,7 @@ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
47
47
  interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
48
48
  queryKey: QueryKey;
49
49
  queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
50
- retry?(failureCount: number, error: TError): boolean;
50
+ throwOnError?(error: TError): boolean;
51
51
  enabled: boolean;
52
52
  }
53
53
  type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
@@ -70,6 +70,13 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
70
70
  * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-options-utility Tanstack Query Options Utility Docs}
71
71
  */
72
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 [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/prefetchQuery/...
75
+ * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
76
+ *
77
+ * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#streamed-query-options-utility Tanstack Streamed Query Options Utility Docs}
78
+ */
79
+ experimental_streamedOptions<U, USelectData = experimental_InferStreamedOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>>;
73
80
  /**
74
81
  * Generate options used for createInfiniteQuery/prefetchInfiniteQuery/...
75
82
  *
@@ -102,5 +109,5 @@ interface CreateRouterUtilsOptions {
102
109
  */
103
110
  declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
104
111
 
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 };
112
+ export { createGeneralUtils, createRouterUtils as createORPCSolidQueryUtils, createProcedureUtils, createRouterUtils };
113
+ 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,13 +1,7 @@
1
- import { skipToken } from '@tanstack/solid-query';
2
-
3
- function buildKey(path, options) {
4
- const withInput = options?.input !== void 0 ? { input: options?.input } : {};
5
- const withType = options?.type !== void 0 ? { type: options?.type } : {};
6
- return [path, {
7
- ...withInput,
8
- ...withType
9
- }];
10
- }
1
+ import { buildKey } from '@orpc/tanstack-query';
2
+ export { buildKey } from '@orpc/tanstack-query';
3
+ import { isAsyncIteratorObject } from '@orpc/shared';
4
+ import { skipToken, experimental_streamedQuery } from '@tanstack/solid-query';
11
5
 
12
6
  function createGeneralUtils(path) {
13
7
  return {
@@ -33,6 +27,26 @@ function createProcedureUtils(client, options) {
33
27
  ...optionsIn
34
28
  };
35
29
  },
30
+ experimental_streamedOptions(...[optionsIn = {}]) {
31
+ return {
32
+ enabled: optionsIn.input !== skipToken,
33
+ queryKey: buildKey(options.path, { type: "streamed", input: optionsIn.input }),
34
+ queryFn: experimental_streamedQuery({
35
+ ...optionsIn,
36
+ queryFn: async ({ signal }) => {
37
+ if (optionsIn.input === skipToken) {
38
+ throw new Error("queryFn should not be called with skipToken used as input");
39
+ }
40
+ const output = await client(optionsIn.input, { signal, context: optionsIn.context });
41
+ if (!isAsyncIteratorObject(output)) {
42
+ throw new Error("streamedQuery requires an event iterator output");
43
+ }
44
+ return output;
45
+ }
46
+ }),
47
+ ...optionsIn
48
+ };
49
+ },
36
50
  infiniteOptions(optionsIn) {
37
51
  return {
38
52
  queryKey: buildKey(options.path, {
@@ -86,4 +100,4 @@ function createRouterUtils(client, options = {}) {
86
100
  return recursive;
87
101
  }
88
102
 
89
- export { buildKey, createGeneralUtils, createRouterUtils as createORPCSolidQueryUtils, createProcedureUtils, createRouterUtils };
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.fd13879",
4
+ "version": "0.0.0-next.fd6982a",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,14 +29,15 @@
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.fd13879"
32
+ "@orpc/client": "0.0.0-next.fd6982a"
33
33
  },
34
34
  "dependencies": {
35
- "@orpc/shared": "0.0.0-next.fd13879"
35
+ "@orpc/shared": "0.0.0-next.fd6982a",
36
+ "@orpc/tanstack-query": "0.0.0-next.fd6982a"
36
37
  },
37
38
  "devDependencies": {
38
- "@tanstack/vue-query": "^5.72.3",
39
- "zod": "3.25.0-beta.20250516T005923"
39
+ "@tanstack/solid-query": "^5.77.2",
40
+ "zod": "^3.25.11"
40
41
  },
41
42
  "scripts": {
42
43
  "build": "unbuild",