@openapi-qraft/tanstack-query-react-types 2.15.0-beta.6 → 2.15.0-beta.8
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/CHANGELOG.md +14 -0
- package/dist/types/service-operation/ServiceOperationQueryFn.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationQueryFn.d.ts.map +1 -1
- package/dist/types/shared/RequestFn.d.ts +16 -0
- package/dist/types/shared/RequestFn.d.ts.map +1 -1
- package/dist/types/shared/ServiceOperationQuery.d.ts +8 -11
- package/dist/types/shared/ServiceOperationQuery.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/service-operation/ServiceOperationQueryFn.ts +5 -1
- package/src/shared/RequestFn.ts +24 -0
- package/src/shared/ServiceOperationQuery.ts +8 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @openapi-qraft/tanstack-query-react-types
|
|
2
2
|
|
|
3
|
+
## 2.15.0-beta.8
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0da32c6: Expose request source metadata on `requestFn` calls. Query requests now include the original TanStack Query function context, mutation requests include variables and the computed mutation key, and direct operation calls are marked as invokes.
|
|
8
|
+
|
|
9
|
+
## 2.15.0-beta.7
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- f43bc5c: When an operation has only optional parameters, the imperative operation function now accepts `QueryFnOptions` (e.g. `signal`, `meta`) without requiring a `parameters` argument. This matches how optional request fields are already handled for hooks and improves typing for direct `qraft.<service>.<operation>(…)` calls.
|
|
14
|
+
- 6a2f1ed: Updated repository dependencies to current compatible versions across the workspace.
|
|
15
|
+
- 55a23fd: Updated the openapi-typescript package to the current compatible version.
|
|
16
|
+
|
|
3
17
|
## 2.15.0-beta.6
|
|
4
18
|
|
|
5
19
|
## 2.15.0-beta.5
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AreAllOptional, QueryFnOptionsByParameters, QueryFnOptionsByQueryKey, RequestFnResponse } from '@openapi-qraft/tanstack-query-react-types';
|
|
1
|
+
import type { AreAllOptional, QueryFnOptions, QueryFnOptionsByParameters, QueryFnOptionsByQueryKey, RequestFnResponse } from '@openapi-qraft/tanstack-query-react-types';
|
|
2
2
|
export interface ServiceOperationQueryFn<TSchema extends {
|
|
3
3
|
url: string;
|
|
4
4
|
method: string;
|
|
5
5
|
}, TOperationQueryFnData, TQueryParams, TError> {
|
|
6
|
-
<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByQueryKey<TSchema, TQueryParams, TMeta, TSignal> | (AreAllOptional<TQueryParams> extends true ? QueryFnOptionsByParameters<TQueryParams, TMeta, TSignal> | void : QueryFnOptionsByParameters<TQueryParams, TMeta, TSignal>), client?: (schema: TSchema, options: {
|
|
6
|
+
<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByQueryKey<TSchema, TQueryParams, TMeta, TSignal> | (AreAllOptional<TQueryParams> extends true ? QueryFnOptionsByParameters<TQueryParams, TMeta, TSignal> | QueryFnOptions<TMeta, TSignal> | void : QueryFnOptionsByParameters<TQueryParams, TMeta, TSignal>), client?: (schema: TSchema, options: {
|
|
7
7
|
parameters: TQueryParams;
|
|
8
8
|
signal?: TSignal;
|
|
9
9
|
meta?: TMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOperationQueryFn.d.ts","sourceRoot":"","sources":["../../../src/service-operation/ServiceOperationQueryFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,uBAAuB,CACtC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,qBAAqB,EACrB,YAAY,EACZ,MAAM;IAEN,CACE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW,EAEzC,OAAO,EACH,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,GAC/D,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,IAAI,
|
|
1
|
+
{"version":3,"file":"ServiceOperationQueryFn.d.ts","sourceRoot":"","sources":["../../../src/service-operation/ServiceOperationQueryFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,uBAAuB,CACtC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,qBAAqB,EACrB,YAAY,EACZ,MAAM;IAEN,CACE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW,EAEzC,OAAO,EACH,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,GAC/D,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,IAAI,GAElC,0BAA0B,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,GACxD,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,GAC9B,IAAI,GACR,0BAA0B,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EACjE,MAAM,CAAC,EAAE,CACP,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,UAAU,EAAE,YAAY,CAAC;QACzB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,KAAK,CAAC;KACd,KACE,OAAO,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,GAC7D,OAAO,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC;CAC9D"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { QueryFunctionContext } from '@tanstack/react-query';
|
|
1
2
|
import type { OperationError } from './OperationError.js';
|
|
3
|
+
import type { ServiceOperationMutationKey } from './ServiceOperationKey.js';
|
|
2
4
|
/**
|
|
3
5
|
* The `RequestFn` is the wrapper on top of the `fetch` function that simplifies
|
|
4
6
|
* the process of making requests to the API using Qraft.
|
|
@@ -30,6 +32,16 @@ export interface OperationSchema {
|
|
|
30
32
|
readonly mediaType?: string[];
|
|
31
33
|
readonly security?: string[];
|
|
32
34
|
}
|
|
35
|
+
export type RequestFnSource = {
|
|
36
|
+
readonly type: 'query';
|
|
37
|
+
readonly context: QueryFunctionContext;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: 'mutation';
|
|
40
|
+
readonly variables: unknown;
|
|
41
|
+
readonly mutationKey: ServiceOperationMutationKey<OperationSchema, unknown>;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: 'invoke';
|
|
44
|
+
};
|
|
33
45
|
export interface RequestFnInfo extends Omit<RequestInit, 'headers' | 'method' | 'body' | 'signal'> {
|
|
34
46
|
/**
|
|
35
47
|
* Request headers
|
|
@@ -64,6 +76,10 @@ export interface RequestFnInfo extends Omit<RequestInit, 'headers' | 'method' |
|
|
|
64
76
|
readonly meta?: Record<string, unknown>;
|
|
65
77
|
/** An AbortSignal to set request's signal. */
|
|
66
78
|
readonly signal?: AbortSignal | null;
|
|
79
|
+
/**
|
|
80
|
+
* Original qraft request source metadata.
|
|
81
|
+
*/
|
|
82
|
+
readonly source?: RequestFnSource;
|
|
67
83
|
}
|
|
68
84
|
/**
|
|
69
85
|
* The `RequestFnResponse` is the response of the `RequestFn` function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestFn.d.ts","sourceRoot":"","sources":["../../../src/shared/R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C/B,GACD;IAEE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEN,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,KAAK,cAAc,GAAG,CACpB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,KAEzB;IACE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,cAAc,CAAC;CACzB,GACD,SAAS,CAAC;AAEd,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,KAAK,MAAM,CAAC;AAG9E,MAAM,MAAM,cAAc,GACtB,WAAW,GACX,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC"}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import type { ServiceOperationQueryKey } from '@openapi-qraft/tanstack-query-react-types';
|
|
2
2
|
import type { DeepReadonly } from './DeepReadonly.js';
|
|
3
|
-
interface
|
|
3
|
+
export interface QueryFnOptions<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> {
|
|
4
4
|
signal?: TSignal;
|
|
5
5
|
meta?: TMeta;
|
|
6
|
+
/**
|
|
7
|
+
* Base URL to use for the request
|
|
8
|
+
* @example 'https://api.example.com'
|
|
9
|
+
*/
|
|
10
|
+
baseUrl?: string;
|
|
6
11
|
}
|
|
7
|
-
export interface QueryFnOptionsByParameters<TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends
|
|
12
|
+
export interface QueryFnOptionsByParameters<TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends QueryFnOptions<TMeta, TSignal> {
|
|
8
13
|
parameters: DeepReadonly<TParams>;
|
|
9
14
|
queryKey?: never;
|
|
10
15
|
}
|
|
11
16
|
export interface QueryFnOptionsByQueryKey<TSchema extends {
|
|
12
17
|
url: string;
|
|
13
18
|
method: string;
|
|
14
|
-
}, TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends
|
|
19
|
+
}, TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends QueryFnOptions<TMeta, TSignal> {
|
|
15
20
|
queryKey: ServiceOperationQueryKey<TSchema, TParams>;
|
|
16
21
|
parameters?: never;
|
|
17
22
|
}
|
|
18
|
-
interface QueryFnBaseUrlOptions {
|
|
19
|
-
/**
|
|
20
|
-
* Base URL to use for the request
|
|
21
|
-
* @example 'https://api.example.com'
|
|
22
|
-
*/
|
|
23
|
-
baseUrl?: string;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
26
23
|
//# sourceMappingURL=ServiceOperationQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOperationQuery.d.ts","sourceRoot":"","sources":["../../../src/shared/ServiceOperationQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"ServiceOperationQuery.d.ts","sourceRoot":"","sources":["../../../src/shared/ServiceOperationQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,cAAc,CAC7B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW;IAEzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B,CACzC,OAAO,EACP,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW,CACzC,SAAQ,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;IACtC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAElC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB,CACvC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EACP,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW,CACzC,SAAQ,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;IACtC,QAAQ,EAAE,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAErD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/tanstack-query-react-types",
|
|
3
|
-
"version": "2.15.0-beta.
|
|
3
|
+
"version": "2.15.0-beta.8",
|
|
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",
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
8
|
-
"lint": "eslint",
|
|
8
|
+
"lint": "eslint --max-warnings 0",
|
|
9
9
|
"clean": "rimraf dist/"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"react": "^18 || ^19"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@openapi-qraft/eslint-config": "1.0.
|
|
39
|
-
"@openapi-qraft/rollup-config": "1.
|
|
40
|
-
"@tanstack/react-query": "^5.
|
|
41
|
-
"eslint": "^
|
|
42
|
-
"rimraf": "^6.1.
|
|
43
|
-
"rollup": "~4.
|
|
44
|
-
"typescript": "^5.
|
|
38
|
+
"@openapi-qraft/eslint-config": "1.1.0-beta.0",
|
|
39
|
+
"@openapi-qraft/rollup-config": "1.2.0-beta.0",
|
|
40
|
+
"@tanstack/react-query": "^5.96.1",
|
|
41
|
+
"eslint": "^10.2.0",
|
|
42
|
+
"rimraf": "^6.1.3",
|
|
43
|
+
"rollup": "~4.60.1",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
45
|
},
|
|
46
46
|
"packageManager": "yarn@4.2.1",
|
|
47
47
|
"files": [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AreAllOptional,
|
|
3
|
+
QueryFnOptions,
|
|
3
4
|
QueryFnOptionsByParameters,
|
|
4
5
|
QueryFnOptionsByQueryKey,
|
|
5
6
|
RequestFnResponse,
|
|
@@ -18,7 +19,10 @@ export interface ServiceOperationQueryFn<
|
|
|
18
19
|
options:
|
|
19
20
|
| QueryFnOptionsByQueryKey<TSchema, TQueryParams, TMeta, TSignal>
|
|
20
21
|
| (AreAllOptional<TQueryParams> extends true
|
|
21
|
-
?
|
|
22
|
+
?
|
|
23
|
+
| QueryFnOptionsByParameters<TQueryParams, TMeta, TSignal>
|
|
24
|
+
| QueryFnOptions<TMeta, TSignal>
|
|
25
|
+
| void
|
|
22
26
|
: QueryFnOptionsByParameters<TQueryParams, TMeta, TSignal>),
|
|
23
27
|
client?: (
|
|
24
28
|
schema: TSchema,
|
package/src/shared/RequestFn.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { QueryFunctionContext } from '@tanstack/react-query';
|
|
1
2
|
import type { OperationError } from './OperationError.js';
|
|
3
|
+
import type { ServiceOperationMutationKey } from './ServiceOperationKey.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* The `RequestFn` is the wrapper on top of the `fetch` function that simplifies
|
|
@@ -48,6 +50,23 @@ export interface OperationSchema {
|
|
|
48
50
|
readonly security?: string[];
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
export type RequestFnSource =
|
|
54
|
+
| {
|
|
55
|
+
readonly type: 'query';
|
|
56
|
+
readonly context: QueryFunctionContext;
|
|
57
|
+
}
|
|
58
|
+
| {
|
|
59
|
+
readonly type: 'mutation';
|
|
60
|
+
readonly variables: unknown;
|
|
61
|
+
readonly mutationKey: ServiceOperationMutationKey<
|
|
62
|
+
OperationSchema,
|
|
63
|
+
unknown
|
|
64
|
+
>;
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
readonly type: 'invoke';
|
|
68
|
+
};
|
|
69
|
+
|
|
51
70
|
export interface RequestFnInfo extends Omit<
|
|
52
71
|
RequestInit,
|
|
53
72
|
'headers' | 'method' | 'body' | 'signal'
|
|
@@ -90,6 +109,11 @@ export interface RequestFnInfo extends Omit<
|
|
|
90
109
|
|
|
91
110
|
/** An AbortSignal to set request's signal. */
|
|
92
111
|
readonly signal?: AbortSignal | null;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Original qraft request source metadata.
|
|
115
|
+
*/
|
|
116
|
+
readonly source?: RequestFnSource;
|
|
93
117
|
}
|
|
94
118
|
|
|
95
119
|
/**
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { ServiceOperationQueryKey } from '@openapi-qraft/tanstack-query-react-types';
|
|
2
2
|
import type { DeepReadonly } from './DeepReadonly.js';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
export interface QueryFnOptions<
|
|
5
5
|
TMeta extends Record<string, any>,
|
|
6
6
|
TSignal extends AbortSignal = AbortSignal,
|
|
7
7
|
> {
|
|
8
8
|
signal?: TSignal;
|
|
9
9
|
meta?: TMeta;
|
|
10
|
+
/**
|
|
11
|
+
* Base URL to use for the request
|
|
12
|
+
* @example 'https://api.example.com'
|
|
13
|
+
*/
|
|
14
|
+
baseUrl?: string;
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
export interface QueryFnOptionsByParameters<
|
|
13
18
|
TParams,
|
|
14
19
|
TMeta extends Record<string, any>,
|
|
15
20
|
TSignal extends AbortSignal = AbortSignal,
|
|
16
|
-
>
|
|
17
|
-
extends QueryFnOptionsBase<TMeta, TSignal>, QueryFnBaseUrlOptions {
|
|
21
|
+
> extends QueryFnOptions<TMeta, TSignal> {
|
|
18
22
|
parameters: DeepReadonly<TParams>;
|
|
19
23
|
|
|
20
24
|
queryKey?: never;
|
|
@@ -25,17 +29,8 @@ export interface QueryFnOptionsByQueryKey<
|
|
|
25
29
|
TParams,
|
|
26
30
|
TMeta extends Record<string, any>,
|
|
27
31
|
TSignal extends AbortSignal = AbortSignal,
|
|
28
|
-
>
|
|
29
|
-
extends QueryFnOptionsBase<TMeta, TSignal>, QueryFnBaseUrlOptions {
|
|
32
|
+
> extends QueryFnOptions<TMeta, TSignal> {
|
|
30
33
|
queryKey: ServiceOperationQueryKey<TSchema, TParams>;
|
|
31
34
|
|
|
32
35
|
parameters?: never;
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
interface QueryFnBaseUrlOptions {
|
|
36
|
-
/**
|
|
37
|
-
* Base URL to use for the request
|
|
38
|
-
* @example 'https://api.example.com'
|
|
39
|
-
*/
|
|
40
|
-
baseUrl?: string;
|
|
41
|
-
}
|