@acrool/rtk-query-codegen-openapi 1.4.0-alpha.4 → 1.4.0-alpha.5
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/lib/bin/cli.mjs +17 -24
- package/lib/bin/cli.mjs.map +1 -1
- package/lib/index.js +3 -17
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +3 -17
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/generators/rtk-enhance-endpoints-generator.ts +2 -23
package/package.json
CHANGED
|
@@ -14,34 +14,13 @@ export function generateRtkEnhanceEndpointsFile(endpointInfos: Array<{
|
|
|
14
14
|
summary: string;
|
|
15
15
|
}>, options: GenerationOptions) {
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
const endpointConfigs = endpointInfos.map(info => {
|
|
19
|
-
// 為 query 類型的端點添加 providesTags,為 mutation 類型的添加 invalidatesTags
|
|
20
|
-
if (info.isQuery) {
|
|
21
|
-
// Query 端點提供 tags
|
|
22
|
-
return ` ${info.operationName}: {
|
|
23
|
-
providesTags: (result, error, arg) => [],
|
|
24
|
-
},`;
|
|
25
|
-
} else {
|
|
26
|
-
// Mutation 端點使 tags 失效
|
|
27
|
-
return ` ${info.operationName}: {
|
|
28
|
-
invalidatesTags: (result, error, arg) => [],
|
|
29
|
-
},`;
|
|
30
|
-
}
|
|
31
|
-
}).join('\n');
|
|
32
|
-
|
|
33
|
-
// 生成 import 語句
|
|
34
|
-
const importStatements = `/* eslint-disable */
|
|
17
|
+
return `/* eslint-disable */
|
|
35
18
|
// [Warning] Generated automatically - do not edit manually
|
|
36
19
|
|
|
37
20
|
import api from "./query.generated";
|
|
38
|
-
`;
|
|
39
21
|
|
|
40
|
-
return `${importStatements}
|
|
41
22
|
const enhancedApi = api.enhanceEndpoints({
|
|
42
|
-
endpoints: {
|
|
43
|
-
${endpointConfigs}
|
|
44
|
-
},
|
|
23
|
+
endpoints: {},
|
|
45
24
|
});
|
|
46
25
|
|
|
47
26
|
export default enhancedApi;
|