@adhd/apigen-plugin-health 0.2.2 → 0.2.3
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 +1 -1
- package/index.mjs +14 -14
- package/package.json +20 -3
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("node:fs");const h=require("node:module");require("node:path");var o=typeof document<"u"?document.currentScript:null;function i(e){return{raw:e,words:e.split(/(?=[A-Z])|[-_]/).map(n=>n.toLowerCase()).filter(Boolean)}}function m(e,n,t={}){const a=e.split("/");if(a.length<2||a.some(d=>d.length===0))throw new Error(`syntheticOp: id "${e}" must be "<namespace>/<path...>" with non-empty segments`);const[p,...l]=a,c=p.replace(/^_+/,""),r=t.kind??"action",s={id:e,host:n.host,namespace:i(c),path:l.map(i),kind:r,async:t.async??!1,streaming:t.streaming??!1,safe:t.safe??r==="query",input:t.input??{},output:t.output??{},envelope:t.envelope??{},typeText:t.typeText??null};return t.hasCtx!==void 0&&(s.hasCtx=t.hasCtx),t.transports!==void 0&&(s.transports=t.transports),s}h.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:o&&o.tagName.toUpperCase()==="SCRIPT"&&o.src||new URL("index.js",document.baseURI).href);const f={"decimal.js":"Decimal"};function g(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(f).map(([e,n])=>({pattern:new RegExp(`import\\(["'][^"']*${g(e)}[^"']*["']\\)\\.\\w+`,"g"),key:n}));function y(e,n={}){return[{...m("_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 a={status:"ok",host:e.host};return n.meta!==void 0&&Object.keys(n.meta).length>0&&(a.meta=n.meta),a}}]}const u={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,n){return y(e,n)}}}};exports.default=u;exports.healthPlugin=u;
|
package/index.mjs
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import "ts-morph";
|
|
2
1
|
import "node:fs";
|
|
2
|
+
import { createRequire as c } from "node:module";
|
|
3
3
|
import "node:path";
|
|
4
|
-
import "ts-json-schema-generator";
|
|
5
4
|
function i(t) {
|
|
6
5
|
return {
|
|
7
6
|
raw: t,
|
|
8
7
|
words: t.split(/(?=[A-Z])|[-_]/).map((a) => a.toLowerCase()).filter(Boolean)
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
|
-
function
|
|
10
|
+
function h(t, a, e = {}) {
|
|
12
11
|
const s = t.split("/");
|
|
13
|
-
if (s.length < 2 || s.some((
|
|
12
|
+
if (s.length < 2 || s.some((l) => l.length === 0))
|
|
14
13
|
throw new Error(
|
|
15
14
|
`syntheticOp: id "${t}" must be "<namespace>/<path...>" with non-empty segments`
|
|
16
15
|
);
|
|
17
|
-
const [
|
|
16
|
+
const [r, ...p] = s, u = r.replace(/^_+/, ""), o = e.kind ?? "action", n = {
|
|
18
17
|
id: t,
|
|
19
18
|
host: a.host,
|
|
20
|
-
namespace: i(
|
|
21
|
-
path:
|
|
19
|
+
namespace: i(u),
|
|
20
|
+
path: p.map(i),
|
|
22
21
|
kind: o,
|
|
23
22
|
async: e.async ?? !1,
|
|
24
23
|
streaming: e.streaming ?? !1,
|
|
@@ -30,13 +29,14 @@ function c(t, a, e = {}) {
|
|
|
30
29
|
};
|
|
31
30
|
return e.hasCtx !== void 0 && (n.hasCtx = e.hasCtx), e.transports !== void 0 && (n.transports = e.transports), n;
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
c(import.meta.url);
|
|
33
|
+
const m = {
|
|
34
34
|
"decimal.js": "Decimal"
|
|
35
35
|
};
|
|
36
|
-
function
|
|
36
|
+
function d(t) {
|
|
37
37
|
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
38
38
|
}
|
|
39
|
-
Object.entries(
|
|
39
|
+
Object.entries(m).map(([t, a]) => ({
|
|
40
40
|
// Matches: import("...{modSpec}...").<anyMemberName> (single or double quotes)
|
|
41
41
|
// The module specifier appears inside an absolute path, so we allow any
|
|
42
42
|
// characters between the quote and the specifier, and between the specifier
|
|
@@ -44,15 +44,15 @@ Object.entries(h).map(([t, a]) => ({
|
|
|
44
44
|
// …) is matched generically (`\w+`) rather than anchored to one spelling —
|
|
45
45
|
// see the doc comment above for why.
|
|
46
46
|
pattern: new RegExp(
|
|
47
|
-
`import\\(["'][^"']*${
|
|
47
|
+
`import\\(["'][^"']*${d(t)}[^"']*["']\\)\\.\\w+`,
|
|
48
48
|
"g"
|
|
49
49
|
),
|
|
50
50
|
key: a
|
|
51
51
|
}));
|
|
52
|
-
function
|
|
52
|
+
function g(t, a = {}) {
|
|
53
53
|
return [
|
|
54
54
|
{
|
|
55
|
-
...
|
|
55
|
+
...h("_meta/health", t, {
|
|
56
56
|
// query + safe → GET /meta/health; gRPC also useful for load-balancer probes.
|
|
57
57
|
kind: "query",
|
|
58
58
|
safe: !0,
|
|
@@ -98,7 +98,7 @@ const w = {
|
|
|
98
98
|
capabilities: {
|
|
99
99
|
mount: {
|
|
100
100
|
operations(t, a) {
|
|
101
|
-
return
|
|
101
|
+
return g(
|
|
102
102
|
t,
|
|
103
103
|
a
|
|
104
104
|
);
|
package/package.json
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhd/apigen-plugin-health",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@adhd/apigen-core-client": "^0.3.
|
|
6
|
+
"@adhd/apigen-core-client": "^0.3.1"
|
|
7
7
|
},
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"module": "./index.mjs",
|
|
12
|
-
"types": "./index.d.ts"
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"description": "Health-check plugin for apigen servers",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"health",
|
|
16
|
+
"apigen",
|
|
17
|
+
"plugin",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/PseudoSky/adhd.git",
|
|
24
|
+
"directory": "packages/apigen/apigen-plugin-health"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/PseudoSky/adhd/tree/main/packages/apigen/apigen-plugin-health#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/PseudoSky/adhd/issues"
|
|
29
|
+
}
|
|
13
30
|
}
|