@rexeus/typeweaver-aws-cdk 0.7.0 → 0.9.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/README.md +1 -1
- package/dist/index.cjs +37 -47
- package/dist/index.mjs +31 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ npm install @rexeus/typeweaver-core
|
|
|
28
28
|
## 💡 How to use
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
npx typeweaver generate --input ./api/
|
|
31
|
+
npx typeweaver generate --input ./api/spec/index.ts --output ./api/generated --plugins aws-cdk
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
More details on how to use the
|
package/dist/index.cjs
CHANGED
|
@@ -6,16 +6,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
19
15
|
}
|
|
20
16
|
return to;
|
|
21
17
|
};
|
|
@@ -23,7 +19,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
19
|
value: mod,
|
|
24
20
|
enumerable: true
|
|
25
21
|
}) : target, mod));
|
|
26
|
-
|
|
27
22
|
//#endregion
|
|
28
23
|
let node_path = require("node:path");
|
|
29
24
|
node_path = __toESM(node_path);
|
|
@@ -31,41 +26,37 @@ let node_url = require("node:url");
|
|
|
31
26
|
let _rexeus_typeweaver_gen = require("@rexeus/typeweaver-gen");
|
|
32
27
|
let case$1 = require("case");
|
|
33
28
|
case$1 = __toESM(case$1);
|
|
34
|
-
|
|
35
|
-
//#region src/HttpApiRouterGenerator.ts
|
|
29
|
+
//#region src/httpApiRouterGenerator.ts
|
|
36
30
|
const moduleDir$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
routes[path].push(operation.definition.method);
|
|
51
|
-
}
|
|
52
|
-
const content = context.renderTemplate(templateFile, {
|
|
53
|
-
entityName,
|
|
54
|
-
pascalCaseEntityName,
|
|
55
|
-
routes,
|
|
56
|
-
coreDir: context.coreDir
|
|
57
|
-
});
|
|
58
|
-
const relativePath = node_path.default.relative(context.outputDir, outputFile);
|
|
59
|
-
context.writeFile(relativePath, content);
|
|
31
|
+
function generate(context) {
|
|
32
|
+
const templateFile = node_path.default.join(moduleDir$1, "templates", "HttpApiRouter.ejs");
|
|
33
|
+
for (const resource of context.normalizedSpec.resources) writeHttpApiRoutes(resource, templateFile, context);
|
|
34
|
+
}
|
|
35
|
+
function writeHttpApiRoutes(resource, templateFile, context) {
|
|
36
|
+
const routes = {};
|
|
37
|
+
const pascalCaseEntityName = case$1.default.pascal(resource.name);
|
|
38
|
+
const outputDir = context.getResourceOutputDir(resource.name);
|
|
39
|
+
const outputFile = node_path.default.join(outputDir, `${pascalCaseEntityName}HttpApiRoutes.ts`);
|
|
40
|
+
for (const operation of resource.operations) {
|
|
41
|
+
const routePath = createRoutePath(operation.path);
|
|
42
|
+
if (!routes[routePath]) routes[routePath] = [];
|
|
43
|
+
routes[routePath].push(operation.method);
|
|
60
44
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
const content = context.renderTemplate(templateFile, {
|
|
46
|
+
entityName: resource.name,
|
|
47
|
+
pascalCaseEntityName,
|
|
48
|
+
routes,
|
|
49
|
+
coreDir: context.coreDir
|
|
50
|
+
});
|
|
51
|
+
const relativePath = node_path.default.relative(context.outputDir, outputFile);
|
|
52
|
+
context.writeFile(relativePath, content);
|
|
53
|
+
}
|
|
54
|
+
function createRoutePath(routePath) {
|
|
55
|
+
return routePath.split("/").map((part) => {
|
|
56
|
+
if (part.startsWith(":")) return `{${part.slice(1)}}`;
|
|
57
|
+
return part;
|
|
58
|
+
}).join("/");
|
|
59
|
+
}
|
|
69
60
|
//#endregion
|
|
70
61
|
//#region src/index.ts
|
|
71
62
|
const moduleDir = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
@@ -74,9 +65,8 @@ var AwsCdkPlugin = class extends _rexeus_typeweaver_gen.BasePlugin {
|
|
|
74
65
|
generate(context) {
|
|
75
66
|
const libDir = node_path.default.join(moduleDir, "lib");
|
|
76
67
|
this.copyLibFiles(context, libDir, "aws-cdk");
|
|
77
|
-
|
|
68
|
+
generate(context);
|
|
78
69
|
}
|
|
79
70
|
};
|
|
80
|
-
|
|
81
71
|
//#endregion
|
|
82
|
-
module.exports = AwsCdkPlugin;
|
|
72
|
+
module.exports = AwsCdkPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -2,41 +2,37 @@ import path from "node:path";
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { BasePlugin } from "@rexeus/typeweaver-gen";
|
|
4
4
|
import Case from "case";
|
|
5
|
-
|
|
6
|
-
//#region src/HttpApiRouterGenerator.ts
|
|
5
|
+
//#region src/httpApiRouterGenerator.ts
|
|
7
6
|
const moduleDir$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
routes[path].push(operation.definition.method);
|
|
22
|
-
}
|
|
23
|
-
const content = context.renderTemplate(templateFile, {
|
|
24
|
-
entityName,
|
|
25
|
-
pascalCaseEntityName,
|
|
26
|
-
routes,
|
|
27
|
-
coreDir: context.coreDir
|
|
28
|
-
});
|
|
29
|
-
const relativePath = path.relative(context.outputDir, outputFile);
|
|
30
|
-
context.writeFile(relativePath, content);
|
|
7
|
+
function generate(context) {
|
|
8
|
+
const templateFile = path.join(moduleDir$1, "templates", "HttpApiRouter.ejs");
|
|
9
|
+
for (const resource of context.normalizedSpec.resources) writeHttpApiRoutes(resource, templateFile, context);
|
|
10
|
+
}
|
|
11
|
+
function writeHttpApiRoutes(resource, templateFile, context) {
|
|
12
|
+
const routes = {};
|
|
13
|
+
const pascalCaseEntityName = Case.pascal(resource.name);
|
|
14
|
+
const outputDir = context.getResourceOutputDir(resource.name);
|
|
15
|
+
const outputFile = path.join(outputDir, `${pascalCaseEntityName}HttpApiRoutes.ts`);
|
|
16
|
+
for (const operation of resource.operations) {
|
|
17
|
+
const routePath = createRoutePath(operation.path);
|
|
18
|
+
if (!routes[routePath]) routes[routePath] = [];
|
|
19
|
+
routes[routePath].push(operation.method);
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
const content = context.renderTemplate(templateFile, {
|
|
22
|
+
entityName: resource.name,
|
|
23
|
+
pascalCaseEntityName,
|
|
24
|
+
routes,
|
|
25
|
+
coreDir: context.coreDir
|
|
26
|
+
});
|
|
27
|
+
const relativePath = path.relative(context.outputDir, outputFile);
|
|
28
|
+
context.writeFile(relativePath, content);
|
|
29
|
+
}
|
|
30
|
+
function createRoutePath(routePath) {
|
|
31
|
+
return routePath.split("/").map((part) => {
|
|
32
|
+
if (part.startsWith(":")) return `{${part.slice(1)}}`;
|
|
33
|
+
return part;
|
|
34
|
+
}).join("/");
|
|
35
|
+
}
|
|
40
36
|
//#endregion
|
|
41
37
|
//#region src/index.ts
|
|
42
38
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -45,10 +41,10 @@ var AwsCdkPlugin = class extends BasePlugin {
|
|
|
45
41
|
generate(context) {
|
|
46
42
|
const libDir = path.join(moduleDir, "lib");
|
|
47
43
|
this.copyLibFiles(context, libDir, "aws-cdk");
|
|
48
|
-
|
|
44
|
+
generate(context);
|
|
49
45
|
}
|
|
50
46
|
};
|
|
51
|
-
|
|
52
47
|
//#endregion
|
|
53
48
|
export { AwsCdkPlugin as default };
|
|
49
|
+
|
|
54
50
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["moduleDir"],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["moduleDir"],"sources":["../src/httpApiRouterGenerator.ts","../src/index.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { HttpMethod } from \"@rexeus/typeweaver-core\";\nimport type {\n GeneratorContext,\n NormalizedResource,\n} from \"@rexeus/typeweaver-gen\";\nimport Case from \"case\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport function generate(context: GeneratorContext): void {\n const templateFile = path.join(moduleDir, \"templates\", \"HttpApiRouter.ejs\");\n\n for (const resource of context.normalizedSpec.resources) {\n writeHttpApiRoutes(resource, templateFile, context);\n }\n}\n\nfunction writeHttpApiRoutes(\n resource: NormalizedResource,\n templateFile: string,\n context: GeneratorContext\n): void {\n const routes: Record<string, HttpMethod[]> = {};\n const pascalCaseEntityName = Case.pascal(resource.name);\n const outputDir = context.getResourceOutputDir(resource.name);\n const outputFile = path.join(\n outputDir,\n `${pascalCaseEntityName}HttpApiRoutes.ts`\n );\n\n for (const operation of resource.operations) {\n const routePath = createRoutePath(operation.path);\n\n if (!routes[routePath]) {\n routes[routePath] = [];\n }\n\n routes[routePath]!.push(operation.method);\n }\n\n const content = context.renderTemplate(templateFile, {\n entityName: resource.name,\n pascalCaseEntityName,\n routes,\n coreDir: context.coreDir,\n });\n\n const relativePath = path.relative(context.outputDir, outputFile);\n context.writeFile(relativePath, content);\n}\n\nfunction createRoutePath(routePath: string): string {\n const parts = routePath.split(\"/\").map(part => {\n if (part.startsWith(\":\")) {\n return `{${part.slice(1)}}`;\n }\n return part;\n });\n\n return parts.join(\"/\");\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 generateHttpApiRoutes } from \"./httpApiRouterGenerator\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport default class AwsCdkPlugin extends BasePlugin {\n public name = \"aws-cdk\";\n public override generate(context: GeneratorContext): Promise<void> | void {\n // Copy lib files to lib/aws-cdk/ from dist folder\n const libDir = path.join(moduleDir, \"lib\");\n this.copyLibFiles(context, libDir, \"aws-cdk\");\n\n generateHttpApiRoutes(context);\n }\n}\n"],"mappings":";;;;;AASA,MAAMA,cAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,SAAgB,SAAS,SAAiC;CACxD,MAAM,eAAe,KAAK,KAAKA,aAAW,aAAa,oBAAoB;AAE3E,MAAK,MAAM,YAAY,QAAQ,eAAe,UAC5C,oBAAmB,UAAU,cAAc,QAAQ;;AAIvD,SAAS,mBACP,UACA,cACA,SACM;CACN,MAAM,SAAuC,EAAE;CAC/C,MAAM,uBAAuB,KAAK,OAAO,SAAS,KAAK;CACvD,MAAM,YAAY,QAAQ,qBAAqB,SAAS,KAAK;CAC7D,MAAM,aAAa,KAAK,KACtB,WACA,GAAG,qBAAqB,kBACzB;AAED,MAAK,MAAM,aAAa,SAAS,YAAY;EAC3C,MAAM,YAAY,gBAAgB,UAAU,KAAK;AAEjD,MAAI,CAAC,OAAO,WACV,QAAO,aAAa,EAAE;AAGxB,SAAO,WAAY,KAAK,UAAU,OAAO;;CAG3C,MAAM,UAAU,QAAQ,eAAe,cAAc;EACnD,YAAY,SAAS;EACrB;EACA;EACA,SAAS,QAAQ;EAClB,CAAC;CAEF,MAAM,eAAe,KAAK,SAAS,QAAQ,WAAW,WAAW;AACjE,SAAQ,UAAU,cAAc,QAAQ;;AAG1C,SAAS,gBAAgB,WAA2B;AAQlD,QAPc,UAAU,MAAM,IAAI,CAAC,KAAI,SAAQ;AAC7C,MAAI,KAAK,WAAW,IAAI,CACtB,QAAO,IAAI,KAAK,MAAM,EAAE,CAAC;AAE3B,SAAO;GACP,CAEW,KAAK,IAAI;;;;ACvDxB,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,IAAqB,eAArB,cAA0C,WAAW;CACnD,OAAc;CACd,SAAyB,SAAiD;EAExE,MAAM,SAAS,KAAK,KAAK,WAAW,MAAM;AAC1C,OAAK,aAAa,SAAS,QAAQ,UAAU;AAE7C,WAAsB,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-aws-cdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Generates AWS CDK helpers to provision the infrastructure your APIs need. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@rexeus/typeweaver-
|
|
51
|
-
"@rexeus/typeweaver-
|
|
50
|
+
"@rexeus/typeweaver-core": "^0.9.0",
|
|
51
|
+
"@rexeus/typeweaver-gen": "^0.9.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@rexeus/typeweaver-
|
|
55
|
-
"@rexeus/typeweaver-
|
|
54
|
+
"@rexeus/typeweaver-core": "^0.9.0",
|
|
55
|
+
"@rexeus/typeweaver-gen": "^0.9.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"case": "^1.6.3"
|