@adhd/apigen-codegen-openapi 0.1.3 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.1.4 (2026-07-23)
2
+
3
+
4
+ ### 🚀 Features
5
+
6
+ - **apigen:** canonical route/tool-name projection across transports; serve + generate() + import-specifier fixes
7
+
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - **apigen:** externalize real npm deps in vite builds — 10 packages shipped broken dist bundles (__filename/timeOrigin crash)
12
+
13
+
14
+ ### ❤️ Thank You
15
+
16
+ - pseudosky
17
+
1
18
  ## 0.1.3 (2026-07-23)
2
19
 
3
20
 
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ts-morph");require("node:fs");require("node:path");require("ts-json-schema-generator");const g=new Set(["string","number","boolean","integer"]);function j(e){if(typeof e!="object"||e===null)return!1;const t=e;if(t.$ref!==void 0||t.oneOf||t.anyOf||t.allOf)return!1;const{type:n}=t;return typeof n=="string"?g.has(n):Array.isArray(n)?n.every(r=>g.has(r)||r==="null"):Array.isArray(t.enum)&&t.enum.length>0?t.enum.every(r=>["string","number","boolean"].includes(typeof r)):!1}function v(e){if(!e||typeof e!="object")return!1;const t=e.properties;return t===void 0||typeof t!="object"||t===null?!1:Object.values(t).every(j)}const O={"decimal.js":"Decimal"};function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(O).map(([e,t])=>({pattern:new RegExp(`import\\(["'][^"']*${q(e)}[^"']*["']\\)\\.\\w+`,"g"),key:t}));function m(e){return e.words.join("-")}function b(e){return e.words.map(k).join("")}function h(e){return e.words.join("_")}function S(e,t={}){var y,d;const n=[e.namespace,...e.path],r=e.safe||v(e.input)?"GET":"POST",o=((d=(y=t.http)==null?void 0:y.verb)==null?void 0:d[e.id])??r,s="/"+n.map(i=>m(i)).join("/"),u=n.map(i=>h(i)).join("_"),a=n.map(i=>h(i)).slice(0,-1).join("."),f=b(n[n.length-2]??n[0]),p=b(n[n.length-1]),c=n.map(i=>m(i));return{http:{verb:o,route:s},mcp:{name:u},grpc:{package:a,service:f,method:p},cli:{path:c}}}function k(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function A(e,t={}){const n=t.title??"API",r=t.version??"0.0.0",o={};for(const s of e){const u=S(s),{verb:l,route:a}=u.http,f=l.toLowerCase(),p={operationId:s.id,summary:s.id,responses:{200:P(s.output)}};if(l==="GET")p.parameters=_(s.input);else{const c=s.input;typeof c=="object"&&c!==null&&Object.keys(c).length>0&&(p.requestBody={required:!0,content:{"application/json":{schema:c}}})}o[a]===void 0&&(o[a]={}),o[a][f]=p}return{openapi:"3.1.0",info:{title:n,version:r},paths:o}}function P(e){return typeof e=="object"&&e!==null&&Object.keys(e).length>0?{description:"Success",content:{"application/json":{schema:e}}}:{description:"Success"}}function _(e){if(typeof e!="object"||e===null||typeof e.properties!="object"||e.properties===null)return[];const t=Array.isArray(e.required)?e.required:[],n=e.properties;return Object.entries(n).map(([r,o])=>({name:r,in:"query",required:t.includes(r),schema:o}))}const w="@adhd/apigen-codegen-openapi";exports.__apigen_pkg=w;exports.toOpenApi=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ts-morph");require("node:fs");require("node:path");require("ts-json-schema-generator");const y=new Set(["string","number","boolean","integer"]);function h(e){if(typeof e!="object"||e===null)return!1;const n=e;if(n.$ref!==void 0||n.oneOf||n.anyOf||n.allOf)return!1;const{type:o}=n;return typeof o=="string"?y.has(o):Array.isArray(o)?o.every(r=>y.has(r)||r==="null"):Array.isArray(n.enum)&&n.enum.length>0?n.enum.every(r=>["string","number","boolean"].includes(typeof r)):!1}function j(e){if(!e||typeof e!="object")return!1;const n=e.properties;return n===void 0||typeof n!="object"||n===null?!1:Object.values(n).every(h)}const v={"decimal.js":"Decimal"};function O(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(v).map(([e,n])=>({pattern:new RegExp(`import\\(["'][^"']*${O(e)}[^"']*["']\\)\\.\\w+`,"g"),key:n}));function m(e){return e.words.join("-")}function b(e){return e.words.map(A).join("")}function g(e){return e.words.join("_")}function q(e,n={}){var o,r;const t=[e.namespace,...e.path],i=e.safe||j(e.input)?"GET":"POST",l=((r=(o=n.http)==null?void 0:o.verb)==null?void 0:r[e.id])??i,u="/"+t.map(s=>m(s)).join("/"),a=t.map(s=>g(s)).join("_"),f=t.map(s=>g(s)).slice(0,-1).join("."),p=b(t[t.length-2]??t[0]),c=b(t[t.length-1]),d=t.map(s=>m(s));return{http:{verb:l,route:u},mcp:{name:a},grpc:{package:f,service:p,method:c},cli:{path:d}}}function A(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function w(e,n={}){const o=n.title??"API",r=n.version??"0.0.0",t={};for(const i of e){const l=q(i),{verb:u,route:a}=l.http,f=u.toLowerCase(),p={operationId:i.id,summary:i.id,responses:{200:S(i.output)}};if(u==="GET")p.parameters=_(i.input);else{const c=i.input;typeof c=="object"&&c!==null&&Object.keys(c).length>0&&(p.requestBody={required:!0,content:{"application/json":{schema:c}}})}t[a]===void 0&&(t[a]={}),t[a][f]=p}return{openapi:"3.1.0",info:{title:o,version:r},paths:t}}function S(e){return typeof e=="object"&&e!==null&&Object.keys(e).length>0?{description:"Success",content:{"application/json":{schema:e}}}:{description:"Success"}}function _(e){if(typeof e!="object"||e===null||typeof e.properties!="object"||e.properties===null)return[];const n=Array.isArray(e.required)?e.required:[],o=e.properties;return Object.entries(o).map(([r,t])=>({name:r,in:"query",required:n.includes(r),schema:t}))}const k="@adhd/apigen-codegen-openapi";exports.__apigen_pkg=k;exports.toOpenApi=w;
package/index.mjs CHANGED
@@ -2,31 +2,31 @@ import "ts-morph";
2
2
  import "node:fs";
3
3
  import "node:path";
4
4
  import "ts-json-schema-generator";
5
- const d = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
5
+ const m = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
6
6
  function j(e) {
7
7
  if (typeof e != "object" || e === null)
8
8
  return !1;
9
- const t = e;
10
- if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf)
9
+ const n = e;
10
+ if (n.$ref !== void 0 || n.oneOf || n.anyOf || n.allOf)
11
11
  return !1;
12
- const { type: n } = t;
13
- return typeof n == "string" ? d.has(n) : Array.isArray(n) ? n.every((r) => d.has(r) || r === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((r) => ["string", "number", "boolean"].includes(typeof r)) : !1;
12
+ const { type: o } = n;
13
+ return typeof o == "string" ? m.has(o) : Array.isArray(o) ? o.every((r) => m.has(r) || r === "null") : Array.isArray(n.enum) && n.enum.length > 0 ? n.enum.every((r) => ["string", "number", "boolean"].includes(typeof r)) : !1;
14
14
  }
15
- function v(e) {
15
+ function g(e) {
16
16
  if (!e || typeof e != "object")
17
17
  return !1;
18
- const t = e.properties;
19
- return t === void 0 || typeof t != "object" || t === null ? !1 : Object.values(t).every(
18
+ const n = e.properties;
19
+ return n === void 0 || typeof n != "object" || n === null ? !1 : Object.values(n).every(
20
20
  j
21
21
  );
22
22
  }
23
- const O = {
23
+ const v = {
24
24
  "decimal.js": "Decimal"
25
25
  };
26
- function S(e) {
26
+ function O(e) {
27
27
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28
28
  }
29
- Object.entries(O).map(([e, t]) => ({
29
+ Object.entries(v).map(([e, n]) => ({
30
30
  // Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
31
31
  // The module specifier appears inside an absolute path, so we allow any
32
32
  // characters between the quote and the specifier, and between the specifier
@@ -34,65 +34,65 @@ Object.entries(O).map(([e, t]) => ({
34
34
  // …) is matched generically (`\w+`) rather than anchored to one spelling —
35
35
  // see the doc comment above for why.
36
36
  pattern: new RegExp(
37
- `import\\(["'][^"']*${S(e)}[^"']*["']\\)\\.\\w+`,
37
+ `import\\(["'][^"']*${O(e)}[^"']*["']\\)\\.\\w+`,
38
38
  "g"
39
39
  ),
40
- key: t
40
+ key: n
41
41
  }));
42
- function g(e) {
42
+ function y(e) {
43
43
  return e.words.join("-");
44
44
  }
45
- function b(e) {
45
+ function h(e) {
46
46
  return e.words.map(A).join("");
47
47
  }
48
- function h(e) {
48
+ function b(e) {
49
49
  return e.words.join("_");
50
50
  }
51
- function k(e, t = {}) {
52
- var m, y;
53
- const n = [e.namespace, ...e.path], r = e.safe || v(e.input) ? "GET" : "POST", o = ((y = (m = t.http) == null ? void 0 : m.verb) == null ? void 0 : y[e.id]) ?? r, s = "/" + n.map((c) => g(c)).join("/"), u = n.map((c) => h(c)).join("_"), a = n.map((c) => h(c)).slice(0, -1).join("."), f = b(n[n.length - 2] ?? n[0]), p = b(n[n.length - 1]), i = n.map((c) => g(c));
51
+ function w(e, n = {}) {
52
+ var o, r;
53
+ const t = [e.namespace, ...e.path], i = e.safe || g(e.input) ? "GET" : "POST", l = ((r = (o = n.http) == null ? void 0 : o.verb) == null ? void 0 : r[e.id]) ?? i, u = "/" + t.map((s) => y(s)).join("/"), p = t.map((s) => b(s)).join("_"), f = t.map((s) => b(s)).slice(0, -1).join("."), a = h(t[t.length - 2] ?? t[0]), c = h(t[t.length - 1]), d = t.map((s) => y(s));
54
54
  return {
55
- http: { verb: o, route: s },
56
- mcp: { name: u },
57
- grpc: { package: a, service: f, method: p },
58
- cli: { path: i }
55
+ http: { verb: l, route: u },
56
+ mcp: { name: p },
57
+ grpc: { package: f, service: a, method: c },
58
+ cli: { path: d }
59
59
  };
60
60
  }
61
61
  function A(e) {
62
62
  return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
63
63
  }
64
- function $(e, t = {}) {
65
- const n = t.title ?? "API", r = t.version ?? "0.0.0", o = {};
66
- for (const s of e) {
67
- const u = k(s), { verb: l, route: a } = u.http, f = l.toLowerCase(), p = {
68
- operationId: s.id,
69
- summary: s.id,
64
+ function E(e, n = {}) {
65
+ const o = n.title ?? "API", r = n.version ?? "0.0.0", t = {};
66
+ for (const i of e) {
67
+ const l = w(i), { verb: u, route: p } = l.http, f = u.toLowerCase(), a = {
68
+ operationId: i.id,
69
+ summary: i.id,
70
70
  responses: {
71
- 200: P(s.output)
71
+ 200: q(i.output)
72
72
  }
73
73
  };
74
- if (l === "GET")
75
- p.parameters = q(s.input);
74
+ if (u === "GET")
75
+ a.parameters = S(i.input);
76
76
  else {
77
- const i = s.input;
78
- typeof i == "object" && i !== null && Object.keys(i).length > 0 && (p.requestBody = {
77
+ const c = i.input;
78
+ typeof c == "object" && c !== null && Object.keys(c).length > 0 && (a.requestBody = {
79
79
  required: !0,
80
80
  content: {
81
81
  "application/json": {
82
- schema: i
82
+ schema: c
83
83
  }
84
84
  }
85
85
  });
86
86
  }
87
- o[a] === void 0 && (o[a] = {}), o[a][f] = p;
87
+ t[p] === void 0 && (t[p] = {}), t[p][f] = a;
88
88
  }
89
89
  return {
90
90
  openapi: "3.1.0",
91
- info: { title: n, version: r },
92
- paths: o
91
+ info: { title: o, version: r },
92
+ paths: t
93
93
  };
94
94
  }
95
- function P(e) {
95
+ function q(e) {
96
96
  return typeof e == "object" && e !== null && Object.keys(e).length > 0 ? {
97
97
  description: "Success",
98
98
  content: {
@@ -100,19 +100,19 @@ function P(e) {
100
100
  }
101
101
  } : { description: "Success" };
102
102
  }
103
- function q(e) {
103
+ function S(e) {
104
104
  if (typeof e != "object" || e === null || typeof e.properties != "object" || e.properties === null)
105
105
  return [];
106
- const t = Array.isArray(e.required) ? e.required : [], n = e.properties;
107
- return Object.entries(n).map(([r, o]) => ({
106
+ const n = Array.isArray(e.required) ? e.required : [], o = e.properties;
107
+ return Object.entries(o).map(([r, t]) => ({
108
108
  name: r,
109
109
  in: "query",
110
- required: t.includes(r),
111
- schema: o
110
+ required: n.includes(r),
111
+ schema: t
112
112
  }));
113
113
  }
114
- const B = "@adhd/apigen-codegen-openapi";
114
+ const P = "@adhd/apigen-codegen-openapi";
115
115
  export {
116
- B as __apigen_pkg,
117
- $ as toOpenApi
116
+ P as __apigen_pkg,
117
+ E as toOpenApi
118
118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhd/apigen-codegen-openapi",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "./index.js",
5
5
  "module": "./index.mjs",
6
6
  "typings": "./index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "access": "public"
9
9
  },
10
10
  "dependencies": {
11
- "@adhd/apigen-core-client": "^0.1.1",
12
- "@adhd/apigen-engine-naming": "^0.1.2"
11
+ "@adhd/apigen-core-client": "^0.1.2",
12
+ "@adhd/apigen-engine-naming": "^0.1.3"
13
13
  }
14
14
  }