@adhd/apigen-plugin-health 0.2.6 → 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 +4 -0
- package/index.js +12 -1
- package/index.mjs +57 -26
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
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
|
|
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={"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,t={}){return[{...n(`_meta/health`,e,{kind:`query`,safe:!0,output:{type:`object`,required:[`status`,`host`],properties:{status:{const:`ok`},host:{type:`string`},meta:{type:`object`}}},transports:[`http`,`grpc`]}),handler:n=>{let r={status:`ok`,host:e.host};return t.meta!==void 0&&Object.keys(t.meta).length>0&&(r.meta=t.meta),r}}]}var v={id:`health`,description:`Mount plugin: exposes GET /meta/health for gateway readiness (SPEC §13.1)`,language:`ts`,optionsSchema:{type:`object`,properties:{meta:{type:`object`,description:`Extra metadata included in the health response`}},additionalProperties:!1},capabilities:{mount:{operations(e,t){return _(e,t)}}}};exports.default=v,exports.healthPlugin=v;
|
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
|
|
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
|
-
},
|
|
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
|
|
124
|
+
function o(e) {
|
|
94
125
|
return e;
|
|
95
126
|
}
|
|
96
|
-
var
|
|
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
|
|
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
|
|
146
|
+
return o(e);
|
|
116
147
|
}
|
|
117
|
-
},
|
|
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
|
-
},
|
|
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" && !
|
|
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
|
-
},
|
|
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
|
-
|
|
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) ?
|
|
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 ===
|
|
184
|
-
if (e ===
|
|
185
|
-
if (e ===
|
|
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 ${[...
|
|
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,17 +444,17 @@ r.id, i.id, o.id, s.id, l.id, {
|
|
|
413
444
|
});
|
|
414
445
|
//#endregion
|
|
415
446
|
//#region ../apigen-core-client/src/lib/schema-builders/ts-json-schema.ts
|
|
416
|
-
var
|
|
417
|
-
function
|
|
447
|
+
var h = { "decimal.js": "Decimal" };
|
|
448
|
+
function g(e) {
|
|
418
449
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
419
450
|
}
|
|
420
|
-
Object.entries(
|
|
421
|
-
pattern: RegExp(`import\\(["'][^"']*${
|
|
451
|
+
Object.entries(h).map(([e, t]) => ({
|
|
452
|
+
pattern: RegExp(`import\\(["'][^"']*${g(e)}[^"']*["']\\)\\.\\w+`, "g"),
|
|
422
453
|
key: t
|
|
423
454
|
}));
|
|
424
455
|
//#endregion
|
|
425
456
|
//#region src/lib/plugin.ts
|
|
426
|
-
function
|
|
457
|
+
function _(e, t = {}) {
|
|
427
458
|
return [{
|
|
428
459
|
...n("_meta/health", e, {
|
|
429
460
|
kind: "query",
|
|
@@ -448,7 +479,7 @@ function g(e, t = {}) {
|
|
|
448
479
|
}
|
|
449
480
|
}];
|
|
450
481
|
}
|
|
451
|
-
var
|
|
482
|
+
var v = {
|
|
452
483
|
id: "health",
|
|
453
484
|
description: "Mount plugin: exposes GET /meta/health for gateway readiness (SPEC §13.1)",
|
|
454
485
|
language: "ts",
|
|
@@ -461,8 +492,8 @@ var _ = {
|
|
|
461
492
|
additionalProperties: !1
|
|
462
493
|
},
|
|
463
494
|
capabilities: { mount: { operations(e, t) {
|
|
464
|
-
return
|
|
495
|
+
return _(e, t);
|
|
465
496
|
} } }
|
|
466
497
|
};
|
|
467
498
|
//#endregion
|
|
468
|
-
export {
|
|
499
|
+
export { v as default, v as healthPlugin };
|
package/package.json
CHANGED