logixia 2.0.0 → 2.0.4

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 (231) hide show
  1. package/README.md +46 -29
  2. package/dist/async-context-B05ArHgM.mjs +134 -0
  3. package/dist/async-context-B05ArHgM.mjs.map +1 -0
  4. package/dist/async-context-DTQgi8f7.js +150 -0
  5. package/dist/async-context-DTQgi8f7.js.map +1 -0
  6. package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
  7. package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
  8. package/dist/{azure-monitor.transport-Cn_3Usvu.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
  9. package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
  10. package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
  11. package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
  12. package/dist/{azure-monitor.transport-D7Da4RAb.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
  13. package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
  14. package/dist/azure.d.mts +1 -2
  15. package/dist/azure.d.ts +1 -2
  16. package/dist/azure.js +3 -6
  17. package/dist/azure.mjs +1 -6
  18. package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
  19. package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
  20. package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
  21. package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
  22. package/dist/browser.d.mts +45 -25
  23. package/dist/browser.d.mts.map +1 -1
  24. package/dist/browser.d.ts +45 -25
  25. package/dist/browser.d.ts.map +1 -1
  26. package/dist/browser.js +420 -53
  27. package/dist/browser.js.map +1 -1
  28. package/dist/browser.mjs +421 -56
  29. package/dist/browser.mjs.map +1 -1
  30. package/dist/{builder-0gEzRopq.mjs → builder-D70z6kjj.mjs} +212 -104
  31. package/dist/builder-D70z6kjj.mjs.map +1 -0
  32. package/dist/{builder-D44QktIo.js → builder-M7NoaugM.js} +355 -249
  33. package/dist/builder-M7NoaugM.js.map +1 -0
  34. package/dist/cli/index.js +59 -59
  35. package/dist/cloudwatch.d.mts +1 -2
  36. package/dist/cloudwatch.d.ts +1 -2
  37. package/dist/cloudwatch.js +3 -7
  38. package/dist/cloudwatch.mjs +1 -7
  39. package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
  40. package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
  41. package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
  42. package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
  43. package/dist/{cloudwatch.transport-DsEq633o.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
  44. package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
  45. package/dist/{cloudwatch.transport-UlyZFWMn.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
  46. package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
  47. package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
  48. package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
  49. package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
  50. package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
  51. package/dist/correlation.d.mts +13 -16
  52. package/dist/correlation.d.mts.map +1 -1
  53. package/dist/correlation.d.ts +13 -16
  54. package/dist/correlation.d.ts.map +1 -1
  55. package/dist/correlation.js +58 -9
  56. package/dist/correlation.js.map +1 -1
  57. package/dist/correlation.mjs +56 -6
  58. package/dist/correlation.mjs.map +1 -1
  59. package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
  60. package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
  61. package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
  62. package/dist/entry-fields-RLd1jCoR.js.map +1 -0
  63. package/dist/gcp.d.mts +1 -2
  64. package/dist/gcp.d.ts +1 -2
  65. package/dist/gcp.js +3 -7
  66. package/dist/gcp.mjs +1 -7
  67. package/dist/{gcp.transport-B7oc97sG.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
  68. package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
  69. package/dist/{gcp.transport-GrJurKo8.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
  70. package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
  71. package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
  72. package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
  73. package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
  74. package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
  75. package/dist/{index-DhIoploR.d.ts → index-DwozbmB4.d.ts} +3 -8
  76. package/dist/index-DwozbmB4.d.ts.map +1 -0
  77. package/dist/{index-3mw5gaCw.d.mts → index-xqaJtAZn.d.mts} +3 -8
  78. package/dist/index-xqaJtAZn.d.mts.map +1 -0
  79. package/dist/index.d.mts +106 -165
  80. package/dist/index.d.mts.map +1 -1
  81. package/dist/index.d.ts +105 -164
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +164 -261
  84. package/dist/index.js.map +1 -1
  85. package/dist/index.mjs +147 -243
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/internal-log-b0Vp4qrB.js +183 -0
  88. package/dist/internal-log-b0Vp4qrB.js.map +1 -0
  89. package/dist/internal-log-uCSd1PMc.mjs +142 -0
  90. package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
  91. package/dist/{logitron-logger-UVeN-mQm.d.ts → logitron-logger-D2B75Oc7.d.ts} +116 -8
  92. package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
  93. package/dist/{logitron-logger-BFDSO8Io.d.mts → logitron-logger-oEd6wNhf.d.mts} +116 -8
  94. package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
  95. package/dist/middleware.d.mts +10 -12
  96. package/dist/middleware.d.mts.map +1 -1
  97. package/dist/middleware.d.ts +10 -12
  98. package/dist/middleware.d.ts.map +1 -1
  99. package/dist/middleware.js +16 -47
  100. package/dist/middleware.js.map +1 -1
  101. package/dist/middleware.mjs +13 -45
  102. package/dist/middleware.mjs.map +1 -1
  103. package/dist/nest.d.mts +26 -44
  104. package/dist/nest.d.mts.map +1 -1
  105. package/dist/nest.d.ts +26 -44
  106. package/dist/nest.d.ts.map +1 -1
  107. package/dist/nest.js +116 -132
  108. package/dist/nest.js.map +1 -1
  109. package/dist/nest.mjs +59 -73
  110. package/dist/nest.mjs.map +1 -1
  111. package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
  112. package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
  113. package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
  114. package/dist/request-trace-wTJdKp6-.js.map +1 -0
  115. package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
  116. package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
  117. package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
  118. package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
  119. package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
  120. package/dist/{search-CNh9uVwR.d.ts → search-BH33XhuU.d.mts} +2 -22
  121. package/dist/search-BH33XhuU.d.mts.map +1 -0
  122. package/dist/{search-BFbu_oVn.mjs → search-CWMVYC-R.mjs} +22 -39
  123. package/dist/search-CWMVYC-R.mjs.map +1 -0
  124. package/dist/{search-DXANsQ2n.d.mts → search-CazwyX5Z.d.ts} +2 -22
  125. package/dist/search-CazwyX5Z.d.ts.map +1 -0
  126. package/dist/{search-C4V0OMEn.js → search-DUfWuzFP.js} +52 -69
  127. package/dist/search-DUfWuzFP.js.map +1 -0
  128. package/dist/search.d.mts +2 -4
  129. package/dist/search.d.ts +2 -4
  130. package/dist/search.js +3 -4
  131. package/dist/search.mjs +1 -4
  132. package/dist/secret-config-BegMLkYl.mjs +209 -0
  133. package/dist/secret-config-BegMLkYl.mjs.map +1 -0
  134. package/dist/secret-config-CBZBs0p1.js +271 -0
  135. package/dist/secret-config-CBZBs0p1.js.map +1 -0
  136. package/dist/{slack.transport-Bzw7sucI.mjs → slack.transport-Ce96JBDk.mjs} +212 -31
  137. package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
  138. package/dist/{slack.transport-BfJRouB2.js → slack.transport-Dlx3xvb7.js} +234 -41
  139. package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
  140. package/dist/{slack.transport-BZzoXDPn.d.mts → slack.transport-DrirgDNy.d.ts} +56 -9
  141. package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
  142. package/dist/{slack.transport-CXjQYOes.d.ts → slack.transport-DxHOXlLu.d.mts} +56 -9
  143. package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
  144. package/dist/testing.d.mts +3 -8
  145. package/dist/testing.d.mts.map +1 -1
  146. package/dist/testing.d.ts +3 -8
  147. package/dist/testing.d.ts.map +1 -1
  148. package/dist/testing.js +3 -4
  149. package/dist/testing.js.map +1 -1
  150. package/dist/testing.mjs +2 -3
  151. package/dist/testing.mjs.map +1 -1
  152. package/dist/{transport.manager-CXbKKdVE.js → transport.manager-DkcEOlqV.js} +164 -160
  153. package/dist/transport.manager-DkcEOlqV.js.map +1 -0
  154. package/dist/{transport.manager-BiuCAJd2.mjs → transport.manager-eZ_EeC00.mjs} +108 -99
  155. package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
  156. package/dist/{transport.types-CGoHpWQR.d.ts → transport.types-BJVL1QQl.d.mts} +1 -3
  157. package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
  158. package/dist/{transport.types-BMnurPcc.d.mts → transport.types-BJVL1QQl.d.ts} +1 -3
  159. package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
  160. package/dist/transports.d.mts +22 -36
  161. package/dist/transports.d.mts.map +1 -1
  162. package/dist/transports.d.ts +22 -36
  163. package/dist/transports.d.ts.map +1 -1
  164. package/dist/transports.js +10 -13
  165. package/dist/transports.mjs +7 -13
  166. package/dist/worker-entry.js +337 -87
  167. package/dist/worker.d.mts +1 -2
  168. package/dist/worker.d.ts +1 -2
  169. package/dist/worker.js +3 -4
  170. package/dist/worker.mjs +1 -4
  171. package/dist/{worker.transport-CdzSZJmw.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
  172. package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
  173. package/dist/{worker.transport-BdPxu3PN.js → worker.transport-C6GNl_r2.js} +44 -14
  174. package/dist/worker.transport-C6GNl_r2.js.map +1 -0
  175. package/dist/{worker.transport-lPxO2MVL.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
  176. package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
  177. package/dist/{worker.transport-JvGPog3C.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
  178. package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
  179. package/package.json +19 -11
  180. package/dist/async-context-BzJrbfQs.mjs +0 -72
  181. package/dist/async-context-BzJrbfQs.mjs.map +0 -1
  182. package/dist/async-context-DyQQYq3I.js +0 -92
  183. package/dist/async-context-DyQQYq3I.js.map +0 -1
  184. package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
  185. package/dist/azure-monitor.transport-Cn_3Usvu.d.ts.map +0 -1
  186. package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
  187. package/dist/azure-monitor.transport-D7Da4RAb.d.mts.map +0 -1
  188. package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
  189. package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
  190. package/dist/builder-0gEzRopq.mjs.map +0 -1
  191. package/dist/builder-D44QktIo.js.map +0 -1
  192. package/dist/chunk-DLSkYcPk.mjs +0 -7
  193. package/dist/chunk-nOFOJqeH.js +0 -30
  194. package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
  195. package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
  196. package/dist/cloudwatch.transport-DsEq633o.d.ts.map +0 -1
  197. package/dist/cloudwatch.transport-UlyZFWMn.d.mts.map +0 -1
  198. package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
  199. package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
  200. package/dist/gcp.transport-B7oc97sG.d.ts.map +0 -1
  201. package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
  202. package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
  203. package/dist/gcp.transport-GrJurKo8.d.mts.map +0 -1
  204. package/dist/index-3mw5gaCw.d.mts.map +0 -1
  205. package/dist/index-DhIoploR.d.ts.map +0 -1
  206. package/dist/internal-log-BUJYMZbE.js +0 -70
  207. package/dist/internal-log-BUJYMZbE.js.map +0 -1
  208. package/dist/internal-log-Cm8SOWSV.mjs +0 -52
  209. package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
  210. package/dist/logitron-logger-BFDSO8Io.d.mts.map +0 -1
  211. package/dist/logitron-logger-UVeN-mQm.d.ts.map +0 -1
  212. package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
  213. package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
  214. package/dist/search-BFbu_oVn.mjs.map +0 -1
  215. package/dist/search-C4V0OMEn.js.map +0 -1
  216. package/dist/search-CNh9uVwR.d.ts.map +0 -1
  217. package/dist/search-DXANsQ2n.d.mts.map +0 -1
  218. package/dist/slack.transport-BZzoXDPn.d.mts.map +0 -1
  219. package/dist/slack.transport-BfJRouB2.js.map +0 -1
  220. package/dist/slack.transport-Bzw7sucI.mjs.map +0 -1
  221. package/dist/slack.transport-CXjQYOes.d.ts.map +0 -1
  222. package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
  223. package/dist/trace.utils-DpBOLDtq.js.map +0 -1
  224. package/dist/transport.manager-BiuCAJd2.mjs.map +0 -1
  225. package/dist/transport.manager-CXbKKdVE.js.map +0 -1
  226. package/dist/transport.types-BMnurPcc.d.mts.map +0 -1
  227. package/dist/transport.types-CGoHpWQR.d.ts.map +0 -1
  228. package/dist/worker.transport-BdPxu3PN.js.map +0 -1
  229. package/dist/worker.transport-CdzSZJmw.d.ts.map +0 -1
  230. package/dist/worker.transport-JvGPog3C.d.mts.map +0 -1
  231. package/dist/worker.transport-lPxO2MVL.mjs.map +0 -1
package/README.md CHANGED
@@ -982,23 +982,33 @@ const incomingTraceId = extractTraceId(req, {
982
982
  ### Express / Fastify middleware
983
983
 
984
984
  ```typescript
985
- import { traceMiddleware } from 'logixia';
986
-
987
- // Zero-config — reads from traceparent / x-trace-id / x-request-id / x-correlation-id
988
- // and generates a UUID v4 if none is present. Sets X-Trace-Id on the response.
989
- app.use(traceMiddleware());
985
+ import { createExpressContextMiddleware, createFastifyContextHook } from 'logixia';
986
+
987
+ // Express: trace ID = first present header of traceIdHeader (default
988
+ // DEFAULT_TRACE_HEADERS: traceparent, x-trace-id, x-request-id, x-correlation-id,
989
+ // trace-id; traceparent is parsed to its 32-hex trace id), else request.id, else a
990
+ // generated UUID. The ID is available via getCurrentTraceId() and is the logger's
991
+ // top-level traceId for everything inside the request. No response header is set
992
+ // unless you ask for one with responseHeader.
993
+ app.use(createExpressContextMiddleware({ responseHeader: 'X-Trace-Id' }));
994
+
995
+ // Fastify: same resolution; fastify's default counter ids ('req-1', ...) are never
996
+ // used as trace IDs. Also shared with createFastifyPlugin() from 'logixia/middleware'.
997
+ // traceIdHeader accepts a single name or a list; responseHeader works as above.
998
+ fastify.addHook('onRequest', createFastifyContextHook());
999
+
1000
+ // Prefer full control? Wrap the request yourself:
1001
+ app.use((req, res, next) => {
1002
+ const traceId =
1003
+ extractTraceId(req, { header: DEFAULT_TRACE_HEADERS, query: ['traceId'] }) ?? generateTraceId();
1004
+ res.setHeader('X-Trace-Id', traceId);
1005
+ runWithTraceId(traceId, () => next());
1006
+ });
990
1007
 
991
- // With custom config:
992
- app.use(
993
- traceMiddleware({
994
- enabled: true,
995
- generator: () => `req_${crypto.randomUUID()}`,
996
- extractor: {
997
- header: ['x-trace-id', 'traceparent'],
998
- query: ['traceId'],
999
- },
1000
- })
1001
- );
1008
+ // Request/response logging (separate from tracing) lives in 'logixia/middleware':
1009
+ // app.use(createExpressMiddleware(logger));
1010
+ // await fastify.register(createFastifyPlugin(logger));
1011
+ // NestJS: import { TraceMiddleware } from 'logixia/nest';
1002
1012
 
1003
1013
  // Service layer — no parameters needed, trace ID propagates automatically
1004
1014
  class OrderService {
@@ -1531,6 +1541,8 @@ const logger = new BrowserLogger({
1531
1541
  });
1532
1542
  ```
1533
1543
 
1544
+ Delivery failures (network errors and non-OK HTTP statuses) are counted in `failedFlushes` / `lastError` and passed to the optional `onError` callback. A throttled (at most one per minute) console report containing only the error name, HTTP status and endpoint host is printed everywhere except real browser pages, where it is silent by default; set `silent: true` or `silent: false` to override. Entries written to the transport from inside `onError` or while a report is printed are dropped (counted in `dropped`) to avoid feedback loops.
1545
+
1534
1546
  **Cloudflare Workers** — see [`examples/cloudflare-worker/`](./examples/cloudflare-worker/) for a Worker that logs JSON, tags each request with `child({ requestId })` and flushes a `BrowserRemoteTransport` with `ctx.waitUntil()`. Pass `flushIntervalMs: 0` to the transport: Workers don't allow timers at global scope.
1535
1547
 
1536
1548
  The following utilities from the main package are also re-exported from `logixia/browser` (safe for non-Node runtimes):
@@ -1739,24 +1751,27 @@ interface TransportLogEntry {
1739
1751
  Query your in-memory log history without shipping to Elasticsearch, Datadog, or any external service. Useful in development and lightweight production setups:
1740
1752
 
1741
1753
  ```typescript
1742
- import { SearchManager } from 'logixia';
1754
+ import { SearchManager } from 'logixia/search';
1743
1755
 
1744
- const search = new SearchManager({ maxEntries: 10_000 });
1756
+ const search = new SearchManager({ maxIndexSize: 10_000 });
1745
1757
 
1746
1758
  // Index a batch of entries (from a file, database query, or any source)
1747
- await search.index(logEntries);
1748
-
1749
- // Search by text query, level, and time range
1750
- const results = await search.search({
1751
- query: 'payment failed',
1752
- level: 'error',
1753
- from: new Date('2025-01-01'),
1754
- to: new Date(),
1755
- limit: 50,
1756
- });
1757
- // → sorted by relevance, full metadata included
1759
+ await search.indexLogs(logEntries); // or: await search.indexLog(entry)
1760
+
1761
+ // Search by text, with filters and options
1762
+ const results = await search.search(
1763
+ 'payment failed',
1764
+ { levels: ['error'], timeRange: { start: new Date('2025-01-01'), end: new Date() } },
1765
+ { limit: 50 }
1766
+ );
1767
+ // → sorted by relevance, each result is { log, score, ... }
1768
+
1769
+ const nl = await search.naturalLanguageSearch('payment errors'); // plain-English query
1770
+ const trace = await search.correlateByTraceId('req-001'); // every log of one request
1758
1771
  ```
1759
1772
 
1773
+ The same code runs as [`examples/search-readme.ts`](examples/search-readme.ts).
1774
+
1760
1775
  ---
1761
1776
 
1762
1777
  ## OpenTelemetry
@@ -1810,6 +1825,8 @@ const logger = createLogger({
1810
1825
  // trace↔log correlation. Buffers drain on close() — no loss on shutdown.
1811
1826
  ```
1812
1827
 
1828
+ Import it from `logixia` or `logixia/transports`. Ready-made configs (URL and auth headers) for Grafana Loki / Grafana Cloud, Axiom, Better Stack and a local OpenTelemetry Collector are in [docs/otlp-recipes.md](docs/otlp-recipes.md).
1829
+
1813
1830
  ---
1814
1831
 
1815
1832
  ## Wide events / canonical log lines
@@ -0,0 +1,134 @@
1
+ import { n as resolveTraceHeaders, o as TraceContext, t as resolveRequestTraceId } from "./request-trace-C_fvIDv4.mjs";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+ // src/context/async-context.ts
4
+ /**
5
+ * LogixiaContext — Zero-boilerplate AsyncLocalStorage context propagation.
6
+ *
7
+ * Lets every `logger.info()` call inside a context automatically pick up stored
8
+ * fields (requestId, userId, tenantId, …) without passing them through every function.
9
+ *
10
+ * Works across `Promise.all`, `setTimeout`, and event emitters — anything that
11
+ * inherits the async execution context.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { LogixiaContext } from 'logixia';
16
+ *
17
+ * // Wrap a request handler:
18
+ * app.use((req, res, next) => {
19
+ * LogixiaContext.run({ requestId: req.id, userId: req.user?.id }, next);
20
+ * });
21
+ *
22
+ * // Anywhere deeper in the call tree:
23
+ * async function processOrder(orderId: string) {
24
+ * const ctx = LogixiaContext.get(); // { requestId, userId, orderId }
25
+ * logger.info('Processing order', { orderId, ...ctx });
26
+ * }
27
+ * ```
28
+ */
29
+ const _storage = new AsyncLocalStorage();
30
+ const LogixiaContext = {
31
+ /**
32
+ * Run `callback` inside an async context that carries `store` fields.
33
+ * All loggers queried within `callback` (and its async descendants) will
34
+ * automatically see these fields.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * LogixiaContext.run({ requestId: 'abc', userId: '42' }, async () => {
39
+ * await processOrder(); // sees requestId + userId in every log
40
+ * });
41
+ * ```
42
+ */
43
+ run(store, callback) {
44
+ const parent = _storage.getStore() ?? {};
45
+ const scoped = () => _storage.run({
46
+ ...parent,
47
+ ...store
48
+ }, callback);
49
+ const traceId = store.traceId;
50
+ if (typeof traceId !== "string" || traceId === "") return scoped();
51
+ const trace = TraceContext.instance;
52
+ return trace.storage.run({
53
+ ...trace.storage.getStore(),
54
+ [trace.contextKey]: traceId
55
+ }, scoped);
56
+ },
57
+ /**
58
+ * Return the context fields active in the current async scope.
59
+ * Returns `undefined` when called outside any `LogixiaContext.run()`.
60
+ */
61
+ get() {
62
+ return _storage.getStore();
63
+ },
64
+ /**
65
+ * Merge `fields` into the **existing** context for the current scope.
66
+ * If called outside a `run()` context this is a no-op (logs a dev warning).
67
+ */
68
+ set(fields) {
69
+ const store = _storage.getStore();
70
+ if (!store) return;
71
+ for (const key of Object.keys(fields)) {
72
+ if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
73
+ store[key] = fields[key];
74
+ }
75
+ },
76
+ /**
77
+ * Retrieve the underlying `AsyncLocalStorage` instance.
78
+ * Useful for advanced use-cases like custom middleware.
79
+ */
80
+ getStorage() {
81
+ return _storage;
82
+ }
83
+ };
84
+ function buildScope(request, options, headers) {
85
+ return {
86
+ ...options.enrich ? options.enrich(request) : {},
87
+ traceId: resolveRequestTraceId(request, headers)
88
+ };
89
+ }
90
+ /**
91
+ * Create an Express/Connect-compatible middleware that wraps each request in
92
+ * a `LogixiaContext.run()` scope populated with common request fields.
93
+ *
94
+ * Trace ID: the first present header of `traceIdHeader` (default
95
+ * `DEFAULT_TRACE_HEADERS`, `traceparent` parsed), else `request.id`, else a
96
+ * generated UUID. It is available via `getCurrentTraceId()` and is the logger's
97
+ * top-level `traceId` inside the request. No response header is set unless
98
+ * `responseHeader` is given.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import { createExpressContextMiddleware } from 'logixia';
103
+ * app.use(createExpressContextMiddleware({ responseHeader: 'x-trace-id' }));
104
+ * ```
105
+ */
106
+ function createExpressContextMiddleware(options = {}) {
107
+ const headers = resolveTraceHeaders(options.traceIdHeader);
108
+ return function logixiaContextMiddleware(req, res, next) {
109
+ var _res$setHeader;
110
+ const scope = buildScope(req, options, headers);
111
+ if (options.responseHeader) (_res$setHeader = res.setHeader) === null || _res$setHeader === void 0 || _res$setHeader.call(res, options.responseHeader, scope.traceId);
112
+ LogixiaContext.run(scope, next);
113
+ };
114
+ }
115
+ /**
116
+ * Create a Fastify lifecycle hook that wraps each request in a context scope.
117
+ *
118
+ * Register with `fastify.addHook('onRequest', createFastifyContextHook())`.
119
+ * Resolves the trace ID exactly like {@link createExpressContextMiddleware} and
120
+ * shares it with `createFastifyPlugin()` from `logixia/middleware`. Fastify's
121
+ * default counter `request.id` (`req-1`, ...) is never used as a trace ID.
122
+ */
123
+ function createFastifyContextHook(options = {}) {
124
+ const headers = resolveTraceHeaders(options.traceIdHeader);
125
+ return function logixiaFastifyHook(request, reply, done) {
126
+ var _reply$header;
127
+ const scope = buildScope(request, options, headers);
128
+ if (options.responseHeader) (_reply$header = reply.header) === null || _reply$header === void 0 || _reply$header.call(reply, options.responseHeader, scope.traceId);
129
+ LogixiaContext.run(scope, done);
130
+ };
131
+ }
132
+ export { createExpressContextMiddleware as n, createFastifyContextHook as r, LogixiaContext as t };
133
+
134
+ //# sourceMappingURL=async-context-B05ArHgM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-context-B05ArHgM.mjs","names":[],"sources":["../src/context/async-context.ts"],"sourcesContent":["/**\n * LogixiaContext — Zero-boilerplate AsyncLocalStorage context propagation.\n *\n * Lets every `logger.info()` call inside a context automatically pick up stored\n * fields (requestId, userId, tenantId, …) without passing them through every function.\n *\n * Works across `Promise.all`, `setTimeout`, and event emitters — anything that\n * inherits the async execution context.\n *\n * @example\n * ```ts\n * import { LogixiaContext } from 'logixia';\n *\n * // Wrap a request handler:\n * app.use((req, res, next) => {\n * LogixiaContext.run({ requestId: req.id, userId: req.user?.id }, next);\n * });\n *\n * // Anywhere deeper in the call tree:\n * async function processOrder(orderId: string) {\n * const ctx = LogixiaContext.get(); // { requestId, userId, orderId }\n * logger.info('Processing order', { orderId, ...ctx });\n * }\n * ```\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport {\n type ContextRequestLike,\n resolveRequestTraceId,\n resolveTraceHeaders,\n type TraceHeaderOption,\n} from '../utils/request-trace';\nimport { TraceContext } from '../utils/trace.utils';\n\nexport interface LogContext {\n traceId?: string;\n spanId?: string;\n userId?: string;\n tenantId?: string;\n sessionId?: string;\n [key: string]: unknown;\n}\n\n// Module-level singleton so all loggers share the same ALS store.\nconst _storage = new AsyncLocalStorage<LogContext>();\n\nexport const LogixiaContext = {\n /**\n * Run `callback` inside an async context that carries `store` fields.\n * All loggers queried within `callback` (and its async descendants) will\n * automatically see these fields.\n *\n * @example\n * ```ts\n * LogixiaContext.run({ requestId: 'abc', userId: '42' }, async () => {\n * await processOrder(); // sees requestId + userId in every log\n * });\n * ```\n */\n run<T>(store: LogContext, callback: () => T): T {\n const parent = _storage.getStore() ?? {};\n const scoped = (): T => _storage.run({ ...parent, ...store }, callback);\n const traceId = store.traceId;\n if (typeof traceId !== 'string' || traceId === '') return scoped();\n // An explicit traceId also becomes the TraceContext ID, so getCurrentTraceId(),\n // the logger, outbound propagation and the OTel bridge all see the same value.\n const trace = TraceContext.instance;\n return trace.storage.run({ ...trace.storage.getStore(), [trace.contextKey]: traceId }, scoped);\n },\n\n /**\n * Return the context fields active in the current async scope.\n * Returns `undefined` when called outside any `LogixiaContext.run()`.\n */\n get(): LogContext | undefined {\n return _storage.getStore();\n },\n\n /**\n * Merge `fields` into the **existing** context for the current scope.\n * If called outside a `run()` context this is a no-op (logs a dev warning).\n */\n set(fields: Partial<LogContext>): void {\n const store = _storage.getStore();\n if (!store) {\n // Silently ignore — avoids crashing in code that may call setContext\n // before a request context is established (e.g. background jobs).\n return;\n }\n for (const key of Object.keys(fields)) {\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n store[key] = fields[key];\n }\n },\n\n /**\n * Retrieve the underlying `AsyncLocalStorage` instance.\n * Useful for advanced use-cases like custom middleware.\n */\n getStorage(): AsyncLocalStorage<LogContext> {\n return _storage;\n },\n};\n\nexport type { ContextRequestLike };\n\ninterface ContextHelperOptions<Req extends ContextRequestLike> {\n /**\n * Extract additional fields from the request. A `traceId` returned here is ignored:\n * the resolved request trace ID always wins.\n */\n enrich?: (request: Req & Record<string, unknown>) => Partial<LogContext>;\n /**\n * Header name, or list of names tried in order, to read the trace ID from.\n * Default: `DEFAULT_TRACE_HEADERS` (traceparent is parsed to its 32-hex trace id).\n */\n traceIdHeader?: TraceHeaderOption;\n /**\n * Echo the resolved trace ID on the response under this header name.\n * Default: `false` (no response header is set).\n */\n responseHeader?: string | false;\n}\n\nfunction buildScope<Req extends ContextRequestLike>(\n request: Req,\n options: ContextHelperOptions<Req>,\n headers: readonly string[]\n): LogContext {\n const extra = options.enrich ? options.enrich(request as Req & Record<string, unknown>) : {};\n return { ...extra, traceId: resolveRequestTraceId(request, headers) };\n}\n\n/**\n * Create an Express/Connect-compatible middleware that wraps each request in\n * a `LogixiaContext.run()` scope populated with common request fields.\n *\n * Trace ID: the first present header of `traceIdHeader` (default\n * `DEFAULT_TRACE_HEADERS`, `traceparent` parsed), else `request.id`, else a\n * generated UUID. It is available via `getCurrentTraceId()` and is the logger's\n * top-level `traceId` inside the request. No response header is set unless\n * `responseHeader` is given.\n *\n * @example\n * ```ts\n * import { createExpressContextMiddleware } from 'logixia';\n * app.use(createExpressContextMiddleware({ responseHeader: 'x-trace-id' }));\n * ```\n */\nexport function createExpressContextMiddleware<Req extends ContextRequestLike = ContextRequestLike>(\n options: ContextHelperOptions<Req> = {}\n) {\n const headers = resolveTraceHeaders(options.traceIdHeader);\n\n return function logixiaContextMiddleware(\n req: Req,\n res: { setHeader?: (name: string, value: string) => unknown },\n next: () => void\n ): void {\n const scope = buildScope(req, options, headers);\n if (options.responseHeader) res.setHeader?.(options.responseHeader, scope.traceId as string);\n LogixiaContext.run(scope, next);\n };\n}\n\n/**\n * Create a Fastify lifecycle hook that wraps each request in a context scope.\n *\n * Register with `fastify.addHook('onRequest', createFastifyContextHook())`.\n * Resolves the trace ID exactly like {@link createExpressContextMiddleware} and\n * shares it with `createFastifyPlugin()` from `logixia/middleware`. Fastify's\n * default counter `request.id` (`req-1`, ...) is never used as a trace ID.\n */\nexport function createFastifyContextHook<Req extends ContextRequestLike = ContextRequestLike>(\n options: ContextHelperOptions<Req> = {}\n) {\n const headers = resolveTraceHeaders(options.traceIdHeader);\n\n return function logixiaFastifyHook(\n request: Req,\n reply: { header?: (name: string, value: string) => unknown },\n done: () => void\n ): void {\n const scope = buildScope(request, options, headers);\n if (options.responseHeader) reply.header?.(options.responseHeader, scope.traceId as string);\n LogixiaContext.run(scope, done);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,WAAW,IAAI,kBAA8B;AAEnD,MAAa,iBAAiB;;;;;;;;;;;;;CAa5B,IAAO,OAAmB,UAAsB;EAC9C,MAAM,SAAS,SAAS,SAAS,KAAK,CAAC;EACvC,MAAM,eAAkB,SAAS,IAAI;GAAE,GAAG;GAAQ,GAAG;EAAM,GAAG,QAAQ;EACtE,MAAM,UAAU,MAAM;EACtB,IAAI,OAAO,YAAY,YAAY,YAAY,IAAI,OAAO,OAAO;EAGjE,MAAM,QAAQ,aAAa;EAC3B,OAAO,MAAM,QAAQ,IAAI;GAAE,GAAG,MAAM,QAAQ,SAAS;IAAI,MAAM,aAAa;EAAQ,GAAG,MAAM;CAC/F;;;;;CAMA,MAA8B;EAC5B,OAAO,SAAS,SAAS;CAC3B;;;;;CAMA,IAAI,QAAmC;EACrC,MAAM,QAAQ,SAAS,SAAS;EAChC,IAAI,CAAC,OAGH;EAEF,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;GACrC,IAAI,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ,aAAa;GACzE,MAAM,OAAO,OAAO;EACtB;CACF;;;;;CAMA,aAA4C;EAC1C,OAAO;CACT;AACF;AAsBA,SAAS,WACP,SACA,SACA,SACY;CAEZ,OAAO;EAAE,GADK,QAAQ,SAAS,QAAQ,OAAO,OAAwC,IAAI,CAAC;EACxE,SAAS,sBAAsB,SAAS,OAAO;CAAE;AACtE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,+BACd,UAAqC,CAAC,GACtC;CACA,MAAM,UAAU,oBAAoB,QAAQ,aAAa;CAEzD,OAAO,SAAS,yBACd,KACA,KACA,MACM;;EACN,MAAM,QAAQ,WAAW,KAAK,SAAS,OAAO;EAC9C,IAAI,QAAQ,gBAAgB,CAAA,iBAAA,IAAI,eAAA,QAAA,mBAAA,KAAA,KAAA,eAAA,KAAA,KAAY,QAAQ,gBAAgB,MAAM,OAAiB;EAC3F,eAAe,IAAI,OAAO,IAAI;CAChC;AACF;;;;;;;;;AAUA,SAAgB,yBACd,UAAqC,CAAC,GACtC;CACA,MAAM,UAAU,oBAAoB,QAAQ,aAAa;CAEzD,OAAO,SAAS,mBACd,SACA,OACA,MACM;;EACN,MAAM,QAAQ,WAAW,SAAS,SAAS,OAAO;EAClD,IAAI,QAAQ,gBAAgB,CAAA,gBAAA,MAAM,YAAA,QAAA,kBAAA,KAAA,KAAA,cAAA,KAAA,OAAS,QAAQ,gBAAgB,MAAM,OAAiB;EAC1F,eAAe,IAAI,OAAO,IAAI;CAChC;AACF"}
@@ -0,0 +1,150 @@
1
+ const require_request_trace = require("./request-trace-wTJdKp6-.js");
2
+ // src/context/async-context.ts
3
+ /**
4
+ * LogixiaContext — Zero-boilerplate AsyncLocalStorage context propagation.
5
+ *
6
+ * Lets every `logger.info()` call inside a context automatically pick up stored
7
+ * fields (requestId, userId, tenantId, …) without passing them through every function.
8
+ *
9
+ * Works across `Promise.all`, `setTimeout`, and event emitters — anything that
10
+ * inherits the async execution context.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { LogixiaContext } from 'logixia';
15
+ *
16
+ * // Wrap a request handler:
17
+ * app.use((req, res, next) => {
18
+ * LogixiaContext.run({ requestId: req.id, userId: req.user?.id }, next);
19
+ * });
20
+ *
21
+ * // Anywhere deeper in the call tree:
22
+ * async function processOrder(orderId: string) {
23
+ * const ctx = LogixiaContext.get(); // { requestId, userId, orderId }
24
+ * logger.info('Processing order', { orderId, ...ctx });
25
+ * }
26
+ * ```
27
+ */
28
+ const _storage = new (require("node:async_hooks")).AsyncLocalStorage();
29
+ const LogixiaContext = {
30
+ /**
31
+ * Run `callback` inside an async context that carries `store` fields.
32
+ * All loggers queried within `callback` (and its async descendants) will
33
+ * automatically see these fields.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * LogixiaContext.run({ requestId: 'abc', userId: '42' }, async () => {
38
+ * await processOrder(); // sees requestId + userId in every log
39
+ * });
40
+ * ```
41
+ */
42
+ run(store, callback) {
43
+ const parent = _storage.getStore() ?? {};
44
+ const scoped = () => _storage.run({
45
+ ...parent,
46
+ ...store
47
+ }, callback);
48
+ const traceId = store.traceId;
49
+ if (typeof traceId !== "string" || traceId === "") return scoped();
50
+ const trace = require_request_trace.TraceContext.instance;
51
+ return trace.storage.run({
52
+ ...trace.storage.getStore(),
53
+ [trace.contextKey]: traceId
54
+ }, scoped);
55
+ },
56
+ /**
57
+ * Return the context fields active in the current async scope.
58
+ * Returns `undefined` when called outside any `LogixiaContext.run()`.
59
+ */
60
+ get() {
61
+ return _storage.getStore();
62
+ },
63
+ /**
64
+ * Merge `fields` into the **existing** context for the current scope.
65
+ * If called outside a `run()` context this is a no-op (logs a dev warning).
66
+ */
67
+ set(fields) {
68
+ const store = _storage.getStore();
69
+ if (!store) return;
70
+ for (const key of Object.keys(fields)) {
71
+ if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
72
+ store[key] = fields[key];
73
+ }
74
+ },
75
+ /**
76
+ * Retrieve the underlying `AsyncLocalStorage` instance.
77
+ * Useful for advanced use-cases like custom middleware.
78
+ */
79
+ getStorage() {
80
+ return _storage;
81
+ }
82
+ };
83
+ function buildScope(request, options, headers) {
84
+ return {
85
+ ...options.enrich ? options.enrich(request) : {},
86
+ traceId: require_request_trace.resolveRequestTraceId(request, headers)
87
+ };
88
+ }
89
+ /**
90
+ * Create an Express/Connect-compatible middleware that wraps each request in
91
+ * a `LogixiaContext.run()` scope populated with common request fields.
92
+ *
93
+ * Trace ID: the first present header of `traceIdHeader` (default
94
+ * `DEFAULT_TRACE_HEADERS`, `traceparent` parsed), else `request.id`, else a
95
+ * generated UUID. It is available via `getCurrentTraceId()` and is the logger's
96
+ * top-level `traceId` inside the request. No response header is set unless
97
+ * `responseHeader` is given.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { createExpressContextMiddleware } from 'logixia';
102
+ * app.use(createExpressContextMiddleware({ responseHeader: 'x-trace-id' }));
103
+ * ```
104
+ */
105
+ function createExpressContextMiddleware(options = {}) {
106
+ const headers = require_request_trace.resolveTraceHeaders(options.traceIdHeader);
107
+ return function logixiaContextMiddleware(req, res, next) {
108
+ var _res$setHeader;
109
+ const scope = buildScope(req, options, headers);
110
+ if (options.responseHeader) (_res$setHeader = res.setHeader) === null || _res$setHeader === void 0 || _res$setHeader.call(res, options.responseHeader, scope.traceId);
111
+ LogixiaContext.run(scope, next);
112
+ };
113
+ }
114
+ /**
115
+ * Create a Fastify lifecycle hook that wraps each request in a context scope.
116
+ *
117
+ * Register with `fastify.addHook('onRequest', createFastifyContextHook())`.
118
+ * Resolves the trace ID exactly like {@link createExpressContextMiddleware} and
119
+ * shares it with `createFastifyPlugin()` from `logixia/middleware`. Fastify's
120
+ * default counter `request.id` (`req-1`, ...) is never used as a trace ID.
121
+ */
122
+ function createFastifyContextHook(options = {}) {
123
+ const headers = require_request_trace.resolveTraceHeaders(options.traceIdHeader);
124
+ return function logixiaFastifyHook(request, reply, done) {
125
+ var _reply$header;
126
+ const scope = buildScope(request, options, headers);
127
+ if (options.responseHeader) (_reply$header = reply.header) === null || _reply$header === void 0 || _reply$header.call(reply, options.responseHeader, scope.traceId);
128
+ LogixiaContext.run(scope, done);
129
+ };
130
+ }
131
+ Object.defineProperty(exports, "LogixiaContext", {
132
+ enumerable: true,
133
+ get: function() {
134
+ return LogixiaContext;
135
+ }
136
+ });
137
+ Object.defineProperty(exports, "createExpressContextMiddleware", {
138
+ enumerable: true,
139
+ get: function() {
140
+ return createExpressContextMiddleware;
141
+ }
142
+ });
143
+ Object.defineProperty(exports, "createFastifyContextHook", {
144
+ enumerable: true,
145
+ get: function() {
146
+ return createFastifyContextHook;
147
+ }
148
+ });
149
+
150
+ //# sourceMappingURL=async-context-DTQgi8f7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-context-DTQgi8f7.js","names":["AsyncLocalStorage","TraceContext","resolveRequestTraceId","resolveTraceHeaders"],"sources":["../src/context/async-context.ts"],"sourcesContent":["/**\n * LogixiaContext — Zero-boilerplate AsyncLocalStorage context propagation.\n *\n * Lets every `logger.info()` call inside a context automatically pick up stored\n * fields (requestId, userId, tenantId, …) without passing them through every function.\n *\n * Works across `Promise.all`, `setTimeout`, and event emitters — anything that\n * inherits the async execution context.\n *\n * @example\n * ```ts\n * import { LogixiaContext } from 'logixia';\n *\n * // Wrap a request handler:\n * app.use((req, res, next) => {\n * LogixiaContext.run({ requestId: req.id, userId: req.user?.id }, next);\n * });\n *\n * // Anywhere deeper in the call tree:\n * async function processOrder(orderId: string) {\n * const ctx = LogixiaContext.get(); // { requestId, userId, orderId }\n * logger.info('Processing order', { orderId, ...ctx });\n * }\n * ```\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport {\n type ContextRequestLike,\n resolveRequestTraceId,\n resolveTraceHeaders,\n type TraceHeaderOption,\n} from '../utils/request-trace';\nimport { TraceContext } from '../utils/trace.utils';\n\nexport interface LogContext {\n traceId?: string;\n spanId?: string;\n userId?: string;\n tenantId?: string;\n sessionId?: string;\n [key: string]: unknown;\n}\n\n// Module-level singleton so all loggers share the same ALS store.\nconst _storage = new AsyncLocalStorage<LogContext>();\n\nexport const LogixiaContext = {\n /**\n * Run `callback` inside an async context that carries `store` fields.\n * All loggers queried within `callback` (and its async descendants) will\n * automatically see these fields.\n *\n * @example\n * ```ts\n * LogixiaContext.run({ requestId: 'abc', userId: '42' }, async () => {\n * await processOrder(); // sees requestId + userId in every log\n * });\n * ```\n */\n run<T>(store: LogContext, callback: () => T): T {\n const parent = _storage.getStore() ?? {};\n const scoped = (): T => _storage.run({ ...parent, ...store }, callback);\n const traceId = store.traceId;\n if (typeof traceId !== 'string' || traceId === '') return scoped();\n // An explicit traceId also becomes the TraceContext ID, so getCurrentTraceId(),\n // the logger, outbound propagation and the OTel bridge all see the same value.\n const trace = TraceContext.instance;\n return trace.storage.run({ ...trace.storage.getStore(), [trace.contextKey]: traceId }, scoped);\n },\n\n /**\n * Return the context fields active in the current async scope.\n * Returns `undefined` when called outside any `LogixiaContext.run()`.\n */\n get(): LogContext | undefined {\n return _storage.getStore();\n },\n\n /**\n * Merge `fields` into the **existing** context for the current scope.\n * If called outside a `run()` context this is a no-op (logs a dev warning).\n */\n set(fields: Partial<LogContext>): void {\n const store = _storage.getStore();\n if (!store) {\n // Silently ignore — avoids crashing in code that may call setContext\n // before a request context is established (e.g. background jobs).\n return;\n }\n for (const key of Object.keys(fields)) {\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n store[key] = fields[key];\n }\n },\n\n /**\n * Retrieve the underlying `AsyncLocalStorage` instance.\n * Useful for advanced use-cases like custom middleware.\n */\n getStorage(): AsyncLocalStorage<LogContext> {\n return _storage;\n },\n};\n\nexport type { ContextRequestLike };\n\ninterface ContextHelperOptions<Req extends ContextRequestLike> {\n /**\n * Extract additional fields from the request. A `traceId` returned here is ignored:\n * the resolved request trace ID always wins.\n */\n enrich?: (request: Req & Record<string, unknown>) => Partial<LogContext>;\n /**\n * Header name, or list of names tried in order, to read the trace ID from.\n * Default: `DEFAULT_TRACE_HEADERS` (traceparent is parsed to its 32-hex trace id).\n */\n traceIdHeader?: TraceHeaderOption;\n /**\n * Echo the resolved trace ID on the response under this header name.\n * Default: `false` (no response header is set).\n */\n responseHeader?: string | false;\n}\n\nfunction buildScope<Req extends ContextRequestLike>(\n request: Req,\n options: ContextHelperOptions<Req>,\n headers: readonly string[]\n): LogContext {\n const extra = options.enrich ? options.enrich(request as Req & Record<string, unknown>) : {};\n return { ...extra, traceId: resolveRequestTraceId(request, headers) };\n}\n\n/**\n * Create an Express/Connect-compatible middleware that wraps each request in\n * a `LogixiaContext.run()` scope populated with common request fields.\n *\n * Trace ID: the first present header of `traceIdHeader` (default\n * `DEFAULT_TRACE_HEADERS`, `traceparent` parsed), else `request.id`, else a\n * generated UUID. It is available via `getCurrentTraceId()` and is the logger's\n * top-level `traceId` inside the request. No response header is set unless\n * `responseHeader` is given.\n *\n * @example\n * ```ts\n * import { createExpressContextMiddleware } from 'logixia';\n * app.use(createExpressContextMiddleware({ responseHeader: 'x-trace-id' }));\n * ```\n */\nexport function createExpressContextMiddleware<Req extends ContextRequestLike = ContextRequestLike>(\n options: ContextHelperOptions<Req> = {}\n) {\n const headers = resolveTraceHeaders(options.traceIdHeader);\n\n return function logixiaContextMiddleware(\n req: Req,\n res: { setHeader?: (name: string, value: string) => unknown },\n next: () => void\n ): void {\n const scope = buildScope(req, options, headers);\n if (options.responseHeader) res.setHeader?.(options.responseHeader, scope.traceId as string);\n LogixiaContext.run(scope, next);\n };\n}\n\n/**\n * Create a Fastify lifecycle hook that wraps each request in a context scope.\n *\n * Register with `fastify.addHook('onRequest', createFastifyContextHook())`.\n * Resolves the trace ID exactly like {@link createExpressContextMiddleware} and\n * shares it with `createFastifyPlugin()` from `logixia/middleware`. Fastify's\n * default counter `request.id` (`req-1`, ...) is never used as a trace ID.\n */\nexport function createFastifyContextHook<Req extends ContextRequestLike = ContextRequestLike>(\n options: ContextHelperOptions<Req> = {}\n) {\n const headers = resolveTraceHeaders(options.traceIdHeader);\n\n return function logixiaFastifyHook(\n request: Req,\n reply: { header?: (name: string, value: string) => unknown },\n done: () => void\n ): void {\n const scope = buildScope(request, options, headers);\n if (options.responseHeader) reply.header?.(options.responseHeader, scope.traceId as string);\n LogixiaContext.run(scope, done);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,WAAW,K,0BAAIA,EAAAA,CAAAA,kBAA8B;AAEnD,MAAa,iBAAiB;;;;;;;;;;;;;CAa5B,IAAO,OAAmB,UAAsB;EAC9C,MAAM,SAAS,SAAS,SAAS,KAAK,CAAC;EACvC,MAAM,eAAkB,SAAS,IAAI;GAAE,GAAG;GAAQ,GAAG;EAAM,GAAG,QAAQ;EACtE,MAAM,UAAU,MAAM;EACtB,IAAI,OAAO,YAAY,YAAY,YAAY,IAAI,OAAO,OAAO;EAGjE,MAAM,QAAQC,sBAAAA,aAAa;EAC3B,OAAO,MAAM,QAAQ,IAAI;GAAE,GAAG,MAAM,QAAQ,SAAS;IAAI,MAAM,aAAa;EAAQ,GAAG,MAAM;CAC/F;;;;;CAMA,MAA8B;EAC5B,OAAO,SAAS,SAAS;CAC3B;;;;;CAMA,IAAI,QAAmC;EACrC,MAAM,QAAQ,SAAS,SAAS;EAChC,IAAI,CAAC,OAGH;EAEF,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;GACrC,IAAI,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ,aAAa;GACzE,MAAM,OAAO,OAAO;EACtB;CACF;;;;;CAMA,aAA4C;EAC1C,OAAO;CACT;AACF;AAsBA,SAAS,WACP,SACA,SACA,SACY;CAEZ,OAAO;EAAE,GADK,QAAQ,SAAS,QAAQ,OAAO,OAAwC,IAAI,CAAC;EACxE,SAASC,sBAAAA,sBAAsB,SAAS,OAAO;CAAE;AACtE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,+BACd,UAAqC,CAAC,GACtC;CACA,MAAM,UAAUC,sBAAAA,oBAAoB,QAAQ,aAAa;CAEzD,OAAO,SAAS,yBACd,KACA,KACA,MACM;;EACN,MAAM,QAAQ,WAAW,KAAK,SAAS,OAAO;EAC9C,IAAI,QAAQ,gBAAgB,CAAA,iBAAA,IAAI,eAAA,QAAA,mBAAA,KAAA,KAAA,eAAA,KAAA,KAAY,QAAQ,gBAAgB,MAAM,OAAiB;EAC3F,eAAe,IAAI,OAAO,IAAI;CAChC;AACF;;;;;;;;;AAUA,SAAgB,yBACd,UAAqC,CAAC,GACtC;CACA,MAAM,UAAUA,sBAAAA,oBAAoB,QAAQ,aAAa;CAEzD,OAAO,SAAS,mBACd,SACA,OACA,MACM;;EACN,MAAM,QAAQ,WAAW,SAAS,SAAS,OAAO;EAClD,IAAI,QAAQ,gBAAgB,CAAA,gBAAA,MAAM,YAAA,QAAA,kBAAA,KAAA,KAAA,cAAA,KAAA,OAAS,QAAQ,gBAAgB,MAAM,OAAiB;EAC1F,eAAe,IAAI,OAAO,IAAI;CAChC;AACF"}
@@ -1,8 +1,8 @@
1
- import { r as internalWarn, t as internalError } from "./internal-log-Cm8SOWSV.mjs";
2
- import { i as stringifyForLog } from "./safe-stringify-DJ66tW5I.mjs";
3
- import { a as httpRequest, n as DEFAULT_MAX_BUFFER_SIZE, r as DEFAULT_REQUEST_TIMEOUT_MS, t as BatchBuffer } from "./batch-buffer-PGvSgbmd.mjs";
4
-
5
- //#region src/transports/azure-monitor.transport.ts
1
+ import { r as internalWarn, t as internalError } from "./internal-log-uCSd1PMc.mjs";
2
+ import { i as scrubSecrets, n as protectSecrets, o as urlSecrets, r as scrubError } from "./secret-config-BegMLkYl.mjs";
3
+ import { i as stringifyForLog } from "./safe-stringify-BMRl3EX3.mjs";
4
+ import { a as httpRequest, t as BatchBuffer } from "./batch-buffer-0fgLmIPn.mjs";
5
+ // src/transports/azure-monitor.transport.ts
6
6
  /**
7
7
  * Azure AD tenant IDs are either a GUID or a verified domain (e.g. `contoso.onmicrosoft.com`).
8
8
  * This pattern is deliberately permissive on structure but strict on character
@@ -32,6 +32,7 @@ var AzureMonitorTransport = class {
32
32
  this.flushTimer = null;
33
33
  this.accessToken = null;
34
34
  this.tokenExpiry = 0;
35
+ protectSecrets(this, ["clientSecret", "accessToken"]);
35
36
  this.endpoint = config.endpoint.replace(/\/$/, "");
36
37
  this.ruleId = config.ruleId;
37
38
  this.streamName = config.streamName;
@@ -41,12 +42,13 @@ var AzureMonitorTransport = class {
41
42
  this.batchSize = config.batchSize ?? 200;
42
43
  this.flushInterval = config.flushIntervalMs ?? 5e3;
43
44
  this.level = config.level;
44
- this.requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
45
+ this.requestTimeoutMs = config.requestTimeoutMs ?? 1e4;
45
46
  this.buffer = new BatchBuffer({
46
47
  name: "AzureMonitorTransport",
47
48
  batchSize: this.batchSize,
48
- maxBufferSize: config.maxBufferSize ?? DEFAULT_MAX_BUFFER_SIZE,
49
- send: (entries) => this.sendEntries(entries)
49
+ maxBufferSize: config.maxBufferSize ?? 1e4,
50
+ send: (entries) => this.sendEntries(entries),
51
+ secrets: () => this.secretValues()
50
52
  });
51
53
  this.flushTimer = setInterval(() => {
52
54
  this.flush().catch(() => {});
@@ -83,6 +85,14 @@ var AzureMonitorTransport = class {
83
85
  Properties: stringifyForLog(entry.data ?? {})
84
86
  };
85
87
  }
88
+ secretValues(token) {
89
+ return [
90
+ this.clientSecret,
91
+ this.accessToken ?? void 0,
92
+ token,
93
+ ...urlSecrets(this.endpoint)
94
+ ];
95
+ }
86
96
  async getAccessToken() {
87
97
  if (this.accessToken && Date.now() < this.tokenExpiry) return this.accessToken;
88
98
  if (!this.tenantId || !this.clientId || !this.clientSecret) {
@@ -107,7 +117,8 @@ var AzureMonitorTransport = class {
107
117
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
108
118
  body,
109
119
  timeoutMs: this.requestTimeoutMs,
110
- label: "Azure token request"
120
+ label: "Azure token request",
121
+ secrets: () => this.secretValues()
111
122
  });
112
123
  const parsed = JSON.parse(res.body);
113
124
  if (!parsed.access_token) return null;
@@ -122,12 +133,13 @@ var AzureMonitorTransport = class {
122
133
  async sendEntries(entries) {
123
134
  const token = await this.getAccessToken();
124
135
  if (!token) throw new Error("AzureMonitorTransport: no access token available");
125
- const body = stringifyForLog(entries.map((e) => this.toAzureRecord(e)));
136
+ const records = entries.map((e) => this.toAzureRecord(e));
137
+ const body = stringifyForLog(records);
126
138
  let reqUrl;
127
139
  try {
128
140
  reqUrl = new URL(`dataCollectionRules/${encodeURIComponent(this.ruleId)}/streams/${encodeURIComponent(this.streamName)}?api-version=2023-01-01`, this.endpoint.endsWith("/") ? this.endpoint : `${this.endpoint}/`);
129
141
  } catch (error) {
130
- internalError(`AzureMonitorTransport: invalid endpoint "${this.endpoint}"`, error);
142
+ internalError(`AzureMonitorTransport: invalid endpoint "${scrubSecrets(this.endpoint, urlSecrets(this.endpoint))}"`, scrubError(error, urlSecrets(this.endpoint)));
131
143
  return;
132
144
  }
133
145
  if (reqUrl.protocol !== "https:") {
@@ -142,11 +154,11 @@ var AzureMonitorTransport = class {
142
154
  },
143
155
  body,
144
156
  timeoutMs: this.requestTimeoutMs,
145
- label: "Azure Monitor API"
157
+ label: "Azure Monitor API",
158
+ secrets: () => this.secretValues(token)
146
159
  });
147
160
  }
148
161
  };
149
-
150
- //#endregion
151
162
  export { AzureMonitorTransport as t };
152
- //# sourceMappingURL=azure-monitor.transport-CHnjVRF-.mjs.map
163
+
164
+ //# sourceMappingURL=azure-monitor.transport-BPbgjATu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-monitor.transport-BPbgjATu.mjs","names":[],"sources":["../src/transports/azure-monitor.transport.ts"],"sourcesContent":["/**\n * logixia — Azure Monitor / Application Insights transport\n *\n * Sends log entries to Azure Monitor via the Data Collection Rules (DCR) API\n * using the Logs Ingestion API (the modern replacement for the legacy HTTP\n * Data Collector API).\n *\n * Maps logixia levels to Application Insights severity levels:\n * verbose → 0, debug → 1, info → 1, warn → 2, error → 3, critical → 4\n *\n * @example\n * ```ts\n * import { AzureMonitorTransport } from 'logixia';\n *\n * const logger = createLogger({\n * transports: {\n * azure: new AzureMonitorTransport({\n * // Logs Ingestion API endpoint (from your DCR)\n * endpoint: 'https://<dce>.ingest.monitor.azure.com',\n * ruleId: 'dcr-xxxxxxxxxxxxxxxx',\n * streamName: 'Custom-LogixiaLogs',\n * // Client credentials (or managed identity via no-credential mode)\n * tenantId: process.env.AZURE_TENANT_ID,\n * clientId: process.env.AZURE_CLIENT_ID,\n * clientSecret: process.env.AZURE_CLIENT_SECRET,\n * }),\n * },\n * });\n * ```\n */\n\nimport type { IAsyncTransport, TransportLogEntry } from '../types/transport.types';\nimport { internalError, internalWarn } from '../utils/internal-log';\nimport { stringifyForLog } from '../utils/safe-stringify';\nimport {\n BatchBuffer,\n DEFAULT_MAX_BUFFER_SIZE,\n DEFAULT_REQUEST_TIMEOUT_MS,\n httpRequest,\n} from './batch-buffer';\nimport { protectSecrets, scrubError, scrubSecrets, urlSecrets } from './secret-config';\n\n/**\n * Azure AD tenant IDs are either a GUID or a verified domain (e.g. `contoso.onmicrosoft.com`).\n * This pattern is deliberately permissive on structure but strict on character\n * set — it rejects the breakout characters (`/`, `@`, `:`, `?`, `#`, whitespace)\n * that would let a hostile config smuggle a different host, path, or query into\n * the OAuth token URL.\n */\nconst AZURE_TENANT_RE = /^[a-z0-9][a-z0-9.-]{1,253}$/i;\n\nexport interface AzureMonitorTransportConfig {\n /** DCE (Data Collection Endpoint) URL, e.g. `https://<name>.ingest.monitor.azure.com`. */\n endpoint: string;\n /** Data Collection Rule immutable ID (from Azure portal). */\n ruleId: string;\n /** Stream name defined in the DCR, e.g. `'Custom-LogixiaLogs_CL'`. */\n streamName: string;\n /** Azure AD tenant ID for OAuth2 client-credentials flow. */\n tenantId?: string;\n /** Azure AD app (service principal) client ID. */\n clientId?: string;\n /** Azure AD app client secret. */\n clientSecret?: string;\n /** Number of entries to batch. @default 200 */\n batchSize?: number;\n /** Flush interval in ms. @default 5000 */\n flushIntervalMs?: number;\n /** Abort a request that has not finished after this many ms. @default 10000 */\n requestTimeoutMs?: number;\n /** Max buffered entries; the oldest are dropped past this. @default 10000 */\n maxBufferSize?: number;\n level?: string;\n}\n\nconst SEVERITY_MAP: Record<string, number> = {\n verbose: 0,\n trace: 0,\n debug: 1,\n info: 1,\n log: 1,\n warn: 2,\n warning: 2,\n error: 3,\n critical: 4,\n fatal: 4,\n};\n\n/**\n * Azure Monitor Logs Ingestion transport.\n */\nexport class AzureMonitorTransport implements IAsyncTransport {\n public readonly name = 'azure-monitor';\n public readonly batchSize: number;\n public readonly flushInterval: number;\n public readonly level: string | undefined;\n\n private readonly buffer: BatchBuffer<TransportLogEntry>;\n private readonly requestTimeoutMs: number;\n private flushTimer: NodeJS.Timeout | null = null;\n private accessToken: string | null = null;\n private tokenExpiry = 0;\n\n private readonly endpoint: string;\n private readonly ruleId: string;\n private readonly streamName: string;\n private readonly tenantId: string | undefined;\n private readonly clientId: string | undefined;\n private readonly clientSecret: string | undefined;\n\n constructor(config: AzureMonitorTransportConfig) {\n protectSecrets(this, ['clientSecret', 'accessToken']);\n this.endpoint = config.endpoint.replace(/\\/$/, '');\n this.ruleId = config.ruleId;\n this.streamName = config.streamName;\n this.tenantId = config.tenantId ?? process.env['AZURE_TENANT_ID'];\n this.clientId = config.clientId ?? process.env['AZURE_CLIENT_ID'];\n this.clientSecret = config.clientSecret ?? process.env['AZURE_CLIENT_SECRET'];\n this.batchSize = config.batchSize ?? 200;\n this.flushInterval = config.flushIntervalMs ?? 5000;\n this.level = config.level;\n this.requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n this.buffer = new BatchBuffer<TransportLogEntry>({\n name: 'AzureMonitorTransport',\n batchSize: this.batchSize,\n maxBufferSize: config.maxBufferSize ?? DEFAULT_MAX_BUFFER_SIZE,\n send: (entries) => this.sendEntries(entries),\n secrets: () => this.secretValues(),\n });\n\n this.flushTimer = setInterval(() => {\n this.flush().catch(() => {});\n }, this.flushInterval);\n if (this.flushTimer.unref) this.flushTimer.unref();\n }\n\n write(entry: TransportLogEntry): void {\n this.buffer.push(entry);\n this.buffer.flushIfFull();\n }\n\n flush(): Promise<void> {\n return this.buffer.flush();\n }\n\n /**\n * Flush remaining entries and stop the interval timer on shutdown. Without\n * this the manager's close() skipped the transport (close was undefined) and\n * buffered entries were lost on deploy. Waits for any in-flight send first.\n */\n async close(): Promise<void> {\n if (this.flushTimer) {\n clearInterval(this.flushTimer);\n this.flushTimer = null;\n }\n await this.buffer.close();\n }\n\n private toAzureRecord(entry: TransportLogEntry): Record<string, unknown> {\n return {\n TimeGenerated: entry.timestamp ?? new Date().toISOString(),\n SeverityLevel: SEVERITY_MAP[entry.level.toLowerCase()] ?? 1,\n Message: entry.message,\n AppName: entry.appName,\n Context: entry.context ?? '',\n TraceId: entry.traceId ?? '',\n Properties: stringifyForLog(entry.data ?? {}),\n };\n }\n\n private secretValues(token?: string): (string | undefined)[] {\n return [this.clientSecret, this.accessToken ?? undefined, token, ...urlSecrets(this.endpoint)];\n }\n\n private async getAccessToken(): Promise<string | null> {\n if (this.accessToken && Date.now() < this.tokenExpiry) return this.accessToken;\n\n if (!this.tenantId || !this.clientId || !this.clientSecret) {\n internalWarn(\n 'AzureMonitorTransport: missing credentials — set tenantId, clientId, clientSecret'\n );\n return null;\n }\n\n const body = new URLSearchParams({\n grant_type: 'client_credentials',\n client_id: this.clientId,\n client_secret: this.clientSecret,\n scope: 'https://monitor.azure.com/.default',\n }).toString();\n\n const tenantId = this.tenantId;\n if (!AZURE_TENANT_RE.test(tenantId)) {\n internalWarn(\n `AzureMonitorTransport: refusing to request token — tenantId \"${tenantId}\" is not a valid GUID or domain`\n );\n return null;\n }\n\n const reqUrl = new URL(\n `https://login.microsoftonline.com/${encodeURIComponent(tenantId)}/oauth2/v2.0/token`\n );\n try {\n const res = await httpRequest({\n url: reqUrl,\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body,\n timeoutMs: this.requestTimeoutMs,\n label: 'Azure token request',\n secrets: () => this.secretValues(),\n });\n const parsed = JSON.parse(res.body) as { access_token?: string; expires_in?: number };\n if (!parsed.access_token) return null;\n this.accessToken = parsed.access_token;\n this.tokenExpiry = Date.now() + (parsed.expires_in ?? 3600) * 1000 - 60_000;\n return this.accessToken;\n } catch (err) {\n internalError('AzureMonitorTransport token request failed', err);\n return null;\n }\n }\n\n private async sendEntries(entries: TransportLogEntry[]): Promise<void> {\n const token = await this.getAccessToken();\n if (!token) throw new Error('AzureMonitorTransport: no access token available');\n\n const records = entries.map((e) => this.toAzureRecord(e));\n const body = stringifyForLog(records);\n let reqUrl: URL;\n try {\n // Build from the user-configured DCE endpoint; encodeURIComponent-ing the\n // ruleId/streamName stops a hostile config from smuggling extra path\n // segments or query params into the request.\n reqUrl = new URL(\n `dataCollectionRules/${encodeURIComponent(this.ruleId)}/streams/${encodeURIComponent(this.streamName)}?api-version=2023-01-01`,\n this.endpoint.endsWith('/') ? this.endpoint : `${this.endpoint}/`\n );\n } catch (error) {\n internalError(\n `AzureMonitorTransport: invalid endpoint \"${scrubSecrets(this.endpoint, urlSecrets(this.endpoint))}\"`,\n scrubError(error, urlSecrets(this.endpoint))\n );\n return;\n }\n if (reqUrl.protocol !== 'https:') {\n internalError(`AzureMonitorTransport: endpoint must use https (got ${reqUrl.protocol})`);\n return;\n }\n\n await httpRequest({\n url: reqUrl,\n headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },\n body,\n timeoutMs: this.requestTimeoutMs,\n label: 'Azure Monitor API',\n secrets: () => this.secretValues(token),\n });\n }\n}\n"],"mappings":"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"}
@@ -1,7 +1,4 @@
1
- import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-CGoHpWQR.js";
2
-
3
- //#region src/transports/azure-monitor.transport.d.ts
4
-
1
+ import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-BJVL1QQl.mjs";
5
2
  interface AzureMonitorTransportConfig {
6
3
  /** DCE (Data Collection Endpoint) URL, e.g. `https://<name>.ingest.monitor.azure.com`. */
7
4
  endpoint: string;
@@ -54,9 +51,9 @@ declare class AzureMonitorTransport implements IAsyncTransport {
54
51
  */
55
52
  close(): Promise<void>;
56
53
  private toAzureRecord;
54
+ private secretValues;
57
55
  private getAccessToken;
58
56
  private sendEntries;
59
57
  }
60
- //#endregion
61
58
  export { AzureMonitorTransportConfig as n, AzureMonitorTransport as t };
62
- //# sourceMappingURL=azure-monitor.transport-Cn_3Usvu.d.ts.map
59
+ //# sourceMappingURL=azure-monitor.transport-C7kYyZUW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure-monitor.transport-C7kYyZUW.d.mts","names":[],"sources":["../src/transports/azure-monitor.transport.ts"],"mappings":";UAmDiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;;;;cAmBW,iCAAiC;WAC5B;WACA;WACA;WACA;mBAEC;mBACA;UACT;UACA;UACA;mBAES;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;EA0BpB,MAAM,OAAO;EAKb,SAAS;;;;;;EASH,SAAS;UAQP;UAYA;UAIM;UAgDA"}