@venizia/ignis-helpers 0.4.8-9 → 0.4.8

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 (199) hide show
  1. package/README.md +2 -3
  2. package/dist/esm/common/constants/app.d.ts +1 -3
  3. package/dist/esm/common/constants/app.js +1 -11
  4. package/dist/esm/common/constants/app.js.map +1 -1
  5. package/dist/esm/common/constants/http.d.ts +2 -0
  6. package/dist/esm/common/constants/http.js +3 -0
  7. package/dist/esm/common/constants/http.js.map +1 -1
  8. package/dist/esm/common/constants/mime.d.ts +0 -2
  9. package/dist/esm/common/constants/mime.js +0 -4
  10. package/dist/esm/common/constants/mime.js.map +1 -1
  11. package/dist/esm/common/redact.js.map +1 -1
  12. package/dist/esm/common/types/class.d.ts +14 -12
  13. package/dist/esm/common/types/class.js.map +1 -1
  14. package/dist/esm/common/types/const-value.d.ts +3 -3
  15. package/dist/esm/common/types/const-value.js.map +1 -1
  16. package/dist/esm/common/types/field-mapping.d.ts +6 -8
  17. package/dist/esm/common/types/field-mapping.js +0 -10
  18. package/dist/esm/common/types/field-mapping.js.map +1 -1
  19. package/dist/esm/common/types/index.d.ts +1 -0
  20. package/dist/esm/common/types/index.js +1 -0
  21. package/dist/esm/common/types/index.js.map +1 -1
  22. package/dist/esm/common/types/injection.d.ts +1 -1
  23. package/dist/esm/common/types/injection.js.map +1 -1
  24. package/dist/esm/common/types/json.d.ts +14 -0
  25. package/dist/esm/common/types/json.js +2 -0
  26. package/dist/esm/common/types/json.js.map +1 -0
  27. package/dist/esm/common/types/utility.d.ts +0 -4
  28. package/dist/esm/common/types/utility.js.map +1 -1
  29. package/dist/esm/modules/env/app-env.d.ts +17 -8
  30. package/dist/esm/modules/env/app-env.js +18 -15
  31. package/dist/esm/modules/env/app-env.js.map +1 -1
  32. package/dist/esm/modules/env/common/types.d.ts +22 -6
  33. package/dist/esm/modules/env/common/types.js.map +1 -1
  34. package/dist/esm/modules/logger/base/abstract.d.ts +6 -7
  35. package/dist/esm/modules/logger/base/abstract.js.map +1 -1
  36. package/dist/esm/modules/logger/base/base.d.ts +7 -8
  37. package/dist/esm/modules/logger/base/base.js.map +1 -1
  38. package/dist/esm/modules/logger/base/console.d.ts +6 -7
  39. package/dist/esm/modules/logger/base/console.js.map +1 -1
  40. package/dist/esm/modules/logger/common/types.d.ts +7 -7
  41. package/dist/esm/modules/logger/common/types.js.map +1 -1
  42. package/dist/esm/modules/logger/factory.js.map +1 -1
  43. package/dist/esm/modules/logger/hf/flusher.js.map +1 -1
  44. package/dist/esm/modules/logger/hf/logger.d.ts +6 -7
  45. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  46. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  47. package/dist/esm/modules/logger/pino/destination.d.ts +1 -1
  48. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  49. package/dist/esm/modules/logger/pino/logger.d.ts +1 -2
  50. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  51. package/dist/esm/modules/logger/winston/formats.js +2 -2
  52. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  53. package/dist/esm/modules/logger/winston/logger.d.ts +1 -2
  54. package/dist/esm/modules/logger/winston/logger.js.map +1 -1
  55. package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts +1 -1
  56. package/dist/esm/modules/logger/winston/transports/dgram.transport.js +1 -1
  57. package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
  58. package/dist/esm/modules/network/http-request/common/constants.d.ts +0 -2
  59. package/dist/esm/modules/network/http-request/common/constants.js +0 -4
  60. package/dist/esm/modules/network/http-request/common/constants.js.map +1 -1
  61. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts +6 -6
  62. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  63. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts +2 -3
  64. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
  65. package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts +1 -1
  66. package/dist/esm/modules/network/http-request/fetcher/common/types.js.map +1 -1
  67. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts +1 -2
  68. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +5 -6
  69. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  70. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts +4 -4
  71. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +1 -1
  72. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  73. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +3 -5
  74. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +0 -8
  75. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  76. package/dist/esm/modules/network/utilities/query-string.d.ts +2 -2
  77. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  78. package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts +0 -2
  79. package/dist/esm/modules/network/utilities/url-safety/common/constants.js +0 -4
  80. package/dist/esm/modules/network/utilities/url-safety/common/constants.js.map +1 -1
  81. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  82. package/dist/esm/modules/queue/bullmq/helper.d.ts +23 -10
  83. package/dist/esm/modules/queue/bullmq/helper.js +57 -10
  84. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  85. package/dist/esm/modules/queue/common/constants.d.ts +6 -2
  86. package/dist/esm/modules/queue/common/constants.js +6 -4
  87. package/dist/esm/modules/queue/common/constants.js.map +1 -1
  88. package/dist/esm/modules/queue/internal/sequential/common/types.d.ts +2 -4
  89. package/dist/esm/modules/queue/internal/sequential/common/types.js +0 -4
  90. package/dist/esm/modules/queue/internal/sequential/common/types.js.map +1 -1
  91. package/dist/esm/modules/queue/kafka/base.d.ts +1 -1
  92. package/dist/esm/modules/queue/kafka/base.js +13 -2
  93. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  94. package/dist/esm/modules/queue/kafka/common/constants.d.ts +0 -4
  95. package/dist/esm/modules/queue/kafka/common/constants.js +0 -8
  96. package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
  97. package/dist/esm/modules/redis/base/abstract.helper.d.ts +13 -2
  98. package/dist/esm/modules/redis/base/abstract.helper.js +53 -45
  99. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  100. package/dist/esm/modules/redis/cluster/cluster.helper.d.ts +1 -2
  101. package/dist/esm/modules/redis/cluster/cluster.helper.js +21 -9
  102. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  103. package/dist/esm/modules/redis/cluster/index.d.ts +1 -0
  104. package/dist/esm/modules/redis/cluster/index.js +1 -0
  105. package/dist/esm/modules/redis/cluster/index.js.map +1 -1
  106. package/dist/esm/modules/redis/cluster/types.d.ts +20 -0
  107. package/dist/esm/modules/redis/cluster/types.js +2 -0
  108. package/dist/esm/modules/redis/cluster/types.js.map +1 -0
  109. package/dist/esm/modules/redis/common/constants.d.ts +15 -19
  110. package/dist/esm/modules/redis/common/constants.js +16 -18
  111. package/dist/esm/modules/redis/common/constants.js.map +1 -1
  112. package/dist/esm/modules/redis/common/types.d.ts +10 -60
  113. package/dist/esm/modules/redis/common/types.js.map +1 -1
  114. package/dist/esm/modules/redis/factory.d.ts +7 -25
  115. package/dist/esm/modules/redis/factory.js +9 -18
  116. package/dist/esm/modules/redis/factory.js.map +1 -1
  117. package/dist/esm/modules/redis/sentinel/constants.d.ts +14 -0
  118. package/dist/esm/modules/redis/sentinel/constants.js +11 -0
  119. package/dist/esm/modules/redis/sentinel/constants.js.map +1 -0
  120. package/dist/esm/modules/redis/sentinel/index.d.ts +2 -0
  121. package/dist/esm/modules/redis/sentinel/index.js +2 -0
  122. package/dist/esm/modules/redis/sentinel/index.js.map +1 -1
  123. package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts +1 -2
  124. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +25 -15
  125. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  126. package/dist/esm/modules/redis/sentinel/types.d.ts +26 -0
  127. package/dist/esm/modules/redis/sentinel/types.js +2 -0
  128. package/dist/esm/modules/redis/sentinel/types.js.map +1 -0
  129. package/dist/esm/modules/redis/single/index.d.ts +1 -0
  130. package/dist/esm/modules/redis/single/index.js +1 -0
  131. package/dist/esm/modules/redis/single/index.js.map +1 -1
  132. package/dist/esm/modules/redis/single/single.helper.d.ts +1 -2
  133. package/dist/esm/modules/redis/single/single.helper.js +5 -6
  134. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  135. package/dist/esm/modules/redis/single/types.d.ts +15 -0
  136. package/dist/esm/modules/redis/single/types.js +2 -0
  137. package/dist/esm/modules/redis/single/types.js.map +1 -0
  138. package/dist/esm/modules/secrets/base/abstract.helper.js +6 -1
  139. package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
  140. package/dist/esm/modules/secrets/common/types/registration.d.ts +25 -6
  141. package/dist/esm/modules/secrets/common/types/registration.js.map +1 -1
  142. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js +1 -1
  143. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
  144. package/dist/esm/modules/secrets/factory.js +7 -6
  145. package/dist/esm/modules/secrets/factory.js.map +1 -1
  146. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts +12 -10
  147. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +50 -25
  148. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  149. package/dist/esm/modules/socket/socket-io/client/browser-helper.js.map +1 -1
  150. package/dist/esm/modules/socket/socket-io/common/types/client.d.ts +2 -2
  151. package/dist/esm/modules/socket/socket-io/common/types/client.js.map +1 -1
  152. package/dist/esm/modules/socket/socket-io/common/types/server.d.ts +3 -1
  153. package/dist/esm/modules/socket/socket-io/common/types/server.js.map +1 -1
  154. package/dist/esm/modules/socket/socket-io/server/helper.d.ts +2 -2
  155. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  156. package/dist/esm/modules/storage/base.d.ts +24 -60
  157. package/dist/esm/modules/storage/base.js +66 -123
  158. package/dist/esm/modules/storage/base.js.map +1 -1
  159. package/dist/esm/modules/storage/bun-s3/helper.d.ts +21 -35
  160. package/dist/esm/modules/storage/bun-s3/helper.js +126 -128
  161. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  162. package/dist/esm/modules/storage/bun-s3/utility.d.ts +13 -7
  163. package/dist/esm/modules/storage/bun-s3/utility.js +63 -45
  164. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  165. package/dist/esm/modules/storage/common/constants.d.ts +29 -2
  166. package/dist/esm/modules/storage/common/constants.js +29 -4
  167. package/dist/esm/modules/storage/common/constants.js.map +1 -1
  168. package/dist/esm/modules/storage/common/errors.d.ts +9 -0
  169. package/dist/esm/modules/storage/common/errors.js +9 -0
  170. package/dist/esm/modules/storage/common/errors.js.map +1 -1
  171. package/dist/esm/modules/storage/common/types.d.ts +90 -61
  172. package/dist/esm/modules/storage/common/types.js.map +1 -1
  173. package/dist/esm/modules/storage/common/utility.d.ts +8 -0
  174. package/dist/esm/modules/storage/common/utility.js +14 -2
  175. package/dist/esm/modules/storage/common/utility.js.map +1 -1
  176. package/dist/esm/modules/storage/disk/helper.d.ts +3 -8
  177. package/dist/esm/modules/storage/disk/helper.js +1 -0
  178. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  179. package/dist/esm/modules/storage/in-memory/helper.d.ts +2 -3
  180. package/dist/esm/modules/storage/in-memory/helper.js.map +1 -1
  181. package/dist/esm/modules/worker-thread/common/types.d.ts +2 -2
  182. package/dist/esm/modules/worker-thread/common/types.js.map +1 -1
  183. package/dist/esm/modules/worker-thread/thread/abstract.d.ts +2 -2
  184. package/dist/esm/modules/worker-thread/thread/abstract.js.map +1 -1
  185. package/dist/esm/modules/worker-thread/worker-pool.d.ts +1 -1
  186. package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
  187. package/dist/esm/utilities/module.utility.d.ts +8 -5
  188. package/dist/esm/utilities/module.utility.js +5 -1
  189. package/dist/esm/utilities/module.utility.js.map +1 -1
  190. package/dist/esm/utilities/parse.utility.d.ts +34 -6
  191. package/dist/esm/utilities/parse.utility.js +82 -15
  192. package/dist/esm/utilities/parse.utility.js.map +1 -1
  193. package/dist/esm/utilities/performance.utility.d.ts +3 -3
  194. package/dist/esm/utilities/performance.utility.js.map +1 -1
  195. package/dist/esm/utilities/promise.utility.d.ts +1 -1
  196. package/dist/esm/utilities/promise.utility.js.map +1 -1
  197. package/dist/esm/utilities/request.utility.d.ts +9 -11
  198. package/dist/esm/utilities/request.utility.js.map +1 -1
  199. package/package.json +3 -3
package/README.md CHANGED
@@ -16,15 +16,14 @@ Choose a logger provider once at the entrypoint, then take scoped loggers and he
16
16
 
17
17
  ```typescript
18
18
  // bun add pino ioredis
19
- import { LoggerFactory, RedisHelperFactory, RedisModes } from '@venizia/ignis-helpers';
19
+ import { LoggerFactory, RedisHelperFactory } from '@venizia/ignis-helpers';
20
20
  import { PinoLogger } from '@venizia/ignis-helpers/pino';
21
21
 
22
22
  LoggerFactory.use({ provider: PinoLogger });
23
23
 
24
24
  const logger = LoggerFactory.getLogger(['CacheService']);
25
25
 
26
- const redis = RedisHelperFactory.create({
27
- mode: RedisModes.SINGLE,
26
+ const redis = RedisHelperFactory.single({
28
27
  name: 'cache',
29
28
  host: '127.0.0.1',
30
29
  port: 6379,
@@ -25,14 +25,12 @@ export declare class RuntimeModules {
25
25
  }
26
26
  /** The runtime names `RuntimeModules` holds; only `bun` today. */
27
27
  export type TRuntimeModule = TConstValue<typeof RuntimeModules>;
28
- /** The value kinds a stored field can hold; `isValid` tests a string against them. */
28
+ /** The value kinds a stored field can hold. */
29
29
  export declare class DataTypes {
30
30
  static readonly NUMBER = "NUMBER";
31
31
  static readonly TEXT = "TEXT";
32
32
  static readonly BYTE = "BYTE";
33
33
  static readonly JSON = "JSON";
34
34
  static readonly BOOLEAN = "BOOLEAN";
35
- static readonly SCHEME_SET: Set<string>;
36
- static isValid(orgType: string): boolean;
37
35
  }
38
36
  //# sourceMappingURL=app.d.ts.map
@@ -26,22 +26,12 @@ export class RuntimeModules {
26
26
  return RuntimeModules.detect() === RuntimeModules.BUN;
27
27
  }
28
28
  }
29
- /** The value kinds a stored field can hold; `isValid` tests a string against them. */
29
+ /** The value kinds a stored field can hold. */
30
30
  export class DataTypes {
31
31
  static { this.NUMBER = 'NUMBER'; }
32
32
  static { this.TEXT = 'TEXT'; }
33
33
  static { this.BYTE = 'BYTE'; }
34
34
  static { this.JSON = 'JSON'; }
35
35
  static { this.BOOLEAN = 'BOOLEAN'; }
36
- static { this.SCHEME_SET = new Set([
37
- this.NUMBER,
38
- this.TEXT,
39
- this.BYTE,
40
- this.JSON,
41
- this.BOOLEAN,
42
- ]); }
43
- static isValid(orgType) {
44
- return this.SCHEME_SET.has(orgType);
45
- }
46
36
  }
47
37
  //# sourceMappingURL=app.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../../src/common/constants/app.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,MAAM,OAAO,QAAQ;IACnB;;;OAGG;aACa,qBAAgB,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,wBAAwB,IAAI,KAAK,CAAC;IAE9F;;;OAGG;aACa,gBAAW,GAAG,EAAE,CAAC;IACjC;;;OAGG;aACa,iBAAY,GAAG,CAAC,CAAC;;AAGnC,2HAA2H;AAC3H,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,KAAK,CAAC;IAE5B,MAAM,CAAC,MAAM;QACX,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,KAAK;QACV,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC;IACxD,CAAC;;AAKH,sFAAsF;AACtF,MAAM,OAAO,SAAS;aACJ,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** Application-wide defaults: the application name and the paging values of a list query. */\nexport class Defaults {\n /**\n * The application name; reads `APP_ENV_APPLICATION_NAME`.\n * @default 'APP'\n */\n static readonly APPLICATION_NAME = globalThis.process?.env?.APP_ENV_APPLICATION_NAME ?? 'APP';\n\n /**\n * Rows a list query returns.\n * @default 50\n */\n static readonly QUERY_LIMIT = 50;\n /**\n * Rows a list query skips.\n * @default 0\n */\n static readonly QUERY_OFFSET = 0;\n}\n\n/** IGNIS runs on Bun only: `detect()` answers `'bun'` there and `undefined` anywhere else (a browser, another runtime). */\nexport class RuntimeModules {\n static readonly BUN = 'bun';\n\n static detect(): TRuntimeModule | undefined {\n return typeof Bun !== 'undefined' ? RuntimeModules.BUN : undefined;\n }\n\n static isBun(): boolean {\n return RuntimeModules.detect() === RuntimeModules.BUN;\n }\n}\n/** The runtime names `RuntimeModules` holds; only `bun` today. */\nexport type TRuntimeModule = TConstValue<typeof RuntimeModules>;\n\n/** The value kinds a stored field can hold; `isValid` tests a string against them. */\nexport class DataTypes {\n static readonly NUMBER = 'NUMBER';\n static readonly TEXT = 'TEXT';\n static readonly BYTE = 'BYTE';\n static readonly JSON = 'JSON';\n static readonly BOOLEAN = 'BOOLEAN';\n\n static readonly SCHEME_SET = new Set([\n this.NUMBER,\n this.TEXT,\n this.BYTE,\n this.JSON,\n this.BOOLEAN,\n ]);\n\n static isValid(orgType: string): boolean {\n return this.SCHEME_SET.has(orgType);\n }\n}\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../../src/common/constants/app.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,MAAM,OAAO,QAAQ;IACnB;;;OAGG;aACa,qBAAgB,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,wBAAwB,IAAI,KAAK,CAAC;IAE9F;;;OAGG;aACa,gBAAW,GAAG,EAAE,CAAC;IACjC;;;OAGG;aACa,iBAAY,GAAG,CAAC,CAAC;;AAGnC,2HAA2H;AAC3H,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,KAAK,CAAC;IAE5B,MAAM,CAAC,MAAM;QACX,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,KAAK;QACV,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC;IACxD,CAAC;;AAKH,+CAA+C;AAC/C,MAAM,OAAO,SAAS;aACJ,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,YAAO,GAAG,SAAS,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** Application-wide defaults: the application name and the paging values of a list query. */\nexport class Defaults {\n /**\n * The application name; reads `APP_ENV_APPLICATION_NAME`.\n * @default 'APP'\n */\n static readonly APPLICATION_NAME = globalThis.process?.env?.APP_ENV_APPLICATION_NAME ?? 'APP';\n\n /**\n * Rows a list query returns.\n * @default 50\n */\n static readonly QUERY_LIMIT = 50;\n /**\n * Rows a list query skips.\n * @default 0\n */\n static readonly QUERY_OFFSET = 0;\n}\n\n/** IGNIS runs on Bun only: `detect()` answers `'bun'` there and `undefined` anywhere else (a browser, another runtime). */\nexport class RuntimeModules {\n static readonly BUN = 'bun';\n\n static detect(): TRuntimeModule | undefined {\n return typeof Bun !== 'undefined' ? RuntimeModules.BUN : undefined;\n }\n\n static isBun(): boolean {\n return RuntimeModules.detect() === RuntimeModules.BUN;\n }\n}\n/** The runtime names `RuntimeModules` holds; only `bun` today. */\nexport type TRuntimeModule = TConstValue<typeof RuntimeModules>;\n\n/** The value kinds a stored field can hold. */\nexport class DataTypes {\n static readonly NUMBER = 'NUMBER';\n static readonly TEXT = 'TEXT';\n static readonly BYTE = 'BYTE';\n static readonly JSON = 'JSON';\n static readonly BOOLEAN = 'BOOLEAN';\n}\n"]}
@@ -17,6 +17,7 @@ export declare class HTTP {
17
17
  readonly AUTHORIZATION: "authorization";
18
18
  readonly COOKIE: "cookie";
19
19
  readonly HOST: "host";
20
+ readonly IF_MATCH: "if-match";
20
21
  readonly IF_MODIFIED_SINCE: "if-modified-since";
21
22
  readonly IF_NONE_MATCH: "if-none-match";
22
23
  readonly ORIGIN: "origin";
@@ -96,6 +97,7 @@ export declare class HTTP {
96
97
  readonly IMAGE_PNG: "image/png";
97
98
  readonly IMAGE_SVG: "image/svg+xml";
98
99
  readonly IMAGE_WEBP: "image/webp";
100
+ readonly RANGE_UNIT_BYTES: "bytes";
99
101
  };
100
102
  /** Standard HTTP methods (lowercase). */
101
103
  static readonly Methods: {
@@ -18,6 +18,7 @@ export class HTTP {
18
18
  AUTHORIZATION: 'authorization',
19
19
  COOKIE: 'cookie',
20
20
  HOST: 'host',
21
+ IF_MATCH: 'if-match',
21
22
  IF_MODIFIED_SINCE: 'if-modified-since',
22
23
  IF_NONE_MATCH: 'if-none-match',
23
24
  ORIGIN: 'origin',
@@ -120,6 +121,8 @@ export class HTTP {
120
121
  IMAGE_PNG: 'image/png',
121
122
  IMAGE_SVG: 'image/svg+xml',
122
123
  IMAGE_WEBP: 'image/webp',
124
+ // Range units
125
+ RANGE_UNIT_BYTES: 'bytes',
123
126
  }; }
124
127
  /** Standard HTTP methods (lowercase). */
125
128
  static { this.Methods = {
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/common/constants/http.ts"],"names":[],"mappings":"AAEA,yJAAyJ;AACzJ,MAAM,OAAO,IAAI;IACf,0EAA0E;aAC1D,YAAO,GAAG;QACxB,UAAU;QACV,mBAAmB,EAAE,qBAAqB;QAC1C,gBAAgB,EAAE,kBAAkB;QACpC,cAAc,EAAE,gBAAgB;QAChC,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,eAAe;QAC9B,uBAAuB,EAAE,yBAAyB;QAClD,aAAa,EAAE,eAAe;QAC9B,KAAK,EAAE,OAAO;QAEd,+CAA+C;QAC/C,MAAM,EAAE,QAAQ;QAChB,eAAe,EAAE,iBAAiB;QAClC,eAAe,EAAE,iBAAiB;QAClC,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,iBAAiB,EAAE,mBAAmB;QACtC,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,SAAS;QAClB,UAAU,EAAE,YAAY;QAExB,kDAAkD;QAClD,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,eAAe;QAC9B,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,aAAa;QAC1B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;QACZ,gBAAgB,EAAE,kBAAkB;QAEpC,+BAA+B;QAC/B,gCAAgC,EAAE,kCAAkC;QACpE,4BAA4B,EAAE,8BAA8B;QAC5D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YACnB,WAAW,EAAE,GAAG;SACjB;QAED,yBAAyB;QACzB,IAAI,EAAE;YACJ,gBAAgB,EAAE,GAAG;YACrB,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,GAAG;YAChB,iBAAiB,EAAE,GAAG;YACtB,iBAAiB,EAAE,GAAG;SACvB;QAED,0BAA0B;QAC1B,IAAI,EAAE;YACJ,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,GAAG;YACjB,eAAe,EAAE,GAAG;YACpB,SAAS,EAAE,GAAG;YACd,QAAQ,EAAE,GAAG;YACb,gBAAgB,EAAE,GAAG;YACrB,aAAa,EAAE,GAAG;YAClB,cAAc,EAAE,GAAG;YACnB,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,GAAG;YACT,cAAc,EAAE,GAAG;YACnB,kBAAkB,EAAE,GAAG;YACvB,eAAe,EAAE,GAAG;YACpB,UAAU,EAAE,GAAG;YACf,oBAAoB,EAAE,GAAG;YACzB,mBAAmB,EAAE,GAAG;YACxB,iBAAiB,EAAE,GAAG;YACtB,mBAAmB,EAAE,GAAG;YACxB,MAAM,EAAE,GAAG;YACX,gBAAgB,EAAE,GAAG;YACrB,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,GAAG;YACpB,oBAAoB,EAAE,GAAG;YACzB,eAAe,EAAE,GAAG;YACpB,2BAA2B,EAAE,GAAG;YAChC,0BAA0B,EAAE,GAAG;SAChC;QAED,0BAA0B;QAC1B,IAAI,EAAE;YACJ,mBAAmB,EAAE,GAAG;YACxB,cAAc,EAAE,GAAG;YACnB,UAAU,EAAE,GAAG;YACf,kBAAkB,EAAE,GAAG;YACvB,cAAc,EAAE,GAAG;YACnB,uBAAuB,EAAE,GAAG;YAC5B,mBAAmB,EAAE,GAAG;YACxB,YAAY,EAAE,GAAG;YACjB,6BAA6B,EAAE,GAAG;SACnC;KACO,CAAC","sourcesContent":["import { type ValueOf } from '../types';\n\n/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */\nexport class HTTP {\n /** Standard and common HTTP headers (lowercase per HTTP/2 convention). */\n static readonly Headers = {\n // Content\n CONTENT_DISPOSITION: 'content-disposition',\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_LENGTH: 'content-length',\n CONTENT_TYPE: 'content-type',\n CONTENT_RANGE: 'content-range',\n CONTENT_SECURITY_POLICY: 'content-security-policy',\n ACCEPT_RANGES: 'accept-ranges',\n RANGE: 'range',\n\n // Request - content negotiation & conditionals\n ACCEPT: 'accept',\n ACCEPT_ENCODING: 'accept-encoding',\n ACCEPT_LANGUAGE: 'accept-language',\n AUTHORIZATION: 'authorization',\n COOKIE: 'cookie',\n HOST: 'host',\n IF_MODIFIED_SINCE: 'if-modified-since',\n IF_NONE_MATCH: 'if-none-match',\n ORIGIN: 'origin',\n REFERER: 'referer',\n USER_AGENT: 'user-agent',\n\n // Response - caching, auth challenges & redirects\n ALLOW: 'allow',\n CACHE_CONTROL: 'cache-control',\n ETAG: 'etag',\n LAST_MODIFIED: 'last-modified',\n LOCATION: 'location',\n RETRY_AFTER: 'retry-after',\n SET_COOKIE: 'set-cookie',\n VARY: 'vary',\n WWW_AUTHENTICATE: 'www-authenticate',\n\n // CORS (RFC 6454 / Fetch spec)\n ACCESS_CONTROL_ALLOW_CREDENTIALS: 'access-control-allow-credentials',\n ACCESS_CONTROL_ALLOW_HEADERS: 'access-control-allow-headers',\n ACCESS_CONTROL_ALLOW_METHODS: 'access-control-allow-methods',\n ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',\n ACCESS_CONTROL_EXPOSE_HEADERS: 'access-control-expose-headers',\n ACCESS_CONTROL_MAX_AGE: 'access-control-max-age',\n ACCESS_CONTROL_REQUEST_HEADERS: 'access-control-request-headers',\n ACCESS_CONTROL_REQUEST_METHOD: 'access-control-request-method',\n\n // Transport\n CONNECTION: 'connection',\n TRANSFER_ENCODING: 'transfer-encoding',\n UPGRADE: 'upgrade',\n\n // Security\n STRICT_TRANSPORT_SECURITY: 'strict-transport-security',\n X_CONTENT_TYPE_OPTIONS: 'x-content-type-options',\n X_FRAME_OPTIONS: 'x-frame-options',\n\n // Proxy / forwarding (de facto standard)\n FORWARDED: 'forwarded',\n X_FORWARDED_FOR: 'x-forwarded-for',\n X_FORWARDED_HOST: 'x-forwarded-host',\n X_FORWARDED_PROTO: 'x-forwarded-proto',\n\n // Rate limiting (de facto standard)\n X_RATELIMIT_LIMIT: 'x-ratelimit-limit',\n X_RATELIMIT_REMAINING: 'x-ratelimit-remaining',\n X_RATELIMIT_RESET: 'x-ratelimit-reset',\n\n // IGNIS custom\n REQUEST_TRACING_ID: 'x-request-id',\n REQUEST_DEVICE_INFO: 'x-device-info',\n REQUEST_CHANNEL: 'x-request-channel',\n REQUEST_COUNT_DATA: 'x-request-count',\n REQUEST_EXTRA: 'x-request-extra',\n RESPONSE_COUNT_DATA: 'x-response-count',\n RESPONSE_FORMAT: 'x-response-format',\n RESPONSE_EXTRA: 'x-response-extra',\n } as const;\n\n /**\n * The headers IGNIS adds to a request and to a response, for a CORS configuration that lists them\n * by hand: spread `ALLOW` into the allowed request headers and `EXPOSE` into the exposed ones, so\n * a header IGNIS adds later needs no change there.\n */\n static readonly CorsHeaders = {\n ALLOW: [\n 'x-request-id',\n 'x-request-count',\n 'x-request-extra',\n 'x-request-channel',\n 'x-device-info',\n ],\n EXPOSE: [\n 'content-range',\n 'x-request-id',\n 'x-response-count',\n 'x-response-format',\n 'x-response-extra',\n ],\n } as const;\n\n /** Common MIME / Content-Type values. */\n static readonly HeaderValues = {\n // Application\n APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n APPLICATION_GRAPHQL_JSON: 'application/graphql+json',\n APPLICATION_GZIP: 'application/gzip',\n APPLICATION_JAVASCRIPT: 'application/javascript',\n APPLICATION_JSON: 'application/json',\n APPLICATION_MSGPACK: 'application/msgpack',\n APPLICATION_NDJSON: 'application/x-ndjson',\n APPLICATION_OCTET_STREAM: 'application/octet-stream',\n APPLICATION_PDF: 'application/pdf',\n APPLICATION_PROTOBUF: 'application/x-protobuf',\n APPLICATION_XML: 'application/xml',\n APPLICATION_ZIP: 'application/zip',\n\n // Multipart\n MULTIPART_FORM_DATA: 'multipart/form-data',\n\n // Text\n TEXT_CSS: 'text/css',\n TEXT_CSV: 'text/csv',\n TEXT_EVENT_STREAM: 'text/event-stream',\n TEXT_HTML: 'text/html',\n TEXT_PLAIN: 'text/plain',\n TEXT_XML: 'text/xml',\n\n // Image\n IMAGE_GIF: 'image/gif',\n IMAGE_JPEG: 'image/jpeg',\n IMAGE_PNG: 'image/png',\n IMAGE_SVG: 'image/svg+xml',\n IMAGE_WEBP: 'image/webp',\n } as const;\n\n /** Standard HTTP methods (lowercase). */\n static readonly Methods = {\n GET: 'get',\n POST: 'post',\n PUT: 'put',\n PATCH: 'patch',\n DELETE: 'delete',\n HEAD: 'head',\n OPTIONS: 'options',\n QUERY: 'query',\n } as const;\n\n /** Standard HTTP protocols (lowercase). */\n static readonly Protocols = {\n HTTP: 'http',\n HTTPS: 'https',\n } as const;\n\n /** HTTP status codes grouped by class (1xx - 5xx). */\n static readonly ResultCodes = {\n /** 1xx - Informational. */\n RS_1: {\n Continue: 100,\n SwitchingProtocols: 101,\n EarlyHints: 103,\n },\n\n /** 2xx - Success. */\n RS_2: {\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n },\n\n /** 3xx - Redirection. */\n RS_3: {\n MovedPermanently: 301,\n Found: 302,\n NotModified: 304,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n },\n\n /** 4xx - Client error. */\n RS_4: {\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n ContentTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n },\n\n /** 5xx - Server error. */\n RS_5: {\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NetworkAuthenticationRequired: 511,\n },\n } as const;\n}\n\n/** An HTTP method from `HTTP.Methods`, in lowercase or uppercase. */\nexport type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;\n/** An HTTP protocol from `HTTP.Protocols`, in lowercase or uppercase. */\nexport type THttpProtocol =\n | ValueOf<typeof HTTP.Protocols>\n | Uppercase<ValueOf<typeof HTTP.Protocols>>;\n/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */\nexport type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/common/constants/http.ts"],"names":[],"mappings":"AAEA,yJAAyJ;AACzJ,MAAM,OAAO,IAAI;IACf,0EAA0E;aAC1D,YAAO,GAAG;QACxB,UAAU;QACV,mBAAmB,EAAE,qBAAqB;QAC1C,gBAAgB,EAAE,kBAAkB;QACpC,cAAc,EAAE,gBAAgB;QAChC,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,eAAe;QAC9B,uBAAuB,EAAE,yBAAyB;QAClD,aAAa,EAAE,eAAe;QAC9B,KAAK,EAAE,OAAO;QAEd,+CAA+C;QAC/C,MAAM,EAAE,QAAQ;QAChB,eAAe,EAAE,iBAAiB;QAClC,eAAe,EAAE,iBAAiB;QAClC,a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B,EAAE,GAAG;YACxB,MAAM,EAAE,GAAG;YACX,gBAAgB,EAAE,GAAG;YACrB,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,GAAG;YACpB,oBAAoB,EAAE,GAAG;YACzB,eAAe,EAAE,GAAG;YACpB,2BAA2B,EAAE,GAAG;YAChC,0BAA0B,EAAE,GAAG;SAChC;QAED,0BAA0B;QAC1B,IAAI,EAAE;YACJ,mBAAmB,EAAE,GAAG;YACxB,cAAc,EAAE,GAAG;YACnB,UAAU,EAAE,GAAG;YACf,kBAAkB,EAAE,GAAG;YACvB,cAAc,EAAE,GAAG;YACnB,uBAAuB,EAAE,GAAG;YAC5B,mBAAmB,EAAE,GAAG;YACxB,YAAY,EAAE,GAAG;YACjB,6BAA6B,EAAE,GAAG;SACnC;KACO,CAAC","sourcesContent":["import { type ValueOf } from '../types';\n\n/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */\nexport class HTTP {\n /** Standard and common HTTP headers (lowercase per HTTP/2 convention). */\n static readonly Headers = {\n // Content\n CONTENT_DISPOSITION: 'content-disposition',\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_LENGTH: 'content-length',\n CONTENT_TYPE: 'content-type',\n CONTENT_RANGE: 'content-range',\n CONTENT_SECURITY_POLICY: 'content-security-policy',\n ACCEPT_RANGES: 'accept-ranges',\n RANGE: 'range',\n\n // Request - content negotiation & conditionals\n ACCEPT: 'accept',\n ACCEPT_ENCODING: 'accept-encoding',\n ACCEPT_LANGUAGE: 'accept-language',\n AUTHORIZATION: 'authorization',\n COOKIE: 'cookie',\n HOST: 'host',\n IF_MATCH: 'if-match',\n IF_MODIFIED_SINCE: 'if-modified-since',\n IF_NONE_MATCH: 'if-none-match',\n ORIGIN: 'origin',\n REFERER: 'referer',\n USER_AGENT: 'user-agent',\n\n // Response - caching, auth challenges & redirects\n ALLOW: 'allow',\n CACHE_CONTROL: 'cache-control',\n ETAG: 'etag',\n LAST_MODIFIED: 'last-modified',\n LOCATION: 'location',\n RETRY_AFTER: 'retry-after',\n SET_COOKIE: 'set-cookie',\n VARY: 'vary',\n WWW_AUTHENTICATE: 'www-authenticate',\n\n // CORS (RFC 6454 / Fetch spec)\n ACCESS_CONTROL_ALLOW_CREDENTIALS: 'access-control-allow-credentials',\n ACCESS_CONTROL_ALLOW_HEADERS: 'access-control-allow-headers',\n ACCESS_CONTROL_ALLOW_METHODS: 'access-control-allow-methods',\n ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',\n ACCESS_CONTROL_EXPOSE_HEADERS: 'access-control-expose-headers',\n ACCESS_CONTROL_MAX_AGE: 'access-control-max-age',\n ACCESS_CONTROL_REQUEST_HEADERS: 'access-control-request-headers',\n ACCESS_CONTROL_REQUEST_METHOD: 'access-control-request-method',\n\n // Transport\n CONNECTION: 'connection',\n TRANSFER_ENCODING: 'transfer-encoding',\n UPGRADE: 'upgrade',\n\n // Security\n STRICT_TRANSPORT_SECURITY: 'strict-transport-security',\n X_CONTENT_TYPE_OPTIONS: 'x-content-type-options',\n X_FRAME_OPTIONS: 'x-frame-options',\n\n // Proxy / forwarding (de facto standard)\n FORWARDED: 'forwarded',\n X_FORWARDED_FOR: 'x-forwarded-for',\n X_FORWARDED_HOST: 'x-forwarded-host',\n X_FORWARDED_PROTO: 'x-forwarded-proto',\n\n // Rate limiting (de facto standard)\n X_RATELIMIT_LIMIT: 'x-ratelimit-limit',\n X_RATELIMIT_REMAINING: 'x-ratelimit-remaining',\n X_RATELIMIT_RESET: 'x-ratelimit-reset',\n\n // IGNIS custom\n REQUEST_TRACING_ID: 'x-request-id',\n REQUEST_DEVICE_INFO: 'x-device-info',\n REQUEST_CHANNEL: 'x-request-channel',\n REQUEST_COUNT_DATA: 'x-request-count',\n REQUEST_EXTRA: 'x-request-extra',\n RESPONSE_COUNT_DATA: 'x-response-count',\n RESPONSE_FORMAT: 'x-response-format',\n RESPONSE_EXTRA: 'x-response-extra',\n } as const;\n\n /**\n * The headers IGNIS adds to a request and to a response, for a CORS configuration that lists them\n * by hand: spread `ALLOW` into the allowed request headers and `EXPOSE` into the exposed ones, so\n * a header IGNIS adds later needs no change there.\n */\n static readonly CorsHeaders = {\n ALLOW: [\n 'x-request-id',\n 'x-request-count',\n 'x-request-extra',\n 'x-request-channel',\n 'x-device-info',\n ],\n EXPOSE: [\n 'content-range',\n 'x-request-id',\n 'x-response-count',\n 'x-response-format',\n 'x-response-extra',\n ],\n } as const;\n\n /** Common MIME / Content-Type values. */\n static readonly HeaderValues = {\n // Application\n APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n APPLICATION_GRAPHQL_JSON: 'application/graphql+json',\n APPLICATION_GZIP: 'application/gzip',\n APPLICATION_JAVASCRIPT: 'application/javascript',\n APPLICATION_JSON: 'application/json',\n APPLICATION_MSGPACK: 'application/msgpack',\n APPLICATION_NDJSON: 'application/x-ndjson',\n APPLICATION_OCTET_STREAM: 'application/octet-stream',\n APPLICATION_PDF: 'application/pdf',\n APPLICATION_PROTOBUF: 'application/x-protobuf',\n APPLICATION_XML: 'application/xml',\n APPLICATION_ZIP: 'application/zip',\n\n // Multipart\n MULTIPART_FORM_DATA: 'multipart/form-data',\n\n // Text\n TEXT_CSS: 'text/css',\n TEXT_CSV: 'text/csv',\n TEXT_EVENT_STREAM: 'text/event-stream',\n TEXT_HTML: 'text/html',\n TEXT_PLAIN: 'text/plain',\n TEXT_XML: 'text/xml',\n\n // Image\n IMAGE_GIF: 'image/gif',\n IMAGE_JPEG: 'image/jpeg',\n IMAGE_PNG: 'image/png',\n IMAGE_SVG: 'image/svg+xml',\n IMAGE_WEBP: 'image/webp',\n\n // Range units\n RANGE_UNIT_BYTES: 'bytes',\n } as const;\n\n /** Standard HTTP methods (lowercase). */\n static readonly Methods = {\n GET: 'get',\n POST: 'post',\n PUT: 'put',\n PATCH: 'patch',\n DELETE: 'delete',\n HEAD: 'head',\n OPTIONS: 'options',\n QUERY: 'query',\n } as const;\n\n /** Standard HTTP protocols (lowercase). */\n static readonly Protocols = {\n HTTP: 'http',\n HTTPS: 'https',\n } as const;\n\n /** HTTP status codes grouped by class (1xx - 5xx). */\n static readonly ResultCodes = {\n /** 1xx - Informational. */\n RS_1: {\n Continue: 100,\n SwitchingProtocols: 101,\n EarlyHints: 103,\n },\n\n /** 2xx - Success. */\n RS_2: {\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n },\n\n /** 3xx - Redirection. */\n RS_3: {\n MovedPermanently: 301,\n Found: 302,\n NotModified: 304,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n },\n\n /** 4xx - Client error. */\n RS_4: {\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n ContentTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n },\n\n /** 5xx - Server error. */\n RS_5: {\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NetworkAuthenticationRequired: 511,\n },\n } as const;\n}\n\n/** An HTTP method from `HTTP.Methods`, in lowercase or uppercase. */\nexport type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;\n/** An HTTP protocol from `HTTP.Protocols`, in lowercase or uppercase. */\nexport type THttpProtocol =\n | ValueOf<typeof HTTP.Protocols>\n | Uppercase<ValueOf<typeof HTTP.Protocols>>;\n/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */\nexport type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;\n"]}
@@ -5,8 +5,6 @@ export declare class MimeTypes {
5
5
  static readonly IMAGE = "image";
6
6
  static readonly VIDEO = "video";
7
7
  static readonly TEXT = "text";
8
- static readonly SCHEME_SET: Set<string>;
9
- static isValid(value: string): boolean;
10
8
  }
11
9
  /** One of the `MimeTypes` values. */
12
10
  export type TMimeTypes = TConstValue<typeof MimeTypes>;
@@ -4,10 +4,6 @@ export class MimeTypes {
4
4
  static { this.IMAGE = 'image'; }
5
5
  static { this.VIDEO = 'video'; }
6
6
  static { this.TEXT = 'text'; }
7
- static { this.SCHEME_SET = new Set([this.UNKNOWN, this.IMAGE, this.VIDEO, this.TEXT]); }
8
- static isValid(value) {
9
- return this.SCHEME_SET.has(value);
10
- }
11
7
  }
12
8
  /** The leading dot is part of the value: `path.extname` returns one. */
13
9
  export class FileExtensions {
@@ -1 +1 @@
1
- {"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAEA,kIAAkI;AAClI,MAAM,OAAO,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhG,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,wEAAwE;AACxE,MAAM,OAAO,cAAc;aACT,QAA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C,EAAE,YAAY,CAAC,GAAG;KACkB,CAAC;IAE3D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAA0B;QACvC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC;IACnE,CAAC;;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */\nexport class MimeTypes {\n static readonly UNKNOWN = 'unknown';\n static readonly IMAGE = 'image';\n static readonly VIDEO = 'video';\n static readonly TEXT = 'text';\n\n static readonly SCHEME_SET = new Set<string>([this.UNKNOWN, this.IMAGE, this.VIDEO, this.TEXT]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `MimeTypes` values. */\nexport type TMimeTypes = TConstValue<typeof MimeTypes>;\n\n/** The leading dot is part of the value: `path.extname` returns one. */\nexport class FileExtensions {\n static readonly PNG = '.png';\n static readonly JPG = '.jpg';\n static readonly JPEG = '.jpeg';\n static readonly GIF = '.gif';\n static readonly WEBP = '.webp';\n static readonly SVG = '.svg';\n static readonly PDF = '.pdf';\n static readonly JSON = '.json';\n static readonly TXT = '.txt';\n static readonly HTML = '.html';\n static readonly CSS = '.css';\n static readonly JS = '.js';\n static readonly MP4 = '.mp4';\n static readonly WEBM = '.webm';\n static readonly MP3 = '.mp3';\n static readonly WAV = '.wav';\n static readonly ZIP = '.zip';\n static readonly CSV = '.csv';\n static readonly XML = '.xml';\n static readonly XLSX = '.xlsx';\n static readonly XLS = '.xls';\n static readonly DOCX = '.docx';\n static readonly DOC = '.doc';\n static readonly PPTX = '.pptx';\n static readonly PPT = '.ppt';\n static readonly ODT = '.odt';\n static readonly ODS = '.ods';\n\n static readonly SCHEME_SET = new Set<string>([\n this.PNG,\n this.JPG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.TXT,\n this.HTML,\n this.CSS,\n this.JS,\n this.MP4,\n this.WEBM,\n this.MP3,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `FileExtensions` values, with its leading dot. */\nexport type TFileExtension = TConstValue<typeof FileExtensions>;\n\n/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */\nexport class ContentTypes {\n static readonly OCTET_STREAM = 'application/octet-stream';\n static readonly PNG = 'image/png';\n static readonly JPEG = 'image/jpeg';\n static readonly GIF = 'image/gif';\n static readonly WEBP = 'image/webp';\n static readonly SVG = 'image/svg+xml';\n static readonly PDF = 'application/pdf';\n static readonly JSON = 'application/json';\n static readonly PLAIN_TEXT = 'text/plain';\n static readonly HTML = 'text/html';\n static readonly CSS = 'text/css';\n static readonly JAVASCRIPT = 'text/javascript';\n static readonly MP4 = 'video/mp4';\n static readonly WEBM = 'video/webm';\n static readonly MPEG_AUDIO = 'audio/mpeg';\n static readonly WAV = 'audio/wav';\n static readonly ZIP = 'application/zip';\n static readonly CSV = 'text/csv';\n static readonly XML = 'application/xml';\n static readonly XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n static readonly XLS = 'application/vnd.ms-excel';\n static readonly DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';\n static readonly DOC = 'application/msword';\n static readonly PPTX =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n\n static readonly PPT = 'application/vnd.ms-powerpoint';\n static readonly ODT = 'application/vnd.oasis.opendocument.text';\n static readonly ODS = 'application/vnd.oasis.opendocument.spreadsheet';\n\n static readonly SCHEME_SET = new Set<string>([\n this.OCTET_STREAM,\n this.PNG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.PLAIN_TEXT,\n this.HTML,\n this.CSS,\n this.JAVASCRIPT,\n this.MP4,\n this.WEBM,\n this.MPEG_AUDIO,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `ContentTypes` values. */\nexport type TContentType = TConstValue<typeof ContentTypes>;\n\n/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */\nexport class ContentTypeTable {\n /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */\n static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>> = {\n [FileExtensions.PNG]: ContentTypes.PNG,\n [FileExtensions.JPG]: ContentTypes.JPEG,\n [FileExtensions.JPEG]: ContentTypes.JPEG,\n [FileExtensions.GIF]: ContentTypes.GIF,\n [FileExtensions.WEBP]: ContentTypes.WEBP,\n [FileExtensions.SVG]: ContentTypes.SVG,\n [FileExtensions.PDF]: ContentTypes.PDF,\n [FileExtensions.JSON]: ContentTypes.JSON,\n [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,\n [FileExtensions.HTML]: ContentTypes.HTML,\n [FileExtensions.CSS]: ContentTypes.CSS,\n [FileExtensions.JS]: ContentTypes.JAVASCRIPT,\n [FileExtensions.MP4]: ContentTypes.MP4,\n [FileExtensions.WEBM]: ContentTypes.WEBM,\n [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,\n [FileExtensions.WAV]: ContentTypes.WAV,\n [FileExtensions.ZIP]: ContentTypes.ZIP,\n [FileExtensions.CSV]: ContentTypes.CSV,\n [FileExtensions.XML]: ContentTypes.XML,\n [FileExtensions.XLSX]: ContentTypes.XLSX,\n [FileExtensions.XLS]: ContentTypes.XLS,\n [FileExtensions.DOCX]: ContentTypes.DOCX,\n [FileExtensions.DOC]: ContentTypes.DOC,\n [FileExtensions.PPTX]: ContentTypes.PPTX,\n [FileExtensions.PPT]: ContentTypes.PPT,\n [FileExtensions.ODT]: ContentTypes.ODT,\n [FileExtensions.ODS]: ContentTypes.ODS,\n } satisfies Readonly<Record<TFileExtension, TContentType>>;\n\n /**\n * The content type an object name implies. `node:path` is deliberately not used: this file is\n * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last\n * dot either way.\n */\n static resolve(opts: { filename: string }): TContentType {\n const { filename } = opts;\n const lastDot = filename.lastIndexOf('.');\n const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();\n\n return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;\n }\n}\n\n/** Published before the table moved onto the class; kept as the one-line delegate it now is. */\nexport const CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;\n"]}
1
+ {"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAEA,kIAAkI;AAClI,MAAM,OAAO,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;;AAKhC,wEAAwE;AACxE,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb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AAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC;IACnE,CAAC;;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */\nexport class MimeTypes {\n static readonly UNKNOWN = 'unknown';\n static readonly IMAGE = 'image';\n static readonly VIDEO = 'video';\n static readonly TEXT = 'text';\n}\n/** One of the `MimeTypes` values. */\nexport type TMimeTypes = TConstValue<typeof MimeTypes>;\n\n/** The leading dot is part of the value: `path.extname` returns one. */\nexport class FileExtensions {\n static readonly PNG = '.png';\n static readonly JPG = '.jpg';\n static readonly JPEG = '.jpeg';\n static readonly GIF = '.gif';\n static readonly WEBP = '.webp';\n static readonly SVG = '.svg';\n static readonly PDF = '.pdf';\n static readonly JSON = '.json';\n static readonly TXT = '.txt';\n static readonly HTML = '.html';\n static readonly CSS = '.css';\n static readonly JS = '.js';\n static readonly MP4 = '.mp4';\n static readonly WEBM = '.webm';\n static readonly MP3 = '.mp3';\n static readonly WAV = '.wav';\n static readonly ZIP = '.zip';\n static readonly CSV = '.csv';\n static readonly XML = '.xml';\n static readonly XLSX = '.xlsx';\n static readonly XLS = '.xls';\n static readonly DOCX = '.docx';\n static readonly DOC = '.doc';\n static readonly PPTX = '.pptx';\n static readonly PPT = '.ppt';\n static readonly ODT = '.odt';\n static readonly ODS = '.ods';\n\n static readonly SCHEME_SET = new Set<string>([\n this.PNG,\n this.JPG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.TXT,\n this.HTML,\n this.CSS,\n this.JS,\n this.MP4,\n this.WEBM,\n this.MP3,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `FileExtensions` values, with its leading dot. */\nexport type TFileExtension = TConstValue<typeof FileExtensions>;\n\n/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */\nexport class ContentTypes {\n static readonly OCTET_STREAM = 'application/octet-stream';\n static readonly PNG = 'image/png';\n static readonly JPEG = 'image/jpeg';\n static readonly GIF = 'image/gif';\n static readonly WEBP = 'image/webp';\n static readonly SVG = 'image/svg+xml';\n static readonly PDF = 'application/pdf';\n static readonly JSON = 'application/json';\n static readonly PLAIN_TEXT = 'text/plain';\n static readonly HTML = 'text/html';\n static readonly CSS = 'text/css';\n static readonly JAVASCRIPT = 'text/javascript';\n static readonly MP4 = 'video/mp4';\n static readonly WEBM = 'video/webm';\n static readonly MPEG_AUDIO = 'audio/mpeg';\n static readonly WAV = 'audio/wav';\n static readonly ZIP = 'application/zip';\n static readonly CSV = 'text/csv';\n static readonly XML = 'application/xml';\n static readonly XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n static readonly XLS = 'application/vnd.ms-excel';\n static readonly DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';\n static readonly DOC = 'application/msword';\n static readonly PPTX =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n\n static readonly PPT = 'application/vnd.ms-powerpoint';\n static readonly ODT = 'application/vnd.oasis.opendocument.text';\n static readonly ODS = 'application/vnd.oasis.opendocument.spreadsheet';\n\n static readonly SCHEME_SET = new Set<string>([\n this.OCTET_STREAM,\n this.PNG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.PLAIN_TEXT,\n this.HTML,\n this.CSS,\n this.JAVASCRIPT,\n this.MP4,\n this.WEBM,\n this.MPEG_AUDIO,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `ContentTypes` values. */\nexport type TContentType = TConstValue<typeof ContentTypes>;\n\n/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */\nexport class ContentTypeTable {\n /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */\n static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>> = {\n [FileExtensions.PNG]: ContentTypes.PNG,\n [FileExtensions.JPG]: ContentTypes.JPEG,\n [FileExtensions.JPEG]: ContentTypes.JPEG,\n [FileExtensions.GIF]: ContentTypes.GIF,\n [FileExtensions.WEBP]: ContentTypes.WEBP,\n [FileExtensions.SVG]: ContentTypes.SVG,\n [FileExtensions.PDF]: ContentTypes.PDF,\n [FileExtensions.JSON]: ContentTypes.JSON,\n [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,\n [FileExtensions.HTML]: ContentTypes.HTML,\n [FileExtensions.CSS]: ContentTypes.CSS,\n [FileExtensions.JS]: ContentTypes.JAVASCRIPT,\n [FileExtensions.MP4]: ContentTypes.MP4,\n [FileExtensions.WEBM]: ContentTypes.WEBM,\n [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,\n [FileExtensions.WAV]: ContentTypes.WAV,\n [FileExtensions.ZIP]: ContentTypes.ZIP,\n [FileExtensions.CSV]: ContentTypes.CSV,\n [FileExtensions.XML]: ContentTypes.XML,\n [FileExtensions.XLSX]: ContentTypes.XLSX,\n [FileExtensions.XLS]: ContentTypes.XLS,\n [FileExtensions.DOCX]: ContentTypes.DOCX,\n [FileExtensions.DOC]: ContentTypes.DOC,\n [FileExtensions.PPTX]: ContentTypes.PPTX,\n [FileExtensions.PPT]: ContentTypes.PPT,\n [FileExtensions.ODT]: ContentTypes.ODT,\n [FileExtensions.ODS]: ContentTypes.ODS,\n } satisfies Readonly<Record<TFileExtension, TContentType>>;\n\n /**\n * The content type an object name implies. `node:path` is deliberately not used: this file is\n * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last\n * dot either way.\n */\n static resolve(opts: { filename: string }): TContentType {\n const { filename } = opts;\n const lastDot = filename.lastIndexOf('.');\n const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();\n\n return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;\n }\n}\n\n/** Published before the table moved onto the class; kept as the one-line delegate it now is. */\nexport const CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/common/redact.ts"],"names":[],"mappings":"AAEA,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACnC;IACE,qDAAqD;IACrD,6EAA6E;IAC7E,qFAAqF;IACrF,oEAAoE;IAEpE,iKAAiK;IACjK,qCAAqC;IAErC,8MAA8M;IAC9M,yBAAyB;IAEzB,8RAA8R;IAC9R,2BAA2B;IAE3B,4JAA4J;IAC5J,qDAAqD;IAErD,uMAAuM;IACvM,uCAAuC;IAEvC,yIAAyI;IACzI,+BAA+B;IAE/B,2MAA2M;IAC3M,gFAAgF;IAChF,6DAA6D;IAE7D,kHAAkH;IAClH,qHAAqH;IACrH,uHAAuH;IACvH,kCAAkC;IAClC,sNAAsN;IACtN,sIAAsI;IACtI,qHAAqH;IACrH,8DAA8D;IAC9D,4DAA4D;IAC5D,gEAAgE;IAChE,yFAAyF;CAC1F,CAAC,IAAI,CAAC,EAAE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G,CAAC;QACb,CAAC;QAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { type AnyObject } from './types';\n\n/** Keys whose VALUES must never reach a log line - matched case-insensitively on the key name, at any depth. */\nconst SECRET_KEY_PATTERN = new RegExp(\n [\n // Options-object spellings (camelCase / snake_case).\n '^(pass|password|passphrase|secret|token|apiKey|api_key|accessKey|access_key',\n '|secretKey|secret_key|privateKey|private_key|key|cert|ca|pfx|credential|credentials',\n '|authorization|auth|jwtSecret|applicationSecret|connectionString)$',\n\n // Vault wire spellings (snake_case): node-vault's AppRole login/response bodies carry these exact keys, and none are matched by the anchored options list above.\n '|^(client_token|secret_id|role_id)$',\n\n // Any `*_token` (snake_case) or `*Token` (camelCase) key; a preceding character is required so the bare word `token` (already covered above) is not the whole match, and so ordinary words are not swallowed.\n '|_token$|[a-z0-9]token$',\n\n // The `*Secret` counterpart the `*Token` rule always lacked. `clientSecret` / `client_secret` is the RFC 6749 parameter name and a live field on the search connector's model options, and `webhookSecret` is the standard spelling everywhere; none of them matched the anchored list above.\n '|_secret$|[a-z0-9]secret$',\n\n // Connection descriptors: `connectionString` was anchored above but its snake_case twin was not, and `dsn` is the third common spelling for the same thing.\n '|^(connection_string|dsn|database_url|databaseUrl)$',\n\n // Any `*_credential` / `*Credential` key, singular or plural - `dbCredential`, `api_credentials`. The bare words are anchored above; this catches the prefixed forms, the way the `*Secret` rule does.\n '|_credentials?$|[a-z0-9]credentials?$',\n\n // Any `*_password` / `*Password` key - `dbPassword`, `admin_password`. The bare word is anchored above; this catches the prefixed forms.\n '|_password$|[a-z0-9]password$',\n\n // HTTP HEADER spellings: header names are kebab-case and often `x-`-prefixed, none of which the camelCase list above matches; `vault` is included so `X-Vault-Token` (node-vault's auth header) is caught.\n '|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',\n '|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',\n\n // Named secrets that no suffix rule reaches. An explicit list, never a blanket `*Key` or `code`: those would mask\n // `primaryKey`, `cacheKey` and every status `code`. Cloud and signing keys, session and one-time values, signatures,\n // card and national-id numbers, and the kebab spellings of tokens and secrets (the suffix rules above need a letter or\n // an underscore before the word).\n '|^(secret_?access_?key|aws_?secret_?access_?key|signing_?key|encryption_?key|master_?key|hmac_?key|account_?key|storage_?key|license_?key|reset_?key|reset_?code|verification_?code|authorization_?code|auth_?code)$',\n '|^(jwt|session_?id|sid|signature|sig|passwd|pwd|passcode|pass_phrase|secret_?answer|otp|totp|cvv|cvc|card_?number|ssn|national_?id)$',\n '|^(redis_?url|mongo_?uri|mongo_?url|webhook_?url|private_?key_?pem|password_?hash|mfa_?code|otp_?code|x_?api_?key)$',\n '|^(api_?keys|refresh_?tokens|access_?tokens|secrets|tokens)$',\n '|^(x-amz-signature|x-amz-security-token|x-amz-credential)$',\n '|^(id|refresh|access|bearer|auth|api|session|csrf|xsrf)-token$',\n '|^(client|api|app|webhook)-secret$|^(private|signing|secret|api|access|encryption)-key$',\n ].join(''),\n 'i',\n);\n\n/** The placeholder that replaces a secret value in redacted output. */\nexport const REDACTED = '[REDACTED]';\n\n/**\n * `://user:password@host`: the password of a url's userinfo, wherever the url sits inside a string. Anchored on `://`\n * (not on the scheme, whose letters a pattern would rescan from every start) and every run is bounded, so the cost is\n * linear in the string. The password runs to the LAST `@` before a space or slash, so one that holds an `@` is whole.\n */\nconst URL_USERINFO_PATTERN = /(:\\/\\/[^\\s/:@]{0,256}):[^\\s/]{1,256}@/g;\n\n/** `://token@host`: a userinfo with no password is the credential itself (`https://<token>@github.com`). */\nconst URL_USER_ONLY_PATTERN = /:\\/\\/[^\\s/:@]{1,256}@/g;\n\n/** `Bearer abc...` and `Basic abc...` credentials, as an `Authorization` header or a message quotes them. */\nconst AUTH_SCHEME_PATTERN = /\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}/gi;\n\n/** A credential-like `name=value` after a query, fragment, list or space: `?access_token=...`, `#id_token=...`, `, password=...`. */\nconst QUERY_CREDENTIAL_PATTERN =\n /([?&;,#\\s])(access_token|refresh_token|id_token|token|api_key|apikey|x-api-key|key|auth|password|passwd|pwd|secret|client_secret|signature|sig|x-amz-signature|x-amz-security-token|jwt|session_id|sessionid|code)=([^&\\s#,)]*)/gi;\n\n/** A string with the credentials it carries masked: a connection url's password, a bearer token, a credential query parameter. */\nconst scrubString = (value: string): string => {\n if (!value.includes('@') && !value.includes('=') && !/bearer|basic/i.test(value)) {\n return value;\n }\n\n return value\n .replace(URL_USERINFO_PATTERN, `$1:${'[REDACTED]'}@`)\n .replace(URL_USER_ONLY_PATTERN, `://${'[REDACTED]'}@`)\n .replace(AUTH_SCHEME_PATTERN, `$1 ${'[REDACTED]'}`)\n .replace(QUERY_CREDENTIAL_PATTERN, `$1$2=${'[REDACTED]'}`);\n};\n\n/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. `force` is the caller opting out of the switch: it always masks. */\nconst isRedactionEnabled = (force?: boolean): boolean =>\n force === true || globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';\n\n/** Longest string a log line carries whole. `APP_ENV_LOGGER_MAX_STRING_LENGTH=0` turns capping off. */\nconst DEFAULT_MAX_STRING_LENGTH = 2048;\n\nconst resolveMaxStringLength = (): number => {\n const configured = Number(globalThis.process?.env?.APP_ENV_LOGGER_MAX_STRING_LENGTH);\n\n return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_STRING_LENGTH;\n};\n\n/**\n * Keys whose value is long BY NATURE and useless truncated. A stack trace is the whole reason you\n * are reading the line.\n */\nconst UNCAPPED_KEYS = new Set(['stack', 'stacktrace', 'stack_trace']);\n\n/**\n * Caps a long string, keeping the ORIGINAL LENGTH in the marker - that number is what tells you the\n * payload was a 300 KB image rather than a truncated sentence.\n *\n * A base64 body is the case this exists for: one `data:image/png;base64,...` field turns a request\n * log into hundreds of kilobytes, and nothing about it is readable.\n */\nconst capString = (opts: { value: string; key?: string; limit: number }): string => {\n const { value, key, limit } = opts;\n\n if (limit === 0 || value.length <= limit || (key && UNCAPPED_KEYS.has(key.toLowerCase()))) {\n return value;\n }\n\n return `${value.slice(0, limit)}... [truncated, ${value.length} chars total]`;\n};\n\ntype TSanitizeContext = {\n seen: WeakSet<object>;\n doRedact: boolean;\n /** Levels still allowed BELOW the current one; `Infinity` walks the whole graph. */\n depth: number;\n /** Longest string kept whole; 0 keeps every string. */\n maxStringLength: number;\n /** The key this value was found under, so a stack trace can be exempted from capping. */\n key?: string;\n};\n\nconst deepSanitize = (value: unknown, context: TSanitizeContext): unknown => {\n const { seen, doRedact, depth } = context;\n\n if (typeof value === 'string') {\n const text = doRedact ? scrubString(value) : value;\n\n return capString({ value: text, key: context.key, limit: context.maxStringLength });\n }\n\n // A function is not data, and an own `toJSON` on an object would run after this walk, inside `JSON.stringify`, and\n // hand back keys the walk never saw. Naming it keeps the redacted copy free of code.\n if (typeof value === 'function') {\n return '[Function]';\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n // A Date holds its value in an internal slot, so the generic branch below - which reads Object.keys() - would flatten it to `{}`. Checked BEFORE `seen`: a Date cannot carry a cycle, and entering the set would make a second reference to the same instance read as `[Circular]`.\n if (value instanceof Date) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return `[Binary ${(value as ArrayBufferView).byteLength ?? 0} bytes]`;\n }\n\n if (depth <= 0) {\n return Array.isArray(value) ? '[Array]' : '[Object]';\n }\n\n seen.add(value);\n const nested: TSanitizeContext = {\n seen,\n doRedact,\n depth: depth - 1,\n maxStringLength: context.maxStringLength,\n };\n\n // Error keeps name/message/stack NON-enumerable, so Object.keys() skips them and naive redaction would drop the message - reproject into a plain object carrying those fields plus its redacted enumerable own-props.\n if (value instanceof Error) {\n const source = value;\n const result: AnyObject = {\n name: value.name,\n message: doRedact ? scrubString(value.message) : value.message,\n stack: doRedact && value.stack ? scrubString(value.stack) : value.stack,\n };\n\n for (const [key, entry] of Object.entries(source)) {\n result[key] =\n doRedact && SECRET_KEY_PATTERN.test(key)\n ? REDACTED\n : deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => deepSanitize(entry, nested));\n }\n\n const source = value;\n const result: AnyObject = {};\n\n for (const [key, entry] of Object.entries(source)) {\n if (doRedact && SECRET_KEY_PATTERN.test(key)) {\n result[key] = REDACTED;\n continue;\n }\n\n result[key] = deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n};\n\n/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */\nexport class RedactUtility {\n /**\n * Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not\n * serialized). `APP_ENV_LOGGER_DO_REDACT=false` makes this the identity function.\n *\n * `depth` bounds the walk, exactly as {@link RedactUtility.toJsonSafe} already does. It defaults to\n * `Infinity` for callers that really do want the whole graph, but the logger passes its own bound:\n * rendering only inspects a handful of levels, so walking to `Infinity` did work whose result was\n * thrown away - 12x on a deep graph, and a `RangeError` on a very deep chain.\n *\n * `force: true` masks secret-looking KEYS even when `APP_ENV_LOGGER_DO_REDACT=false`. The result is still the\n * log-shaped copy: long strings are capped, a second reference to one object reads `[Circular]`, binary is\n * summarized, and a key is masked by name only (a card number under `number` is not). It is not a faithful\n * redacted document. The logger never sets it.\n */\n static redactSecrets(opts: {\n value: unknown;\n seen?: WeakSet<object>;\n depth?: number;\n force?: boolean;\n }): unknown {\n const { value, seen, depth = Infinity, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return value;\n }\n\n return deepSanitize(value, {\n seen: seen ?? new WeakSet<object>(),\n doRedact: true,\n depth,\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Masks the credentials a plain string carries (a url's password, a bearer token, credential query parameters). For a log line's string argument; objects go through {@link RedactUtility.redactSecrets}. `force: true` scrubs even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static scrubText(opts: { value: string; force?: boolean }): string {\n return isRedactionEnabled(opts.force) ? scrubString(opts.value) : opts.value;\n }\n\n /** Projects a value into something `JSON.stringify` can render: it answers `[Circular]` for the WHOLE payload when one cycle sits anywhere inside it, so cycles must be broken per-branch first. `depth` bounds the walk the way `util.inspect` does - a log argument may hold a live connector or request context, whose graph is effectively unbounded. The projection itself is unconditional: `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking, never the structural pass. `force: true` keeps the key masking on whatever the switch says; the projection stays lossy, as in {@link RedactUtility.redactSecrets}. */\n static toJsonSafe(opts: { value: unknown; depth?: number; force?: boolean }): unknown {\n return deepSanitize(opts.value, {\n seen: new WeakSet<object>(),\n doRedact: isRedactionEnabled(opts.force),\n depth: opts.depth ?? Infinity,\n // Capping is STRUCTURAL, like the projection itself: turning redaction off is about key masking,\n // never about letting a 300 KB base64 field through.\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Strips credentials from a connection URL's authority section (`user:hunter2@host` -> `user:[REDACTED]@host`) - {@link RedactUtility.redactSecrets} matches on KEY names and can't see them there. A value that fails to parse as a URL is returned unchanged. `force: true` strips even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static redactUrlCredentials(opts: { url: string; force?: boolean }): string {\n const { url, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return url;\n }\n\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n return url;\n }\n\n if (!parsed.password) {\n return url;\n }\n\n parsed.password = REDACTED;\n\n return decodeURIComponent(parsed.toString());\n }\n}\n"]}
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/common/redact.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,IAAI,MAAM,C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AAe,EAAE,sBAAsB,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,qUAAqU;IACrU,MAAM,CAAC,oBAAoB,CAAC,IAAsC;QAChE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE5B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,MAAW,CAAC;QAEhB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/** Keys whose VALUES must never reach a log line - matched case-insensitively on the key name, at any depth. */\nconst SECRET_KEY_PATTERN = new RegExp(\n [\n // Options-object spellings (camelCase / snake_case).\n '^(pass|password|passphrase|secret|token|apiKey|api_key|accessKey|access_key',\n '|secretKey|secret_key|privateKey|private_key|key|cert|ca|pfx|credential|credentials',\n '|authorization|auth|jwtSecret|applicationSecret|connectionString)$',\n\n // Vault wire spellings (snake_case): node-vault's AppRole login/response bodies carry these exact keys, and none are matched by the anchored options list above.\n '|^(client_token|secret_id|role_id)$',\n\n // Any `*_token` (snake_case) or `*Token` (camelCase) key; a preceding character is required so the bare word `token` (already covered above) is not the whole match, and so ordinary words are not swallowed.\n '|_token$|[a-z0-9]token$',\n\n // The `*Secret` counterpart the `*Token` rule always lacked. `clientSecret` / `client_secret` is the RFC 6749 parameter name and a live field on the search connector's model options, and `webhookSecret` is the standard spelling everywhere; none of them matched the anchored list above.\n '|_secret$|[a-z0-9]secret$',\n\n // Connection descriptors: `connectionString` was anchored above but its snake_case twin was not, and `dsn` is the third common spelling for the same thing.\n '|^(connection_string|dsn|database_url|databaseUrl)$',\n\n // Any `*_credential` / `*Credential` key, singular or plural - `dbCredential`, `api_credentials`. The bare words are anchored above; this catches the prefixed forms, the way the `*Secret` rule does.\n '|_credentials?$|[a-z0-9]credentials?$',\n\n // Any `*_password` / `*Password` key - `dbPassword`, `admin_password`. The bare word is anchored above; this catches the prefixed forms.\n '|_password$|[a-z0-9]password$',\n\n // HTTP HEADER spellings: header names are kebab-case and often `x-`-prefixed, none of which the camelCase list above matches; `vault` is included so `X-Vault-Token` (node-vault's auth header) is caught.\n '|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',\n '|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',\n\n // Named secrets that no suffix rule reaches. An explicit list, never a blanket `*Key` or `code`: those would mask\n // `primaryKey`, `cacheKey` and every status `code`. Cloud and signing keys, session and one-time values, signatures,\n // card and national-id numbers, and the kebab spellings of tokens and secrets (the suffix rules above need a letter or\n // an underscore before the word).\n '|^(secret_?access_?key|aws_?secret_?access_?key|signing_?key|encryption_?key|master_?key|hmac_?key|account_?key|storage_?key|license_?key|reset_?key|reset_?code|verification_?code|authorization_?code|auth_?code)$',\n '|^(jwt|session_?id|sid|signature|sig|passwd|pwd|passcode|pass_phrase|secret_?answer|otp|totp|cvv|cvc|card_?number|ssn|national_?id)$',\n '|^(redis_?url|mongo_?uri|mongo_?url|webhook_?url|private_?key_?pem|password_?hash|mfa_?code|otp_?code|x_?api_?key)$',\n '|^(api_?keys|refresh_?tokens|access_?tokens|secrets|tokens)$',\n '|^(x-amz-signature|x-amz-security-token|x-amz-credential)$',\n '|^(id|refresh|access|bearer|auth|api|session|csrf|xsrf)-token$',\n '|^(client|api|app|webhook)-secret$|^(private|signing|secret|api|access|encryption)-key$',\n ].join(''),\n 'i',\n);\n\n/** The placeholder that replaces a secret value in redacted output. */\nexport const REDACTED = '[REDACTED]';\n\n/**\n * `://user:password@host`: the password of a url's userinfo, wherever the url sits inside a string. Anchored on `://`\n * (not on the scheme, whose letters a pattern would rescan from every start) and every run is bounded, so the cost is\n * linear in the string. The password runs to the LAST `@` before a space or slash, so one that holds an `@` is whole.\n */\nconst URL_USERINFO_PATTERN = /(:\\/\\/[^\\s/:@]{0,256}):[^\\s/]{1,256}@/g;\n\n/** `://token@host`: a userinfo with no password is the credential itself (`https://<token>@github.com`). */\nconst URL_USER_ONLY_PATTERN = /:\\/\\/[^\\s/:@]{1,256}@/g;\n\n/** `Bearer abc...` and `Basic abc...` credentials, as an `Authorization` header or a message quotes them. */\nconst AUTH_SCHEME_PATTERN = /\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}/gi;\n\n/** A credential-like `name=value` after a query, fragment, list or space: `?access_token=...`, `#id_token=...`, `, password=...`. */\nconst QUERY_CREDENTIAL_PATTERN =\n /([?&;,#\\s])(access_token|refresh_token|id_token|token|api_key|apikey|x-api-key|key|auth|password|passwd|pwd|secret|client_secret|signature|sig|x-amz-signature|x-amz-security-token|jwt|session_id|sessionid|code)=([^&\\s#,)]*)/gi;\n\n/** A string with the credentials it carries masked: a connection url's password, a bearer token, a credential query parameter. */\nconst scrubString = (value: string): string => {\n if (!value.includes('@') && !value.includes('=') && !/bearer|basic/i.test(value)) {\n return value;\n }\n\n return value\n .replace(URL_USERINFO_PATTERN, `$1:${'[REDACTED]'}@`)\n .replace(URL_USER_ONLY_PATTERN, `://${'[REDACTED]'}@`)\n .replace(AUTH_SCHEME_PATTERN, `$1 ${'[REDACTED]'}`)\n .replace(QUERY_CREDENTIAL_PATTERN, `$1$2=${'[REDACTED]'}`);\n};\n\n/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. `force` is the caller opting out of the switch: it always masks. */\nconst isRedactionEnabled = (force?: boolean): boolean =>\n force === true || globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';\n\n/** Longest string a log line carries whole. `APP_ENV_LOGGER_MAX_STRING_LENGTH=0` turns capping off. */\nconst DEFAULT_MAX_STRING_LENGTH = 2048;\n\nconst resolveMaxStringLength = (): number => {\n const configured = Number(globalThis.process?.env?.APP_ENV_LOGGER_MAX_STRING_LENGTH);\n\n return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_STRING_LENGTH;\n};\n\n/**\n * Keys whose value is long BY NATURE and useless truncated. A stack trace is the whole reason you\n * are reading the line.\n */\nconst UNCAPPED_KEYS = new Set(['stack', 'stacktrace', 'stack_trace']);\n\n/**\n * Caps a long string, keeping the ORIGINAL LENGTH in the marker - that number is what tells you the\n * payload was a 300 KB image rather than a truncated sentence.\n *\n * A base64 body is the case this exists for: one `data:image/png;base64,...` field turns a request\n * log into hundreds of kilobytes, and nothing about it is readable.\n */\nconst capString = (opts: { value: string; key?: string; limit: number }): string => {\n const { value, key, limit } = opts;\n\n if (limit === 0 || value.length <= limit || (key && UNCAPPED_KEYS.has(key.toLowerCase()))) {\n return value;\n }\n\n return `${value.slice(0, limit)}... [truncated, ${value.length} chars total]`;\n};\n\ntype TSanitizeContext = {\n seen: WeakSet<object>;\n doRedact: boolean;\n /** Levels still allowed BELOW the current one; `Infinity` walks the whole graph. */\n depth: number;\n /** Longest string kept whole; 0 keeps every string. */\n maxStringLength: number;\n /** The key this value was found under, so a stack trace can be exempted from capping. */\n key?: string;\n};\n\nconst deepSanitize = (value: unknown, context: TSanitizeContext): unknown => {\n const { seen, doRedact, depth } = context;\n\n if (typeof value === 'string') {\n const text = doRedact ? scrubString(value) : value;\n\n return capString({ value: text, key: context.key, limit: context.maxStringLength });\n }\n\n // A function is not data, and an own `toJSON` on an object would run after this walk, inside `JSON.stringify`, and\n // hand back keys the walk never saw. Naming it keeps the redacted copy free of code.\n if (typeof value === 'function') {\n return '[Function]';\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n // A Date holds its value in an internal slot, so the generic branch below - which reads Object.keys() - would flatten it to `{}`. Checked BEFORE `seen`: a Date cannot carry a cycle, and entering the set would make a second reference to the same instance read as `[Circular]`.\n if (value instanceof Date) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return `[Binary ${(value as ArrayBufferView).byteLength ?? 0} bytes]`;\n }\n\n if (depth <= 0) {\n return Array.isArray(value) ? '[Array]' : '[Object]';\n }\n\n seen.add(value);\n const nested: TSanitizeContext = {\n seen,\n doRedact,\n depth: depth - 1,\n maxStringLength: context.maxStringLength,\n };\n\n // Error keeps name/message/stack NON-enumerable, so Object.keys() skips them and naive redaction would drop the message - reproject into a plain object carrying those fields plus its redacted enumerable own-props.\n if (value instanceof Error) {\n const source = value;\n const result: Record<string, unknown> = {\n name: value.name,\n message: doRedact ? scrubString(value.message) : value.message,\n stack: doRedact && value.stack ? scrubString(value.stack) : value.stack,\n };\n\n for (const [key, entry] of Object.entries(source)) {\n result[key] =\n doRedact && SECRET_KEY_PATTERN.test(key)\n ? REDACTED\n : deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => deepSanitize(entry, nested));\n }\n\n const source = value;\n const result: Record<string, unknown> = {};\n\n for (const [key, entry] of Object.entries(source)) {\n if (doRedact && SECRET_KEY_PATTERN.test(key)) {\n result[key] = REDACTED;\n continue;\n }\n\n result[key] = deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n};\n\n/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */\nexport class RedactUtility {\n /**\n * Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not\n * serialized). `APP_ENV_LOGGER_DO_REDACT=false` makes this the identity function.\n *\n * `depth` bounds the walk, exactly as {@link RedactUtility.toJsonSafe} already does. It defaults to\n * `Infinity` for callers that really do want the whole graph, but the logger passes its own bound:\n * rendering only inspects a handful of levels, so walking to `Infinity` did work whose result was\n * thrown away - 12x on a deep graph, and a `RangeError` on a very deep chain.\n *\n * `force: true` masks secret-looking KEYS even when `APP_ENV_LOGGER_DO_REDACT=false`. The result is still the\n * log-shaped copy: long strings are capped, a second reference to one object reads `[Circular]`, binary is\n * summarized, and a key is masked by name only (a card number under `number` is not). It is not a faithful\n * redacted document. The logger never sets it.\n */\n static redactSecrets(opts: {\n value: unknown;\n seen?: WeakSet<object>;\n depth?: number;\n force?: boolean;\n }): unknown {\n const { value, seen, depth = Infinity, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return value;\n }\n\n return deepSanitize(value, {\n seen: seen ?? new WeakSet<object>(),\n doRedact: true,\n depth,\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Masks the credentials a plain string carries (a url's password, a bearer token, credential query parameters). For a log line's string argument; objects go through {@link RedactUtility.redactSecrets}. `force: true` scrubs even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static scrubText(opts: { value: string; force?: boolean }): string {\n return isRedactionEnabled(opts.force) ? scrubString(opts.value) : opts.value;\n }\n\n /** Projects a value into something `JSON.stringify` can render: it answers `[Circular]` for the WHOLE payload when one cycle sits anywhere inside it, so cycles must be broken per-branch first. `depth` bounds the walk the way `util.inspect` does - a log argument may hold a live connector or request context, whose graph is effectively unbounded. The projection itself is unconditional: `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking, never the structural pass. `force: true` keeps the key masking on whatever the switch says; the projection stays lossy, as in {@link RedactUtility.redactSecrets}. */\n static toJsonSafe(opts: { value: unknown; depth?: number; force?: boolean }): unknown {\n return deepSanitize(opts.value, {\n seen: new WeakSet<object>(),\n doRedact: isRedactionEnabled(opts.force),\n depth: opts.depth ?? Infinity,\n // Capping is STRUCTURAL, like the projection itself: turning redaction off is about key masking,\n // never about letting a 300 KB base64 field through.\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Strips credentials from a connection URL's authority section (`user:hunter2@host` -> `user:[REDACTED]@host`) - {@link RedactUtility.redactSecrets} matches on KEY names and can't see them there. A value that fails to parse as a URL is returned unchanged. `force: true` strips even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static redactUrlCredentials(opts: { url: string; force?: boolean }): string {\n const { url, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return url;\n }\n\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n return url;\n }\n\n if (!parsed.password) {\n return url;\n }\n\n parsed.password = REDACTED;\n\n return decodeURIComponent(parsed.toString());\n }\n}\n"]}
@@ -1,21 +1,23 @@
1
1
  /** A concrete class constructor producing `T`. */
2
- export type TConstructor<T> = new (...args: any[]) => T;
2
+ export type TConstructor<T> = new (...args: never[]) => T;
3
3
  /** An abstract class constructor producing `T`; it cannot be called with `new` directly. */
4
- export type TAbstractConstructor<T> = abstract new (...args: any[]) => T;
5
- /** A concrete class producing `T`, with any static members allowed. */
6
- export type TClass<T> = TConstructor<T> & {
7
- [property: string]: any;
8
- };
9
- /** An abstract class producing `T`, with any static members allowed. */
10
- export type TAbstractClass<T> = TAbstractConstructor<T> & {
11
- [property: string]: any;
12
- };
4
+ export type TAbstractConstructor<T> = abstract new (...args: never[]) => T;
5
+ /** A concrete class producing `T`. Read its static members through a type that declares them, such as `typeof MyClass`. */
6
+ export type TClass<T> = TConstructor<T>;
7
+ /** An abstract class producing `T`. */
8
+ export type TAbstractClass<T> = TAbstractConstructor<T>;
9
+ /**
10
+ * The constructor shape a mixin base takes. TypeScript requires `new (...args: any[]) => T` here (error TS2545: a mixin class must have a constructor with a single rest parameter of type `any[]`), so this is the one `any` the language mandates.
11
+ */
12
+ export type TMixinConstructor<T> = new (...args: any[]) => T;
13
+ /** The abstract form of {@link TMixinConstructor}. */
14
+ export type TAbstractMixinConstructor<T> = abstract new (...args: any[]) => T;
13
15
  /** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */
14
- export type TMixinTarget<T> = TConstructor<{
16
+ export type TMixinTarget<T> = TMixinConstructor<{
15
17
  [P in keyof T]: T[P];
16
18
  }>;
17
19
  /** `TMixinTarget` for an abstract base class. */
18
- export type TAbstractMixinTarget<T> = TAbstractConstructor<{
20
+ export type TAbstractMixinTarget<T> = TAbstractMixinConstructor<{
19
21
  [P in keyof T]: T[P];
20
22
  }>;
21
23
  //# sourceMappingURL=class.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/common/types/class.ts"],"names":[],"mappings":"","sourcesContent":["/** A concrete class constructor producing `T`. */\nexport type TConstructor<T> = new (...args: any[]) => T;\n/** An abstract class constructor producing `T`; it cannot be called with `new` directly. */\nexport type TAbstractConstructor<T> = abstract new (...args: any[]) => T;\n/** A concrete class producing `T`, with any static members allowed. */\nexport type TClass<T> = TConstructor<T> & { [property: string]: any };\n/** An abstract class producing `T`, with any static members allowed. */\nexport type TAbstractClass<T> = TAbstractConstructor<T> & { [property: string]: any };\n\n/** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */\nexport type TMixinTarget<T> = TConstructor<{ [P in keyof T]: T[P] }>;\n/** `TMixinTarget` for an abstract base class. */\nexport type TAbstractMixinTarget<T> = TAbstractConstructor<{ [P in keyof T]: T[P] }>;\n"]}
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/common/types/class.ts"],"names":[],"mappings":"","sourcesContent":["/** A concrete class constructor producing `T`. */\nexport type TConstructor<T> = new (...args: never[]) => T;\n/** An abstract class constructor producing `T`; it cannot be called with `new` directly. */\nexport type TAbstractConstructor<T> = abstract new (...args: never[]) => T;\n/** A concrete class producing `T`. Read its static members through a type that declares them, such as `typeof MyClass`. */\nexport type TClass<T> = TConstructor<T>;\n/** An abstract class producing `T`. */\nexport type TAbstractClass<T> = TAbstractConstructor<T>;\n\n/**\n * The constructor shape a mixin base takes. TypeScript requires `new (...args: any[]) => T` here (error TS2545: a mixin class must have a constructor with a single rest parameter of type `any[]`), so this is the one `any` the language mandates.\n */\nexport type TMixinConstructor<T> = new (...args: any[]) => T;\n/** The abstract form of {@link TMixinConstructor}. */\nexport type TAbstractMixinConstructor<T> = abstract new (...args: any[]) => T;\n\n/** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */\nexport type TMixinTarget<T> = TMixinConstructor<{ [P in keyof T]: T[P] }>;\n/** `TMixinTarget` for an abstract base class. */\nexport type TAbstractMixinTarget<T> = TAbstractMixinConstructor<{ [P in keyof T]: T[P] }>;\n"]}
@@ -1,9 +1,9 @@
1
1
  import type { TClass } from './class.js';
2
2
  import type { ValueOf } from './utility.js';
3
3
  /** The string values held by the `static readonly` members of const class `T`, as a plain union. */
4
- export type TStringConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string> & {};
4
+ export type TStringConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string> & {};
5
5
  /** The number values held by the `static readonly` members of const class `T`, as a plain union. */
6
- export type TNumberConstValue<T extends TClass<any>> = Extract<ValueOf<T>, number> & {};
6
+ export type TNumberConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, number> & {};
7
7
  /** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */
8
- export type TConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string | number> & {};
8
+ export type TConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string | number> & {};
9
9
  //# sourceMappingURL=const-value.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"const-value.js","sourceRoot":"","sources":["../../../../src/common/types/const-value.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from './class';\nimport type { ValueOf } from './utility';\n\n/*\n * `& {}` keeps the same literal set but makes it a regular union. Without it the members of a\n * `static readonly` const class stay widening literals, and a value of these types widens to\n * `string` / `number` in an object literal, a `let`, or a generic inference.\n */\n/** The string values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TStringConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string> & {};\n/** The number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TNumberConstValue<T extends TClass<any>> = Extract<ValueOf<T>, number> & {};\n/** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string | number> & {};\n"]}
1
+ {"version":3,"file":"const-value.js","sourceRoot":"","sources":["../../../../src/common/types/const-value.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from './class';\nimport type { ValueOf } from './utility';\n\n/*\n * `& {}` keeps the same literal set but makes it a regular union. Without it the members of a\n * `static readonly` const class stay widening literals, and a value of these types widens to\n * `string` / `number` in an object literal, a `let`, or a generic inference.\n */\n/** The string values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TStringConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string> & {};\n/** The number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TNumberConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, number> & {};\n/** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string | number> & {};\n"]}
@@ -6,8 +6,6 @@ export declare class FieldMappingDataTypes {
6
6
  static readonly STRINGS = "strings";
7
7
  static readonly NUMBERS = "numbers";
8
8
  static readonly BOOLEAN = "boolean";
9
- static readonly SCHEME_SET: Set<string>;
10
- static isValid(value: string): boolean;
11
9
  }
12
10
  /** Valid field mapping data type values. */
13
11
  export type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;
@@ -25,28 +23,28 @@ export type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<T[numbe
25
23
  export type TObjectFromFieldMappings<T extends readonly {
26
24
  name: string;
27
25
  type: string;
28
- [extra: string | symbol]: any;
26
+ [extra: string | symbol]: unknown;
29
27
  }[]> = {
30
28
  [K in T[number]['name']]: T extends {
31
29
  name: K;
32
30
  type: 'string';
33
- [extra: string | symbol]: any;
31
+ [extra: string | symbol]: unknown;
34
32
  } ? string : T extends {
35
33
  name: K;
36
34
  type: 'number';
37
- [extra: string | symbol]: any;
35
+ [extra: string | symbol]: unknown;
38
36
  } ? number : T extends {
39
37
  name: K;
40
38
  type: 'boolean';
41
- [extra: string | symbol]: any;
39
+ [extra: string | symbol]: unknown;
42
40
  } ? boolean : T extends {
43
41
  name: K;
44
42
  type: 'strings';
45
- [extra: string | symbol]: any;
43
+ [extra: string | symbol]: unknown;
46
44
  } ? string[] : T extends {
47
45
  name: K;
48
46
  type: 'numbers';
49
- [extra: string | symbol]: any;
47
+ [extra: string | symbol]: unknown;
50
48
  } ? number[] : never;
51
49
  };
52
50
  //# sourceMappingURL=field-mapping.d.ts.map
@@ -5,15 +5,5 @@ export class FieldMappingDataTypes {
5
5
  static { this.STRINGS = 'strings'; }
6
6
  static { this.NUMBERS = 'numbers'; }
7
7
  static { this.BOOLEAN = 'boolean'; }
8
- static { this.SCHEME_SET = new Set([
9
- this.STRING,
10
- this.NUMBER,
11
- this.STRINGS,
12
- this.NUMBERS,
13
- this.BOOLEAN,
14
- ]); }
15
- static isValid(value) {
16
- return this.SCHEME_SET.has(value);
17
- }
18
8
  }
19
9
  //# sourceMappingURL=field-mapping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,OAAO,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n\n static readonly SCHEME_SET = new Set<string>([\n this.STRING,\n this.NUMBER,\n this.STRINGS,\n this.NUMBERS,\n this.BOOLEAN,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\n/** Describes one field to read: its `name`, its value `type`, and an optional `default`. */\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\n/** The union of `name` values in a list of field mappings. */\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\n/** The object a list of field mappings yields: one key per `name`, typed from its `type` (`string`, `number`, `boolean`, `strings` or `numbers`). Needs the list typed as a literal (`as const`) to narrow. */\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: any;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: any;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: any }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: any }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: any }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: any;\n }\n ? number[]\n : never;\n};\n"]}
1
+ {"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,OAAO,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\n/** Describes one field to read: its `name`, its value `type`, and an optional `default`. */\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\n/** The union of `name` values in a list of field mappings. */\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\n/** The object a list of field mappings yields: one key per `name`, typed from its `type` (`string`, `number`, `boolean`, `strings` or `numbers`). Needs the list typed as a literal (`as const`) to narrow. */\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: unknown;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: unknown;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: unknown }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: unknown }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: unknown }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: unknown;\n }\n ? number[]\n : never;\n};\n"]}
@@ -2,6 +2,7 @@ export * from './class.js';
2
2
  export * from './const-value.js';
3
3
  export * from './field-mapping.js';
4
4
  export * from './injection.js';
5
+ export * from './json.js';
5
6
  export * from './resolver.js';
6
7
  export * from './utility.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -2,6 +2,7 @@ export * from './class.js';
2
2
  export * from './const-value.js';
3
3
  export * from './field-mapping.js';
4
4
  export * from './injection.js';
5
+ export * from './json.js';
5
6
  export * from './resolver.js';
6
7
  export * from './utility.js';
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["export * from './class';\nexport * from './const-value';\nexport * from './field-mapping';\nexport * from './injection';\nexport * from './resolver';\nexport * from './utility';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["export * from './class';\nexport * from './const-value';\nexport * from './field-mapping';\nexport * from './injection';\nexport * from './json';\nexport * from './resolver';\nexport * from './utility';\n"]}
@@ -4,7 +4,7 @@ export type TInjectionGetter = <T>(opts: {
4
4
  key: string | symbol;
5
5
  }) => T;
6
6
  /** Something set up by a `configure` call, which may be asynchronous. */
7
- export interface IConfigurable<Options extends object = any, Result = any> {
7
+ export interface IConfigurable<Options extends object = object, Result = unknown> {
8
8
  configure(opts?: Options): ValueOrPromise<Result>;
9
9
  }
10
10
  //# sourceMappingURL=injection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../src/common/types/injection.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueOrPromise } from './utility';\n\n/** Reads one value by binding `key` from the container; the caller supplies `T`. */\nexport type TInjectionGetter = <T>(opts: { key: string | symbol }) => T;\n\n/** Something set up by a `configure` call, which may be asynchronous. */\nexport interface IConfigurable<Options extends object = any, Result = any> {\n configure(opts?: Options): ValueOrPromise<Result>;\n}\n"]}
1
+ {"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../src/common/types/injection.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueOrPromise } from './utility';\n\n/** Reads one value by binding `key` from the container; the caller supplies `T`. */\nexport type TInjectionGetter = <T>(opts: { key: string | symbol }) => T;\n\n/** Something set up by a `configure` call, which may be asynchronous. */\nexport interface IConfigurable<Options extends object = object, Result = unknown> {\n configure(opts?: Options): ValueOrPromise<Result>;\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /** A JSON scalar. */
2
+ export type TJsonPrimitive = string | number | boolean | null;
3
+ /**
4
+ * Any value JSON can hold: a scalar, an array of JSON values, or an object whose values are JSON values. The type of a
5
+ * `jsonb` or JSON column that stores whatever the app puts in it (`jValue` of the data-type enrichers).
6
+ *
7
+ * A value typed as an `interface` is not assignable, because an interface has no index signature: spread it
8
+ * (`{ ...meta }`) or declare its shape as a `type`. A `readonly` array is refused too, at any depth, so an `as const` object that holds one is refused:
9
+ * copy each array (`[...list]`). An `as const` object of scalars is accepted.
10
+ */
11
+ export type TJsonValue = TJsonPrimitive | TJsonValue[] | {
12
+ [key: string]: TJsonValue;
13
+ };
14
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/common/types/json.ts"],"names":[],"mappings":"","sourcesContent":["/** A JSON scalar. */\nexport type TJsonPrimitive = string | number | boolean | null;\n\n/**\n * Any value JSON can hold: a scalar, an array of JSON values, or an object whose values are JSON values. The type of a\n * `jsonb` or JSON column that stores whatever the app puts in it (`jValue` of the data-type enrichers).\n *\n * A value typed as an `interface` is not assignable, because an interface has no index signature: spread it\n * (`{ ...meta }`) or declare its shape as a `type`. A `readonly` array is refused too, at any depth, so an `as const` object that holds one is refused:\n * copy each array (`[...list]`). An `as const` object of scalars is accepted.\n */\nexport type TJsonValue = TJsonPrimitive | TJsonValue[] | { [key: string]: TJsonValue };\n"]}
@@ -1,9 +1,5 @@
1
1
  /** `T`, `undefined` or `null`. */
2
2
  export type TNullable<T> = T | undefined | null;
3
- /** Escape hatch for a value of unknown shape; prefer a real type. */
4
- export type AnyType = any;
5
- /** An object with any string, number or symbol keys. */
6
- export type AnyObject = Record<string | symbol | number, any>;
7
3
  /** An options object of shape `T`; empty by default. */
8
4
  export type TOptions<T extends object = {}> = T;
9
5
  /** `T` or a promise of `T`; `await` it to get `T` either way. */
@@ -1 +1 @@
1
- {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/common/types/utility.ts"],"names":[],"mappings":"","sourcesContent":["/** `T`, `undefined` or `null`. */\nexport type TNullable<T> = T | undefined | null;\n\n/** Escape hatch for a value of unknown shape; prefer a real type. */\nexport type AnyType = any;\n/** An object with any string, number or symbol keys. */\nexport type AnyObject = Record<string | symbol | number, any>;\n\n/** An options object of shape `T`; empty by default. */\nexport type TOptions<T extends object = {}> = T;\n\n/** `T` or a promise of `T`; `await` it to get `T` either way. */\nexport type ValueOrPromise<T> = T | Promise<T>;\n/** The union of the property value types of `T`. */\nexport type ValueOf<T> = T[keyof T];\n\n/** `T` with the keys `K` made optional. */\nexport type ValueOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n/** `T` with every key optional except `K`. */\nexport type ValueOptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;\n\n/** Flattens an intersection of types into one object type, for readable hovers. */\nexport type TPrettify<T> = { [K in keyof T]: T[K] } & {};\n"]}
1
+ {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/common/types/utility.ts"],"names":[],"mappings":"","sourcesContent":["/** `T`, `undefined` or `null`. */\nexport type TNullable<T> = T | undefined | null;\n\n/** An options object of shape `T`; empty by default. */\nexport type TOptions<T extends object = {}> = T;\n\n/** `T` or a promise of `T`; `await` it to get `T` either way. */\nexport type ValueOrPromise<T> = T | Promise<T>;\n/** The union of the property value types of `T`. */\nexport type ValueOf<T> = T[keyof T];\n\n/** `T` with the keys `K` made optional. */\nexport type ValueOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n/** `T` with every key optional except `K`. */\nexport type ValueOptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;\n\n/** Flattens an intersection of types into one object type, for readable hovers. */\nexport type TPrettify<T> = { [K in keyof T]: T[K] } & {};\n"]}