@openapi-qraft/tanstack-query-react-types 2.3.1 → 2.3.2

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/types/service-operation/ServiceOperationFetchInfiniteQuery.d.ts +4 -4
  3. package/dist/types/service-operation/ServiceOperationFetchInfiniteQuery.d.ts.map +1 -1
  4. package/dist/types/service-operation/ServiceOperationGetInfiniteQueryData.d.ts +2 -2
  5. package/dist/types/service-operation/ServiceOperationGetInfiniteQueryData.d.ts.map +1 -1
  6. package/dist/types/service-operation/ServiceOperationGetQueryData.d.ts +2 -2
  7. package/dist/types/service-operation/ServiceOperationGetQueryData.d.ts.map +1 -1
  8. package/dist/types/service-operation/ServiceOperationGetQueryState.d.ts +3 -3
  9. package/dist/types/service-operation/ServiceOperationGetQueryState.d.ts.map +1 -1
  10. package/dist/types/service-operation/ServiceOperationSetInfiniteQueryData.d.ts +3 -3
  11. package/dist/types/service-operation/ServiceOperationSetInfiniteQueryData.d.ts.map +1 -1
  12. package/dist/types/service-operation/ServiceOperationSetQueryData.d.ts +2 -2
  13. package/dist/types/service-operation/ServiceOperationSetQueryData.d.ts.map +1 -1
  14. package/dist/types/service-operation/ServiceOperationUseInfiniteQuery.d.ts +4 -4
  15. package/dist/types/service-operation/ServiceOperationUseInfiniteQuery.d.ts.map +1 -1
  16. package/dist/types/service-operation/ServiceOperationUseMutation.d.ts +3 -3
  17. package/dist/types/service-operation/ServiceOperationUseMutation.d.ts.map +1 -1
  18. package/dist/types/service-operation/ServiceOperationUseQuery.d.ts +4 -4
  19. package/dist/types/service-operation/ServiceOperationUseQuery.d.ts.map +1 -1
  20. package/dist/types/service-operation/ServiceOperationUseSuspenseInfiniteQuery.d.ts +2 -2
  21. package/dist/types/service-operation/ServiceOperationUseSuspenseInfiniteQuery.d.ts.map +1 -1
  22. package/dist/types/service-operation/ServiceOperationUseSuspenseQuery.d.ts +2 -2
  23. package/dist/types/service-operation/ServiceOperationUseSuspenseQuery.d.ts.map +1 -1
  24. package/dist/types/shared/DeepReadonly.d.ts +4 -0
  25. package/dist/types/shared/DeepReadonly.d.ts.map +1 -0
  26. package/dist/types/shared/MutationFilters.d.ts +2 -1
  27. package/dist/types/shared/MutationFilters.d.ts.map +1 -1
  28. package/dist/types/shared/QueryFilters.d.ts +3 -2
  29. package/dist/types/shared/QueryFilters.d.ts.map +1 -1
  30. package/dist/types/shared/ServiceOperationFetchInfiniteQueryOptions.d.ts +11 -5
  31. package/dist/types/shared/ServiceOperationFetchInfiniteQueryOptions.d.ts.map +1 -1
  32. package/dist/types/shared/ServiceOperationFetchQueryOptions.d.ts +14 -7
  33. package/dist/types/shared/ServiceOperationFetchQueryOptions.d.ts.map +1 -1
  34. package/dist/types/shared/ServiceOperationMutation.d.ts +5 -4
  35. package/dist/types/shared/ServiceOperationMutation.d.ts.map +1 -1
  36. package/dist/types/shared/ServiceOperationQuery.d.ts +2 -1
  37. package/dist/types/shared/ServiceOperationQuery.d.ts.map +1 -1
  38. package/dist/types/shared/UseQueryOptionsForUseQueries.d.ts +2 -1
  39. package/dist/types/shared/UseQueryOptionsForUseQueries.d.ts.map +1 -1
  40. package/dist/types/shared/UseQueryOptionsForUseSuspenseQuery.d.ts +2 -1
  41. package/dist/types/shared/UseQueryOptionsForUseSuspenseQuery.d.ts.map +1 -1
  42. package/dist/types/shared/index.d.ts +1 -0
  43. package/dist/types/shared/index.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/src/service-operation/ServiceOperationFetchInfiniteQuery.ts +47 -21
  46. package/src/service-operation/ServiceOperationGetInfiniteQueryData.ts +4 -1
  47. package/src/service-operation/ServiceOperationGetQueryData.ts +4 -1
  48. package/src/service-operation/ServiceOperationGetQueryState.ts +11 -3
  49. package/src/service-operation/ServiceOperationSetInfiniteQueryData.ts +12 -3
  50. package/src/service-operation/ServiceOperationSetQueryData.ts +5 -2
  51. package/src/service-operation/ServiceOperationUseInfiniteQuery.ts +14 -7
  52. package/src/service-operation/ServiceOperationUseMutation.ts +3 -2
  53. package/src/service-operation/ServiceOperationUseQuery.ts +10 -3
  54. package/src/service-operation/ServiceOperationUseSuspenseInfiniteQuery.ts +6 -3
  55. package/src/service-operation/ServiceOperationUseSuspenseQuery.ts +4 -1
  56. package/src/shared/DeepReadonly.ts +7 -0
  57. package/src/shared/MutationFilters.ts +2 -1
  58. package/src/shared/QueryFilters.ts +3 -2
  59. package/src/shared/ServiceOperationFetchInfiniteQueryOptions.ts +19 -5
  60. package/src/shared/ServiceOperationFetchQueryOptions.ts +24 -9
  61. package/src/shared/ServiceOperationMutation.ts +5 -4
  62. package/src/shared/ServiceOperationQuery.ts +2 -1
  63. package/src/shared/UseQueryOptionsForUseQueries.ts +2 -1
  64. package/src/shared/UseQueryOptionsForUseSuspenseQuery.ts +2 -1
  65. package/src/shared/index.ts +1 -0
@@ -1,11 +1,12 @@
1
1
  import type { QueriesPlaceholderDataFunction } from '@tanstack/query-core';
2
2
  import type { UseQueryOptions } from '@tanstack/react-query';
3
+ import type { DeepReadonly } from './DeepReadonly.js';
3
4
  import type { ServiceOperationQueryKey } from './ServiceOperationKey.js';
4
5
  export type UseQueryOptionsForUseQueries<TSchema extends {
5
6
  url: string;
6
7
  method: string;
7
8
  }, TParams, TQueryFnData, TError, TData = TQueryFnData> = Omit<UseQueryOptions<TQueryFnData, TError, TData, ServiceOperationQueryKey<TSchema, TParams>>, 'placeholderData' | 'suspense' | 'queryKey'> & ({
8
- parameters: TParams;
9
+ parameters: DeepReadonly<TParams>;
9
10
  placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
10
11
  queryKey?: never;
11
12
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"UseQueryOptionsForUseQueries.d.ts","sourceRoot":"","sources":["../../../src/shared/UseQueryOptionsForUseQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,MAAM,MAAM,4BAA4B,CACtC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,GAAG,YAAY,IAClB,IAAI,CACN,eAAe,CACb,YAAY,EACZ,MAAM,EACN,KAAK,EACL,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAC3C,EACD,iBAAiB,GAAG,UAAU,GAAG,UAAU,CAC5C,GACC,CACI;IACE,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EACZ,YAAY,GACZ,8BAA8B,CAAC,YAAY,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,QAAQ,EAAE,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,eAAe,CAAC,EACZ,YAAY,GACZ,8BAA8B,CAAC,YAAY,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB,CACJ,CAAC"}
1
+ {"version":3,"file":"UseQueryOptionsForUseQueries.d.ts","sourceRoot":"","sources":["../../../src/shared/UseQueryOptionsForUseQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,MAAM,MAAM,4BAA4B,CACtC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,GAAG,YAAY,IAClB,IAAI,CACN,eAAe,CACb,YAAY,EACZ,MAAM,EACN,KAAK,EACL,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAC3C,EACD,iBAAiB,GAAG,UAAU,GAAG,UAAU,CAC5C,GACC,CACI;IACE,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAClC,eAAe,CAAC,EACZ,YAAY,GACZ,8BAA8B,CAAC,YAAY,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,QAAQ,EAAE,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,eAAe,CAAC,EACZ,YAAY,GACZ,8BAA8B,CAAC,YAAY,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB,CACJ,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import type { UseQueryOptions } from '@tanstack/react-query';
2
+ import type { DeepReadonly } from './DeepReadonly.js';
2
3
  import type { ServiceOperationQueryKey } from './ServiceOperationKey.js';
3
4
  export type UseQueryOptionsForUseSuspenseQuery<TSchema extends {
4
5
  url: string;
5
6
  method: string;
6
7
  }, TParams, TQueryFnData, TError, TData = TQueryFnData> = Omit<UseQueryOptions<TQueryFnData, TError, TData, ServiceOperationQueryKey<TSchema, TParams>>, 'enabled' | 'throwOnError' | 'placeholderData' | 'queryKey'> & ({
7
- parameters: TParams;
8
+ parameters: DeepReadonly<TParams>;
8
9
  queryKey?: never;
9
10
  } | {
10
11
  queryKey: ServiceOperationQueryKey<TSchema, TParams>;
@@ -1 +1 @@
1
- {"version":3,"file":"UseQueryOptionsForUseSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/shared/UseQueryOptionsForUseSuspenseQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,MAAM,MAAM,kCAAkC,CAC5C,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,GAAG,YAAY,IAClB,IAAI,CACN,eAAe,CACb,YAAY,EACZ,MAAM,EACN,KAAK,EACL,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAC3C,EACD,SAAS,GAAG,cAAc,GAAG,iBAAiB,GAAG,UAAU,CAC5D,GACC,CACI;IACE,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,QAAQ,EAAE,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB,CACJ,CAAC"}
1
+ {"version":3,"file":"UseQueryOptionsForUseSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/shared/UseQueryOptionsForUseSuspenseQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,MAAM,MAAM,kCAAkC,CAC5C,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,GAAG,YAAY,IAClB,IAAI,CACN,eAAe,CACb,YAAY,EACZ,MAAM,EACN,KAAK,EACL,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAC3C,EACD,SAAS,GAAG,cAAc,GAAG,iBAAiB,GAAG,UAAU,CAC5D,GACC,CACI;IACE,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,QAAQ,EAAE,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB,CACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export type * from './AreAllOptional.js';
2
+ export type * from './DeepReadonly.js';
2
3
  export type * from './InvalidateQueryFilters.js';
3
4
  export type * from './MutationFilters.js';
4
5
  export type * from './OperationInfiniteData.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,gDAAgD,CAAC;AACpE,mBAAmB,wCAAwC,CAAC;AAC5D,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,gDAAgD,CAAC;AACpE,mBAAmB,wCAAwC,CAAC;AAC5D,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-qraft/tanstack-query-react-types",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "scripts": {
5
5
  "build": "yarn clean && NODE_ENV=production rollup --config rollup.config.mjs && tsc --project tsconfig.build.json --emitDeclarationOnly",
6
6
  "dev": "yarn clean && tsc --project tsconfig.build.json --watch --outDir ./dist/esm --noEmitOnError false",
@@ -1,4 +1,6 @@
1
1
  import type {
2
+ AreAllOptional,
3
+ DeepReadonly,
2
4
  OperationInfiniteData,
3
5
  ServiceOperationEnsureInfiniteQueryDataOptions,
4
6
  ServiceOperationFetchInfiniteQueryOptions,
@@ -11,32 +13,56 @@ export interface ServiceOperationFetchInfiniteQuery<
11
13
  TError,
12
14
  > {
13
15
  fetchInfiniteQuery<TPageParam extends TParams>(
14
- options: ServiceOperationFetchInfiniteQueryOptions<
15
- TSchema,
16
- TOperationQueryFnData,
17
- TParams,
18
- TPageParam,
19
- TError
20
- >
16
+ options: AreAllOptional<TParams> extends true
17
+ ? ServiceOperationFetchInfiniteQueryOptions<
18
+ TSchema,
19
+ TOperationQueryFnData,
20
+ TParams,
21
+ DeepReadonly<TPageParam>,
22
+ TError
23
+ > | void
24
+ : ServiceOperationFetchInfiniteQueryOptions<
25
+ TSchema,
26
+ TOperationQueryFnData,
27
+ TParams,
28
+ DeepReadonly<TPageParam>,
29
+ TError
30
+ >
21
31
  ): Promise<OperationInfiniteData<TOperationQueryFnData, TParams>>;
22
32
 
23
33
  prefetchInfiniteQuery<TPageParam extends TParams>(
24
- options: ServiceOperationFetchInfiniteQueryOptions<
25
- TSchema,
26
- TOperationQueryFnData,
27
- TParams,
28
- TPageParam,
29
- TError
30
- >
34
+ options: AreAllOptional<TParams> extends true
35
+ ? ServiceOperationFetchInfiniteQueryOptions<
36
+ TSchema,
37
+ TOperationQueryFnData,
38
+ TParams,
39
+ DeepReadonly<TPageParam>,
40
+ TError
41
+ > | void
42
+ : ServiceOperationFetchInfiniteQueryOptions<
43
+ TSchema,
44
+ TOperationQueryFnData,
45
+ TParams,
46
+ DeepReadonly<TPageParam>,
47
+ TError
48
+ >
31
49
  ): Promise<void>;
32
50
 
33
51
  ensureInfiniteQueryData<TPageParam extends TParams>(
34
- options: ServiceOperationEnsureInfiniteQueryDataOptions<
35
- TSchema,
36
- TOperationQueryFnData,
37
- TParams,
38
- TPageParam,
39
- TError
40
- >
52
+ options: AreAllOptional<TParams> extends true
53
+ ? ServiceOperationEnsureInfiniteQueryDataOptions<
54
+ TSchema,
55
+ TOperationQueryFnData,
56
+ TParams,
57
+ DeepReadonly<TPageParam>,
58
+ TError
59
+ > | void
60
+ : ServiceOperationEnsureInfiniteQueryDataOptions<
61
+ TSchema,
62
+ TOperationQueryFnData,
63
+ TParams,
64
+ DeepReadonly<TPageParam>,
65
+ TError
66
+ >
41
67
  ): Promise<OperationInfiniteData<TOperationQueryFnData, TParams>>;
42
68
  }
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  OperationInfiniteData,
4
5
  ServiceOperationInfiniteQueryKey,
5
6
  } from '@openapi-qraft/tanstack-query-react-types';
@@ -12,6 +13,8 @@ export interface ServiceOperationGetInfiniteQueryData<
12
13
  getInfiniteQueryData(
13
14
  parameters:
14
15
  | ServiceOperationInfiniteQueryKey<TSchema, TParams>
15
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams)
16
+ | (AreAllOptional<TParams> extends true
17
+ ? DeepReadonly<TParams> | void
18
+ : DeepReadonly<TParams>)
16
19
  ): OperationInfiniteData<TOperationQueryFnData, TParams> | undefined;
17
20
  }
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  ServiceOperationQueryKey,
4
5
  } from '@openapi-qraft/tanstack-query-react-types';
5
6
 
@@ -11,6 +12,8 @@ export interface ServiceOperationGetQueryData<
11
12
  getQueryData(
12
13
  parameters:
13
14
  | ServiceOperationQueryKey<TSchema, TParams>
14
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams)
15
+ | (AreAllOptional<TParams> extends true
16
+ ? DeepReadonly<TParams> | void
17
+ : DeepReadonly<TParams>)
15
18
  ): TOperationQueryFnData | undefined;
16
19
  }
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  OperationInfiniteData,
4
5
  ServiceOperationInfiniteQueryKey,
5
6
  ServiceOperationQueryKey,
@@ -15,13 +16,20 @@ export interface ServiceOperationGetQueryState<
15
16
  getQueryState(
16
17
  parameters:
17
18
  | ServiceOperationQueryKey<TSchema, TParams>
18
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams)
19
+ | (AreAllOptional<TParams> extends true
20
+ ? DeepReadonly<TParams> | void
21
+ : DeepReadonly<TParams>)
19
22
  ): QueryState<TOperationQueryFnData, TError> | undefined;
20
23
 
21
24
  getInfiniteQueryState(
22
25
  parameters: AreAllOptional<TParams> extends true
23
- ? TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams> | void
24
- : TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams>
26
+ ?
27
+ | DeepReadonly<TParams>
28
+ | ServiceOperationInfiniteQueryKey<TSchema, TParams>
29
+ | void
30
+ :
31
+ | DeepReadonly<TParams>
32
+ | ServiceOperationInfiniteQueryKey<TSchema, TParams>
25
33
  ):
26
34
  | QueryState<OperationInfiniteData<TOperationQueryFnData, TParams>, TError>
27
35
  | undefined;
@@ -1,4 +1,6 @@
1
1
  import type {
2
+ AreAllOptional,
3
+ DeepReadonly,
2
4
  OperationInfiniteData,
3
5
  ServiceOperationInfiniteQueryKey,
4
6
  } from '@openapi-qraft/tanstack-query-react-types';
@@ -7,14 +9,21 @@ import type { NoInfer, SetDataOptions, Updater } from '@tanstack/query-core';
7
9
  export interface ServiceOperationSetInfiniteQueryData<
8
10
  TSchema extends { url: string; method: string },
9
11
  TOperationQueryFnData,
10
- TParams = {},
12
+ TParams,
11
13
  > {
12
14
  setInfiniteQueryData(
13
- parameters: TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams>,
15
+ parameters:
16
+ | (AreAllOptional<TParams> extends true
17
+ ? DeepReadonly<TParams> | undefined
18
+ : DeepReadonly<TParams>)
19
+ | ServiceOperationInfiniteQueryKey<TSchema, TParams>,
14
20
  updater: Updater<
15
21
  | NoInfer<OperationInfiniteData<TOperationQueryFnData, TParams>>
16
22
  | undefined,
17
- NoInfer<OperationInfiniteData<TOperationQueryFnData, TParams>> | undefined
23
+ | NoInfer<
24
+ DeepReadonly<OperationInfiniteData<TOperationQueryFnData, TParams>>
25
+ >
26
+ | undefined
18
27
  >,
19
28
  options?: SetDataOptions
20
29
  ): OperationInfiniteData<TOperationQueryFnData, TParams> | undefined;
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  ServiceOperationQueryKey,
4
5
  } from '@openapi-qraft/tanstack-query-react-types';
5
6
  import type { NoInfer, SetDataOptions, Updater } from '@tanstack/query-core';
@@ -11,11 +12,13 @@ export interface ServiceOperationSetQueryData<
11
12
  > {
12
13
  setQueryData(
13
14
  parameters:
14
- | (AreAllOptional<TParams> extends true ? TParams | undefined : TParams)
15
+ | (AreAllOptional<TParams> extends true
16
+ ? DeepReadonly<TParams> | undefined
17
+ : DeepReadonly<TParams>)
15
18
  | ServiceOperationQueryKey<TSchema, TParams>,
16
19
  updater: Updater<
17
20
  NoInfer<TOperationQueryFnData> | undefined,
18
- NoInfer<TOperationQueryFnData> | undefined
21
+ NoInfer<DeepReadonly<TOperationQueryFnData>> | undefined
19
22
  >,
20
23
  options?: SetDataOptions
21
24
  ): TOperationQueryFnData | undefined;
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  OperationInfiniteData,
4
5
  PartialParameters,
5
6
  ServiceOperationInfiniteQueryKey,
@@ -19,7 +20,9 @@ export interface ServiceOperationUseInfiniteQuery<
19
20
  TError,
20
21
  > {
21
22
  getInfiniteQueryKey(
22
- parameters: AreAllOptional<TParams> extends true ? TParams | void : TParams
23
+ parameters: AreAllOptional<TParams> extends true
24
+ ? DeepReadonly<TParams> | void
25
+ : DeepReadonly<TParams>
23
26
  ): ServiceOperationInfiniteQueryKey<TSchema, TParams>;
24
27
 
25
28
  useInfiniteQuery<
@@ -29,14 +32,16 @@ export interface ServiceOperationUseInfiniteQuery<
29
32
  >(
30
33
  parameters:
31
34
  | ServiceOperationInfiniteQueryKey<TSchema, TParams>
32
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams),
35
+ | (AreAllOptional<TParams> extends true
36
+ ? DeepReadonly<TParams> | void
37
+ : DeepReadonly<TParams>),
33
38
  options: Omit<
34
39
  UndefinedInitialDataInfiniteOptions<
35
40
  TQueryFnData,
36
41
  TError,
37
42
  TData,
38
43
  ServiceOperationInfiniteQueryKey<TSchema, TParams>,
39
- PartialParameters<TPageParam>
44
+ PartialParameters<DeepReadonly<TPageParam>>
40
45
  >,
41
46
  | 'queryKey'
42
47
  | 'getPreviousPageParam'
@@ -45,7 +50,7 @@ export interface ServiceOperationUseInfiniteQuery<
45
50
  > &
46
51
  InfiniteQueryPageParamsOptions<
47
52
  TQueryFnData,
48
- PartialParameters<TPageParam>
53
+ PartialParameters<DeepReadonly<TPageParam>>
49
54
  >
50
55
  ): UseInfiniteQueryResult<TData, TError | Error>;
51
56
 
@@ -56,14 +61,16 @@ export interface ServiceOperationUseInfiniteQuery<
56
61
  >(
57
62
  parameters:
58
63
  | ServiceOperationInfiniteQueryKey<TSchema, TParams>
59
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams),
64
+ | (AreAllOptional<TParams> extends true
65
+ ? DeepReadonly<TParams> | void
66
+ : DeepReadonly<TParams>),
60
67
  options: Omit<
61
68
  DefinedInitialDataInfiniteOptions<
62
69
  TQueryFnData,
63
70
  TError,
64
71
  TData,
65
72
  ServiceOperationInfiniteQueryKey<TSchema, TParams>,
66
- PartialParameters<TPageParam>
73
+ PartialParameters<DeepReadonly<TPageParam>>
67
74
  >,
68
75
  | 'queryKey'
69
76
  | 'getPreviousPageParam'
@@ -72,7 +79,7 @@ export interface ServiceOperationUseInfiniteQuery<
72
79
  > &
73
80
  InfiniteQueryPageParamsOptions<
74
81
  TOperationQueryFnData,
75
- PartialParameters<TPageParam>
82
+ PartialParameters<DeepReadonly<TPageParam>>
76
83
  >
77
84
  ): DefinedUseInfiniteQueryResult<TData, TError | Error>;
78
85
  }
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  MutationVariables,
4
5
  ServiceOperationMutationKey,
5
6
  ServiceOperationUseMutationOptions,
@@ -14,11 +15,11 @@ export interface ServiceOperationUseMutation<
14
15
  TError,
15
16
  > {
16
17
  getMutationKey(
17
- parameters: TParams | void
18
+ parameters: DeepReadonly<TParams> | void
18
19
  ): ServiceOperationMutationKey<TSchema, TParams>;
19
20
 
20
21
  useMutation<TVariables extends TBody, TContext = unknown>(
21
- parameters: TParams,
22
+ parameters: DeepReadonly<TParams>,
22
23
  options?: ServiceOperationUseMutationOptions<
23
24
  TSchema,
24
25
  TMutationData,
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  ServiceOperationQueryKey,
4
5
  } from '@openapi-qraft/tanstack-query-react-types';
5
6
  import type {
@@ -16,13 +17,17 @@ export interface ServiceOperationUseQuery<
16
17
  TError,
17
18
  > {
18
19
  getQueryKey(
19
- parameters: AreAllOptional<TParams> extends true ? TParams | void : TParams
20
+ parameters: AreAllOptional<TParams> extends true
21
+ ? DeepReadonly<TParams> | void
22
+ : DeepReadonly<TParams>
20
23
  ): ServiceOperationQueryKey<TSchema, TParams>;
21
24
 
22
25
  useQuery<TData = TOperationQueryFnData>(
23
26
  parameters:
24
27
  | ServiceOperationQueryKey<TSchema, TParams>
25
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams),
28
+ | (AreAllOptional<TParams> extends true
29
+ ? DeepReadonly<TParams> | void
30
+ : DeepReadonly<TParams>),
26
31
  options?: Omit<
27
32
  UndefinedInitialDataOptions<
28
33
  TOperationQueryFnData,
@@ -37,7 +42,9 @@ export interface ServiceOperationUseQuery<
37
42
  useQuery<TData = TOperationQueryFnData>(
38
43
  parameters:
39
44
  | ServiceOperationQueryKey<TSchema, TParams>
40
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams),
45
+ | (AreAllOptional<TParams> extends true
46
+ ? DeepReadonly<TParams> | void
47
+ : DeepReadonly<TParams>),
41
48
  options: Omit<
42
49
  DefinedInitialDataOptions<
43
50
  TOperationQueryFnData,
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  OperationInfiniteData,
4
5
  PartialParameters,
5
6
  ServiceOperationInfiniteQueryKey,
@@ -22,7 +23,9 @@ export interface ServiceOperationUseSuspenseInfiniteQuery<
22
23
  >(
23
24
  parameters:
24
25
  | ServiceOperationInfiniteQueryKey<TSchema, TParams>
25
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams),
26
+ | (AreAllOptional<TParams> extends true
27
+ ? DeepReadonly<TParams> | void
28
+ : DeepReadonly<TParams>),
26
29
  options: Omit<
27
30
  UseSuspenseInfiniteQueryOptions<
28
31
  TOperationQueryFnData,
@@ -30,7 +33,7 @@ export interface ServiceOperationUseSuspenseInfiniteQuery<
30
33
  OperationInfiniteData<TData, TParams>,
31
34
  TOperationQueryFnData,
32
35
  ServiceOperationInfiniteQueryKey<TSchema, TParams>,
33
- PartialParameters<TPageParam>
36
+ PartialParameters<DeepReadonly<TPageParam>>
34
37
  >,
35
38
  | 'queryKey'
36
39
  | 'getPreviousPageParam'
@@ -39,7 +42,7 @@ export interface ServiceOperationUseSuspenseInfiniteQuery<
39
42
  > &
40
43
  InfiniteQueryPageParamsOptions<
41
44
  TOperationQueryFnData,
42
- PartialParameters<TPageParam>
45
+ PartialParameters<DeepReadonly<TPageParam>>
43
46
  >
44
47
  ): UseSuspenseInfiniteQueryResult<
45
48
  OperationInfiniteData<TData, TParams>,
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AreAllOptional,
3
+ DeepReadonly,
3
4
  ServiceOperationQueryKey,
4
5
  } from '@openapi-qraft/tanstack-query-react-types';
5
6
  import type {
@@ -16,7 +17,9 @@ export interface ServiceOperationUseSuspenseQuery<
16
17
  useSuspenseQuery<TData = TOperationQueryFnData>(
17
18
  parameters:
18
19
  | ServiceOperationQueryKey<TSchema, TParams>
19
- | (AreAllOptional<TParams> extends true ? TParams | void : TParams),
20
+ | (AreAllOptional<TParams> extends true
21
+ ? DeepReadonly<TParams> | void
22
+ : DeepReadonly<TParams>),
20
23
  options?: Omit<
21
24
  UseSuspenseQueryOptions<
22
25
  TOperationQueryFnData,
@@ -0,0 +1,7 @@
1
+ export type DeepReadonly<T> = T extends (...args: any[]) => any
2
+ ? T
3
+ : T extends Array<infer U>
4
+ ? ReadonlyArray<DeepReadonly<U>>
5
+ : T extends object
6
+ ? { readonly [P in keyof T]: DeepReadonly<T[P]> }
7
+ : T;
@@ -5,6 +5,7 @@ import type {
5
5
  } from '@tanstack/query-core';
6
6
  import type { UseMutationOptions } from '@tanstack/react-query';
7
7
  import type { AreAllOptional } from './AreAllOptional.js';
8
+ import type { DeepReadonly } from './DeepReadonly.js';
8
9
  import type { PartialParameters } from './PartialParameters.js';
9
10
  import type { ServiceOperationMutationKey } from './ServiceOperationKey.js';
10
11
 
@@ -47,7 +48,7 @@ export interface MutationFiltersByParameters<
47
48
  /**
48
49
  * Include mutations matching these parameters
49
50
  */
50
- parameters?: PartialParameters<TParams>;
51
+ parameters?: PartialParameters<DeepReadonly<TParams>>;
51
52
  mutationKey?: never;
52
53
  }
53
54
 
@@ -1,4 +1,5 @@
1
1
  import type { DefaultError, FetchStatus, Query } from '@tanstack/query-core';
2
+ import type { DeepReadonly } from './DeepReadonly.js';
2
3
  import type { OperationInfiniteData } from './OperationInfiniteData.js';
3
4
  import type { PartialParameters } from './PartialParameters.js';
4
5
  import type {
@@ -150,7 +151,7 @@ interface QueryFiltersByExactParameters<
150
151
  /**
151
152
  * Include queries matching parameters
152
153
  */
153
- parameters: TParams;
154
+ parameters: DeepReadonly<TParams>;
154
155
  }
155
156
 
156
157
  interface QueryFiltersByWeakParameters<
@@ -174,7 +175,7 @@ interface QueryFiltersByWeakParameters<
174
175
  /**
175
176
  * Include queries matching parameters
176
177
  */
177
- parameters?: PartialParameters<TParams>;
178
+ parameters?: PartialParameters<DeepReadonly<TParams>>;
178
179
  }
179
180
 
180
181
  export type QueryFiltersByParameters<
@@ -6,6 +6,7 @@ import type {
6
6
  QueryFunction,
7
7
  } from '@tanstack/query-core';
8
8
  import type { AreAllOptional } from './AreAllOptional.js';
9
+ import type { DeepReadonly } from './DeepReadonly.js';
9
10
  import type { OperationInfiniteData } from './OperationInfiniteData.js';
10
11
  import type { PartialParameters } from './PartialParameters.js';
11
12
  import type { RequestFn } from './RequestFn.js';
@@ -76,7 +77,7 @@ type FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =
76
77
  | {
77
78
  pages: number;
78
79
  getNextPageParam: GetNextPageParamFunction<
79
- PartialParameters<TPageParam>,
80
+ PartialParameters<DeepReadonly<TPageParam>>,
80
81
  TQueryFnData
81
82
  >;
82
83
  };
@@ -114,11 +115,19 @@ type FetchInfiniteQueryOptionsByQueryKey<
114
115
  TParams,
115
116
  TPageParam,
116
117
  TError
117
- > & {
118
+ > &
119
+ (AreAllOptional<TParams> extends true
120
+ ? Partial<FetchInfiniteQueryOptionsQueryKey<TSchema, TParams>>
121
+ : FetchInfiniteQueryOptionsQueryKey<TSchema, TParams>);
122
+
123
+ type FetchInfiniteQueryOptionsQueryKey<
124
+ TSchema extends { url: string; method: string },
125
+ TParams,
126
+ > = {
118
127
  /**
119
128
  * Fetch Queries by query key
120
129
  */
121
- queryKey?: ServiceOperationInfiniteQueryKey<TSchema, TParams>;
130
+ queryKey: ServiceOperationInfiniteQueryKey<TSchema, TParams>;
122
131
  parameters?: never;
123
132
  };
124
133
 
@@ -134,11 +143,16 @@ type FetchInfiniteQueryOptionsByParameters<
134
143
  TParams,
135
144
  TPageParam,
136
145
  TError
137
- > & {
146
+ > &
147
+ (AreAllOptional<TParams> extends true
148
+ ? Partial<FetchInfiniteQueryOptionsParameters<TParams>>
149
+ : FetchInfiniteQueryOptionsParameters<TParams>);
150
+
151
+ type FetchInfiniteQueryOptionsParameters<TParams> = {
138
152
  /**
139
153
  * Fetch Queries by parameters
140
154
  */
141
- parameters?: TParams;
155
+ parameters: DeepReadonly<TParams>;
142
156
  queryKey?: never;
143
157
  };
144
158
 
@@ -4,6 +4,8 @@ import type {
4
4
  FetchQueryOptions,
5
5
  QueryFunction,
6
6
  } from '@tanstack/query-core';
7
+ import type { AreAllOptional } from './AreAllOptional.js';
8
+ import type { DeepReadonly } from './DeepReadonly.js';
7
9
  import type { ServiceOperationQueryKey } from './ServiceOperationKey.js';
8
10
 
9
11
  export type ServiceOperationFetchQueryOptions<
@@ -47,31 +49,44 @@ type FetchQueryOptionsBase<
47
49
  'queryKey' | 'queryFn'
48
50
  >;
49
51
 
50
- interface FetchQueryOptionsByQueryKey<
52
+ type FetchQueryOptionsByQueryKey<
51
53
  TSchema extends { url: string; method: string },
52
54
  TQueryFnData,
53
- TParams = {},
55
+ TParams,
54
56
  TError = DefaultError,
55
- > extends FetchQueryOptionsBase<TSchema, TQueryFnData, TParams, TError> {
57
+ > = FetchQueryOptionsBase<TSchema, TQueryFnData, TParams, TError> &
58
+ (AreAllOptional<TParams> extends true
59
+ ? Partial<FetchQueryOptionsQueryKey<TSchema, TParams>>
60
+ : FetchQueryOptionsQueryKey<TSchema, TParams>);
61
+
62
+ type FetchQueryOptionsQueryKey<
63
+ TSchema extends { url: string; method: string },
64
+ TParams,
65
+ > = {
56
66
  /**
57
67
  * Fetch Queries by query key
58
68
  */
59
69
  queryKey: ServiceOperationQueryKey<TSchema, TParams>;
60
70
  parameters?: never;
61
- }
71
+ };
62
72
 
63
- interface FetchQueryOptionsByParameters<
73
+ type FetchQueryOptionsByParameters<
64
74
  TSchema extends { url: string; method: string },
65
75
  TQueryFnData,
66
- TParams = {},
76
+ TParams,
67
77
  TError = DefaultError,
68
- > extends FetchQueryOptionsBase<TSchema, TQueryFnData, TParams, TError> {
78
+ > = FetchQueryOptionsBase<TSchema, TQueryFnData, TParams, TError> &
79
+ (AreAllOptional<TParams> extends true
80
+ ? Partial<FetchQueryOptionsParameters<TParams>>
81
+ : FetchQueryOptionsParameters<TParams>);
82
+
83
+ type FetchQueryOptionsParameters<TParams> = {
69
84
  /**
70
85
  * Fetch Queries by parameters
71
86
  */
72
- parameters: TParams;
87
+ parameters: DeepReadonly<TParams>;
73
88
  queryKey?: never;
74
- }
89
+ };
75
90
 
76
91
  type FetchQueryOptionsQueryFn<
77
92
  TSchema extends { url: string; method: string },
@@ -1,4 +1,5 @@
1
1
  import type { AreAllOptional } from '@openapi-qraft/tanstack-query-react-types';
2
+ import type { DeepReadonly } from './DeepReadonly.js';
2
3
 
3
4
  interface QueryFnBaseUrlOptions {
4
5
  /**
@@ -14,19 +15,19 @@ export type ServiceOperationMutationFnOptions<TBody, TParams> =
14
15
  ?
15
16
  | void // todo::try to move void to arguments
16
17
  | ({
17
- parameters?: TParams;
18
+ parameters?: DeepReadonly<TParams>;
18
19
  body?: TBody;
19
20
  } & QueryFnBaseUrlOptions)
20
21
  : {
21
- parameters: TParams;
22
+ parameters: DeepReadonly<TParams>;
22
23
  body?: TBody;
23
24
  } & QueryFnBaseUrlOptions
24
25
  : AreAllOptional<TParams> extends true
25
26
  ? {
26
- parameters?: TParams;
27
+ parameters?: DeepReadonly<TParams>;
27
28
  body: TBody;
28
29
  } & QueryFnBaseUrlOptions
29
30
  : {
30
- parameters: TParams;
31
+ parameters: DeepReadonly<TParams>;
31
32
  body: TBody;
32
33
  } & QueryFnBaseUrlOptions;