@rexeus/typeweaver-aws-cdk 0.10.4 → 0.10.5

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 CHANGED
@@ -39,13 +39,21 @@ function writeHttpApiRoutes(resource, templateFile, context) {
39
39
  const outputFile = node_path.default.join(outputDir, `${pascalCaseEntityName}HttpApiRoutes.ts`);
40
40
  for (const operation of resource.operations) {
41
41
  const routePath = createRoutePath(operation.path);
42
- if (!routes[routePath]) routes[routePath] = [];
43
- routes[routePath].push(operation.method);
42
+ if (!routes[routePath]) routes[routePath] = {
43
+ methods: [],
44
+ methodSummaries: []
45
+ };
46
+ routes[routePath].methods.push(operation.method);
47
+ routes[routePath].methodSummaries.push(operation.summary ? `${operation.method}: ${operation.summary}` : operation.method);
44
48
  }
49
+ const routesWithDocs = Object.fromEntries(Object.entries(routes).map(([routePath, route]) => [routePath, {
50
+ methods: route.methods,
51
+ jsDoc: (0, _rexeus_typeweaver_gen.createJSDocComment)(route.methodSummaries.join("\n"), { indentation: " " })
52
+ }]));
45
53
  const content = context.renderTemplate(templateFile, {
46
54
  entityName: resource.name,
47
55
  pascalCaseEntityName,
48
- routes,
56
+ routes: routesWithDocs,
49
57
  coreDir: context.coreDir
50
58
  });
51
59
  const relativePath = node_path.default.relative(context.outputDir, outputFile);
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 } from "@rexeus/typeweaver-gen";
3
+ import { BasePlugin, createJSDocComment } from "@rexeus/typeweaver-gen";
4
4
  import { pascalCase } from "polycase";
5
5
  //#region src/httpApiRouterGenerator.ts
6
6
  const moduleDir$1 = path.dirname(fileURLToPath(import.meta.url));
@@ -15,13 +15,21 @@ function writeHttpApiRoutes(resource, templateFile, context) {
15
15
  const outputFile = path.join(outputDir, `${pascalCaseEntityName}HttpApiRoutes.ts`);
16
16
  for (const operation of resource.operations) {
17
17
  const routePath = createRoutePath(operation.path);
18
- if (!routes[routePath]) routes[routePath] = [];
19
- routes[routePath].push(operation.method);
18
+ if (!routes[routePath]) routes[routePath] = {
19
+ methods: [],
20
+ methodSummaries: []
21
+ };
22
+ routes[routePath].methods.push(operation.method);
23
+ routes[routePath].methodSummaries.push(operation.summary ? `${operation.method}: ${operation.summary}` : operation.method);
20
24
  }
25
+ const routesWithDocs = Object.fromEntries(Object.entries(routes).map(([routePath, route]) => [routePath, {
26
+ methods: route.methods,
27
+ jsDoc: createJSDocComment(route.methodSummaries.join("\n"), { indentation: " " })
28
+ }]));
21
29
  const content = context.renderTemplate(templateFile, {
22
30
  entityName: resource.name,
23
31
  pascalCaseEntityName,
24
- routes,
32
+ routes: routesWithDocs,
25
33
  coreDir: context.coreDir
26
34
  });
27
35
  const relativePath = path.relative(context.outputDir, outputFile);
@@ -1 +1 @@
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 { pascalCase } from \"polycase\";\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 = pascalCase(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.js\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport class AwsCdkPlugin extends BasePlugin {\n public name = \"aws-cdk\";\n public override depends = [\"types\"];\n\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,WAAW,SAAS,KAAK;CACtD,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,IAAa,eAAb,cAAkC,WAAW;CAC3C,OAAc;CACd,UAA0B,CAAC,QAAQ;CAEnC,SAAyB,SAAiD;EAExE,MAAM,SAAS,KAAK,KAAK,WAAW,MAAM;AAC1C,OAAK,aAAa,SAAS,QAAQ,UAAU;AAE7C,WAAsB,QAAQ"}
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 { createJSDocComment } from \"@rexeus/typeweaver-gen\";\nimport type {\n GeneratorContext,\n NormalizedResource,\n} from \"@rexeus/typeweaver-gen\";\nimport { pascalCase } from \"polycase\";\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<\n string,\n {\n readonly methods: HttpMethod[];\n readonly methodSummaries: string[];\n }\n > = {};\n const pascalCaseEntityName = pascalCase(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 methods: [],\n methodSummaries: [],\n };\n }\n\n routes[routePath]!.methods.push(operation.method);\n routes[routePath]!.methodSummaries.push(\n operation.summary\n ? `${operation.method}: ${operation.summary}`\n : operation.method\n );\n }\n\n const routesWithDocs = Object.fromEntries(\n Object.entries(routes).map(([routePath, route]) => [\n routePath,\n {\n methods: route.methods,\n jsDoc: createJSDocComment(route.methodSummaries.join(\"\\n\"), {\n indentation: \" \",\n }),\n },\n ])\n );\n\n const content = context.renderTemplate(templateFile, {\n entityName: resource.name,\n pascalCaseEntityName,\n routes: routesWithDocs,\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.js\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport class AwsCdkPlugin extends BasePlugin {\n public name = \"aws-cdk\";\n public override depends = [\"types\"];\n\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.copy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,CAAC,KAAI,SAAQ;AAC7C,MAAI,KAAK,WAAW,IAAI,CACtB,QAAO,IAAI,KAAK,MAAM,EAAE,CAAC;AAE3B,SAAO;GACP,CAEW,KAAK,IAAI;;;;AClFxB,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,IAAa,eAAb,cAAkC,WAAW;CAC3C,OAAc;CACd,UAA0B,CAAC,QAAQ;CAEnC,SAAyB,SAAiD;EAExE,MAAM,SAAS,KAAK,KAAK,WAAW,MAAM;AAC1C,OAAK,aAAa,SAAS,QAAQ,UAAU;AAE7C,WAAsB,QAAQ"}
@@ -14,10 +14,11 @@ import {
14
14
 
15
15
  export class <%= pascalCaseEntityName %>HttpApiRoutes extends AwsHttpApiGatewayRoutes {
16
16
  private routes: AwsHttpApiGatewayRoute[] = [
17
- <% for(const [path, methods] of Object.entries(routes)) { %>
17
+ <% for(const [path, route] of Object.entries(routes)) { %>
18
18
  {
19
- path: "<%= path %>",
20
- methods: [<% for(const method of methods) { %>HttpMethod.<%= method %>,<% } %>],
19
+ <% if (route.jsDoc) { %><%- route.jsDoc %>
20
+ <% } %> path: "<%= path %>",
21
+ methods: [<% for(const method of route.methods) { %>HttpMethod.<%= method %>,<% } %>],
21
22
  },
22
23
  <% } %>
23
24
  ];
@@ -29,4 +30,4 @@ export class <%= pascalCaseEntityName %>HttpApiRoutes extends AwsHttpApiGatewayR
29
30
  public getRoutes(): AwsHttpApiGatewayRoute[] {
30
31
  return this.routes;
31
32
  }
32
- }
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexeus/typeweaver-aws-cdk",
3
- "version": "0.10.4",
3
+ "version": "0.10.5",
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-core": "^0.10.4",
51
- "@rexeus/typeweaver-gen": "^0.10.4"
50
+ "@rexeus/typeweaver-core": "^0.10.5",
51
+ "@rexeus/typeweaver-gen": "^0.10.5"
52
52
  },
53
53
  "devDependencies": {
54
- "@rexeus/typeweaver-core": "^0.10.4",
55
- "@rexeus/typeweaver-gen": "^0.10.4"
54
+ "@rexeus/typeweaver-core": "^0.10.5",
55
+ "@rexeus/typeweaver-gen": "^0.10.5"
56
56
  },
57
57
  "dependencies": {
58
58
  "polycase": "^1.1.0"