@feasibleone/blong 1.17.0 → 1.18.1

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/dist/types.js CHANGED
@@ -16,7 +16,8 @@ export class Internal {
16
16
  async stop() {
17
17
  return this;
18
18
  }
19
- async start(...params) {
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ async start(..._args) {
20
21
  return this;
21
22
  }
22
23
  }
@@ -40,7 +41,7 @@ export const handler = (definition) => Object.defineProperty(definition, Kind, {
40
41
  * });
41
42
  * ```
42
43
  */
43
- export const defineActions = (actions) => Object.defineProperty((_blong) => Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])), Kind, { value: 'handler' });
44
+ export const defineActions = (actions) => Object.defineProperty(() => Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])), Kind, { value: 'handler' });
44
45
  export const library = (definition) => Object.defineProperty(definition, Kind, { value: 'lib' });
45
46
  export const validation = (validation) => Object.defineProperty(validation, Kind, { value: 'validation' });
46
47
  export const api = (api) => Object.defineProperty(api, Kind, { value: 'api' });
@@ -54,12 +55,22 @@ export const validationHandlers = handlers => validation(() => Object.fromEntrie
54
55
  description: 'description' in handler ? handler.description : undefined,
55
56
  }), 'name', { value: name }),
56
57
  ])));
57
- export const realm = (definition) => Object.defineProperty(definition, Kind, { value: 'solution' });
58
- export const server = (definition) => Object.defineProperty(definition, Kind, { value: 'server' });
59
- export const browser = (definition) => Object.defineProperty(definition, Kind, { value: 'browser' });
58
+ export const realm = (definition) => Object.defineProperty(definition, Kind, {
59
+ value: 'solution',
60
+ });
61
+ export const server = (definition) => Object.defineProperty(definition, Kind, {
62
+ value: 'server',
63
+ });
64
+ export const browser = (definition) => Object.defineProperty(definition, Kind, {
65
+ value: 'browser',
66
+ });
60
67
  export const layer = (activation) => Object.defineProperty(activation, Kind, { value: 'layer' });
61
- export const adapter = (definition) => Object.defineProperty(definition, Kind, { value: 'adapter' });
62
- export const orchestrator = (definition) => Object.defineProperty(definition, Kind, { value: 'orchestrator' });
68
+ export const adapter = (definition) => Object.defineProperty(definition, Kind, {
69
+ value: 'adapter',
70
+ });
71
+ export const orchestrator = (definition) => Object.defineProperty(definition, Kind, {
72
+ value: 'orchestrator',
73
+ });
63
74
  export const kind = (what) => what[Kind] || '';
64
75
  export default {
65
76
  handler,
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,IAAI,GAWP,MAAM,SAAS,CAAC;AAQjB,OAAO,KAAK,MAAM,mBAAmB,CAAC;AA+tBtC,MAAM,IAAI,GAAW,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAG9C,MAAM,OAAgB,QAAQ;IAC1B,IAAI,CAAQ;IACF,GAAG,CAA8B;IAC3C,YAAmB,GAAiB;QAChC,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,GAAG,CAAC;IACzB,CAAC;IACS,KAAK,GAAkB,CAAC,GAAG,IAA+B,EAAE,EAAE;QACpE,MAAM,MAAM,GAAG,KAAK,CAAqB,GAAG,IAAI,CAAC,CAAC;QAClD,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI;YAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAC,CAAC,CAAC;QAChF,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;IACK,KAAK,CAAC,IAAI;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IACM,KAAK,CAAC,KAAK,CAAC,GAAG,MAAiB;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,UAA4B,EACZ,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,UAA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jF,KAAK,EAAE,UAAU;CACpB,CAAC,CAAC;AACP,MAAM,CAAC,MAAM,MAAM,GAAG,CAClB,UAA8B,EACS,EAAE,CACzC,MAAM,CAAC,cAAc,CAAC,UAAqD,EAAE,IAAI,EAAE;IAC/E,KAAK,EAAE,QAAQ;CAClB,CAAC,CAAC;AACP,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,UAA8B,EACU,EAAE,CAC1C,MAAM,CAAC,cAAc,CAAC,UAAsD,EAAE,IAAI,EAAE;IAChF,KAAK,EAAE,SAAS;CACnB,CAAC,CAAC;AACP,MAAM,CAAC,MAAM,KAAK,GAAG,CACjB,UAA4C,EACQ,EAAE,CACtD,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,UAAiC,EACU,EAAE,CAC7C,MAAM,CAAC,cAAc,CAAC,UAAyD,EAAE,IAAI,EAAE;IACnF,KAAK,EAAE,SAAS;CACnB,CAAC,CAAC;AACP,MAAM,CAAC,MAAM,YAAY,GAAG,CACxB,UAAiC,EACe,EAAE,CAClD,MAAM,CAAC,cAAc,CAAC,UAA8D,EAAE,IAAI,EAAE;IACxF,KAAK,EAAE,cAAc;CACxB,CAAC,CAAC;AAeP,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAiC,EAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAEnF,eAAe;IACX,OAAO;IACP,aAAa;IACb,OAAO;IACP,UAAU;IACV,GAAG;IACH,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,YAAY;IACZ,OAAO;IACP,IAAI;CACP,CAAC"}
package/dist/widget.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.js","sourceRoot":"","sources":["../widget.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feasibleone/blong",
3
- "version": "1.17.0",
3
+ "version": "1.18.1",
4
4
  "description": "API and DRY focused RAD framework https://feasibleone.github.io/blong-docs",
5
5
  "keywords": [
6
6
  "blong",
@@ -34,6 +34,7 @@
34
34
  "@rushstack/heft-typescript-plugin": "^1.3.1",
35
35
  "@slack/types": "^2.20.1",
36
36
  "@slack/webhook": "^7.0.7",
37
+ "@types/react": "^19.1.2",
37
38
  "@types/request": "^2.48.13",
38
39
  "@types/ut-function.merge": "file:./types/ut-function.merge",
39
40
  "bson": "^7.2.0",
@@ -43,11 +44,13 @@
43
44
  "mongodb": "^7.1.0",
44
45
  "node-vault": "^0.10.10",
45
46
  "openapi-types": "^12.1.3",
47
+ "react": "^19.1.0",
46
48
  "tarn": "^3.0.2",
47
49
  "typescript": "^5.9.3"
48
50
  },
49
51
  "scripts": {
50
52
  "build": "heft build --clean;dts-bundle-generator --config dts-gen.config.json",
53
+ "ci-lint": "tsc --noEmit",
51
54
  "ci-publish": "node ../../common/scripts/install-run-rush-pnpm.js publish --access public --provenance"
52
55
  }
53
56
  }
package/types.ts CHANGED
@@ -31,7 +31,7 @@ import type {Duplex} from 'node:stream';
31
31
  import type {OpenAPI, OpenAPIV2, OpenAPIV3_1} from 'openapi-types';
32
32
  import type {Level, LogFn, Logger as PinoLogger} from 'pino';
33
33
  import merge from 'ut-function.merge';
34
- import type {Knex} from './knex.js';
34
+ import type {Knex} from './knex.ts';
35
35
  import type {IMock, IModelSpec} from './model.ts';
36
36
 
37
37
  // export {
@@ -49,6 +49,7 @@ export type {IJsonSchema, OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1} from 'open
49
49
  // export type {Level, LogFn, Logger as PinoLogger} from 'pino';
50
50
  export type {Knex} from './knex.js';
51
51
  export type * from './model.ts';
52
+ export type * from './widget.ts';
52
53
 
53
54
  export type ServerContext = {
54
55
  queryBuilder?: Knex;
@@ -94,7 +95,7 @@ export type ConfigSubscriber = (
94
95
  ) => void | Promise<void>;
95
96
 
96
97
  /**
97
- * Mode used when the config proxy is queried during handler factory initialisation.
98
+ * Mode used when the config proxy is queried during handler factory initialization.
98
99
  *
99
100
  * - `'throw'` — throw immediately (default; keeps misuse from going unnoticed)
100
101
  * - `'collect'` — accumulate errors and return them from exitConfigFactoryPhase()
@@ -160,6 +161,7 @@ export interface IPlatformApi {
160
161
  isAfter: (time: HRTime, timeout: HRTime) => boolean;
161
162
  spare: (time: HRTime, latency?: number) => number;
162
163
  };
164
+ configs: string[];
163
165
  }
164
166
 
165
167
  export interface IErrorFactory {
@@ -266,29 +268,30 @@ export interface IGateway {
266
268
  export type Handlers = ((params: {
267
269
  remote: unknown;
268
270
  lib: object;
269
- port: object;
271
+ port: object | undefined;
270
272
  local: object;
271
273
  literals: object[];
272
274
  gateway: IGateway;
273
275
  apiSchema: IApiSchema;
276
+ attachCheckpoint?: (meta: IMeta) => void;
274
277
  }) => void)[];
275
278
 
276
279
  export interface IRegistry {
277
- start: (configOverride?: object) => Promise<IRegistry>;
280
+ start: (configOverride: object) => Promise<IRegistry>;
278
281
  test: (tester?: unknown) => Promise<void>;
279
282
  stop: () => Promise<IRegistry>;
280
- ports: Map<string, IAdapterFactory>;
283
+ ports: Map<string, IAdapterRegistry>;
281
284
  methods: Map<string, Handlers>;
282
285
  modules: Map<string | symbol, IRegistry[]>;
283
- createPort: (id: string) => Promise<ReturnType<IAdapterFactory>>;
284
- getPort: (id: string) => ReturnType<IAdapterFactory> | undefined;
285
- replaceHandlers: (id: string, handlers: object) => Promise<void>;
286
+ createPort: (id: string) => Promise<Adapter | undefined>;
287
+ getPort: (id: string) => Adapter | undefined;
288
+ replaceHandlers: (id: string, handlers: Handlers) => Promise<void>;
286
289
  loadApi: (
287
290
  id: string,
288
291
  def: {
289
292
  namespace: Record<string, string | string[]>;
290
293
  },
291
- source?: string,
294
+ source: string,
292
295
  ) => Promise<void>;
293
296
  connected: () => Promise<boolean>;
294
297
  }
@@ -296,15 +299,7 @@ export interface IRegistry {
296
299
  export interface IApi {
297
300
  id?: string;
298
301
  type: typeof Type;
299
- adapter: (
300
- id: string,
301
- ) => (api: {
302
- utError: IError;
303
- remote: IRemote;
304
- rpc: IRpcServer;
305
- local: ILocal;
306
- registry: IRegistry;
307
- }) => object;
302
+ adapter: (id: string) => IAdapterRegistry | undefined;
308
303
  utError: IError;
309
304
  errors: IErrorFactory;
310
305
  gateway: unknown;
@@ -323,7 +318,15 @@ export interface IApi {
323
318
  methodName: string,
324
319
  options?: object,
325
320
  ) => (...params: unknown[]) => Promise<unknown>;
326
- attachHandlers: (target: object, patterns: unknown, adapter?: boolean) => unknown;
321
+ attachHandlers: (
322
+ target: {
323
+ importedMap?: Map<string, object>;
324
+ imported: object;
325
+ config: {namespace?: string | string[]};
326
+ },
327
+ patterns: (string | RegExp)[] | string | RegExp,
328
+ adapter?: boolean,
329
+ ) => unknown;
327
330
  createLog: ILog['logger'];
328
331
  attachCheckpoint?: (meta: IMeta) => void;
329
332
  handlers?: (api: {utError: IError; remote: IRemote; type: typeof Type}) => {
@@ -349,6 +352,21 @@ export interface IErrorMap {
349
352
  };
350
353
  }
351
354
 
355
+ export type Adapter<T = Record<string, unknown>, C = Record<string, unknown>> = IAdapter<T, C> &
356
+ Pick<
357
+ Required<IAdapter<T, C>>,
358
+ | 'init'
359
+ | 'start'
360
+ | 'stop'
361
+ | 'ready'
362
+ | 'config'
363
+ | 'imported'
364
+ | 'errors'
365
+ | 'error'
366
+ | 'findValidation'
367
+ | 'getConversion'
368
+ | 'dispatch'
369
+ >;
352
370
  export interface IAdapter<T, C> {
353
371
  validation?: TSchema;
354
372
  config?: Config<T, C>;
@@ -356,60 +374,63 @@ export interface IAdapter<T, C> {
356
374
  configBase?: string;
357
375
  log?: ILogger;
358
376
  errors?: Errors<IErrorMap>;
359
- imported?: ReturnType<IAdapterFactory<T, C>>;
377
+ imported?: Record<string, PortHandlerBound>;
360
378
  importedMap?: Map<string, IRemoteHandler>;
361
379
  extends?: object | `adapter.${string}` | `orchestrator.${string}`;
362
- activeConfig?: (this: ReturnType<IAdapterFactory<T, C>>) => Partial<Config<T, C>>;
363
- init?: (
364
- this: ReturnType<IAdapterFactory<T, C>>,
365
- ...config: Partial<Config<T, C>>[]
366
- ) => Promise<void>;
367
- start?: (this: ReturnType<IAdapterFactory<T, C>>, configOverride: object) => Promise<object>;
368
- ready?: (this: ReturnType<IAdapterFactory<T, C>>) => Promise<object>;
369
- stop?: (this: ReturnType<IAdapterFactory<T, C>>) => Promise<object>;
370
- connected?: (this: ReturnType<IAdapterFactory<T, C>>) => Promise<boolean>;
371
- error?: (error: Error, $meta: IMeta) => void;
372
- pack?: (
373
- this: ReturnType<IAdapterFactory<T, C>>,
374
- packet: {size: number; data: Buffer},
375
- ) => Buffer;
376
- unpackSize?: (
377
- this: ReturnType<IAdapterFactory<T, C>>,
378
- buffer: Buffer,
379
- ) => {size: number; data: Buffer};
380
- unpack?: (
381
- this: ReturnType<IAdapterFactory<T, C>>,
382
- buffer: Buffer,
383
- options?: {size: number},
384
- ) => Buffer;
385
- encode?: (data: unknown, $meta: IMeta, context: object, log: ILogger) => string | Buffer;
386
- decode?: (buff: string | Buffer, $meta: IMeta, context: object, log: ILogger) => object[];
387
- request?: (...params: unknown[]) => Promise<unknown>;
388
- publish?: () => Promise<unknown>;
389
- drain?: () => void;
390
- findValidation?: (this: ReturnType<IAdapterFactory<T, C>>, $meta: IMeta) => () => object;
391
- getConversion?: (
392
- this: ReturnType<IAdapterFactory<T, C>>,
393
- $meta: IMeta,
394
- type: 'send' | 'receive',
395
- ) => {name: string; fn: () => object};
396
- findHandler?: (this: ReturnType<IAdapterFactory<T, C>>, name: string) => () => unknown;
397
- handles?: (this: ReturnType<IAdapterFactory<T, C>>, name: string) => boolean;
398
- forNamespaces?: <T>(reducer: (prev: T, current: unknown) => T, initial: T) => T;
399
- methodPath?: (name: string) => string;
400
- dispatch?: (...params: unknown[]) => Promise<unknown>;
401
- exec?: (this: ReturnType<IAdapterFactory<T, C>>, ...params: unknown[]) => Promise<unknown>;
402
- bytesSent?: (count: number) => void;
403
- bytesReceived?: (count: number) => void;
404
- msgSent?: (count: number) => void;
405
- msgReceived?: (count: number) => void;
380
+ activeConfig?(this: Adapter<T, C>): Partial<Config<T, C>>;
381
+ init?(this: Adapter<T, C>, ...config: unknown[]): Promise<unknown>;
382
+ start?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
383
+ ready?(this: Adapter<T, C>): Promise<unknown>;
384
+ stop?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
385
+ link?(
386
+ this: Adapter<T, C>,
387
+ patterns: (string | RegExp)[] | string | RegExp,
388
+ target: object,
389
+ ): Promise<{
390
+ importedMap?: Map<string, object>;
391
+ imported?: object;
392
+ config?: {namespace?: string | string[]};
393
+ }>;
394
+ connected?(this: Adapter<T, C>): Promise<boolean>;
395
+ error?(error: unknown, $meta: unknown): void;
396
+ pack?(this: Adapter<T, C>, ...params: unknown[]): unknown;
397
+ unpackSize?(this: Adapter<T, C>, ...params: unknown[]): unknown;
398
+ unpack?(this: Adapter<T, C>, ...params: unknown[]): unknown;
399
+ encode?(
400
+ data: unknown,
401
+ $meta: unknown,
402
+ context: unknown,
403
+ log: unknown,
404
+ ): Promise<string | Buffer>;
405
+ decode?(
406
+ buff: string | Buffer,
407
+ $meta: unknown,
408
+ context: unknown,
409
+ log: unknown,
410
+ ): Promise<object[]>;
411
+ request?(...params: unknown[]): Promise<unknown>;
412
+ publish?(): Promise<unknown>;
413
+ drain?(): void;
414
+ findValidation?(this: Adapter<T, C>, $meta: unknown): (...params: unknown[]) => object;
415
+ getConversion?(
416
+ this: Adapter<T, C>,
417
+ $meta: unknown,
418
+ type: string,
419
+ ): {name: string; fn: (...params: unknown[]) => Promise<object>};
420
+ findHandler?(this: Adapter<T, C>, name: string): () => unknown;
421
+ handles?(this: Adapter<T, C>, name: string): boolean;
422
+ forNamespaces?<U>(reducer: (prev: U, current: unknown) => U, initial: U): U;
423
+ methodPath?(name: string): string;
424
+ dispatch?(...params: unknown[]): Promise<unknown>;
425
+ exec?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
426
+ bytesSent?(count: number): void;
427
+ bytesReceived?(count: number): void;
428
+ msgSent?(count: number): void;
429
+ msgReceived?(count: number): void;
406
430
  isConnected?: Promise<boolean>;
407
- event?: (name: string, params?: unknown) => Promise<object>;
408
- handle?: (...params: unknown[]) => Promise<unknown>;
409
- connect?: (
410
- what: unknown,
411
- context: {requests: unknown; waiting: unknown; buffer: unknown},
412
- ) => void;
431
+ event?(name: string, params?: unknown): Promise<object>;
432
+ handle?(...params: unknown[]): Promise<unknown>;
433
+ connect?(what: unknown, context: unknown): void;
413
434
  /**
414
435
  * Optional lifecycle hook called when configuration changes.
415
436
  * When present, the framework calls this instead of a full stop+start cycle.
@@ -421,11 +442,14 @@ export interface IAdapter<T, C> {
421
442
  * @param next The full new effective config snapshot (via proxy)
422
443
  * @param prev The full previous effective config snapshot
423
444
  */
424
- configChanged?: (
425
- diff: Map<string, {prev: unknown; next: unknown}>,
426
- next: object,
427
- prev: object,
428
- ) => Promise<void>;
445
+ configChanged?(
446
+ this: Adapter<T, C>,
447
+ diff: unknown,
448
+ next: unknown,
449
+ prev?: unknown,
450
+ ): Promise<void>;
451
+ /** Allow arbitrary extra methods on adapter definitions (e.g. authenticate) */
452
+ [key: string]: unknown;
429
453
  }
430
454
 
431
455
  export interface IAdapterFactory<T = Record<string, unknown>, C = Record<string, unknown>> {
@@ -433,6 +457,17 @@ export interface IAdapterFactory<T = Record<string, unknown>, C = Record<string,
433
457
  (api: IApi): IAdapter<T, C>;
434
458
  }
435
459
 
460
+ export interface IAdapterRegistry {
461
+ config: unknown;
462
+ (api: {
463
+ utError: IError;
464
+ remote: IRemote;
465
+ rpc: IRpcServer;
466
+ local: ILocal;
467
+ registry: IRegistry;
468
+ }): Promise<Adapter>;
469
+ }
470
+
436
471
  export interface IMeta {
437
472
  mtid?: 'request' | 'response' | 'error' | 'notification' | 'discard' | 'event';
438
473
  request?: IMeta;
@@ -444,7 +479,7 @@ export interface IMeta {
444
479
  expect?: string[] | string;
445
480
  opcode?: string;
446
481
  source?: string;
447
- forward?: object;
482
+ forward?: Record<string, string>;
448
483
  httpResponse?: {
449
484
  type?: string;
450
485
  redirect?: string;
@@ -490,16 +525,16 @@ export interface IMeta {
490
525
  deviceId?: string | string[];
491
526
  latitude?: string | string[];
492
527
  longitude?: string | string[];
493
- conId?: number;
528
+ conId?: string | number;
494
529
  dispatch?: (
495
530
  msg?: object,
496
531
  $meta?: IMeta,
497
532
  ) => [msg: object, $meta: IMeta] | boolean | void | Promise<boolean>;
498
533
  reply?: unknown;
499
- timeout?: number;
534
+ timeout?: HRTime;
500
535
  timer?: (
501
536
  name?: string,
502
- newTime?: HRTime | false,
537
+ newTime?: HRTime | undefined,
503
538
  ) => {
504
539
  [name: string]: number;
505
540
  };
@@ -511,16 +546,17 @@ export interface IMeta {
511
546
  }
512
547
 
513
548
  export interface IContext {
514
- trace: number;
549
+ // trace: number;
515
550
  session?: {
516
551
  [name: string]: unknown;
517
552
  };
518
- conId?: string;
553
+ conId?: string | number;
519
554
  requests: Map<
520
555
  string,
521
- {$meta: IMeta; end: (error: Error) => {local: object; literals: object[]}}
556
+ {$meta: IMeta; end?: (error: Error) => {local: object; literals: object[]}}
522
557
  >;
523
558
  waiting: Set<(error: Error) => void>;
559
+ buffer?: Buffer;
524
560
  }
525
561
 
526
562
  export interface ITypedError extends Error {
@@ -578,7 +614,10 @@ export interface IModuleConfig<T extends TSchema = TNever> {
578
614
  url: string;
579
615
  config?: IActivationConfig<Partial<Static<T>> & Partial<Static<IBaseConfig>>>;
580
616
  validation?: T;
581
- children?: (string | (() => Promise<object>))[] | ((layer: ModuleApi) => unknown)[];
617
+ children?:
618
+ | (string | (() => Promise<object>))[]
619
+ | ((layer: ModuleApi) => unknown)[]
620
+ | Record<string, () => Promise<unknown>>;
582
621
  glob?: Record<string, () => Promise<object>>;
583
622
  }
584
623
 
@@ -702,17 +741,24 @@ export type ApiDefinition = (blong: IValidationProxy) =>
702
741
  };
703
742
 
704
743
  export type PortHandler<T, C> = <R>(
705
- this: ReturnType<IAdapterFactory<T, C>>,
706
- params: {},
744
+ this: Adapter<T, C>,
745
+ params: object,
707
746
  $meta: IMeta,
708
747
  context?: IContext,
709
748
  ) => Promise<R> | R;
710
- export type PortHandlerBound = <T>(params: {}, $meta: IMeta, context?: IContext) => Promise<T> | T;
749
+ export type PortHandlerBound = (<T>(
750
+ params: object,
751
+ $meta: IMeta,
752
+ context?: IContext,
753
+ ) => Promise<T> | T) & {
754
+ [name: string]: PortHandlerBound;
755
+ };
711
756
  export type LibFn = <T>(...params: unknown[]) => T;
712
757
  export interface IRemoteHandler {
713
758
  [name: string]: PortHandlerBound;
714
759
  }
715
- export interface ISchema {}
760
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
761
+ export interface ISchema {} // this is being extended via ambient declarations in ~.schema.ts
716
762
  export interface IHandlerProxy<T> {
717
763
  config: T;
718
764
  handler: {
@@ -769,9 +815,9 @@ const Kind: symbol = Symbol.for('blong:kind');
769
815
  export type Kind = typeof Kind;
770
816
 
771
817
  export abstract class Internal {
772
- #log?: ILog;
818
+ #log?: ILog | undefined;
773
819
  protected log?: ReturnType<ILog['logger']>;
774
- public constructor(api?: {log: ILog}) {
820
+ public constructor(api?: {log?: ILog}) {
775
821
  this.#log = api?.log;
776
822
  }
777
823
  protected merge: ILib['merge'] = (...args: Parameters<ILib['merge']>) => {
@@ -783,7 +829,8 @@ export abstract class Internal {
783
829
  public async stop(): Promise<unknown> {
784
830
  return this;
785
831
  }
786
- public async start(...params: unknown[]): Promise<unknown> {
832
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
833
+ public async start(..._args: unknown[]): Promise<unknown> {
787
834
  return this;
788
835
  }
789
836
  }
@@ -850,8 +897,7 @@ export const defineActions = (
850
897
  actions: Record<string, IActionDef>,
851
898
  ): ((_blong: unknown) => Record<string, () => IActionDef>) =>
852
899
  Object.defineProperty(
853
- (_blong: unknown) =>
854
- Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])),
900
+ () => Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])),
855
901
  Kind,
856
902
  {value: 'handler'},
857
903
  );
@@ -888,21 +934,40 @@ export const validationHandlers: (
888
934
  ),
889
935
  );
890
936
 
891
- export const realm = <T extends TObject>(definition: SolutionFactory<T>): SolutionFactory<T> =>
892
- Object.defineProperty(definition, Kind, {value: 'solution'});
893
- export const server = <T extends TObject>(definition: SolutionFactory<T>): SolutionFactory<T> =>
894
- Object.defineProperty(definition, Kind, {value: 'server'});
895
- export const browser = <T extends TObject>(definition: SolutionFactory<T>): SolutionFactory<T> =>
896
- Object.defineProperty(definition, Kind, {value: 'browser'});
937
+ export const realm = <T extends TObject>(
938
+ definition: SolutionFactory<T>,
939
+ ): SolutionFactory<T> & {[Kind]: 'solution'} =>
940
+ Object.defineProperty(definition as SolutionFactory<T> & {[Kind]: 'solution'}, Kind, {
941
+ value: 'solution',
942
+ });
943
+ export const server = <T extends TObject>(
944
+ definition: SolutionFactory<T>,
945
+ ): SolutionFactory<T> & {[Kind]: 'server'} =>
946
+ Object.defineProperty(definition as SolutionFactory<T> & {[Kind]: 'server'}, Kind, {
947
+ value: 'server',
948
+ });
949
+ export const browser = <T extends TObject>(
950
+ definition: SolutionFactory<T>,
951
+ ): SolutionFactory<T> & {[Kind]: 'browser'} =>
952
+ Object.defineProperty(definition as SolutionFactory<T> & {[Kind]: 'browser'}, Kind, {
953
+ value: 'browser',
954
+ });
897
955
  export const layer = (
898
956
  activation: Record<string, boolean | object>,
899
- ): Record<string, boolean | object> => Object.defineProperty(activation, Kind, {value: 'layer'});
957
+ ): Record<string, boolean | object> & {[Kind]: 'layer'} =>
958
+ Object.defineProperty(activation, Kind, {value: 'layer'});
900
959
  export const adapter = <T, C = AdapterContext>(
901
960
  definition: IAdapterFactory<T, C>,
902
- ): IAdapterFactory<T, C> => Object.defineProperty(definition, Kind, {value: 'adapter'});
961
+ ): IAdapterFactory<T, C> & {[Kind]: 'adapter'} =>
962
+ Object.defineProperty(definition as IAdapterFactory<T, C> & {[Kind]: 'adapter'}, Kind, {
963
+ value: 'adapter',
964
+ });
903
965
  export const orchestrator = <T, C = AdapterContext>(
904
966
  definition: IAdapterFactory<T, C>,
905
- ): IAdapterFactory<T, C> => Object.defineProperty(definition, Kind, {value: 'orchestrator'});
967
+ ): IAdapterFactory<T, C> & {[Kind]: 'orchestrator'} =>
968
+ Object.defineProperty(definition as IAdapterFactory<T, C> & {[Kind]: 'orchestrator'}, Kind, {
969
+ value: 'orchestrator',
970
+ });
906
971
 
907
972
  export type Kinds =
908
973
  | 'lib'