@adhd/apigen-plugin-health 0.2.0 → 0.2.2
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 +22 -0
- package/index.js +1 -1
- package/index.mjs +78 -39
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## 0.2.2 (2026-08-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🚀 Features
|
|
5
|
+
|
|
6
|
+
- **apigen:** wire MountHostBridge/LayerContext into express, fastify, health
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 🩹 Fixes
|
|
10
|
+
|
|
11
|
+
- **apigen-cli:** restore 2768 files mass-deleted by 0117eb22 (BUG-APIGEN-052)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### ❤️ Thank You
|
|
15
|
+
|
|
16
|
+
- parity-harness-self-test
|
|
17
|
+
- pseudosky
|
|
18
|
+
|
|
19
|
+
## 0.2.1 (2026-07-28)
|
|
20
|
+
|
|
21
|
+
This was a version bump only for apigen-plugin-health to align it with other projects, there were no code changes.
|
|
22
|
+
|
|
1
23
|
## 0.1.7 (2026-07-25)
|
|
2
24
|
|
|
3
25
|
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("ts-morph");require("node:fs");require("node:path");require("ts-json-schema-generator");function i(e){return{raw:e,words:e.split(/(?=[A-Z])|[-_]/).map(a=>a.toLowerCase()).filter(Boolean)}}function h(e,a,t={}){const s=e.split("/");if(s.length<2||s.some(c=>c.length===0))throw new Error(`syntheticOp: id "${e}" must be "<namespace>/<path...>" with non-empty segments`);const[p,...u]=s,l=p.replace(/^_+/,""),o=t.kind??"action",n={id:e,host:a.host,namespace:i(l),path:u.map(i),kind:o,async:t.async??!1,streaming:t.streaming??!1,safe:t.safe??o==="query",input:t.input??{},output:t.output??{},envelope:t.envelope??{},typeText:t.typeText??null};return t.hasCtx!==void 0&&(n.hasCtx=t.hasCtx),t.transports!==void 0&&(n.transports=t.transports),n}const m={"decimal.js":"Decimal"};function d(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(m).map(([e,a])=>({pattern:new RegExp(`import\\(["'][^"']*${d(e)}[^"']*["']\\)\\.\\w+`,"g"),key:a}));function g(e,a={}){return[{...h("_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:t=>{const s={status:"ok",host:e.host};return a.meta!==void 0&&Object.keys(a.meta).length>0&&(s.meta=a.meta),s}}]}const r={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,a){return g(e,a)}}}};exports.default=r;exports.healthPlugin=r;
|
package/index.mjs
CHANGED
|
@@ -1,48 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import "ts-morph";
|
|
2
|
+
import "node:fs";
|
|
3
|
+
import "node:path";
|
|
4
|
+
import "ts-json-schema-generator";
|
|
5
|
+
function i(t) {
|
|
6
|
+
return {
|
|
7
|
+
raw: t,
|
|
8
|
+
words: t.split(/(?=[A-Z])|[-_]/).map((a) => a.toLowerCase()).filter(Boolean)
|
|
9
|
+
};
|
|
3
10
|
}
|
|
4
|
-
function
|
|
11
|
+
function c(t, a, e = {}) {
|
|
12
|
+
const s = t.split("/");
|
|
13
|
+
if (s.length < 2 || s.some((u) => u.length === 0))
|
|
14
|
+
throw new Error(
|
|
15
|
+
`syntheticOp: id "${t}" must be "<namespace>/<path...>" with non-empty segments`
|
|
16
|
+
);
|
|
17
|
+
const [p, ...r] = s, l = p.replace(/^_+/, ""), o = e.kind ?? "action", n = {
|
|
18
|
+
id: t,
|
|
19
|
+
host: a.host,
|
|
20
|
+
namespace: i(l),
|
|
21
|
+
path: r.map(i),
|
|
22
|
+
kind: o,
|
|
23
|
+
async: e.async ?? !1,
|
|
24
|
+
streaming: e.streaming ?? !1,
|
|
25
|
+
safe: e.safe ?? o === "query",
|
|
26
|
+
input: e.input ?? {},
|
|
27
|
+
output: e.output ?? {},
|
|
28
|
+
envelope: e.envelope ?? {},
|
|
29
|
+
typeText: e.typeText ?? null
|
|
30
|
+
};
|
|
31
|
+
return e.hasCtx !== void 0 && (n.hasCtx = e.hasCtx), e.transports !== void 0 && (n.transports = e.transports), n;
|
|
32
|
+
}
|
|
33
|
+
const h = {
|
|
34
|
+
"decimal.js": "Decimal"
|
|
35
|
+
};
|
|
36
|
+
function m(t) {
|
|
37
|
+
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
38
|
+
}
|
|
39
|
+
Object.entries(h).map(([t, a]) => ({
|
|
40
|
+
// Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
|
|
41
|
+
// The module specifier appears inside an absolute path, so we allow any
|
|
42
|
+
// characters between the quote and the specifier, and between the specifier
|
|
43
|
+
// and the closing quote. The trailing member accessor (`.default`, `.Decimal`,
|
|
44
|
+
// …) is matched generically (`\w+`) rather than anchored to one spelling —
|
|
45
|
+
// see the doc comment above for why.
|
|
46
|
+
pattern: new RegExp(
|
|
47
|
+
`import\\(["'][^"']*${m(t)}[^"']*["']\\)\\.\\w+`,
|
|
48
|
+
"g"
|
|
49
|
+
),
|
|
50
|
+
key: a
|
|
51
|
+
}));
|
|
52
|
+
function d(t, a = {}) {
|
|
5
53
|
return [
|
|
6
54
|
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
host: { type: "string" },
|
|
26
|
-
meta: { type: "object" }
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
envelope: {},
|
|
30
|
-
typeText: null,
|
|
31
|
-
// Expose on HTTP and gRPC — useful for both HTTP health checks and
|
|
32
|
-
// gRPC-native load-balancer probes (SPEC §7.2c / §13.1).
|
|
33
|
-
transports: ["http", "grpc"],
|
|
55
|
+
...c("_meta/health", t, {
|
|
56
|
+
// query + safe → GET /meta/health; gRPC also useful for load-balancer probes.
|
|
57
|
+
kind: "query",
|
|
58
|
+
safe: !0,
|
|
59
|
+
// Output: the HealthResponse shape (inlined for zero extra dependencies).
|
|
60
|
+
output: {
|
|
61
|
+
type: "object",
|
|
62
|
+
required: ["status", "host"],
|
|
63
|
+
properties: {
|
|
64
|
+
status: { const: "ok" },
|
|
65
|
+
host: { type: "string" },
|
|
66
|
+
meta: { type: "object" }
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// Expose on HTTP and gRPC — useful for both HTTP health checks and
|
|
70
|
+
// gRPC-native load-balancer probes (SPEC §7.2c / §13.1).
|
|
71
|
+
transports: ["http", "grpc"]
|
|
72
|
+
}),
|
|
34
73
|
// Handler: always returns ready when the runtime can answer.
|
|
35
|
-
handler: (
|
|
36
|
-
const
|
|
74
|
+
handler: (e) => {
|
|
75
|
+
const s = {
|
|
37
76
|
status: "ok",
|
|
38
77
|
host: t.host
|
|
39
78
|
};
|
|
40
|
-
return
|
|
79
|
+
return a.meta !== void 0 && Object.keys(a.meta).length > 0 && (s.meta = a.meta), s;
|
|
41
80
|
}
|
|
42
81
|
}
|
|
43
82
|
];
|
|
44
83
|
}
|
|
45
|
-
const
|
|
84
|
+
const w = {
|
|
46
85
|
id: "health",
|
|
47
86
|
description: "Mount plugin: exposes GET /meta/health for gateway readiness (SPEC §13.1)",
|
|
48
87
|
language: "ts",
|
|
@@ -58,16 +97,16 @@ const r = {
|
|
|
58
97
|
},
|
|
59
98
|
capabilities: {
|
|
60
99
|
mount: {
|
|
61
|
-
operations(t,
|
|
62
|
-
return
|
|
100
|
+
operations(t, a) {
|
|
101
|
+
return d(
|
|
63
102
|
t,
|
|
64
|
-
|
|
103
|
+
a
|
|
65
104
|
);
|
|
66
105
|
}
|
|
67
106
|
}
|
|
68
107
|
}
|
|
69
108
|
};
|
|
70
109
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
110
|
+
w as default,
|
|
111
|
+
w as healthPlugin
|
|
73
112
|
};
|
package/package.json
CHANGED