@openapi-qraft/tanstack-query-react-types 2.15.0-beta.7 → 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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 2.15.0-beta.7
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -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/RequestFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"RequestFn.d.ts","sourceRoot":"","sources":["../../../src/shared/RequestFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK,EAAE,MAAM;IACtC,CACE,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,aAAa,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EACX,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,M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": "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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@openapi-qraft/eslint-config": "1.1.0-beta.0",
|
|
39
39
|
"@openapi-qraft/rollup-config": "1.2.0-beta.0",
|
|
40
40
|
"@tanstack/react-query": "^5.96.1",
|
|
41
|
-
"eslint": "^10.
|
|
41
|
+
"eslint": "^10.2.0",
|
|
42
42
|
"rimraf": "^6.1.3",
|
|
43
43
|
"rollup": "~4.60.1",
|
|
44
44
|
"typescript": "^5.9.3"
|
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
|
/**
|