@rexeus/typeweaver-hono 0.10.0 → 0.10.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/dist/index.cjs +2 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ function writeHonoRouter(resource, templateFile, context) {
|
|
|
38
38
|
const outputPath = node_path.default.join(outputDir, `${pascalCaseEntityName}Hono.ts`);
|
|
39
39
|
const operations = resource.operations.filter((operation) => operation.method !== _rexeus_typeweaver_core.HttpMethod.HEAD).map((operation) => createOperationData(operation)).sort((a, b) => (0, _rexeus_typeweaver_gen.compareRoutes)(a, b));
|
|
40
40
|
const content = context.renderTemplate(templateFile, {
|
|
41
|
-
coreDir:
|
|
41
|
+
coreDir: (0, _rexeus_typeweaver_gen.relative)(outputDir, context.outputDir),
|
|
42
42
|
entityName: resource.name,
|
|
43
43
|
pascalCaseEntityName,
|
|
44
44
|
operations
|
|
@@ -62,6 +62,7 @@ function createOperationData(operation) {
|
|
|
62
62
|
const moduleDir = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
63
63
|
var HonoPlugin = class extends _rexeus_typeweaver_gen.BasePlugin {
|
|
64
64
|
name = "hono";
|
|
65
|
+
depends = ["types"];
|
|
65
66
|
generate(context) {
|
|
66
67
|
const libSourceDir = node_path.default.join(moduleDir, "lib");
|
|
67
68
|
this.copyLibFiles(context, libSourceDir, this.name);
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAQa,UAAA,SAAmB,UAAA;EACvB,IAAA;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAQa,UAAA,SAAmB,UAAA;EACvB,IAAA;EACS,OAAA;EAEA,QAAA,CAAS,OAAA,EAAS,gBAAA;AAAA"}
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAQa,UAAA,SAAmB,UAAA;EACvB,IAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAQa,UAAA,SAAmB,UAAA;EACvB,IAAA;EACS,OAAA;EAEA,QAAA,CAAS,OAAA,EAAS,gBAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { BasePlugin, compareRoutes, toPascalCase } from "@rexeus/typeweaver-gen";
|
|
3
|
+
import { BasePlugin, compareRoutes, relative, toPascalCase } from "@rexeus/typeweaver-gen";
|
|
4
4
|
import { HttpMethod } from "@rexeus/typeweaver-core";
|
|
5
5
|
//#region src/honoRouterGenerator.ts
|
|
6
6
|
function generate(context) {
|
|
@@ -14,7 +14,7 @@ function writeHonoRouter(resource, templateFile, context) {
|
|
|
14
14
|
const outputPath = path.join(outputDir, `${pascalCaseEntityName}Hono.ts`);
|
|
15
15
|
const operations = resource.operations.filter((operation) => operation.method !== HttpMethod.HEAD).map((operation) => createOperationData(operation)).sort((a, b) => compareRoutes(a, b));
|
|
16
16
|
const content = context.renderTemplate(templateFile, {
|
|
17
|
-
coreDir:
|
|
17
|
+
coreDir: relative(outputDir, context.outputDir),
|
|
18
18
|
entityName: resource.name,
|
|
19
19
|
pascalCaseEntityName,
|
|
20
20
|
operations
|
|
@@ -38,6 +38,7 @@ function createOperationData(operation) {
|
|
|
38
38
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
39
39
|
var HonoPlugin = class extends BasePlugin {
|
|
40
40
|
name = "hono";
|
|
41
|
+
depends = ["types"];
|
|
41
42
|
generate(context) {
|
|
42
43
|
const libSourceDir = path.join(moduleDir, "lib");
|
|
43
44
|
this.copyLibFiles(context, libSourceDir, this.name);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/honoRouterGenerator.ts","../src/index.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { HttpMethod } from \"@rexeus/typeweaver-core\";\nimport { compareRoutes, toPascalCase } from \"@rexeus/typeweaver-gen\";\nimport type {\n GeneratorContext,\n NormalizedOperation,\n NormalizedResource,\n} from \"@rexeus/typeweaver-gen\";\n\nexport function generate(context: GeneratorContext): void {\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const templateFile = path.join(moduleDir, \"templates\", \"HonoRouter.ejs\");\n\n for (const resource of context.normalizedSpec.resources) {\n writeHonoRouter(resource, templateFile, context);\n }\n}\n\nfunction writeHonoRouter(\n resource: NormalizedResource,\n templateFile: string,\n context: GeneratorContext\n): void {\n const pascalCaseEntityName = toPascalCase(resource.name);\n const outputDir = context.getResourceOutputDir(resource.name);\n const outputPath = path.join(outputDir, `${pascalCaseEntityName}Hono.ts`);\n\n const operations = resource.operations\n // Hono handles HEAD requests automatically, so we skip them\n .filter(operation => operation.method !== HttpMethod.HEAD)\n .map(operation => createOperationData(operation))\n .sort((a, b) => compareRoutes(a, b));\n\n const content = context.renderTemplate(templateFile, {\n coreDir:
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/honoRouterGenerator.ts","../src/index.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { HttpMethod } from \"@rexeus/typeweaver-core\";\nimport { compareRoutes, relative, toPascalCase } from \"@rexeus/typeweaver-gen\";\nimport type {\n GeneratorContext,\n NormalizedOperation,\n NormalizedResource,\n} from \"@rexeus/typeweaver-gen\";\n\nexport function generate(context: GeneratorContext): void {\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const templateFile = path.join(moduleDir, \"templates\", \"HonoRouter.ejs\");\n\n for (const resource of context.normalizedSpec.resources) {\n writeHonoRouter(resource, templateFile, context);\n }\n}\n\nfunction writeHonoRouter(\n resource: NormalizedResource,\n templateFile: string,\n context: GeneratorContext\n): void {\n const pascalCaseEntityName = toPascalCase(resource.name);\n const outputDir = context.getResourceOutputDir(resource.name);\n const outputPath = path.join(outputDir, `${pascalCaseEntityName}Hono.ts`);\n\n const operations = resource.operations\n // Hono handles HEAD requests automatically, so we skip them\n .filter(operation => operation.method !== HttpMethod.HEAD)\n .map(operation => createOperationData(operation))\n .sort((a, b) => compareRoutes(a, b));\n\n const content = context.renderTemplate(templateFile, {\n coreDir: relative(outputDir, context.outputDir),\n entityName: resource.name,\n pascalCaseEntityName,\n operations,\n });\n\n const relativePath = path.relative(context.outputDir, outputPath);\n context.writeFile(relativePath, content);\n}\n\nfunction createOperationData(operation: NormalizedOperation) {\n const operationId = operation.operationId;\n const className = toPascalCase(operationId);\n const handlerName = `handle${className}Request`;\n\n return {\n operationId,\n className,\n handlerName,\n method: operation.method,\n path: operation.path,\n };\n}\n","import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { BasePlugin } from \"@rexeus/typeweaver-gen\";\nimport type { GeneratorContext } from \"@rexeus/typeweaver-gen\";\nimport { generate as generateHonoRouters } from \"./honoRouterGenerator\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport class HonoPlugin extends BasePlugin {\n public name = \"hono\";\n public override depends = [\"types\"];\n\n public override generate(context: GeneratorContext): void {\n const libSourceDir = path.join(moduleDir, \"lib\");\n this.copyLibFiles(context, libSourceDir, this.name);\n\n generateHonoRouters(context);\n }\n}\n"],"mappings":";;;;;AAUA,SAAgB,SAAS,SAAi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rexeus/typeweaver-hono",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Generates Hono routers and handlers straight from your API definitions. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"hono": "^4.11.0",
|
|
50
|
-
"@rexeus/typeweaver-core": "^0.10.
|
|
51
|
-
"@rexeus/typeweaver-gen": "^0.10.
|
|
50
|
+
"@rexeus/typeweaver-core": "^0.10.1",
|
|
51
|
+
"@rexeus/typeweaver-gen": "^0.10.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"hono": "^4.12.9",
|
|
55
55
|
"test-utils": "file:../test-utils",
|
|
56
|
-
"@rexeus/typeweaver-
|
|
57
|
-
"@rexeus/typeweaver-
|
|
56
|
+
"@rexeus/typeweaver-core": "^0.10.1",
|
|
57
|
+
"@rexeus/typeweaver-gen": "^0.10.1"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|
|
61
61
|
"format": "oxfmt",
|
|
62
|
-
"build": "tsdown
|
|
62
|
+
"build": "tsdown",
|
|
63
63
|
"test": "vitest --run",
|
|
64
64
|
"preversion": "npm run build"
|
|
65
65
|
}
|