hono-takibi 0.9.24 → 0.9.26
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 +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/core/schema.js +6 -6
- package/dist/vite-plugin/index.d.ts +1 -1
- package/dist/vite-plugin/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ If you use a `.tsp` TypeSpec file, you must set up the TypeSpec environment and
|
|
|
146
146
|
|
|
147
147
|
```ts
|
|
148
148
|
import { defineConfig } from 'vite'
|
|
149
|
-
import HonoTakibiVite from 'hono-takibi/vite-plugin'
|
|
149
|
+
import { HonoTakibiVite } from 'hono-takibi/vite-plugin'
|
|
150
150
|
|
|
151
151
|
export default defineConfig({
|
|
152
152
|
plugins: [
|
package/dist/cli/index.js
CHANGED
|
@@ -83,7 +83,7 @@ export async function honoTakibi() {
|
|
|
83
83
|
return { ok: false, error: configResult.error };
|
|
84
84
|
}
|
|
85
85
|
const c = configResult.value;
|
|
86
|
-
const takibiResult = c['zod-openapi']
|
|
86
|
+
const takibiResult = c['zod-openapi']?.output
|
|
87
87
|
? await takibi(c.input, c['zod-openapi']?.output, c['zod-openapi']?.exportSchema ?? false, c['zod-openapi']?.exportType ?? false, false, // template
|
|
88
88
|
false)
|
|
89
89
|
: undefined;
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type Config = {
|
|
2
2
|
readonly input: `${string}.yaml` | `${string}.json` | `${string}.tsp`;
|
|
3
3
|
readonly 'zod-openapi'?: {
|
|
4
|
-
readonly output
|
|
4
|
+
readonly output?: `${string}.ts`;
|
|
5
5
|
readonly exportType?: boolean;
|
|
6
6
|
readonly exportSchema?: boolean;
|
|
7
7
|
readonly schema?: {
|
package/dist/core/schema.js
CHANGED
|
@@ -26,14 +26,10 @@ export async function schema(input, output, exportType, split) {
|
|
|
26
26
|
if (!schemas) {
|
|
27
27
|
return { ok: false, error: 'No schemas found' };
|
|
28
28
|
}
|
|
29
|
-
const orderedSchemas = resolveSchemasDependencies(schemas);
|
|
30
|
-
if (orderedSchemas.length === 0) {
|
|
31
|
-
return { ok: true, value: 'No schemas found' };
|
|
32
|
-
}
|
|
33
29
|
// split
|
|
34
30
|
if (split) {
|
|
35
31
|
const outDir = output.replace(/\.ts$/, '');
|
|
36
|
-
for (const schemaName of
|
|
32
|
+
for (const schemaName of Object.keys(schemas)) {
|
|
37
33
|
const schema = schemas[schemaName];
|
|
38
34
|
const z = zodToOpenAPI(schema);
|
|
39
35
|
const zs = zodToOpenAPISchema(schemaName, z, true, exportType);
|
|
@@ -58,7 +54,7 @@ export async function schema(input, output, exportType, split) {
|
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
56
|
// index.ts
|
|
61
|
-
const indexBody = `${
|
|
57
|
+
const indexBody = `${Object.keys(schemas)
|
|
62
58
|
.map((n) => `export * from './${lowerFirst(n)}'`)
|
|
63
59
|
.join('\n')}\n`;
|
|
64
60
|
const indexFmt = await fmt(indexBody);
|
|
@@ -78,6 +74,10 @@ export async function schema(input, output, exportType, split) {
|
|
|
78
74
|
value: `Generated schema code written to ${outDir}/*.ts (index.ts included)`,
|
|
79
75
|
};
|
|
80
76
|
}
|
|
77
|
+
const orderedSchemas = resolveSchemasDependencies(schemas);
|
|
78
|
+
if (orderedSchemas.length === 0) {
|
|
79
|
+
return { ok: true, value: 'No schemas found' };
|
|
80
|
+
}
|
|
81
81
|
const schemaDefinitions = orderedSchemas
|
|
82
82
|
.map((schemaName) => {
|
|
83
83
|
const schema = schemas[schemaName];
|
|
@@ -29,7 +29,7 @@ import type { ViteDevServer } from 'vite';
|
|
|
29
29
|
* @param exportSchema - Whether to export Zod schemas.
|
|
30
30
|
* @returns A Vite plugin object.
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export declare function HonoTakibiVite({ input, output, exportType, exportSchema, }: {
|
|
33
33
|
input: `${string}.yaml` | `${string}.json` | `${string}.tsp`;
|
|
34
34
|
output: `${string}.ts`;
|
|
35
35
|
exportType?: boolean;
|
|
@@ -33,7 +33,7 @@ import { parseOpenAPI } from '../openapi/index.js';
|
|
|
33
33
|
* @param exportSchema - Whether to export Zod schemas.
|
|
34
34
|
* @returns A Vite plugin object.
|
|
35
35
|
*/
|
|
36
|
-
export
|
|
36
|
+
export async function HonoTakibiVite({ input, output, exportType = true, exportSchema = true, }) {
|
|
37
37
|
const run = async () => {
|
|
38
38
|
const isYamlOrJsonOrTsp = (i) => i.endsWith('.yaml') || i.endsWith('.json') || i.endsWith('.tsp');
|
|
39
39
|
if (!isYamlOrJsonOrTsp(input)) {
|