@rexeus/typeweaver-aws-cdk 0.2.0 → 0.3.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 ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
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);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ default: () => AwsCdkPlugin
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
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();
40
+
41
+ // src/index.ts
42
+ var import_node_path2 = __toESM(require("node:path"), 1);
43
+ var import_node_url2 = require("node:url");
44
+ var import_typeweaver_gen = require("@rexeus/typeweaver-gen");
45
+
46
+ // src/HttpApiRouterGenerator.ts
47
+ var import_node_path = __toESM(require("node:path"), 1);
48
+ var import_node_url = require("node:url");
49
+ var import_case = __toESM(require("case"), 1);
50
+ var moduleDir = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
51
+ var HttpApiRouterGenerator = class {
52
+ static generate(context) {
53
+ const templateFile = import_node_path.default.join(moduleDir, "templates", "HttpApiRouter.ejs");
54
+ for (const [entityName, entityResource] of Object.entries(
55
+ context.resources.entityResources
56
+ )) {
57
+ this.writeHttpApiRoutes(
58
+ entityName,
59
+ templateFile,
60
+ entityResource.operations,
61
+ context
62
+ );
63
+ }
64
+ }
65
+ static writeHttpApiRoutes(entityName, templateFile, operationResources, context) {
66
+ const routes = {};
67
+ const pascalCaseEntityName = import_case.default.pascal(entityName);
68
+ const outputDir = operationResources[0].outputDir;
69
+ const outputFile = import_node_path.default.join(
70
+ outputDir,
71
+ `${pascalCaseEntityName}HttpApiRoutes.ts`
72
+ );
73
+ for (const operation of operationResources) {
74
+ const path3 = this.createRoutePath(operation.definition.path);
75
+ if (!routes[path3]) {
76
+ routes[path3] = [];
77
+ }
78
+ routes[path3].push(operation.definition.method);
79
+ }
80
+ const content = context.renderTemplate(templateFile, {
81
+ entityName,
82
+ pascalCaseEntityName,
83
+ routes,
84
+ coreDir: context.coreDir
85
+ });
86
+ const relativePath = import_node_path.default.relative(context.outputDir, outputFile);
87
+ context.writeFile(relativePath, content);
88
+ }
89
+ static createRoutePath(path3) {
90
+ const parts = path3.split("/").map((part) => {
91
+ if (part.startsWith(":")) {
92
+ return `{${part.slice(1)}}`;
93
+ }
94
+ return part;
95
+ });
96
+ return parts.join("/");
97
+ }
98
+ };
99
+
100
+ // src/index.ts
101
+ var moduleDir2 = import_node_path2.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
102
+ var AwsCdkPlugin = class extends import_typeweaver_gen.BasePlugin {
103
+ name = "aws-cdk";
104
+ generate(context) {
105
+ const libDir = import_node_path2.default.join(moduleDir2, "lib");
106
+ this.copyLibFiles(context, libDir, "aws-cdk");
107
+ HttpApiRouterGenerator.generate(context);
108
+ }
109
+ };
@@ -0,0 +1,8 @@
1
+ import { BasePlugin, GeneratorContext } from '@rexeus/typeweaver-gen';
2
+
3
+ declare class AwsCdkPlugin extends BasePlugin {
4
+ name: string;
5
+ generate(context: GeneratorContext): Promise<void> | void;
6
+ }
7
+
8
+ export { AwsCdkPlugin as default };
package/dist/index.js CHANGED
@@ -1,12 +1,16 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'url';
3
- import { BasePlugin } from '@rexeus/typeweaver-gen';
4
- import Case from 'case';
1
+ // src/index.ts
2
+ import path2 from "node:path";
3
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
4
+ import { BasePlugin } from "@rexeus/typeweaver-gen";
5
5
 
6
- const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
7
- class HttpApiRouterGenerator {
6
+ // src/HttpApiRouterGenerator.ts
7
+ import path from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+ import Case from "case";
10
+ var moduleDir = path.dirname(fileURLToPath(import.meta.url));
11
+ var HttpApiRouterGenerator = class {
8
12
  static generate(context) {
9
- const templateFile = path.join(__dirname$1, "templates", "HttpApiRouter.ejs");
13
+ const templateFile = path.join(moduleDir, "templates", "HttpApiRouter.ejs");
10
14
  for (const [entityName, entityResource] of Object.entries(
11
15
  context.resources.entityResources
12
16
  )) {
@@ -27,11 +31,11 @@ class HttpApiRouterGenerator {
27
31
  `${pascalCaseEntityName}HttpApiRoutes.ts`
28
32
  );
29
33
  for (const operation of operationResources) {
30
- const path2 = this.createRoutePath(operation.definition.path);
31
- if (!routes[path2]) {
32
- routes[path2] = [];
34
+ const path3 = this.createRoutePath(operation.definition.path);
35
+ if (!routes[path3]) {
36
+ routes[path3] = [];
33
37
  }
34
- routes[path2].push(operation.definition.method);
38
+ routes[path3].push(operation.definition.method);
35
39
  }
36
40
  const content = context.renderTemplate(templateFile, {
37
41
  entityName,
@@ -42,8 +46,8 @@ class HttpApiRouterGenerator {
42
46
  const relativePath = path.relative(context.outputDir, outputFile);
43
47
  context.writeFile(relativePath, content);
44
48
  }
45
- static createRoutePath(path2) {
46
- const parts = path2.split("/").map((part) => {
49
+ static createRoutePath(path3) {
50
+ const parts = path3.split("/").map((part) => {
47
51
  if (part.startsWith(":")) {
48
52
  return `{${part.slice(1)}}`;
49
53
  }
@@ -51,16 +55,18 @@ class HttpApiRouterGenerator {
51
55
  });
52
56
  return parts.join("/");
53
57
  }
54
- }
58
+ };
55
59
 
56
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
57
- class AwsCdkPlugin extends BasePlugin {
60
+ // src/index.ts
61
+ var moduleDir2 = path2.dirname(fileURLToPath2(import.meta.url));
62
+ var AwsCdkPlugin = class extends BasePlugin {
58
63
  name = "aws-cdk";
59
64
  generate(context) {
60
- const libDir = path.join(__dirname, "lib");
65
+ const libDir = path2.join(moduleDir2, "lib");
61
66
  this.copyLibFiles(context, libDir, "aws-cdk");
62
67
  HttpApiRouterGenerator.generate(context);
63
68
  }
64
- }
65
-
66
- export { AwsCdkPlugin as default };
69
+ };
70
+ export {
71
+ AwsCdkPlugin as default
72
+ };
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@rexeus/typeweaver-aws-cdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Generates AWS CDK helpers to provision the infrastructure your APIs need. Powered by Typeweaver 🧵✨",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
12
19
  }
13
20
  },
14
21
  "files": [
@@ -39,12 +46,12 @@
39
46
  },
40
47
  "homepage": "https://github.com/rexeus/typeweaver#readme",
41
48
  "peerDependencies": {
42
- "@rexeus/typeweaver-gen": "^0.2.0",
43
- "@rexeus/typeweaver-core": "^0.2.0"
49
+ "@rexeus/typeweaver-core": "^0.3.0",
50
+ "@rexeus/typeweaver-gen": "^0.3.0"
44
51
  },
45
52
  "devDependencies": {
46
- "@rexeus/typeweaver-core": "^0.2.0",
47
- "@rexeus/typeweaver-gen": "^0.2.0"
53
+ "@rexeus/typeweaver-core": "^0.3.0",
54
+ "@rexeus/typeweaver-gen": "^0.3.0"
48
55
  },
49
56
  "dependencies": {
50
57
  "case": "^1.6.3"
@@ -52,7 +59,7 @@
52
59
  "scripts": {
53
60
  "typecheck": "tsc --noEmit",
54
61
  "format": "prettier --write .",
55
- "build": "pkgroll --clean-dist && cp -r ./src/templates ./dist/templates && cp -r ./src/lib ./dist/lib && cp ../../LICENSE ../../NOTICE ./dist/",
62
+ "build": "tsup && mkdir -p ./dist/templates ./dist/lib && cp -r ./src/templates/* ./dist/templates/ && cp -r ./src/lib/* ./dist/lib/ && cp ../../LICENSE ../../NOTICE ./dist/",
56
63
  "preversion": "npm run build"
57
64
  }
58
65
  }