@adhd/apigen-codegen-openapi 0.2.0 → 0.2.1
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 +12 -0
- package/index.js +1 -1
- package/index.mjs +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
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
|
|
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 _(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:w(i.output)}};if(u==="GET")p.parameters=S(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 w(e){return typeof e=="object"&&e!==null&&Object.keys(e).length>0?{description:"Success",content:{"application/json":{schema:e}}}:{description:"Success"}}function S(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=_;
|
package/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhd/apigen-codegen-openapi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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.2.
|
|
12
|
-
"@adhd/apigen-engine-naming": "^0.2.
|
|
11
|
+
"@adhd/apigen-core-client": "^0.2.1",
|
|
12
|
+
"@adhd/apigen-engine-naming": "^0.2.1"
|
|
13
13
|
}
|
|
14
14
|
}
|