@openapi-qraft/react 2.5.0 → 2.6.1
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 +27 -0
- package/dist/cjs/qraftAPIClient.cjs +11 -6
- package/dist/cjs/qraftAPIClient.cjs.map +1 -1
- package/dist/esm/qraftAPIClient.js +11 -6
- package/dist/esm/qraftAPIClient.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migrate-to-v2.6.0-codemod.d.ts +3 -0
- package/dist/types/migrate-to-v2.6.0-codemod.d.ts.map +1 -0
- package/dist/types/qraftAPIClient.d.ts +132 -34
- package/dist/types/qraftAPIClient.d.ts.map +1 -1
- package/package.json +11 -6
- package/src/index.ts +2 -0
- package/src/migrate-to-v2.6.0-codemod.ts +55 -0
- package/src/qraftAPIClient.ts +343 -192
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "OpenAPI client for React, providing type-safe requests and dynamic TanStack Query React Hooks via a modular, Proxy-based architecture.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "NODE_ENV=production rollup --config rollup.config.mjs && tsc --project tsconfig.build.json --emitDeclarationOnly",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"lint": "eslint",
|
|
12
12
|
"clean": "rimraf dist/",
|
|
13
13
|
"codegen": "openapi-qraft --redocly && yarn _prettify-api",
|
|
14
|
-
"_prettify-api": "prettier --write 'src/tests/fixtures/{api,queryable-write-operations-api}/**/*.ts'"
|
|
14
|
+
"_prettify-api": "prettier --write 'src/tests/fixtures/{api,queryable-write-operations-api,files-api}/**/*.ts'"
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@openapi-qraft/tanstack-query-react-types": "2.
|
|
18
|
+
"@openapi-qraft/tanstack-query-react-types": "2.6.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@tanstack/query-core": "^5.0.0",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"react": "^18 || ^19"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@openapi-qraft/cli": "2.
|
|
26
|
+
"@openapi-qraft/cli": "2.6.1",
|
|
27
27
|
"@openapi-qraft/eslint-config": "1.0.1",
|
|
28
|
-
"@openapi-qraft/openapi-typescript-plugin": "^1.2.
|
|
28
|
+
"@openapi-qraft/openapi-typescript-plugin": "^1.2.17",
|
|
29
29
|
"@openapi-qraft/rollup-config": "1.1.1",
|
|
30
|
-
"@openapi-qraft/tanstack-query-react-plugin": "2.
|
|
30
|
+
"@openapi-qraft/tanstack-query-react-plugin": "2.6.1",
|
|
31
31
|
"@openapi-qraft/test-fixtures": "1.1.0",
|
|
32
32
|
"@tanstack/query-core": "^5.66.3",
|
|
33
33
|
"@tanstack/react-query": "^5.66.3",
|
|
@@ -67,6 +67,11 @@
|
|
|
67
67
|
"import": "./dist/esm/index.js",
|
|
68
68
|
"require": "./dist/cjs/index.cjs"
|
|
69
69
|
},
|
|
70
|
+
"./callbacks": {
|
|
71
|
+
"types": "./dist/types/callbacks/index.d.ts",
|
|
72
|
+
"import": "./dist/esm/callbacks/index.js",
|
|
73
|
+
"require": "./dist/cjs/callbacks/index.cjs"
|
|
74
|
+
},
|
|
70
75
|
"./callbacks/*": {
|
|
71
76
|
"types": "./dist/types/callbacks/*.d.ts",
|
|
72
77
|
"import": "./dist/esm/callbacks/*.js",
|
package/src/index.ts
CHANGED
|
@@ -5,9 +5,11 @@ export {
|
|
|
5
5
|
type CreateAPIBasicClientOptions,
|
|
6
6
|
type CreateAPIQueryClientOptions,
|
|
7
7
|
type APIQueryClientServices,
|
|
8
|
+
type APIDefaultQueryClientServices,
|
|
8
9
|
type APIBasicQueryClientServices,
|
|
9
10
|
type APIBasicClientServices,
|
|
10
11
|
type APIUtilityClientServices,
|
|
12
|
+
type UnionServiceOperationsDeclaration,
|
|
11
13
|
type QraftClientOptions,
|
|
12
14
|
} from './qraftAPIClient.js';
|
|
13
15
|
export {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { API, FileInfo, Options } from 'jscodeshift';
|
|
2
|
+
|
|
3
|
+
export default function transformer(
|
|
4
|
+
file: FileInfo,
|
|
5
|
+
api: API,
|
|
6
|
+
options: Options
|
|
7
|
+
) {
|
|
8
|
+
const j = api.jscodeshift;
|
|
9
|
+
const root = j(file.source);
|
|
10
|
+
|
|
11
|
+
// Get the package name from options or use the default value
|
|
12
|
+
const packageName = options.packageName || '@openapi-qraft/react-client';
|
|
13
|
+
|
|
14
|
+
// Check if qraftAPIClient is imported from our module
|
|
15
|
+
const hasQraftImport =
|
|
16
|
+
root
|
|
17
|
+
.find(j.ImportDeclaration, {
|
|
18
|
+
source: {
|
|
19
|
+
type: 'StringLiteral',
|
|
20
|
+
value: packageName,
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
.find(j.ImportSpecifier, {
|
|
24
|
+
imported: {
|
|
25
|
+
type: 'Identifier',
|
|
26
|
+
name: 'qraftAPIClient',
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
.size() > 0;
|
|
30
|
+
|
|
31
|
+
// If there is no import from our module, we don't make any changes
|
|
32
|
+
if (!hasQraftImport) {
|
|
33
|
+
return file.source;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The TypeParameters type differs in different parsers
|
|
37
|
+
// We check both possible variants
|
|
38
|
+
return root
|
|
39
|
+
.find(j.CallExpression, {
|
|
40
|
+
callee: {
|
|
41
|
+
type: 'Identifier',
|
|
42
|
+
name: 'qraftAPIClient',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
.forEach((path) => {
|
|
46
|
+
// Cast node to a type with possible typeParameters/typeArguments properties
|
|
47
|
+
const node = path.node;
|
|
48
|
+
|
|
49
|
+
// Remove generics, checking different possible property names
|
|
50
|
+
if ('typeParameters' in node) {
|
|
51
|
+
delete node.typeParameters;
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.toSource();
|
|
55
|
+
}
|