@povio/openapi-codegen-cli 2.0.8-rc.5 → 2.0.8-rc.7
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/README.md +63 -0
- package/dist/acl.d.mts +48 -0
- package/dist/acl.mjs +62 -7
- package/dist/auth.context-DKjzWiaA.mjs +59 -0
- package/dist/config-Cu_GYfai.d.mts +6 -0
- package/dist/generate.runner-DNldmk0f.mjs +98 -0
- package/dist/generateCodeFromOpenAPIDoc-B5lnFNGB.mjs +4522 -0
- package/dist/generator.d.mts +65 -0
- package/dist/generator.mjs +144 -0
- package/dist/index.d.mts +246 -0
- package/dist/index.mjs +365 -22
- package/dist/options-DBz5YE3s.d.mts +90 -0
- package/dist/sh.d.mts +1 -0
- package/dist/sh.mjs +439 -0
- package/dist/vite.d.mts +8 -0
- package/dist/vite.mjs +50 -0
- package/package.json +50 -45
- package/src/assets/useMutationEffects.ts +6 -1
- package/src/generators/templates/endpoints.hbs +0 -1
- package/dist/acl.d.ts +0 -4
- package/dist/commands/check.command.d.ts +0 -2
- package/dist/commands/check.d.ts +0 -7
- package/dist/commands/generate.command.d.ts +0 -2
- package/dist/commands/generate.d.ts +0 -8
- package/dist/generator.d.ts +0 -3
- package/dist/generator.js +0 -78
- package/dist/generators/checkOpenAPIDoc.d.ts +0 -3
- package/dist/generators/const/acl.const.d.ts +0 -13
- package/dist/generators/const/buildConfigs.const.d.ts +0 -1
- package/dist/generators/const/deps.const.d.ts +0 -38
- package/dist/generators/const/endpoints.const.d.ts +0 -11
- package/dist/generators/const/js.const.d.ts +0 -1
- package/dist/generators/const/openapi.const.d.ts +0 -7
- package/dist/generators/const/options.const.d.ts +0 -2
- package/dist/generators/const/package.const.d.ts +0 -2
- package/dist/generators/const/queries.const.d.ts +0 -8
- package/dist/generators/const/validation.const.d.ts +0 -53
- package/dist/generators/const/zod.const.d.ts +0 -19
- package/dist/generators/core/SchemaResolver.class.d.ts +0 -71
- package/dist/generators/core/endpoints/getEndpointAcl.d.ts +0 -8
- package/dist/generators/core/endpoints/getEndpointBody.d.ts +0 -13
- package/dist/generators/core/endpoints/getEndpointParameter.d.ts +0 -11
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.d.ts +0 -3
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.test.d.ts +0 -1
- package/dist/generators/core/getDataFromOpenAPIDoc.d.ts +0 -8
- package/dist/generators/core/getMetadataFromOpenAPIDoc.d.ts +0 -4
- package/dist/generators/core/getMetadataFromOpenAPIDoc.test.d.ts +0 -1
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.d.ts +0 -2
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.test.d.ts +0 -1
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.d.ts +0 -6
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.test.d.ts +0 -1
- package/dist/generators/core/openapi/getSchemaRefObjs.d.ts +0 -4
- package/dist/generators/core/openapi/iterateSchema.d.ts +0 -22
- package/dist/generators/core/resolveConfig.d.ts +0 -7
- package/dist/generators/core/zod/ZodSchema.class.d.ts +0 -26
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaNames.d.ts +0 -2
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaTags.d.ts +0 -2
- package/dist/generators/core/zod/enumExtraction/updateExtractedEnumZodSchemaData.d.ts +0 -17
- package/dist/generators/core/zod/getZodChain.d.ts +0 -8
- package/dist/generators/core/zod/getZodSchema.d.ts +0 -17
- package/dist/generators/core/zod/getZodSchema.test.d.ts +0 -1
- package/dist/generators/core/zod/getZodSchemaRefs.d.ts +0 -6
- package/dist/generators/core/zod/getZodSchemasFromOpenAPIDoc.d.ts +0 -6
- package/dist/generators/core/zod/resolveZodSchemaName.d.ts +0 -10
- package/dist/generators/core/zod/sortZodSchemasByTopology.d.ts +0 -4
- package/dist/generators/generate/generateAcl.d.ts +0 -3
- package/dist/generators/generate/generateAclCheck.d.ts +0 -2
- package/dist/generators/generate/generateAppRestClient.d.ts +0 -2
- package/dist/generators/generate/generateConfigs.d.ts +0 -2
- package/dist/generators/generate/generateEndpoints.d.ts +0 -2
- package/dist/generators/generate/generateModels.d.ts +0 -2
- package/dist/generators/generate/generateQueries.d.ts +0 -2
- package/dist/generators/generate/generateQueryModules.d.ts +0 -2
- package/dist/generators/generate/generateZodExtended.d.ts +0 -2
- package/dist/generators/generateCodeFromOpenAPIDoc.d.ts +0 -4
- package/dist/generators/types/builder-config.d.ts +0 -48
- package/dist/generators/types/common.d.ts +0 -27
- package/dist/generators/types/config.d.ts +0 -2
- package/dist/generators/types/endpoint.d.ts +0 -50
- package/dist/generators/types/generate.d.ts +0 -39
- package/dist/generators/types/metadata.d.ts +0 -51
- package/dist/generators/types/openapi.d.ts +0 -22
- package/dist/generators/types/options.d.ts +0 -66
- package/dist/generators/types/validation.d.ts +0 -5
- package/dist/generators/utils/array.utils.d.ts +0 -1
- package/dist/generators/utils/endpoint.utils.d.ts +0 -12
- package/dist/generators/utils/endpoint.utils.test.d.ts +0 -1
- package/dist/generators/utils/file.utils.d.ts +0 -8
- package/dist/generators/utils/generate/generate.acl.utils.d.ts +0 -23
- package/dist/generators/utils/generate/generate.configs.utils.d.ts +0 -15
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +0 -39
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +0 -39
- package/dist/generators/utils/generate/generate.imports.utils.test.d.ts +0 -1
- package/dist/generators/utils/generate/generate.openapi.utils.d.ts +0 -2
- package/dist/generators/utils/generate/generate.query.utils.d.ts +0 -6
- package/dist/generators/utils/generate/generate.utils.d.ts +0 -18
- package/dist/generators/utils/generate/generate.zod.utils.d.ts +0 -13
- package/dist/generators/utils/generate-files.utils.d.ts +0 -6
- package/dist/generators/utils/hbs/hbs-template.utils.d.ts +0 -3
- package/dist/generators/utils/hbs/hbs.acl.utils.d.ts +0 -2
- package/dist/generators/utils/hbs/hbs.common.utils.d.ts +0 -1
- package/dist/generators/utils/hbs/hbs.endpoints.utils.d.ts +0 -2
- package/dist/generators/utils/hbs/hbs.imports.utils.d.ts +0 -1
- package/dist/generators/utils/hbs/hbs.partials.utils.d.ts +0 -2
- package/dist/generators/utils/hbs/hbs.query.utils.d.ts +0 -2
- package/dist/generators/utils/hbs/hbs.zod.utils.d.ts +0 -2
- package/dist/generators/utils/js.utils.d.ts +0 -2
- package/dist/generators/utils/js.utils.test.d.ts +0 -1
- package/dist/generators/utils/math.utils.d.ts +0 -1
- package/dist/generators/utils/namespace.utils.d.ts +0 -7
- package/dist/generators/utils/object.utils.d.ts +0 -13
- package/dist/generators/utils/object.utils.test.d.ts +0 -1
- package/dist/generators/utils/openapi-schema.utils.d.ts +0 -15
- package/dist/generators/utils/openapi.utils.d.ts +0 -23
- package/dist/generators/utils/openapi.utils.test.d.ts +0 -1
- package/dist/generators/utils/operation.utils.d.ts +0 -22
- package/dist/generators/utils/operation.utils.test.d.ts +0 -1
- package/dist/generators/utils/query.utils.d.ts +0 -7
- package/dist/generators/utils/sort.utils.d.ts +0 -7
- package/dist/generators/utils/string.utils.d.ts +0 -14
- package/dist/generators/utils/string.utils.test.d.ts +0 -1
- package/dist/generators/utils/tag.utils.d.ts +0 -7
- package/dist/generators/utils/ts.utils.d.ts +0 -16
- package/dist/generators/utils/validation.utils.d.ts +0 -17
- package/dist/generators/utils/zod-schema.utils.d.ts +0 -15
- package/dist/helpers/cli.helper.d.ts +0 -22
- package/dist/helpers/config.helper.d.ts +0 -3
- package/dist/helpers/version.helper.d.ts +0 -4
- package/dist/helpers/yargs.helper.d.ts +0 -10
- package/dist/index.d.ts +0 -15
- package/dist/lib/acl/AclGuard.d.ts +0 -8
- package/dist/lib/acl/AclGuard.mjs +0 -14
- package/dist/lib/acl/Can.d.ts +0 -9
- package/dist/lib/acl/Can.mjs +0 -11
- package/dist/lib/acl/ability.context.d.ts +0 -15
- package/dist/lib/acl/ability.context.mjs +0 -37
- package/dist/lib/acl/appAbility.types.d.ts +0 -3
- package/dist/lib/assets/locales/en/translation.json.mjs +0 -8
- package/dist/lib/assets/locales/sl/translation.json.mjs +0 -8
- package/dist/lib/auth/AuthGuard.d.ts +0 -6
- package/dist/lib/auth/AuthGuard.mjs +0 -26
- package/dist/lib/auth/auth.context.d.ts +0 -22
- package/dist/lib/auth/auth.context.mjs +0 -41
- package/dist/lib/config/i18n.d.ts +0 -32
- package/dist/lib/config/i18n.mjs +0 -31
- package/dist/lib/config/queryConfig.context.d.ts +0 -17
- package/dist/lib/config/queryConfig.context.mjs +0 -26
- package/dist/lib/config/router.context.d.ts +0 -9
- package/dist/lib/config/router.context.mjs +0 -20
- package/dist/lib/react-query.types.d.ts +0 -10
- package/dist/lib/rest/error-handling.d.ts +0 -30
- package/dist/lib/rest/error-handling.mjs +0 -132
- package/dist/lib/rest/rest-client.d.ts +0 -22
- package/dist/lib/rest/rest-client.mjs +0 -62
- package/dist/lib/rest/rest-client.types.d.ts +0 -23
- package/dist/lib/rest/rest-interceptor.d.ts +0 -8
- package/dist/lib/rest/rest-interceptor.mjs +0 -21
- package/dist/lib/rest/rest.utils.d.ts +0 -7
- package/dist/lib/rest/rest.utils.mjs +0 -51
- package/dist/sh.d.ts +0 -2
- package/dist/sh.js +0 -635
package/dist/sh.mjs
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { S as VALIDATION_ERROR_TYPE_TITLE, g as groupByType, h as GenerateType, i as getDataFromOpenAPIDoc, n as getOutputFileName, u as getTagFileName, x as Profiler } from "./generateCodeFromOpenAPIDoc-B5lnFNGB.mjs";
|
|
3
|
+
import { n as resolveConfig, t as runGenerate } from "./generate.runner-DNldmk0f.mjs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import yargs from "yargs";
|
|
6
|
+
import { hideBin } from "yargs/helpers";
|
|
7
|
+
import { styleText } from "node:util";
|
|
8
|
+
import fs, { existsSync, rmSync, writeFileSync } from "fs";
|
|
9
|
+
import "reflect-metadata";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
12
|
+
import { exec } from "child_process";
|
|
13
|
+
|
|
14
|
+
//#region \0rolldown/runtime.js
|
|
15
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/helpers/cli.helper.ts
|
|
19
|
+
function log(message) {
|
|
20
|
+
console.log(message);
|
|
21
|
+
}
|
|
22
|
+
function logInfo(message) {
|
|
23
|
+
console.log(`[INFO] ${message}`);
|
|
24
|
+
}
|
|
25
|
+
function logSuccess(message) {
|
|
26
|
+
console.log(styleText("green", `[SUCCESS] ${message}`));
|
|
27
|
+
}
|
|
28
|
+
function logError(error, message) {
|
|
29
|
+
if (error instanceof Error) console.log(styleText("red", `[ERROR] ${message || error.message}`));
|
|
30
|
+
else console.log(styleText("red", `[ERROR] ${error}`));
|
|
31
|
+
}
|
|
32
|
+
function logBanner(message) {
|
|
33
|
+
console.log(styleText("bgYellow", `==== ${message} ====`));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/helpers/version.helper.ts
|
|
38
|
+
/**
|
|
39
|
+
* Fetch the version from package.json
|
|
40
|
+
*/
|
|
41
|
+
function getVersion() {
|
|
42
|
+
return "2.0.8-rc.7";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/helpers/yargs.helper.ts
|
|
47
|
+
const optionsKey = Symbol("options_key");
|
|
48
|
+
function YargOption(properties) {
|
|
49
|
+
return (target, propertyKey) => {
|
|
50
|
+
if (properties !== void 0 && properties !== null) {
|
|
51
|
+
const newMetadata = {
|
|
52
|
+
...Reflect.getMetadata(optionsKey, target),
|
|
53
|
+
[propertyKey]: {
|
|
54
|
+
...properties,
|
|
55
|
+
describe: properties.envAlias ? `${properties.describe || ""} [${properties.envAlias}]` : properties.describe,
|
|
56
|
+
type: properties.type || Reflect.getMetadata("design:type", target, propertyKey)?.name?.toLowerCase()
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
Reflect.defineMetadata(optionsKey, newMetadata, target);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function getYargsOption(target) {
|
|
64
|
+
const options = Reflect.getMetadata(optionsKey, target.prototype);
|
|
65
|
+
if (!options) throw new Error(`Options for ${target.name} were not defined`);
|
|
66
|
+
return options;
|
|
67
|
+
}
|
|
68
|
+
function getBuilder(options) {
|
|
69
|
+
return async (y) => {
|
|
70
|
+
return y.options(getYargsOptions(options)).middleware(async (_argv) => {
|
|
71
|
+
return await loadYargsConfig(options, _argv);
|
|
72
|
+
}, true);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function getYargsOptions(target) {
|
|
76
|
+
return Object.entries(getYargsOption(target)).reduce((a, [property, options]) => {
|
|
77
|
+
a[property] = Object.fromEntries(Object.entries(options).filter(([optionName]) => !["envAlias", "default"].includes(optionName)));
|
|
78
|
+
return a;
|
|
79
|
+
}, {});
|
|
80
|
+
}
|
|
81
|
+
async function loadYargsConfig(cls, _argv) {
|
|
82
|
+
const argv = new cls();
|
|
83
|
+
for (const [name, o] of Object.entries(getYargsOption(cls))) argv[name] = _argv[name] ?? o.default;
|
|
84
|
+
return argv;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/generators/checkOpenAPIDoc.ts
|
|
89
|
+
function checkOpenAPIDoc(openApiDoc, options) {
|
|
90
|
+
const { resolver, data } = getDataFromOpenAPIDoc(openApiDoc, options);
|
|
91
|
+
if (resolver.validationErrors.length > 0) {
|
|
92
|
+
const groupedErrors = groupByType(resolver.validationErrors);
|
|
93
|
+
Object.entries(groupedErrors).forEach(([type, errorMessages]) => {
|
|
94
|
+
log(`${styleText("red", `${VALIDATION_ERROR_TYPE_TITLE[type]}:`)}\n${errorMessages.map((message) => `- ${message}`).join("\n")}\n`);
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
const outputs = [...data.keys()].reduce((acc, tag) => [...acc, ...getOutputFileNames(tag, options)], []);
|
|
98
|
+
log(`${styleText("green", "Outputs:")}\n${outputs.map((output) => `- ${output}`).join("\n")}\n`);
|
|
99
|
+
}
|
|
100
|
+
return resolver.validationErrors;
|
|
101
|
+
}
|
|
102
|
+
function getOutputFileNames(tag, options) {
|
|
103
|
+
return [
|
|
104
|
+
GenerateType.Models,
|
|
105
|
+
GenerateType.Endpoints,
|
|
106
|
+
GenerateType.Queries
|
|
107
|
+
].map((type) => getOutputFileName({
|
|
108
|
+
output: options.output,
|
|
109
|
+
fileName: getTagFileName({
|
|
110
|
+
tag,
|
|
111
|
+
type,
|
|
112
|
+
options
|
|
113
|
+
})
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/helpers/config.helper.ts
|
|
119
|
+
const CONFIG_FILE_NAMES = ["openapi-codegen.config.mjs", "openapi-codegen.config.ts"];
|
|
120
|
+
async function loadConfig(configPath) {
|
|
121
|
+
try {
|
|
122
|
+
if (configPath) return await loadConfigFromPath(configPath);
|
|
123
|
+
for (const fileName of CONFIG_FILE_NAMES) {
|
|
124
|
+
const filePath = path.resolve(process.cwd(), fileName);
|
|
125
|
+
if (fs.existsSync(filePath)) return await loadConfigFromPath(filePath);
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
logError(`Failed to load configuration: ${error instanceof Error ? error.message : error}`);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async function loadConfigFromPath(filePath) {
|
|
134
|
+
const absolutePath = path.resolve(process.cwd(), filePath);
|
|
135
|
+
if (!fs.existsSync(absolutePath)) throw new Error(`Configuration file not found: ${filePath}`);
|
|
136
|
+
const ext = path.extname(absolutePath).toLowerCase();
|
|
137
|
+
if (ext === ".mjs") return loadMjsConfig(absolutePath);
|
|
138
|
+
if (ext !== ".ts") throw new Error(`Only ESM (.mjs) and TypeScript (.ts) configuration files are supported. Found: ${ext}`);
|
|
139
|
+
return loadTsConfig(absolutePath);
|
|
140
|
+
}
|
|
141
|
+
async function loadMjsConfig(filePath) {
|
|
142
|
+
const imported = await import(`${pathToFileURL(filePath).href}?t=${Date.now()}`);
|
|
143
|
+
if (!imported.default) throw new Error(`ESM config must have a default export: ${filePath}`);
|
|
144
|
+
return imported.default;
|
|
145
|
+
}
|
|
146
|
+
let importFresh;
|
|
147
|
+
const loadJsSync = function loadJsSync(filepath) {
|
|
148
|
+
if (importFresh === void 0) importFresh = __require("import-fresh");
|
|
149
|
+
return importFresh(filepath);
|
|
150
|
+
};
|
|
151
|
+
let typescript;
|
|
152
|
+
async function loadTsConfig(filePath) {
|
|
153
|
+
if (typescript === void 0) typescript = __require("typescript");
|
|
154
|
+
const transpiledFilepath = `${filePath.slice(0, -2)}cjs`;
|
|
155
|
+
try {
|
|
156
|
+
const tsConfig = resolveTsConfig(path.dirname(filePath)) ?? {};
|
|
157
|
+
tsConfig.compilerOptions = Object.assign({}, tsConfig.compilerOptions, {
|
|
158
|
+
module: typescript.ModuleKind.NodeNext,
|
|
159
|
+
moduleResolution: typescript.ModuleResolutionKind.NodeNext,
|
|
160
|
+
target: typescript.ScriptTarget.ES2022,
|
|
161
|
+
noEmit: false
|
|
162
|
+
});
|
|
163
|
+
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
164
|
+
const transpiledFileContent = typescript.transpileModule(fileContent, tsConfig).outputText;
|
|
165
|
+
writeFileSync(transpiledFilepath, transpiledFileContent);
|
|
166
|
+
return loadJsSync(transpiledFilepath).default;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
error.message = `TypeScript Error in ${filePath}:\n${error.message}`;
|
|
169
|
+
throw error;
|
|
170
|
+
} finally {
|
|
171
|
+
if (existsSync(transpiledFilepath)) rmSync(transpiledFilepath);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function resolveTsConfig(directory) {
|
|
175
|
+
const filePath = typescript.findConfigFile(directory, (fileName) => {
|
|
176
|
+
return typescript.sys.fileExists(fileName);
|
|
177
|
+
});
|
|
178
|
+
if (filePath === void 0) return;
|
|
179
|
+
const { config, error } = typescript.readConfigFile(filePath, (path) => typescript.sys.readFile(path));
|
|
180
|
+
if (error) throw new Error(`Error in ${filePath}: ${error.messageText.toString()}`);
|
|
181
|
+
return config;
|
|
182
|
+
}
|
|
183
|
+
function pathToFileURL(filePath) {
|
|
184
|
+
const normalizedPath = path.resolve(filePath).replace(/\\/g, "/");
|
|
185
|
+
return { href: normalizedPath.startsWith("/") ? `file://${normalizedPath}` : `file:///${normalizedPath}` };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/commands/check.ts
|
|
190
|
+
async function check({ verbose, config: configParam, excludeTags: _excludeTagsParam, ...params }) {
|
|
191
|
+
const start = Date.now();
|
|
192
|
+
if (verbose) logInfo("Resolving config...");
|
|
193
|
+
const config = resolveConfig({
|
|
194
|
+
fileConfig: await loadConfig(configParam),
|
|
195
|
+
params
|
|
196
|
+
});
|
|
197
|
+
if (verbose) logInfo("Parsing OpenAPI spec...");
|
|
198
|
+
const openApiDoc = await SwaggerParser.bundle(config.input);
|
|
199
|
+
if (verbose) logInfo("Running check...");
|
|
200
|
+
const errorMessages = checkOpenAPIDoc(openApiDoc, config);
|
|
201
|
+
if (errorMessages.length === 0) logSuccess(`Time: ${Date.now() - start}ms`);
|
|
202
|
+
else throw new Error(`Found ${errorMessages.length} issues. Time: ${Date.now() - start}ms`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region \0@oxc-project+runtime@0.114.0/helpers/decorateMetadata.js
|
|
207
|
+
function __decorateMetadata(k, v) {
|
|
208
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region \0@oxc-project+runtime@0.114.0/helpers/decorate.js
|
|
213
|
+
function __decorate(decorators, target, key, desc) {
|
|
214
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
215
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
216
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
217
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/commands/check.command.ts
|
|
222
|
+
var CheckOptions = class {
|
|
223
|
+
config;
|
|
224
|
+
input;
|
|
225
|
+
splitByTags;
|
|
226
|
+
defaultTag;
|
|
227
|
+
excludeTags;
|
|
228
|
+
excludePathRegex;
|
|
229
|
+
excludeRedundantZodSchemas;
|
|
230
|
+
verbose;
|
|
231
|
+
};
|
|
232
|
+
__decorate([YargOption({ envAlias: "config" }), __decorateMetadata("design:type", String)], CheckOptions.prototype, "config", void 0);
|
|
233
|
+
__decorate([YargOption({ envAlias: "input" }), __decorateMetadata("design:type", String)], CheckOptions.prototype, "input", void 0);
|
|
234
|
+
__decorate([YargOption({
|
|
235
|
+
envAlias: "splitByTags",
|
|
236
|
+
type: "boolean"
|
|
237
|
+
}), __decorateMetadata("design:type", Boolean)], CheckOptions.prototype, "splitByTags", void 0);
|
|
238
|
+
__decorate([YargOption({ envAlias: "defaultTag" }), __decorateMetadata("design:type", String)], CheckOptions.prototype, "defaultTag", void 0);
|
|
239
|
+
__decorate([YargOption({ envAlias: "excludeTags" }), __decorateMetadata("design:type", String)], CheckOptions.prototype, "excludeTags", void 0);
|
|
240
|
+
__decorate([YargOption({ envAlias: "excludePathRegex" }), __decorateMetadata("design:type", String)], CheckOptions.prototype, "excludePathRegex", void 0);
|
|
241
|
+
__decorate([YargOption({
|
|
242
|
+
envAlias: "excludeRedundantZodSchemas",
|
|
243
|
+
type: "boolean"
|
|
244
|
+
}), __decorateMetadata("design:type", Boolean)], CheckOptions.prototype, "excludeRedundantZodSchemas", void 0);
|
|
245
|
+
__decorate([YargOption({
|
|
246
|
+
envAlias: "verbose",
|
|
247
|
+
default: false,
|
|
248
|
+
type: "boolean"
|
|
249
|
+
}), __decorateMetadata("design:type", Boolean)], CheckOptions.prototype, "verbose", void 0);
|
|
250
|
+
const command$1 = {
|
|
251
|
+
command: "check",
|
|
252
|
+
describe: "Check OpenAPI spec",
|
|
253
|
+
builder: getBuilder(CheckOptions),
|
|
254
|
+
handler: async (_argv) => {
|
|
255
|
+
const argv = await _argv;
|
|
256
|
+
if (argv.verbose) logBanner(`OpenAPI CodeGen ${getVersion()}`);
|
|
257
|
+
return check(argv);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/commands/generate.ts
|
|
263
|
+
async function generate({ prettier, verbose, config: configParam, ...params }) {
|
|
264
|
+
const start = Date.now();
|
|
265
|
+
const profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1");
|
|
266
|
+
const fileConfig = await profiler.runAsync("config.load", async () => await loadConfig(configParam));
|
|
267
|
+
if (verbose) logInfo("Generating code...");
|
|
268
|
+
const result = await runGenerate({
|
|
269
|
+
fileConfig,
|
|
270
|
+
params,
|
|
271
|
+
profiler
|
|
272
|
+
});
|
|
273
|
+
const config = result.config;
|
|
274
|
+
if (result.skipped && verbose) logInfo("OpenAPI and config unchanged. Skipping generation.");
|
|
275
|
+
if (verbose) {
|
|
276
|
+
logSuccess(`Time: ${Date.now() - start}ms`);
|
|
277
|
+
if (profiler.enabled) {
|
|
278
|
+
logInfo("Profile breakdown:");
|
|
279
|
+
profiler.formatLines().forEach((line) => logInfo(` ${line}`));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (prettier) execPrettier({
|
|
283
|
+
output: config.output,
|
|
284
|
+
verbose
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function execPrettier({ output, verbose }) {
|
|
288
|
+
if (verbose) logInfo("Running Prettier...");
|
|
289
|
+
exec(`prettier --write ${output} `, (error) => {
|
|
290
|
+
if (verbose) if (error) logError(error, "Prettier error");
|
|
291
|
+
else logSuccess("Prettier finished.");
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/commands/generate.command.ts
|
|
297
|
+
var GenerateOptions = class {
|
|
298
|
+
config;
|
|
299
|
+
input;
|
|
300
|
+
output;
|
|
301
|
+
incremental;
|
|
302
|
+
tsNamespaces;
|
|
303
|
+
tsPath;
|
|
304
|
+
splitByTags;
|
|
305
|
+
defaultTag;
|
|
306
|
+
excludeTags;
|
|
307
|
+
excludePathRegex;
|
|
308
|
+
excludeRedundantZodSchemas;
|
|
309
|
+
importPath;
|
|
310
|
+
extractEnums;
|
|
311
|
+
modelsInCommon;
|
|
312
|
+
removeOperationPrefixEndingWith;
|
|
313
|
+
acl;
|
|
314
|
+
checkAcl;
|
|
315
|
+
baseUrl;
|
|
316
|
+
replaceOptionalWithNullish;
|
|
317
|
+
infiniteQueries;
|
|
318
|
+
mutationEffects;
|
|
319
|
+
workspaceContext;
|
|
320
|
+
parseRequestParams;
|
|
321
|
+
inlineEndpoints;
|
|
322
|
+
inlineEndpointsExcludeModules;
|
|
323
|
+
modelsOnly;
|
|
324
|
+
axiosRequestConfig;
|
|
325
|
+
builderConfigs;
|
|
326
|
+
format;
|
|
327
|
+
verbose;
|
|
328
|
+
};
|
|
329
|
+
__decorate([YargOption({ envAlias: "config" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "config", void 0);
|
|
330
|
+
__decorate([YargOption({ envAlias: "input" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "input", void 0);
|
|
331
|
+
__decorate([YargOption({ envAlias: "output" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "output", void 0);
|
|
332
|
+
__decorate([YargOption({
|
|
333
|
+
envAlias: "incremental",
|
|
334
|
+
type: "boolean"
|
|
335
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "incremental", void 0);
|
|
336
|
+
__decorate([YargOption({
|
|
337
|
+
envAlias: "tsNamespaces",
|
|
338
|
+
type: "boolean"
|
|
339
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "tsNamespaces", void 0);
|
|
340
|
+
__decorate([YargOption({ envAlias: "tsPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "tsPath", void 0);
|
|
341
|
+
__decorate([YargOption({
|
|
342
|
+
envAlias: "splitByTags",
|
|
343
|
+
type: "boolean"
|
|
344
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "splitByTags", void 0);
|
|
345
|
+
__decorate([YargOption({ envAlias: "defaultTag" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "defaultTag", void 0);
|
|
346
|
+
__decorate([YargOption({ envAlias: "excludeTags" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "excludeTags", void 0);
|
|
347
|
+
__decorate([YargOption({ envAlias: "excludePathRegex" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "excludePathRegex", void 0);
|
|
348
|
+
__decorate([YargOption({
|
|
349
|
+
envAlias: "excludeRedundantZodSchemas",
|
|
350
|
+
type: "boolean"
|
|
351
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "excludeRedundantZodSchemas", void 0);
|
|
352
|
+
__decorate([YargOption({ envAlias: "importPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "importPath", void 0);
|
|
353
|
+
__decorate([YargOption({
|
|
354
|
+
envAlias: "extractEnums",
|
|
355
|
+
type: "boolean"
|
|
356
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "extractEnums", void 0);
|
|
357
|
+
__decorate([YargOption({
|
|
358
|
+
envAlias: "modelsInCommon",
|
|
359
|
+
type: "boolean"
|
|
360
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "modelsInCommon", void 0);
|
|
361
|
+
__decorate([YargOption({ envAlias: "removeOperationPrefixEndingWith" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "removeOperationPrefixEndingWith", void 0);
|
|
362
|
+
__decorate([YargOption({
|
|
363
|
+
envAlias: "acl",
|
|
364
|
+
type: "boolean"
|
|
365
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "acl", void 0);
|
|
366
|
+
__decorate([YargOption({
|
|
367
|
+
envAlias: "checkAcl",
|
|
368
|
+
type: "boolean"
|
|
369
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "checkAcl", void 0);
|
|
370
|
+
__decorate([YargOption({ envAlias: "baseUrl" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "baseUrl", void 0);
|
|
371
|
+
__decorate([YargOption({
|
|
372
|
+
envAlias: "replaceOptionalWithNullish",
|
|
373
|
+
type: "boolean"
|
|
374
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "replaceOptionalWithNullish", void 0);
|
|
375
|
+
__decorate([YargOption({
|
|
376
|
+
envAlias: "infiniteQueries",
|
|
377
|
+
type: "boolean"
|
|
378
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "infiniteQueries", void 0);
|
|
379
|
+
__decorate([YargOption({
|
|
380
|
+
envAlias: "mutationEffects",
|
|
381
|
+
type: "boolean"
|
|
382
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "mutationEffects", void 0);
|
|
383
|
+
__decorate([YargOption({
|
|
384
|
+
envAlias: "workspaceContext",
|
|
385
|
+
type: "boolean"
|
|
386
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "workspaceContext", void 0);
|
|
387
|
+
__decorate([YargOption({
|
|
388
|
+
envAlias: "parseRequestParams",
|
|
389
|
+
type: "boolean"
|
|
390
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "parseRequestParams", void 0);
|
|
391
|
+
__decorate([YargOption({
|
|
392
|
+
envAlias: "inlineEndpoints",
|
|
393
|
+
type: "boolean"
|
|
394
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "inlineEndpoints", void 0);
|
|
395
|
+
__decorate([YargOption({ envAlias: "inlineEndpointsExcludeModules" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "inlineEndpointsExcludeModules", void 0);
|
|
396
|
+
__decorate([YargOption({
|
|
397
|
+
envAlias: "modelsOnly",
|
|
398
|
+
type: "boolean"
|
|
399
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "modelsOnly", void 0);
|
|
400
|
+
__decorate([YargOption({
|
|
401
|
+
envAlias: "axiosRequestConfig",
|
|
402
|
+
type: "boolean"
|
|
403
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "axiosRequestConfig", void 0);
|
|
404
|
+
__decorate([YargOption({
|
|
405
|
+
envAlias: "builderConfigs",
|
|
406
|
+
type: "boolean"
|
|
407
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "builderConfigs", void 0);
|
|
408
|
+
__decorate([YargOption({
|
|
409
|
+
envAlias: "format",
|
|
410
|
+
default: true,
|
|
411
|
+
type: "boolean"
|
|
412
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "format", void 0);
|
|
413
|
+
__decorate([YargOption({
|
|
414
|
+
envAlias: "verbose",
|
|
415
|
+
default: false,
|
|
416
|
+
type: "boolean"
|
|
417
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "verbose", void 0);
|
|
418
|
+
const command = {
|
|
419
|
+
command: "generate",
|
|
420
|
+
describe: "Generate code from OpenAPI spec",
|
|
421
|
+
builder: getBuilder(GenerateOptions),
|
|
422
|
+
handler: async (_argv) => {
|
|
423
|
+
const argv = await _argv;
|
|
424
|
+
if (argv.verbose) logBanner(`OpenAPI CodeGen ${getVersion()}`);
|
|
425
|
+
return generate(argv);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/sh.ts
|
|
431
|
+
yargs(hideBin(process.argv)).version(getVersion() || "unknown").scriptName("openapi-codegen").command(command).command(command$1).help().demandCommand(1).strictCommands(true).showHelpOnFail(true).fail((msg, err) => {
|
|
432
|
+
if (msg) logError(msg);
|
|
433
|
+
if (err) logError(err);
|
|
434
|
+
logInfo("Use '--help' for more info");
|
|
435
|
+
process.exit(1);
|
|
436
|
+
}).parse();
|
|
437
|
+
|
|
438
|
+
//#endregion
|
|
439
|
+
export { };
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./options-DBz5YE3s.mjs";
|
|
2
|
+
import { t as OpenAPICodegenConfig } from "./config-Cu_GYfai.mjs";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
|
|
5
|
+
//#region src/vite/openapi-codegen.plugin.d.ts
|
|
6
|
+
declare function openApiCodegen(config: OpenAPICodegenConfig): Plugin;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type OpenAPICodegenConfig, openApiCodegen };
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { x as Profiler } from "./generateCodeFromOpenAPIDoc-B5lnFNGB.mjs";
|
|
2
|
+
import { t as runGenerate } from "./generate.runner-DNldmk0f.mjs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
//#region src/vite/openapi-codegen.plugin.ts
|
|
6
|
+
function openApiCodegen(config) {
|
|
7
|
+
let resolvedViteConfig;
|
|
8
|
+
let queue = Promise.resolve();
|
|
9
|
+
const isLocalInput = typeof config.input === "string" && !/^https?:\/\//i.test(config.input);
|
|
10
|
+
const normalizedConfig = { ...config };
|
|
11
|
+
const enqueueGenerate = () => {
|
|
12
|
+
queue = queue.then(async () => {
|
|
13
|
+
const currentConfig = resolvedViteConfig;
|
|
14
|
+
if (!currentConfig) return;
|
|
15
|
+
await runGenerate({
|
|
16
|
+
fileConfig: normalizePaths(normalizedConfig, currentConfig.root),
|
|
17
|
+
profiler: new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1")
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const setupWatcher = (server) => {
|
|
22
|
+
if (!isLocalInput || !config.input) return;
|
|
23
|
+
const openApiPath = path.resolve(server.config.root, config.input);
|
|
24
|
+
server.watcher.add(openApiPath);
|
|
25
|
+
server.watcher.on("change", (changedPath) => {
|
|
26
|
+
if (path.resolve(changedPath) === openApiPath) enqueueGenerate();
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
name: "openapi-codegen",
|
|
31
|
+
configResolved(config) {
|
|
32
|
+
resolvedViteConfig = config;
|
|
33
|
+
},
|
|
34
|
+
buildStart() {
|
|
35
|
+
enqueueGenerate();
|
|
36
|
+
},
|
|
37
|
+
configureServer(server) {
|
|
38
|
+
setupWatcher(server);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function normalizePaths(config, root) {
|
|
43
|
+
const normalized = { ...config };
|
|
44
|
+
if (typeof normalized.output === "string" && !path.isAbsolute(normalized.output)) normalized.output = path.resolve(root, normalized.output);
|
|
45
|
+
if (typeof normalized.input === "string" && !path.isAbsolute(normalized.input) && !/^https?:\/\//i.test(normalized.input)) normalized.input = path.resolve(root, normalized.input);
|
|
46
|
+
return normalized;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { openApiCodegen };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@povio/openapi-codegen-cli",
|
|
3
|
-
"version": "2.0.8-rc.
|
|
3
|
+
"version": "2.0.8-rc.7",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"codegen",
|
|
6
6
|
"openapi",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"url": "git+https://github.com/povio/openapi-codegen-cli.git"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"openapi-codegen": "./dist/sh.
|
|
19
|
+
"openapi-codegen": "./dist/sh.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"README.md",
|
|
@@ -24,85 +24,88 @@
|
|
|
24
24
|
"src/assets/**",
|
|
25
25
|
"src/generators/templates/**"
|
|
26
26
|
],
|
|
27
|
+
"type": "module",
|
|
27
28
|
"main": "./dist/index.mjs",
|
|
28
|
-
"types": "./dist/index.d.
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
29
30
|
"exports": {
|
|
30
31
|
".": {
|
|
31
|
-
"types": "./dist/index.d.
|
|
32
|
-
"import": "./dist/index.mjs"
|
|
33
|
-
|
|
32
|
+
"types": "./dist/index.d.mts",
|
|
33
|
+
"import": "./dist/index.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./vite": {
|
|
36
|
+
"types": "./dist/vite.d.mts",
|
|
37
|
+
"import": "./dist/vite.mjs"
|
|
34
38
|
},
|
|
35
39
|
"./generator": {
|
|
36
|
-
"types": "./dist/generator.d.
|
|
37
|
-
"import": "./dist/generator.
|
|
38
|
-
"require": "./dist/generator.js"
|
|
40
|
+
"types": "./dist/generator.d.mts",
|
|
41
|
+
"import": "./dist/generator.mjs"
|
|
39
42
|
},
|
|
40
43
|
"./acl": {
|
|
41
|
-
"types": "./dist/acl.d.
|
|
42
|
-
"import": "./dist/acl.mjs"
|
|
43
|
-
"require": "./dist/acl.mjs"
|
|
44
|
+
"types": "./dist/acl.d.mts",
|
|
45
|
+
"import": "./dist/acl.mjs"
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
48
|
"scripts": {
|
|
47
49
|
"start": "node --import tsx ./src/sh.ts",
|
|
48
50
|
"test": "vitest run",
|
|
49
51
|
"test:watch": "vitest",
|
|
50
|
-
"build
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
52
|
+
"build": "tsdown",
|
|
53
|
+
"start:dist": "node ./dist/sh.mjs",
|
|
54
|
+
"gen:base": "rm -rf ./test/generated/base && mkdir -p ./test/generated/base && pnpm start generate --config ./test/config.mjs --output ./test/generated/base --no-prettier",
|
|
55
|
+
"gen:next": "rm -rf ./test/generated/next && mkdir -p ./test/generated/next && pnpm start generate --config ./test/config.mjs --output ./test/generated/next --no-prettier",
|
|
56
|
+
"test:generated-eq": "vitest run ./src/generators/generated-output-eq.test.ts",
|
|
57
|
+
"gen:verify": "pnpm gen:base && pnpm gen:next && pnpm test:generated-eq",
|
|
55
58
|
"typecheck": "tsc --noEmit",
|
|
56
59
|
"lint": "oxlint --type-aware --fix",
|
|
57
60
|
"lint:check": "oxlint --type-aware",
|
|
58
61
|
"format": "oxfmt",
|
|
59
62
|
"format:check": "oxfmt --check",
|
|
60
|
-
"check": "
|
|
61
|
-
"push": "
|
|
62
|
-
"dev:generate": "rm -rf ./output &&
|
|
63
|
-
"dev:check": "
|
|
63
|
+
"check": "pnpm typecheck && pnpm lint && pnpm test",
|
|
64
|
+
"push": "node ./scripts/publish.mjs",
|
|
65
|
+
"dev:generate": "rm -rf ./output && pnpm start generate --config ./test/config.mjs",
|
|
66
|
+
"dev:check": "pnpm start check --config ./test/config.mjs",
|
|
67
|
+
"snapshot:openapi-localhost": "node ./scripts/snapshot-openapi-localhost.mjs",
|
|
68
|
+
"bench:vite-codegen": "node ./scripts/benchmark-vite-codegen.mjs"
|
|
64
69
|
},
|
|
65
70
|
"dependencies": {
|
|
66
|
-
"
|
|
67
|
-
"
|
|
71
|
+
"@apidevtools/swagger-parser": "^10.1.0",
|
|
72
|
+
"handlebars": "^4.7.8",
|
|
73
|
+
"i18next": "^25.8.13",
|
|
74
|
+
"import-fresh": "^3.3.1",
|
|
75
|
+
"prompt-sync": "^4.2.0",
|
|
76
|
+
"reflect-metadata": "^0.2.2",
|
|
77
|
+
"ts-pattern": "^5.9.0",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"yargs": "^18.0.0"
|
|
68
80
|
},
|
|
69
81
|
"devDependencies": {
|
|
70
|
-
"@apidevtools/swagger-parser": "^10.1.0",
|
|
71
82
|
"@casl/ability": "^6.8.0",
|
|
72
83
|
"@casl/react": "^5.0.1",
|
|
73
84
|
"@tanstack/react-query": "~5.90.21",
|
|
74
|
-
"@types/node": "^
|
|
85
|
+
"@types/node": "^25.3.0",
|
|
75
86
|
"@types/prompt-sync": "^4.2.3",
|
|
76
87
|
"@types/react": "^19.2.14",
|
|
77
88
|
"@types/yargs": "^17.0.35",
|
|
78
89
|
"@vitejs/plugin-react": "^5.1.4",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"openapi-types": "^12.1.3",
|
|
83
|
-
"oxfmt": "^0.33.0",
|
|
84
|
-
"oxlint": "^1.48.0",
|
|
85
|
-
"oxlint-tsgolint": "^0.14.0",
|
|
86
|
-
"prompt-sync": "^4.2.0",
|
|
90
|
+
"oxfmt": "^0.34.0",
|
|
91
|
+
"oxlint": "^1.50.0",
|
|
92
|
+
"oxlint-tsgolint": "^0.15.0",
|
|
87
93
|
"react": "^19.2.4",
|
|
88
|
-
"
|
|
89
|
-
"ts-node": "^10.9.2",
|
|
90
|
-
"ts-pattern": "^5.9.0",
|
|
94
|
+
"tsdown": "^0.21.0-beta.1",
|
|
91
95
|
"tsx": "^4.21.0",
|
|
92
|
-
"type-fest": "^4.
|
|
93
|
-
"
|
|
94
|
-
"vite": "^7.3.1",
|
|
96
|
+
"type-fest": "^5.4.4",
|
|
97
|
+
"vite": "npm:rolldown-vite@^7.3.1",
|
|
95
98
|
"vite-plugin-dts": "^4.5.4",
|
|
96
|
-
"vitest": "
|
|
97
|
-
"yargs": "^17.7.2",
|
|
98
|
-
"zod": "^4.3.6"
|
|
99
|
+
"vitest": "4.0.18"
|
|
99
100
|
},
|
|
100
101
|
"peerDependencies": {
|
|
101
102
|
"@casl/ability": "^6.7.3",
|
|
102
103
|
"@casl/react": "^5.0.0",
|
|
103
104
|
"@tanstack/react-query": "^5.90.21",
|
|
104
105
|
"axios": "^1.13.1",
|
|
106
|
+
"openapi-types": "^12.1.3",
|
|
105
107
|
"react": "^19.1.0",
|
|
108
|
+
"vite": "^6.0.0 || ^7.0.0",
|
|
106
109
|
"zod": "^4.1.12"
|
|
107
110
|
},
|
|
108
111
|
"peerDependenciesMeta": {
|
|
@@ -111,12 +114,14 @@
|
|
|
111
114
|
},
|
|
112
115
|
"@casl/react": {
|
|
113
116
|
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"vite": {
|
|
119
|
+
"optional": true
|
|
114
120
|
}
|
|
115
121
|
},
|
|
116
122
|
"engines": {
|
|
117
123
|
"node": ">= 14",
|
|
118
|
-
"
|
|
119
|
-
"yarn": ">= 3.2"
|
|
124
|
+
"pnpm": ">= 9"
|
|
120
125
|
},
|
|
121
|
-
"packageManager": "
|
|
126
|
+
"packageManager": "pnpm@10.4.0"
|
|
122
127
|
}
|
|
@@ -27,7 +27,12 @@ export function useMutationEffects({ currentModule }: UseMutationEffectsProps) {
|
|
|
27
27
|
}, [queryClient, config.crossTabInvalidation]);
|
|
28
28
|
|
|
29
29
|
const runMutationEffects = useCallback(
|
|
30
|
-
async <TData, TVariables>(
|
|
30
|
+
async <TData, TVariables>(
|
|
31
|
+
data: TData,
|
|
32
|
+
variables: TVariables,
|
|
33
|
+
options: MutationEffectsOptions = {},
|
|
34
|
+
updateKeys?: QueryKey[],
|
|
35
|
+
) => {
|
|
31
36
|
const { invalidateCurrentModule, invalidateModules, invalidateKeys, preferUpdate } = options;
|
|
32
37
|
const shouldUpdate = preferUpdate ?? config.preferUpdate ?? false;
|
|
33
38
|
const shouldInvalidateCurrentModule = invalidateCurrentModule ?? config.invalidateCurrentModule ?? true;
|