@rexeus/typeweaver-hono 0.3.1 → 0.4.0
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 +26 -58
- package/dist/index.js +10 -14
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -1,57 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
29
2
|
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
module.exports = __toCommonJS(index_exports);
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var node_url = require('node:url');
|
|
5
|
+
var typeweaverGen = require('@rexeus/typeweaver-gen');
|
|
6
|
+
var typeweaverCore = require('@rexeus/typeweaver-core');
|
|
7
|
+
var Case = require('case');
|
|
36
8
|
|
|
37
|
-
|
|
38
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
39
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
40
10
|
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
var import_node_url2 = require("node:url");
|
|
44
|
-
var import_typeweaver_gen = require("@rexeus/typeweaver-gen");
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
12
|
+
var Case__default = /*#__PURE__*/_interopDefault(Case);
|
|
45
13
|
|
|
46
|
-
//
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var import_typeweaver_core = require("@rexeus/typeweaver-core");
|
|
50
|
-
var import_case = __toESM(require("case"), 1);
|
|
14
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
|
|
15
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
16
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
51
17
|
var HonoRouterGenerator = class {
|
|
52
18
|
static generate(context) {
|
|
53
|
-
const moduleDir2 =
|
|
54
|
-
const templateFile =
|
|
19
|
+
const moduleDir2 = path__default.default.dirname(node_url.fileURLToPath(importMetaUrl));
|
|
20
|
+
const templateFile = path__default.default.join(moduleDir2, "templates", "HonoRouter.ejs");
|
|
55
21
|
for (const [entityName, entityResource] of Object.entries(
|
|
56
22
|
context.resources.entityResources
|
|
57
23
|
)) {
|
|
@@ -64,22 +30,22 @@ var HonoRouterGenerator = class {
|
|
|
64
30
|
}
|
|
65
31
|
}
|
|
66
32
|
static writeHonoRouter(entityName, templateFile, operationResources, context) {
|
|
67
|
-
const pascalCaseEntityName =
|
|
68
|
-
const outputDir =
|
|
69
|
-
const outputPath =
|
|
70
|
-
const operations = operationResources.filter((resource) => resource.definition.method !==
|
|
33
|
+
const pascalCaseEntityName = Case__default.default.pascal(entityName);
|
|
34
|
+
const outputDir = path__default.default.join(context.outputDir, entityName);
|
|
35
|
+
const outputPath = path__default.default.join(outputDir, `${pascalCaseEntityName}Hono.ts`);
|
|
36
|
+
const operations = operationResources.filter((resource) => resource.definition.method !== typeweaverCore.HttpMethod.HEAD).map((resource) => this.createOperationData(resource)).sort((a, b) => this.compareRoutes(a, b));
|
|
71
37
|
const content = context.renderTemplate(templateFile, {
|
|
72
|
-
coreDir:
|
|
38
|
+
coreDir: path__default.default.relative(outputDir, context.outputDir),
|
|
73
39
|
entityName,
|
|
74
40
|
pascalCaseEntityName,
|
|
75
41
|
operations
|
|
76
42
|
});
|
|
77
|
-
const relativePath =
|
|
43
|
+
const relativePath = path__default.default.relative(context.outputDir, outputPath);
|
|
78
44
|
context.writeFile(relativePath, content);
|
|
79
45
|
}
|
|
80
46
|
static createOperationData(resource) {
|
|
81
47
|
const operationId = resource.definition.operationId;
|
|
82
|
-
const className =
|
|
48
|
+
const className = Case__default.default.pascal(operationId);
|
|
83
49
|
const handlerName = `handle${className}Request`;
|
|
84
50
|
return {
|
|
85
51
|
className,
|
|
@@ -123,12 +89,14 @@ var HonoRouterGenerator = class {
|
|
|
123
89
|
};
|
|
124
90
|
|
|
125
91
|
// src/index.ts
|
|
126
|
-
var moduleDir =
|
|
127
|
-
var HonoPlugin = class extends
|
|
92
|
+
var moduleDir = path__default.default.dirname(node_url.fileURLToPath(importMetaUrl));
|
|
93
|
+
var HonoPlugin = class extends typeweaverGen.BasePlugin {
|
|
128
94
|
name = "hono";
|
|
129
95
|
generate(context) {
|
|
130
|
-
const libSourceDir =
|
|
96
|
+
const libSourceDir = path__default.default.join(moduleDir, "lib");
|
|
131
97
|
this.copyLibFiles(context, libSourceDir, this.name);
|
|
132
98
|
HonoRouterGenerator.generate(context);
|
|
133
99
|
}
|
|
134
100
|
};
|
|
101
|
+
|
|
102
|
+
module.exports = HonoPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { BasePlugin } from '@rexeus/typeweaver-gen';
|
|
4
|
+
import { HttpMethod } from '@rexeus/typeweaver-core';
|
|
5
|
+
import Case from 'case';
|
|
5
6
|
|
|
6
|
-
// src/
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { HttpMethod } from "@rexeus/typeweaver-core";
|
|
10
|
-
import Case from "case";
|
|
7
|
+
// src/index.ts
|
|
11
8
|
var HonoRouterGenerator = class {
|
|
12
9
|
static generate(context) {
|
|
13
10
|
const moduleDir2 = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -83,15 +80,14 @@ var HonoRouterGenerator = class {
|
|
|
83
80
|
};
|
|
84
81
|
|
|
85
82
|
// src/index.ts
|
|
86
|
-
var moduleDir =
|
|
83
|
+
var moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
87
84
|
var HonoPlugin = class extends BasePlugin {
|
|
88
85
|
name = "hono";
|
|
89
86
|
generate(context) {
|
|
90
|
-
const libSourceDir =
|
|
87
|
+
const libSourceDir = path.join(moduleDir, "lib");
|
|
91
88
|
this.copyLibFiles(context, libSourceDir, this.name);
|
|
92
89
|
HonoRouterGenerator.generate(context);
|
|
93
90
|
}
|
|
94
91
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
92
|
+
|
|
93
|
+
export { HonoPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/HonoRouterGenerator.ts":{"bytes":3465,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-core","kind":"import-statement","external":true},{"path":"case","kind":"import-statement","external":true},{"path":"/home/runner/work/typeweaver/typeweaver/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":617,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-gen","kind":"import-statement","external":true},{"path":"src/HonoRouterGenerator.ts","kind":"import-statement","original":"./HonoRouterGenerator"},{"path":"/home/runner/work/typeweaver/typeweaver/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.cjs":{"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-gen","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-core","kind":"import-statement","external":true},{"path":"case","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/index.ts","inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytesInOutput":314},"src/index.ts":{"bytesInOutput":451},"src/HonoRouterGenerator.ts":{"bytesInOutput":2705}},"bytes":3701}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js":{"bytes":322,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true}],"format":"esm"},"src/HonoRouterGenerator.ts":{"bytes":3465,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-core","kind":"import-statement","external":true},{"path":"case","kind":"import-statement","external":true},{"path":"/home/runner/work/typeweaver/typeweaver/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":617,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-gen","kind":"import-statement","external":true},{"path":"src/HonoRouterGenerator.ts","kind":"import-statement","original":"./HonoRouterGenerator"},{"path":"/home/runner/work/typeweaver/typeweaver/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-gen","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@rexeus/typeweaver-core","kind":"import-statement","external":true},{"path":"case","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":453},"src/HonoRouterGenerator.ts":{"bytesInOutput":2707}},"bytes":3260}}}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-hono",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Generates Hono routers and handlers straight from your API definitions. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"main": "dist/index.cjs",
|
|
7
8
|
"module": "dist/index.js",
|
|
8
9
|
"types": "dist/index.d.ts",
|
|
@@ -45,15 +46,15 @@
|
|
|
45
46
|
},
|
|
46
47
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"hono": "^4.11.
|
|
49
|
-
"@rexeus/typeweaver-core": "^0.
|
|
50
|
-
"@rexeus/typeweaver-gen": "^0.
|
|
49
|
+
"hono": "^4.11.0",
|
|
50
|
+
"@rexeus/typeweaver-core": "^0.4.0",
|
|
51
|
+
"@rexeus/typeweaver-gen": "^0.4.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"hono": "^4.11.3",
|
|
54
55
|
"test-utils": "file:../test-utils",
|
|
55
|
-
"@rexeus/typeweaver-core": "^0.
|
|
56
|
-
"@rexeus/typeweaver-gen": "^0.
|
|
56
|
+
"@rexeus/typeweaver-core": "^0.4.0",
|
|
57
|
+
"@rexeus/typeweaver-gen": "^0.4.0"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"case": "^1.6.3"
|