@povio/openapi-codegen-cli 3.1.0-rc.1 → 3.1.0-rc.3

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/dist/metro.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { r as GenerateFileFormatter } from "./options-CE4Koxof.mjs";
2
2
  import { t as OpenAPICodegenConfig } from "./config-BU7wVf7U.mjs";
3
- import { a as GenerateOpenApiFile } from "./openapi-B14GzSA_.mjs";
3
+ import { a as GenerateOpenApiFile } from "./openapi-BkC5yZ-W.mjs";
4
4
  import { IncomingMessage, ServerResponse } from "http";
5
5
 
6
6
  //#region src/metro/openapi-codegen.plugin.d.ts
@@ -106,26 +106,24 @@ declare function isProcedureMeta(meta: unknown): meta is ProcedureMeta;
106
106
  declare function operationKey(method: string, routePath: string): string;
107
107
  declare function toPascalCase(value: string): string;
108
108
  declare function isZodSchema(value: unknown): value is ZodSchema;
109
- declare function dtoSchemaName(name: string): string;
110
- declare function shouldUseDtoSchemaName(moduleName: string, schema: ZodSchema): boolean;
111
109
  declare function schemaExportName(moduleName: string, exportName: string, schema: ZodSchema, getSchemaName?: typeof getOpenApiSchemaName): string;
110
+ declare function modelSchemaExportName(exportName: string): string;
112
111
  declare function sharedSchemaExportName(exportName: string): string;
113
112
  declare function collectModelSchemaExports(options: {
114
113
  apiRoot?: string;
115
114
  dbTablesRoot?: string;
116
- getOpenApiSchemaName?: (schema: unknown) => string | undefined;
117
- }): Promise<ModelSchemaExport[]>;
118
- declare function collectApiModelSchemaExports(apiRoot: string, options?: {
119
- getOpenApiSchemaName?: (schema: unknown) => string | undefined;
120
- }): Promise<ModelSchemaExport[]>;
121
- declare function collectModuleModelSchemaExports(apiRoot: string, moduleName: string, options?: {
122
- getOpenApiSchemaName?: (schema: unknown) => string | undefined;
123
115
  }): Promise<ModelSchemaExport[]>;
116
+ declare function collectApiModelSchemaExports(apiRoot: string): Promise<ModelSchemaExport[]>;
117
+ declare function collectModuleModelSchemaExports(apiRoot: string, moduleName: string): Promise<ModelSchemaExport[]>;
124
118
  declare function collectDbTableModelSchemaExports(tablesRoot: string): Promise<ModelSchemaExport[]>;
125
119
  declare function collectDbTableModelSchemaExport(tablesRoot: string, tableName: string): Promise<ModelSchemaExport[]>;
126
120
  declare function toOpenAPIAclRule(rule: string): JsonObject;
127
121
  declare function collectOperationMeta(router: AnyContractRouter, routerPath?: string[], operationMeta?: Map<string, OperationContractInfo>): Map<string, OperationContractInfo>;
128
122
  declare function getObjectPropertySchema(schema: AnySchema, property: string): AnySchema | undefined;
123
+ declare function routeHasPathParameters(routePath?: string): boolean;
124
+ declare function getProcedureInputSchemaRole(route: OrpcContractProcedureData["route"]): "Params" | "Query" | "Request";
125
+ declare function procedureSchemaName(procedureName: string, role: "Params" | "Query" | "Request" | "Response"): string;
126
+ declare function addContractSchema(schemas: OpenApiSchemaRegistry, schema: AnySchema | undefined, name: string, getSchemaName: (schema: unknown) => string | undefined, strategy?: "input" | "output"): void;
129
127
  declare function collectContractSchemas(router: AnyContractRouter, routerPath?: string[], schemas?: OpenApiSchemaRegistry, getSchemaName?: typeof getOpenApiSchemaName): OpenApiSchemaRegistry;
130
128
  declare function collectContractSchemaRoots(router: AnyContractRouter, roots?: Set<unknown>): Set<AnySchema>;
131
129
  declare function visitZodSchema(schema: ZodSchema, visit: (schema: ZodSchema) => void, seen?: Set<{
@@ -134,11 +132,14 @@ declare function visitZodSchema(schema: ZodSchema, visit: (schema: ZodSchema) =>
134
132
  };
135
133
  }>): void;
136
134
  declare function collectSchemaRegistryRoots(registry: OpenApiSchemaRegistry): Set<AnySchema>;
135
+ declare function modelSchemaNameEntries(modelSchemas: ModelSchemaExport[]): Map<ZodSchema, string>;
136
+ declare function createModelSchemaNameGetter(modelSchemas: ModelSchemaExport[], getSchemaName?: typeof getOpenApiSchemaName): (schema: unknown) => string | undefined;
137
137
  declare function collectReachableModelSchemas(router: AnyContractRouter, options?: {
138
138
  apiRoot?: string;
139
139
  dbTablesRoot?: string;
140
140
  excludedSchemas?: Set<AnySchema>;
141
141
  getOpenApiSchemaName?: (schema: unknown) => string | undefined;
142
+ modelSchemas?: ModelSchemaExport[];
142
143
  }): Promise<OpenApiSchemaRegistry>;
143
144
  declare function compactTagName(value: string): string;
144
145
  declare function getModuleOpenApiController(apiModules: Record<string, TinyOpenApiModule>, moduleName: string): string;
@@ -167,4 +168,4 @@ declare function applyPaginatedItemSchemas(spec: JsonObject): void;
167
168
  declare function toOpenAPI30Document(spec: JsonObject): JsonObject;
168
169
  declare function generateORPCOpenAPISpec(options: GenerateORPCOpenAPISpecOptions): Promise<JsonObject>;
169
170
  //#endregion
170
- export { isContractProcedure as $, collectOperationMeta as A, generateOpenApiFile as B, collectContractSchemaRoots as C, collectExtraSchemas as D, collectDbTableModelSchemaExports as E, defineOpenApiSchemas as F, getModuleOpenApiTag as G, getContractProcedureData as H, dtoSchemaName as I, getOperationAction as J, getObjectPropertySchema as K, findComponentEnumNames as L, collectReachableModelSchemas as M, collectSchemaRegistryRoots as N, collectModelSchemaExports as O, compactTagName as P, getStringEnumValues as Q, findEnumNames as R, collectApiModelSchemaExports as S, visitZodSchema as St, collectDbTableModelSchemaExport as T, getDerivedOperationId as U, getComponentSchemas as V, getModuleOpenApiController as W, getPaginatedItemSchema as X, getOperationController as Y, getRobodevModuleRoles as Z, applyPaginatedItemSchemas as _, stripNoContentResponseBodies as _t, GenerateOpenApiFile as a, namedControllerActionInputDtoSchema as at, applyRobodevUserRolesExtension as b, toOpenAPIAclRule as bt, GenerateTinyOpenApiFileOptions as c, namedOpenApiRequestSchema as ct, ProcedureMeta as d, operationKey as dt, isNullSchema as et, TinyOpenApiModule as f, resolveOpenApiOutputPath as ft, applyOperationMeta as g, shouldUseDtoSchemaName as gt, applyEnumExtensions as h, sharedSchemaExportName as ht, GenerateORPCOpenAPISpecOptions as i, isZodSchema as it, collectOperationTags as j, collectModuleModelSchemaExports as k, JsonObject as l, namedOpenApiResponseSchema as lt, ZodSchema as m, schemaExportName as mt, AnyContractRouter as n, isObject as nt, GenerateOpenApiFileOptions as o, namedControllerActionSchema as ot, TinyOpenApiUserRole as p, schemaComponentRef as pt, getOpenApiSchemaName as q, AnySchema as r, isProcedureMeta as rt, GenerateOpenApiFileResult as s, namedOpenApiOutputSchema as st, AclRule as t, isNullableOnlySchema as tt, OpenApiSchemaRegistry as u, namedOpenApiSchema as ut, applyParameterExtensions as v, toOpenAPI30Document as vt, collectContractSchemas as w, asStringArray as x, toPascalCase as xt, applyRobodevModuleExtensions as y, toOpenAPI30Schema as yt, generateORPCOpenAPISpec as z };
171
+ export { getRobodevModuleRoles as $, collectModuleModelSchemaExports as A, generateORPCOpenAPISpec as B, collectApiModelSchemaExports as C, toOpenAPI30Document as Ct, collectDbTableModelSchemaExports as D, visitZodSchema as Dt, collectDbTableModelSchemaExport as E, toPascalCase as Et, compactTagName as F, getModuleOpenApiController as G, getComponentSchemas as H, createModelSchemaNameGetter as I, getOpenApiSchemaName as J, getModuleOpenApiTag as K, defineOpenApiSchemas as L, collectOperationTags as M, collectReachableModelSchemas as N, collectExtraSchemas as O, collectSchemaRegistryRoots as P, getProcedureInputSchemaRole as Q, findComponentEnumNames as R, asStringArray as S, stripNoContentResponseBodies as St, collectContractSchemas as T, toOpenAPIAclRule as Tt, getContractProcedureData as U, generateOpenApiFile as V, getDerivedOperationId as W, getOperationController as X, getOperationAction as Y, getPaginatedItemSchema as Z, applyOperationMeta as _, resolveOpenApiOutputPath as _t, GenerateOpenApiFile as a, isProcedureMeta as at, applyRobodevModuleExtensions as b, schemaExportName as bt, GenerateTinyOpenApiFileOptions as c, modelSchemaNameEntries as ct, ProcedureMeta as d, namedOpenApiOutputSchema as dt, getStringEnumValues as et, TinyOpenApiModule as f, namedOpenApiRequestSchema as ft, applyEnumExtensions as g, procedureSchemaName as gt, addContractSchema as h, operationKey as ht, GenerateORPCOpenAPISpecOptions as i, isObject as it, collectOperationMeta as j, collectModelSchemaExports as k, JsonObject as l, namedControllerActionInputDtoSchema as lt, ZodSchema as m, namedOpenApiSchema as mt, AnyContractRouter as n, isNullSchema as nt, GenerateOpenApiFileOptions as o, isZodSchema as ot, TinyOpenApiUserRole as p, namedOpenApiResponseSchema as pt, getObjectPropertySchema as q, AnySchema as r, isNullableOnlySchema as rt, GenerateOpenApiFileResult as s, modelSchemaExportName as st, AclRule as t, isContractProcedure as tt, OpenApiSchemaRegistry as u, namedControllerActionSchema as ut, applyPaginatedItemSchemas as v, routeHasPathParameters as vt, collectContractSchemaRoots as w, toOpenAPI30Schema as wt, applyRobodevUserRolesExtension as x, sharedSchemaExportName as xt, applyParameterExtensions as y, schemaComponentRef as yt, findEnumNames as z };
package/dist/sh.mjs CHANGED
@@ -39,7 +39,7 @@ function logBanner(message) {
39
39
  * Fetch the version from package.json
40
40
  */
41
41
  function getVersion() {
42
- return "3.1.0-rc.1";
42
+ return "3.1.0-rc.3";
43
43
  }
44
44
 
45
45
  //#endregion
package/dist/tiny.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./options-CE4Koxof.mjs";
2
2
  import { t as OpenAPICodegenConfig } from "./config-BU7wVf7U.mjs";
3
- import { $ as isContractProcedure, A as collectOperationMeta, B as generateOpenApiFile, C as collectContractSchemaRoots, D as collectExtraSchemas, E as collectDbTableModelSchemaExports, F as defineOpenApiSchemas, G as getModuleOpenApiTag, H as getContractProcedureData, I as dtoSchemaName, J as getOperationAction, K as getObjectPropertySchema, L as findComponentEnumNames, M as collectReachableModelSchemas, N as collectSchemaRegistryRoots, O as collectModelSchemaExports, P as compactTagName, Q as getStringEnumValues, R as findEnumNames, S as collectApiModelSchemaExports, St as visitZodSchema, T as collectDbTableModelSchemaExport, U as getDerivedOperationId, V as getComponentSchemas, W as getModuleOpenApiController, X as getPaginatedItemSchema, Y as getOperationController, Z as getRobodevModuleRoles, _ as applyPaginatedItemSchemas, _t as stripNoContentResponseBodies, a as GenerateOpenApiFile, at as namedControllerActionInputDtoSchema, b as applyRobodevUserRolesExtension, bt as toOpenAPIAclRule, c as GenerateTinyOpenApiFileOptions, ct as namedOpenApiRequestSchema, d as ProcedureMeta, dt as operationKey, et as isNullSchema, f as TinyOpenApiModule, ft as resolveOpenApiOutputPath, g as applyOperationMeta, gt as shouldUseDtoSchemaName, h as applyEnumExtensions, ht as sharedSchemaExportName, i as GenerateORPCOpenAPISpecOptions, it as isZodSchema, j as collectOperationTags, k as collectModuleModelSchemaExports, l as JsonObject, lt as namedOpenApiResponseSchema, m as ZodSchema, mt as schemaExportName, n as AnyContractRouter, nt as isObject, o as GenerateOpenApiFileOptions, ot as namedControllerActionSchema, p as TinyOpenApiUserRole, pt as schemaComponentRef, q as getOpenApiSchemaName, r as AnySchema, rt as isProcedureMeta, s as GenerateOpenApiFileResult, st as namedOpenApiOutputSchema, t as AclRule, tt as isNullableOnlySchema, u as OpenApiSchemaRegistry, ut as namedOpenApiSchema, v as applyParameterExtensions, vt as toOpenAPI30Document, w as collectContractSchemas, x as asStringArray, xt as toPascalCase, y as applyRobodevModuleExtensions, yt as toOpenAPI30Schema, z as generateORPCOpenAPISpec } from "./openapi-B14GzSA_.mjs";
3
+ import { $ as getRobodevModuleRoles, A as collectModuleModelSchemaExports, B as generateORPCOpenAPISpec, C as collectApiModelSchemaExports, Ct as toOpenAPI30Document, D as collectDbTableModelSchemaExports, Dt as visitZodSchema, E as collectDbTableModelSchemaExport, Et as toPascalCase, F as compactTagName, G as getModuleOpenApiController, H as getComponentSchemas, I as createModelSchemaNameGetter, J as getOpenApiSchemaName, K as getModuleOpenApiTag, L as defineOpenApiSchemas, M as collectOperationTags, N as collectReachableModelSchemas, O as collectExtraSchemas, P as collectSchemaRegistryRoots, Q as getProcedureInputSchemaRole, R as findComponentEnumNames, S as asStringArray, St as stripNoContentResponseBodies, T as collectContractSchemas, Tt as toOpenAPIAclRule, U as getContractProcedureData, V as generateOpenApiFile, W as getDerivedOperationId, X as getOperationController, Y as getOperationAction, Z as getPaginatedItemSchema, _ as applyOperationMeta, _t as resolveOpenApiOutputPath, a as GenerateOpenApiFile, at as isProcedureMeta, b as applyRobodevModuleExtensions, bt as schemaExportName, c as GenerateTinyOpenApiFileOptions, ct as modelSchemaNameEntries, d as ProcedureMeta, dt as namedOpenApiOutputSchema, et as getStringEnumValues, f as TinyOpenApiModule, ft as namedOpenApiRequestSchema, g as applyEnumExtensions, gt as procedureSchemaName, h as addContractSchema, ht as operationKey, i as GenerateORPCOpenAPISpecOptions, it as isObject, j as collectOperationMeta, k as collectModelSchemaExports, l as JsonObject, lt as namedControllerActionInputDtoSchema, m as ZodSchema, mt as namedOpenApiSchema, n as AnyContractRouter, nt as isNullSchema, o as GenerateOpenApiFileOptions, ot as isZodSchema, p as TinyOpenApiUserRole, pt as namedOpenApiResponseSchema, q as getObjectPropertySchema, r as AnySchema, rt as isNullableOnlySchema, s as GenerateOpenApiFileResult, st as modelSchemaExportName, t as AclRule, tt as isContractProcedure, u as OpenApiSchemaRegistry, ut as namedControllerActionSchema, v as applyPaginatedItemSchemas, vt as routeHasPathParameters, w as collectContractSchemaRoots, wt as toOpenAPI30Schema, x as applyRobodevUserRolesExtension, xt as sharedSchemaExportName, y as applyParameterExtensions, yt as schemaComponentRef, z as findEnumNames } from "./openapi-BkC5yZ-W.mjs";
4
4
 
5
5
  //#region src/tiny/openapi-source.runner.d.ts
6
6
  interface TinyOpenApiSourceRunnerConfig {
@@ -18,4 +18,4 @@ declare function isTinyOpenApiFakeMode(apiMode?: string | undefined): boolean;
18
18
  declare function getLocalInputPath(input: OpenAPICodegenConfig["input"], root: string): string | undefined;
19
19
  declare function normalizeWatchFolders(root: string, watchFolders?: readonly string[]): string[];
20
20
  //#endregion
21
- export { AclRule, AnyContractRouter, AnySchema, GenerateORPCOpenAPISpecOptions, GenerateOpenApiFile, GenerateOpenApiFileOptions, GenerateOpenApiFileResult, GenerateTinyOpenApiFileOptions, JsonObject, OpenApiSchemaRegistry, ProcedureMeta, TinyOpenApiModule, type TinyOpenApiSourceRunnerConfig, TinyOpenApiUserRole, ZodSchema, applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createTinyOpenApiSourceRunner, defineOpenApiSchemas, dtoSchemaName, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, resolveOpenApiOutputPath, schemaComponentRef, schemaExportName, sharedSchemaExportName, shouldUseDtoSchemaName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
21
+ export { AclRule, AnyContractRouter, AnySchema, GenerateORPCOpenAPISpecOptions, GenerateOpenApiFile, GenerateOpenApiFileOptions, GenerateOpenApiFileResult, GenerateTinyOpenApiFileOptions, JsonObject, OpenApiSchemaRegistry, ProcedureMeta, TinyOpenApiModule, type TinyOpenApiSourceRunnerConfig, TinyOpenApiUserRole, ZodSchema, addContractSchema, applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createModelSchemaNameGetter, createTinyOpenApiSourceRunner, defineOpenApiSchemas, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getProcedureInputSchemaRole, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, modelSchemaExportName, modelSchemaNameEntries, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, procedureSchemaName, resolveOpenApiOutputPath, routeHasPathParameters, schemaComponentRef, schemaExportName, sharedSchemaExportName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
package/dist/tiny.mjs CHANGED
@@ -8,11 +8,10 @@ import { access, readdir } from "fs/promises";
8
8
  async function importRuntimeModule(specifier) {
9
9
  return new Function("specifier", "return import(specifier)")(specifier);
10
10
  }
11
- const DTO_SUFFIX = "Dto";
12
- const PAGINATED_OUTPUT_SUFFIX = "PaginateOutputDto";
11
+ const PAGINATED_OUTPUT_SUFFIX = "PaginateOutput";
13
12
  const PAGINATED_RESPONSE_SUFFIX = "PaginateResponse";
14
13
  const PAGINATION_RESPONSE_OUTPUT_SUFFIX = "PaginationResponseOutput";
15
- const PAGINATED_ITEM_SUFFIX = "PaginateItemDto";
14
+ const PAGINATED_ITEM_SUFFIX = "PaginateItem";
16
15
  const PAGINATED_ITEM_OUTPUT_SUFFIX = "PaginateItemOutput";
17
16
  const PAGINATION_DTO_SCHEMA_NAME = "PaginationDto";
18
17
  const PAGINATION_PROPERTY_NAMES = [
@@ -84,13 +83,13 @@ function namedOpenApiResponseSchema(schema, name) {
84
83
  return namedOpenApiSchema(schema, `${name}Response`);
85
84
  }
86
85
  function namedOpenApiOutputSchema(schema, name) {
87
- return namedOpenApiSchema(schema, `${name}Output`);
86
+ return namedOpenApiResponseSchema(schema, name);
88
87
  }
89
88
  function namedControllerActionSchema(schema, controller, action, suffix) {
90
89
  return namedOpenApiSchema(schema, `${controller}Controller${toPascalCase(action)}${suffix}`);
91
90
  }
92
91
  function namedControllerActionInputDtoSchema(schema, controller, action) {
93
- return namedControllerActionSchema(schema, controller, action, "InputDto");
92
+ return namedControllerActionSchema(schema, controller, action, "Request");
94
93
  }
95
94
  function getOpenApiSchemaName(schema) {
96
95
  return typeof schema === "object" && schema !== null ? openApiSchemaNames.get(schema) : void 0;
@@ -201,34 +200,30 @@ function toPascalCase(value) {
201
200
  function isZodSchema(value) {
202
201
  return isObject(value) && isObject(value["~standard"]) && value["~standard"].vendor === "zod" && isObject(value._zod) && isObject(value._zod.def);
203
202
  }
204
- function dtoSchemaName(name) {
205
- return name.endsWith(DTO_SUFFIX) ? name : `${name}${DTO_SUFFIX}`;
206
- }
207
- function shouldUseDtoSchemaName(moduleName, schema) {
208
- return moduleName !== "common" && ["object", "array"].includes(String(schema._zod.def.type));
209
- }
210
203
  function schemaExportName(moduleName, exportName, schema, getSchemaName = getOpenApiSchemaName) {
211
204
  const explicitName = getSchemaName(schema);
212
205
  if (explicitName) return explicitName;
213
- const schemaName = exportName.replace(/Schema$/, "").replace(/DTO$/u, DTO_SUFFIX);
206
+ const schemaName = exportName.replace(/Schema$/, "").replace(/DTO$/u, "");
214
207
  const modulePrefix = toPascalCase(moduleName);
215
208
  const singularModulePrefix = modulePrefix.endsWith("s") ? modulePrefix.slice(0, -1) : modulePrefix;
216
- const prefixedName = moduleName === "common" || schemaName.startsWith(modulePrefix) || schemaName.startsWith(singularModulePrefix) ? schemaName : `${modulePrefix}${schemaName}`;
217
- return shouldUseDtoSchemaName(moduleName, schema) ? dtoSchemaName(prefixedName) : prefixedName;
209
+ return moduleName === "common" || schemaName.startsWith(modulePrefix) || schemaName.startsWith(singularModulePrefix) ? schemaName : `${modulePrefix}${schemaName}`;
210
+ }
211
+ function modelSchemaExportName(exportName) {
212
+ return exportName.replace(/Schema$/, "");
218
213
  }
219
214
  function sharedSchemaExportName(exportName) {
220
215
  return exportName.replace(/Schema$/, "");
221
216
  }
222
217
  async function collectModelSchemaExports(options) {
223
- const apiSchemaGroups = options.apiRoot ? await collectApiModelSchemaExports(options.apiRoot, options) : [];
218
+ const apiSchemaGroups = options.apiRoot ? await collectApiModelSchemaExports(options.apiRoot) : [];
224
219
  const dbSchemaExports = options.dbTablesRoot ? await collectDbTableModelSchemaExports(options.dbTablesRoot) : [];
225
220
  return [...apiSchemaGroups, ...dbSchemaExports];
226
221
  }
227
- async function collectApiModelSchemaExports(apiRoot, options = {}) {
222
+ async function collectApiModelSchemaExports(apiRoot) {
228
223
  const entries = await readdir(apiRoot, { withFileTypes: true });
229
- return (await Promise.all(entries.filter((item) => item.isDirectory()).sort((a, b) => a.name.localeCompare(b.name)).map((entry) => collectModuleModelSchemaExports(apiRoot, entry.name, options)))).flat();
224
+ return (await Promise.all(entries.filter((item) => item.isDirectory()).sort((a, b) => a.name.localeCompare(b.name)).map((entry) => collectModuleModelSchemaExports(apiRoot, entry.name)))).flat();
230
225
  }
231
- async function collectModuleModelSchemaExports(apiRoot, moduleName, options = {}) {
226
+ async function collectModuleModelSchemaExports(apiRoot, moduleName) {
232
227
  const modelsPath = join(apiRoot, moduleName, `${moduleName}.models.ts`);
233
228
  try {
234
229
  await access(modelsPath);
@@ -242,7 +237,7 @@ async function collectModuleModelSchemaExports(apiRoot, moduleName, options = {}
242
237
  const schemas = [];
243
238
  for (const [exportName, schema] of Object.entries(models)) if (exportName.endsWith("Schema") && isZodSchema(schema)) schemas.push({
244
239
  moduleName,
245
- name: schemaExportName(moduleName, exportName, schema, options.getOpenApiSchemaName),
240
+ name: modelSchemaExportName(exportName),
246
241
  schema
247
242
  });
248
243
  return schemas;
@@ -298,23 +293,35 @@ function getObjectPropertySchema(schema, property) {
298
293
  const propertySchema = shape[property];
299
294
  return isZodSchema(propertySchema) ? propertySchema : void 0;
300
295
  }
296
+ function routeHasPathParameters(routePath) {
297
+ return typeof routePath === "string" && /\{[^}]+\}/u.test(routePath);
298
+ }
299
+ function getProcedureInputSchemaRole(route) {
300
+ if (routeHasPathParameters(route.path)) return "Params";
301
+ return route.method?.toUpperCase() === "GET" ? "Query" : "Request";
302
+ }
303
+ function procedureSchemaName(procedureName, role) {
304
+ if (procedureName.endsWith(role)) return procedureName;
305
+ return `${procedureName}${role}`;
306
+ }
307
+ function addContractSchema(schemas, schema, name, getSchemaName, strategy) {
308
+ if (!schema) return;
309
+ schemas[getSchemaName(schema) ?? name] = {
310
+ schema,
311
+ ...strategy ? { strategy } : {}
312
+ };
313
+ }
301
314
  function collectContractSchemas(router, routerPath = [], schemas = {}, getSchemaName = getOpenApiSchemaName) {
302
315
  const procedure = getContractProcedureData(router);
303
316
  if (procedure) {
304
317
  const procedureName = routerPath.map(toPascalCase).join("");
305
318
  const { inputSchema, outputSchema, route } = procedure;
306
- if (inputSchema) {
307
- const schema = route.inputStructure === "detailed" ? getObjectPropertySchema(inputSchema, "body") ?? inputSchema : inputSchema;
308
- const inputName = getSchemaName(schema) ?? dtoSchemaName(`${procedureName}Input`);
309
- schemas[inputName] = { schema };
310
- }
311
- if (outputSchema && route.successStatus !== 204) {
312
- const outputName = getSchemaName(outputSchema) ?? dtoSchemaName(`${procedureName}Output`);
313
- schemas[outputName] = {
314
- schema: outputSchema,
315
- strategy: "output"
316
- };
317
- }
319
+ if (inputSchema) if (route.inputStructure === "detailed") {
320
+ addContractSchema(schemas, getObjectPropertySchema(inputSchema, "params"), procedureSchemaName(procedureName, "Params"), getSchemaName);
321
+ addContractSchema(schemas, getObjectPropertySchema(inputSchema, "query"), procedureSchemaName(procedureName, "Query"), getSchemaName);
322
+ addContractSchema(schemas, getObjectPropertySchema(inputSchema, "body") ?? inputSchema, procedureSchemaName(procedureName, "Request"), getSchemaName);
323
+ } else addContractSchema(schemas, inputSchema, procedureSchemaName(procedureName, getProcedureInputSchemaRole(route)), getSchemaName);
324
+ if (outputSchema && route.successStatus !== 204) addContractSchema(schemas, outputSchema, procedureSchemaName(procedureName, "Response"), getSchemaName, "output");
318
325
  return schemas;
319
326
  }
320
327
  for (const [name, child] of routerEntries(router)) collectContractSchemas(child, [...routerPath, name], schemas, getSchemaName);
@@ -359,18 +366,25 @@ function collectSchemaRegistryRoots(registry) {
359
366
  return schemas;
360
367
  }, /* @__PURE__ */ new Set());
361
368
  }
369
+ function modelSchemaNameEntries(modelSchemas) {
370
+ const schemaNameBySchema = /* @__PURE__ */ new Map();
371
+ for (const { name, schema } of modelSchemas) {
372
+ const existingName = schemaNameBySchema.get(schema);
373
+ if (!existingName || name.length < existingName.length) schemaNameBySchema.set(schema, name);
374
+ }
375
+ return schemaNameBySchema;
376
+ }
377
+ function createModelSchemaNameGetter(modelSchemas, getSchemaName = getOpenApiSchemaName) {
378
+ const schemaNameBySchema = modelSchemaNameEntries(modelSchemas);
379
+ return (schema) => (isZodSchema(schema) ? schemaNameBySchema.get(schema) : void 0) ?? getSchemaName(schema);
380
+ }
362
381
  async function collectReachableModelSchemas(router, options = {}) {
363
382
  const excludedSchemas = options.excludedSchemas ?? /* @__PURE__ */ new Set();
364
- const modelSchemas = await collectModelSchemaExports(options);
365
- const schemaNameBySchema = /* @__PURE__ */ new Map();
383
+ const modelSchemas = options.modelSchemas ?? await collectModelSchemaExports(options);
384
+ const schemaNameBySchema = modelSchemaNameEntries(modelSchemas);
366
385
  const routeRoots = collectContractSchemaRoots(router);
367
386
  const reachableSchemas = {};
368
387
  for (const { moduleName, name, schema } of modelSchemas) if ((moduleName === "common" || name.endsWith("SortableKey") || name.endsWith("OrderParamEnum")) && !excludedSchemas.has(schema)) reachableSchemas[name] = { schema };
369
- for (const { name, schema } of modelSchemas) {
370
- const existingName = schemaNameBySchema.get(schema);
371
- if (!existingName) schemaNameBySchema.set(schema, name);
372
- else if (existingName !== name) schemaNameBySchema.set(schema, existingName.length <= name.length ? existingName : name);
373
- }
374
388
  for (const root of routeRoots) {
375
389
  if (!isZodSchema(root)) continue;
376
390
  visitZodSchema(root, (schema) => {
@@ -575,14 +589,20 @@ function toOpenAPI30Document(spec) {
575
589
  async function generateORPCOpenAPISpec(options) {
576
590
  const [{ OpenAPIGenerator }, { ZodToJsonSchemaConverter }] = await Promise.all([importRuntimeModule("@orpc/openapi"), importRuntimeModule("@orpc/zod/zod4")]);
577
591
  const generator = new OpenAPIGenerator({ schemaConverters: [new ZodToJsonSchemaConverter()] });
578
- const getSchemaName = options.getOpenApiSchemaName ?? getOpenApiSchemaName;
592
+ const explicitSchemaName = options.getOpenApiSchemaName ?? getOpenApiSchemaName;
593
+ const modelSchemas = await collectModelSchemaExports({
594
+ apiRoot: options.apiRoot,
595
+ dbTablesRoot: options.dbTablesRoot
596
+ });
597
+ const getSchemaName = createModelSchemaNameGetter(modelSchemas, explicitSchemaName);
579
598
  const operationMeta = collectOperationMeta(options.contract);
580
599
  const extraSchemas = collectExtraSchemas(options.apiModules);
581
600
  const reachableModelSchemas = await collectReachableModelSchemas(options.contract, {
582
601
  apiRoot: options.apiRoot,
583
602
  dbTablesRoot: options.dbTablesRoot,
584
603
  excludedSchemas: collectSchemaRegistryRoots(extraSchemas),
585
- getOpenApiSchemaName: getSchemaName
604
+ getOpenApiSchemaName: getSchemaName,
605
+ modelSchemas
586
606
  });
587
607
  const commonSchemas = {
588
608
  ...collectContractSchemas(options.contract, [], {}, getSchemaName),
@@ -628,4 +648,4 @@ async function generateORPCOpenAPISpec(options) {
628
648
  }
629
649
 
630
650
  //#endregion
631
- export { applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createTinyOpenApiSourceRunner, defineOpenApiSchemas, dtoSchemaName, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, resolveOpenApiOutputPath, schemaComponentRef, schemaExportName, sharedSchemaExportName, shouldUseDtoSchemaName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
651
+ export { addContractSchema, applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createModelSchemaNameGetter, createTinyOpenApiSourceRunner, defineOpenApiSchemas, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getProcedureInputSchemaRole, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, modelSchemaExportName, modelSchemaNameEntries, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, procedureSchemaName, resolveOpenApiOutputPath, routeHasPathParameters, schemaComponentRef, schemaExportName, sharedSchemaExportName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { r as GenerateFileFormatter } from "./options-CE4Koxof.mjs";
2
2
  import { t as OpenAPICodegenConfig } from "./config-BU7wVf7U.mjs";
3
- import { a as GenerateOpenApiFile } from "./openapi-B14GzSA_.mjs";
3
+ import { a as GenerateOpenApiFile } from "./openapi-BkC5yZ-W.mjs";
4
4
  import { Plugin, PluginOption } from "vite";
5
5
 
6
6
  //#region src/plugins/openapi-codegen.runner.d.ts
package/package.json CHANGED
@@ -138,5 +138,5 @@
138
138
  "pnpm": ">= 9"
139
139
  },
140
140
  "packageManager": "pnpm@10.4.0",
141
- "version": "3.1.0-rc.1"
141
+ "version": "3.1.0-rc.3"
142
142
  }