@povio/openapi-codegen-cli 2.0.8-rc.35 → 2.0.8-rc.37
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 +17 -0
- package/dist/{config-DqD9ExKp.d.mts → config-DTx4Ck6g.d.mts} +1 -1
- package/dist/{generate.runner-QejaDLjW.mjs → generate.runner-DLLGYMVB.mjs} +1 -1
- package/dist/{generateCodeFromOpenAPIDoc-C2niF2V7.mjs → generateCodeFromOpenAPIDoc-CFbiHxB7.mjs} +59 -13
- package/dist/generator.d.mts +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +2 -1
- package/dist/{options-D3n-bZbj.d.mts → options-fyt0BYYE.d.mts} +1 -0
- package/dist/sh.mjs +8 -3
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ yarn openapi-codegen generate --config my-config.ts
|
|
|
92
92
|
--axiosRequestConfig Include Axios request config parameters in query hooks (default: false)
|
|
93
93
|
--infiniteQueries Generate infinite queries for paginated API endpoints (default: false)
|
|
94
94
|
--mutationEffects Add mutation effects options to mutation hooks (default: true)
|
|
95
|
+
--mutationDefaultOnError Use OpenApiQueryConfig.onError as the default onError for mutation hooks (default: false)
|
|
95
96
|
--workspaceContext Comma-separated list of path/ACL params that generated hooks may resolve from OpenApiWorkspaceContext
|
|
96
97
|
--inlineEndpoints Inline endpoint implementations into generated query files (default: false)
|
|
97
98
|
--inlineEndpointsExcludeModules Comma-separated modules/tags to keep as separate API files while inlineEndpoints=true
|
|
@@ -194,6 +195,22 @@ const config: OpenAPICodegenConfig = {
|
|
|
194
195
|
export default config;
|
|
195
196
|
```
|
|
196
197
|
|
|
198
|
+
### Default mutation errors
|
|
199
|
+
|
|
200
|
+
Set `mutationDefaultOnError: true` in codegen config (or pass `--mutationDefaultOnError`) to let generated mutation hooks fall back to `OpenApiQueryConfig.Provider` when a mutation call does not define its own `onError`.
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { ErrorHandler, OpenApiQueryConfig } from "@povio/openapi-codegen-cli";
|
|
204
|
+
|
|
205
|
+
<OpenApiQueryConfig.Provider
|
|
206
|
+
onError={(error) => {
|
|
207
|
+
errorToast({ text: ErrorHandler.getErrorMessage(error) });
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
<App />
|
|
211
|
+
</OpenApiQueryConfig.Provider>;
|
|
212
|
+
```
|
|
213
|
+
|
|
197
214
|
### OpenApiWorkspaceContext (Path + ACL defaults)
|
|
198
215
|
|
|
199
216
|
Set `workspaceContext` to a list of param names in codegen config (or pass `--workspaceContext officeId,projectId`) and wrap your app subtree with `OpenApiWorkspaceContext.Provider` if generated hooks frequently repeat workspace-scoped params.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Profiler, i as writeGenerateFileData, m as DEFAULT_GENERATE_OPTIONS, o as deepMerge, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { S as Profiler, i as writeGenerateFileData, m as DEFAULT_GENERATE_OPTIONS, o as deepMerge, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CFbiHxB7.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
4
|
|
package/dist/{generateCodeFromOpenAPIDoc-C2niF2V7.mjs → generateCodeFromOpenAPIDoc-CFbiHxB7.mjs}
RENAMED
|
@@ -645,6 +645,7 @@ const DEFAULT_GENERATE_OPTIONS = {
|
|
|
645
645
|
queryTypesImportPath: PACKAGE_IMPORT_PATH,
|
|
646
646
|
axiosRequestConfig: false,
|
|
647
647
|
mutationEffects: true,
|
|
648
|
+
mutationDefaultOnError: false,
|
|
648
649
|
workspaceContext: [],
|
|
649
650
|
prefetchQueries: true,
|
|
650
651
|
infiniteQueries: false,
|
|
@@ -3468,6 +3469,7 @@ function generateConfigs(generateTypeParams) {
|
|
|
3468
3469
|
const hasMutation = endpoints.length > 0;
|
|
3469
3470
|
resolver.options.checkAcl && endpoints.some((e) => e.acl);
|
|
3470
3471
|
const hasMutationEffects = resolver.options.mutationEffects && hasMutation;
|
|
3472
|
+
const hasMutationDefaultOnError = resolver.options.mutationDefaultOnError && hasMutation;
|
|
3471
3473
|
const hasWorkspaceContext = resolver.options.workspaceContext && endpoints.some((e) => resolver.options.workspaceContext);
|
|
3472
3474
|
const endpointsImports = getEndpointsImports({
|
|
3473
3475
|
tag,
|
|
@@ -3479,7 +3481,7 @@ function generateConfigs(generateTypeParams) {
|
|
|
3479
3481
|
from: "@tanstack/react-query"
|
|
3480
3482
|
};
|
|
3481
3483
|
const queryTypesImport = {
|
|
3482
|
-
bindings: ["OpenApiQueryConfig"],
|
|
3484
|
+
bindings: [...hasMutationDefaultOnError ? ["OpenApiQueryConfig"] : []],
|
|
3483
3485
|
typeBindings: [QUERY_OPTIONS_TYPES.mutation],
|
|
3484
3486
|
from: getQueryTypesImportPath(resolver.options)
|
|
3485
3487
|
};
|
|
@@ -3573,6 +3575,7 @@ function renderColumnsConfig(columnsConfig) {
|
|
|
3573
3575
|
function renderMutationContent(resolver, endpoint, tag) {
|
|
3574
3576
|
const hasAclCheck = resolver.options.checkAcl && endpoint.acl;
|
|
3575
3577
|
const hasMutationEffects = resolver.options.mutationEffects;
|
|
3578
|
+
const hasMutationDefaultOnError = resolver.options.mutationDefaultOnError;
|
|
3576
3579
|
const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
|
|
3577
3580
|
const endpointTag = getEndpointTag(endpoint, resolver.options);
|
|
3578
3581
|
const endpointParams = mapEndpointParamsToFunctionParams(resolver, endpoint, {
|
|
@@ -3585,7 +3588,7 @@ function renderMutationContent(resolver, endpoint, tag) {
|
|
|
3585
3588
|
const mutationVariablesType = endpoint.mediaUpload ? `{ ${endpointParamsStr}${endpointParamsStr ? "; " : ""}abortController?: AbortController; onUploadProgress?: (progress: { loaded: number; total: number }) => void }` : `{ ${endpointParamsStr} }`;
|
|
3586
3589
|
const lines = [];
|
|
3587
3590
|
lines.push(`(options?: AppMutationOptions<typeof ${endpointFunction}, ${mutationVariablesType}>${hasAxiosRequestConfig ? `, config?: AxiosRequestConfig` : ""}) => {`);
|
|
3588
|
-
lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
|
|
3591
|
+
if (hasMutationDefaultOnError) lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
|
|
3589
3592
|
if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects<typeof ${QUERY_MODULE_ENUM}.${endpointTag}>({ currentModule: ${QUERY_MODULE_ENUM}.${tag} });`);
|
|
3590
3593
|
lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
|
|
3591
3594
|
lines.push("");
|
|
@@ -3606,6 +3609,7 @@ function renderMutationContent(resolver, endpoint, tag) {
|
|
|
3606
3609
|
lines.push(" },");
|
|
3607
3610
|
}
|
|
3608
3611
|
lines.push(" ...options,");
|
|
3612
|
+
if (hasMutationDefaultOnError) lines.push(" onError: options?.onError ?? queryConfig.onError,");
|
|
3609
3613
|
lines.push(" });");
|
|
3610
3614
|
lines.push("}");
|
|
3611
3615
|
return lines.map((line) => " " + line).join("\n").trimStart();
|
|
@@ -3938,6 +3942,7 @@ function generateQueries(params) {
|
|
|
3938
3942
|
from: AXIOS_IMPORT.from
|
|
3939
3943
|
};
|
|
3940
3944
|
const { queryEndpoints, infiniteQueryEndpoints, mutationEndpoints, aclEndpoints } = endpointGroups;
|
|
3945
|
+
const hasMutationDefaultOnError = resolver.options.mutationDefaultOnError && mutationEndpoints.length > 0;
|
|
3941
3946
|
const queryImport = {
|
|
3942
3947
|
bindings: [
|
|
3943
3948
|
...resolver.options.prefetchQueries && queryEndpoints.length > 0 ? ["QueryClient"] : [],
|
|
@@ -3964,7 +3969,7 @@ function generateQueries(params) {
|
|
|
3964
3969
|
from: ACL_PACKAGE_IMPORT_PATH
|
|
3965
3970
|
};
|
|
3966
3971
|
const queryTypesImport = {
|
|
3967
|
-
bindings: [...
|
|
3972
|
+
bindings: [...hasMutationDefaultOnError ? ["OpenApiQueryConfig"] : []],
|
|
3968
3973
|
typeBindings: [
|
|
3969
3974
|
...queryEndpoints.length > 0 ? [QUERY_OPTIONS_TYPES.query] : [],
|
|
3970
3975
|
...resolver.options.infiniteQueries && infiniteQueryEndpoints.length > 0 ? [QUERY_OPTIONS_TYPES.infiniteQuery] : [],
|
|
@@ -3974,7 +3979,7 @@ function generateQueries(params) {
|
|
|
3974
3979
|
};
|
|
3975
3980
|
const hasWorkspaceContext = resolver.options.workspaceContext && endpoints.some((endpoint) => getWorkspaceParamNames(resolver, endpoint).length > 0);
|
|
3976
3981
|
const workspaceContextImport = {
|
|
3977
|
-
bindings: ["
|
|
3982
|
+
bindings: ["useWorkspaceContext"],
|
|
3978
3983
|
from: PACKAGE_IMPORT_PATH
|
|
3979
3984
|
};
|
|
3980
3985
|
const endpointParams = endpoints.flatMap((endpoint) => endpoint.parameters);
|
|
@@ -4169,15 +4174,40 @@ function getWorkspaceParamNames(resolver, endpoint) {
|
|
|
4169
4174
|
return getUniqueArray([...workspaceParamNames, ...aclParamNames]).filter((name) => allowList.has(name));
|
|
4170
4175
|
}
|
|
4171
4176
|
function getWorkspaceParamReplacements(resolver, endpoint) {
|
|
4172
|
-
return Object.fromEntries(getWorkspaceParamNames(resolver, endpoint).map((name) => [name,
|
|
4177
|
+
return Object.fromEntries(getWorkspaceParamNames(resolver, endpoint).map((name) => [name, `normalize${capitalize(name)}`]));
|
|
4178
|
+
}
|
|
4179
|
+
function getWorkspaceParamTypes(resolver, endpoint, modelNamespaceTag) {
|
|
4180
|
+
const workspaceParamNames = new Set(getWorkspaceParamNames(resolver, endpoint));
|
|
4181
|
+
return Object.fromEntries(getEndpointParamMapping(resolver, endpoint, { modelNamespaceTag }).filter((param) => workspaceParamNames.has(param.name)).map((param) => [param.name, param.type]));
|
|
4173
4182
|
}
|
|
4174
|
-
function
|
|
4183
|
+
function renderWorkspaceContextDestructure({ replacements, paramTypes, indent }) {
|
|
4175
4184
|
const workspaceParamNames = Object.keys(replacements);
|
|
4176
4185
|
if (workspaceParamNames.length === 0) return [];
|
|
4177
|
-
const
|
|
4178
|
-
|
|
4186
|
+
const workspaceParamBindings = workspaceParamNames.map((paramName) => `${paramName}: ${paramName}Workspace`);
|
|
4187
|
+
const workspaceContextType = workspaceParamNames.map((paramName) => `${paramName}?: ${paramTypes[paramName] ?? "unknown"}`).join("; ");
|
|
4188
|
+
return [`${indent}const { ${workspaceParamBindings.join(", ")} } = useWorkspaceContext<{ ${workspaceContextType} }>();`];
|
|
4189
|
+
}
|
|
4190
|
+
function renderWorkspaceParamCoalescing({ replacements, indent }) {
|
|
4191
|
+
const workspaceParamNames = Object.keys(replacements);
|
|
4192
|
+
const lines = [];
|
|
4193
|
+
for (const paramName of workspaceParamNames) {
|
|
4194
|
+
lines.push(`${indent}const ${replacements[paramName]} = ${paramName} ?? ${paramName}Workspace;`);
|
|
4195
|
+
lines.push(`${indent}if (!${replacements[paramName]}) {`);
|
|
4196
|
+
lines.push(`${indent} throw Error(\`${capitalize(paramName)} not provided\`);`);
|
|
4197
|
+
lines.push(`${indent}}`);
|
|
4198
|
+
}
|
|
4179
4199
|
return lines;
|
|
4180
4200
|
}
|
|
4201
|
+
function renderWorkspaceParamResolutions({ replacements, paramTypes, indent }) {
|
|
4202
|
+
return [...renderWorkspaceContextDestructure({
|
|
4203
|
+
replacements,
|
|
4204
|
+
paramTypes,
|
|
4205
|
+
indent
|
|
4206
|
+
}), ...renderWorkspaceParamCoalescing({
|
|
4207
|
+
replacements,
|
|
4208
|
+
indent
|
|
4209
|
+
})];
|
|
4210
|
+
}
|
|
4181
4211
|
function renderAclCheckCall(resolver, endpoint, replacements, indent = "") {
|
|
4182
4212
|
const checkParams = getAbilityConditionsTypes(endpoint)?.map((condition) => invalidVariableNameCharactersToCamel(condition.name));
|
|
4183
4213
|
const paramNames = new Set(endpoint.parameters.map((param) => invalidVariableNameCharactersToCamel(param.name)));
|
|
@@ -4347,6 +4377,7 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4347
4377
|
const hasAclCheck = resolver.options.checkAcl && endpoint.acl;
|
|
4348
4378
|
const tag = getEndpointTag(endpoint, resolver.options);
|
|
4349
4379
|
const workspaceParamReplacements = resolver.options.workspaceContext ? getWorkspaceParamReplacements(resolver, endpoint) : {};
|
|
4380
|
+
const workspaceParamTypes = getWorkspaceParamTypes(resolver, endpoint, tag);
|
|
4350
4381
|
const endpointArgs = renderEndpointArgs(resolver, endpoint, {});
|
|
4351
4382
|
const resolvedEndpointArgs = renderEndpointObjectArgs(resolver, endpoint, {}, workspaceParamReplacements);
|
|
4352
4383
|
const endpointParams = renderEndpointParams(resolver, endpoint, {
|
|
@@ -4367,6 +4398,7 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4367
4398
|
if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
|
|
4368
4399
|
lines.push(...renderWorkspaceParamResolutions({
|
|
4369
4400
|
replacements: workspaceParamReplacements,
|
|
4401
|
+
paramTypes: workspaceParamTypes,
|
|
4370
4402
|
indent: " "
|
|
4371
4403
|
}));
|
|
4372
4404
|
lines.push(" ");
|
|
@@ -4386,9 +4418,11 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4386
4418
|
function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
|
|
4387
4419
|
const hasAclCheck = resolver.options.checkAcl && endpoint.acl;
|
|
4388
4420
|
const hasMutationEffects = resolver.options.mutationEffects;
|
|
4421
|
+
const hasMutationDefaultOnError = resolver.options.mutationDefaultOnError;
|
|
4389
4422
|
const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
|
|
4390
4423
|
const tag = getEndpointTag(endpoint, resolver.options);
|
|
4391
4424
|
const workspaceParamReplacements = resolver.options.workspaceContext ? getWorkspaceParamReplacements(resolver, endpoint) : {};
|
|
4425
|
+
const workspaceParamTypes = getWorkspaceParamTypes(resolver, endpoint, tag);
|
|
4392
4426
|
const endpointParams = renderEndpointParams(resolver, endpoint, {
|
|
4393
4427
|
includeFileParam: true,
|
|
4394
4428
|
optionalPathParams: resolver.options.workspaceContext,
|
|
@@ -4409,15 +4443,22 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
|
|
|
4409
4443
|
tag
|
|
4410
4444
|
}));
|
|
4411
4445
|
lines.push(`export const ${getQueryName(endpoint, true)} = (options?: AppMutationOptions<typeof ${endpointFunction}, { ${mutationVariablesType} }>${hasMutationEffects ? ` & ${MUTATION_EFFECTS.optionsType}` : ""}${hasAxiosRequestConfig ? `, ${AXIOS_REQUEST_CONFIG_NAME}?: ${AXIOS_REQUEST_CONFIG_TYPE}` : ""}) => {`);
|
|
4412
|
-
lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
|
|
4446
|
+
if (hasMutationDefaultOnError) lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
|
|
4413
4447
|
if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
|
|
4414
|
-
|
|
4448
|
+
lines.push(...renderWorkspaceContextDestructure({
|
|
4449
|
+
replacements: workspaceParamReplacements,
|
|
4450
|
+
paramTypes: workspaceParamTypes,
|
|
4451
|
+
indent: " "
|
|
4452
|
+
}));
|
|
4415
4453
|
if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects<typeof ${QUERY_MODULE_ENUM}.${tag}>({ currentModule: ${QUERIES_MODULE_NAME} });`);
|
|
4416
4454
|
lines.push("");
|
|
4417
4455
|
lines.push(` return ${QUERY_HOOKS.mutation}({`);
|
|
4418
4456
|
const mutationFnArg = endpointParams ? `{ ${destructuredMutationArgs}${endpoint.mediaUpload ? `${destructuredMutationArgs ? ", " : ""}abortController, onUploadProgress` : ""} }` : "";
|
|
4419
4457
|
lines.push(` mutationFn: ${endpoint.mediaUpload ? "async " : ""}(${mutationFnArg}) => ${hasMutationFnBody ? "{ " : ""}`);
|
|
4420
|
-
|
|
4458
|
+
lines.push(...renderWorkspaceParamCoalescing({
|
|
4459
|
+
replacements: workspaceParamReplacements,
|
|
4460
|
+
indent: " "
|
|
4461
|
+
}));
|
|
4421
4462
|
if (hasAclCheck) lines.push(renderAclCheckCall(resolver, endpoint, workspaceParamReplacements, " "));
|
|
4422
4463
|
if (endpoint.mediaUpload) {
|
|
4423
4464
|
lines.push(` const uploadInstructions = await ${endpointFunction}(${resolvedEndpointArgs}${hasAxiosRequestConfig ? `${resolvedEndpointArgs ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}` : ""});`);
|
|
@@ -4450,12 +4491,15 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
|
|
|
4450
4491
|
if (hasMutationFnBody) lines.push(" },");
|
|
4451
4492
|
else lines.push(",");
|
|
4452
4493
|
lines.push(" ...options,");
|
|
4453
|
-
lines.push(" onError: options?.onError ?? queryConfig.onError,");
|
|
4494
|
+
if (hasMutationDefaultOnError) lines.push(" onError: options?.onError ?? queryConfig.onError,");
|
|
4454
4495
|
if (hasMutationEffects) {
|
|
4455
4496
|
lines.push(" onSuccess: async (resData, variables, onMutateResult, context) => {");
|
|
4456
4497
|
if (updateQueryEndpoints.length > 0) {
|
|
4457
4498
|
if (destructuredVariables.length > 0) lines.push(` const { ${destructuredVariables.join(", ")} } = variables;`);
|
|
4458
|
-
|
|
4499
|
+
lines.push(...renderWorkspaceParamCoalescing({
|
|
4500
|
+
replacements: workspaceParamReplacements,
|
|
4501
|
+
indent: " "
|
|
4502
|
+
}));
|
|
4459
4503
|
lines.push(` const updateKeys = [${updateQueryEndpoints.map((e) => `keys.${getEndpointName(e)}(${renderEndpointArgs(resolver, e, { includeOnlyRequiredParams: true }, workspaceParamReplacements)})`).join(", ")}];`);
|
|
4460
4504
|
lines.push(` await runMutationEffects(resData, variables, options, updateKeys);`);
|
|
4461
4505
|
} else lines.push(" await runMutationEffects(resData, variables, options);");
|
|
@@ -4508,6 +4552,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4508
4552
|
const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
|
|
4509
4553
|
const tag = getEndpointTag(endpoint, resolver.options);
|
|
4510
4554
|
const workspaceParamReplacements = resolver.options.workspaceContext ? getWorkspaceParamReplacements(resolver, endpoint) : {};
|
|
4555
|
+
const workspaceParamTypes = getWorkspaceParamTypes(resolver, endpoint, tag);
|
|
4511
4556
|
const endpointParams = renderEndpointParams(resolver, endpoint, {
|
|
4512
4557
|
excludePageParam: true,
|
|
4513
4558
|
optionalPathParams: resolver.options.workspaceContext,
|
|
@@ -4529,6 +4574,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
|
|
|
4529
4574
|
if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
|
|
4530
4575
|
lines.push(...renderWorkspaceParamResolutions({
|
|
4531
4576
|
replacements: workspaceParamReplacements,
|
|
4577
|
+
paramTypes: workspaceParamTypes,
|
|
4532
4578
|
indent: " "
|
|
4533
4579
|
}));
|
|
4534
4580
|
lines.push("");
|
package/dist/generator.d.mts
CHANGED
package/dist/generator.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getDataFromOpenAPIDoc, b as invalidVariableNameCharactersToCamel, c as isQuery, f as getTagImportPath, g as GenerateType, h as getNamespaceName, l as getSchemaTsMetaType, m as DEFAULT_GENERATE_OPTIONS, p as getQueryName, s as isMutation, t as generateCodeFromOpenAPIDoc, u as getTsTypeBase, v as isMediaTypeAllowed, x as formatTag, y as isParamMediaTypeAllowed } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { a as getDataFromOpenAPIDoc, b as invalidVariableNameCharactersToCamel, c as isQuery, f as getTagImportPath, g as GenerateType, h as getNamespaceName, l as getSchemaTsMetaType, m as DEFAULT_GENERATE_OPTIONS, p as getQueryName, s as isMutation, t as generateCodeFromOpenAPIDoc, u as getTsTypeBase, v as isMediaTypeAllowed, x as formatTag, y as isParamMediaTypeAllowed } from "./generateCodeFromOpenAPIDoc-CFbiHxB7.mjs";
|
|
2
2
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/core/getMetadataFromOpenAPIDoc.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as GeneralErrorCodes, i as ErrorHandlerOptions, n as ErrorEntry, o as SharedErrorHandler, r as ErrorHandler, t as ApplicationException } from "./error-handling-CXeVTk1T.mjs";
|
|
2
|
-
import "./options-
|
|
3
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
2
|
+
import "./options-fyt0BYYE.mjs";
|
|
3
|
+
import { t as OpenAPICodegenConfig } from "./config-DTx4Ck6g.mjs";
|
|
4
4
|
import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import "i18next";
|
|
@@ -145,9 +145,10 @@ declare namespace OpenApiWorkspaceContext {
|
|
|
145
145
|
values,
|
|
146
146
|
children
|
|
147
147
|
}: PropsWithChildren<WorkspaceProviderProps>) => react_jsx_runtime0.JSX.Element;
|
|
148
|
-
const useContext: () =>
|
|
148
|
+
const useContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
149
149
|
const resolveParam: <T>(context: WorkspaceValues, name: string, value: T | null | undefined) => T;
|
|
150
150
|
}
|
|
151
|
+
declare const useWorkspaceContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
|
|
151
152
|
//#endregion
|
|
152
153
|
//#region src/lib/config/i18n.d.ts
|
|
153
154
|
declare const ns = "openapi";
|
|
@@ -227,4 +228,4 @@ declare const AuthGuard: ({
|
|
|
227
228
|
children
|
|
228
229
|
}: PropsWithChildren<AuthGuardProps>) => react.ReactNode;
|
|
229
230
|
//#endregion
|
|
230
|
-
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MutationEffectsOptions, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects };
|
|
231
|
+
export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MutationEffectsOptions, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
|
package/dist/index.mjs
CHANGED
|
@@ -226,6 +226,7 @@ let OpenApiWorkspaceContext;
|
|
|
226
226
|
return workspaceValue;
|
|
227
227
|
};
|
|
228
228
|
})(OpenApiWorkspaceContext || (OpenApiWorkspaceContext = {}));
|
|
229
|
+
const useWorkspaceContext = () => OpenApiWorkspaceContext.useContext();
|
|
229
230
|
|
|
230
231
|
//#endregion
|
|
231
232
|
//#region src/lib/auth/AuthGuard.tsx
|
|
@@ -249,4 +250,4 @@ const AuthGuard = ({ type, redirectTo, children }) => {
|
|
|
249
250
|
};
|
|
250
251
|
|
|
251
252
|
//#endregion
|
|
252
|
-
export { ApplicationException, AuthContext, AuthGuard, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects };
|
|
253
|
+
export { ApplicationException, AuthContext, AuthGuard, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
|
package/dist/sh.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as VALIDATION_ERROR_TYPE_TITLE, S as Profiler, _ as groupByType, a as getDataFromOpenAPIDoc, d as getTagFileName, g as GenerateType, n as getOutputFileName } from "./generateCodeFromOpenAPIDoc-
|
|
3
|
-
import { n as resolveConfig, t as runGenerate } from "./generate.runner-
|
|
2
|
+
import { C as VALIDATION_ERROR_TYPE_TITLE, S as Profiler, _ as groupByType, a as getDataFromOpenAPIDoc, d as getTagFileName, g as GenerateType, n as getOutputFileName } from "./generateCodeFromOpenAPIDoc-CFbiHxB7.mjs";
|
|
3
|
+
import { n as resolveConfig, t as runGenerate } from "./generate.runner-DLLGYMVB.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import yargs from "yargs";
|
|
6
6
|
import { hideBin } from "yargs/helpers";
|
|
@@ -39,7 +39,7 @@ function logBanner(message) {
|
|
|
39
39
|
* Fetch the version from package.json
|
|
40
40
|
*/
|
|
41
41
|
function getVersion() {
|
|
42
|
-
return "2.0.8-rc.
|
|
42
|
+
return "2.0.8-rc.37";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
@@ -320,6 +320,7 @@ var GenerateOptions = class {
|
|
|
320
320
|
replaceOptionalWithNullish;
|
|
321
321
|
infiniteQueries;
|
|
322
322
|
mutationEffects;
|
|
323
|
+
mutationDefaultOnError;
|
|
323
324
|
workspaceContext;
|
|
324
325
|
parseRequestParams;
|
|
325
326
|
inlineEndpoints;
|
|
@@ -389,6 +390,10 @@ __decorate([YargOption({
|
|
|
389
390
|
envAlias: "mutationEffects",
|
|
390
391
|
type: "boolean"
|
|
391
392
|
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "mutationEffects", void 0);
|
|
393
|
+
__decorate([YargOption({
|
|
394
|
+
envAlias: "mutationDefaultOnError",
|
|
395
|
+
type: "boolean"
|
|
396
|
+
}), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "mutationDefaultOnError", void 0);
|
|
392
397
|
__decorate([YargOption({ envAlias: "workspaceContext" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "workspaceContext", void 0);
|
|
393
398
|
__decorate([YargOption({
|
|
394
399
|
envAlias: "parseRequestParams",
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as GenerateFileFormatter } from "./options-
|
|
2
|
-
import { t as OpenAPICodegenConfig } from "./config-
|
|
1
|
+
import { r as GenerateFileFormatter } from "./options-fyt0BYYE.mjs";
|
|
2
|
+
import { t as OpenAPICodegenConfig } from "./config-DTx4Ck6g.mjs";
|
|
3
3
|
import { Plugin } from "vite";
|
|
4
4
|
|
|
5
5
|
//#region src/vite/openapi-codegen.plugin.d.ts
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import { t as runGenerate } from "./generate.runner-
|
|
1
|
+
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-CFbiHxB7.mjs";
|
|
2
|
+
import { t as runGenerate } from "./generate.runner-DLLGYMVB.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
//#region src/vite/openapi-codegen.plugin.ts
|