@adhd/apigen-plugin-openapi 0.2.3 → 0.2.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/CHANGELOG.md +15 -0
- package/index.js +1 -1
- package/index.mjs +541 -188
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## 0.2.4 (2026-09-26)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **vite-plugins:** absorb perf/test-resolve-fix — test-time @adhd/* source resolution ([3e344506](https://github.com/PseudoSky/adhd/commit/3e344506))
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- **vite:** restore import.meta.url in CJS output under vite 8 ([7916e639](https://github.com/PseudoSky/adhd/commit/7916e639))
|
|
10
|
+
- **nx:** finish the ESLint v9 flat-config migration and unblock the gate ([53f4ff3e](https://github.com/PseudoSky/adhd/commit/53f4ff3e))
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- pseudosky
|
|
15
|
+
|
|
1
16
|
## 0.2.3 (2026-09-24)
|
|
2
17
|
|
|
3
18
|
This was a version bump only for apigen-plugin-openapi to align it with other projects, there were no code changes.
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("node:fs");const v=require("node:module");require("node:path");var c=typeof document<"u"?document.currentScript:null;function m(e){return{raw:e,words:e.split(/(?=[A-Z])|[-_]/).map(t=>t.toLowerCase()).filter(Boolean)}}function O(e,t,n={}){const o=e.split("/");if(o.length<2||o.some(f=>f.length===0))throw new Error(`syntheticOp: id "${e}" must be "<namespace>/<path...>" with non-empty segments`);const[r,...i]=o,l=r.replace(/^_+/,""),a=n.kind??"action",s={id:e,host:t.host,namespace:m(l),path:i.map(m),kind:a,async:n.async??!1,streaming:n.streaming??!1,safe:n.safe??a==="query",input:n.input??{},output:n.output??{},envelope:n.envelope??{},typeText:n.typeText??null};return n.hasCtx!==void 0&&(s.hasCtx=n.hasCtx),n.transports!==void 0&&(s.transports=n.transports),s}v.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("index.js",document.baseURI).href);const q={"decimal.js":"Decimal"};function _(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(q).map(([e,t])=>({pattern:new RegExp(`import\\(["'][^"']*${_(e)}[^"']*["']\\)\\.\\w+`,"g"),key:t}));v.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("index.js",document.baseURI).href);const y=new Set(["string","number","boolean","integer"]);function R(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"?y.has(n):Array.isArray(n)?n.every(o=>y.has(o)||o==="null"):Array.isArray(t.enum)&&t.enum.length>0?t.enum.every(o=>["string","number","boolean"].includes(typeof o)):!1}function A(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(R)}const S={"decimal.js":"Decimal"};function C(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(S).map(([e,t])=>({pattern:new RegExp(`import\\(["'][^"']*${C(e)}[^"']*["']\\)\\.\\w+`,"g"),key:t}));function h(e){return e.words.join("-")}function g(e){return e.words.map(T).join("")}function b(e){return e.words.join("_")}function P(e,t={}){var n,o;const r=[e.namespace,...e.path],i=e.safe||A(e.input)?"GET":"POST",l=((o=(n=t.http)==null?void 0:n.verb)==null?void 0:o[e.id])??i,a="/"+r.map(p=>h(p)).join("/"),s=r.map(p=>b(p)).join("_"),f=r.map(p=>b(p)).slice(0,-1).join("."),d=g(r[r.length-2]??r[0]),u=g(r[r.length-1]),w=r.map(p=>h(p));return{http:{verb:l,route:a},mcp:{name:s},grpc:{package:f,service:d,method:u},cli:{path:w}}}function T(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function x(e,t={}){const n=t.title??"API",o=t.version??"0.0.0",r={};for(const i of e){const l=P(i),{verb:a,route:s}=l.http,f=a.toLowerCase(),d={operationId:i.id,summary:i.id,responses:{200:I(i.output)}};if(a==="GET")d.parameters=U(i.input);else{const u=i.input;typeof u=="object"&&u!==null&&Object.keys(u).length>0&&(d.requestBody={required:!0,content:{"application/json":{schema:u}}})}r[s]===void 0&&(r[s]={}),r[s][f]=d}return{openapi:"3.1.0",info:{title:n,version:o},paths:r}}function I(e){return typeof e=="object"&&e!==null&&Object.keys(e).length>0?{description:"Success",content:{"application/json":{schema:e}}}:{description:"Success"}}function U(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(([o,r])=>({name:o,in:"query",required:t.includes(o),schema:r}))}function k(e,t={}){return[{...O("_meta/openapi",e,{kind:"query",safe:!0,output:{type:"object"},transports:["http"]}),handler:n=>x(e.operations,{title:t.title,version:t.version})}]}const j={id:"openapi",description:"Mount plugin: serves the OpenAPI 3.1 doc at GET /meta/openapi",language:"ts",optionsSchema:{type:"object",properties:{title:{type:"string",description:"OpenAPI info.title"},version:{type:"string",description:"OpenAPI info.version"}},additionalProperties:!1},capabilities:{mount:{operations(e,t){return k(e,t)}}}};exports.default=j;exports.openapiPlugin=j;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require("node:fs");let e=require("node:module");require("node:path");function t(e){return{raw:e,words:e.split(/(?=[A-Z])|[-_]/).map(e=>e.toLowerCase()).filter(Boolean)}}function n(e,n,r={}){let i=e.split(`/`);if(i.length<2||i.some(e=>e.length===0))throw Error(`syntheticOp: id "${e}" must be "<namespace>/<path...>" with non-empty segments`);let[a,...o]=i,s=a.replace(/^_+/,``),c=r.kind??`action`,l={id:e,host:n.host,namespace:t(s),path:o.map(t),kind:c,async:r.async??!1,streaming:r.streaming??!1,safe:r.safe??c===`query`,input:r.input??{},output:r.output??{},envelope:r.envelope??{},typeText:r.typeText??null};return r.hasCtx!==void 0&&(l.hasCtx=r.hasCtx),r.transports!==void 0&&(l.transports=r.transports),l}(0,e.createRequire)(require("node:url").pathToFileURL(__filename).href);var r={id:`date-time`,kind:`scalar`,schema:{type:`string`,format:`date-time`},matches(e){return e.type===`string`&&e.format===`date-time`},ownsValue(e){return e instanceof Date},encode(e,t,n){return e.toISOString()},decode(e,t,n){if(typeof e!=`string`){if(n.mode===`strict`)throw TypeError(`[date-time] expected a string on the wire at "${n.path}", got ${typeof e}`);return new Date(String(e))}if(n.mode===`strict`&&Number.isNaN(new Date(e).getTime()))throw TypeError(`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(e)}`);return new Date(e)}},i={id:`int64`,kind:`scalar`,schema:{type:`string`,format:`int64`},matches(e){return e.type===`string`&&e.format===`int64`},ownsValue(e){return typeof e==`bigint`},encode(e,t,n){return String(e)},decode(e,t,n){if(typeof e!=`string`){if(n.mode===`strict`)throw TypeError(`[int64] expected a string on the wire at "${n.path}", got ${typeof e}`);try{return BigInt(Math.trunc(Number(e)))}catch{return BigInt(0)}}if(n.mode===`strict`)return BigInt(e);if(/^-?\d+$/.test(e))try{return BigInt(e)}catch{return BigInt(0)}return BigInt(0)}};function a(e){return e}var o={id:`decimal`,kind:`scalar`,schema:{type:`string`,format:`decimal`},matches(e){return e.type===`string`&&e.format===`decimal`},encode(e,t,n){return e},decode(e,t,n){if(typeof e!=`string`){if(n.mode===`strict`)throw TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`);return a(String(e))}if(n.mode===`strict`&&!/^-?\d+(\.\d+)?$/.test(e))throw TypeError(`[decimal] wire value "${e}" at "${n.path}" is not a valid decimal string`);return a(e)}},s={id:`byte`,kind:`scalar`,schema:{type:`string`,format:`byte`},matches(e){return e.type===`string`&&e.format===`byte`},ownsValue(e){return e instanceof Uint8Array},encode(e,t,n){return Buffer.from(e).toString(`base64`)},decode(e,t,n){if(typeof e!=`string`){if(n.mode===`strict`)throw TypeError(`[byte] expected a base64 string on the wire at "${n.path}", got ${typeof e}`);return new Uint8Array}if(n.mode===`strict`&&!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw TypeError(`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${e}"`);return new Uint8Array(Buffer.from(e,`base64`))}},c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,l={id:`uuid`,kind:`scalar`,schema:{type:`string`,format:`uuid`},matches(e){return e.type===`string`&&e.format===`uuid`},encode(e,t,n){return e.toLowerCase()},decode(e,t,n){if(typeof e!=`string`){if(n.mode===`strict`)throw TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`);return String(e).toLowerCase()}if(n.mode===`strict`&&!c.test(e))throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);return e}},u=`NaN`,d=`Infinity`,f=`-Infinity`,p=new Set([u,d,f]);r.id,i.id,o.id,s.id,l.id,{id:`number-special`,kind:`scalar`,schema:{type:`number`},matches(e){return e.type===`number`&&e.format===void 0},ownsValue(e){return typeof e==`number`&&!Number.isFinite(e)},encode(e,t,n){return Number.isNaN(e)?u:e===1/0?d:e===-1/0?f:e},decode(e,t,n){if(typeof e==`number`)return e;if(typeof e==`string`){if(e===u)return NaN;if(e===d)return 1/0;if(e===f)return-1/0;let t=Number(e);if(!Number.isNaN(t))return t}if(n.mode===`strict`)throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...p].join(`, `)}.`);return NaN}}.id,Object.freeze({typescript:{"date-time":{encode:`$.toISOString()`,decode:`new Date($)`,mode:`native`},int64:{encode:`String($)`,decode:`BigInt($)`,mode:`native`},decimal:{encode:`$.toString()`,decode:`new Decimal($)`,imports:[],dep:{name:`decimal.js`,version:`^10`},mode:`branded`},byte:{encode:`Buffer.from($).toString('base64')`,decode:`new Uint8Array(Buffer.from($, 'base64'))`,mode:`native`},uuid:{encode:`$.toLowerCase()`,decode:`$`,mode:`native`},"number-special":{encode:`numToWire($)`,decode:`wireToNum($)`,mode:`native`}},python:{"date-time":{encode:`$.isoformat()`,decode:`datetime.fromisoformat($)`,imports:[`from datetime import datetime`],mode:`native`},int64:{encode:`str($)`,decode:`int($)`,mode:`native`},decimal:{encode:`str($)`,decode:`Decimal($)`,imports:[`from decimal import Decimal`],mode:`native`},byte:{encode:`b64encode($).decode()`,decode:`b64decode($)`,imports:[`from base64 import b64encode, b64decode`],mode:`native`},uuid:{encode:`str($)`,decode:`UUID($)`,imports:[`from uuid import UUID`],mode:`native`},"number-special":{encode:`num_to_wire($)`,decode:`wire_to_num($)`,mode:`native`}},rust:{"date-time":{encode:`__SCAFFOLD_RUST_DATETIME_ENCODE__`,decode:`__SCAFFOLD_RUST_DATETIME_DECODE__`,imports:[`use chrono::{DateTime, Utc};`],dep:{name:`chrono`,version:`^0.4`},mode:`lib`},int64:{encode:`__SCAFFOLD_RUST_INT64_ENCODE__`,decode:`__SCAFFOLD_RUST_INT64_DECODE__`,imports:[`use serde_with::DisplayFromStr;`],dep:{name:`serde_with`,version:`^3`},mode:`lib`},decimal:{encode:`__SCAFFOLD_RUST_DECIMAL_ENCODE__`,decode:`__SCAFFOLD_RUST_DECIMAL_DECODE__`,imports:[`use rust_decimal::Decimal;`],dep:{name:`rust_decimal`,version:`^1`},mode:`lib`},byte:{encode:`__SCAFFOLD_RUST_BYTE_ENCODE__`,decode:`__SCAFFOLD_RUST_BYTE_DECODE__`,imports:[`use serde_with::base64::Base64;`],dep:{name:`serde_with`,version:`^3`},mode:`lib`},uuid:{encode:`__SCAFFOLD_RUST_UUID_ENCODE__`,decode:`__SCAFFOLD_RUST_UUID_DECODE__`,imports:[`use uuid::Uuid;`],dep:{name:`uuid`,version:`^1`},mode:`lib`},"number-special":{encode:`__SCAFFOLD_RUST_NUMSPECIAL_ENCODE__`,decode:`__SCAFFOLD_RUST_NUMSPECIAL_DECODE__`,mode:`native`}},go:{"date-time":{encode:`__SCAFFOLD_GO_DATETIME_ENCODE__`,decode:`__SCAFFOLD_GO_DATETIME_DECODE__`,imports:[`"time"`],mode:`native`},int64:{encode:`__SCAFFOLD_GO_INT64_ENCODE__`,decode:`__SCAFFOLD_GO_INT64_DECODE__`,imports:[`"strconv"`],mode:`native`},decimal:{encode:`__SCAFFOLD_GO_DECIMAL_ENCODE__`,decode:`__SCAFFOLD_GO_DECIMAL_DECODE__`,imports:[`"github.com/shopspring/decimal"`],dep:{name:`github.com/shopspring/decimal`,version:`v1`},mode:`lib`},byte:{encode:`__SCAFFOLD_GO_BYTE_ENCODE__`,decode:`__SCAFFOLD_GO_BYTE_DECODE__`,imports:[`"encoding/base64"`],mode:`native`},uuid:{encode:`__SCAFFOLD_GO_UUID_ENCODE__`,decode:`__SCAFFOLD_GO_UUID_DECODE__`,imports:[`"github.com/google/uuid"`],dep:{name:`github.com/google/uuid`,version:`v1`},mode:`lib`},"number-special":{encode:`__SCAFFOLD_GO_NUMSPECIAL_ENCODE__`,decode:`__SCAFFOLD_GO_NUMSPECIAL_DECODE__`,mode:`native`}},java:{"date-time":{encode:`$.toString()`,decode:`Instant.parse($)`,imports:[`import java.time.Instant;`],dep:{name:`jackson-datatype-jsr310`,version:`2.x`},mode:`lib`},int64:{encode:`@JsonFormat(shape = JsonFormat.Shape.STRING)`,decode:`@JsonFormat(shape = JsonFormat.Shape.STRING)`,imports:[`import com.fasterxml.jackson.annotation.JsonFormat;`],mode:`native`},decimal:{encode:`@JsonSerialize(using = ToStringSerializer.class)`,decode:`new BigDecimal($)`,imports:[`import java.math.BigDecimal;`,`import com.fasterxml.jackson.databind.annotation.JsonSerialize;`,`import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;`],mode:`native`},byte:{encode:`$`,decode:`$`,mode:`native`},uuid:{encode:`$.toString()`,decode:`UUID.fromString($)`,imports:[`import java.util.UUID;`],mode:`native`},"number-special":{encode:`@JsonSerialize(using = NumberSpecialSerializer.class)`,decode:`@JsonDeserialize(using = NumberSpecialDeserializer.class)`,imports:[`import com.fasterxml.jackson.databind.annotation.JsonSerialize;`,`import com.fasterxml.jackson.databind.annotation.JsonDeserialize;`],mode:`native`}}});var m=new Set([`string`,`number`,`boolean`,`integer`]);function h(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.$ref!==void 0||t.oneOf||t.anyOf||t.allOf)return!1;let{type:n}=t;return typeof n==`string`?m.has(n):Array.isArray(n)?n.every(e=>m.has(e)||e===`null`):Array.isArray(t.enum)&&t.enum.length>0?t.enum.every(e=>[`string`,`number`,`boolean`].includes(typeof e)):!1}function g(e){if(!e||typeof e!=`object`)return!1;let t=e.properties;return t===void 0||typeof t!=`object`||!t?!1:Object.values(t).every(h)}var _={"decimal.js":`Decimal`};function v(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}Object.entries(_).map(([e,t])=>({pattern:RegExp(`import\\(["'][^"']*${v(e)}[^"']*["']\\)\\.\\w+`,`g`),key:t}));function y(e){return e.words.join(`-`)}function b(e){return e.words.map(C).join(``)}function x(e){return e.words.join(`_`)}function S(e,t={}){let n=[e.namespace,...e.path],r=e.safe||g(e.input)?`GET`:`POST`,i=t.http?.verb?.[e.id]??r,a=`/`+n.map(e=>y(e)).join(`/`),o=n.map(e=>x(e)).join(`_`),s=n.map(e=>x(e)).slice(0,-1).join(`.`),c=b(n[n.length-2]??n[0]),l=b(n[n.length-1]),u=n.map(e=>y(e));return{http:{verb:i,route:a},mcp:{name:o},grpc:{package:s,service:c,method:l},cli:{path:u}}}function C(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function w(e,t={}){let n=t.title??`API`,r=t.version??`0.0.0`,i={};for(let t of e){let{verb:e,route:n}=S(t).http,r=e.toLowerCase(),a={operationId:t.id,summary:t.id,responses:{200:T(t.output)}};if(e===`GET`)a.parameters=E(t.input);else{let e=t.input;typeof e==`object`&&e&&Object.keys(e).length>0&&(a.requestBody={required:!0,content:{"application/json":{schema:e}}})}i[n]===void 0&&(i[n]={}),i[n][r]=a}return{openapi:`3.1.0`,info:{title:n,version:r},paths:i}}function T(e){return typeof e==`object`&&e&&Object.keys(e).length>0?{description:`Success`,content:{"application/json":{schema:e}}}:{description:`Success`}}function E(e){if(typeof e!=`object`||!e||typeof e.properties!=`object`||e.properties===null)return[];let t=Array.isArray(e.required)?e.required:[],n=e.properties;return Object.entries(n).map(([e,n])=>({name:e,in:`query`,required:t.includes(e),schema:n}))}function D(e,t={}){return[{...n(`_meta/openapi`,e,{kind:`query`,safe:!0,output:{type:`object`},transports:[`http`]}),handler:n=>w(e.operations,{title:t.title,version:t.version})}]}var O={id:`openapi`,description:`Mount plugin: serves the OpenAPI 3.1 doc at GET /meta/openapi`,language:`ts`,optionsSchema:{type:`object`,properties:{title:{type:`string`,description:`OpenAPI info.title`},version:{type:`string`,description:`OpenAPI info.version`}},additionalProperties:!1},capabilities:{mount:{operations(e,t){return D(e,t)}}}};exports.default=O,exports.openapiPlugin=O;
|
package/index.mjs
CHANGED
|
@@ -1,209 +1,562 @@
|
|
|
1
1
|
import "node:fs";
|
|
2
|
-
import { createRequire as
|
|
2
|
+
import { createRequire as e } from "node:module";
|
|
3
3
|
import "node:path";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
//#region ../apigen-core-client/src/lib/plugin.ts
|
|
5
|
+
function t(e) {
|
|
6
|
+
return {
|
|
7
|
+
raw: e,
|
|
8
|
+
words: e.split(/(?=[A-Z])|[-_]/).map((e) => e.toLowerCase()).filter(Boolean)
|
|
9
|
+
};
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
typeText: n.typeText ?? null
|
|
29
|
-
};
|
|
30
|
-
return n.hasCtx !== void 0 && (s.hasCtx = n.hasCtx), n.transports !== void 0 && (s.transports = n.transports), s;
|
|
11
|
+
function n(e, n, r = {}) {
|
|
12
|
+
let i = e.split("/");
|
|
13
|
+
if (i.length < 2 || i.some((e) => e.length === 0)) throw Error(`syntheticOp: id "${e}" must be "<namespace>/<path...>" with non-empty segments`);
|
|
14
|
+
let [a, ...o] = i, s = a.replace(/^_+/, ""), c = r.kind ?? "action", l = {
|
|
15
|
+
id: e,
|
|
16
|
+
host: n.host,
|
|
17
|
+
namespace: t(s),
|
|
18
|
+
path: o.map(t),
|
|
19
|
+
kind: c,
|
|
20
|
+
async: r.async ?? !1,
|
|
21
|
+
streaming: r.streaming ?? !1,
|
|
22
|
+
safe: r.safe ?? c === "query",
|
|
23
|
+
input: r.input ?? {},
|
|
24
|
+
output: r.output ?? {},
|
|
25
|
+
envelope: r.envelope ?? {},
|
|
26
|
+
typeText: r.typeText ?? null
|
|
27
|
+
};
|
|
28
|
+
return r.hasCtx !== void 0 && (l.hasCtx = r.hasCtx), r.transports !== void 0 && (l.transports = r.transports), l;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
e(import.meta.url);
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region ../apigen-base-logical/src/lib/codecs/date-time.ts
|
|
33
|
+
var r = {
|
|
34
|
+
id: "date-time",
|
|
35
|
+
kind: "scalar",
|
|
36
|
+
schema: {
|
|
37
|
+
type: "string",
|
|
38
|
+
format: "date-time"
|
|
39
|
+
},
|
|
40
|
+
matches(e) {
|
|
41
|
+
return e.type === "string" && e.format === "date-time";
|
|
42
|
+
},
|
|
43
|
+
ownsValue(e) {
|
|
44
|
+
return e instanceof Date;
|
|
45
|
+
},
|
|
46
|
+
encode(e, t, n) {
|
|
47
|
+
return e.toISOString();
|
|
48
|
+
},
|
|
49
|
+
decode(e, t, n) {
|
|
50
|
+
if (typeof e != "string") {
|
|
51
|
+
if (n.mode === "strict") throw TypeError(`[date-time] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
52
|
+
return new Date(String(e));
|
|
53
|
+
}
|
|
54
|
+
if (n.mode === "strict" && Number.isNaN(new Date(e).getTime())) throw TypeError(`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(e)}`);
|
|
55
|
+
return new Date(e);
|
|
56
|
+
}
|
|
57
|
+
}, i = {
|
|
58
|
+
id: "int64",
|
|
59
|
+
kind: "scalar",
|
|
60
|
+
schema: {
|
|
61
|
+
type: "string",
|
|
62
|
+
format: "int64"
|
|
63
|
+
},
|
|
64
|
+
matches(e) {
|
|
65
|
+
return e.type === "string" && e.format === "int64";
|
|
66
|
+
},
|
|
67
|
+
ownsValue(e) {
|
|
68
|
+
return typeof e == "bigint";
|
|
69
|
+
},
|
|
70
|
+
encode(e, t, n) {
|
|
71
|
+
return String(e);
|
|
72
|
+
},
|
|
73
|
+
decode(e, t, n) {
|
|
74
|
+
if (typeof e != "string") {
|
|
75
|
+
if (n.mode === "strict") throw TypeError(`[int64] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
76
|
+
try {
|
|
77
|
+
return BigInt(Math.trunc(Number(e)));
|
|
78
|
+
} catch {
|
|
79
|
+
return BigInt(0);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (n.mode === "strict") return BigInt(e);
|
|
83
|
+
if (/^-?\d+$/.test(e)) try {
|
|
84
|
+
return BigInt(e);
|
|
85
|
+
} catch {
|
|
86
|
+
return BigInt(0);
|
|
87
|
+
}
|
|
88
|
+
return BigInt(0);
|
|
89
|
+
}
|
|
35
90
|
};
|
|
36
|
-
|
|
37
|
-
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../apigen-base-logical/src/lib/codecs/decimal.ts
|
|
93
|
+
function a(e) {
|
|
94
|
+
return e;
|
|
38
95
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
96
|
+
var o = {
|
|
97
|
+
id: "decimal",
|
|
98
|
+
kind: "scalar",
|
|
99
|
+
schema: {
|
|
100
|
+
type: "string",
|
|
101
|
+
format: "decimal"
|
|
102
|
+
},
|
|
103
|
+
matches(e) {
|
|
104
|
+
return e.type === "string" && e.format === "decimal";
|
|
105
|
+
},
|
|
106
|
+
encode(e, t, n) {
|
|
107
|
+
return e;
|
|
108
|
+
},
|
|
109
|
+
decode(e, t, n) {
|
|
110
|
+
if (typeof e != "string") {
|
|
111
|
+
if (n.mode === "strict") throw TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
112
|
+
return a(String(e));
|
|
113
|
+
}
|
|
114
|
+
if (n.mode === "strict" && !/^-?\d+(\.\d+)?$/.test(e)) throw TypeError(`[decimal] wire value "${e}" at "${n.path}" is not a valid decimal string`);
|
|
115
|
+
return a(e);
|
|
116
|
+
}
|
|
117
|
+
}, s = {
|
|
118
|
+
id: "byte",
|
|
119
|
+
kind: "scalar",
|
|
120
|
+
schema: {
|
|
121
|
+
type: "string",
|
|
122
|
+
format: "byte"
|
|
123
|
+
},
|
|
124
|
+
matches(e) {
|
|
125
|
+
return e.type === "string" && e.format === "byte";
|
|
126
|
+
},
|
|
127
|
+
ownsValue(e) {
|
|
128
|
+
return e instanceof Uint8Array;
|
|
129
|
+
},
|
|
130
|
+
encode(e, t, n) {
|
|
131
|
+
return Buffer.from(e).toString("base64");
|
|
132
|
+
},
|
|
133
|
+
decode(e, t, n) {
|
|
134
|
+
if (typeof e != "string") {
|
|
135
|
+
if (n.mode === "strict") throw TypeError(`[byte] expected a base64 string on the wire at "${n.path}", got ${typeof e}`);
|
|
136
|
+
return /* @__PURE__ */ new Uint8Array();
|
|
137
|
+
}
|
|
138
|
+
if (n.mode === "strict" && !/^[A-Za-z0-9+/]*={0,2}$/.test(e)) throw TypeError(`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${e}"`);
|
|
139
|
+
return new Uint8Array(Buffer.from(e, "base64"));
|
|
140
|
+
}
|
|
141
|
+
}, c = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, l = {
|
|
142
|
+
id: "uuid",
|
|
143
|
+
kind: "scalar",
|
|
144
|
+
schema: {
|
|
145
|
+
type: "string",
|
|
146
|
+
format: "uuid"
|
|
147
|
+
},
|
|
148
|
+
matches(e) {
|
|
149
|
+
return e.type === "string" && e.format === "uuid";
|
|
150
|
+
},
|
|
151
|
+
encode(e, t, n) {
|
|
152
|
+
return e.toLowerCase();
|
|
153
|
+
},
|
|
154
|
+
decode(e, t, n) {
|
|
155
|
+
if (typeof e != "string") {
|
|
156
|
+
if (n.mode === "strict") throw TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`);
|
|
157
|
+
return String(e).toLowerCase();
|
|
158
|
+
}
|
|
159
|
+
if (n.mode === "strict" && !c.test(e)) throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);
|
|
160
|
+
return e;
|
|
161
|
+
}
|
|
162
|
+
}, u = "NaN", d = "Infinity", f = "-Infinity", p = /* @__PURE__ */ new Set([
|
|
163
|
+
u,
|
|
164
|
+
d,
|
|
165
|
+
f
|
|
166
|
+
]);
|
|
167
|
+
r.id, i.id, o.id, s.id, l.id, {
|
|
168
|
+
id: "number-special",
|
|
169
|
+
kind: "scalar",
|
|
170
|
+
schema: { type: "number" },
|
|
171
|
+
matches(e) {
|
|
172
|
+
return e.type === "number" && e.format === void 0;
|
|
173
|
+
},
|
|
174
|
+
ownsValue(e) {
|
|
175
|
+
return typeof e == "number" && !Number.isFinite(e);
|
|
176
|
+
},
|
|
177
|
+
encode(e, t, n) {
|
|
178
|
+
return Number.isNaN(e) ? u : e === Infinity ? d : e === -Infinity ? f : e;
|
|
179
|
+
},
|
|
180
|
+
decode(e, t, n) {
|
|
181
|
+
if (typeof e == "number") return e;
|
|
182
|
+
if (typeof e == "string") {
|
|
183
|
+
if (e === u) return NaN;
|
|
184
|
+
if (e === d) return Infinity;
|
|
185
|
+
if (e === f) return -Infinity;
|
|
186
|
+
let t = Number(e);
|
|
187
|
+
if (!Number.isNaN(t)) return t;
|
|
188
|
+
}
|
|
189
|
+
if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...p].join(", ")}.`);
|
|
190
|
+
return NaN;
|
|
191
|
+
}
|
|
192
|
+
}.id, Object.freeze({
|
|
193
|
+
typescript: {
|
|
194
|
+
"date-time": {
|
|
195
|
+
encode: "$.toISOString()",
|
|
196
|
+
decode: "new Date($)",
|
|
197
|
+
mode: "native"
|
|
198
|
+
},
|
|
199
|
+
int64: {
|
|
200
|
+
encode: "String($)",
|
|
201
|
+
decode: "BigInt($)",
|
|
202
|
+
mode: "native"
|
|
203
|
+
},
|
|
204
|
+
decimal: {
|
|
205
|
+
encode: "$.toString()",
|
|
206
|
+
decode: "new Decimal($)",
|
|
207
|
+
imports: [],
|
|
208
|
+
dep: {
|
|
209
|
+
name: "decimal.js",
|
|
210
|
+
version: "^10"
|
|
211
|
+
},
|
|
212
|
+
mode: "branded"
|
|
213
|
+
},
|
|
214
|
+
byte: {
|
|
215
|
+
encode: "Buffer.from($).toString('base64')",
|
|
216
|
+
decode: "new Uint8Array(Buffer.from($, 'base64'))",
|
|
217
|
+
mode: "native"
|
|
218
|
+
},
|
|
219
|
+
uuid: {
|
|
220
|
+
encode: "$.toLowerCase()",
|
|
221
|
+
decode: "$",
|
|
222
|
+
mode: "native"
|
|
223
|
+
},
|
|
224
|
+
"number-special": {
|
|
225
|
+
encode: "numToWire($)",
|
|
226
|
+
decode: "wireToNum($)",
|
|
227
|
+
mode: "native"
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
python: {
|
|
231
|
+
"date-time": {
|
|
232
|
+
encode: "$.isoformat()",
|
|
233
|
+
decode: "datetime.fromisoformat($)",
|
|
234
|
+
imports: ["from datetime import datetime"],
|
|
235
|
+
mode: "native"
|
|
236
|
+
},
|
|
237
|
+
int64: {
|
|
238
|
+
encode: "str($)",
|
|
239
|
+
decode: "int($)",
|
|
240
|
+
mode: "native"
|
|
241
|
+
},
|
|
242
|
+
decimal: {
|
|
243
|
+
encode: "str($)",
|
|
244
|
+
decode: "Decimal($)",
|
|
245
|
+
imports: ["from decimal import Decimal"],
|
|
246
|
+
mode: "native"
|
|
247
|
+
},
|
|
248
|
+
byte: {
|
|
249
|
+
encode: "b64encode($).decode()",
|
|
250
|
+
decode: "b64decode($)",
|
|
251
|
+
imports: ["from base64 import b64encode, b64decode"],
|
|
252
|
+
mode: "native"
|
|
253
|
+
},
|
|
254
|
+
uuid: {
|
|
255
|
+
encode: "str($)",
|
|
256
|
+
decode: "UUID($)",
|
|
257
|
+
imports: ["from uuid import UUID"],
|
|
258
|
+
mode: "native"
|
|
259
|
+
},
|
|
260
|
+
"number-special": {
|
|
261
|
+
encode: "num_to_wire($)",
|
|
262
|
+
decode: "wire_to_num($)",
|
|
263
|
+
mode: "native"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
rust: {
|
|
267
|
+
"date-time": {
|
|
268
|
+
encode: "__SCAFFOLD_RUST_DATETIME_ENCODE__",
|
|
269
|
+
decode: "__SCAFFOLD_RUST_DATETIME_DECODE__",
|
|
270
|
+
imports: ["use chrono::{DateTime, Utc};"],
|
|
271
|
+
dep: {
|
|
272
|
+
name: "chrono",
|
|
273
|
+
version: "^0.4"
|
|
274
|
+
},
|
|
275
|
+
mode: "lib"
|
|
276
|
+
},
|
|
277
|
+
int64: {
|
|
278
|
+
encode: "__SCAFFOLD_RUST_INT64_ENCODE__",
|
|
279
|
+
decode: "__SCAFFOLD_RUST_INT64_DECODE__",
|
|
280
|
+
imports: ["use serde_with::DisplayFromStr;"],
|
|
281
|
+
dep: {
|
|
282
|
+
name: "serde_with",
|
|
283
|
+
version: "^3"
|
|
284
|
+
},
|
|
285
|
+
mode: "lib"
|
|
286
|
+
},
|
|
287
|
+
decimal: {
|
|
288
|
+
encode: "__SCAFFOLD_RUST_DECIMAL_ENCODE__",
|
|
289
|
+
decode: "__SCAFFOLD_RUST_DECIMAL_DECODE__",
|
|
290
|
+
imports: ["use rust_decimal::Decimal;"],
|
|
291
|
+
dep: {
|
|
292
|
+
name: "rust_decimal",
|
|
293
|
+
version: "^1"
|
|
294
|
+
},
|
|
295
|
+
mode: "lib"
|
|
296
|
+
},
|
|
297
|
+
byte: {
|
|
298
|
+
encode: "__SCAFFOLD_RUST_BYTE_ENCODE__",
|
|
299
|
+
decode: "__SCAFFOLD_RUST_BYTE_DECODE__",
|
|
300
|
+
imports: ["use serde_with::base64::Base64;"],
|
|
301
|
+
dep: {
|
|
302
|
+
name: "serde_with",
|
|
303
|
+
version: "^3"
|
|
304
|
+
},
|
|
305
|
+
mode: "lib"
|
|
306
|
+
},
|
|
307
|
+
uuid: {
|
|
308
|
+
encode: "__SCAFFOLD_RUST_UUID_ENCODE__",
|
|
309
|
+
decode: "__SCAFFOLD_RUST_UUID_DECODE__",
|
|
310
|
+
imports: ["use uuid::Uuid;"],
|
|
311
|
+
dep: {
|
|
312
|
+
name: "uuid",
|
|
313
|
+
version: "^1"
|
|
314
|
+
},
|
|
315
|
+
mode: "lib"
|
|
316
|
+
},
|
|
317
|
+
"number-special": {
|
|
318
|
+
encode: "__SCAFFOLD_RUST_NUMSPECIAL_ENCODE__",
|
|
319
|
+
decode: "__SCAFFOLD_RUST_NUMSPECIAL_DECODE__",
|
|
320
|
+
mode: "native"
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
go: {
|
|
324
|
+
"date-time": {
|
|
325
|
+
encode: "__SCAFFOLD_GO_DATETIME_ENCODE__",
|
|
326
|
+
decode: "__SCAFFOLD_GO_DATETIME_DECODE__",
|
|
327
|
+
imports: ["\"time\""],
|
|
328
|
+
mode: "native"
|
|
329
|
+
},
|
|
330
|
+
int64: {
|
|
331
|
+
encode: "__SCAFFOLD_GO_INT64_ENCODE__",
|
|
332
|
+
decode: "__SCAFFOLD_GO_INT64_DECODE__",
|
|
333
|
+
imports: ["\"strconv\""],
|
|
334
|
+
mode: "native"
|
|
335
|
+
},
|
|
336
|
+
decimal: {
|
|
337
|
+
encode: "__SCAFFOLD_GO_DECIMAL_ENCODE__",
|
|
338
|
+
decode: "__SCAFFOLD_GO_DECIMAL_DECODE__",
|
|
339
|
+
imports: ["\"github.com/shopspring/decimal\""],
|
|
340
|
+
dep: {
|
|
341
|
+
name: "github.com/shopspring/decimal",
|
|
342
|
+
version: "v1"
|
|
343
|
+
},
|
|
344
|
+
mode: "lib"
|
|
345
|
+
},
|
|
346
|
+
byte: {
|
|
347
|
+
encode: "__SCAFFOLD_GO_BYTE_ENCODE__",
|
|
348
|
+
decode: "__SCAFFOLD_GO_BYTE_DECODE__",
|
|
349
|
+
imports: ["\"encoding/base64\""],
|
|
350
|
+
mode: "native"
|
|
351
|
+
},
|
|
352
|
+
uuid: {
|
|
353
|
+
encode: "__SCAFFOLD_GO_UUID_ENCODE__",
|
|
354
|
+
decode: "__SCAFFOLD_GO_UUID_DECODE__",
|
|
355
|
+
imports: ["\"github.com/google/uuid\""],
|
|
356
|
+
dep: {
|
|
357
|
+
name: "github.com/google/uuid",
|
|
358
|
+
version: "v1"
|
|
359
|
+
},
|
|
360
|
+
mode: "lib"
|
|
361
|
+
},
|
|
362
|
+
"number-special": {
|
|
363
|
+
encode: "__SCAFFOLD_GO_NUMSPECIAL_ENCODE__",
|
|
364
|
+
decode: "__SCAFFOLD_GO_NUMSPECIAL_DECODE__",
|
|
365
|
+
mode: "native"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
java: {
|
|
369
|
+
"date-time": {
|
|
370
|
+
encode: "$.toString()",
|
|
371
|
+
decode: "Instant.parse($)",
|
|
372
|
+
imports: ["import java.time.Instant;"],
|
|
373
|
+
dep: {
|
|
374
|
+
name: "jackson-datatype-jsr310",
|
|
375
|
+
version: "2.x"
|
|
376
|
+
},
|
|
377
|
+
mode: "lib"
|
|
378
|
+
},
|
|
379
|
+
int64: {
|
|
380
|
+
encode: "@JsonFormat(shape = JsonFormat.Shape.STRING)",
|
|
381
|
+
decode: "@JsonFormat(shape = JsonFormat.Shape.STRING)",
|
|
382
|
+
imports: ["import com.fasterxml.jackson.annotation.JsonFormat;"],
|
|
383
|
+
mode: "native"
|
|
384
|
+
},
|
|
385
|
+
decimal: {
|
|
386
|
+
encode: "@JsonSerialize(using = ToStringSerializer.class)",
|
|
387
|
+
decode: "new BigDecimal($)",
|
|
388
|
+
imports: [
|
|
389
|
+
"import java.math.BigDecimal;",
|
|
390
|
+
"import com.fasterxml.jackson.databind.annotation.JsonSerialize;",
|
|
391
|
+
"import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;"
|
|
392
|
+
],
|
|
393
|
+
mode: "native"
|
|
394
|
+
},
|
|
395
|
+
byte: {
|
|
396
|
+
encode: "$",
|
|
397
|
+
decode: "$",
|
|
398
|
+
mode: "native"
|
|
399
|
+
},
|
|
400
|
+
uuid: {
|
|
401
|
+
encode: "$.toString()",
|
|
402
|
+
decode: "UUID.fromString($)",
|
|
403
|
+
imports: ["import java.util.UUID;"],
|
|
404
|
+
mode: "native"
|
|
405
|
+
},
|
|
406
|
+
"number-special": {
|
|
407
|
+
encode: "@JsonSerialize(using = NumberSpecialSerializer.class)",
|
|
408
|
+
decode: "@JsonDeserialize(using = NumberSpecialDeserializer.class)",
|
|
409
|
+
imports: ["import com.fasterxml.jackson.databind.annotation.JsonSerialize;", "import com.fasterxml.jackson.databind.annotation.JsonDeserialize;"],
|
|
410
|
+
mode: "native"
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region ../apigen-core-client/src/lib/get-safety.ts
|
|
416
|
+
var m = /* @__PURE__ */ new Set([
|
|
417
|
+
"string",
|
|
418
|
+
"number",
|
|
419
|
+
"boolean",
|
|
420
|
+
"integer"
|
|
421
|
+
]);
|
|
422
|
+
function h(e) {
|
|
423
|
+
if (typeof e != "object" || !e) return !1;
|
|
424
|
+
let t = e;
|
|
425
|
+
if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf) return !1;
|
|
426
|
+
let { type: n } = t;
|
|
427
|
+
return typeof n == "string" ? m.has(n) : Array.isArray(n) ? n.every((e) => m.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
|
|
428
|
+
"string",
|
|
429
|
+
"number",
|
|
430
|
+
"boolean"
|
|
431
|
+
].includes(typeof e)) : !1;
|
|
62
432
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return t === void 0 || typeof t != "object" || t === null ? !1 : Object.values(t).every(
|
|
68
|
-
A
|
|
69
|
-
);
|
|
433
|
+
function g(e) {
|
|
434
|
+
if (!e || typeof e != "object") return !1;
|
|
435
|
+
let t = e.properties;
|
|
436
|
+
return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(h);
|
|
70
437
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
function
|
|
75
|
-
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region ../apigen-core-client/src/lib/schema-builders/ts-json-schema.ts
|
|
440
|
+
var _ = { "decimal.js": "Decimal" };
|
|
441
|
+
function v(e) {
|
|
442
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
443
|
}
|
|
77
|
-
Object.entries(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// characters between the quote and the specifier, and between the specifier
|
|
81
|
-
// and the closing quote. The trailing member accessor (`.default`, `.Decimal`,
|
|
82
|
-
// …) is matched generically (`\w+`) rather than anchored to one spelling —
|
|
83
|
-
// see the doc comment above for why.
|
|
84
|
-
pattern: new RegExp(
|
|
85
|
-
`import\\(["'][^"']*${x(e)}[^"']*["']\\)\\.\\w+`,
|
|
86
|
-
"g"
|
|
87
|
-
),
|
|
88
|
-
key: t
|
|
444
|
+
Object.entries(_).map(([e, t]) => ({
|
|
445
|
+
pattern: RegExp(`import\\(["'][^"']*${v(e)}[^"']*["']\\)\\.\\w+`, "g"),
|
|
446
|
+
key: t
|
|
89
447
|
}));
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region ../apigen-engine-naming/src/lib/naming.ts
|
|
90
450
|
function y(e) {
|
|
91
|
-
|
|
451
|
+
return e.words.join("-");
|
|
92
452
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
453
|
+
function b(e) {
|
|
454
|
+
return e.words.map(C).join("");
|
|
95
455
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
456
|
+
function x(e) {
|
|
457
|
+
return e.words.join("_");
|
|
98
458
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
459
|
+
function S(e, t = {}) {
|
|
460
|
+
let n = [e.namespace, ...e.path], r = e.safe || g(e.input) ? "GET" : "POST", i = t.http?.verb?.[e.id] ?? r, a = "/" + n.map((e) => y(e)).join("/"), o = n.map((e) => x(e)).join("_"), s = n.map((e) => x(e)).slice(0, -1).join("."), c = b(n[n.length - 2] ?? n[0]), l = b(n[n.length - 1]), u = n.map((e) => y(e));
|
|
461
|
+
return {
|
|
462
|
+
http: {
|
|
463
|
+
verb: i,
|
|
464
|
+
route: a
|
|
465
|
+
},
|
|
466
|
+
mcp: { name: o },
|
|
467
|
+
grpc: {
|
|
468
|
+
package: s,
|
|
469
|
+
service: c,
|
|
470
|
+
method: l
|
|
471
|
+
},
|
|
472
|
+
cli: { path: u }
|
|
473
|
+
};
|
|
108
474
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
475
|
+
function C(e) {
|
|
476
|
+
return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
|
|
111
477
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
paths: o
|
|
141
|
-
};
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region ../codegen/openapi/src/lib/to-openapi.ts
|
|
480
|
+
function w(e, t = {}) {
|
|
481
|
+
let n = t.title ?? "API", r = t.version ?? "0.0.0", i = {};
|
|
482
|
+
for (let t of e) {
|
|
483
|
+
let { verb: e, route: n } = S(t).http, r = e.toLowerCase(), a = {
|
|
484
|
+
operationId: t.id,
|
|
485
|
+
summary: t.id,
|
|
486
|
+
responses: { 200: T(t.output) }
|
|
487
|
+
};
|
|
488
|
+
if (e === "GET") a.parameters = E(t.input);
|
|
489
|
+
else {
|
|
490
|
+
let e = t.input;
|
|
491
|
+
typeof e == "object" && e && Object.keys(e).length > 0 && (a.requestBody = {
|
|
492
|
+
required: !0,
|
|
493
|
+
content: { "application/json": { schema: e } }
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
i[n] === void 0 && (i[n] = {}), i[n][r] = a;
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
openapi: "3.1.0",
|
|
500
|
+
info: {
|
|
501
|
+
title: n,
|
|
502
|
+
version: r
|
|
503
|
+
},
|
|
504
|
+
paths: i
|
|
505
|
+
};
|
|
142
506
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
} : { description: "Success" };
|
|
507
|
+
function T(e) {
|
|
508
|
+
return typeof e == "object" && e && Object.keys(e).length > 0 ? {
|
|
509
|
+
description: "Success",
|
|
510
|
+
content: { "application/json": { schema: e } }
|
|
511
|
+
} : { description: "Success" };
|
|
150
512
|
}
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}));
|
|
513
|
+
function E(e) {
|
|
514
|
+
if (typeof e != "object" || !e || typeof e.properties != "object" || e.properties === null) return [];
|
|
515
|
+
let t = Array.isArray(e.required) ? e.required : [], n = e.properties;
|
|
516
|
+
return Object.entries(n).map(([e, n]) => ({
|
|
517
|
+
name: e,
|
|
518
|
+
in: "query",
|
|
519
|
+
required: t.includes(e),
|
|
520
|
+
schema: n
|
|
521
|
+
}));
|
|
161
522
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
title: t.title,
|
|
178
|
-
version: t.version
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
];
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/lib/plugin.ts
|
|
525
|
+
function D(e, t = {}) {
|
|
526
|
+
return [{
|
|
527
|
+
...n("_meta/openapi", e, {
|
|
528
|
+
kind: "query",
|
|
529
|
+
safe: !0,
|
|
530
|
+
output: { type: "object" },
|
|
531
|
+
transports: ["http"]
|
|
532
|
+
}),
|
|
533
|
+
handler: (n) => w(e.operations, {
|
|
534
|
+
title: t.title,
|
|
535
|
+
version: t.version
|
|
536
|
+
})
|
|
537
|
+
}];
|
|
182
538
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
export {
|
|
207
|
-
G as default,
|
|
208
|
-
G as openapiPlugin
|
|
539
|
+
var O = {
|
|
540
|
+
id: "openapi",
|
|
541
|
+
description: "Mount plugin: serves the OpenAPI 3.1 doc at GET /meta/openapi",
|
|
542
|
+
language: "ts",
|
|
543
|
+
optionsSchema: {
|
|
544
|
+
type: "object",
|
|
545
|
+
properties: {
|
|
546
|
+
title: {
|
|
547
|
+
type: "string",
|
|
548
|
+
description: "OpenAPI info.title"
|
|
549
|
+
},
|
|
550
|
+
version: {
|
|
551
|
+
type: "string",
|
|
552
|
+
description: "OpenAPI info.version"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
additionalProperties: !1
|
|
556
|
+
},
|
|
557
|
+
capabilities: { mount: { operations(e, t) {
|
|
558
|
+
return D(e, t);
|
|
559
|
+
} } }
|
|
209
560
|
};
|
|
561
|
+
//#endregion
|
|
562
|
+
export { O as default, O as openapiPlugin };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhd/apigen-plugin-openapi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@adhd/apigen-core-client": "^0.3.
|
|
7
|
-
"@adhd/apigen-codegen-openapi": "^0.2.
|
|
6
|
+
"@adhd/apigen-core-client": "^0.3.3",
|
|
7
|
+
"@adhd/apigen-codegen-openapi": "^0.2.5"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|