@feasibleone/blong-gogo 1.19.0 → 1.20.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.20.0](https://github.com/feasibleone/blong/compare/blong-gogo-v1.19.1...blong-gogo-v1.20.0) (2026-05-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * add runtime introspection endpoints for development troubleshooting ([#144](https://github.com/feasibleone/blong/issues/144)) ([81d665c](https://github.com/feasibleone/blong/commit/81d665c3d09bdd767ee78e824d4e529fed5f00d5))
9
+
10
+ ## [1.19.1](https://github.com/feasibleone/blong/compare/blong-gogo-v1.19.0...blong-gogo-v1.19.1) (2026-05-09)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * improve model and mock ([20b530c](https://github.com/feasibleone/blong/commit/20b530cc9d00284a52ad99b63b95fbb7bd4e4e82))
16
+
3
17
  ## [1.19.0](https://github.com/feasibleone/blong/compare/blong-gogo-v1.18.1...blong-gogo-v1.19.0) (2026-04-29)
4
18
 
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feasibleone/blong-gogo",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "repository": {
5
5
  "url": "git+https://github.com/feasibleone/blong.git"
6
6
  },
@@ -0,0 +1,118 @@
1
+ import type {IConfigRuntime, IGateway, ILog, IRegistry} from '@feasibleone/blong/types';
2
+ import {Internal} from '@feasibleone/blong/types';
3
+ import type {FastifyInstance} from 'fastify';
4
+ import fp from 'fastify-plugin';
5
+
6
+ interface IConfig {
7
+ enabled: boolean;
8
+ routePrefix: string;
9
+ auth: false | 'jwt';
10
+ }
11
+
12
+ interface IGatewayWithPlugins extends IGateway {
13
+ registerPlugin(plugin: unknown, options?: unknown): void;
14
+ }
15
+
16
+ interface IRpcServerWithInfo {
17
+ info(): object;
18
+ }
19
+
20
+ // The api object is captured by reference so that configRuntime — which is set
21
+ // on it after infra items are constructed (load.ts) — is visible at request time.
22
+ interface IApiRef {
23
+ log?: ILog;
24
+ gateway?: IGatewayWithPlugins;
25
+ registry?: IRegistry;
26
+ rpcServer?: IRpcServerWithInfo;
27
+ configRuntime?: IConfigRuntime;
28
+ }
29
+
30
+ export default class SystemDebug extends Internal {
31
+ #config: IConfig = {
32
+ enabled: false,
33
+ routePrefix: '/api/sys',
34
+ auth: false,
35
+ };
36
+
37
+ #apiRef: IApiRef;
38
+
39
+ public constructor(config: IConfig, apiRef: IApiRef) {
40
+ super({log: apiRef.log});
41
+ this.merge(this.#config, config);
42
+ this.#apiRef = apiRef;
43
+ }
44
+
45
+ public async init(): Promise<void> {
46
+ if (!this.#config.enabled || !this.#apiRef.gateway) return;
47
+
48
+ this.log?.warn?.(
49
+ 'systemDebug is enabled — introspection endpoints are active; do not enable in production',
50
+ );
51
+
52
+ const apiRef = this.#apiRef;
53
+ const prefix = this.#config.routePrefix;
54
+ const authConfig = this.#config.auth;
55
+
56
+ const plugin = fp(
57
+ async (server: FastifyInstance) => {
58
+ // GET /api/sys/config — effective runtime configuration snapshot
59
+ server.route({
60
+ method: 'GET',
61
+ url: `${prefix}/config`,
62
+ config: {auth: authConfig},
63
+ handler: async () => apiRef.configRuntime?.rawSnapshot ?? {},
64
+ });
65
+
66
+ // GET /api/sys/ports — registered adapter/orchestrator port definitions
67
+ server.route({
68
+ method: 'GET',
69
+ url: `${prefix}/ports`,
70
+ config: {auth: authConfig},
71
+ handler: async () => ({
72
+ ports: Array.from(apiRef.registry?.ports.keys() ?? []),
73
+ }),
74
+ });
75
+
76
+ // GET /api/sys/methods — registered handler method groups with handler counts
77
+ server.route({
78
+ method: 'GET',
79
+ url: `${prefix}/methods`,
80
+ config: {auth: authConfig},
81
+ handler: async () => ({
82
+ methods: Array.from(apiRef.registry?.methods.entries() ?? []).map(
83
+ ([name, handlers]) => ({
84
+ name,
85
+ handlerCount: handlers.length,
86
+ }),
87
+ ),
88
+ }),
89
+ });
90
+
91
+ // GET /api/sys/modules — registered realm modules.
92
+ // Symbol keys (used internally for system-tagged infrastructure items)
93
+ // are excluded because they are not JSON-serialisable.
94
+ server.route({
95
+ method: 'GET',
96
+ url: `${prefix}/modules`,
97
+ config: {auth: authConfig},
98
+ handler: async () => ({
99
+ modules: Array.from(apiRef.registry?.modules.keys() ?? []).filter(
100
+ (k): k is string => typeof k === 'string',
101
+ ),
102
+ }),
103
+ });
104
+
105
+ // GET /api/sys/rpc — internal RPC server address info
106
+ server.route({
107
+ method: 'GET',
108
+ url: `${prefix}/rpc`,
109
+ config: {auth: authConfig},
110
+ handler: async () => apiRef.rpcServer?.info() ?? {},
111
+ });
112
+ },
113
+ {name: 'system-debug'},
114
+ );
115
+
116
+ apiRef.gateway!.registerPlugin(plugin);
117
+ }
118
+ }
package/src/load.ts CHANGED
@@ -21,7 +21,6 @@ import {Type, type TSchema} from 'typebox';
21
21
  import merge from 'ut-function.merge';
22
22
  import {methodParts} from './lib.ts';
23
23
 
24
- import minimist from 'minimist';
25
24
  import ConfigRuntime from './ConfigRuntime.ts';
26
25
  import layerProxy from './layerProxy.ts';
27
26
  import RealmImpl, {type IRealm} from './Realm.ts';
@@ -189,16 +188,15 @@ interface IConstructor {
189
188
  new (config?: object, api?: object): object;
190
189
  }
191
190
 
192
- const argConfigs = minimist(process.argv.slice(2))._;
193
-
194
191
  function activeConfigs<T extends TSchema>(
195
192
  mod: IModuleConfig<T>,
196
193
  configNames: string[],
194
+ platformConfigs: string[],
197
195
  ): (boolean | object)[] {
198
196
  return (
199
197
  (['default'] as string[])
200
198
  .concat(configNames)
201
- .concat(argConfigs)
199
+ .concat(platformConfigs)
202
200
  .map(name => (mod.config as unknown as Record<string, unknown>)?.[name])
203
201
  .filter(Boolean) as (boolean | object)[]
204
202
  ).concat({pkg: mod.pkg, children: mod.children, url: mod.url});
@@ -377,6 +375,7 @@ export default async function loadRealm<T extends TSchema>(
377
375
  rpcServer: {},
378
376
  gateway: {},
379
377
  restFs: {},
378
+ systemDebug: {},
380
379
  });
381
380
  items = topoSort([
382
381
  {
@@ -466,6 +465,11 @@ export default async function loadRealm<T extends TSchema>(
466
465
  deps: ['log', 'gateway'],
467
466
  load: () => import('./RestFs.ts'),
468
467
  },
468
+ {
469
+ name: 'systemDebug',
470
+ deps: ['log', 'gateway', 'registry', 'rpcServer'],
471
+ load: () => import('./SystemDebug.ts'),
472
+ },
469
473
  {
470
474
  name: 'registry',
471
475
  deps: [
@@ -502,7 +506,7 @@ export default async function loadRealm<T extends TSchema>(
502
506
  return fn;
503
507
  });
504
508
  }
505
- loadedConfigs.push(...activeConfigs(mod, configNames));
509
+ loadedConfigs.push(...activeConfigs(mod, configNames, platformApi.configs));
506
510
  const {loadedConfig, configRuntime} = await platformApi.loadConfig(parentConfig);
507
511
  if (loadedConfig) loadedConfigs.push(loadedConfig);
508
512
 
@@ -11,8 +11,8 @@ declare global {
11
11
  }
12
12
  }
13
13
 
14
- var performance = globalThis.performance || {};
15
- var performanceNow =
14
+ const performance = globalThis.performance || {};
15
+ const performanceNow =
16
16
  performance.now ||
17
17
  performance.mozNow ||
18
18
  performance.msNow ||
@@ -25,9 +25,9 @@ var performanceNow =
25
25
  // generate timestamp or delta
26
26
  // see http://nodejs.org/api/process.html#process_process_hrtime
27
27
  function hrtime(previousTimestamp?: HRTime): HRTime {
28
- var clocktime = performanceNow.call(performance) * 1e-3;
29
- var seconds = Math.floor(clocktime);
30
- var nanoseconds = Math.floor((clocktime % 1) * 1e9);
28
+ const clockTime = performanceNow.call(performance) * 1e-3;
29
+ let seconds = Math.floor(clockTime);
30
+ let nanoseconds = Math.floor((clockTime % 1) * 1e9);
31
31
  if (previousTimestamp) {
32
32
  seconds = seconds - previousTimestamp[0];
33
33
  nanoseconds = nanoseconds - previousTimestamp[1];
@@ -79,4 +79,5 @@ export default load.bind(null, {
79
79
  },
80
80
  statSync: (() => undefined) as unknown as import('node:fs').StatSyncFn,
81
81
  timing: timing(hrtime),
82
+ configs: ['browser'],
82
83
  });
package/src/loadServer.ts CHANGED
@@ -2,6 +2,7 @@ import {watch} from 'chokidar';
2
2
  import type {Dirent} from 'fs';
3
3
  import {existsSync, readFileSync, statSync, writeFileSync} from 'fs';
4
4
  import {readdir} from 'fs/promises';
5
+ import minimist from 'minimist';
5
6
  import {createRequire} from 'node:module';
6
7
  import {hrtime} from 'node:process';
7
8
  import {basename, dirname, extname, join, relative, resolve} from 'path';
@@ -45,4 +46,5 @@ export default load.bind(null, {
45
46
  statSync,
46
47
  watch,
47
48
  timing: timing(hrtime),
49
+ configs: ['server', ...minimist(process.argv.slice(2))._],
48
50
  });