@softprobe/softprobe-js 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +202 -0
  3. package/bin/softprobe +15 -0
  4. package/dist/api/baggage.d.ts +13 -0
  5. package/dist/api/baggage.d.ts.map +1 -0
  6. package/dist/api/baggage.js +32 -0
  7. package/dist/api/baggage.js.map +1 -0
  8. package/dist/api/compare.d.ts +16 -0
  9. package/dist/api/compare.d.ts.map +1 -0
  10. package/dist/api/compare.js +77 -0
  11. package/dist/api/compare.js.map +1 -0
  12. package/dist/api.d.ts +63 -0
  13. package/dist/api.d.ts.map +1 -0
  14. package/dist/api.js +104 -0
  15. package/dist/api.js.map +1 -0
  16. package/dist/bindings/http-span.d.ts +6 -0
  17. package/dist/bindings/http-span.d.ts.map +1 -0
  18. package/dist/bindings/http-span.js +11 -0
  19. package/dist/bindings/http-span.js.map +1 -0
  20. package/dist/bindings/postgres-span.d.ts +6 -0
  21. package/dist/bindings/postgres-span.d.ts.map +1 -0
  22. package/dist/bindings/postgres-span.js +11 -0
  23. package/dist/bindings/postgres-span.js.map +1 -0
  24. package/dist/bindings/redis-span.d.ts +6 -0
  25. package/dist/bindings/redis-span.d.ts.map +1 -0
  26. package/dist/bindings/redis-span.js +11 -0
  27. package/dist/bindings/redis-span.js.map +1 -0
  28. package/dist/bindings/test-span.d.ts +6 -0
  29. package/dist/bindings/test-span.d.ts.map +1 -0
  30. package/dist/bindings/test-span.js +9 -0
  31. package/dist/bindings/test-span.js.map +1 -0
  32. package/dist/bootstrap/otel/framework-mutator.d.ts +20 -0
  33. package/dist/bootstrap/otel/framework-mutator.d.ts.map +1 -0
  34. package/dist/bootstrap/otel/framework-mutator.js +144 -0
  35. package/dist/bootstrap/otel/framework-mutator.js.map +1 -0
  36. package/dist/bootstrap/otel/inject.d.ts +17 -0
  37. package/dist/bootstrap/otel/inject.d.ts.map +1 -0
  38. package/dist/bootstrap/otel/inject.js +28 -0
  39. package/dist/bootstrap/otel/inject.js.map +1 -0
  40. package/dist/bootstrap/otel/mutator.d.ts +17 -0
  41. package/dist/bootstrap/otel/mutator.d.ts.map +1 -0
  42. package/dist/bootstrap/otel/mutator.js +51 -0
  43. package/dist/bootstrap/otel/mutator.js.map +1 -0
  44. package/dist/capture/express.d.ts +6 -0
  45. package/dist/capture/express.d.ts.map +1 -0
  46. package/dist/capture/express.js +11 -0
  47. package/dist/capture/express.js.map +1 -0
  48. package/dist/capture/fastify.d.ts +5 -0
  49. package/dist/capture/fastify.d.ts.map +1 -0
  50. package/dist/capture/fastify.js +9 -0
  51. package/dist/capture/fastify.js.map +1 -0
  52. package/dist/capture/framework-mutator.d.ts +20 -0
  53. package/dist/capture/framework-mutator.d.ts.map +1 -0
  54. package/dist/capture/framework-mutator.js +144 -0
  55. package/dist/capture/framework-mutator.js.map +1 -0
  56. package/dist/capture/http-inbound.d.ts +28 -0
  57. package/dist/capture/http-inbound.d.ts.map +1 -0
  58. package/dist/capture/http-inbound.js +40 -0
  59. package/dist/capture/http-inbound.js.map +1 -0
  60. package/dist/capture/inject.d.ts +17 -0
  61. package/dist/capture/inject.d.ts.map +1 -0
  62. package/dist/capture/inject.js +28 -0
  63. package/dist/capture/inject.js.map +1 -0
  64. package/dist/capture/mutator.d.ts +17 -0
  65. package/dist/capture/mutator.d.ts.map +1 -0
  66. package/dist/capture/mutator.js +51 -0
  67. package/dist/capture/mutator.js.map +1 -0
  68. package/dist/capture/postgres.d.ts +6 -0
  69. package/dist/capture/postgres.d.ts.map +1 -0
  70. package/dist/capture/postgres.js +11 -0
  71. package/dist/capture/postgres.js.map +1 -0
  72. package/dist/capture/redis.d.ts +5 -0
  73. package/dist/capture/redis.d.ts.map +1 -0
  74. package/dist/capture/redis.js +10 -0
  75. package/dist/capture/redis.js.map +1 -0
  76. package/dist/capture/store-accessor.d.ts +11 -0
  77. package/dist/capture/store-accessor.d.ts.map +1 -0
  78. package/dist/capture/store-accessor.js +19 -0
  79. package/dist/capture/store-accessor.js.map +1 -0
  80. package/dist/capture/stream-tap.d.ts +5 -0
  81. package/dist/capture/stream-tap.d.ts.map +1 -0
  82. package/dist/capture/stream-tap.js +9 -0
  83. package/dist/capture/stream-tap.js.map +1 -0
  84. package/dist/cli/diff-reporter.d.ts +26 -0
  85. package/dist/cli/diff-reporter.d.ts.map +1 -0
  86. package/dist/cli/diff-reporter.js +163 -0
  87. package/dist/cli/diff-reporter.js.map +1 -0
  88. package/dist/cli/diff.d.ts +18 -0
  89. package/dist/cli/diff.d.ts.map +1 -0
  90. package/dist/cli/diff.js +105 -0
  91. package/dist/cli/diff.js.map +1 -0
  92. package/dist/cli.d.ts +7 -0
  93. package/dist/cli.d.ts.map +1 -0
  94. package/dist/cli.js +84 -0
  95. package/dist/cli.js.map +1 -0
  96. package/dist/config/config-manager.d.ts +20 -0
  97. package/dist/config/config-manager.d.ts.map +1 -0
  98. package/dist/config/config-manager.js +46 -0
  99. package/dist/config/config-manager.js.map +1 -0
  100. package/dist/context.d.ts +98 -0
  101. package/dist/context.d.ts.map +1 -0
  102. package/dist/context.js +198 -0
  103. package/dist/context.js.map +1 -0
  104. package/dist/core/bindings/http-span.d.ts +39 -0
  105. package/dist/core/bindings/http-span.d.ts.map +1 -0
  106. package/dist/core/bindings/http-span.js +55 -0
  107. package/dist/core/bindings/http-span.js.map +1 -0
  108. package/dist/core/bindings/index.d.ts +12 -0
  109. package/dist/core/bindings/index.d.ts.map +1 -0
  110. package/dist/core/bindings/index.js +21 -0
  111. package/dist/core/bindings/index.js.map +1 -0
  112. package/dist/core/bindings/postgres-span.d.ts +41 -0
  113. package/dist/core/bindings/postgres-span.d.ts.map +1 -0
  114. package/dist/core/bindings/postgres-span.js +57 -0
  115. package/dist/core/bindings/postgres-span.js.map +1 -0
  116. package/dist/core/bindings/redis-span.d.ts +40 -0
  117. package/dist/core/bindings/redis-span.d.ts.map +1 -0
  118. package/dist/core/bindings/redis-span.js +65 -0
  119. package/dist/core/bindings/redis-span.js.map +1 -0
  120. package/dist/core/bindings/test-span.d.ts +15 -0
  121. package/dist/core/bindings/test-span.d.ts.map +1 -0
  122. package/dist/core/bindings/test-span.js +24 -0
  123. package/dist/core/bindings/test-span.js.map +1 -0
  124. package/dist/core/cassette/capture-store-accessor.d.ts +11 -0
  125. package/dist/core/cassette/capture-store-accessor.d.ts.map +1 -0
  126. package/dist/core/cassette/capture-store-accessor.js +19 -0
  127. package/dist/core/cassette/capture-store-accessor.js.map +1 -0
  128. package/dist/core/cassette/context-request-storage.d.ts +14 -0
  129. package/dist/core/cassette/context-request-storage.d.ts.map +1 -0
  130. package/dist/core/cassette/context-request-storage.js +24 -0
  131. package/dist/core/cassette/context-request-storage.js.map +1 -0
  132. package/dist/core/cassette/index.d.ts +8 -0
  133. package/dist/core/cassette/index.d.ts.map +1 -0
  134. package/dist/core/cassette/index.js +16 -0
  135. package/dist/core/cassette/index.js.map +1 -0
  136. package/dist/core/cassette/ndjson-cassette.d.ts +22 -0
  137. package/dist/core/cassette/ndjson-cassette.d.ts.map +1 -0
  138. package/dist/core/cassette/ndjson-cassette.js +56 -0
  139. package/dist/core/cassette/ndjson-cassette.js.map +1 -0
  140. package/dist/core/cassette/request-storage.d.ts +16 -0
  141. package/dist/core/cassette/request-storage.d.ts.map +1 -0
  142. package/dist/core/cassette/request-storage.js +22 -0
  143. package/dist/core/cassette/request-storage.js.map +1 -0
  144. package/dist/core/context/index.d.ts +5 -0
  145. package/dist/core/context/index.d.ts.map +1 -0
  146. package/dist/core/context/index.js +9 -0
  147. package/dist/core/context/index.js.map +1 -0
  148. package/dist/core/contracts/index.d.ts +5 -0
  149. package/dist/core/contracts/index.d.ts.map +1 -0
  150. package/dist/core/contracts/index.js +3 -0
  151. package/dist/core/contracts/index.js.map +1 -0
  152. package/dist/core/identifier.d.ts +20 -0
  153. package/dist/core/identifier.d.ts.map +1 -0
  154. package/dist/core/identifier.js +31 -0
  155. package/dist/core/identifier.js.map +1 -0
  156. package/dist/core/index.d.ts +11 -0
  157. package/dist/core/index.d.ts.map +1 -0
  158. package/dist/core/index.js +27 -0
  159. package/dist/core/index.js.map +1 -0
  160. package/dist/core/matcher/extract-key.d.ts +41 -0
  161. package/dist/core/matcher/extract-key.d.ts.map +1 -0
  162. package/dist/core/matcher/extract-key.js +80 -0
  163. package/dist/core/matcher/extract-key.js.map +1 -0
  164. package/dist/core/matcher/index.d.ts +9 -0
  165. package/dist/core/matcher/index.d.ts.map +1 -0
  166. package/dist/core/matcher/index.js +24 -0
  167. package/dist/core/matcher/index.js.map +1 -0
  168. package/dist/core/matcher/matcher.d.ts +25 -0
  169. package/dist/core/matcher/matcher.d.ts.map +1 -0
  170. package/dist/core/matcher/matcher.js +83 -0
  171. package/dist/core/matcher/matcher.js.map +1 -0
  172. package/dist/core/matcher/softprobe-matcher.d.ts +41 -0
  173. package/dist/core/matcher/softprobe-matcher.d.ts.map +1 -0
  174. package/dist/core/matcher/softprobe-matcher.js +92 -0
  175. package/dist/core/matcher/softprobe-matcher.js.map +1 -0
  176. package/dist/core/matcher/store-accessor.d.ts +14 -0
  177. package/dist/core/matcher/store-accessor.d.ts.map +1 -0
  178. package/dist/core/matcher/store-accessor.js +25 -0
  179. package/dist/core/matcher/store-accessor.js.map +1 -0
  180. package/dist/core/matcher/topology.d.ts +37 -0
  181. package/dist/core/matcher/topology.d.ts.map +1 -0
  182. package/dist/core/matcher/topology.js +72 -0
  183. package/dist/core/matcher/topology.js.map +1 -0
  184. package/dist/core/runtime/architecture-guard.d.ts +9 -0
  185. package/dist/core/runtime/architecture-guard.d.ts.map +1 -0
  186. package/dist/core/runtime/architecture-guard.js +131 -0
  187. package/dist/core/runtime/architecture-guard.js.map +1 -0
  188. package/dist/core/runtime/index.d.ts +6 -0
  189. package/dist/core/runtime/index.d.ts.map +1 -0
  190. package/dist/core/runtime/index.js +11 -0
  191. package/dist/core/runtime/index.js.map +1 -0
  192. package/dist/identifier.d.ts +5 -0
  193. package/dist/identifier.d.ts.map +1 -0
  194. package/dist/identifier.js +11 -0
  195. package/dist/identifier.js.map +1 -0
  196. package/dist/index.d.ts +5 -0
  197. package/dist/index.d.ts.map +1 -0
  198. package/dist/index.js +21 -0
  199. package/dist/index.js.map +1 -0
  200. package/dist/init.d.ts +21 -0
  201. package/dist/init.d.ts.map +1 -0
  202. package/dist/init.js +51 -0
  203. package/dist/init.js.map +1 -0
  204. package/dist/instrumentations/common/http/context-headers.d.ts +9 -0
  205. package/dist/instrumentations/common/http/context-headers.d.ts.map +1 -0
  206. package/dist/instrumentations/common/http/context-headers.js +16 -0
  207. package/dist/instrumentations/common/http/context-headers.js.map +1 -0
  208. package/dist/instrumentations/common/http/inbound-capture.d.ts +17 -0
  209. package/dist/instrumentations/common/http/inbound-capture.d.ts.map +1 -0
  210. package/dist/instrumentations/common/http/inbound-capture.js +41 -0
  211. package/dist/instrumentations/common/http/inbound-capture.js.map +1 -0
  212. package/dist/instrumentations/common/http/inbound-record.d.ts +28 -0
  213. package/dist/instrumentations/common/http/inbound-record.d.ts.map +1 -0
  214. package/dist/instrumentations/common/http/inbound-record.js +40 -0
  215. package/dist/instrumentations/common/http/inbound-record.js.map +1 -0
  216. package/dist/instrumentations/common/http/span-adapter.d.ts +6 -0
  217. package/dist/instrumentations/common/http/span-adapter.d.ts.map +1 -0
  218. package/dist/instrumentations/common/http/span-adapter.js +12 -0
  219. package/dist/instrumentations/common/http/span-adapter.js.map +1 -0
  220. package/dist/instrumentations/common/http/stream-tap.d.ts +28 -0
  221. package/dist/instrumentations/common/http/stream-tap.d.ts.map +1 -0
  222. package/dist/instrumentations/common/http/stream-tap.js +61 -0
  223. package/dist/instrumentations/common/http/stream-tap.js.map +1 -0
  224. package/dist/instrumentations/express/capture.d.ts +26 -0
  225. package/dist/instrumentations/express/capture.d.ts.map +1 -0
  226. package/dist/instrumentations/express/capture.js +80 -0
  227. package/dist/instrumentations/express/capture.js.map +1 -0
  228. package/dist/instrumentations/express/index.d.ts +7 -0
  229. package/dist/instrumentations/express/index.d.ts.map +1 -0
  230. package/dist/instrumentations/express/index.js +15 -0
  231. package/dist/instrumentations/express/index.js.map +1 -0
  232. package/dist/instrumentations/express/replay.d.ts +10 -0
  233. package/dist/instrumentations/express/replay.d.ts.map +1 -0
  234. package/dist/instrumentations/express/replay.js +16 -0
  235. package/dist/instrumentations/express/replay.js.map +1 -0
  236. package/dist/instrumentations/fastify/capture.d.ts +13 -0
  237. package/dist/instrumentations/fastify/capture.d.ts.map +1 -0
  238. package/dist/instrumentations/fastify/capture.js +65 -0
  239. package/dist/instrumentations/fastify/capture.js.map +1 -0
  240. package/dist/instrumentations/fastify/index.d.ts +7 -0
  241. package/dist/instrumentations/fastify/index.d.ts.map +1 -0
  242. package/dist/instrumentations/fastify/index.js +13 -0
  243. package/dist/instrumentations/fastify/index.js.map +1 -0
  244. package/dist/instrumentations/fastify/replay.d.ts +13 -0
  245. package/dist/instrumentations/fastify/replay.d.ts.map +1 -0
  246. package/dist/instrumentations/fastify/replay.js +24 -0
  247. package/dist/instrumentations/fastify/replay.js.map +1 -0
  248. package/dist/instrumentations/fetch/index.d.ts +5 -0
  249. package/dist/instrumentations/fetch/index.d.ts.map +1 -0
  250. package/dist/instrumentations/fetch/index.js +10 -0
  251. package/dist/instrumentations/fetch/index.js.map +1 -0
  252. package/dist/instrumentations/fetch/replay.d.ts +19 -0
  253. package/dist/instrumentations/fetch/replay.d.ts.map +1 -0
  254. package/dist/instrumentations/fetch/replay.js +259 -0
  255. package/dist/instrumentations/fetch/replay.js.map +1 -0
  256. package/dist/instrumentations/postgres/capture.d.ts +46 -0
  257. package/dist/instrumentations/postgres/capture.d.ts.map +1 -0
  258. package/dist/instrumentations/postgres/capture.js +68 -0
  259. package/dist/instrumentations/postgres/capture.js.map +1 -0
  260. package/dist/instrumentations/postgres/index.d.ts +6 -0
  261. package/dist/instrumentations/postgres/index.d.ts.map +1 -0
  262. package/dist/instrumentations/postgres/index.js +14 -0
  263. package/dist/instrumentations/postgres/index.js.map +1 -0
  264. package/dist/instrumentations/postgres/replay.d.ts +20 -0
  265. package/dist/instrumentations/postgres/replay.d.ts.map +1 -0
  266. package/dist/instrumentations/postgres/replay.js +163 -0
  267. package/dist/instrumentations/postgres/replay.js.map +1 -0
  268. package/dist/instrumentations/redis/capture.d.ts +20 -0
  269. package/dist/instrumentations/redis/capture.d.ts.map +1 -0
  270. package/dist/instrumentations/redis/capture.js +61 -0
  271. package/dist/instrumentations/redis/capture.js.map +1 -0
  272. package/dist/instrumentations/redis/index.d.ts +6 -0
  273. package/dist/instrumentations/redis/index.d.ts.map +1 -0
  274. package/dist/instrumentations/redis/index.js +13 -0
  275. package/dist/instrumentations/redis/index.js.map +1 -0
  276. package/dist/instrumentations/redis/replay.d.ts +24 -0
  277. package/dist/instrumentations/redis/replay.d.ts.map +1 -0
  278. package/dist/instrumentations/redis/replay.js +173 -0
  279. package/dist/instrumentations/redis/replay.js.map +1 -0
  280. package/dist/replay/express.d.ts +5 -0
  281. package/dist/replay/express.d.ts.map +1 -0
  282. package/dist/replay/express.js +9 -0
  283. package/dist/replay/express.js.map +1 -0
  284. package/dist/replay/extract-key.d.ts +41 -0
  285. package/dist/replay/extract-key.d.ts.map +1 -0
  286. package/dist/replay/extract-key.js +80 -0
  287. package/dist/replay/extract-key.js.map +1 -0
  288. package/dist/replay/fastify.d.ts +5 -0
  289. package/dist/replay/fastify.d.ts.map +1 -0
  290. package/dist/replay/fastify.js +9 -0
  291. package/dist/replay/fastify.js.map +1 -0
  292. package/dist/replay/http.d.ts +5 -0
  293. package/dist/replay/http.d.ts.map +1 -0
  294. package/dist/replay/http.js +10 -0
  295. package/dist/replay/http.js.map +1 -0
  296. package/dist/replay/matcher.d.ts +25 -0
  297. package/dist/replay/matcher.d.ts.map +1 -0
  298. package/dist/replay/matcher.js +83 -0
  299. package/dist/replay/matcher.js.map +1 -0
  300. package/dist/replay/postgres.d.ts +5 -0
  301. package/dist/replay/postgres.d.ts.map +1 -0
  302. package/dist/replay/postgres.js +10 -0
  303. package/dist/replay/postgres.js.map +1 -0
  304. package/dist/replay/redis.d.ts +5 -0
  305. package/dist/replay/redis.d.ts.map +1 -0
  306. package/dist/replay/redis.js +10 -0
  307. package/dist/replay/redis.js.map +1 -0
  308. package/dist/replay/softprobe-matcher.d.ts +41 -0
  309. package/dist/replay/softprobe-matcher.d.ts.map +1 -0
  310. package/dist/replay/softprobe-matcher.js +92 -0
  311. package/dist/replay/softprobe-matcher.js.map +1 -0
  312. package/dist/replay/store-accessor.d.ts +14 -0
  313. package/dist/replay/store-accessor.d.ts.map +1 -0
  314. package/dist/replay/store-accessor.js +26 -0
  315. package/dist/replay/store-accessor.js.map +1 -0
  316. package/dist/replay/topology.d.ts +37 -0
  317. package/dist/replay/topology.d.ts.map +1 -0
  318. package/dist/replay/topology.js +72 -0
  319. package/dist/replay/topology.js.map +1 -0
  320. package/dist/store/cassette-store.d.ts +36 -0
  321. package/dist/store/cassette-store.d.ts.map +1 -0
  322. package/dist/store/cassette-store.js +66 -0
  323. package/dist/store/cassette-store.js.map +1 -0
  324. package/dist/types/schema.d.ts +114 -0
  325. package/dist/types/schema.d.ts.map +1 -0
  326. package/dist/types/schema.js +13 -0
  327. package/dist/types/schema.js.map +1 -0
  328. package/package.json +88 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/cli/diff.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BH,0BAsCC;AAnED,gDAAwB;AACxB,wCAA8C;AAG9C,0GAA0G;AAC1G,SAAS,sBAAsB,CAAC,OAAgC;IAC9D,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACnF,MAAM,MAA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
+ * CLI entry point for softprobe. Usage: softprobe diff <cassette.ndjson> <targetUrl>
4
+ * Task 21.3.1: on mismatch, prints colored diff of recorded vs live and exits 1.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
package/dist/cli.js ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * CLI entry point for softprobe. Usage: softprobe diff <cassette.ndjson> <targetUrl>
5
+ * Task 21.3.1: on mismatch, prints colored diff of recorded vs live and exits 1.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const diff_1 = require("./cli/diff");
9
+ const diff_reporter_1 = require("./cli/diff-reporter");
10
+ const args = process.argv.slice(2);
11
+ const command = args[0];
12
+ const HELP_COMMANDS = new Set(['help', '--help', '-h']);
13
+ const VERSION_COMMANDS = new Set(['version', '--version', '-v']);
14
+ const ignoreBodyPaths = [];
15
+ const positional = [];
16
+ for (let i = 1; i < args.length; i++) {
17
+ if (args[i] === '--ignore-paths' && args[i + 1]) {
18
+ ignoreBodyPaths.push(args[++i]);
19
+ }
20
+ else {
21
+ positional.push(args[i]);
22
+ }
23
+ }
24
+ const file = positional[0];
25
+ const target = positional[1];
26
+ function usage() {
27
+ console.error('Usage: softprobe diff [--ignore-paths <path> ...] <cassette.ndjson> <targetUrl>');
28
+ console.error(' softprobe --help');
29
+ console.error(' softprobe --version');
30
+ console.error(' Replays the recorded inbound request to the target with coordination headers.');
31
+ console.error(' --ignore-paths JSON path to omit from body comparison (e.g. http.headers for upstream variance).');
32
+ }
33
+ function printVersion() {
34
+ // Read version from package metadata at runtime for both dist and ts-node execution.
35
+ // dist/cli.js -> ../package.json, src/cli.ts -> ../package.json
36
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
37
+ const pkg = require('../package.json');
38
+ process.stdout.write(`softprobe ${pkg.version ?? '0.0.0'}\n`);
39
+ }
40
+ /** Extracts recorded status and body from cassette inbound (responsePayload or top-level). */
41
+ function getRecordedResponse(inbound) {
42
+ const payload = inbound.responsePayload;
43
+ return {
44
+ statusCode: payload?.statusCode ?? payload?.status ?? inbound.statusCode,
45
+ body: payload?.body,
46
+ };
47
+ }
48
+ async function main() {
49
+ if (!command || HELP_COMMANDS.has(command)) {
50
+ usage();
51
+ return command ? 0 : 1;
52
+ }
53
+ if (VERSION_COMMANDS.has(command)) {
54
+ printVersion();
55
+ return 0;
56
+ }
57
+ if (command !== 'diff' || !file || !target) {
58
+ usage();
59
+ return 1;
60
+ }
61
+ try {
62
+ const { response, inbound } = await (0, diff_1.runDiff)(file, target);
63
+ const liveBody = await response.text();
64
+ const recorded = getRecordedResponse(inbound);
65
+ const match = (0, diff_reporter_1.reportDiff)(recorded, { status: response.status, body: liveBody }, { ignoreBodyPaths: ignoreBodyPaths.length ? ignoreBodyPaths : undefined });
66
+ if (!match)
67
+ return 1;
68
+ process.stderr.write('softprobe diff: PASS (response matches recording)\n');
69
+ if (liveBody)
70
+ process.stdout.write(liveBody + (liveBody.endsWith('\n') ? '' : '\n'));
71
+ return 0;
72
+ }
73
+ catch (err) {
74
+ console.error(err instanceof Error ? err.message : String(err));
75
+ return 1;
76
+ }
77
+ }
78
+ main()
79
+ .then((code) => process.exit(code))
80
+ .catch((err) => {
81
+ console.error(err);
82
+ process.exit(1);
83
+ });
84
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;GAGG;;AAEH,qCAAqC;AACrC,uDAAiD;AAEjD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACxB,MAAM,aAAa,GAAG,IAAI,GAAG,CA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E,OAAO,CAAC,CAAC;QACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;QAC5E,IAAI,QAAQ;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACrF,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,IAAI,EAAE;KACH,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAClC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Config loader for .softprobe/config.yml.
3
+ * Must be discoverable synchronously at boot (softprobe/init first).
4
+ */
5
+ /**
6
+ * Reads and caches .softprobe/config.yml. Exposes parsed config via get().
7
+ * Accepts optional configPath for testing (fixture path).
8
+ */
9
+ export declare class ConfigManager {
10
+ private cfg;
11
+ private ignoreRegexes;
12
+ constructor(configPath?: string);
13
+ /** Returns the parsed config object. */
14
+ get(): Record<string, unknown>;
15
+ /** Returns compiled ignore-url patterns (for bypass checks). */
16
+ getIgnoreRegexes(): RegExp[];
17
+ /** Returns true if url matches any replay.ignoreUrls pattern; false if no url or no match. */
18
+ shouldIgnore(url?: string): boolean;
19
+ }
20
+ //# sourceMappingURL=config-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-manager.d.ts","sourceRoot":"","sources":["../../src/config/config-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,UAAU,GAAE,MAA4B;IAWpD,wCAAwC;IACxC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI9B,gEAAgE;IAChE,gBAAgB,IAAI,MAAM,EAAE;IAI5B,8FAA8F;IAC9F,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO;CAIpC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Config loader for .softprobe/config.yml.
4
+ * Must be discoverable synchronously at boot (softprobe/init first).
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ConfigManager = void 0;
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const yaml_1 = require("yaml");
13
+ const DEFAULT_CONFIG_PATH = './.softprobe/config.yml';
14
+ /**
15
+ * Reads and caches .softprobe/config.yml. Exposes parsed config via get().
16
+ * Accepts optional configPath for testing (fixture path).
17
+ */
18
+ class ConfigManager {
19
+ constructor(configPath = DEFAULT_CONFIG_PATH) {
20
+ this.ignoreRegexes = [];
21
+ const raw = fs_1.default.readFileSync(configPath, 'utf8');
22
+ this.cfg = (0, yaml_1.parse)(raw);
23
+ /** Default mode when not set in YAML (design: global default for bootstrap). */
24
+ if (this.cfg.mode === undefined) {
25
+ this.cfg.mode = 'PASSTHROUGH';
26
+ }
27
+ const urls = this.cfg.replay?.ignoreUrls ?? [];
28
+ this.ignoreRegexes = urls.map((p) => new RegExp(p));
29
+ }
30
+ /** Returns the parsed config object. */
31
+ get() {
32
+ return this.cfg;
33
+ }
34
+ /** Returns compiled ignore-url patterns (for bypass checks). */
35
+ getIgnoreRegexes() {
36
+ return this.ignoreRegexes;
37
+ }
38
+ /** Returns true if url matches any replay.ignoreUrls pattern; false if no url or no match. */
39
+ shouldIgnore(url) {
40
+ if (url == null || url === '')
41
+ return false;
42
+ return this.ignoreRegexes.some((re) => re.test(url));
43
+ }
44
+ }
45
+ exports.ConfigManager = ConfigManager;
46
+ //# sourceMappingURL=config-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-manager.js","sourceRoot":"","sources":["../../src/config/config-manager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AACpB,+BAA6B;AAE7B,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAEtD;;;GAGG;AACH,MAAa,aAAa;IAIxB,YAAY,aAAqB,mBAAmB;QAF5C,kBAAa,GAAa,EAAE,CAAC;QAGnC,MAAM,GAAG,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,GAAG,GAAG,IAAA,YAAK,EAAC,GAAG,CAA4B,CAAC;QACjD,gFAAgF;QAChF,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,aAAa,CAAC;QAChC,CAAC;QACD,MAAM,IAAI,GAAI,IAAI,CAAC,GAAG,CAAC,MAAgD,EAAE,UAAU,IAAI,EAAE,CAAC;QAC1F,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,wCAAwC;IACxC,GAAG;QACD,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,gEAAgE;IAChE,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,8FAA8F;IAC9F,YAAY,CAAC,GAAY;QACvB,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AA9BD,sCA8BC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Single immutable context API for Softprobe (design-context.md).
3
+ * One module: read via SoftprobeContext getters, write via withData/initGlobal/fromHeaders/run.
4
+ */
5
+ import type { Context } from '@opentelemetry/api';
6
+ import type { Cassette, SoftprobeCassetteRecord, SoftprobeRunOptions } from './types/schema';
7
+ import type { SemanticMatcher } from './core/matcher/matcher';
8
+ import { SoftprobeMatcher } from './core/matcher/softprobe-matcher';
9
+ /** Context key under which softprobe state is stored in OTel Context. Exported for tests. */
10
+ export declare const SOFTPROBE_CONTEXT_KEY: symbol;
11
+ /** Internal stored shape (not exported). */
12
+ interface Stored {
13
+ mode: 'CAPTURE' | 'REPLAY' | 'PASSTHROUGH';
14
+ storage?: Cassette;
15
+ cassetteDirectory?: string;
16
+ traceId?: string;
17
+ strictReplay?: boolean;
18
+ strictComparison?: boolean;
19
+ matcher?: SemanticMatcher | SoftprobeMatcher;
20
+ inboundRecord?: SoftprobeCassetteRecord;
21
+ }
22
+ /** Partial context for run() and withData(); all fields optional. */
23
+ interface PartialData {
24
+ mode?: 'CAPTURE' | 'REPLAY' | 'PASSTHROUGH';
25
+ storage?: Cassette;
26
+ cassetteDirectory?: string;
27
+ traceId?: string;
28
+ strictReplay?: boolean;
29
+ strictComparison?: boolean;
30
+ matcher?: SemanticMatcher | SoftprobeMatcher | unknown;
31
+ inboundRecord?: SoftprobeCassetteRecord;
32
+ }
33
+ /**
34
+ * Returns a cached cassette for a given (cassetteDirectory, traceId) pair.
35
+ * Task 13.5/13.6: only this module creates NdjsonCassette; request-storage and middleware call this.
36
+ */
37
+ declare function getOrCreateCassette(cassetteDirectory: string, traceId: string): Cassette;
38
+ /**
39
+ * Returns the current softprobe state from the given OTel context, or global default when empty.
40
+ * When otelContext is omitted, uses context.active().
41
+ */
42
+ declare function active(otelContext?: Context): Stored;
43
+ /**
44
+ * Returns a new OTel context with the given softprobe data. Does not mutate otelContext.
45
+ */
46
+ declare function withData(otelContext: Context, data: PartialData): Context;
47
+ /**
48
+ * Seeds the global default from config. Call at boot.
49
+ * Task 13.1: accepts cassetteDirectory; when set, runtime cassette paths are derived as {cassetteDirectory}/{traceId}.ndjson.
50
+ */
51
+ declare function initGlobal(config: {
52
+ mode?: string;
53
+ cassetteDirectory?: string;
54
+ storage?: Cassette;
55
+ strictReplay?: boolean;
56
+ strictComparison?: boolean;
57
+ }): void;
58
+ /**
59
+ * Returns a new softprobe state by applying coordination headers over base. Used by middleware.
60
+ */
61
+ declare function fromHeaders(base: Stored, headers: Record<string, string | string[] | undefined>): Stored;
62
+ /**
63
+ * Sets the global matcher used when active context has no matcher (e.g. server REPLAY mode).
64
+ */
65
+ declare function setGlobalReplayMatcher(matcher: SoftprobeMatcher | undefined): void;
66
+ declare function getTraceId(otelContext?: Context): string;
67
+ declare function getMode(otelContext?: Context): 'CAPTURE' | 'REPLAY' | 'PASSTHROUGH';
68
+ declare function getCassette(otelContext?: Context): Cassette | undefined;
69
+ /** Task 13.1: directory for per-trace cassette files; paths are {cassetteDirectory}/{traceId}.ndjson. */
70
+ declare function getCassetteDirectory(otelContext?: Context): string | undefined;
71
+ declare function getScopedCassette(otelContext?: Context): Cassette | undefined;
72
+ declare function getStrictReplay(otelContext?: Context): boolean;
73
+ declare function getStrictComparison(otelContext?: Context): boolean;
74
+ /** Returns the matcher from active context only. */
75
+ declare function getMatcher(otelContext?: Context): SemanticMatcher | SoftprobeMatcher | undefined;
76
+ declare function getInboundRecord(otelContext?: Context): SoftprobeCassetteRecord | undefined;
77
+ declare function run<T>(options: SoftprobeRunOptions, fn: () => T | Promise<T>): T | Promise<T>;
78
+ export declare const SoftprobeContext: {
79
+ active: typeof active;
80
+ getTraceId: typeof getTraceId;
81
+ getMode: typeof getMode;
82
+ getCassette: typeof getCassette;
83
+ getCassetteDirectory: typeof getCassetteDirectory;
84
+ getScopedCassette: typeof getScopedCassette;
85
+ getStrictReplay: typeof getStrictReplay;
86
+ getStrictComparison: typeof getStrictComparison;
87
+ getMatcher: typeof getMatcher;
88
+ getInboundRecord: typeof getInboundRecord;
89
+ withData: typeof withData;
90
+ initGlobal: typeof initGlobal;
91
+ fromHeaders: typeof fromHeaders;
92
+ setGlobalReplayMatcher: typeof setGlobalReplayMatcher;
93
+ run: typeof run;
94
+ /** Task 13.6: Obtain cassette for (directory, traceId) without constructing; used by request-storage/middleware. */
95
+ getOrCreateCassette: typeof getOrCreateCassette;
96
+ };
97
+ export {};
98
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIpE,6FAA6F;AAC7F,eAAO,MAAM,qBAAqB,QAAwC,CAAC;AAE3E,4CAA4C;AAC5C,UAAU,MAAM;IACd,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC3C,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,C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;AAED;;GAEG;AACH,iBAAS,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAE3E;AAED,iBAAS,UAAU,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAEjD;AAED,iBAAS,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAE5E;AAED,iBAAS,WAAW,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAEhE;AAED,yGAAyG;AACzG,iBAAS,oBAAoB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED,iBAAS,iBAAiB,CAAC,WAAW,GAAE,OAA0B,GAAG,QAAQ,GAAG,SAAS,CAGxF;AAED,iBAAS,eAAe,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAEvD;AAED,iBAAS,mBAAmB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAE3D;AAED,oDAAoD;AACpD,iBAAS,UAAU,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,eAAe,GAAG,gBAAgB,GAAG,SAAS,CAIzF;AAED,iBAAS,gBAAgB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,CAEpF;AAcD,iBAAS,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAgCtF;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;IAgB3B,oHAAoH;;CAErH,CAAC"}
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ /**
3
+ * Single immutable context API for Softprobe (design-context.md).
4
+ * One module: read via SoftprobeContext getters, write via withData/initGlobal/fromHeaders/run.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SoftprobeContext = exports.SOFTPROBE_CONTEXT_KEY = void 0;
8
+ const crypto_1 = require("crypto");
9
+ const api_1 = require("@opentelemetry/api");
10
+ const softprobe_matcher_1 = require("./core/matcher/softprobe-matcher");
11
+ const extract_key_1 = require("./core/matcher/extract-key");
12
+ const ndjson_cassette_1 = require("./core/cassette/ndjson-cassette");
13
+ /** Context key under which softprobe state is stored in OTel Context. Exported for tests. */
14
+ exports.SOFTPROBE_CONTEXT_KEY = (0, api_1.createContextKey)('softprobe_context');
15
+ let globalDefault = {
16
+ mode: 'PASSTHROUGH',
17
+ strictReplay: false,
18
+ strictComparison: false,
19
+ };
20
+ let globalReplayMatcher;
21
+ const cassetteByPath = new Map();
22
+ /**
23
+ * Returns a cached cassette for a given (cassetteDirectory, traceId) pair.
24
+ * Task 13.5/13.6: only this module creates NdjsonCassette; request-storage and middleware call this.
25
+ */
26
+ function getOrCreateCassette(cassetteDirectory, traceId) {
27
+ const key = `${cassetteDirectory}::${traceId}`;
28
+ const existing = cassetteByPath.get(key);
29
+ if (existing)
30
+ return existing;
31
+ const created = new ndjson_cassette_1.NdjsonCassette(cassetteDirectory, traceId);
32
+ cassetteByPath.set(key, created);
33
+ return created;
34
+ }
35
+ function merge(base, partial) {
36
+ return {
37
+ ...base,
38
+ ...(partial.mode !== undefined && { mode: partial.mode }),
39
+ ...(partial.storage !== undefined && { storage: partial.storage }),
40
+ ...(partial.cassetteDirectory !== undefined && { cassetteDirectory: partial.cassetteDirectory }),
41
+ ...(partial.traceId !== undefined && { traceId: partial.traceId }),
42
+ ...(partial.strictReplay !== undefined && { strictReplay: partial.strictReplay }),
43
+ ...(partial.strictComparison !== undefined && { strictComparison: partial.strictComparison }),
44
+ ...(partial.matcher !== undefined && { matcher: partial.matcher }),
45
+ ...(partial.inboundRecord !== undefined && { inboundRecord: partial.inboundRecord }),
46
+ };
47
+ }
48
+ /**
49
+ * Returns the current softprobe state from the given OTel context, or global default when empty.
50
+ * When otelContext is omitted, uses context.active().
51
+ */
52
+ function active(otelContext = api_1.context.active()) {
53
+ const value = otelContext.getValue(exports.SOFTPROBE_CONTEXT_KEY);
54
+ return value ?? globalDefault;
55
+ }
56
+ /**
57
+ * Returns a new OTel context with the given softprobe data. Does not mutate otelContext.
58
+ */
59
+ function withData(otelContext, data) {
60
+ const stored = merge(globalDefault, data);
61
+ return otelContext.setValue(exports.SOFTPROBE_CONTEXT_KEY, stored);
62
+ }
63
+ /**
64
+ * Seeds the global default from config. Call at boot.
65
+ * Task 13.1: accepts cassetteDirectory; when set, runtime cassette paths are derived as {cassetteDirectory}/{traceId}.ndjson.
66
+ */
67
+ function initGlobal(config) {
68
+ globalDefault = {
69
+ mode: config.mode || 'PASSTHROUGH',
70
+ ...(config.storage !== undefined && { storage: config.storage }),
71
+ ...(config.cassetteDirectory !== undefined && { cassetteDirectory: config.cassetteDirectory }),
72
+ strictReplay: config.strictReplay ?? false,
73
+ strictComparison: config.strictComparison ?? false,
74
+ };
75
+ }
76
+ const HEADER_MODE = 'x-softprobe-mode';
77
+ const HEADER_TRACE_ID = 'x-softprobe-trace-id';
78
+ function readHeaderValue(headers, key) {
79
+ const value = headers[key];
80
+ if (typeof value === 'string' && value)
81
+ return value;
82
+ if (Array.isArray(value) && typeof value[0] === 'string' && value[0])
83
+ return value[0];
84
+ return undefined;
85
+ }
86
+ /**
87
+ * Returns a new softprobe state by applying coordination headers over base. Used by middleware.
88
+ */
89
+ function fromHeaders(base, headers) {
90
+ const mode = readHeaderValue(headers, HEADER_MODE);
91
+ const traceId = readHeaderValue(headers, HEADER_TRACE_ID);
92
+ return {
93
+ ...base,
94
+ ...(mode && (mode === 'REPLAY' || mode === 'CAPTURE' || mode === 'PASSTHROUGH') && { mode: mode }),
95
+ ...(traceId && { traceId }),
96
+ };
97
+ }
98
+ /**
99
+ * Sets the global matcher used when active context has no matcher (e.g. server REPLAY mode).
100
+ */
101
+ function setGlobalReplayMatcher(matcher) {
102
+ globalReplayMatcher = matcher;
103
+ }
104
+ function getTraceId(otelContext) {
105
+ return active(otelContext).traceId ?? '';
106
+ }
107
+ function getMode(otelContext) {
108
+ return active(otelContext).mode;
109
+ }
110
+ function getCassette(otelContext) {
111
+ return active(otelContext).storage;
112
+ }
113
+ /** Task 13.1: directory for per-trace cassette files; paths are {cassetteDirectory}/{traceId}.ndjson. */
114
+ function getCassetteDirectory(otelContext) {
115
+ return active(otelContext).cassetteDirectory;
116
+ }
117
+ function getScopedCassette(otelContext = api_1.context.active()) {
118
+ const value = otelContext.getValue(exports.SOFTPROBE_CONTEXT_KEY);
119
+ return value?.storage;
120
+ }
121
+ function getStrictReplay(otelContext) {
122
+ return active(otelContext).strictReplay ?? false;
123
+ }
124
+ function getStrictComparison(otelContext) {
125
+ return active(otelContext).strictComparison ?? false;
126
+ }
127
+ /** Returns the matcher from active context only. */
128
+ function getMatcher(otelContext) {
129
+ const ctx = otelContext ?? api_1.context.active();
130
+ const stored = active(ctx);
131
+ return stored.matcher;
132
+ }
133
+ function getInboundRecord(otelContext) {
134
+ return active(otelContext).inboundRecord;
135
+ }
136
+ /** Runs fn inside an OTel scope seeded from required Softprobe run options. */
137
+ function ensureTraceId(stored, fallback) {
138
+ return stored.traceId ? stored : { ...stored, traceId: fallback };
139
+ }
140
+ function resolveStorage(merged, traceId) {
141
+ if (merged.storage)
142
+ return merged.storage;
143
+ const dir = merged.cassetteDirectory;
144
+ if (dir && traceId)
145
+ return getOrCreateCassette(dir, traceId);
146
+ return undefined;
147
+ }
148
+ function run(options, fn) {
149
+ const otelContextAtCall = api_1.context.active();
150
+ const base = active(otelContextAtCall);
151
+ const mergedBase = merge(base, options);
152
+ const defaultTraceId = () => (0, crypto_1.randomBytes)(16).toString('hex');
153
+ if (options.mode === 'REPLAY') {
154
+ const traceId = options.traceId !== undefined && options.traceId !== null
155
+ ? options.traceId
156
+ : mergedBase.traceId || base.traceId || defaultTraceId();
157
+ const storage = resolveStorage(mergedBase, traceId);
158
+ return (async () => {
159
+ if (!storage)
160
+ throw new Error('Softprobe REPLAY requires storage or cassetteDirectory + traceId');
161
+ const records = await storage.loadTrace();
162
+ const matcher = new softprobe_matcher_1.SoftprobeMatcher();
163
+ matcher._setRecords(records);
164
+ matcher.use(options.matcher ?? (0, extract_key_1.createDefaultMatcher)());
165
+ const withReplayData = merge(mergedBase, { matcher, storage });
166
+ const withTraceId = ensureTraceId(withReplayData, traceId);
167
+ // Use context captured when run() was called (e.g. from middleware) so REPLAY scope
168
+ // is attached to the right parent; context.active() here would be wrong after await.
169
+ const ctxWith = withData(otelContextAtCall, withTraceId);
170
+ return api_1.context.with(ctxWith, fn);
171
+ })();
172
+ }
173
+ const withTraceId = ensureTraceId(mergedBase, mergedBase.traceId || base.traceId || defaultTraceId());
174
+ const storage = resolveStorage(mergedBase, withTraceId.traceId);
175
+ const finalStored = storage ? merge(withTraceId, { storage }) : withTraceId;
176
+ const ctxWith = withData(api_1.context.active(), finalStored);
177
+ return api_1.context.with(ctxWith, fn);
178
+ }
179
+ exports.SoftprobeContext = {
180
+ active,
181
+ getTraceId,
182
+ getMode,
183
+ getCassette,
184
+ getCassetteDirectory,
185
+ getScopedCassette,
186
+ getStrictReplay,
187
+ getStrictComparison,
188
+ getMatcher,
189
+ getInboundRecord,
190
+ withData,
191
+ initGlobal,
192
+ fromHeaders,
193
+ setGlobalReplayMatcher,
194
+ run,
195
+ /** Task 13.6: Obtain cassette for (directory, traceId) without constructing; used by request-storage/middleware. */
196
+ getOrCreateCassette,
197
+ };
198
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAqC;AACrC,4CAA+D;AAI/D,wEAAoE;AACpE,4DAAkE;AAClE,qEAAiE;AAEjE,6FAA6F;AAChF,QAAA,qBAAqB,GAAG,IAAA,sBAAgB,EAAC,mBAAmB,CAAC,CAAC;AA0B3E,IAAI,aAAa,GAAW;IA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AqF;YACrF,MAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;YACzD,OAAO,aAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAe,CAAC;QACjD,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IAED,MAAM,WAAW,GAAG,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,IAAI,cAAc,EAAE,CAAC,CAAC;IACtG,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,WAAW,CAAC,OAAQ,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAC5E,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC;IACxD,OAAO,aAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAmB,CAAC;AACrD,CAAC;AAEY,QAAA,gBAAgB,GAAG;IAC9B,MAAM;IACN,UAAU;IACV,OAAO;IACP,WAAW;IACX,oBAAoB;IACpB,iBAAiB;IACjB,eAAe;IACf,mBAAmB;IACnB,UAAU;IACV,gBAAgB;IAChB,QAAQ;IACR,UAAU;IACV,WAAW;IACX,sBAAsB;IACtB,GAAG;IACH,oHAAoH;IACpH,mBAAmB;CACpB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Typed binding for HTTP spans (design §7.2).
3
+ * tagRequest sets protocol, identifier (via httpIdentifier), and optional request body.
4
+ */
5
+ /** Span-like with setAttribute (OTel Span or test span). */
6
+ type SpanLike = {
7
+ setAttribute?(key: string, value: unknown): void;
8
+ } | undefined;
9
+ /** Span-like with readable attributes. */
10
+ type ReadableSpan = {
11
+ attributes?: Record<string, unknown>;
12
+ } | undefined;
13
+ /** Data extracted from an http-tagged span by fromSpan. */
14
+ export type HttpSpanData = {
15
+ protocol: 'http';
16
+ identifier: string;
17
+ };
18
+ /**
19
+ * Tags the span with http protocol and identifier from method + url.
20
+ * Optionally stores a small request body (e.g. bodyText) when provided.
21
+ *
22
+ * @param method - HTTP method (e.g. 'GET', 'POST').
23
+ * @param url - Request URL.
24
+ * @param bodyText - Optional request body string (stored as-is when provided).
25
+ * @param span - Target span; pass test span in tests.
26
+ */
27
+ export declare function tagRequest(method: string, url: string, bodyText?: string, span?: SpanLike): void;
28
+ /**
29
+ * Reads protocol and identifier from a span. Returns http data when the span
30
+ * is tagged with softprobe.protocol === 'http'; otherwise null.
31
+ */
32
+ export declare function fromSpan(span: ReadableSpan): HttpSpanData | null;
33
+ /** HttpSpan namespace for tagRequest and fromSpan. */
34
+ export declare const HttpSpan: {
35
+ tagRequest: typeof tagRequest;
36
+ fromSpan: typeof fromSpan;
37
+ };
38
+ export {};
39
+ //# sourceMappingURL=http-span.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-span.d.ts","sourceRoot":"","sources":["../../../src/core/bindings/http-span.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,4DAA4D;AAC5D,KAAK,QAAQ,GAAG;IAAE,YAAY,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,GAAG,SAAS,CAAC;AAEjF,0CAA0C;AAC1C,KAAK,YAAY,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,SAAS,CAAC;AAEzE,2DAA2D;AAC3D,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,QAAQ,GACd,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,GAAG,IAAI,CAqBhE;AAED,sDAAsD;AACtD,eAAO,MAAM,QAAQ;;;CAA2B,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * Typed binding for HTTP spans (design §7.2).
4
+ * tagRequest sets protocol, identifier (via httpIdentifier), and optional request body.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.HttpSpan = void 0;
8
+ exports.tagRequest = tagRequest;
9
+ exports.fromSpan = fromSpan;
10
+ const identifier_1 = require("../identifier");
11
+ /**
12
+ * Tags the span with http protocol and identifier from method + url.
13
+ * Optionally stores a small request body (e.g. bodyText) when provided.
14
+ *
15
+ * @param method - HTTP method (e.g. 'GET', 'POST').
16
+ * @param url - Request URL.
17
+ * @param bodyText - Optional request body string (stored as-is when provided).
18
+ * @param span - Target span; pass test span in tests.
19
+ */
20
+ function tagRequest(method, url, bodyText, span) {
21
+ if (!span?.setAttribute)
22
+ return;
23
+ span.setAttribute('softprobe.protocol', 'http');
24
+ span.setAttribute('softprobe.identifier', (0, identifier_1.httpIdentifier)(method, url));
25
+ if (bodyText !== undefined) {
26
+ span.setAttribute('softprobe.request.body', bodyText);
27
+ }
28
+ }
29
+ /**
30
+ * Reads protocol and identifier from a span. Returns http data when the span
31
+ * is tagged with softprobe.protocol === 'http'; otherwise null.
32
+ */
33
+ function fromSpan(span) {
34
+ const protocol = span?.attributes?.['softprobe.protocol'];
35
+ if (protocol === 'http') {
36
+ const identifier = span?.attributes?.['softprobe.identifier'];
37
+ if (typeof identifier === 'string')
38
+ return { protocol: 'http', identifier };
39
+ }
40
+ // OTel HTTP client span fallback (no softprobe tagging required).
41
+ const attrs = span?.attributes ?? {};
42
+ const methodRaw = attrs['http.request.method'] ??
43
+ attrs['http.method'] ??
44
+ attrs['http.request.method_original'];
45
+ const urlRaw = attrs['url.full'] ??
46
+ attrs['http.url'] ??
47
+ attrs['http.target'];
48
+ if (typeof methodRaw === 'string' && typeof urlRaw === 'string') {
49
+ return { protocol: 'http', identifier: (0, identifier_1.httpIdentifier)(methodRaw, urlRaw) };
50
+ }
51
+ return null;
52
+ }
53
+ /** HttpSpan namespace for tagRequest and fromSpan. */
54
+ exports.HttpSpan = { tagRequest, fromSpan };
55
+ //# sourceMappingURL=http-span.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-span.js","sourceRoot":"","sources":["../../../src/core/bindings/http-span.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyBH,gCAYC;AAMD,4BAqBC;AA9DD,8CAA+C;AAc/C;;;;;;;;GAQG;AACH,SAAgB,UAAU,CACxB,MAAc,EACd,GAAW,EACX,QAAiB,EACjB,IAAe;IAEf,IAAI,CAAC,IAAI,EAAE,YAAY;QAAE,OAAO;IAChC,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAChD,IAAI,CAAC,YAAY,CAAC,sBAAsB,EAAE,IAAA,2BAAc,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACvE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,YAAY,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,IAAkB;IACzC,MAAM,QAAQ,GAAG,IAAI,EAAE,UAAU,EAAE,CAAC,oBAAoB,CAAC,CAAC;IAC1D,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,EAAE,CAAC,sBAAsB,CAAC,CAAC;QAC9D,IAAI,OAAO,UAAU,KAAK,QAAQ;YAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC9E,CAAC;IAED,kEAAkE;IAClE,MAAM,KAAK,GAAG,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC;IACrC,MAAM,SAAS,GACb,KAAK,CAAC,qBAAqB,CAAC;QAC5B,KAAK,CAAC,aAAa,CAAC;QACpB,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACxC,MAAM,MAAM,GACV,KAAK,CAAC,UAAU,CAAC;QACjB,KAAK,CAAC,UAAU,CAAC;QACjB,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAA,2BAAc,EAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC;IAC7E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sDAAsD;AACzC,QAAA,QAAQ,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared span helper contracts and adapters.
3
+ */
4
+ export { HttpSpan, tagRequest as tagHttpRequest, fromSpan as parseHttpSpan } from './http-span';
5
+ export type { HttpSpanData } from './http-span';
6
+ export { PostgresSpan, tagQuery as tagPostgresQuery, fromSpan as parsePostgresSpan } from './postgres-span';
7
+ export type { PostgresSpanData } from './postgres-span';
8
+ export { RedisSpan, tagCommand as tagRedisCommand, fromSpan as parseRedisSpan } from './redis-span';
9
+ export type { RedisSpanData } from './redis-span';
10
+ export { testSpan } from './test-span';
11
+ export type { TestSpan } from './test-span';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/bindings/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,UAAU,IAAI,cAAc,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAChG,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,QAAQ,IAAI,gBAAgB,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC5G,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,IAAI,eAAe,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AACpG,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}