@adhd/apigen-plugin-openapi 0.2.5 → 0.2.7

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,11 @@
1
+ ## 0.2.7 (2026-10-21)
2
+
3
+ This was a version bump only for apigen-plugin-openapi to align it with other projects, there were no code changes.
4
+
5
+ ## 0.2.6 (2026-10-15)
6
+
7
+ This was a version bump only for apigen-plugin-openapi to align it with other projects, there were no code changes.
8
+
1
9
  ## 0.2.4 (2026-09-26)
2
10
 
3
11
  ### 🚀 Features
package/index.js CHANGED
@@ -1 +1,12 @@
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;
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=`$apigen`;`
2
+ function __apigenEnvelopeEncode(v) {
3
+ // Schema-less position: pass typed JSON through unchanged. A richer host
4
+ // prelude may wrap recognized runtime types as { ${JSON.stringify(r)}: id, v }.
5
+ return v;
6
+ }
7
+ function __apigenEnvelopeDecode(w) {
8
+ return w != null && typeof w === 'object' && ${JSON.stringify(r)} in w
9
+ ? w.v
10
+ : w;
11
+ }
12
+ `.trim(),Object.freeze({"date-time":{encode:`$.toISOString()`,decode:`new Date($)`,mode:`native`},int64:{encode:`String($)`,decode:`BigInt($)`,mode:`native`},byte:{encode:`Buffer.from($).toString('base64')`,decode:`new Uint8Array(Buffer.from($, 'base64'))`,mode:`native`}});var i={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)}},a={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 o(e){return e}var s={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 o(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 o(e)}},c={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`))}},l=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,u={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`&&!l.test(e))throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);return e}},d=`NaN`,f=`Infinity`,p=`-Infinity`,m=new Set([d,f,p]);i.id,a.id,s.id,c.id,u.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)?d:e===1/0?f:e===-1/0?p:e},decode(e,t,n){if(typeof e==`number`)return e;if(typeof e==`string`){if(e===d)return NaN;if(e===f)return 1/0;if(e===p)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 ${[...m].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 h=new Set([`string`,`number`,`boolean`,`integer`]);function g(e){if(!Array.isArray(e)||e.length<2)return!1;let t=0;for(let n of e){if(typeof n!=`object`||!n)return!1;let{type:e,$ref:r,oneOf:i,anyOf:a,allOf:o}=n;if(r!==void 0||i||a||o)return!1;if(e!==`null`){if(typeof e==`string`&&h.has(e)){t++;continue}return!1}}return t===1}function _(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.$ref!==void 0||t.allOf)return!1;if(t.oneOf||t.anyOf)return g(t.oneOf??t.anyOf);let{type:n}=t;return typeof n==`string`?h.has(n):Array.isArray(n)?n.every(e=>h.has(e)||e===`null`):Array.isArray(t.enum)&&t.enum.length>0?t.enum.every(e=>[`string`,`number`,`boolean`].includes(typeof e)):!1}function v(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(_)}var y={"decimal.js":`Decimal`};function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}Object.entries(y).map(([e,t])=>({pattern:RegExp(`import\\(["'][^"']*${b(e)}[^"']*["']\\)\\.\\w+`,`g`),key:t}));function x(e){return e.words.join(`-`)}function S(e){return e.words.map(T).join(``)}function C(e){return e.words.join(`_`)}function w(e,t={}){let n=[e.namespace,...e.path],r=e.safe||v(e.input)?`GET`:`POST`,i=t.http?.verb?.[e.id]??r,a=`/`+n.map(e=>x(e)).join(`/`),o=n.map(e=>C(e)).join(`_`),s=n.map(e=>C(e)).slice(0,-1).join(`.`),c=S(n[n.length-2]??n[0]),l=S(n[n.length-1]),u=n.map(e=>x(e));return{http:{verb:i,route:a},mcp:{name:o},grpc:{package:s,service:c,method:l},cli:{path:u}}}function T(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function E(e,t={}){let n=t.title??`API`,r=t.version??`0.0.0`,i={};for(let t of e){let{verb:e,route:n}=w(t).http,r=e.toLowerCase(),a={operationId:t.id,summary:t.id,responses:{200:D(t.output)}};if(e===`GET`)a.parameters=O(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 D(e){return typeof e==`object`&&e&&Object.keys(e).length>0?{description:`Success`,content:{"application/json":{schema:e}}}:{description:`Success`}}function O(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 k(e,t={}){return[{...n(`_meta/openapi`,e,{kind:`query`,safe:!0,output:{type:`object`},transports:[`http`]}),handler:n=>E(e.operations,{title:t.title,version:t.version})}]}var A={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=A,exports.openapiPlugin=A;
package/index.mjs CHANGED
@@ -29,8 +29,39 @@ function n(e, n, r = {}) {
29
29
  }
30
30
  e(import.meta.url);
31
31
  //#endregion
32
+ //#region ../apigen-base-logical/src/lib/contracts.ts
33
+ var r = "$apigen";
34
+ `
35
+ function __apigenEnvelopeEncode(v) {
36
+ // Schema-less position: pass typed JSON through unchanged. A richer host
37
+ // prelude may wrap recognized runtime types as { ${JSON.stringify(r)}: id, v }.
38
+ return v;
39
+ }
40
+ function __apigenEnvelopeDecode(w) {
41
+ return w != null && typeof w === 'object' && ${JSON.stringify(r)} in w
42
+ ? w.v
43
+ : w;
44
+ }
45
+ `.trim(), Object.freeze({
46
+ "date-time": {
47
+ encode: "$.toISOString()",
48
+ decode: "new Date($)",
49
+ mode: "native"
50
+ },
51
+ int64: {
52
+ encode: "String($)",
53
+ decode: "BigInt($)",
54
+ mode: "native"
55
+ },
56
+ byte: {
57
+ encode: "Buffer.from($).toString('base64')",
58
+ decode: "new Uint8Array(Buffer.from($, 'base64'))",
59
+ mode: "native"
60
+ }
61
+ });
62
+ //#endregion
32
63
  //#region ../apigen-base-logical/src/lib/codecs/date-time.ts
33
- var r = {
64
+ var i = {
34
65
  id: "date-time",
35
66
  kind: "scalar",
36
67
  schema: {
@@ -54,7 +85,7 @@ var r = {
54
85
  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
86
  return new Date(e);
56
87
  }
57
- }, i = {
88
+ }, a = {
58
89
  id: "int64",
59
90
  kind: "scalar",
60
91
  schema: {
@@ -90,10 +121,10 @@ var r = {
90
121
  };
91
122
  //#endregion
92
123
  //#region ../apigen-base-logical/src/lib/codecs/decimal.ts
93
- function a(e) {
124
+ function o(e) {
94
125
  return e;
95
126
  }
96
- var o = {
127
+ var s = {
97
128
  id: "decimal",
98
129
  kind: "scalar",
99
130
  schema: {
@@ -109,12 +140,12 @@ var o = {
109
140
  decode(e, t, n) {
110
141
  if (typeof e != "string") {
111
142
  if (n.mode === "strict") throw TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`);
112
- return a(String(e));
143
+ return o(String(e));
113
144
  }
114
145
  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);
146
+ return o(e);
116
147
  }
117
- }, s = {
148
+ }, c = {
118
149
  id: "byte",
119
150
  kind: "scalar",
120
151
  schema: {
@@ -138,7 +169,7 @@ var o = {
138
169
  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
170
  return new Uint8Array(Buffer.from(e, "base64"));
140
171
  }
141
- }, c = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, l = {
172
+ }, l = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, u = {
142
173
  id: "uuid",
143
174
  kind: "scalar",
144
175
  schema: {
@@ -156,15 +187,15 @@ var o = {
156
187
  if (n.mode === "strict") throw TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`);
157
188
  return String(e).toLowerCase();
158
189
  }
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`);
190
+ if (n.mode === "strict" && !l.test(e)) throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);
160
191
  return e;
161
192
  }
162
- }, u = "NaN", d = "Infinity", f = "-Infinity", p = /* @__PURE__ */ new Set([
163
- u,
193
+ }, d = "NaN", f = "Infinity", p = "-Infinity", m = /* @__PURE__ */ new Set([
164
194
  d,
165
- f
195
+ f,
196
+ p
166
197
  ]);
167
- r.id, i.id, o.id, s.id, l.id, {
198
+ i.id, a.id, s.id, c.id, u.id, {
168
199
  id: "number-special",
169
200
  kind: "scalar",
170
201
  schema: { type: "number" },
@@ -175,18 +206,18 @@ r.id, i.id, o.id, s.id, l.id, {
175
206
  return typeof e == "number" && !Number.isFinite(e);
176
207
  },
177
208
  encode(e, t, n) {
178
- return Number.isNaN(e) ? u : e === Infinity ? d : e === -Infinity ? f : e;
209
+ return Number.isNaN(e) ? d : e === Infinity ? f : e === -Infinity ? p : e;
179
210
  },
180
211
  decode(e, t, n) {
181
212
  if (typeof e == "number") return e;
182
213
  if (typeof e == "string") {
183
- if (e === u) return NaN;
184
- if (e === d) return Infinity;
185
- if (e === f) return -Infinity;
214
+ if (e === d) return NaN;
215
+ if (e === f) return Infinity;
216
+ if (e === p) return -Infinity;
186
217
  let t = Number(e);
187
218
  if (!Number.isNaN(t)) return t;
188
219
  }
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(", ")}.`);
220
+ if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...m].join(", ")}.`);
190
221
  return NaN;
191
222
  }
192
223
  }.id, Object.freeze({
@@ -413,51 +444,69 @@ r.id, i.id, o.id, s.id, l.id, {
413
444
  });
414
445
  //#endregion
415
446
  //#region ../apigen-core-client/src/lib/get-safety.ts
416
- var m = /* @__PURE__ */ new Set([
447
+ var h = /* @__PURE__ */ new Set([
417
448
  "string",
418
449
  "number",
419
450
  "boolean",
420
451
  "integer"
421
452
  ]);
422
- function h(e) {
453
+ function g(e) {
454
+ if (!Array.isArray(e) || e.length < 2) return !1;
455
+ let t = 0;
456
+ for (let n of e) {
457
+ if (typeof n != "object" || !n) return !1;
458
+ let { type: e, $ref: r, oneOf: i, anyOf: a, allOf: o } = n;
459
+ if (r !== void 0 || i || a || o) return !1;
460
+ if (e !== "null") {
461
+ if (typeof e == "string" && h.has(e)) {
462
+ t++;
463
+ continue;
464
+ }
465
+ return !1;
466
+ }
467
+ }
468
+ return t === 1;
469
+ }
470
+ function _(e) {
423
471
  if (typeof e != "object" || !e) return !1;
424
472
  let t = e;
425
- if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf) return !1;
473
+ if (t.$ref !== void 0 || t.allOf) return !1;
474
+ if (t.oneOf || t.anyOf) return g(t.oneOf ?? t.anyOf);
426
475
  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) => [
476
+ return typeof n == "string" ? h.has(n) : Array.isArray(n) ? n.every((e) => h.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
428
477
  "string",
429
478
  "number",
430
479
  "boolean"
431
480
  ].includes(typeof e)) : !1;
432
481
  }
433
- function g(e) {
482
+ function v(e) {
434
483
  if (!e || typeof e != "object") return !1;
435
484
  let t = e.properties;
436
- return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(h);
485
+ return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(_);
437
486
  }
438
487
  //#endregion
439
488
  //#region ../apigen-core-client/src/lib/schema-builders/ts-json-schema.ts
440
- var _ = { "decimal.js": "Decimal" };
441
- function v(e) {
489
+ var y = { "decimal.js": "Decimal" };
490
+ function b(e) {
442
491
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
443
492
  }
444
- Object.entries(_).map(([e, t]) => ({
445
- pattern: RegExp(`import\\(["'][^"']*${v(e)}[^"']*["']\\)\\.\\w+`, "g"),
493
+ Object.entries(y).map(([e, t]) => ({
494
+ pattern: RegExp(`import\\(["'][^"']*${b(e)}[^"']*["']\\)\\.\\w+`, "g"),
446
495
  key: t
447
496
  }));
448
497
  //#endregion
449
498
  //#region ../apigen-engine-naming/src/lib/naming.ts
450
- function y(e) {
499
+ function x(e) {
451
500
  return e.words.join("-");
452
501
  }
453
- function b(e) {
454
- return e.words.map(C).join("");
502
+ function S(e) {
503
+ return e.words.map(T).join("");
455
504
  }
456
- function x(e) {
505
+ function C(e) {
457
506
  return e.words.join("_");
458
507
  }
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));
508
+ function w(e, t = {}) {
509
+ let n = [e.namespace, ...e.path], r = e.safe || v(e.input) ? "GET" : "POST", i = t.http?.verb?.[e.id] ?? r, a = "/" + n.map((e) => x(e)).join("/"), o = n.map((e) => C(e)).join("_"), s = n.map((e) => C(e)).slice(0, -1).join("."), c = S(n[n.length - 2] ?? n[0]), l = S(n[n.length - 1]), u = n.map((e) => x(e));
461
510
  return {
462
511
  http: {
463
512
  verb: i,
@@ -472,20 +521,20 @@ function S(e, t = {}) {
472
521
  cli: { path: u }
473
522
  };
474
523
  }
475
- function C(e) {
524
+ function T(e) {
476
525
  return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
477
526
  }
478
527
  //#endregion
479
528
  //#region ../codegen/openapi/src/lib/to-openapi.ts
480
- function w(e, t = {}) {
529
+ function E(e, t = {}) {
481
530
  let n = t.title ?? "API", r = t.version ?? "0.0.0", i = {};
482
531
  for (let t of e) {
483
- let { verb: e, route: n } = S(t).http, r = e.toLowerCase(), a = {
532
+ let { verb: e, route: n } = w(t).http, r = e.toLowerCase(), a = {
484
533
  operationId: t.id,
485
534
  summary: t.id,
486
- responses: { 200: T(t.output) }
535
+ responses: { 200: D(t.output) }
487
536
  };
488
- if (e === "GET") a.parameters = E(t.input);
537
+ if (e === "GET") a.parameters = O(t.input);
489
538
  else {
490
539
  let e = t.input;
491
540
  typeof e == "object" && e && Object.keys(e).length > 0 && (a.requestBody = {
@@ -504,13 +553,13 @@ function w(e, t = {}) {
504
553
  paths: i
505
554
  };
506
555
  }
507
- function T(e) {
556
+ function D(e) {
508
557
  return typeof e == "object" && e && Object.keys(e).length > 0 ? {
509
558
  description: "Success",
510
559
  content: { "application/json": { schema: e } }
511
560
  } : { description: "Success" };
512
561
  }
513
- function E(e) {
562
+ function O(e) {
514
563
  if (typeof e != "object" || !e || typeof e.properties != "object" || e.properties === null) return [];
515
564
  let t = Array.isArray(e.required) ? e.required : [], n = e.properties;
516
565
  return Object.entries(n).map(([e, n]) => ({
@@ -522,7 +571,7 @@ function E(e) {
522
571
  }
523
572
  //#endregion
524
573
  //#region src/lib/plugin.ts
525
- function D(e, t = {}) {
574
+ function k(e, t = {}) {
526
575
  return [{
527
576
  ...n("_meta/openapi", e, {
528
577
  kind: "query",
@@ -530,13 +579,13 @@ function D(e, t = {}) {
530
579
  output: { type: "object" },
531
580
  transports: ["http"]
532
581
  }),
533
- handler: (n) => w(e.operations, {
582
+ handler: (n) => E(e.operations, {
534
583
  title: t.title,
535
584
  version: t.version
536
585
  })
537
586
  }];
538
587
  }
539
- var O = {
588
+ var A = {
540
589
  id: "openapi",
541
590
  description: "Mount plugin: serves the OpenAPI 3.1 doc at GET /meta/openapi",
542
591
  language: "ts",
@@ -555,8 +604,8 @@ var O = {
555
604
  additionalProperties: !1
556
605
  },
557
606
  capabilities: { mount: { operations(e, t) {
558
- return D(e, t);
607
+ return k(e, t);
559
608
  } } }
560
609
  };
561
610
  //#endregion
562
- export { O as default, O as openapiPlugin };
611
+ export { A as default, A as openapiPlugin };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@adhd/apigen-plugin-openapi",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
- "@adhd/apigen-core-client": "^0.3.3",
7
- "@adhd/apigen-codegen-openapi": "^0.2.5"
6
+ "@adhd/apigen-core-client": "^0.3.6",
7
+ "@adhd/apigen-codegen-openapi": "^0.2.7"
8
8
  },
9
9
  "publishConfig": {
10
10
  "access": "public"