@feasibleone/blong 1.24.0 → 1.25.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/dist/types.js ADDED
@@ -0,0 +1,68 @@
1
+ import { Type, } from 'typebox';
2
+ import merge from 'ut-function.merge';
3
+ const Kind = Symbol.for('blong:kind');
4
+ export class Internal {
5
+ #log;
6
+ log;
7
+ constructor(api) {
8
+ this.#log = api?.log;
9
+ }
10
+ merge = (...args) => {
11
+ const result = merge(...args);
12
+ if (result.logLevel && this.#log)
13
+ this.log = this.#log.logger(result.logLevel, { name: this.constructor.name });
14
+ return result;
15
+ };
16
+ async stop() {
17
+ return this;
18
+ }
19
+ async start(..._args) {
20
+ return this;
21
+ }
22
+ }
23
+ export const handler = (definition) => Object.defineProperty(definition, Kind, { value: 'handler' });
24
+ export const library = (definition) => Object.defineProperty(definition, Kind, { value: 'lib' });
25
+ export const validation = (validation) => Object.defineProperty(validation, Kind, { value: 'validation' });
26
+ export const schema = (schema) => Object.defineProperty(schema, Kind, { value: 'schema' });
27
+ export const api = (api) => Object.defineProperty(api, Kind, { value: 'api' });
28
+ export const model = (definition) => Object.defineProperty(definition, Kind, { value: 'model' });
29
+ export const fixture = (definition) => Object.defineProperty(definition, Kind, { value: 'fixture' });
30
+ export const validationHandlers = handlers => validation(async () => Object.fromEntries(Object.entries(handlers).map(([name, handler]) => [
31
+ name,
32
+ Object.defineProperty(() => ({
33
+ params: Type.Parameters(handler).items[0],
34
+ result: Type.Awaited(Type.ReturnType(handler)),
35
+ description: 'description' in handler ? handler.description : undefined,
36
+ }), 'name', { value: name }),
37
+ ])));
38
+ export const realm = (definition) => Object.defineProperty(definition, Kind, {
39
+ value: 'solution',
40
+ });
41
+ export const server = (definition) => Object.defineProperty(definition, Kind, {
42
+ value: 'server',
43
+ });
44
+ export const browser = (definition) => Object.defineProperty(definition, Kind, {
45
+ value: 'browser',
46
+ });
47
+ export const layer = (activation) => Object.defineProperty(activation, Kind, { value: 'layer' });
48
+ export const adapter = (definition) => Object.defineProperty(definition, Kind, {
49
+ value: 'adapter',
50
+ });
51
+ export const orchestrator = (definition) => Object.defineProperty(definition, Kind, {
52
+ value: 'orchestrator',
53
+ });
54
+ export const kind = (what) => what[Kind] || '';
55
+ export default {
56
+ handler,
57
+ library,
58
+ validation,
59
+ api,
60
+ realm,
61
+ server,
62
+ browser,
63
+ adapter,
64
+ orchestrator,
65
+ fixture,
66
+ kind,
67
+ };
68
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,IAAI,GAeP,MAAM,SAAS,CAAC;AAQjB,OAAO,KAAK,MAAM,mBAAmB,CAAC;AA0gCtC,MAAM,IAAI,GAAW,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAG9C,MAAM,OAAgB,QAAQ;IAC1B,IAAI,CAAoB;IACd,GAAG,CAA8B;IAC3C,YAAmB,GAAkB;QACjC,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,KAAgB;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,CAA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AAC,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;AAgBP,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAiC,EAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAEnF,eAAe;IACX,OAAO;IACP,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.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "API and DRY focused RAD framework https://feasibleone.github.io/blong-docs",
5
5
  "keywords": [
6
6
  "blong",
package/types.ts CHANGED
@@ -586,6 +586,7 @@ export interface IMeta {
586
586
  redirect?: string;
587
587
  code?: number;
588
588
  state?: unknown[];
589
+ unstate?: unknown[];
589
590
  header?: string[] | [string, unknown][];
590
591
  };
591
592
  httpRequest?: {
@@ -599,6 +600,10 @@ export interface IMeta {
599
600
  permissionMap?: Buffer;
600
601
  actorId?: string | number;
601
602
  sessionId?: string;
603
+ /** Audit record id of the access-check audit recorded for this request. */
604
+ auditId?: string;
605
+ /** Allowed action methodIds — populated by the gateway authorize handler. */
606
+ actions?: string[];
602
607
  };
603
608
  language?: {
604
609
  languageId?: string | number;
@@ -667,6 +672,7 @@ export interface ITypedError extends Error {
667
672
  method?: string | string[];
668
673
  params?: object;
669
674
  code?: string;
675
+ silent?: boolean;
670
676
  req?: {
671
677
  httpVersion: string;
672
678
  url: URL;
@@ -806,6 +812,19 @@ export type GatewaySchema = (
806
812
  bundle?: string;
807
813
  creditCost?: number;
808
814
  meter?: boolean;
815
+ /**
816
+ * Opt this route OUT of the gateway access-check audit (`gateway.audit`).
817
+ * Use for operations that record their own audit trail (e.g. payments)
818
+ * or that must not generate audit noise (e.g. integration-test probes).
819
+ */
820
+ audit?: boolean;
821
+ /**
822
+ * Authenticate the route (bearer) but skip the RBAC action-list check.
823
+ * Use ONLY for self-service methods that operate on the caller's own
824
+ * session (e.g. `login.token.revoke`) — the action is scoped by the
825
+ * token's own `ses` claim, so no cross-user action is possible.
826
+ */
827
+ skipAuthorize?: boolean;
809
828
  };
810
829
 
811
830
  export type SchemaObject = OpenAPIV3_1.SchemaObject | OpenAPIV2.SchemaObject;
@@ -919,6 +938,16 @@ export interface ILib {
919
938
  level?: 'info' | 'warn';
920
939
  },
921
940
  ) => Promise<T>;
941
+ /**
942
+ * Optional map of configurable method/handler bindings that a library may
943
+ * expose under the conventional `methods` member — the idiomatic way to
944
+ * bundle soft dependencies (e.g. the access-realm methods that blong-login's
945
+ * `sessionLib` resolves from config). Handlers read the resolved handlers
946
+ * through `lib.methods.<name>`; each value is a bound handler or `undefined`
947
+ * when the binding is disabled. See the blong-handler skill →
948
+ * "Library as a configurable-bindings bundle (soft dependencies)".
949
+ */
950
+ methods?: LibMethods;
922
951
  }
923
952
 
924
953
  export type ValidationFn = () => GatewaySchema;
@@ -968,6 +997,15 @@ export type PortHandlerBound = (<T>(
968
997
  [name: string]: PortHandlerBound;
969
998
  };
970
999
  export type LibFn = <T>(...params: unknown[]) => T;
1000
+ /**
1001
+ * A map of configurable handler/method bindings exposed by a library under the
1002
+ * conventional `methods` member (see the blong-handler skill). Values are
1003
+ * bound handlers (usually resolved from config against the `handler` proxy);
1004
+ * `undefined` when the binding is disabled.
1005
+ */
1006
+ export type LibMethods = {
1007
+ [method: string]: LibFn | undefined;
1008
+ };
971
1009
  export interface IRemoteHandler {
972
1010
  [name: string]: PortHandlerBound;
973
1011
  }