@adhd/apigen-plugin-health 0.1.0

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/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export type { HealthOptions } from './lib/plugin';
2
+ export { healthPlugin } from './lib/plugin';
3
+ export { default } from './lib/plugin';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function s(e){return{raw:e,words:[e]}}function n(e,t={}){return[{id:"_meta/health",host:e.host,namespace:s("meta"),path:[s("health")],kind:"query",async:!1,streaming:!1,safe:!0,input:{},output:{type:"object",required:["status","host"],properties:{status:{const:"ok"},host:{type:"string"},meta:{type:"object"}}},envelope:{},typeText:null,transports:["http","grpc"],handler:i=>{const a={status:"ok",host:e.host};return t.meta!==void 0&&Object.keys(t.meta).length>0&&(a.meta=t.meta),a}}]}const o={id:"health",description:"Mount plugin: exposes GET /meta/health for gateway readiness (SPEC §13.1)",optionsSchema:{type:"object",properties:{meta:{type:"object",description:"Extra metadata included in the health response"}},additionalProperties:!1},capabilities:{mount:{operations(e,t){return n(e,t)}}}};exports.default=o;exports.healthPlugin=o;
package/index.mjs ADDED
@@ -0,0 +1,66 @@
1
+ function s(t) {
2
+ return { raw: t, words: [t] };
3
+ }
4
+ function n(t, e = {}) {
5
+ return [
6
+ {
7
+ // Canonical id — `_meta` prefix convention for meta-endpoints.
8
+ id: "_meta/health",
9
+ host: t.host,
10
+ namespace: s("meta"),
11
+ path: [s("health")],
12
+ // query + safe → GET /meta/health; gRPC also useful for load-balancer probes.
13
+ kind: "query",
14
+ async: !1,
15
+ streaming: !1,
16
+ safe: !0,
17
+ // Input: no domain params.
18
+ input: {},
19
+ // Output: the HealthResponse shape (inlined for zero extra dependencies).
20
+ output: {
21
+ type: "object",
22
+ required: ["status", "host"],
23
+ properties: {
24
+ status: { const: "ok" },
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"],
34
+ // Handler: always returns ready when the runtime can answer.
35
+ handler: (o) => {
36
+ const a = {
37
+ status: "ok",
38
+ host: t.host
39
+ };
40
+ return e.meta !== void 0 && Object.keys(e.meta).length > 0 && (a.meta = e.meta), a;
41
+ }
42
+ }
43
+ ];
44
+ }
45
+ const r = {
46
+ id: "health",
47
+ description: "Mount plugin: exposes GET /meta/health for gateway readiness (SPEC §13.1)",
48
+ optionsSchema: {
49
+ type: "object",
50
+ properties: {
51
+ meta: { type: "object", description: "Extra metadata included in the health response" }
52
+ },
53
+ additionalProperties: !1
54
+ },
55
+ capabilities: {
56
+ mount: {
57
+ operations(t, e) {
58
+ return n(t, e);
59
+ }
60
+ }
61
+ }
62
+ };
63
+ export {
64
+ r as default,
65
+ r as healthPlugin
66
+ };
@@ -0,0 +1,33 @@
1
+ import { Plugin } from '@adhd/apigen-core';
2
+
3
+ /** Options accepted by the health mount plugin. */
4
+ export interface HealthOptions {
5
+ /**
6
+ * Optional extra metadata to include in the health response payload.
7
+ * Values must be serialisable (string / number / boolean / null).
8
+ */
9
+ meta?: Record<string, string | number | boolean | null>;
10
+ }
11
+ /**
12
+ * The readiness signal emitted by `_meta/health`.
13
+ *
14
+ * - `status: 'ok'` — the runtime is alive and ready to serve.
15
+ * - `host` — the owning language runtime tag from the descriptor.
16
+ * - `meta` — optional operator-supplied metadata (see {@link HealthOptions}).
17
+ *
18
+ * The gateway feeds on this shape when aggregating per-host status (§13.1).
19
+ */
20
+ export interface HealthResponse {
21
+ status: 'ok';
22
+ host: string;
23
+ meta?: Record<string, string | number | boolean | null>;
24
+ }
25
+ /**
26
+ * v2 health mount plugin (SPEC §7.1 / §7.2c).
27
+ *
28
+ * Contributes `GET /meta/health` (+ gRPC) → `{ status: 'ok', host: '...' }`.
29
+ * The gateway routes a host's operations only after this endpoint reports
30
+ * ready (SPEC §13.1 gateway readiness contract).
31
+ */
32
+ export declare const healthPlugin: Plugin<HealthOptions>;
33
+ export default healthPlugin;
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@adhd/apigen-plugin-health",
3
+ "version": "0.1.0",
4
+ "main": "./index.js",
5
+ "dependencies": {
6
+ "@adhd/apigen-core": "^0.1.0"
7
+ },
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "module": "./index.mjs",
12
+ "types": "./index.d.ts"
13
+ }