@adhd/apigen-codegen-openapi 0.2.2 → 0.2.3

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,7 @@
1
+ ## 0.2.3 (2026-09-24)
2
+
3
+ This was a version bump only for apigen-codegen-openapi to align it with other projects, there were no code changes.
4
+
1
5
  ## 0.2.2 (2026-08-07)
2
6
 
3
7
 
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 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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("node:fs");const j=require("node:module");require("node:path");var d=typeof document<"u"?document.currentScript:null;j.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:d&&d.tagName.toUpperCase()==="SCRIPT"&&d.src||new URL("index.js",document.baseURI).href);const y=new Set(["string","number","boolean","integer"]);function v(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 O(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(v)}const _={"decimal.js":"Decimal"};function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(_).map(([e,n])=>({pattern:new RegExp(`import\\(["'][^"']*${q(e)}[^"']*["']\\)\\.\\w+`,"g"),key:n}));function h(e){return e.words.join("-")}function b(e){return e.words.map(w).join("")}function g(e){return e.words.join("_")}function S(e,n={}){var o,r;const t=[e.namespace,...e.path],i=e.safe||O(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=>h(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]),m=t.map(s=>h(s));return{http:{verb:l,route:u},mcp:{name:a},grpc:{package:f,service:p,method:c},cli:{path:m}}}function w(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function A(e,n={}){const o=n.title??"API",r=n.version??"0.0.0",t={};for(const i of e){const l=S(i),{verb:u,route:a}=l.http,f=u.toLowerCase(),p={operationId:i.id,summary:i.id,responses:{200:C(i.output)}};if(u==="GET")p.parameters=R(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 C(e){return typeof e=="object"&&e!==null&&Object.keys(e).length>0?{description:"Success",content:{"application/json":{schema:e}}}:{description:"Success"}}function R(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=A;
package/index.mjs CHANGED
@@ -1,32 +1,32 @@
1
- import "ts-morph";
2
1
  import "node:fs";
2
+ import { createRequire as j } from "node:module";
3
3
  import "node:path";
4
- import "ts-json-schema-generator";
5
- const m = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
6
- function j(e) {
4
+ j(import.meta.url);
5
+ const d = /* @__PURE__ */ new Set(["string", "number", "boolean", "integer"]);
6
+ function g(e) {
7
7
  if (typeof e != "object" || e === null)
8
8
  return !1;
9
9
  const n = e;
10
10
  if (n.$ref !== void 0 || n.oneOf || n.anyOf || n.allOf)
11
11
  return !1;
12
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;
13
+ return typeof o == "string" ? d.has(o) : Array.isArray(o) ? o.every((r) => d.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 g(e) {
15
+ function v(e) {
16
16
  if (!e || typeof e != "object")
17
17
  return !1;
18
18
  const n = e.properties;
19
19
  return n === void 0 || typeof n != "object" || n === null ? !1 : Object.values(n).every(
20
- j
20
+ g
21
21
  );
22
22
  }
23
- const v = {
23
+ const O = {
24
24
  "decimal.js": "Decimal"
25
25
  };
26
- function O(e) {
26
+ function q(e) {
27
27
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28
28
  }
29
- Object.entries(v).map(([e, n]) => ({
29
+ Object.entries(O).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,7 +34,7 @@ Object.entries(v).map(([e, n]) => ({
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\\(["'][^"']*${O(e)}[^"']*["']\\)\\.\\w+`,
37
+ `import\\(["'][^"']*${q(e)}[^"']*["']\\)\\.\\w+`,
38
38
  "g"
39
39
  ),
40
40
  key: n
@@ -50,12 +50,12 @@ function b(e) {
50
50
  }
51
51
  function w(e, n = {}) {
52
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));
53
+ const t = [e.namespace, ...e.path], i = e.safe || v(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]), m = t.map((s) => y(s));
54
54
  return {
55
55
  http: { verb: l, route: u },
56
56
  mcp: { name: p },
57
57
  grpc: { package: f, service: a, method: c },
58
- cli: { path: d }
58
+ cli: { path: m }
59
59
  };
60
60
  }
61
61
  function A(e) {
@@ -68,11 +68,11 @@ function E(e, n = {}) {
68
68
  operationId: i.id,
69
69
  summary: i.id,
70
70
  responses: {
71
- 200: q(i.output)
71
+ 200: S(i.output)
72
72
  }
73
73
  };
74
74
  if (u === "GET")
75
- a.parameters = S(i.input);
75
+ a.parameters = _(i.input);
76
76
  else {
77
77
  const c = i.input;
78
78
  typeof c == "object" && c !== null && Object.keys(c).length > 0 && (a.requestBody = {
@@ -92,7 +92,7 @@ function E(e, n = {}) {
92
92
  paths: t
93
93
  };
94
94
  }
95
- function q(e) {
95
+ function S(e) {
96
96
  return typeof e == "object" && e !== null && Object.keys(e).length > 0 ? {
97
97
  description: "Success",
98
98
  content: {
@@ -100,7 +100,7 @@ function q(e) {
100
100
  }
101
101
  } : { description: "Success" };
102
102
  }
103
- function S(e) {
103
+ function _(e) {
104
104
  if (typeof e != "object" || e === null || typeof e.properties != "object" || e.properties === null)
105
105
  return [];
106
106
  const n = Array.isArray(e.required) ? e.required : [], o = e.properties;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhd/apigen-codegen-openapi",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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.3.0",
12
- "@adhd/apigen-engine-naming": "^0.2.2"
11
+ "@adhd/apigen-core-client": "^0.3.1",
12
+ "@adhd/apigen-engine-naming": "^0.2.3"
13
13
  }
14
14
  }