@veryfront/ext-content-mdx 0.1.985

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 (341) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +2 -0
  3. package/README.md +42 -0
  4. package/esm/_dnt.polyfills.d.ts +18 -0
  5. package/esm/_dnt.polyfills.d.ts.map +1 -0
  6. package/esm/_dnt.polyfills.js +15 -0
  7. package/esm/_dnt.shims.d.ts +12 -0
  8. package/esm/_dnt.shims.d.ts.map +1 -0
  9. package/esm/_dnt.shims.js +68 -0
  10. package/esm/deno.d.ts +427 -0
  11. package/esm/deno.d.ts.map +1 -0
  12. package/esm/deno.js +512 -0
  13. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.d.ts +33 -0
  14. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.js +48 -0
  16. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.d.ts +64 -0
  17. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.js +1371 -0
  19. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.d.ts +44 -0
  20. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.js +117 -0
  22. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.d.ts +3 -0
  23. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.js +103 -0
  25. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.d.ts +3 -0
  26. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.js +32 -0
  28. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.d.ts +3 -0
  29. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.js +96 -0
  31. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.d.ts +3 -0
  32. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.js +159 -0
  34. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.d.ts +3 -0
  35. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.js +14 -0
  37. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.d.ts +3 -0
  38. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.js +10 -0
  40. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.d.ts +3 -0
  41. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.js +22 -0
  43. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.d.ts +3 -0
  44. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.js +29 -0
  46. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.d.ts +3 -0
  47. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.js +19 -0
  49. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.d.ts +3 -0
  50. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.js +30 -0
  52. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.d.ts +3 -0
  53. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.js +10 -0
  55. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.d.ts +3 -0
  56. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.js +14 -0
  58. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.d.ts +3 -0
  59. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.d.ts.map +1 -0
  60. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.js +9 -0
  61. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.d.ts +3 -0
  62. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.js +81 -0
  64. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.d.ts +3 -0
  65. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.js +20 -0
  67. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.d.ts +32 -0
  68. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.d.ts.map +1 -0
  69. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.js +6 -0
  70. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.d.ts +4 -0
  71. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.js +13 -0
  73. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.d.ts +76 -0
  74. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.js +91 -0
  76. package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.d.ts +3 -0
  77. package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.d.ts.map +1 -0
  78. package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.js +99 -0
  79. package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.d.ts +3 -0
  80. package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.d.ts.map +1 -0
  81. package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.js +53 -0
  82. package/esm/extensions/ext-content-mdx/src/index.d.ts +31 -0
  83. package/esm/extensions/ext-content-mdx/src/index.d.ts.map +1 -0
  84. package/esm/extensions/ext-content-mdx/src/index.js +56 -0
  85. package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.d.ts +4 -0
  86. package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.d.ts.map +1 -0
  87. package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.js +18 -0
  88. package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.d.ts +20 -0
  89. package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.d.ts.map +1 -0
  90. package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.js +45 -0
  91. package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.d.ts +4 -0
  92. package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.d.ts.map +1 -0
  93. package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.js +69 -0
  94. package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.d.ts +14 -0
  95. package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.d.ts.map +1 -0
  96. package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.js +191 -0
  97. package/esm/package.json +3 -0
  98. package/esm/src/config/defaults.d.ts +39 -0
  99. package/esm/src/config/defaults.d.ts.map +1 -0
  100. package/esm/src/config/defaults.js +65 -0
  101. package/esm/src/errors/error-registry/agent.d.ts +18 -0
  102. package/esm/src/errors/error-registry/agent.d.ts.map +1 -0
  103. package/esm/src/errors/error-registry/agent.js +60 -0
  104. package/esm/src/errors/error-registry/boundary.d.ts +16 -0
  105. package/esm/src/errors/error-registry/boundary.d.ts.map +1 -0
  106. package/esm/src/errors/error-registry/boundary.js +52 -0
  107. package/esm/src/errors/error-registry/build.d.ts +20 -0
  108. package/esm/src/errors/error-registry/build.d.ts.map +1 -0
  109. package/esm/src/errors/error-registry/build.js +68 -0
  110. package/esm/src/errors/error-registry/config.d.ts +22 -0
  111. package/esm/src/errors/error-registry/config.d.ts.map +1 -0
  112. package/esm/src/errors/error-registry/config.js +70 -0
  113. package/esm/src/errors/error-registry/deploy.d.ts +12 -0
  114. package/esm/src/errors/error-registry/deploy.d.ts.map +1 -0
  115. package/esm/src/errors/error-registry/deploy.js +36 -0
  116. package/esm/src/errors/error-registry/dev.d.ts +14 -0
  117. package/esm/src/errors/error-registry/dev.d.ts.map +1 -0
  118. package/esm/src/errors/error-registry/dev.js +44 -0
  119. package/esm/src/errors/error-registry/general.d.ts +29 -0
  120. package/esm/src/errors/error-registry/general.d.ts.map +1 -0
  121. package/esm/src/errors/error-registry/general.js +92 -0
  122. package/esm/src/errors/error-registry/module.d.ts +16 -0
  123. package/esm/src/errors/error-registry/module.d.ts.map +1 -0
  124. package/esm/src/errors/error-registry/module.js +52 -0
  125. package/esm/src/errors/error-registry/route.d.ts +16 -0
  126. package/esm/src/errors/error-registry/route.d.ts.map +1 -0
  127. package/esm/src/errors/error-registry/route.js +52 -0
  128. package/esm/src/errors/error-registry/runtime.d.ts +18 -0
  129. package/esm/src/errors/error-registry/runtime.d.ts.map +1 -0
  130. package/esm/src/errors/error-registry/runtime.js +60 -0
  131. package/esm/src/errors/error-registry/server.d.ts +39 -0
  132. package/esm/src/errors/error-registry/server.d.ts.map +1 -0
  133. package/esm/src/errors/error-registry/server.js +129 -0
  134. package/esm/src/errors/error-registry-helpers.d.ts +6 -0
  135. package/esm/src/errors/error-registry-helpers.d.ts.map +1 -0
  136. package/esm/src/errors/error-registry-helpers.js +9 -0
  137. package/esm/src/errors/error-registry.d.ts +114 -0
  138. package/esm/src/errors/error-registry.d.ts.map +1 -0
  139. package/esm/src/errors/error-registry.js +60 -0
  140. package/esm/src/errors/types.d.ts +84 -0
  141. package/esm/src/errors/types.d.ts.map +1 -0
  142. package/esm/src/errors/types.js +69 -0
  143. package/esm/src/errors/veryfront-error.d.ts +149 -0
  144. package/esm/src/errors/veryfront-error.d.ts.map +1 -0
  145. package/esm/src/errors/veryfront-error.js +61 -0
  146. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts +13 -0
  147. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts.map +1 -0
  148. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.js +55 -0
  149. package/esm/src/observability/tracing/api-shim.d.ts +178 -0
  150. package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
  151. package/esm/src/observability/tracing/api-shim.js +241 -0
  152. package/esm/src/observability/tracing/otlp-setup.d.ts +56 -0
  153. package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -0
  154. package/esm/src/observability/tracing/otlp-setup.js +206 -0
  155. package/esm/src/observability/tracing/telemetry-env.d.ts +3 -0
  156. package/esm/src/observability/tracing/telemetry-env.d.ts.map +1 -0
  157. package/esm/src/observability/tracing/telemetry-env.js +10 -0
  158. package/esm/src/platform/adapters/base.d.ts +188 -0
  159. package/esm/src/platform/adapters/base.d.ts.map +1 -0
  160. package/esm/src/platform/adapters/base.js +15 -0
  161. package/esm/src/platform/compat/constants.d.ts +13 -0
  162. package/esm/src/platform/compat/constants.d.ts.map +1 -0
  163. package/esm/src/platform/compat/constants.js +12 -0
  164. package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
  165. package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
  166. package/esm/src/platform/compat/dynamic-import.js +10 -0
  167. package/esm/src/platform/compat/fs.d.ts +71 -0
  168. package/esm/src/platform/compat/fs.d.ts.map +1 -0
  169. package/esm/src/platform/compat/fs.js +277 -0
  170. package/esm/src/platform/compat/path/basic-operations.d.ts +9 -0
  171. package/esm/src/platform/compat/path/basic-operations.d.ts.map +1 -0
  172. package/esm/src/platform/compat/path/basic-operations.js +56 -0
  173. package/esm/src/platform/compat/path/index.d.ts +13 -0
  174. package/esm/src/platform/compat/path/index.d.ts.map +1 -0
  175. package/esm/src/platform/compat/path/index.js +11 -0
  176. package/esm/src/platform/compat/path/parse-format.d.ts +4 -0
  177. package/esm/src/platform/compat/path/parse-format.d.ts.map +1 -0
  178. package/esm/src/platform/compat/path/parse-format.js +26 -0
  179. package/esm/src/platform/compat/path/resolution.d.ts +6 -0
  180. package/esm/src/platform/compat/path/resolution.d.ts.map +1 -0
  181. package/esm/src/platform/compat/path/resolution.js +121 -0
  182. package/esm/src/platform/compat/path/runtime.d.ts +8 -0
  183. package/esm/src/platform/compat/path/runtime.d.ts.map +1 -0
  184. package/esm/src/platform/compat/path/runtime.js +20 -0
  185. package/esm/src/platform/compat/path/security.d.ts +2 -0
  186. package/esm/src/platform/compat/path/security.d.ts.map +1 -0
  187. package/esm/src/platform/compat/path/security.js +24 -0
  188. package/esm/src/platform/compat/path/types.d.ts +22 -0
  189. package/esm/src/platform/compat/path/types.d.ts.map +1 -0
  190. package/esm/src/platform/compat/path/types.js +1 -0
  191. package/esm/src/platform/compat/path/url-conversion.d.ts +3 -0
  192. package/esm/src/platform/compat/path/url-conversion.d.ts.map +1 -0
  193. package/esm/src/platform/compat/path/url-conversion.js +45 -0
  194. package/esm/src/platform/compat/process/command.d.ts +31 -0
  195. package/esm/src/platform/compat/process/command.d.ts.map +1 -0
  196. package/esm/src/platform/compat/process/command.js +194 -0
  197. package/esm/src/platform/compat/process/env.d.ts +35 -0
  198. package/esm/src/platform/compat/process/env.d.ts.map +1 -0
  199. package/esm/src/platform/compat/process/env.js +194 -0
  200. package/esm/src/platform/compat/process/lifecycle.d.ts +99 -0
  201. package/esm/src/platform/compat/process/lifecycle.d.ts.map +1 -0
  202. package/esm/src/platform/compat/process/lifecycle.js +327 -0
  203. package/esm/src/platform/compat/process/runtime-process.d.ts +10 -0
  204. package/esm/src/platform/compat/process/runtime-process.d.ts.map +1 -0
  205. package/esm/src/platform/compat/process/runtime-process.js +25 -0
  206. package/esm/src/platform/compat/process.d.ts +5 -0
  207. package/esm/src/platform/compat/process.d.ts.map +1 -0
  208. package/esm/src/platform/compat/process.js +4 -0
  209. package/esm/src/platform/compat/runtime.d.ts +51 -0
  210. package/esm/src/platform/compat/runtime.d.ts.map +1 -0
  211. package/esm/src/platform/compat/runtime.js +101 -0
  212. package/esm/src/platform/compat/std/front-matter-yaml.d.ts +13 -0
  213. package/esm/src/platform/compat/std/front-matter-yaml.d.ts.map +1 -0
  214. package/esm/src/platform/compat/std/front-matter-yaml.js +28 -0
  215. package/esm/src/transforms/import-rewriter/url-builder.d.ts +70 -0
  216. package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -0
  217. package/esm/src/transforms/import-rewriter/url-builder.js +152 -0
  218. package/esm/src/transforms/md/utils.d.ts +14 -0
  219. package/esm/src/transforms/md/utils.d.ts.map +1 -0
  220. package/esm/src/transforms/md/utils.js +17 -0
  221. package/esm/src/transforms/mdx/compiler/frontmatter-extractor.d.ts +6 -0
  222. package/esm/src/transforms/mdx/compiler/frontmatter-extractor.d.ts.map +1 -0
  223. package/esm/src/transforms/mdx/compiler/frontmatter-extractor.js +48 -0
  224. package/esm/src/transforms/mdx/compiler/import-rewriter.d.ts +10 -0
  225. package/esm/src/transforms/mdx/compiler/import-rewriter.d.ts.map +1 -0
  226. package/esm/src/transforms/mdx/compiler/import-rewriter.js +87 -0
  227. package/esm/src/utils/base64url.d.ts +6 -0
  228. package/esm/src/utils/base64url.d.ts.map +1 -0
  229. package/esm/src/utils/base64url.js +12 -0
  230. package/esm/src/utils/bundle-manifest.d.ts +63 -0
  231. package/esm/src/utils/bundle-manifest.d.ts.map +1 -0
  232. package/esm/src/utils/bundle-manifest.js +96 -0
  233. package/esm/src/utils/constants/buffers.d.ts +24 -0
  234. package/esm/src/utils/constants/buffers.d.ts.map +1 -0
  235. package/esm/src/utils/constants/buffers.js +23 -0
  236. package/esm/src/utils/constants/build.d.ts +8 -0
  237. package/esm/src/utils/constants/build.d.ts.map +1 -0
  238. package/esm/src/utils/constants/build.js +7 -0
  239. package/esm/src/utils/constants/cache.d.ts +74 -0
  240. package/esm/src/utils/constants/cache.d.ts.map +1 -0
  241. package/esm/src/utils/constants/cache.js +133 -0
  242. package/esm/src/utils/constants/cdn.d.ts +29 -0
  243. package/esm/src/utils/constants/cdn.d.ts.map +1 -0
  244. package/esm/src/utils/constants/cdn.js +58 -0
  245. package/esm/src/utils/constants/crypto.d.ts +10 -0
  246. package/esm/src/utils/constants/crypto.d.ts.map +1 -0
  247. package/esm/src/utils/constants/crypto.js +9 -0
  248. package/esm/src/utils/constants/env.d.ts +16 -0
  249. package/esm/src/utils/constants/env.d.ts.map +1 -0
  250. package/esm/src/utils/constants/env.js +20 -0
  251. package/esm/src/utils/constants/hash.d.ts +5 -0
  252. package/esm/src/utils/constants/hash.d.ts.map +1 -0
  253. package/esm/src/utils/constants/hash.js +4 -0
  254. package/esm/src/utils/constants/hmr.d.ts +24 -0
  255. package/esm/src/utils/constants/hmr.d.ts.map +1 -0
  256. package/esm/src/utils/constants/hmr.js +26 -0
  257. package/esm/src/utils/constants/html.d.ts +13 -0
  258. package/esm/src/utils/constants/html.d.ts.map +1 -0
  259. package/esm/src/utils/constants/html.js +12 -0
  260. package/esm/src/utils/constants/http.d.ts +77 -0
  261. package/esm/src/utils/constants/http.d.ts.map +1 -0
  262. package/esm/src/utils/constants/http.js +76 -0
  263. package/esm/src/utils/constants/index.d.ts +23 -0
  264. package/esm/src/utils/constants/index.d.ts.map +1 -0
  265. package/esm/src/utils/constants/index.js +22 -0
  266. package/esm/src/utils/constants/limits.d.ts +27 -0
  267. package/esm/src/utils/constants/limits.d.ts.map +1 -0
  268. package/esm/src/utils/constants/limits.js +26 -0
  269. package/esm/src/utils/constants/metrics.d.ts +10 -0
  270. package/esm/src/utils/constants/metrics.d.ts.map +1 -0
  271. package/esm/src/utils/constants/metrics.js +34 -0
  272. package/esm/src/utils/constants/network.d.ts +23 -0
  273. package/esm/src/utils/constants/network.d.ts.map +1 -0
  274. package/esm/src/utils/constants/network.js +27 -0
  275. package/esm/src/utils/constants/priorities.d.ts +31 -0
  276. package/esm/src/utils/constants/priorities.d.ts.map +1 -0
  277. package/esm/src/utils/constants/priorities.js +30 -0
  278. package/esm/src/utils/constants/retry.d.ts +14 -0
  279. package/esm/src/utils/constants/retry.d.ts.map +1 -0
  280. package/esm/src/utils/constants/retry.js +13 -0
  281. package/esm/src/utils/constants/security.d.ts +16 -0
  282. package/esm/src/utils/constants/security.d.ts.map +1 -0
  283. package/esm/src/utils/constants/security.js +15 -0
  284. package/esm/src/utils/constants/server.d.ts +107 -0
  285. package/esm/src/utils/constants/server.d.ts.map +1 -0
  286. package/esm/src/utils/constants/server.js +120 -0
  287. package/esm/src/utils/feature-flags.d.ts +7 -0
  288. package/esm/src/utils/feature-flags.d.ts.map +1 -0
  289. package/esm/src/utils/feature-flags.js +8 -0
  290. package/esm/src/utils/hash-utils.d.ts +19 -0
  291. package/esm/src/utils/hash-utils.d.ts.map +1 -0
  292. package/esm/src/utils/hash-utils.js +42 -0
  293. package/esm/src/utils/import-lockfile.d.ts +52 -0
  294. package/esm/src/utils/import-lockfile.d.ts.map +1 -0
  295. package/esm/src/utils/import-lockfile.js +187 -0
  296. package/esm/src/utils/index.d.ts +27 -0
  297. package/esm/src/utils/index.d.ts.map +1 -0
  298. package/esm/src/utils/index.js +25 -0
  299. package/esm/src/utils/logger/components.d.ts +73 -0
  300. package/esm/src/utils/logger/components.d.ts.map +1 -0
  301. package/esm/src/utils/logger/components.js +81 -0
  302. package/esm/src/utils/logger/core.d.ts +73 -0
  303. package/esm/src/utils/logger/core.d.ts.map +1 -0
  304. package/esm/src/utils/logger/core.js +143 -0
  305. package/esm/src/utils/logger/index.d.ts +10 -0
  306. package/esm/src/utils/logger/index.d.ts.map +1 -0
  307. package/esm/src/utils/logger/index.js +9 -0
  308. package/esm/src/utils/logger/logger.d.ts +166 -0
  309. package/esm/src/utils/logger/logger.d.ts.map +1 -0
  310. package/esm/src/utils/logger/logger.js +445 -0
  311. package/esm/src/utils/logger/redact.d.ts +74 -0
  312. package/esm/src/utils/logger/redact.d.ts.map +1 -0
  313. package/esm/src/utils/logger/redact.js +294 -0
  314. package/esm/src/utils/logger/request-context.d.ts +27 -0
  315. package/esm/src/utils/logger/request-context.d.ts.map +1 -0
  316. package/esm/src/utils/logger/request-context.js +28 -0
  317. package/esm/src/utils/memoize.d.ts +19 -0
  318. package/esm/src/utils/memoize.d.ts.map +1 -0
  319. package/esm/src/utils/memoize.js +72 -0
  320. package/esm/src/utils/parallel.d.ts +25 -0
  321. package/esm/src/utils/parallel.d.ts.map +1 -0
  322. package/esm/src/utils/parallel.js +91 -0
  323. package/esm/src/utils/path-utils.d.ts +34 -0
  324. package/esm/src/utils/path-utils.d.ts.map +1 -0
  325. package/esm/src/utils/path-utils.js +138 -0
  326. package/esm/src/utils/perf-timer.d.ts +11 -0
  327. package/esm/src/utils/perf-timer.d.ts.map +1 -0
  328. package/esm/src/utils/perf-timer.js +114 -0
  329. package/esm/src/utils/platform.d.ts +9 -0
  330. package/esm/src/utils/platform.d.ts.map +1 -0
  331. package/esm/src/utils/platform.js +20 -0
  332. package/esm/src/utils/runtime-guards.d.ts +29 -0
  333. package/esm/src/utils/runtime-guards.d.ts.map +1 -0
  334. package/esm/src/utils/runtime-guards.js +23 -0
  335. package/esm/src/utils/version-constant.d.ts +3 -0
  336. package/esm/src/utils/version-constant.d.ts.map +1 -0
  337. package/esm/src/utils/version-constant.js +4 -0
  338. package/esm/src/utils/version.d.ts +17 -0
  339. package/esm/src/utils/version.d.ts.map +1 -0
  340. package/esm/src/utils/version.js +36 -0
  341. package/package.json +80 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Secret / credential redaction for structured log context.
3
+ *
4
+ * Defense-in-depth (#1989): the logger, the error-logging path, and the
5
+ * observability log buffer all accept arbitrary `context`/`data` objects from
6
+ * callers and serialize them to log sinks. There is no guarantee a caller
7
+ * never hands us a tokens object, an `Authorization` header bag, or a request
8
+ * body with a password field. This pass masks values whose *key* looks like a
9
+ * credential before serialization, so an accidental
10
+ * `logger.info("...", { authorization: token })` cannot leak the secret.
11
+ *
12
+ * Scope is intentionally key-based: we do not attempt to find secrets embedded
13
+ * in free-form message strings (too lossy). The deny-list errs toward
14
+ * over-redaction — masking a benign `tokenCount` is acceptable; leaking a real
15
+ * token is not. The traversal fails *closed*: on a cycle, depth overflow, or a
16
+ * throwing getter it returns {@link REDACTED} rather than risk emitting an
17
+ * unredacted object.
18
+ */
19
+ /** Replacement value substituted for any sensitive field. */
20
+ export declare const REDACTED = "[REDACTED]";
21
+ /**
22
+ * Whether a context key names a credential and should have its value masked.
23
+ *
24
+ * Uses substring matching on a normalized key, so `clientSecret`,
25
+ * `x-api-key`, and `refresh_token` all match while benign words that merely
26
+ * *contain* a pattern as a separate token (e.g. `author`) do not — `author`
27
+ * normalizes to `author`, which contains none of the patterns.
28
+ */
29
+ export declare function isSensitiveKey(key: string): boolean;
30
+ /**
31
+ * Returns a redacted deep copy of `context`. Any property whose key is
32
+ * {@link isSensitiveKey} has its value replaced with {@link REDACTED}; nested
33
+ * plain objects, class instances, and arrays are traversed. The input is never
34
+ * mutated, and the pass fails closed (returns {@link REDACTED}) on cycles,
35
+ * depth overflow, or a throwing getter.
36
+ */
37
+ export declare function redactSensitive<T>(context: T): T;
38
+ /**
39
+ * Strip credentials from URL-shaped strings so they can be safely emitted in
40
+ * free-form text (error messages, stacks, lifted `request_url` fields). Unlike
41
+ * {@link redactSensitive}, which is key-based, this scrubs secrets embedded in
42
+ * the *value* itself:
43
+ *
44
+ * - URL userinfo: `http://user:pass@host` → `http://user:[REDACTED]@host`
45
+ * - sensitive query params: `?access_token=abc` → `?access_token=[REDACTED]`
46
+ *
47
+ * It is intentionally tolerant: it operates on any string (a DSN, a Mongo URI,
48
+ * an axios error message containing a URL) via regex rather than requiring a
49
+ * parseable URL, so malformed or partial URLs in error text are still scrubbed.
50
+ * Non-URL strings pass through unchanged.
51
+ */
52
+ export declare function sanitizeUrlCredentials(input: string): string;
53
+ /**
54
+ * Return the URL form safe to attach to observability span attributes.
55
+ *
56
+ * Span attributes bypass the logger's structured redaction pass, so `http.url`
57
+ * must not include query strings, fragments, or URL userinfo. This intentionally
58
+ * strips every query parameter instead of selectively redacting credential-like
59
+ * names because cache keys and callback state can be sensitive even when the
60
+ * parameter name is not obviously a credential.
61
+ */
62
+ export declare function sanitizeUrlForSpan(input: string): string;
63
+ /**
64
+ * Apply {@link sanitizeUrlCredentials} to the `message` and `stack` of a
65
+ * serialized-error-shaped object, returning a new object. Used by the logger's
66
+ * JSON and text paths so errors carrying DSNs, Mongo URIs, or
67
+ * `?access_token=`-bearing URLs do not leak credentials (the serialized error
68
+ * bypasses the key-based redactor). Returns the input unchanged when falsy.
69
+ */
70
+ export declare function sanitizeSerializedError<T extends {
71
+ message?: unknown;
72
+ stack?: unknown;
73
+ } | undefined>(error: T): T;
74
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,eAAe,CAAC;AA8CrC;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAcnD;AA6ED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAEhD;AA2BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA4B5D;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,EAC5D,KAAK,EAAE,CAAC,GAAG,CAAC,CAMb"}
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Secret / credential redaction for structured log context.
3
+ *
4
+ * Defense-in-depth (#1989): the logger, the error-logging path, and the
5
+ * observability log buffer all accept arbitrary `context`/`data` objects from
6
+ * callers and serialize them to log sinks. There is no guarantee a caller
7
+ * never hands us a tokens object, an `Authorization` header bag, or a request
8
+ * body with a password field. This pass masks values whose *key* looks like a
9
+ * credential before serialization, so an accidental
10
+ * `logger.info("...", { authorization: token })` cannot leak the secret.
11
+ *
12
+ * Scope is intentionally key-based: we do not attempt to find secrets embedded
13
+ * in free-form message strings (too lossy). The deny-list errs toward
14
+ * over-redaction — masking a benign `tokenCount` is acceptable; leaking a real
15
+ * token is not. The traversal fails *closed*: on a cycle, depth overflow, or a
16
+ * throwing getter it returns {@link REDACTED} rather than risk emitting an
17
+ * unredacted object.
18
+ */
19
+ import { isRecord } from "./core.js";
20
+ /** Replacement value substituted for any sensitive field. */
21
+ export const REDACTED = "[REDACTED]";
22
+ /**
23
+ * Normalized substrings that mark a key as sensitive. Matching is done against
24
+ * a lowercased, non-alphanumeric-stripped form of the key, so `API-Key`,
25
+ * `api_key`, and `apiKey` all collapse to `apikey` and match.
26
+ *
27
+ * Deliberately omitted to avoid false positives that swamp real logs:
28
+ * - bare `"auth"` (would mask `author`); `authorization`/`authToken` are still
29
+ * covered via `authorization`/`token`.
30
+ * - short tokens like `"dsn"`/`"sas"` (would mask `feedsNamespace`, etc.).
31
+ */
32
+ const SENSITIVE_KEY_PATTERNS = [
33
+ "password",
34
+ "passwd",
35
+ "pwd",
36
+ "passphrase",
37
+ "secret",
38
+ "clientsecret",
39
+ "token",
40
+ "apikey",
41
+ "accesskey",
42
+ "privatekey",
43
+ "credential",
44
+ "authorization",
45
+ "cookie",
46
+ "bearer",
47
+ "jwt",
48
+ "connectionstring",
49
+ "signature",
50
+ "sessionid",
51
+ "sid",
52
+ "otp",
53
+ "mfa",
54
+ "pin",
55
+ "salt",
56
+ "xsrf",
57
+ "csrf",
58
+ ];
59
+ const SENSITIVE_KEY_CACHE_MAX_SIZE = 512;
60
+ const sensitiveKeyCache = new Map();
61
+ /** Stop traversing past this depth to keep the pass cheap and stack-safe. */
62
+ const MAX_DEPTH = 16;
63
+ /**
64
+ * Whether a context key names a credential and should have its value masked.
65
+ *
66
+ * Uses substring matching on a normalized key, so `clientSecret`,
67
+ * `x-api-key`, and `refresh_token` all match while benign words that merely
68
+ * *contain* a pattern as a separate token (e.g. `author`) do not — `author`
69
+ * normalizes to `author`, which contains none of the patterns.
70
+ */
71
+ export function isSensitiveKey(key) {
72
+ const cached = sensitiveKeyCache.get(key);
73
+ if (cached !== undefined)
74
+ return cached;
75
+ const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
76
+ const sensitive = SENSITIVE_KEY_PATTERNS.some((pattern) => normalized.includes(pattern));
77
+ if (sensitiveKeyCache.size >= SENSITIVE_KEY_CACHE_MAX_SIZE) {
78
+ const oldestKey = sensitiveKeyCache.keys().next().value;
79
+ if (oldestKey !== undefined)
80
+ sensitiveKeyCache.delete(oldestKey);
81
+ }
82
+ sensitiveKeyCache.set(key, sensitive);
83
+ return sensitive;
84
+ }
85
+ /**
86
+ * A non-null, non-array object. {@link isRecord} covers class instances too,
87
+ * whose enumerable fields `JSON.stringify` *would* serialize, so we must
88
+ * traverse them to catch secrets.
89
+ */
90
+ function isTraversableRecord(value) {
91
+ return isRecord(value);
92
+ }
93
+ function hasToJson(value) {
94
+ return typeof value.toJSON === "function";
95
+ }
96
+ function redactValue(value, depth, seen) {
97
+ if (Array.isArray(value)) {
98
+ if (depth >= MAX_DEPTH || seen.has(value))
99
+ return REDACTED;
100
+ seen.add(value);
101
+ try {
102
+ return value.map((item) => redactValue(item, depth + 1, seen));
103
+ }
104
+ finally {
105
+ seen.delete(value);
106
+ }
107
+ }
108
+ // Objects defining `toJSON` (Date, URL, custom serializers) are serialized
109
+ // by `JSON.stringify` via the *return value* of `toJSON`, not their own
110
+ // enumerable keys. A key-based pass over the object's own properties would
111
+ // therefore miss credentials smuggled through `toJSON`, e.g.
112
+ // `{ toJSON: () => ({ apiKey: "sk-..." }) }` (CODEX P2). When `toJSON`
113
+ // returns a non-scalar (an object/array that could carry credential keys),
114
+ // redact *that* — the thing actually emitted. When it returns a scalar
115
+ // (Date/URL → ISO string), the original object is left intact, preserving
116
+ // prior behavior and identity.
117
+ if (isRecord(value) && hasToJson(value)) {
118
+ if (depth >= MAX_DEPTH || seen.has(value))
119
+ return REDACTED;
120
+ seen.add(value);
121
+ try {
122
+ const serialized = value.toJSON();
123
+ if (isRecord(serialized) || Array.isArray(serialized)) {
124
+ return redactValue(serialized, depth + 1, seen);
125
+ }
126
+ // Scalar result (string/number/…): the object serializes safely as-is.
127
+ return value;
128
+ }
129
+ catch {
130
+ // A throwing toJSON must never let the raw object (whose own keys we
131
+ // skipped) through: fail closed.
132
+ return REDACTED;
133
+ }
134
+ finally {
135
+ seen.delete(value);
136
+ }
137
+ }
138
+ if (isTraversableRecord(value)) {
139
+ if (depth >= MAX_DEPTH || seen.has(value))
140
+ return REDACTED;
141
+ seen.add(value);
142
+ try {
143
+ const out = {};
144
+ for (const [key, child] of Object.entries(value)) {
145
+ out[key] = isSensitiveKey(key) ? REDACTED : redactValue(child, depth + 1, seen);
146
+ }
147
+ return out;
148
+ }
149
+ catch {
150
+ // A throwing getter (or other access error) must never let an
151
+ // unredacted object through: fail closed.
152
+ return REDACTED;
153
+ }
154
+ finally {
155
+ seen.delete(value);
156
+ }
157
+ }
158
+ // Primitives and scalar-serializing objects (Date, URL, …) are returned
159
+ // untouched: they are not key/value bags we can safely rewrite.
160
+ return value;
161
+ }
162
+ /**
163
+ * Returns a redacted deep copy of `context`. Any property whose key is
164
+ * {@link isSensitiveKey} has its value replaced with {@link REDACTED}; nested
165
+ * plain objects, class instances, and arrays are traversed. The input is never
166
+ * mutated, and the pass fails closed (returns {@link REDACTED}) on cycles,
167
+ * depth overflow, or a throwing getter.
168
+ */
169
+ export function redactSensitive(context) {
170
+ return redactValue(context, 0, new Set());
171
+ }
172
+ /**
173
+ * Query-string parameter names that commonly carry credentials in URLs.
174
+ * Matched case-insensitively against the parameter name.
175
+ */
176
+ const SENSITIVE_URL_PARAMS = [
177
+ "access_token",
178
+ "accesstoken",
179
+ "refresh_token",
180
+ "api_key",
181
+ "apikey",
182
+ "code",
183
+ "token",
184
+ "secret",
185
+ "client_secret",
186
+ "password",
187
+ "passwd",
188
+ "pwd",
189
+ "state",
190
+ "sig",
191
+ "signature",
192
+ "auth",
193
+ ];
194
+ const URL_USERINFO_RE = /(\b[a-z][a-z0-9+.-]*:\/\/)([^/?#@\s]+)@/gi;
195
+ /**
196
+ * Strip credentials from URL-shaped strings so they can be safely emitted in
197
+ * free-form text (error messages, stacks, lifted `request_url` fields). Unlike
198
+ * {@link redactSensitive}, which is key-based, this scrubs secrets embedded in
199
+ * the *value* itself:
200
+ *
201
+ * - URL userinfo: `http://user:pass@host` → `http://user:[REDACTED]@host`
202
+ * - sensitive query params: `?access_token=abc` → `?access_token=[REDACTED]`
203
+ *
204
+ * It is intentionally tolerant: it operates on any string (a DSN, a Mongo URI,
205
+ * an axios error message containing a URL) via regex rather than requiring a
206
+ * parseable URL, so malformed or partial URLs in error text are still scrubbed.
207
+ * Non-URL strings pass through unchanged.
208
+ */
209
+ export function sanitizeUrlCredentials(input) {
210
+ if (typeof input !== "string" || input.length === 0)
211
+ return input;
212
+ // 1) userinfo: scheme://user:pass@ → mask the password (and any bare creds).
213
+ let out = input.replace(URL_USERINFO_RE, (_match, scheme, userinfo) => {
214
+ const colon = userinfo.indexOf(":");
215
+ if (colon === -1) {
216
+ // `scheme://token@host` — the whole userinfo is credential-like.
217
+ return `${scheme}${REDACTED}@`;
218
+ }
219
+ const user = userinfo.slice(0, colon);
220
+ return `${scheme}${user}:${REDACTED}@`;
221
+ });
222
+ // 2) sensitive query/fragment params: `key=value` → `key=[REDACTED]`.
223
+ // Match `?key=`, `&key=`, `;key=` separators and stop at the next delimiter.
224
+ out = out.replace(/([?&;])([a-z0-9_.\-]+)=([^&#;\s]*)/gi, (match, sep, key, _val) => {
225
+ const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
226
+ const sensitive = SENSITIVE_URL_PARAMS.some((p) => normalized === p.replace(/[^a-z0-9]/g, ""));
227
+ return sensitive ? `${sep}${key}=${REDACTED}` : match;
228
+ });
229
+ return out;
230
+ }
231
+ function firstUrlDelimiterIndex(input) {
232
+ const queryIndex = input.indexOf("?");
233
+ const hashIndex = input.indexOf("#");
234
+ if (queryIndex === -1)
235
+ return hashIndex;
236
+ if (hashIndex === -1)
237
+ return queryIndex;
238
+ return Math.min(queryIndex, hashIndex);
239
+ }
240
+ function sanitizeProtocolRelativeUrlForSpan(input) {
241
+ if (!input.startsWith("//"))
242
+ return null;
243
+ try {
244
+ const url = new URL(`https:${input}`);
245
+ return `//${url.host}${url.pathname}`;
246
+ }
247
+ catch (_) {
248
+ return null;
249
+ }
250
+ }
251
+ /**
252
+ * Return the URL form safe to attach to observability span attributes.
253
+ *
254
+ * Span attributes bypass the logger's structured redaction pass, so `http.url`
255
+ * must not include query strings, fragments, or URL userinfo. This intentionally
256
+ * strips every query parameter instead of selectively redacting credential-like
257
+ * names because cache keys and callback state can be sensitive even when the
258
+ * parameter name is not obviously a credential.
259
+ */
260
+ export function sanitizeUrlForSpan(input) {
261
+ if (typeof input !== "string" || input.length === 0)
262
+ return input;
263
+ try {
264
+ const url = new URL(input);
265
+ if (url.origin !== "null")
266
+ return `${url.origin}${url.pathname}`;
267
+ }
268
+ catch (_) {
269
+ // Relative or malformed URL-shaped strings are handled by the fallback.
270
+ }
271
+ const delimiterIndex = firstUrlDelimiterIndex(input);
272
+ const withoutQueryOrFragment = delimiterIndex === -1 ? input : input.slice(0, delimiterIndex);
273
+ const protocolRelativeUrl = sanitizeProtocolRelativeUrlForSpan(withoutQueryOrFragment);
274
+ if (protocolRelativeUrl)
275
+ return protocolRelativeUrl;
276
+ return sanitizeUrlCredentials(withoutQueryOrFragment);
277
+ }
278
+ /**
279
+ * Apply {@link sanitizeUrlCredentials} to the `message` and `stack` of a
280
+ * serialized-error-shaped object, returning a new object. Used by the logger's
281
+ * JSON and text paths so errors carrying DSNs, Mongo URIs, or
282
+ * `?access_token=`-bearing URLs do not leak credentials (the serialized error
283
+ * bypasses the key-based redactor). Returns the input unchanged when falsy.
284
+ */
285
+ export function sanitizeSerializedError(error) {
286
+ if (!error)
287
+ return error;
288
+ const out = { ...error };
289
+ if (typeof out.message === "string")
290
+ out.message = sanitizeUrlCredentials(out.message);
291
+ if (typeof out.stack === "string")
292
+ out.stack = sanitizeUrlCredentials(out.stack);
293
+ return out;
294
+ }
@@ -0,0 +1,27 @@
1
+ /**************************
2
+ * Request Context Store
3
+ *
4
+ * Uses AsyncLocalStorage to propagate request-scoped logger context
5
+ * throughout the call stack without explicit parameter passing.
6
+ *
7
+ * @module utils/logger/request-context
8
+ **************************/
9
+ import { AsyncLocalStorage } from "node:async_hooks";
10
+ import { type Logger } from "./logger.js";
11
+ /** Context for request. */
12
+ export interface RequestContext {
13
+ logger: Logger;
14
+ requestId: string;
15
+ projectSlug?: string;
16
+ projectId?: string;
17
+ domain?: string;
18
+ userId?: string;
19
+ conversationId?: string;
20
+ }
21
+ export declare const requestContextStore: AsyncLocalStorage<RequestContext>;
22
+ export declare function getRequestContext(): RequestContext | undefined;
23
+ export declare function getRequestLogger(): Logger | undefined;
24
+ export declare function runWithRequestContext<T>(context: RequestContext, fn: () => T): T;
25
+ /** Run with request context async. */
26
+ export declare function runWithRequestContextAsync<T>(context: RequestContext, fn: () => Promise<T>): Promise<T>;
27
+ //# sourceMappingURL=request-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;4BAO4B;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkC,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1E,2BAA2B;AAC3B,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,mBAAmB,mCAA0C,CAAC;AAE3E,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEhF;AAED,sCAAsC;AACtC,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,OAAO,EAAE,cAAc,EACvB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -0,0 +1,28 @@
1
+ /**************************
2
+ * Request Context Store
3
+ *
4
+ * Uses AsyncLocalStorage to propagate request-scoped logger context
5
+ * throughout the call stack without explicit parameter passing.
6
+ *
7
+ * @module utils/logger/request-context
8
+ **************************/
9
+ import { AsyncLocalStorage } from "node:async_hooks";
10
+ import { __registerRequestContextGetter } from "./logger.js";
11
+ export const requestContextStore = new AsyncLocalStorage();
12
+ export function getRequestContext() {
13
+ return requestContextStore.getStore();
14
+ }
15
+ export function getRequestLogger() {
16
+ return getRequestContext()?.logger;
17
+ }
18
+ export function runWithRequestContext(context, fn) {
19
+ return requestContextStore.run(context, fn);
20
+ }
21
+ /** Run with request context async. */
22
+ export function runWithRequestContextAsync(context, fn) {
23
+ return requestContextStore.run(context, fn);
24
+ }
25
+ // Register the context getter with the logger module.
26
+ // This allows context-aware loggers to access request context
27
+ // without creating a circular dependency.
28
+ __registerRequestContextGetter(getRequestContext);
@@ -0,0 +1,19 @@
1
+ /** Implement memo cache. */
2
+ export declare class MemoCache<V> {
3
+ private cache;
4
+ get(key: string): V | undefined;
5
+ set(key: string, value: V): void;
6
+ has(key: string): boolean;
7
+ clear(): void;
8
+ size(): number;
9
+ }
10
+ /** Memoize async. */
11
+ export declare function memoizeAsync<Args extends unknown[], Result>(fn: (...args: Args) => Promise<Result>, keyHasher: (...args: Args) => string): (...args: Args) => Promise<Result>;
12
+ /** Memoize. */
13
+ export declare function memoize<Args extends unknown[], Result>(fn: (...args: Args) => Result, keyHasher: (...args: Args) => string): (...args: Args) => Result;
14
+ /**
15
+ * FNV-1a hash algorithm for fast cache key generation.
16
+ * 10-15x faster than JSON.stringify() and uses 70-80% less memory.
17
+ */
18
+ export declare function simpleHash(...values: unknown[]): string;
19
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../src/src/utils/memoize.ts"],"names":[],"mappings":"AAGA,4BAA4B;AAC5B,qBAAa,SAAS,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,CAAwB;IAErC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIhC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,MAAM;CAGf;AA2CD,qBAAqB;AACrB,wBAAgB,YAAY,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACzD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,EACtC,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GACnC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAEpC;AAED,eAAe;AACf,wBAAgB,OAAO,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACpD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAC7B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GACnC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAE3B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAavD"}
@@ -0,0 +1,72 @@
1
+ import { FNV1A_PRIME_32 } from "./constants/crypto.js";
2
+ import { HASH_SEED_FNV1A } from "./constants/hash.js";
3
+ /** Implement memo cache. */
4
+ export class MemoCache {
5
+ cache = new Map();
6
+ get(key) {
7
+ return this.cache.get(key);
8
+ }
9
+ set(key, value) {
10
+ this.cache.set(key, value);
11
+ }
12
+ has(key) {
13
+ return this.cache.has(key);
14
+ }
15
+ clear() {
16
+ this.cache.clear();
17
+ }
18
+ size() {
19
+ return this.cache.size;
20
+ }
21
+ }
22
+ function memoizeWithCache(fn, keyHasher) {
23
+ const cache = new MemoCache();
24
+ const inflight = new Map();
25
+ return (...args) => {
26
+ const key = keyHasher(...args);
27
+ if (cache.has(key)) {
28
+ return cache.get(key);
29
+ }
30
+ const existing = inflight.get(key);
31
+ if (existing)
32
+ return existing;
33
+ const result = fn(...args);
34
+ if (!(result instanceof Promise)) {
35
+ cache.set(key, result);
36
+ return result;
37
+ }
38
+ const promise = result.then((resolved) => {
39
+ cache.set(key, resolved);
40
+ inflight.delete(key);
41
+ return resolved;
42
+ }, (error) => {
43
+ inflight.delete(key);
44
+ throw error;
45
+ });
46
+ inflight.set(key, promise);
47
+ return promise;
48
+ };
49
+ }
50
+ /** Memoize async. */
51
+ export function memoizeAsync(fn, keyHasher) {
52
+ return memoizeWithCache(fn, keyHasher);
53
+ }
54
+ /** Memoize. */
55
+ export function memoize(fn, keyHasher) {
56
+ return memoizeWithCache(fn, keyHasher);
57
+ }
58
+ /**
59
+ * FNV-1a hash algorithm for fast cache key generation.
60
+ * 10-15x faster than JSON.stringify() and uses 70-80% less memory.
61
+ */
62
+ export function simpleHash(...values) {
63
+ let hash = HASH_SEED_FNV1A;
64
+ for (const value of values) {
65
+ const str = typeof value === "string" ? value : String(value);
66
+ for (let i = 0; i < str.length; i++) {
67
+ hash ^= str.charCodeAt(i);
68
+ hash = Math.imul(hash, FNV1A_PRIME_32);
69
+ }
70
+ }
71
+ return (hash >>> 0).toString(36);
72
+ }
@@ -0,0 +1,25 @@
1
+ /*******************************
2
+ * Parallel Execution Utilities
3
+ *
4
+ * Provides utilities for parallel execution with concurrency control.
5
+ * Uses a semaphore to limit the number of concurrent operations.
6
+ *
7
+ * @module core/utils/parallel
8
+ *******************************/
9
+ import { Semaphore } from "../modules/react-loader/ssr-module-loader/concurrency/semaphore.js";
10
+ type ParallelOptions = {
11
+ concurrency?: number;
12
+ semaphore?: Semaphore;
13
+ timeoutMs?: number;
14
+ };
15
+ /** Run parallel map. */
16
+ export declare function parallelMap<T, R>(items: T[], fn: (item: T, index: number) => Promise<R>, options?: ParallelOptions): Promise<R[]>;
17
+ export declare function parallelAll<T extends readonly (() => Promise<unknown>)[]>(fns: T, options?: ParallelOptions): Promise<{
18
+ [K in keyof T]: Awaited<ReturnType<T[K]>>;
19
+ }>;
20
+ export declare function parallelFind<T>(items: T[], predicate: (item: T, index: number) => Promise<boolean>, options?: ParallelOptions): Promise<T | undefined>;
21
+ export declare function parallelFilter<T>(items: T[], predicate: (item: T, index: number) => Promise<boolean>, options?: ParallelOptions): Promise<T[]>;
22
+ export declare function createSemaphore(permits: number): Semaphore;
23
+ export declare function getApiSemaphore(): Semaphore;
24
+ export {};
25
+ //# sourceMappingURL=parallel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../src/src/utils/parallel.ts"],"names":[],"mappings":"AAAA;;;;;;;iCAOiC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,oEAAoE,CAAC;AAY/F,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAgBF,wBAAwB;AACxB,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,CA4Bd;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EACvE,GAAG,EAAE,CAAC,EACN,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,CAMxD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EACvD,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAkCxB;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EACvD,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,CAcd;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAE1D;AAED,wBAAgB,eAAe,IAAI,SAAS,CAE3C"}
@@ -0,0 +1,91 @@
1
+ /*******************************
2
+ * Parallel Execution Utilities
3
+ *
4
+ * Provides utilities for parallel execution with concurrency control.
5
+ * Uses a semaphore to limit the number of concurrent operations.
6
+ *
7
+ * @module core/utils/parallel
8
+ *******************************/
9
+ import { Semaphore } from "../modules/react-loader/ssr-module-loader/concurrency/semaphore.js";
10
+ import { withSpan } from "../observability/tracing/otlp-setup.js";
11
+ import { TIMEOUT_ERROR } from "../errors/error-registry.js";
12
+ const DEFAULT_CONCURRENCY = 20;
13
+ const ACQUIRE_TIMEOUT_MS = 30_000;
14
+ // No maxQueueSize — parallelMap schedules all items via Promise.all,
15
+ // so a queue cap would reject items in large batches instead of letting
16
+ // them progress under the concurrency limit with timeout-based backpressure.
17
+ const apiSemaphore = new Semaphore(DEFAULT_CONCURRENCY);
18
+ async function acquireOrThrow(semaphore, timeoutMs, label) {
19
+ const acquired = await semaphore.tryAcquire(timeoutMs);
20
+ if (acquired)
21
+ return;
22
+ throw TIMEOUT_ERROR.create({
23
+ detail: `${label}: timed out waiting for semaphore after ${timeoutMs}ms (available: ${semaphore.available}, waiting: ${semaphore.waiting})`,
24
+ });
25
+ }
26
+ /** Run parallel map. */
27
+ export function parallelMap(items, fn, options = {}) {
28
+ return withSpan("utils.parallelMap", async () => {
29
+ if (items.length === 0)
30
+ return [];
31
+ const semaphore = options.semaphore ?? apiSemaphore;
32
+ const timeoutMs = options.timeoutMs ?? ACQUIRE_TIMEOUT_MS;
33
+ const results = new Array(items.length);
34
+ await Promise.all(items.map(async (item, index) => {
35
+ await acquireOrThrow(semaphore, timeoutMs, "parallelMap");
36
+ try {
37
+ results[index] = await fn(item, index);
38
+ }
39
+ finally {
40
+ semaphore.release();
41
+ }
42
+ }));
43
+ return results;
44
+ }, {
45
+ "parallel.itemCount": items.length,
46
+ "parallel.timeoutMs": options.timeoutMs ?? ACQUIRE_TIMEOUT_MS,
47
+ });
48
+ }
49
+ export function parallelAll(fns, options = {}) {
50
+ return parallelMap([...fns], (fn) => fn(), options);
51
+ }
52
+ export function parallelFind(items, predicate, options = {}) {
53
+ return withSpan("utils.parallelFind", async () => {
54
+ if (items.length === 0)
55
+ return undefined;
56
+ const semaphore = options.semaphore ?? apiSemaphore;
57
+ const timeoutMs = options.timeoutMs ?? ACQUIRE_TIMEOUT_MS;
58
+ let found;
59
+ let foundIndex = Infinity;
60
+ await Promise.all(items.map(async (item, index) => {
61
+ if (index >= foundIndex)
62
+ return;
63
+ await acquireOrThrow(semaphore, timeoutMs, "parallelFind");
64
+ try {
65
+ if (index >= foundIndex)
66
+ return;
67
+ const matches = await predicate(item, index);
68
+ if (!matches || index >= foundIndex)
69
+ return;
70
+ found = item;
71
+ foundIndex = index;
72
+ }
73
+ finally {
74
+ semaphore.release();
75
+ }
76
+ }));
77
+ return found;
78
+ }, { "parallel.itemCount": items.length });
79
+ }
80
+ export function parallelFilter(items, predicate, options = {}) {
81
+ return withSpan("utils.parallelFilter", async () => {
82
+ const results = await parallelMap(items, async (item, index) => ({ item, keep: await predicate(item, index) }), options);
83
+ return results.filter((r) => r.keep).map((r) => r.item);
84
+ }, { "parallel.itemCount": items.length });
85
+ }
86
+ export function createSemaphore(permits) {
87
+ return new Semaphore(permits);
88
+ }
89
+ export function getApiSemaphore() {
90
+ return apiSemaphore;
91
+ }