@venizia/ignis-helpers 0.4.7-1 → 0.4.7-2

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.
Files changed (62) hide show
  1. package/README.md +3 -3
  2. package/dist/esm/core.d.ts +1 -2
  3. package/dist/esm/core.d.ts.map +1 -1
  4. package/dist/esm/core.js +3 -2
  5. package/dist/esm/core.js.map +1 -1
  6. package/dist/esm/modules/base.d.ts +1 -1
  7. package/dist/esm/modules/base.d.ts.map +1 -1
  8. package/dist/esm/modules/base.js +14 -5
  9. package/dist/esm/modules/base.js.map +1 -1
  10. package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts +15 -5
  11. package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts.map +1 -1
  12. package/dist/esm/modules/crypto/algorithms/hash.algorithm.js +16 -4
  13. package/dist/esm/modules/crypto/algorithms/hash.algorithm.js.map +1 -1
  14. package/dist/esm/modules/logger/base/base.d.ts.map +1 -1
  15. package/dist/esm/modules/logger/base/base.js +3 -3
  16. package/dist/esm/modules/logger/base/base.js.map +1 -1
  17. package/dist/esm/modules/logger/base/console.d.ts +9 -4
  18. package/dist/esm/modules/logger/base/console.d.ts.map +1 -1
  19. package/dist/esm/modules/logger/base/console.js +15 -4
  20. package/dist/esm/modules/logger/base/console.js.map +1 -1
  21. package/dist/esm/modules/logger/common/constants.d.ts +0 -1
  22. package/dist/esm/modules/logger/common/constants.d.ts.map +1 -1
  23. package/dist/esm/modules/logger/common/constants.js +0 -6
  24. package/dist/esm/modules/logger/common/constants.js.map +1 -1
  25. package/dist/esm/modules/logger/common/debug-gate.d.ts +33 -0
  26. package/dist/esm/modules/logger/common/debug-gate.d.ts.map +1 -0
  27. package/dist/esm/modules/logger/common/debug-gate.js +51 -0
  28. package/dist/esm/modules/logger/common/debug-gate.js.map +1 -0
  29. package/dist/esm/modules/logger/common/index.d.ts +1 -0
  30. package/dist/esm/modules/logger/common/index.d.ts.map +1 -1
  31. package/dist/esm/modules/logger/common/index.js +1 -0
  32. package/dist/esm/modules/logger/common/index.js.map +1 -1
  33. package/dist/esm/modules/logger/common/types.d.ts +7 -0
  34. package/dist/esm/modules/logger/common/types.d.ts.map +1 -1
  35. package/dist/esm/modules/logger/common/types.js +16 -0
  36. package/dist/esm/modules/logger/common/types.js.map +1 -1
  37. package/dist/esm/modules/logger/factory.d.ts +29 -12
  38. package/dist/esm/modules/logger/factory.d.ts.map +1 -1
  39. package/dist/esm/modules/logger/factory.js +108 -50
  40. package/dist/esm/modules/logger/factory.js.map +1 -1
  41. package/dist/esm/modules/logger/hf/logger.d.ts.map +1 -1
  42. package/dist/esm/modules/logger/hf/logger.js +3 -3
  43. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  44. package/dist/esm/modules/logger/index.d.ts +0 -1
  45. package/dist/esm/modules/logger/index.d.ts.map +1 -1
  46. package/dist/esm/modules/logger/index.js +0 -1
  47. package/dist/esm/modules/logger/index.js.map +1 -1
  48. package/dist/esm/utilities/module.utility.d.ts.map +1 -1
  49. package/dist/esm/utilities/module.utility.js +1 -0
  50. package/dist/esm/utilities/module.utility.js.map +1 -1
  51. package/dist/esm/utilities/request.utility.d.ts.map +1 -1
  52. package/dist/esm/utilities/request.utility.js +1 -0
  53. package/dist/esm/utilities/request.utility.js.map +1 -1
  54. package/package.json +2 -2
  55. package/dist/esm/modules/logger/resolver.d.ts +0 -33
  56. package/dist/esm/modules/logger/resolver.d.ts.map +0 -1
  57. package/dist/esm/modules/logger/resolver.js +0 -95
  58. package/dist/esm/modules/logger/resolver.js.map +0 -1
  59. package/dist/esm/modules/logger/slot.d.ts +0 -44
  60. package/dist/esm/modules/logger/slot.d.ts.map +0 -1
  61. package/dist/esm/modules/logger/slot.js +0 -126
  62. package/dist/esm/modules/logger/slot.js.map +0 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@ The root entry loads with no optional peer installed. Every third-party backend
12
12
 
13
13
  ## Example
14
14
 
15
- Register a logger provider once at the entrypoint, then take scoped loggers and helpers anywhere:
15
+ Choose a logger provider once at the entrypoint, then take scoped loggers and helpers anywhere:
16
16
 
17
17
  ```typescript
18
18
  // bun add pino ioredis
@@ -37,7 +37,7 @@ const user = await redis.get({ key: 'user:1', transform: JSON.parse });
37
37
  logger.for('warmup').info('Cache warmed | user: %j', user);
38
38
  ```
39
39
 
40
- Notice that your code only ever types against `ILogger`. `LoggerFactory.use()` swaps the backend for every logger handed out so far. With no provider registered, the factory falls back to winston on the first log call.
40
+ Notice that your code only ever types against `ILogger`. `LoggerFactory.use()` swaps the backend for every logger handed out so far. With no provider chosen, the factory uses the console; `@venizia/ignis` selects Winston when an application starts.
41
41
 
42
42
  Dates and IDs need no peer at all:
43
43
 
@@ -90,7 +90,7 @@ import { ModuleUtility } from '@venizia/ignis-helpers';
90
90
  ModuleUtility.register({ modules: { ioredis } });
91
91
  ```
92
92
 
93
- A binary must also call `LoggerFactory.use()` explicitly - the winston fallback cannot reach a bundle. Details: [Module Utility](https://ignis.venizia.ai/references/utilities/module).
93
+ A binary needs no `LoggerFactory.use()`: the console is the default logger. Details: [Module Utility](https://ignis.venizia.ai/references/utilities/module).
94
94
 
95
95
  ## Where it sits
96
96
 
@@ -4,8 +4,7 @@ export * from './modules/error/index.js';
4
4
  export { LogLevels } from './modules/logger/common/types.js';
5
5
  export type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types.js';
6
6
  export { ConsoleLogger } from './modules/logger/base/console.js';
7
- export { LoggerSlot } from './modules/logger/slot.js';
8
- export type { TLoggerResolver } from './modules/logger/slot.js';
7
+ export { LoggerFactory } from './modules/logger/factory.js';
9
8
  export * from './modules/network/http-request/fetcher/base-fetcher.js';
10
9
  export * from './modules/network/http-request/fetcher/node-fetcher.js';
11
10
  export * from './modules/network/http-request/base-network-request.helper.js';
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,M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dist/esm/core.js CHANGED
@@ -4,9 +4,10 @@ export { BaseHelper } from './modules/base.js';
4
4
  export { EnvironmentNames } from './modules/env/names.js';
5
5
  export * from './modules/error/index.js';
6
6
  export { LogLevels } from './modules/logger/common/types.js';
7
- // The browser-safe logger seam: `LoggerFactory` is node-only, so a browser app installs its own resolver here.
7
+ // The one way to get a logger, the same in the browser and on the server: `LoggerFactory` imports nothing from node, and its
8
+ // default provider is the console. An application chooses another with `LoggerFactory.use({ provider, level })`.
8
9
  export { ConsoleLogger } from './modules/logger/base/console.js';
9
- export { LoggerSlot } from './modules/logger/slot.js';
10
+ export { LoggerFactory } from './modules/logger/factory.js';
10
11
  export * from './modules/network/http-request/fetcher/base-fetcher.js';
11
12
  // The node fetcher carries no node builtin - its one `querystring.stringify` is written out - so the
12
13
  // framework HTTP layer is reachable from a browser bundle, and a connector on HTTP need not
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,6FAA6F;AAC7F,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,+GAA+G;AAC/G,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,cAAc,qDAAqD,CAAC;AACpE,qGAAqG;AACrG,4FAA4F;AAC5F,oBAAoB;AACpB,cAAc,qDAAqD,CAAC;AACpE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,iGAAiG;AACjG,yFAAyF;AACzF,cAAc,yDAAyD,CAAC;AAExE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAG5F,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAcrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,+FAA+F;AAC/F,mGAAmG;AACnG,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC","sourcesContent":["export { BaseHelper } from './modules/base';\n// By name, never `export *` from `./modules/env`: that barrel also carries `Environment` and\n// `applicationEnvironment`, both of which read `process.env`.\nexport { EnvironmentNames } from './modules/env/names';\nexport * from './modules/error';\nexport { LogLevels } from './modules/logger/common/types';\nexport type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types';\n// The browser-safe logger seam: `LoggerFactory` is node-only, so a browser app installs its own resolver here.\nexport { ConsoleLogger } from './modules/logger/base/console';\nexport { LoggerSlot } from './modules/logger/slot';\nexport type { TLoggerResolver } from './modules/logger/slot';\nexport * from './modules/network/http-request/fetcher/base-fetcher';\n// The node fetcher carries no node builtin - its one `querystring.stringify` is written out - so the\n// framework HTTP layer is reachable from a browser bundle, and a connector on HTTP need not\n// re-implement one.\nexport * from './modules/network/http-request/fetcher/node-fetcher';\nexport * from './modules/network/http-request/base-network-request.helper';\nexport * from './modules/pool';\nexport * from './modules/queue/internal/hf';\nexport * from './modules/temporal';\nexport * from './modules/uid';\n// The url guard, pure half only: `UrlPolicy` decides a url and a literal address with string and\n// number work. Its sibling `UrlIngest` reaches `node:dns` and stays out of this subpath.\nexport * from './modules/network/utilities/url-safety/common/constants';\nexport type { IUrlSafetyPolicy } from './modules/network/utilities/url-safety/common/types';\nexport * from './modules/network/utilities/url-safety/policy';\nexport * from './modules/network/utilities/query-string';\nexport { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants';\nexport type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants';\nexport type { IRetryBackoffOptions, IRetryContext } from './modules/retry/common/types';\nexport { RetryHelper } from './modules/retry/helper';\nexport { SlugHelper } from './modules/slug/helper';\nexport { TreeBuilder } from './modules/tree/builder';\nexport type {\n IBuildOptions,\n IHeightWhereOptions,\n ILeavesOptions,\n INodeWithPath,\n IPrintOptions,\n ITreeNode,\n IWalkAsyncOptions,\n IWalkOptions,\n TNodePredicate,\n TOnVisit,\n TOnVisitAsync,\n} from './modules/tree/common/types';\nexport { TreeWalker } from './modules/tree/walk';\n\n// Pure value/type utilities that already live under the root barrel's `./utilities` re-export -\n// that barrel also carries node-only siblings (module.utility.ts, request.utility.ts), so it\n// cannot itself become a subpath. Named one at a time here instead of widening the barrel: every\n// symbol below is verified free of node builtins/globals.\nexport { BuildInfoRegistry } from './utilities/build-info.utility';\nexport type { IBuildInfo, TBuildInfoRecord } from './utilities/build-info.utility';\nexport { ParseUtility } from './utilities/parse.utility';\nexport { PerformanceUtility } from './utilities/performance.utility';\nexport { FormBodyUtility, RequestBodyErrors } from './utilities/form-body.utility';\nexport { ProjectRootRegistry } from './utilities/project-root.utility';\n\n// Type-only: erased at compile time, so re-exporting these carries no runtime/bundle cost even\n// though the concrete classes they describe (crypto algorithms, the ioredis-backed helper) are not\n// themselves part of this pure surface.\nexport { AESAlgorithms } from './modules/crypto/algorithms/aes.constants';\nexport type { AESAlgorithmType } from './modules/crypto/algorithms/aes.constants';\nexport type { IPayloadCipher } from './modules/crypto/common/types';\nexport type { IRedisHelper } from './modules/redis/common/interfaces';\n"]}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,6FAA6F;AAC7F,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,6HAA6H;AAC7H,iHAAiH;AACjH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,cAAc,qDAAqD,CAAC;AACpE,qGAAqG;AACrG,4FAA4F;AAC5F,oBAAoB;AACpB,cAAc,qDAAqD,CAAC;AACpE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,iGAAiG;AACjG,yFAAyF;AACzF,cAAc,yDAAyD,CAAC;AAExE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAG5F,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAcrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,+FAA+F;AAC/F,mGAAmG;AACnG,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC","sourcesContent":["export { BaseHelper } from './modules/base';\n// By name, never `export *` from `./modules/env`: that barrel also carries `Environment` and\n// `applicationEnvironment`, both of which read `process.env`.\nexport { EnvironmentNames } from './modules/env/names';\nexport * from './modules/error';\nexport { LogLevels } from './modules/logger/common/types';\nexport type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types';\n// The one way to get a logger, the same in the browser and on the server: `LoggerFactory` imports nothing from node, and its\n// default provider is the console. An application chooses another with `LoggerFactory.use({ provider, level })`.\nexport { ConsoleLogger } from './modules/logger/base/console';\nexport { LoggerFactory } from './modules/logger/factory';\nexport * from './modules/network/http-request/fetcher/base-fetcher';\n// The node fetcher carries no node builtin - its one `querystring.stringify` is written out - so the\n// framework HTTP layer is reachable from a browser bundle, and a connector on HTTP need not\n// re-implement one.\nexport * from './modules/network/http-request/fetcher/node-fetcher';\nexport * from './modules/network/http-request/base-network-request.helper';\nexport * from './modules/pool';\nexport * from './modules/queue/internal/hf';\nexport * from './modules/temporal';\nexport * from './modules/uid';\n// The url guard, pure half only: `UrlPolicy` decides a url and a literal address with string and\n// number work. Its sibling `UrlIngest` reaches `node:dns` and stays out of this subpath.\nexport * from './modules/network/utilities/url-safety/common/constants';\nexport type { IUrlSafetyPolicy } from './modules/network/utilities/url-safety/common/types';\nexport * from './modules/network/utilities/url-safety/policy';\nexport * from './modules/network/utilities/query-string';\nexport { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants';\nexport type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants';\nexport type { IRetryBackoffOptions, IRetryContext } from './modules/retry/common/types';\nexport { RetryHelper } from './modules/retry/helper';\nexport { SlugHelper } from './modules/slug/helper';\nexport { TreeBuilder } from './modules/tree/builder';\nexport type {\n IBuildOptions,\n IHeightWhereOptions,\n ILeavesOptions,\n INodeWithPath,\n IPrintOptions,\n ITreeNode,\n IWalkAsyncOptions,\n IWalkOptions,\n TNodePredicate,\n TOnVisit,\n TOnVisitAsync,\n} from './modules/tree/common/types';\nexport { TreeWalker } from './modules/tree/walk';\n\n// Pure value/type utilities that already live under the root barrel's `./utilities` re-export -\n// that barrel also carries node-only siblings (module.utility.ts, request.utility.ts), so it\n// cannot itself become a subpath. Named one at a time here instead of widening the barrel: every\n// symbol below is verified free of node builtins/globals.\nexport { BuildInfoRegistry } from './utilities/build-info.utility';\nexport type { IBuildInfo, TBuildInfoRecord } from './utilities/build-info.utility';\nexport { ParseUtility } from './utilities/parse.utility';\nexport { PerformanceUtility } from './utilities/performance.utility';\nexport { FormBodyUtility, RequestBodyErrors } from './utilities/form-body.utility';\nexport { ProjectRootRegistry } from './utilities/project-root.utility';\n\n// Type-only: erased at compile time, so re-exporting these carries no runtime/bundle cost even\n// though the concrete classes they describe (crypto algorithms, the ioredis-backed helper) are not\n// themselves part of this pure surface.\nexport { AESAlgorithms } from './modules/crypto/algorithms/aes.constants';\nexport type { AESAlgorithmType } from './modules/crypto/algorithms/aes.constants';\nexport type { IPayloadCipher } from './modules/crypto/common/types';\nexport type { IRedisHelper } from './modules/redis/common/interfaces';\n"]}
@@ -8,7 +8,7 @@ export declare class BaseHelper {
8
8
  });
9
9
  /** The helper's logger, resolved on first read - a helper that never logs never builds one. */
10
10
  get logger(): ILogger;
11
- /** Installs one logger on this helper - a test spy, or a host overriding the global resolver. */
11
+ /** Installs one logger on this helper - a test spy, or a host overriding the factory's logger. */
12
12
  set logger(value: ILogger);
13
13
  getIdentifier(): string;
14
14
  getLogger(): ILogger;
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/modules/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAG7D,qBAAa,UAAU;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAKxD,+FAA+F;IAC/F,IAAI,MAAM,IAAI,OAAO,CAWpB;IAED,iGAAiG;IACjG,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,EAExB;IAED,aAAa;IAIb,SAAS,IAAI,OAAO;CAGrB"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/modules/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAY7D,qBAAa,UAAU;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAKxD,+FAA+F;IAC/F,IAAI,MAAM,IAAI,OAAO,CAWpB;IAED,kGAAkG;IAClG,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,EAExB;IAED,aAAa;IAIb,SAAS,IAAI,OAAO;CAGrB"}
@@ -1,4 +1,13 @@
1
- import { LoggerSlot } from './logger/slot.js';
1
+ import { LoggerFactory } from './logger/factory.js';
2
+ /** Pins a logger on a helper instance: later reads are a plain property read, not its getter. A module function, not a private static: a mixin that extends `BaseHelper` could not be emitted with a private member. */
3
+ const pinLogger = (opts) => {
4
+ Object.defineProperty(opts.helper, 'logger', {
5
+ value: opts.logger,
6
+ writable: true,
7
+ configurable: true,
8
+ enumerable: false,
9
+ });
10
+ };
2
11
  export class BaseHelper {
3
12
  constructor(opts) {
4
13
  this.scope = opts.scope ?? '';
@@ -7,16 +16,16 @@ export class BaseHelper {
7
16
  /** The helper's logger, resolved on first read - a helper that never logs never builds one. */
8
17
  get logger() {
9
18
  const scopes = [this.scope, this.identifier].filter((scope) => typeof scope === 'string' && scope.length > 0);
10
- const logger = LoggerSlot.resolveHelperLogger({ scopes });
19
+ const logger = LoggerFactory.getLogger(scopes);
11
20
  // Read off a prototype (reflection walks them), pinning would shadow this getter for every instance.
12
21
  if (Object.hasOwn(this, 'scope')) {
13
- LoggerSlot.pinHelperLogger({ helper: this, logger });
22
+ pinLogger({ helper: this, logger });
14
23
  }
15
24
  return logger;
16
25
  }
17
- /** Installs one logger on this helper - a test spy, or a host overriding the global resolver. */
26
+ /** Installs one logger on this helper - a test spy, or a host overriding the factory's logger. */
18
27
  set logger(value) {
19
- LoggerSlot.pinHelperLogger({ helper: this, logger: value });
28
+ pinLogger({ helper: this, logger: value });
20
29
  }
21
30
  getIdentifier() {
22
31
  return this.identifier;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/modules/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,OAAO,UAAU;IAIrB,YAAY,IAA4C;QACtD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,+FAA+F;IAC/F,IAAI,MAAM;QACR,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CACjD,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CACzD,CAAC;QACF,MAAM,MAAM,GAAG,UAAU,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAE1D,qGAAqG;QACrG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YACjC,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iGAAiG;IACjG,IAAI,MAAM,CAAC,KAAc;QACvB,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { type ILogger } from '@/modules/logger/common/types';\nimport { LoggerSlot } from '@/modules/logger/slot';\n\nexport class BaseHelper {\n scope: string;\n identifier: string;\n\n constructor(opts: { scope: string; identifier?: string }) {\n this.scope = opts.scope ?? '';\n this.identifier = opts.identifier ?? '';\n }\n\n /** The helper's logger, resolved on first read - a helper that never logs never builds one. */\n get logger(): ILogger {\n const scopes = [this.scope, this.identifier].filter(\n (scope) => typeof scope === 'string' && scope.length > 0,\n );\n const logger = LoggerSlot.resolveHelperLogger({ scopes });\n\n // Read off a prototype (reflection walks them), pinning would shadow this getter for every instance.\n if (Object.hasOwn(this, 'scope')) {\n LoggerSlot.pinHelperLogger({ helper: this, logger });\n }\n return logger;\n }\n\n /** Installs one logger on this helper - a test spy, or a host overriding the global resolver. */\n set logger(value: ILogger) {\n LoggerSlot.pinHelperLogger({ helper: this, logger: value });\n }\n\n getIdentifier() {\n return this.identifier;\n }\n\n getLogger(): ILogger {\n return this.logger;\n }\n}\n"]}
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AED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { LoggerFactory } from '@/modules/logger/factory';\nimport { type ILogger } from '@/modules/logger/common/types';\n\n/** Pins a logger on a helper instance: later reads are a plain property read, not its getter. A module function, not a private static: a mixin that extends `BaseHelper` could not be emitted with a private member. */\nconst pinLogger = (opts: { helper: object; logger: ILogger }): void => {\n Object.defineProperty(opts.helper, 'logger', {\n value: opts.logger,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n};\n\nexport class BaseHelper {\n scope: string;\n identifier: string;\n\n constructor(opts: { scope: string; identifier?: string }) {\n this.scope = opts.scope ?? '';\n this.identifier = opts.identifier ?? '';\n }\n\n /** The helper's logger, resolved on first read - a helper that never logs never builds one. */\n get logger(): ILogger {\n const scopes = [this.scope, this.identifier].filter(\n (scope) => typeof scope === 'string' && scope.length > 0,\n );\n const logger = LoggerFactory.getLogger(scopes);\n\n // Read off a prototype (reflection walks them), pinning would shadow this getter for every instance.\n if (Object.hasOwn(this, 'scope')) {\n pinLogger({ helper: this, logger });\n }\n return logger;\n }\n\n /** Installs one logger on this helper - a test spy, or a host overriding the factory's logger. */\n set logger(value: ILogger) {\n pinLogger({ helper: this, logger: value });\n }\n\n getIdentifier() {\n return this.identifier;\n }\n\n getLogger(): ILogger {\n return this.logger;\n }\n}\n"]}
@@ -3,6 +3,8 @@ import { type THashAlgorithm, type THashOutputEncoding } from '../common/index.j
3
3
  interface IHashExtraOptions {
4
4
  outputEncoding?: THashOutputEncoding;
5
5
  }
6
+ /** Text is hashed as UTF-8, bytes as they are. */
7
+ type THashInput = string | Uint8Array;
6
8
  /**
7
9
  * One-way message digests and keyed HMACs. Unlike `AES`/`RSA` this has no `decrypt` - a digest
8
10
  * cannot be reversed, so `digest`/`hmac` are the only operations, not `ICryptoAlgorithm`.
@@ -18,15 +20,23 @@ export declare class Hash extends BaseHelper {
18
20
  validateAlgorithmName(opts: {
19
21
  algorithm: THashAlgorithm;
20
22
  }): void;
21
- /** Plain digest, no secret. MD5/SHA1 are broken/weak - see {@link HashAlgorithms} - never use for security decisions. */
23
+ /**
24
+ * Plain digest, no secret. `message` is text (UTF-8), bytes, or several parts hashed in order as ONE message: a git
25
+ * blob is the header text "blob <size>" and a NUL byte, then the bytes, so its parts are the header and the bytes. MD5/SHA1
26
+ * are broken/weak - see {@link HashAlgorithms} - never use for security decisions.
27
+ */
22
28
  digest(opts: {
23
- message: string;
29
+ message: THashInput | ReadonlyArray<THashInput>;
24
30
  opts?: IHashExtraOptions;
25
31
  }): string;
26
- /** Keyed HMAC. `secret` is mandatory and validated non-empty so a request for an HMAC never silently degrades into an unkeyed digest. */
32
+ /**
33
+ * Keyed HMAC. `message` and `secret` are text (UTF-8) or bytes: a `Buffer` or `Uint8Array` key gives the same output
34
+ * as the text of the same bytes, so a token printed with one keeps verifying with the other. `secret` is mandatory and
35
+ * validated non-empty so a request for an HMAC never silently degrades into an unkeyed digest.
36
+ */
27
37
  hmac(opts: {
28
- message: string;
29
- secret: string;
38
+ message: THashInput;
39
+ secret: THashInput;
30
40
  opts?: IHashExtraOptions;
31
41
  }): string;
32
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hash.algorithm.d.ts","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/hash.algorithm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAEnB,UAAU,iBAAiB;IACzB,cAAc,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED;;;GAGG;AACH,qBAAa,IAAK,SAAQ,UAAU;IAClC,SAAS,EAAE,cAAc,CAAC;gBAEd,IAAI,EAAE;QAAE,SAAS,EAAE,cAAc,CAAA;KAAE;IAO/C,wJAAwJ;IACxJ,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CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,EAAE,iBAAiB,CAAC;KAC1B,GAAG,MAAM;IAYV;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,iBAAiB,CAAA;KAAE,GAAG,MAAM;CAY1F"}
@@ -31,17 +31,29 @@ export class Hash extends BaseHelper {
31
31
  });
32
32
  }
33
33
  }
34
- /** Plain digest, no secret. MD5/SHA1 are broken/weak - see {@link HashAlgorithms} - never use for security decisions. */
34
+ /**
35
+ * Plain digest, no secret. `message` is text (UTF-8), bytes, or several parts hashed in order as ONE message: a git
36
+ * blob is the header text "blob <size>" and a NUL byte, then the bytes, so its parts are the header and the bytes. MD5/SHA1
37
+ * are broken/weak - see {@link HashAlgorithms} - never use for security decisions.
38
+ */
35
39
  digest(opts) {
36
40
  const { message } = opts;
37
41
  const { outputEncoding = DEFAULT_HASH_OUTPUT_ENCODING } = opts.opts ?? {};
38
- return C.createHash(this.algorithm).update(message).digest(outputEncoding);
42
+ const hash = C.createHash(this.algorithm);
43
+ for (const part of Array.isArray(message) ? message : [message]) {
44
+ hash.update(part);
45
+ }
46
+ return hash.digest(outputEncoding);
39
47
  }
40
- /** Keyed HMAC. `secret` is mandatory and validated non-empty so a request for an HMAC never silently degrades into an unkeyed digest. */
48
+ /**
49
+ * Keyed HMAC. `message` and `secret` are text (UTF-8) or bytes: a `Buffer` or `Uint8Array` key gives the same output
50
+ * as the text of the same bytes, so a token printed with one keeps verifying with the other. `secret` is mandatory and
51
+ * validated non-empty so a request for an HMAC never silently degrades into an unkeyed digest.
52
+ */
41
53
  hmac(opts) {
42
54
  const { message, secret } = opts;
43
55
  const { outputEncoding = DEFAULT_HASH_OUTPUT_ENCODING } = opts.opts ?? {};
44
- if (!secret) {
56
+ if (secret.length === 0) {
45
57
  throw getError({
46
58
  message: `[Hash][hmac] Missing secret for HMAC-${this.algorithm.toUpperCase()}`,
47
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"hash.algorithm.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/hash.algorithm.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,4BAA4B,EAC5B,cAAc,GAGf,MAAM,WAAW,CAAC;AAMnB;;;GAGG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IAGlC,YAAY,IAAmC;QAC7C,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,qBAAqB,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,wJAAwJ;aAChI,cAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEpE,MAAM,CAAC,aAAa,CAAC,SAAyB;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEvC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,qBAAqB,CAAC,IAAmC;QACvD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAE3B,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACrD,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,qEAAqE,SAAS,EAAE;aAC1F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,yHAAyH;IACzH,MAAM,CAAC,IAAmD;QACxD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,MAAM,EAAE,cAAc,GAAG,4BAA4B,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAE1E,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC7E,CAAC;IAED,yIAAyI;IACzI,IAAI,CAAC,IAAmE;QACtE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACjC,MAAM,EAAE,cAAc,GAAG,4BAA4B,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAE1E,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,wCAAwC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE;aAChF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACrF,CAAC","sourcesContent":["import C from 'node:crypto';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport {\n DEFAULT_HASH_OUTPUT_ENCODING,\n HashAlgorithms,\n type THashAlgorithm,\n type THashOutputEncoding,\n} from '../common';\n\ninterface IHashExtraOptions {\n outputEncoding?: THashOutputEncoding;\n}\n\n/**\n * One-way message digests and keyed HMACs. Unlike `AES`/`RSA` this has no `decrypt` - a digest\n * cannot be reversed, so `digest`/`hmac` are the only operations, not `ICryptoAlgorithm`.\n */\nexport class Hash extends BaseHelper {\n algorithm: THashAlgorithm;\n\n constructor(opts: { algorithm: THashAlgorithm }) {\n super({ scope: Hash.name, identifier: opts.algorithm });\n this.validateAlgorithmName({ algorithm: opts.algorithm });\n\n this.algorithm = opts.algorithm;\n }\n\n /** Memoized - `BaseHelper`'s constructor resolves a logger on every allocation (~50ns), and downstream token code calls `withAlgorithm` per request. */\n private static readonly instances = new Map<THashAlgorithm, Hash>();\n\n static withAlgorithm(algorithm: THashAlgorithm) {\n const cached = Hash.instances.get(algorithm);\n if (cached) {\n return cached;\n }\n\n const created = new Hash({ algorithm });\n Hash.instances.set(algorithm, created);\n\n return created;\n }\n\n validateAlgorithmName(opts: { algorithm: THashAlgorithm }) {\n const { algorithm } = opts;\n\n if (!algorithm || !HashAlgorithms.isValid(algorithm)) {\n throw getError({\n message: `[Hash][validateAlgorithmName] Invalid algorithm name | algorithm: ${algorithm}`,\n });\n }\n }\n\n /** Plain digest, no secret. MD5/SHA1 are broken/weak - see {@link HashAlgorithms} - never use for security decisions. */\n digest(opts: { message: string; opts?: IHashExtraOptions }): string {\n const { message } = opts;\n const { outputEncoding = DEFAULT_HASH_OUTPUT_ENCODING } = opts.opts ?? {};\n\n return C.createHash(this.algorithm).update(message).digest(outputEncoding);\n }\n\n /** Keyed HMAC. `secret` is mandatory and validated non-empty so a request for an HMAC never silently degrades into an unkeyed digest. */\n hmac(opts: { message: string; secret: string; opts?: IHashExtraOptions }): string {\n const { message, secret } = opts;\n const { outputEncoding = DEFAULT_HASH_OUTPUT_ENCODING } = opts.opts ?? {};\n\n if (!secret) {\n throw getError({\n message: `[Hash][hmac] Missing secret for HMAC-${this.algorithm.toUpperCase()}`,\n });\n }\n\n return C.createHmac(this.algorithm, secret).update(message).digest(outputEncoding);\n }\n}\n"]}
1
+ {"version":3,"file":"hash.algorithm.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/hash.algorithm.ts"],"names":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AC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAGN;QACC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,MAAM,EAAE,cAAc,GAAG,4BAA4B,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1E,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE1C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,IAA2E;QAC9E,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACjC,MAAM,EAAE,cAAc,GAAG,4BAA4B,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAE1E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,wCAAwC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE;aAChF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACrF,CAAC","sourcesContent":["import C from 'node:crypto';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport {\n DEFAULT_HASH_OUTPUT_ENCODING,\n HashAlgorithms,\n type THashAlgorithm,\n type THashOutputEncoding,\n} from '../common';\n\ninterface IHashExtraOptions {\n outputEncoding?: THashOutputEncoding;\n}\n\n/** Text is hashed as UTF-8, bytes as they are. */\ntype THashInput = string | Uint8Array;\n\n/**\n * One-way message digests and keyed HMACs. Unlike `AES`/`RSA` this has no `decrypt` - a digest\n * cannot be reversed, so `digest`/`hmac` are the only operations, not `ICryptoAlgorithm`.\n */\nexport class Hash extends BaseHelper {\n algorithm: THashAlgorithm;\n\n constructor(opts: { algorithm: THashAlgorithm }) {\n super({ scope: Hash.name, identifier: opts.algorithm });\n this.validateAlgorithmName({ algorithm: opts.algorithm });\n\n this.algorithm = opts.algorithm;\n }\n\n /** Memoized - `BaseHelper`'s constructor resolves a logger on every allocation (~50ns), and downstream token code calls `withAlgorithm` per request. */\n private static readonly instances = new Map<THashAlgorithm, Hash>();\n\n static withAlgorithm(algorithm: THashAlgorithm) {\n const cached = Hash.instances.get(algorithm);\n if (cached) {\n return cached;\n }\n\n const created = new Hash({ algorithm });\n Hash.instances.set(algorithm, created);\n\n return created;\n }\n\n validateAlgorithmName(opts: { algorithm: THashAlgorithm }) {\n const { algorithm } = opts;\n\n if (!algorithm || !HashAlgorithms.isValid(algorithm)) {\n throw getError({\n message: `[Hash][validateAlgorithmName] Invalid algorithm name | algorithm: ${algorithm}`,\n });\n }\n }\n\n /**\n * Plain digest, no secret. `message` is text (UTF-8), bytes, or several parts hashed in order as ONE message: a git\n * blob is the header text \"blob <size>\" and a NUL byte, then the bytes, so its parts are the header and the bytes. MD5/SHA1\n * are broken/weak - see {@link HashAlgorithms} - never use for security decisions.\n */\n digest(opts: {\n message: THashInput | ReadonlyArray<THashInput>;\n opts?: IHashExtraOptions;\n }): string {\n const { message } = opts;\n const { outputEncoding = DEFAULT_HASH_OUTPUT_ENCODING } = opts.opts ?? {};\n const hash = C.createHash(this.algorithm);\n\n for (const part of Array.isArray(message) ? message : [message]) {\n hash.update(part);\n }\n\n return hash.digest(outputEncoding);\n }\n\n /**\n * Keyed HMAC. `message` and `secret` are text (UTF-8) or bytes: a `Buffer` or `Uint8Array` key gives the same output\n * as the text of the same bytes, so a token printed with one keeps verifying with the other. `secret` is mandatory and\n * validated non-empty so a request for an HMAC never silently degrades into an unkeyed digest.\n */\n hmac(opts: { message: THashInput; secret: THashInput; opts?: IHashExtraOptions }): string {\n const { message, secret } = opts;\n const { outputEncoding = DEFAULT_HASH_OUTPUT_ENCODING } = opts.opts ?? {};\n\n if (secret.length === 0) {\n throw getError({\n message: `[Hash][hmac] Missing secret for HMAC-${this.algorithm.toUpperCase()}`,\n });\n }\n\n return C.createHmac(this.algorithm, secret).update(message).digest(outputEncoding);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/base/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,0LAA0L;AAC1L,8BAAsB,UAAW,SAAQ,cAAc;IACrD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;gBAEhC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAMnC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI;IAEjG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAE1D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAOzC,IAAI,CAAC,OAAO,EAA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AAG,IAAI,EAAE,OAAO,EAAE;IAOzC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAOzD,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAIjC"}
@@ -1,4 +1,4 @@
1
- import { LogLevels, SHOULD_LOG_DEBUG } from '../common/index.js';
1
+ import { LogLevels, LoggerDebugGate } from '../common/index.js';
2
2
  import { AbstractLogger } from './abstract.js';
3
3
  /** Provider-independent plumbing: scope, prefix, DEBUG gate, for(). Every level method funnels into ONE abstract write() sink; child() lets each provider keep its own caching policy. */
4
4
  export class BaseLogger extends AbstractLogger {
@@ -8,7 +8,7 @@ export class BaseLogger extends AbstractLogger {
8
8
  this._formattedPrefix = opts.scope !== '' ? `[${opts.scope}] ` : '';
9
9
  }
10
10
  debug(message, ...args) {
11
- if (!SHOULD_LOG_DEBUG) {
11
+ if (!LoggerDebugGate.isOpen()) {
12
12
  return;
13
13
  }
14
14
  this.write({ level: LogLevels.DEBUG, message, args });
@@ -26,7 +26,7 @@ export class BaseLogger extends AbstractLogger {
26
26
  this.write({ level: LogLevels.EMERG, message, args });
27
27
  }
28
28
  log(level, message, ...args) {
29
- if (level === LogLevels.DEBUG && !SHOULD_LOG_DEBUG) {
29
+ if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {
30
30
  return;
31
31
  }
32
32
  this.write({ level, message, args });
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sour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C,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,OAAe,EAAE,GAAG,IAAe;QACvD,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,qHAAqH;QACrH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;CACF","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { type ILogger, LogLevels, SHOULD_LOG_DEBUG, type TLogLevel } from '../common';\nimport { AbstractLogger } from './abstract';\n\n/** Provider-independent plumbing: scope, prefix, DEBUG gate, for(). Every level method funnels into ONE abstract write() sink; child() lets each provider keep its own caching policy. */\nexport abstract class BaseLogger extends AbstractLogger {\n protected readonly _scope: string;\n protected readonly _formattedPrefix: string;\n\n constructor(opts: { scope: string }) {\n super();\n this._scope = opts.scope;\n this._formattedPrefix = opts.scope !== '' ? `[${opts.scope}] ` : '';\n }\n\n protected abstract write(opts: { level: TLogLevel; message: string; args: Array<AnyType> }): void;\n\n protected abstract child(opts: { scope: string }): ILogger;\n\n debug(message: string, ...args: AnyType[]) {\n if (!SHOULD_LOG_DEBUG) {\n return;\n }\n this.write({ level: LogLevels.DEBUG, message, args });\n }\n\n info(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.INFO, message, args });\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.WARN, message, args });\n }\n\n error(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.ERROR, message, args });\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.EMERG, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n if (level === LogLevels.DEBUG && !SHOULD_LOG_DEBUG) {\n return;\n }\n this.write({ level, message, args });\n }\n\n for(methodName: string): ILogger {\n // An empty parent scope must not produce a leading dash - the child simply takes the method name as its whole scope.\n return this.child({ scope: this._scope !== '' ? `${this._scope}-${methodName}` : methodName });\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,SAAS,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,0LAA0L;AAC1L,MAAM,OAAgB,UAAW,SAAQ,cAAc;IAIrD,YAAY,IAAuB;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC;IAMD,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,OAAe,EAAE,GAAG,IAAe;QACvD,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3D,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,qHAAqH;QACrH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;CACF","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { type ILogger, LogLevels, LoggerDebugGate, type TLogLevel } from '../common';\nimport { AbstractLogger } from './abstract';\n\n/** Provider-independent plumbing: scope, prefix, DEBUG gate, for(). Every level method funnels into ONE abstract write() sink; child() lets each provider keep its own caching policy. */\nexport abstract class BaseLogger extends AbstractLogger {\n protected readonly _scope: string;\n protected readonly _formattedPrefix: string;\n\n constructor(opts: { scope: string }) {\n super();\n this._scope = opts.scope;\n this._formattedPrefix = opts.scope !== '' ? `[${opts.scope}] ` : '';\n }\n\n protected abstract write(opts: { level: TLogLevel; message: string; args: Array<AnyType> }): void;\n\n protected abstract child(opts: { scope: string }): ILogger;\n\n debug(message: string, ...args: AnyType[]) {\n if (!LoggerDebugGate.isOpen()) {\n return;\n }\n this.write({ level: LogLevels.DEBUG, message, args });\n }\n\n info(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.INFO, message, args });\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.WARN, message, args });\n }\n\n error(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.ERROR, message, args });\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.write({ level: LogLevels.EMERG, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {\n return;\n }\n this.write({ level, message, args });\n }\n\n for(methodName: string): ILogger {\n // An empty parent scope must not produce a leading dash - the child simply takes the method name as its whole scope.\n return this.child({ scope: this._scope !== '' ? `${this._scope}-${methodName}` : methodName });\n }\n}\n"]}
@@ -1,14 +1,19 @@
1
1
  import { type AnyType } from '../../../common/types/index.js';
2
2
  import { type ILogger, type TLogLevel } from '../common/types.js';
3
3
  import { AbstractLogger } from './abstract.js';
4
- /** The resolver's default when no provider is registered - the only logger a browser bundle can reach. Extends AbstractLogger rather than BaseLogger because BaseLogger's DEBUG gate reads process.env at module load. */
4
+ /**
5
+ * The default logger provider: it writes to the console, and it is the only provider a browser bundle reaches. It
6
+ * satisfies `ILoggerProvider` (`ConsoleLogger.get(scope)`), so it is registered like Winston and Pino.
7
+ *
8
+ * Extends AbstractLogger rather than BaseLogger because BaseLogger's module graph reads `process.env` at load.
9
+ * `debug` follows the rule of the other providers (`LoggerDebugGate`): off unless `DEBUG` is truthy and the
10
+ * environment is allowed, and off in a browser, which has no `process`; `LoggerFactory.use({ level })` overrides it.
11
+ */
5
12
  export declare class ConsoleLogger extends AbstractLogger {
6
13
  private readonly scope;
7
14
  private readonly prefix;
8
15
  private constructor();
9
- static get(opts: {
10
- scope: string;
11
- }): ILogger;
16
+ static get(scope: string): ConsoleLogger;
12
17
  private emit;
13
18
  debug(message: string, ...args: AnyType[]): void;
14
19
  info(message: string, ...args: AnyType[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/base/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,0NAA0N;AAC1N,qBAAa,aAAc,SAAQ,cAAc;IAG3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAF1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO;IAKP,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAI5C,OAAO,CAAC,IAAI;IAQZ,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAqBzD,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAIjC"}
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/base/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,KAAK,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAG3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAF1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO;IAKP,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IAIxC,OAAO,CAAC,IAAI;IAQZ,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAQzC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAqBzD,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAIjC"}
@@ -1,19 +1,30 @@
1
+ import { LoggerDebugGate } from '../common/debug-gate.js';
1
2
  import { LogLevels } from '../common/types.js';
2
3
  import { AbstractLogger } from './abstract.js';
3
- /** The resolver's default when no provider is registered - the only logger a browser bundle can reach. Extends AbstractLogger rather than BaseLogger because BaseLogger's DEBUG gate reads process.env at module load. */
4
+ /**
5
+ * The default logger provider: it writes to the console, and it is the only provider a browser bundle reaches. It
6
+ * satisfies `ILoggerProvider` (`ConsoleLogger.get(scope)`), so it is registered like Winston and Pino.
7
+ *
8
+ * Extends AbstractLogger rather than BaseLogger because BaseLogger's module graph reads `process.env` at load.
9
+ * `debug` follows the rule of the other providers (`LoggerDebugGate`): off unless `DEBUG` is truthy and the
10
+ * environment is allowed, and off in a browser, which has no `process`; `LoggerFactory.use({ level })` overrides it.
11
+ */
4
12
  export class ConsoleLogger extends AbstractLogger {
5
13
  constructor(scope) {
6
14
  super();
7
15
  this.scope = scope;
8
16
  this.prefix = scope !== '' ? `[${scope}] ` : '';
9
17
  }
10
- static get(opts) {
11
- return new ConsoleLogger(opts.scope);
18
+ static get(scope) {
19
+ return new ConsoleLogger(scope);
12
20
  }
13
21
  emit(opts) {
14
22
  opts.sink(`${this.prefix}${opts.message}`, ...opts.args);
15
23
  }
16
24
  debug(message, ...args) {
25
+ if (!LoggerDebugGate.isOpen()) {
26
+ return;
27
+ }
17
28
  this.emit({ sink: console.debug, message, args });
18
29
  }
19
30
  info(message, ...args) {
@@ -50,7 +61,7 @@ export class ConsoleLogger extends AbstractLogger {
50
61
  }
51
62
  for(methodName) {
52
63
  const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;
53
- return ConsoleLogger.get({ scope: childScope });
64
+ return ConsoleLogger.get(childScope);
54
65
  }
55
66
  }
56
67
  //# sourceMappingURL=console.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/console.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,0NAA0N;AAC1N,MAAM,OAAO,aAAc,S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C,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,OAAe,EAAE,GAAG,IAAe;QACvD,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC5B,OAAO;YACT,CAAC;YACD,KAAK,SAAS,CAAC,KAAK,CAAC;YACrB,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;QAClF,OAAO,aAAa,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { type ILogger, LogLevels, type TLogLevel } from '../common/types';\nimport { AbstractLogger } from './abstract';\n\n/** The resolver's default when no provider is registered - the only logger a browser bundle can reach. Extends AbstractLogger rather than BaseLogger because BaseLogger's DEBUG gate reads process.env at module load. */\nexport class ConsoleLogger extends AbstractLogger {\n private readonly prefix: string;\n\n private constructor(private readonly scope: string) {\n super();\n this.prefix = scope !== '' ? `[${scope}] ` : '';\n }\n\n static get(opts: { scope: string }): ILogger {\n return new ConsoleLogger(opts.scope);\n }\n\n private emit(opts: {\n sink: (message: string, ...args: AnyType[]) => void;\n message: string;\n args: AnyType[];\n }) {\n opts.sink(`${this.prefix}${opts.message}`, ...opts.args);\n }\n\n debug(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.debug, message, args });\n }\n\n info(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.log, message, args });\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.warn, message, args });\n }\n\n error(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.error, message, args });\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.error, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n switch (level) {\n case LogLevels.DEBUG: {\n this.debug(message, ...args);\n return;\n }\n case LogLevels.WARN: {\n this.warn(message, ...args);\n return;\n }\n case LogLevels.ERROR:\n case LogLevels.EMERG: {\n this.error(message, ...args);\n return;\n }\n default: {\n this.info(message, ...args);\n }\n }\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n return ConsoleLogger.get({ scope: childScope });\n }\n}\n"]}
1
+ {"version":3,"file":"console.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/console.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAgB,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAG/C,YAAqC,KAAa;QAChD,KAAK,EAAE,CAAC;QAD2B,UAAK,GAAL,KAAK,CAAQ;QAEhD,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,EAAE,CAAC,C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AgB,EAAE,OAAe,EAAE,GAAG,IAAe;QACvD,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC5B,OAAO;YACT,CAAC;YACD,KAAK,SAAS,CAAC,KAAK,CAAC;YACrB,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;QAClF,OAAO,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { LoggerDebugGate } from '../common/debug-gate';\nimport { type ILogger, LogLevels, type TLogLevel } from '../common/types';\nimport { AbstractLogger } from './abstract';\n\n/**\n * The default logger provider: it writes to the console, and it is the only provider a browser bundle reaches. It\n * satisfies `ILoggerProvider` (`ConsoleLogger.get(scope)`), so it is registered like Winston and Pino.\n *\n * Extends AbstractLogger rather than BaseLogger because BaseLogger's module graph reads `process.env` at load.\n * `debug` follows the rule of the other providers (`LoggerDebugGate`): off unless `DEBUG` is truthy and the\n * environment is allowed, and off in a browser, which has no `process`; `LoggerFactory.use({ level })` overrides it.\n */\nexport class ConsoleLogger extends AbstractLogger {\n private readonly prefix: string;\n\n private constructor(private readonly scope: string) {\n super();\n this.prefix = scope !== '' ? `[${scope}] ` : '';\n }\n\n static get(scope: string): ConsoleLogger {\n return new ConsoleLogger(scope);\n }\n\n private emit(opts: {\n sink: (message: string, ...args: AnyType[]) => void;\n message: string;\n args: AnyType[];\n }) {\n opts.sink(`${this.prefix}${opts.message}`, ...opts.args);\n }\n\n debug(message: string, ...args: AnyType[]) {\n if (!LoggerDebugGate.isOpen()) {\n return;\n }\n\n this.emit({ sink: console.debug, message, args });\n }\n\n info(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.log, message, args });\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.warn, message, args });\n }\n\n error(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.error, message, args });\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.emit({ sink: console.error, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n switch (level) {\n case LogLevels.DEBUG: {\n this.debug(message, ...args);\n return;\n }\n case LogLevels.WARN: {\n this.warn(message, ...args);\n return;\n }\n case LogLevels.ERROR:\n case LogLevels.EMERG: {\n this.error(message, ...args);\n return;\n }\n default: {\n this.info(message, ...args);\n }\n }\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n return ConsoleLogger.get(childScope);\n }\n}\n"]}
@@ -7,7 +7,6 @@ export declare class LoggerFormats {
7
7
  static isValid(input: string): input is TLoggerFormat;
8
8
  }
9
9
  export type TLoggerFormat = TConstValue<typeof LoggerFormats>;
10
- export declare const SHOULD_LOG_DEBUG: boolean;
11
10
  export declare class LoggerConfigUtility {
12
11
  /** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */
13
12
  static resolveLevel(opts: {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAmC;IAE7D,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa;CAGtD;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAQ9D,eAAO,MAAM,gBAAgB,SAEwC,CAAC;AAEtE,qBAAa,mBAAmB;IAC9B,mPAAmP;IACnP,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAsB7D;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,GAAG,SAAS;CAkBxB"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAmC;IAE7D,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa;CAGtD;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAG9D,qBAAa,mBAAmB;IAC9B,mPAAmP;IACnP,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAsB7D;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,GAAG,SAAS;CAkBxB"}
@@ -11,12 +11,6 @@ export class LoggerFormats {
11
11
  }
12
12
  }
13
13
  // -------------------------------------------------------------
14
- const extraLogEnvs = (process.env.APP_ENV_EXTRA_LOG_ENVS ?? '').split(',').map((el) => el.trim());
15
- const LOG_ENVIRONMENTS = new Set([...Array.from(Environment.COMMON_ENVS), ...extraLogEnvs]);
16
- /** debug() gate, computed ONCE at module load: DEBUG truthy and NODE_ENV unset or allowlisted. Shared across every logger implementation - runtime env changes need a restart. */
17
- const { DEBUG } = process.env;
18
- export const SHOULD_LOG_DEBUG = ParseUtility.toBoolean({ input: DEBUG }) &&
19
- (!Environment.ambient || LOG_ENVIRONMENTS.has(Environment.ambient));
20
14
  export class LoggerConfigUtility {
21
15
  /** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */
22
16
  static resolveLevel(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/logger/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAA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zB,CAAC;QAED,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YACnC,gJAAgJ;YAChJ,OAAO,CAAC,IAAI,CACV,mFAAmF,EACnF,UAAU,EACV,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,EACzB,SAAS,CAAC,KAAK,CAChB,CAAC;YACF,OAAO,SAAS,CAAC,KAAK,CAAC;QACzB,CAAC;QAED,OAAO,UAAuB,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,eAAe,CAAC,IAGtB;QACC,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACxE,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,OAAO,YAAY,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QACrC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,WAAW,CAAC,OAAO,CAAC;QAC7D,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { type TConstValue } from '@/common/types';\nimport { Environment } from '@/modules/env';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport { LogLevels, type TLogLevel } from './types';\n\n// -------------------------------------------------------------\nexport class LoggerFormats {\n static readonly JSON = 'json';\n static readonly TEXT = 'text';\n\n static readonly SCHEME_SET = new Set([this.JSON, this.TEXT]);\n\n static isValid(input: string): input is TLoggerFormat {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TLoggerFormat = TConstValue<typeof LoggerFormats>;\n\n// -------------------------------------------------------------\nconst extraLogEnvs = (process.env.APP_ENV_EXTRA_LOG_ENVS ?? '').split(',').map((el) => el.trim());\nconst LOG_ENVIRONMENTS = new Set([...Array.from(Environment.COMMON_ENVS), ...extraLogEnvs]);\n\n/** debug() gate, computed ONCE at module load: DEBUG truthy and NODE_ENV unset or allowlisted. Shared across every logger implementation - runtime env changes need a restart. */\nconst { DEBUG } = process.env;\nexport const SHOULD_LOG_DEBUG =\n ParseUtility.toBoolean({ input: DEBUG }) &&\n (!Environment.ambient || LOG_ENVIRONMENTS.has(Environment.ambient));\n\nexport class LoggerConfigUtility {\n /** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */\n static resolveLevel(opts: { configured?: string }): TLogLevel {\n const { configured } = opts;\n\n if (!configured || configured.trim() === '') {\n return LogLevels.DEBUG;\n }\n\n const normalized = configured.trim().toLowerCase();\n if (!LogLevels.isValid(normalized)) {\n // console, not Logger: the logger is being built - routing this warning through it would re-enter the very pipeline that is not configured yet.\n console.warn(\n '[resolveLoggerLevel] Invalid logger level | value: %s | valids: %s | fallback: %s',\n configured,\n [...LogLevels.SCHEME_SET],\n LogLevels.DEBUG,\n );\n return LogLevels.DEBUG;\n }\n\n return normalized as TLogLevel;\n }\n\n /**\n * Whether log lines may carry ANSI color, resolved at CALL time. First match wins:\n *\n * 1. `APP_ENV_LOGGER_COLOR` - an explicit yes or no from the operator.\n * 2. `NO_COLOR`, set to anything non-empty - the no-color.org convention.\n * 3. `NODE_ENV` outside {@link Environment.DEVELOPMENT_ENVS} - production, staging, uat and any\n * unrecognized name. Fail-closed, the same boundary the error sanitizer draws: colors are a\n * terminal affordance, and in a deployed environment the same bytes land in a file or an\n * aggregator as escape noise every grep then has to strip.\n *\n * `undefined` means the framework has no opinion, so a provider that detects a terminal itself\n * keeps deciding - which is why the pino path forwards nothing in that case.\n */\n static resolveColorize(opts?: {\n configured?: string;\n environment?: string;\n }): boolean | undefined {\n const configured = opts?.configured ?? process.env.APP_ENV_LOGGER_COLOR;\n if (configured !== undefined && configured.trim() !== '') {\n return ParseUtility.toBoolean({ input: configured.trim().toLowerCase() });\n }\n\n const noColor = process.env.NO_COLOR;\n if (noColor !== undefined && noColor !== '') {\n return false;\n }\n\n const environment = opts?.environment ?? Environment.current;\n if (!Environment.DEVELOPMENT_ENVS.has(environment)) {\n return false;\n }\n\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/logger/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAkB,MAAM,SAAS,CAAC;AAEpD,gEAAgE;AAChE,MAAM,OAAO,aAAa;aACR,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAE7D,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,gEAAgE;AAChE,MAAM,OAAO,mBAAmB;IAC9B,mPAAmP;IACnP,MAAM,CAAC,YAAY,CAAC,IAA6B;QAC/C,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAE5B,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC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{ Environment } from '@/modules/env';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport { LogLevels, type TLogLevel } from './types';\n\n// -------------------------------------------------------------\nexport class LoggerFormats {\n static readonly JSON = 'json';\n static readonly TEXT = 'text';\n\n static readonly SCHEME_SET = new Set([this.JSON, this.TEXT]);\n\n static isValid(input: string): input is TLoggerFormat {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TLoggerFormat = TConstValue<typeof LoggerFormats>;\n\n// -------------------------------------------------------------\nexport class LoggerConfigUtility {\n /** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */\n static resolveLevel(opts: { configured?: string }): TLogLevel {\n const { configured } = opts;\n\n if (!configured || configured.trim() === '') {\n return LogLevels.DEBUG;\n }\n\n const normalized = configured.trim().toLowerCase();\n if (!LogLevels.isValid(normalized)) {\n // console, not Logger: the logger is being built - routing this warning through it would re-enter the very pipeline that is not configured yet.\n console.warn(\n '[resolveLoggerLevel] Invalid logger level | value: %s | valids: %s | fallback: %s',\n configured,\n [...LogLevels.SCHEME_SET],\n LogLevels.DEBUG,\n );\n return LogLevels.DEBUG;\n }\n\n return normalized as TLogLevel;\n }\n\n /**\n * Whether log lines may carry ANSI color, resolved at CALL time. First match wins:\n *\n * 1. `APP_ENV_LOGGER_COLOR` - an explicit yes or no from the operator.\n * 2. `NO_COLOR`, set to anything non-empty - the no-color.org convention.\n * 3. `NODE_ENV` outside {@link Environment.DEVELOPMENT_ENVS} - production, staging, uat and any\n * unrecognized name. Fail-closed, the same boundary the error sanitizer draws: colors are a\n * terminal affordance, and in a deployed environment the same bytes land in a file or an\n * aggregator as escape noise every grep then has to strip.\n *\n * `undefined` means the framework has no opinion, so a provider that detects a terminal itself\n * keeps deciding - which is why the pino path forwards nothing in that case.\n */\n static resolveColorize(opts?: {\n configured?: string;\n environment?: string;\n }): boolean | undefined {\n const configured = opts?.configured ?? process.env.APP_ENV_LOGGER_COLOR;\n if (configured !== undefined && configured.trim() !== '') {\n return ParseUtility.toBoolean({ input: configured.trim().toLowerCase() });\n }\n\n const noColor = process.env.NO_COLOR;\n if (noColor !== undefined && noColor !== '') {\n return false;\n }\n\n const environment = opts?.environment ?? Environment.current;\n if (!Environment.DEVELOPMENT_ENVS.has(environment)) {\n return false;\n }\n\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ type TEnvironment = Record<string, string | undefined>;
2
+ /**
3
+ * The rule that decides whether `debug` lines are written: off unless `DEBUG` is truthy and the environment is allowed
4
+ * (`NODE_ENV` unset, or one of the common names, or one `APP_ENV_EXTRA_LOG_ENVS` adds). Every provider shares it, so a
5
+ * console, a winston and a pino logger agree.
6
+ *
7
+ * Pure: it takes the environment as an argument and reads `process` only through a guarded `globalThis` read, because a
8
+ * browser has none and there the default is off. `LoggerFactory.use({ level })` overrides it.
9
+ */
10
+ export declare class LoggerDebugGate {
11
+ /** The override lives on globalThis, so `use({ level })` in one copy of the module opens or closes debug in the other. */
12
+ private static readonly FORCED_SLOT;
13
+ private static resolved?;
14
+ /** The environment the host has, `{}` where there is no `process`. */
15
+ static readEnvironment(): TEnvironment;
16
+ /**
17
+ * The truthiness `ParseUtility.toBoolean` has, repeated here on purpose: `ParseUtility` imports the error module, and
18
+ * this file is in the graph of `BaseHelper`, which must stay a few hundred bytes in a browser bundle.
19
+ */
20
+ private static isTruthy;
21
+ /** The rule itself, for any environment: a pure function of `env`. */
22
+ static evaluate(opts: {
23
+ env: TEnvironment;
24
+ }): boolean;
25
+ /** Whether `debug` is written now: the override when `use` set one, else the rule on the host's environment, read once. */
26
+ static isOpen(): boolean;
27
+ /** `LoggerFactory.use({ level })` calls it: an explicit level turns debug on or off whatever the environment says. */
28
+ static force(opts: {
29
+ isOpen: boolean | undefined;
30
+ }): void;
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=debug-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-gate.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/common/debug-gate.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEvD;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,0HAA0H;IAC1H,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAA2C;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAU;IAElC,sEAAsE;IACtE,MAAM,CAAC,eAAe,IAAI,YAAY;IAItC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;IAKvB,sEAAsE;IACtE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,YAAY,CAAA;KAAE,GAAG,OAAO;IASrD,2HAA2H;IAC3H,MAAM,CAAC,MAAM,IAAI,OAAO;IAUxB,sHAAsH;IACtH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,GAAG,SAAS,CAAA;KAAE,GAAG,IAAI;CAQ1D"}
@@ -0,0 +1,51 @@
1
+ import { EnvironmentNames } from '../../env/names.js';
2
+ /**
3
+ * The rule that decides whether `debug` lines are written: off unless `DEBUG` is truthy and the environment is allowed
4
+ * (`NODE_ENV` unset, or one of the common names, or one `APP_ENV_EXTRA_LOG_ENVS` adds). Every provider shares it, so a
5
+ * console, a winston and a pino logger agree.
6
+ *
7
+ * Pure: it takes the environment as an argument and reads `process` only through a guarded `globalThis` read, because a
8
+ * browser has none and there the default is off. `LoggerFactory.use({ level })` overrides it.
9
+ */
10
+ export class LoggerDebugGate {
11
+ /** The override lives on globalThis, so `use({ level })` in one copy of the module opens or closes debug in the other. */
12
+ static { this.FORCED_SLOT = Symbol.for('ignis:logger-debug-forced'); }
13
+ /** The environment the host has, `{}` where there is no `process`. */
14
+ static readEnvironment() {
15
+ return globalThis.process?.env ?? {};
16
+ }
17
+ /**
18
+ * The truthiness `ParseUtility.toBoolean` has, repeated here on purpose: `ParseUtility` imports the error module, and
19
+ * this file is in the graph of `BaseHelper`, which must stay a few hundred bytes in a browser bundle.
20
+ */
21
+ static isTruthy(opts) {
22
+ const { input } = opts;
23
+ return input !== undefined && input !== '' && input !== 'false' && input !== '0';
24
+ }
25
+ /** The rule itself, for any environment: a pure function of `env`. */
26
+ static evaluate(opts) {
27
+ const { env } = opts;
28
+ const { DEBUG, NODE_ENV, APP_ENV_EXTRA_LOG_ENVS } = env;
29
+ const extra = (APP_ENV_EXTRA_LOG_ENVS ?? '').split(',').map((name) => name.trim());
30
+ const allowed = new Set([...Array.from(EnvironmentNames.COMMON_ENVS), ...extra]);
31
+ return this.isTruthy({ input: DEBUG }) && (!NODE_ENV || allowed.has(NODE_ENV));
32
+ }
33
+ /** Whether `debug` is written now: the override when `use` set one, else the rule on the host's environment, read once. */
34
+ static isOpen() {
35
+ const forced = Reflect.get(globalThis, this.FORCED_SLOT);
36
+ if (forced !== undefined) {
37
+ return forced;
38
+ }
39
+ this.resolved ??= this.evaluate({ env: this.readEnvironment() });
40
+ return this.resolved;
41
+ }
42
+ /** `LoggerFactory.use({ level })` calls it: an explicit level turns debug on or off whatever the environment says. */
43
+ static force(opts) {
44
+ if (opts.isOpen === undefined) {
45
+ Reflect.deleteProperty(globalThis, this.FORCED_SLOT);
46
+ return;
47
+ }
48
+ Reflect.set(globalThis, this.FORCED_SLOT, opts.isOpen);
49
+ }
50
+ }
51
+ //# sourceMappingURL=debug-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-gate.js","sourceRoot":"","sources":["../../../../../src/modules/logger/common/debug-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAC1B,0HAA0H;aAClG,gBAAW,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAG9E,sEAAsE;IAC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AAE,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,sHAAsH;IACtH,MAAM,CAAC,KAAK,CAAC,IAAqC;QAChD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC","sourcesContent":["import { EnvironmentNames } from '@/modules/env/names';\n\ntype TEnvironment = Record<string, string | undefined>;\n\n/**\n * The rule that decides whether `debug` lines are written: off unless `DEBUG` is truthy and the environment is allowed\n * (`NODE_ENV` unset, or one of the common names, or one `APP_ENV_EXTRA_LOG_ENVS` adds). Every provider shares it, so a\n * console, a winston and a pino logger agree.\n *\n * Pure: it takes the environment as an argument and reads `process` only through a guarded `globalThis` read, because a\n * browser has none and there the default is off. `LoggerFactory.use({ level })` overrides it.\n */\nexport class LoggerDebugGate {\n /** The override lives on globalThis, so `use({ level })` in one copy of the module opens or closes debug in the other. */\n private static readonly FORCED_SLOT = Symbol.for('ignis:logger-debug-forced');\n private static resolved?: boolean;\n\n /** The environment the host has, `{}` where there is no `process`. */\n static readEnvironment(): TEnvironment {\n return globalThis.process?.env ?? {};\n }\n\n /**\n * The truthiness `ParseUtility.toBoolean` has, repeated here on purpose: `ParseUtility` imports the error module, and\n * this file is in the graph of `BaseHelper`, which must stay a few hundred bytes in a browser bundle.\n */\n private static isTruthy(opts: { input: string | undefined }): boolean {\n const { input } = opts;\n return input !== undefined && input !== '' && input !== 'false' && input !== '0';\n }\n\n /** The rule itself, for any environment: a pure function of `env`. */\n static evaluate(opts: { env: TEnvironment }): boolean {\n const { env } = opts;\n const { DEBUG, NODE_ENV, APP_ENV_EXTRA_LOG_ENVS } = env;\n const extra = (APP_ENV_EXTRA_LOG_ENVS ?? '').split(',').map((name) => name.trim());\n const allowed = new Set([...Array.from(EnvironmentNames.COMMON_ENVS), ...extra]);\n\n return this.isTruthy({ input: DEBUG }) && (!NODE_ENV || allowed.has(NODE_ENV));\n }\n\n /** Whether `debug` is written now: the override when `use` set one, else the rule on the host's environment, read once. */\n static isOpen(): boolean {\n const forced: boolean | undefined = Reflect.get(globalThis, this.FORCED_SLOT);\n if (forced !== undefined) {\n return forced;\n }\n\n this.resolved ??= this.evaluate({ env: this.readEnvironment() });\n return this.resolved;\n }\n\n /** `LoggerFactory.use({ level })` calls it: an explicit level turns debug on or off whatever the environment says. */\n static force(opts: { isOpen: boolean | undefined }): void {\n if (opts.isOpen === undefined) {\n Reflect.deleteProperty(globalThis, this.FORCED_SLOT);\n return;\n }\n\n Reflect.set(globalThis, this.FORCED_SLOT, opts.isOpen);\n }\n}\n"]}