@orpc/vue-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 CHANGED
@@ -1,22 +1,17 @@
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, QueryObserverOptions, QueryFunctionContext, experimental_streamedQuery, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
3
- import { PartialDeep, AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
5
+ import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
4
6
  import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
5
7
 
6
- type KeyType = 'query' | 'streamed' | 'infinite' | 'mutation' | undefined;
7
- interface BuildKeyOptions<TType extends KeyType, TInput> {
8
- type?: TType;
9
- input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
10
- }
11
- declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
12
-
13
8
  interface GeneralUtils<TInput> {
14
9
  /**
15
10
  * Generate a query/mutation key for checking status, invalidate, set, get, etc.
16
11
  *
17
12
  * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
18
13
  */
19
- key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
14
+ key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
20
15
  }
21
16
  declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
22
17
 
@@ -46,11 +41,14 @@ interface QueryOptionsBase<TOutput, TError> {
46
41
  queryKey: ComputedRef<QueryKey>;
47
42
  queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
48
43
  throwOnError?(error: TError): boolean;
44
+ retryDelay?: (count: number, error: TError) => number;
49
45
  enabled: ComputedRef<boolean>;
50
46
  }
51
47
  type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
52
48
  type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
53
- type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & experimental_StreamedQueryOptions;
49
+ type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
50
+ queryFnOptions?: experimental_StreamedQueryOptions;
51
+ };
54
52
  interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
55
53
  }
56
54
  type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
@@ -69,6 +67,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
69
67
  queryKey: ComputedRef<QueryKey>;
70
68
  queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
71
69
  throwOnError?(error: TError): boolean;
70
+ retryDelay?: (count: number, error: TError) => number;
72
71
  enabled: ComputedRef<boolean>;
73
72
  }
74
73
  type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
@@ -139,5 +138,5 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
139
138
  } : T;
140
139
  declare function unrefDeep<T>(value: T): UnrefDeep<T>;
141
140
 
142
- export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
143
- export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
141
+ export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
142
+ export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
package/dist/index.d.ts CHANGED
@@ -1,22 +1,17 @@
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, QueryObserverOptions, QueryFunctionContext, experimental_streamedQuery, InfiniteQueryObserverOptions, MutationObserverOptions, InfiniteData } from '@tanstack/vue-query';
3
- import { PartialDeep, AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
5
+ import { AnyFunction, MaybeOptionalOptions } from '@orpc/shared';
4
6
  import { MaybeRef, MaybeRefOrGetter, ComputedRef, Ref } from 'vue';
5
7
 
6
- type KeyType = 'query' | 'streamed' | 'infinite' | 'mutation' | undefined;
7
- interface BuildKeyOptions<TType extends KeyType, TInput> {
8
- type?: TType;
9
- input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
10
- }
11
- declare function buildKey<TType extends KeyType, TInput>(path: string[], options?: BuildKeyOptions<TType, TInput>): QueryKey;
12
-
13
8
  interface GeneralUtils<TInput> {
14
9
  /**
15
10
  * Generate a query/mutation key for checking status, invalidate, set, get, etc.
16
11
  *
17
12
  * @see {@link https://orpc.unnoq.com/docs/tanstack-query/basic#query-mutation-key Tanstack Query/Mutation Key Docs}
18
13
  */
19
- key<UType extends KeyType = undefined>(options?: BuildKeyOptions<UType, TInput>): QueryKey;
14
+ key<UType extends OperationType>(options?: OperationKeyOptions<UType, TInput>): QueryKey;
20
15
  }
21
16
  declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
22
17
 
@@ -46,11 +41,14 @@ interface QueryOptionsBase<TOutput, TError> {
46
41
  queryKey: ComputedRef<QueryKey>;
47
42
  queryFn(ctx: QueryFunctionContext): Promise<TOutput>;
48
43
  throwOnError?(error: TError): boolean;
44
+ retryDelay?: (count: number, error: TError) => number;
49
45
  enabled: ComputedRef<boolean>;
50
46
  }
51
47
  type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
52
48
  type experimental_InferStreamedOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
53
- type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & experimental_StreamedQueryOptions;
49
+ type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
50
+ queryFnOptions?: experimental_StreamedQueryOptions;
51
+ };
54
52
  interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {
55
53
  }
56
54
  type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam> = (Record<never, never> extends TClientContext ? {
@@ -69,6 +67,7 @@ interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
69
67
  queryKey: ComputedRef<QueryKey>;
70
68
  queryFn(ctx: QueryFunctionContext<QueryKey, TPageParam>): Promise<TOutput>;
71
69
  throwOnError?(error: TError): boolean;
70
+ retryDelay?: (count: number, error: TError) => number;
72
71
  enabled: ComputedRef<boolean>;
73
72
  }
74
73
  type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (Record<never, never> extends TClientContext ? {
@@ -139,5 +138,5 @@ type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunctio
139
138
  } : T;
140
139
  declare function unrefDeep<T>(value: T): UnrefDeep<T>;
141
140
 
142
- export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
143
- export type { BuildKeyOptions, CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, KeyType, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
141
+ export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
142
+ export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MaybeRefDeep, MutationOptions, MutationOptionsIn, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, UnrefDeep, experimental_InferStreamedOutput, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn };
package/dist/index.mjs CHANGED
@@ -1,20 +1,13 @@
1
+ import { generateOperationKey } from '@orpc/tanstack-query';
2
+ export { generateOperationKey as buildKey } from '@orpc/tanstack-query';
1
3
  import { isObject, isAsyncIteratorObject } from '@orpc/shared';
2
4
  import { skipToken, experimental_streamedQuery } from '@tanstack/vue-query';
3
5
  import { isRef, computed } from 'vue';
4
6
 
5
- function buildKey(path, options) {
6
- const withInput = options?.input !== void 0 ? { input: options?.input } : {};
7
- const withType = options?.type !== void 0 ? { type: options?.type } : {};
8
- return [path, {
9
- ...withInput,
10
- ...withType
11
- }];
12
- }
13
-
14
7
  function createGeneralUtils(path) {
15
8
  return {
16
9
  key(options) {
17
- return buildKey(path, options);
10
+ return generateOperationKey(path, options);
18
11
  }
19
12
  };
20
13
  }
@@ -40,7 +33,7 @@ function createProcedureUtils(client, options) {
40
33
  call: client,
41
34
  queryOptions(...[optionsIn = {}]) {
42
35
  return {
43
- queryKey: computed(() => buildKey(options.path, { type: "query", input: unrefDeep(optionsIn.input) })),
36
+ queryKey: computed(() => generateOperationKey(options.path, { type: "query", input: unrefDeep(optionsIn.input) })),
44
37
  queryFn: ({ signal }) => {
45
38
  const input = unrefDeep(optionsIn.input);
46
39
  if (input === skipToken) {
@@ -55,9 +48,8 @@ function createProcedureUtils(client, options) {
55
48
  experimental_streamedOptions(...[optionsIn = {}]) {
56
49
  return {
57
50
  enabled: computed(() => unrefDeep(optionsIn.input) !== skipToken),
58
- queryKey: computed(() => buildKey(options.path, { type: "streamed", input: unrefDeep(optionsIn.input) })),
51
+ queryKey: computed(() => generateOperationKey(options.path, { type: "streamed", input: unrefDeep(optionsIn.input), fnOptions: optionsIn.queryFnOptions })),
59
52
  queryFn: experimental_streamedQuery({
60
- ...optionsIn,
61
53
  queryFn: async ({ signal }) => {
62
54
  const input = unrefDeep(optionsIn.input);
63
55
  if (input === skipToken) {
@@ -68,7 +60,8 @@ function createProcedureUtils(client, options) {
68
60
  throw new Error("streamedQuery requires an event iterator output");
69
61
  }
70
62
  return output;
71
- }
63
+ },
64
+ ...optionsIn.queryFnOptions
72
65
  }),
73
66
  ...optionsIn
74
67
  };
@@ -77,7 +70,7 @@ function createProcedureUtils(client, options) {
77
70
  return {
78
71
  queryKey: computed(() => {
79
72
  const input = unrefDeep(optionsIn.input);
80
- return buildKey(options.path, {
73
+ return generateOperationKey(options.path, {
81
74
  type: "infinite",
82
75
  input: input === skipToken ? skipToken : unrefDeep(input(unrefDeep(optionsIn.initialPageParam)))
83
76
  });
@@ -95,7 +88,7 @@ function createProcedureUtils(client, options) {
95
88
  },
96
89
  mutationOptions(...[optionsIn = {}]) {
97
90
  return {
98
- mutationKey: buildKey(options.path, { type: "mutation" }),
91
+ mutationKey: generateOperationKey(options.path, { type: "mutation" }),
99
92
  mutationFn: (input) => client(input, { context: unrefDeep(optionsIn.context) }),
100
93
  ...optionsIn
101
94
  };
@@ -130,4 +123,4 @@ function createRouterUtils(client, options = {}) {
130
123
  return recursive;
131
124
  }
132
125
 
133
- export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
126
+ export { createGeneralUtils, createRouterUtils as createORPCVueQueryUtils, createProcedureUtils, createRouterUtils, unrefDeep };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/vue-query",
3
3
  "type": "module",
4
- "version": "0.0.0-next.18dad53",
4
+ "version": "0.0.0-next.19c2a69",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,11 +29,14 @@
29
29
  "peerDependencies": {
30
30
  "@tanstack/vue-query": ">=5.55.0",
31
31
  "vue": ">=3.3.0",
32
- "@orpc/client": "0.0.0-next.18dad53"
32
+ "@orpc/client": "0.0.0-next.19c2a69"
33
33
  },
34
34
  "dependencies": {
35
- "@tanstack/vue-query": "^5.72.3",
36
- "@orpc/shared": "0.0.0-next.18dad53"
35
+ "@orpc/shared": "0.0.0-next.19c2a69",
36
+ "@orpc/tanstack-query": "0.0.0-next.19c2a69"
37
+ },
38
+ "devDependencies": {
39
+ "@tanstack/vue-query": "^5.77.2"
37
40
  },
38
41
  "scripts": {
39
42
  "build": "unbuild",