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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -287,6 +287,51 @@ export default defineConfig({
287
287
  The plugin runs on both `vite serve` and `vite build`, and watches local OpenAPI files in dev mode.
288
288
  If you provide `formatGeneratedFile`, the plugin formats each generated file in memory before comparing and writing it, which helps avoid unnecessary HMR when the formatted output is unchanged.
289
289
 
290
+ For Tiny projects that generate the OpenAPI JSON from ORPC before client codegen, use the wrapper plugin:
291
+
292
+ ```ts
293
+ import { defineConfig } from "vite";
294
+ import { generateOpenApiFile as writeOpenApiFile, generateORPCOpenAPISpec } from "@povio/openapi-codegen-cli/tiny";
295
+ import { tinyOpenApiCodegen } from "@povio/openapi-codegen-cli/vite";
296
+ import { apiModules } from "../packages/fake-be/src/orpc/api/modules";
297
+ import { contract } from "../packages/fake-be/src/orpc/api/contract";
298
+ import { getOpenApiSchemaName } from "../packages/fake-be/src/orpc/spec";
299
+ import { userRoles } from "../packages/fake-be/src/roles";
300
+
301
+ const generateOpenApiFile = (options) =>
302
+ writeOpenApiFile({
303
+ ...options,
304
+ generateOpenApiSpec: () =>
305
+ generateORPCOpenAPISpec({
306
+ contract,
307
+ apiModules,
308
+ userRoles,
309
+ apiRoot: "../packages/fake-be/src/orpc/api",
310
+ dbTablesRoot: "../packages/fake-be/src/db/tables",
311
+ getOpenApiSchemaName,
312
+ }),
313
+ });
314
+
315
+ export default defineConfig({
316
+ plugins: [
317
+ tinyOpenApiCodegen(
318
+ {
319
+ input: "./openapi.generated.json",
320
+ output: "./src/data",
321
+ inlineEndpoints: true,
322
+ incremental: true,
323
+ },
324
+ {
325
+ generateOpenApiFile,
326
+ watchFolders: ["../packages/fake-be/src/orpc", "../packages/fake-be/src/db"],
327
+ },
328
+ ),
329
+ ],
330
+ });
331
+ ```
332
+
333
+ When `VITE_PUBLIC_API_MODE` or `EXPO_PUBLIC_API_MODE` is `real`, the Tiny wrapper skips ORPC OpenAPI generation and behaves like `openApiCodegen`.
334
+
290
335
  ### Metro Plugin
291
336
 
292
337
  You can run codegen directly from React Native Metro config:
@@ -318,6 +363,49 @@ export default withOpenApiCodegen(
318
363
  The Metro wrapper runs generation when the config is loaded, waits for it before Metro transforms or serves the first request, and watches local OpenAPI files while the dev server is running.
319
364
  If you provide `formatGeneratedFile`, it behaves the same way as the Vite plugin.
320
365
 
366
+ For Tiny projects, use the Metro wrapper:
367
+
368
+ ```ts
369
+ import { getDefaultConfig } from "@react-native/metro-config";
370
+ import { generateOpenApiFile as writeOpenApiFile, generateORPCOpenAPISpec } from "@povio/openapi-codegen-cli/tiny";
371
+ import { tinyOpenApiCodegenMetro } from "@povio/openapi-codegen-cli/metro";
372
+ import { apiModules } from "../../packages/fake-be/src/orpc/api/modules";
373
+ import { contract } from "../../packages/fake-be/src/orpc/api/contract";
374
+ import { getOpenApiSchemaName } from "../../packages/fake-be/src/orpc/spec";
375
+ import { userRoles } from "../../packages/fake-be/src/roles";
376
+
377
+ const root = __dirname;
378
+ const config = getDefaultConfig(root);
379
+ const generateOpenApiFile = (options) =>
380
+ writeOpenApiFile({
381
+ ...options,
382
+ generateOpenApiSpec: () =>
383
+ generateORPCOpenAPISpec({
384
+ contract,
385
+ apiModules,
386
+ userRoles,
387
+ apiRoot: "../../packages/fake-be/src/orpc/api",
388
+ dbTablesRoot: "../../packages/fake-be/src/db/tables",
389
+ getOpenApiSchemaName,
390
+ }),
391
+ });
392
+
393
+ export default tinyOpenApiCodegenMetro(
394
+ config,
395
+ {
396
+ input: "./assets/openapi/main.json",
397
+ output: "./utils/rest/openapi",
398
+ inlineEndpoints: true,
399
+ incremental: true,
400
+ },
401
+ {
402
+ root,
403
+ generateOpenApiFile,
404
+ watchFolders: ["../../packages/fake-be/src/orpc", "../../packages/fake-be/src/db"],
405
+ },
406
+ );
407
+ ```
408
+
321
409
  ### Enums
322
410
 
323
411
  If you're using Enums in your backend DTOs with `@Expose()` and `@IsEnum`, they may still not appear correctly in the OpenAPI schema unless you also provide both `enum` **and** `enumName` to `@ApiProperty`.
package/dist/acl.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ErrorHandler } from "./error-handling-oM5YJYYH.mjs";
1
+ import { a as ErrorHandler } from "./error-handling-CDeKUFHF.mjs";
2
2
  import * as react from "react";
3
3
  import { PropsWithChildren } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { t as GenerateOptions } from "./options-BZOw7Hx4.mjs";
1
+ import { t as GenerateOptions } from "./options-CE4Koxof.mjs";
2
2
 
3
3
  //#region src/generators/types/config.d.ts
4
4
  type OpenAPICodegenConfig = Partial<GenerateOptions>;
@@ -1,4 +1,4 @@
1
- import { n as GenerateFileData, t as GenerateOptions } from "./options-BZOw7Hx4.mjs";
1
+ import { n as GenerateFileData, t as GenerateOptions } from "./options-CE4Koxof.mjs";
2
2
  import { OpenAPIV3 } from "openapi-types";
3
3
 
4
4
  //#region src/generators/types/metadata.d.ts
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as ErrorHandler, c as SharedErrorHandler, i as ErrorEntry, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-oM5YJYYH.mjs";
2
- import "./options-BZOw7Hx4.mjs";
3
- import { t as OpenAPICodegenConfig } from "./config-CrZa_Jbm.mjs";
1
+ import { a as ErrorHandler, c as SharedErrorHandler, i as ErrorEntry, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-CDeKUFHF.mjs";
2
+ import "./options-CE4Koxof.mjs";
3
+ import { t as OpenAPICodegenConfig } from "./config-BU7wVf7U.mjs";
4
4
  import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
5
5
  import { z } from "zod";
6
6
  import "i18next";
package/dist/metro.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { r as GenerateFileFormatter } from "./options-BZOw7Hx4.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-CrZa_Jbm.mjs";
1
+ import { r as GenerateFileFormatter } from "./options-CE4Koxof.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-BU7wVf7U.mjs";
3
+ import { a as GenerateOpenApiFile } from "./openapi-B14GzSA_.mjs";
3
4
  import { IncomingMessage, ServerResponse } from "http";
4
5
 
5
6
  //#region src/metro/openapi-codegen.plugin.d.ts
@@ -29,4 +30,16 @@ type MetroConfig = {
29
30
  declare function withOpenApiCodegen<TMetroConfig extends MetroConfig>(metroConfig: Promise<TMetroConfig>, codegenConfig: OpenApiCodegenMetroConfig, options?: OpenApiCodegenMetroOptions): Promise<TMetroConfig>;
30
31
  declare function withOpenApiCodegen<TMetroConfig extends MetroConfig>(metroConfig: TMetroConfig, codegenConfig: OpenApiCodegenMetroConfig, options?: OpenApiCodegenMetroOptions): TMetroConfig;
31
32
  //#endregion
32
- export { type MetroConfig, type MetroMiddleware, type OpenAPICodegenConfig, type OpenApiCodegenMetroConfig, type OpenApiCodegenMetroOptions, withOpenApiCodegen };
33
+ //#region src/metro/tiny-openapi-codegen.plugin.d.ts
34
+ interface TinyOpenApiCodegenMetroOptions extends OpenApiCodegenMetroOptions {
35
+ apiMode?: string;
36
+ cwd?: string;
37
+ env?: NodeJS.ProcessEnv;
38
+ generateOpenApiFile: GenerateOpenApiFile;
39
+ watchFolders: readonly string[];
40
+ watchTinyOpenApiInput?: boolean;
41
+ }
42
+ declare function tinyOpenApiCodegenMetro<TMetroConfig extends MetroConfig>(metroConfig: Promise<TMetroConfig>, codegenConfig: OpenApiCodegenMetroConfig, options: TinyOpenApiCodegenMetroOptions): Promise<TMetroConfig>;
43
+ declare function tinyOpenApiCodegenMetro<TMetroConfig extends MetroConfig>(metroConfig: TMetroConfig, codegenConfig: OpenApiCodegenMetroConfig, options: TinyOpenApiCodegenMetroOptions): TMetroConfig;
44
+ //#endregion
45
+ export { type MetroConfig, type MetroMiddleware, type OpenAPICodegenConfig, type OpenApiCodegenMetroConfig, type OpenApiCodegenMetroOptions, type TinyOpenApiCodegenMetroOptions, tinyOpenApiCodegenMetro, withOpenApiCodegen };
package/dist/metro.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  import "./generateCodeFromOpenAPIDoc-C-n0Knj8.mjs";
2
2
  import "./generate.runner-BXTc97I0.mjs";
3
3
  import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-QGd35-a3.mjs";
4
+ import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-D19XnvMe.mjs";
4
5
  import fs from "fs";
5
6
  import path from "path";
6
7
 
7
8
  //#region src/metro/openapi-codegen.plugin.ts
8
9
  function withOpenApiCodegen(metroConfig, codegenConfig, options = {}) {
9
- if (isPromiseLike(metroConfig)) return metroConfig.then((resolvedConfig) => withResolvedOpenApiCodegen(resolvedConfig, codegenConfig, options));
10
+ if (isPromiseLike$1(metroConfig)) return metroConfig.then((resolvedConfig) => withResolvedOpenApiCodegen(resolvedConfig, codegenConfig, options));
10
11
  return withResolvedOpenApiCodegen(metroConfig, codegenConfig, options);
11
12
  }
12
13
  function withResolvedOpenApiCodegen(metroConfig, codegenConfig, options) {
@@ -37,11 +38,11 @@ function withResolvedOpenApiCodegen(metroConfig, codegenConfig, options) {
37
38
  try {
38
39
  inputWatcher = fs.watch(inputPath, { persistent: false }, () => {
39
40
  startupSucceeded = false;
40
- requestStartupGenerate().catch(reportGenerateError);
41
+ requestStartupGenerate().catch(reportGenerateError$1);
41
42
  });
42
- inputWatcher.on("error", reportWatcherError);
43
+ inputWatcher.on("error", reportWatcherError$1);
43
44
  } catch (error) {
44
- reportWatcherError(error);
45
+ reportWatcherError$1(error);
45
46
  }
46
47
  };
47
48
  const wrappedConfig = {
@@ -72,15 +73,113 @@ function withResolvedOpenApiCodegen(metroConfig, codegenConfig, options) {
72
73
  if (options.root || metroConfig.projectRoot) wrappedConfig.projectRoot = root;
73
74
  return wrappedConfig;
74
75
  }
76
+ function isPromiseLike$1(value) {
77
+ return typeof value.then === "function";
78
+ }
79
+ function reportGenerateError$1(error) {
80
+ console.error("[openapi-codegen] Failed to generate OpenAPI client from Metro config.", error);
81
+ }
82
+ function reportWatcherError$1(error) {
83
+ console.error("[openapi-codegen] Failed to watch OpenAPI input from Metro config.", error);
84
+ }
85
+
86
+ //#endregion
87
+ //#region src/metro/tiny-openapi-codegen.plugin.ts
88
+ const watchedEvents = new Set(["change", "rename"]);
89
+ function tinyOpenApiCodegenMetro(metroConfig, codegenConfig, options) {
90
+ if (isPromiseLike(metroConfig)) return metroConfig.then((resolvedConfig) => withResolvedTinyOpenApiCodegen(resolvedConfig, codegenConfig, options));
91
+ return withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options);
92
+ }
93
+ function withResolvedTinyOpenApiCodegen(metroConfig, codegenConfig, options) {
94
+ if (!isTinyOpenApiFakeMode(options.apiMode)) return withOpenApiCodegen(metroConfig, codegenConfig, options);
95
+ const root = path.resolve(options.root ?? metroConfig.projectRoot ?? process.cwd());
96
+ const sourceRunner = createTinyOpenApiSourceRunner({
97
+ cwd: options.cwd,
98
+ env: options.env,
99
+ generateOpenApiFile: options.generateOpenApiFile,
100
+ input: codegenConfig.input,
101
+ root
102
+ });
103
+ const codegenRunner = createOpenApiCodegenRunner(codegenConfig);
104
+ const originalEnhanceMiddleware = metroConfig.server?.enhanceMiddleware;
105
+ const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
106
+ let startupSucceeded = false;
107
+ let inflightGenerate;
108
+ let watcherReady = false;
109
+ const requestGenerateAll = () => {
110
+ if (startupSucceeded) return Promise.resolve();
111
+ if (inflightGenerate) return inflightGenerate;
112
+ const attempt = sourceRunner.enqueueGenerate().then(() => codegenRunner.enqueueGenerate(root)).then(() => {
113
+ startupSucceeded = true;
114
+ inflightGenerate = void 0;
115
+ }, (error) => {
116
+ inflightGenerate = void 0;
117
+ throw error;
118
+ });
119
+ inflightGenerate = attempt;
120
+ return attempt;
121
+ };
122
+ const requestSourceChangeGenerate = () => {
123
+ startupSucceeded = false;
124
+ return requestGenerateAll();
125
+ };
126
+ const ensureWatcher = () => {
127
+ if (watcherReady || options.watchTinyOpenApiInput === false) return;
128
+ watcherReady = true;
129
+ normalizeWatchFolders(root, options.watchFolders).flatMap(watchPath);
130
+ };
131
+ const enhancedConfig = {
132
+ ...metroConfig,
133
+ server: {
134
+ ...metroConfig.server,
135
+ enhanceMiddleware(middleware, server) {
136
+ ensureWatcher();
137
+ const enhancedMiddleware = originalEnhanceMiddleware ? originalEnhanceMiddleware(middleware, server) : middleware;
138
+ return async (request, response, next) => {
139
+ try {
140
+ await requestGenerateAll();
141
+ return await enhancedMiddleware(request, response, next);
142
+ } catch (error) {
143
+ next(error);
144
+ }
145
+ };
146
+ }
147
+ },
148
+ transformer: {
149
+ ...metroConfig.transformer,
150
+ async getTransformOptions(...args) {
151
+ await requestGenerateAll();
152
+ return originalGetTransformOptions ? originalGetTransformOptions(...args) : void 0;
153
+ }
154
+ }
155
+ };
156
+ if (options.root || metroConfig.projectRoot) enhancedConfig.projectRoot = root;
157
+ return enhancedConfig;
158
+ function watchPath(target) {
159
+ try {
160
+ const watcher = fs.watch(target, {
161
+ persistent: false,
162
+ recursive: fs.existsSync(target) && fs.statSync(target).isDirectory()
163
+ }, (event) => {
164
+ if (watchedEvents.has(event)) requestSourceChangeGenerate().catch(reportGenerateError);
165
+ });
166
+ watcher.on("error", reportWatcherError);
167
+ return [watcher];
168
+ } catch (error) {
169
+ reportWatcherError(error);
170
+ return [];
171
+ }
172
+ }
173
+ }
75
174
  function isPromiseLike(value) {
76
175
  return typeof value.then === "function";
77
176
  }
78
177
  function reportGenerateError(error) {
79
- console.error("[openapi-codegen] Failed to generate OpenAPI client from Metro config.", error);
178
+ console.error("[tiny-openapi] Failed to generate OpenAPI spec from Metro config.", error);
80
179
  }
81
180
  function reportWatcherError(error) {
82
- console.error("[openapi-codegen] Failed to watch OpenAPI input from Metro config.", error);
181
+ console.error("[tiny-openapi] Failed to watch OpenAPI inputs from Metro config.", error);
83
182
  }
84
183
 
85
184
  //#endregion
86
- export { withOpenApiCodegen };
185
+ export { tinyOpenApiCodegenMetro, withOpenApiCodegen };
@@ -0,0 +1,170 @@
1
+ //#region src/tiny/openapi.d.ts
2
+ interface GenerateOpenApiFileOptions {
3
+ argv?: readonly string[];
4
+ cwd?: string;
5
+ defaultOutput: string;
6
+ env?: NodeJS.ProcessEnv;
7
+ }
8
+ interface GenerateTinyOpenApiFileOptions extends GenerateOpenApiFileOptions {
9
+ generateOpenApiSpec: () => Promise<unknown> | unknown;
10
+ }
11
+ interface GenerateOpenApiFileResult {
12
+ changed: boolean;
13
+ outputPath: string;
14
+ }
15
+ type GenerateOpenApiFile = (options: GenerateOpenApiFileOptions) => Promise<unknown> | unknown;
16
+ type JsonObject = Record<string, unknown>;
17
+ type AnySchema = unknown;
18
+ type AnyContractRouter = unknown;
19
+ type OpenApiSchemaRegistry = Record<string, {
20
+ schema?: AnySchema;
21
+ strategy?: "input" | "output";
22
+ }>;
23
+ type AclRule = `${string}:${string}`;
24
+ type ZodSchema = AnySchema & {
25
+ _zod: {
26
+ def: JsonObject;
27
+ };
28
+ };
29
+ interface ProcedureMeta {
30
+ bl: string;
31
+ acl?: AclRule[];
32
+ }
33
+ interface TinyOpenApiUserRole {
34
+ description?: string;
35
+ isDefault?: boolean;
36
+ name: string;
37
+ }
38
+ interface TinyOpenApiModule {
39
+ extraSchemas?: OpenApiSchemaRegistry;
40
+ openApiController?: string;
41
+ openApiTag?: string;
42
+ robodevHidden?: boolean;
43
+ robodevOwnedTables?: readonly string[];
44
+ robodevRoles?: readonly string[];
45
+ }
46
+ interface GenerateORPCOpenAPISpecOptions {
47
+ apiModules: Record<string, TinyOpenApiModule>;
48
+ apiRoot?: string;
49
+ contract: AnyContractRouter;
50
+ dbTablesRoot?: string;
51
+ getOpenApiSchemaName?: (schema: unknown) => string | undefined;
52
+ info?: JsonObject;
53
+ realBackendSortableSchemaNames?: ReadonlyMap<string, string> | Record<string, string>;
54
+ servers?: JsonObject[];
55
+ userRoles?: readonly TinyOpenApiUserRole[];
56
+ }
57
+ interface ModelSchemaExport {
58
+ moduleName: string;
59
+ name: string;
60
+ schema: ZodSchema;
61
+ }
62
+ interface OperationContractInfo {
63
+ meta: ProcedureMeta;
64
+ path: string[];
65
+ routeOperationId?: string;
66
+ }
67
+ interface OrpcContractProcedureData {
68
+ inputSchema?: AnySchema;
69
+ meta?: unknown;
70
+ outputSchema?: AnySchema;
71
+ route: {
72
+ inputStructure?: string;
73
+ method?: string;
74
+ operationId?: string;
75
+ path?: string;
76
+ successStatus?: number;
77
+ };
78
+ }
79
+ declare function resolveOpenApiOutputPath({
80
+ argv,
81
+ cwd,
82
+ defaultOutput,
83
+ env
84
+ }: GenerateOpenApiFileOptions): string;
85
+ declare function generateOpenApiFile(options: GenerateTinyOpenApiFileOptions): Promise<GenerateOpenApiFileResult>;
86
+ declare function defineOpenApiSchemas<const TSchemas extends OpenApiSchemaRegistry>(schemas: TSchemas): TSchemas;
87
+ declare function collectExtraSchemas<TModules extends Record<string, {
88
+ extraSchemas?: OpenApiSchemaRegistry;
89
+ }>>(modules: TModules): OpenApiSchemaRegistry;
90
+ declare function namedOpenApiSchema<TSchema extends object>(schema: TSchema, name: string): TSchema;
91
+ declare function namedOpenApiRequestSchema<TSchema extends object>(schema: TSchema, name: string): TSchema;
92
+ declare function namedOpenApiResponseSchema<TSchema extends object>(schema: TSchema, name: string): TSchema;
93
+ declare function namedOpenApiOutputSchema<TSchema extends object>(schema: TSchema, name: string): TSchema;
94
+ declare function namedControllerActionSchema<TSchema extends object>(schema: TSchema, controller: string, action: string, suffix: string): TSchema;
95
+ declare function namedControllerActionInputDtoSchema<TSchema extends object>(schema: TSchema, controller: string, action: string): TSchema;
96
+ declare function getOpenApiSchemaName(schema: unknown): string | undefined;
97
+ declare function isObject(value: unknown): value is JsonObject;
98
+ declare function getContractProcedureData(router: AnyContractRouter): OrpcContractProcedureData | undefined;
99
+ declare function isContractProcedure(router: AnyContractRouter): boolean;
100
+ declare function asStringArray(value: unknown): string[];
101
+ declare function isNullSchema(value: unknown): boolean;
102
+ declare function isNullableOnlySchema(value: unknown): boolean;
103
+ declare function toOpenAPI30Schema(value: unknown): unknown;
104
+ declare function stripNoContentResponseBodies(spec: JsonObject): void;
105
+ declare function isProcedureMeta(meta: unknown): meta is ProcedureMeta;
106
+ declare function operationKey(method: string, routePath: string): string;
107
+ declare function toPascalCase(value: string): string;
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
+ declare function schemaExportName(moduleName: string, exportName: string, schema: ZodSchema, getSchemaName?: typeof getOpenApiSchemaName): string;
112
+ declare function sharedSchemaExportName(exportName: string): string;
113
+ declare function collectModelSchemaExports(options: {
114
+ apiRoot?: string;
115
+ 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
+ }): Promise<ModelSchemaExport[]>;
124
+ declare function collectDbTableModelSchemaExports(tablesRoot: string): Promise<ModelSchemaExport[]>;
125
+ declare function collectDbTableModelSchemaExport(tablesRoot: string, tableName: string): Promise<ModelSchemaExport[]>;
126
+ declare function toOpenAPIAclRule(rule: string): JsonObject;
127
+ declare function collectOperationMeta(router: AnyContractRouter, routerPath?: string[], operationMeta?: Map<string, OperationContractInfo>): Map<string, OperationContractInfo>;
128
+ declare function getObjectPropertySchema(schema: AnySchema, property: string): AnySchema | undefined;
129
+ declare function collectContractSchemas(router: AnyContractRouter, routerPath?: string[], schemas?: OpenApiSchemaRegistry, getSchemaName?: typeof getOpenApiSchemaName): OpenApiSchemaRegistry;
130
+ declare function collectContractSchemaRoots(router: AnyContractRouter, roots?: Set<unknown>): Set<AnySchema>;
131
+ declare function visitZodSchema(schema: ZodSchema, visit: (schema: ZodSchema) => void, seen?: Set<{
132
+ _zod: {
133
+ def: JsonObject;
134
+ };
135
+ }>): void;
136
+ declare function collectSchemaRegistryRoots(registry: OpenApiSchemaRegistry): Set<AnySchema>;
137
+ declare function collectReachableModelSchemas(router: AnyContractRouter, options?: {
138
+ apiRoot?: string;
139
+ dbTablesRoot?: string;
140
+ excludedSchemas?: Set<AnySchema>;
141
+ getOpenApiSchemaName?: (schema: unknown) => string | undefined;
142
+ }): Promise<OpenApiSchemaRegistry>;
143
+ declare function compactTagName(value: string): string;
144
+ declare function getModuleOpenApiController(apiModules: Record<string, TinyOpenApiModule>, moduleName: string): string;
145
+ declare function getOperationController(apiModules: Record<string, TinyOpenApiModule>, operationPath: string[]): string | undefined;
146
+ declare function getOperationAction(operationPath: string[]): string | undefined;
147
+ declare function getDerivedOperationId(apiModules: Record<string, TinyOpenApiModule>, info: OperationContractInfo): string | undefined;
148
+ declare function applyOperationMeta(spec: JsonObject, operationMeta: Map<string, OperationContractInfo>, apiModules: Record<string, TinyOpenApiModule>): void;
149
+ declare function findEnumNames(value: unknown): string[] | undefined;
150
+ declare function getStringEnumValues(schema: JsonObject): string[] | undefined;
151
+ declare function applyEnumExtensions(value: unknown): void;
152
+ declare function findComponentEnumNames(spec: JsonObject, name: string): string[] | undefined;
153
+ declare function applyParameterExtensions(spec: JsonObject, realBackendSortableSchemaNames?: ReadonlyMap<string, string>): void;
154
+ declare function getModuleOpenApiTag(apiModules: Record<string, TinyOpenApiModule>, moduleName: string): string;
155
+ declare function applyRobodevModuleExtensions(spec: JsonObject, moduleExtensions: Map<string, {
156
+ hidden: boolean;
157
+ tables: string[];
158
+ roles: string[];
159
+ }>, apiModules: Record<string, TinyOpenApiModule>): void;
160
+ declare function applyRobodevUserRolesExtension(spec: JsonObject, userRoles?: readonly TinyOpenApiUserRole[]): void;
161
+ declare function collectOperationTags(spec: JsonObject): Set<string>;
162
+ declare function getRobodevModuleRoles(hidden: boolean, explicitRoles: readonly string[] | null, moduleHasOperations: boolean, defaultRoles: readonly string[]): string[];
163
+ declare function schemaComponentRef(name: string): JsonObject;
164
+ declare function getComponentSchemas(spec: JsonObject): JsonObject | null;
165
+ declare function getPaginatedItemSchema(schema: JsonObject): unknown;
166
+ declare function applyPaginatedItemSchemas(spec: JsonObject): void;
167
+ declare function toOpenAPI30Document(spec: JsonObject): JsonObject;
168
+ declare function generateORPCOpenAPISpec(options: GenerateORPCOpenAPISpecOptions): Promise<JsonObject>;
169
+ //#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 };
@@ -0,0 +1,39 @@
1
+ import path from "path";
2
+
3
+ //#region src/tiny/openapi-source.runner.ts
4
+ function createTinyOpenApiSourceRunner(config) {
5
+ let queue = Promise.resolve();
6
+ const getOutputPath = () => getLocalInputPath(config.input, config.root);
7
+ const runGenerate = async () => {
8
+ const outputPath = getOutputPath();
9
+ if (!outputPath) return;
10
+ await config.generateOpenApiFile({
11
+ argv: ["--output", outputPath],
12
+ cwd: config.cwd ?? config.root,
13
+ defaultOutput: outputPath,
14
+ env: config.env ?? process.env
15
+ });
16
+ };
17
+ const enqueueGenerate = () => {
18
+ const run = queue.catch(() => void 0).then(runGenerate);
19
+ queue = run.then(() => void 0, () => void 0);
20
+ return run;
21
+ };
22
+ return {
23
+ enqueueGenerate,
24
+ getOutputPath
25
+ };
26
+ }
27
+ function isTinyOpenApiFakeMode(apiMode = process.env.VITE_PUBLIC_API_MODE ?? process.env.EXPO_PUBLIC_API_MODE) {
28
+ return apiMode !== "real";
29
+ }
30
+ function getLocalInputPath(input, root) {
31
+ if (typeof input !== "string" || /^https?:\/\//i.test(input)) return;
32
+ return path.resolve(root, input);
33
+ }
34
+ function normalizeWatchFolders(root, watchFolders = []) {
35
+ return watchFolders.map((folder) => path.isAbsolute(folder) ? folder : path.resolve(root, folder));
36
+ }
37
+
38
+ //#endregion
39
+ export { normalizeWatchFolders as i, getLocalInputPath as n, isTinyOpenApiFakeMode as r, createTinyOpenApiSourceRunner as t };
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.0.0";
42
+ return "3.1.0-rc.1";
43
43
  }
44
44
 
45
45
  //#endregion
@@ -0,0 +1,21 @@
1
+ import "./options-CE4Koxof.mjs";
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";
4
+
5
+ //#region src/tiny/openapi-source.runner.d.ts
6
+ interface TinyOpenApiSourceRunnerConfig {
7
+ cwd?: string;
8
+ env?: NodeJS.ProcessEnv;
9
+ generateOpenApiFile: GenerateOpenApiFile;
10
+ input: OpenAPICodegenConfig["input"];
11
+ root: string;
12
+ }
13
+ declare function createTinyOpenApiSourceRunner(config: TinyOpenApiSourceRunnerConfig): {
14
+ enqueueGenerate: () => Promise<void>;
15
+ getOutputPath: () => string | undefined;
16
+ };
17
+ declare function isTinyOpenApiFakeMode(apiMode?: string | undefined): boolean;
18
+ declare function getLocalInputPath(input: OpenAPICodegenConfig["input"], root: string): string | undefined;
19
+ declare function normalizeWatchFolders(root: string, watchFolders?: readonly string[]): string[];
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 };