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