@q9labsai/chalk-client 4.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 (253) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/dist/access/base64-url.d.ts +2 -0
  4. package/dist/access/base64-url.d.ts.map +1 -0
  5. package/dist/access/episode-diagnostic-credential.d.ts +11 -0
  6. package/dist/access/episode-diagnostic-credential.d.ts.map +1 -0
  7. package/dist/access/grant.d.ts +53 -0
  8. package/dist/access/grant.d.ts.map +1 -0
  9. package/dist/access/grant.test.helpers.d.ts +10 -0
  10. package/dist/access/grant.test.helpers.d.ts.map +1 -0
  11. package/dist/access/manager.d.ts +36 -0
  12. package/dist/access/manager.d.ts.map +1 -0
  13. package/dist/chat-files/http-transport.d.ts +8 -0
  14. package/dist/chat-files/http-transport.d.ts.map +1 -0
  15. package/dist/chat-files/index.d.ts +3 -0
  16. package/dist/chat-files/index.d.ts.map +1 -0
  17. package/dist/chat-files/types.d.ts +37 -0
  18. package/dist/chat-files/types.d.ts.map +1 -0
  19. package/dist/chunk-5VXGLI3T.js +3385 -0
  20. package/dist/chunk-O22WFBKF.js +5161 -0
  21. package/dist/chunk-PBCGWE2V.js +811 -0
  22. package/dist/chunk-PBSYXPNJ.js +23 -0
  23. package/dist/chunk-QVHR3RMB.js +1229 -0
  24. package/dist/client.d.ts +6785 -0
  25. package/dist/client.d.ts.map +1 -0
  26. package/dist/collaboration/index.d.ts +3 -0
  27. package/dist/collaboration/index.d.ts.map +1 -0
  28. package/dist/collaboration/types.d.ts +94 -0
  29. package/dist/collaboration/types.d.ts.map +1 -0
  30. package/dist/collaboration/wire.d.ts +19 -0
  31. package/dist/collaboration/wire.d.ts.map +1 -0
  32. package/dist/connection/dependencies.d.ts +112 -0
  33. package/dist/connection/dependencies.d.ts.map +1 -0
  34. package/dist/connection/diagnostics.d.ts +52 -0
  35. package/dist/connection/diagnostics.d.ts.map +1 -0
  36. package/dist/connection/index.d.ts +47 -0
  37. package/dist/connection/index.d.ts.map +1 -0
  38. package/dist/connection/lifecycle.d.ts +58 -0
  39. package/dist/connection/lifecycle.d.ts.map +1 -0
  40. package/dist/connection/media-devices.d.ts +6 -0
  41. package/dist/connection/media-devices.d.ts.map +1 -0
  42. package/dist/connection/production.d.ts +13 -0
  43. package/dist/connection/production.d.ts.map +1 -0
  44. package/dist/connection/snapshot.d.ts +23 -0
  45. package/dist/connection/snapshot.d.ts.map +1 -0
  46. package/dist/connection/types.d.ts +128 -0
  47. package/dist/connection/types.d.ts.map +1 -0
  48. package/dist/effect.d.ts +19 -0
  49. package/dist/effect.d.ts.map +1 -0
  50. package/dist/effect.js +7846 -0
  51. package/dist/episode-diagnostic-runtime.test.helpers.d.ts +3 -0
  52. package/dist/episode-diagnostic-runtime.test.helpers.d.ts.map +1 -0
  53. package/dist/generated/http-api.d.ts +6658 -0
  54. package/dist/generated/http-api.d.ts.map +1 -0
  55. package/dist/generated/schemas.d.ts +12076 -0
  56. package/dist/generated/schemas.d.ts.map +1 -0
  57. package/dist/generated/sync.d.ts +3947 -0
  58. package/dist/generated/sync.d.ts.map +1 -0
  59. package/dist/generated/whiteboard-v1.d.ts +334 -0
  60. package/dist/generated/whiteboard-v1.d.ts.map +1 -0
  61. package/dist/index.d.ts +10 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +152 -0
  64. package/dist/media/client.d.ts +18 -0
  65. package/dist/media/client.d.ts.map +1 -0
  66. package/dist/media/cloudflare-sfu.d.ts +5 -0
  67. package/dist/media/cloudflare-sfu.d.ts.map +1 -0
  68. package/dist/media/index.d.ts +3 -0
  69. package/dist/media/index.d.ts.map +1 -0
  70. package/dist/media/index.js +24 -0
  71. package/dist/media/plane.d.ts +24 -0
  72. package/dist/media/plane.d.ts.map +1 -0
  73. package/dist/media/tracks.d.ts +21 -0
  74. package/dist/media/tracks.d.ts.map +1 -0
  75. package/dist/media/transport.d.ts +3 -0
  76. package/dist/media/transport.d.ts.map +1 -0
  77. package/dist/media/types.d.ts +114 -0
  78. package/dist/media/types.d.ts.map +1 -0
  79. package/dist/server/chunk-A6YMG5FM.js +61 -0
  80. package/dist/server/client.d.cts +2 -0
  81. package/dist/server/client.d.ts +3 -0
  82. package/dist/server/client.d.ts.map +1 -0
  83. package/dist/server/errors.d.cts +18 -0
  84. package/dist/server/errors.d.ts +19 -0
  85. package/dist/server/errors.d.ts.map +1 -0
  86. package/dist/server/index.cjs +551 -0
  87. package/dist/server/index.d.cts +3 -0
  88. package/dist/server/index.d.ts +4 -0
  89. package/dist/server/index.d.ts.map +1 -0
  90. package/dist/server/index.js +474 -0
  91. package/dist/server/server-only.cjs +40 -0
  92. package/dist/server/server-only.d.cts +1 -0
  93. package/dist/server/server-only.d.ts +2 -0
  94. package/dist/server/server-only.d.ts.map +1 -0
  95. package/dist/server/server-only.js +9 -0
  96. package/dist/server/transport.d.cts +12 -0
  97. package/dist/server/transport.d.ts +13 -0
  98. package/dist/server/transport.d.ts.map +1 -0
  99. package/dist/server/types.d.cts +201 -0
  100. package/dist/server/types.d.ts +202 -0
  101. package/dist/server/types.d.ts.map +1 -0
  102. package/dist/space-client/chat-controller-helpers.d.ts +15 -0
  103. package/dist/space-client/chat-controller-helpers.d.ts.map +1 -0
  104. package/dist/space-client/chat-controller.d.ts +34 -0
  105. package/dist/space-client/chat-controller.d.ts.map +1 -0
  106. package/dist/space-client/controller-effects.d.ts +45 -0
  107. package/dist/space-client/controller-effects.d.ts.map +1 -0
  108. package/dist/space-client/controller-parity.test.helpers.d.ts +150 -0
  109. package/dist/space-client/controller-parity.test.helpers.d.ts.map +1 -0
  110. package/dist/space-client/core.d.ts +52 -0
  111. package/dist/space-client/core.d.ts.map +1 -0
  112. package/dist/space-client/core.test.helpers.d.ts +14 -0
  113. package/dist/space-client/core.test.helpers.d.ts.map +1 -0
  114. package/dist/space-client/effect.d.ts +44 -0
  115. package/dist/space-client/effect.d.ts.map +1 -0
  116. package/dist/space-client/episode-diagnostic-registry.d.ts +13 -0
  117. package/dist/space-client/episode-diagnostic-registry.d.ts.map +1 -0
  118. package/dist/space-client/episode-diagnostic-render-registry.d.ts +4 -0
  119. package/dist/space-client/episode-diagnostic-render-registry.d.ts.map +1 -0
  120. package/dist/space-client/episode-diagnostic-runtime.d.ts +102 -0
  121. package/dist/space-client/episode-diagnostic-runtime.d.ts.map +1 -0
  122. package/dist/space-client/errors.d.ts +11 -0
  123. package/dist/space-client/errors.d.ts.map +1 -0
  124. package/dist/space-client/index.d.ts +5 -0
  125. package/dist/space-client/index.d.ts.map +1 -0
  126. package/dist/space-client/media-controller.d.ts +30 -0
  127. package/dist/space-client/media-controller.d.ts.map +1 -0
  128. package/dist/space-client/media-controller.test.helpers.d.ts +105 -0
  129. package/dist/space-client/media-controller.test.helpers.d.ts.map +1 -0
  130. package/dist/space-client/media-device-selection.d.ts +13 -0
  131. package/dist/space-client/media-device-selection.d.ts.map +1 -0
  132. package/dist/space-client/participants-controller.d.ts +33 -0
  133. package/dist/space-client/participants-controller.d.ts.map +1 -0
  134. package/dist/space-client/promise-facade.d.ts +12 -0
  135. package/dist/space-client/promise-facade.d.ts.map +1 -0
  136. package/dist/space-client/reactions-controller.d.ts +19 -0
  137. package/dist/space-client/reactions-controller.d.ts.map +1 -0
  138. package/dist/space-client/space-client.d.ts +5 -0
  139. package/dist/space-client/space-client.d.ts.map +1 -0
  140. package/dist/space-client/store.d.ts +29 -0
  141. package/dist/space-client/store.d.ts.map +1 -0
  142. package/dist/space-client/types.d.ts +222 -0
  143. package/dist/space-client/types.d.ts.map +1 -0
  144. package/dist/space-client/whiteboard-controller.d.ts +17 -0
  145. package/dist/space-client/whiteboard-controller.d.ts.map +1 -0
  146. package/dist/sync/browser.d.ts +9 -0
  147. package/dist/sync/browser.d.ts.map +1 -0
  148. package/dist/sync/canonical.d.ts +7 -0
  149. package/dist/sync/canonical.d.ts.map +1 -0
  150. package/dist/sync/errors.d.ts +9 -0
  151. package/dist/sync/errors.d.ts.map +1 -0
  152. package/dist/sync/index.d.ts +13 -0
  153. package/dist/sync/index.d.ts.map +1 -0
  154. package/dist/sync/index.js +51 -0
  155. package/dist/sync/react-native.d.ts +42 -0
  156. package/dist/sync/react-native.d.ts.map +1 -0
  157. package/dist/sync/types.d.ts +28 -0
  158. package/dist/sync/types.d.ts.map +1 -0
  159. package/dist/sync/v1-client.d.ts +59 -0
  160. package/dist/sync/v1-client.d.ts.map +1 -0
  161. package/dist/sync/v1-codec.d.ts +5 -0
  162. package/dist/sync/v1-codec.d.ts.map +1 -0
  163. package/dist/sync/v1-create.d.ts +12 -0
  164. package/dist/sync/v1-create.d.ts.map +1 -0
  165. package/dist/sync/v1-persistence.d.ts +10 -0
  166. package/dist/sync/v1-persistence.d.ts.map +1 -0
  167. package/dist/sync/v1-platform-persistence.d.ts +26 -0
  168. package/dist/sync/v1-platform-persistence.d.ts.map +1 -0
  169. package/dist/sync/v1-reducer.d.ts +17 -0
  170. package/dist/sync/v1-reducer.d.ts.map +1 -0
  171. package/dist/sync/v1-types.d.ts +197 -0
  172. package/dist/sync/v1-types.d.ts.map +1 -0
  173. package/dist/telemetry/attributes.d.ts +7 -0
  174. package/dist/telemetry/attributes.d.ts.map +1 -0
  175. package/dist/telemetry/client.d.ts +44 -0
  176. package/dist/telemetry/client.d.ts.map +1 -0
  177. package/dist/telemetry/delivery.d.ts +107 -0
  178. package/dist/telemetry/delivery.d.ts.map +1 -0
  179. package/dist/telemetry/exporter.d.ts +38 -0
  180. package/dist/telemetry/exporter.d.ts.map +1 -0
  181. package/dist/telemetry/index.d.ts +7 -0
  182. package/dist/telemetry/index.d.ts.map +1 -0
  183. package/dist/telemetry/index.js +48 -0
  184. package/dist/telemetry/journey.d.ts +52 -0
  185. package/dist/telemetry/journey.d.ts.map +1 -0
  186. package/dist/telemetry/random.d.ts +18 -0
  187. package/dist/telemetry/random.d.ts.map +1 -0
  188. package/dist/telemetry/rtc.d.ts +35 -0
  189. package/dist/telemetry/rtc.d.ts.map +1 -0
  190. package/dist/telemetry/storage.d.ts +22 -0
  191. package/dist/telemetry/storage.d.ts.map +1 -0
  192. package/dist/telemetry/sync.d.ts +10 -0
  193. package/dist/telemetry/sync.d.ts.map +1 -0
  194. package/dist/telemetry/test-support.d.ts +51 -0
  195. package/dist/telemetry/test-support.d.ts.map +1 -0
  196. package/dist/telemetry/trace.d.ts +18 -0
  197. package/dist/telemetry/trace.d.ts.map +1 -0
  198. package/dist/telemetry/types.d.ts +109 -0
  199. package/dist/telemetry/types.d.ts.map +1 -0
  200. package/dist/webhooks/chunk-UNMJZNTZ.js +31 -0
  201. package/dist/webhooks/errors.d.cts +8 -0
  202. package/dist/webhooks/errors.d.ts +9 -0
  203. package/dist/webhooks/errors.d.ts.map +1 -0
  204. package/dist/webhooks/generated/event-v1.d.cts +764 -0
  205. package/dist/webhooks/generated/event-v1.d.ts +765 -0
  206. package/dist/webhooks/generated/event-v1.d.ts.map +1 -0
  207. package/dist/webhooks/generated/fixtures-v1.d.cts +46 -0
  208. package/dist/webhooks/generated/fixtures-v1.d.ts +47 -0
  209. package/dist/webhooks/generated/fixtures-v1.d.ts.map +1 -0
  210. package/dist/webhooks/index.cjs +1242 -0
  211. package/dist/webhooks/index.d.cts +5 -0
  212. package/dist/webhooks/index.d.ts +6 -0
  213. package/dist/webhooks/index.d.ts.map +1 -0
  214. package/dist/webhooks/index.js +1197 -0
  215. package/dist/webhooks/processor.d.cts +21 -0
  216. package/dist/webhooks/processor.d.ts +22 -0
  217. package/dist/webhooks/processor.d.ts.map +1 -0
  218. package/dist/webhooks/server-only.cjs +36 -0
  219. package/dist/webhooks/server-only.d.cts +1 -0
  220. package/dist/webhooks/server-only.d.ts +2 -0
  221. package/dist/webhooks/server-only.d.ts.map +1 -0
  222. package/dist/webhooks/server-only.js +9 -0
  223. package/dist/webhooks/test.cjs +160 -0
  224. package/dist/webhooks/test.d.cts +42 -0
  225. package/dist/webhooks/test.d.ts +43 -0
  226. package/dist/webhooks/test.d.ts.map +1 -0
  227. package/dist/webhooks/test.js +137 -0
  228. package/dist/webhooks/types.d.cts +55 -0
  229. package/dist/webhooks/types.d.ts +56 -0
  230. package/dist/webhooks/types.d.ts.map +1 -0
  231. package/dist/webhooks/validate.d.cts +5 -0
  232. package/dist/webhooks/validate.d.ts +6 -0
  233. package/dist/webhooks/validate.d.ts.map +1 -0
  234. package/dist/webhooks/verify.d.cts +10 -0
  235. package/dist/webhooks/verify.d.ts +11 -0
  236. package/dist/webhooks/verify.d.ts.map +1 -0
  237. package/dist/whiteboard/file-http-transport.d.ts +9 -0
  238. package/dist/whiteboard/file-http-transport.d.ts.map +1 -0
  239. package/dist/whiteboard/index.d.ts +7 -0
  240. package/dist/whiteboard/index.d.ts.map +1 -0
  241. package/dist/whiteboard/types.d.ts +139 -0
  242. package/dist/whiteboard/types.d.ts.map +1 -0
  243. package/dist/whiteboard/v1-client.d.ts +18 -0
  244. package/dist/whiteboard/v1-client.d.ts.map +1 -0
  245. package/dist/whiteboard/v1-codec.d.ts +5 -0
  246. package/dist/whiteboard/v1-codec.d.ts.map +1 -0
  247. package/dist/whiteboard/v1-create.d.ts +8 -0
  248. package/dist/whiteboard/v1-create.d.ts.map +1 -0
  249. package/dist/whiteboard/v1-multipart.d.ts +30 -0
  250. package/dist/whiteboard/v1-multipart.d.ts.map +1 -0
  251. package/dist/whiteboard/v1-persistence.d.ts +9 -0
  252. package/dist/whiteboard/v1-persistence.d.ts.map +1 -0
  253. package/package.json +222 -0
@@ -0,0 +1,48 @@
1
+ import {
2
+ CHALK_JOURNEY_ID_HEADER,
3
+ TELEMETRY_EVENT_VERSION,
4
+ TRACEPARENT_HEADER,
5
+ TRACESTATE_HEADER,
6
+ TelemetryClient,
7
+ TelemetryJourney,
8
+ createBrowserRuntimeTelemetryStorage,
9
+ createBrowserTelemetryStorage,
10
+ createJourneyIntakeExporter,
11
+ createKeyValueTelemetryStorage,
12
+ createMemoryTelemetryStorage,
13
+ createTelemetryClient,
14
+ createTraceContext,
15
+ journeyHeaders,
16
+ parseTraceparent,
17
+ rtcSummaryAttributes,
18
+ summarizeRtcStats,
19
+ toJourneyIntakeEvent,
20
+ traceContextFromJourney
21
+ } from "../chunk-QVHR3RMB.js";
22
+ import {
23
+ syncTelemetryCorrelation,
24
+ withSyncTelemetryCorrelation
25
+ } from "../chunk-PBSYXPNJ.js";
26
+ export {
27
+ CHALK_JOURNEY_ID_HEADER,
28
+ TELEMETRY_EVENT_VERSION,
29
+ TRACEPARENT_HEADER,
30
+ TRACESTATE_HEADER,
31
+ TelemetryClient,
32
+ TelemetryJourney,
33
+ createBrowserRuntimeTelemetryStorage,
34
+ createBrowserTelemetryStorage,
35
+ createJourneyIntakeExporter,
36
+ createKeyValueTelemetryStorage,
37
+ createMemoryTelemetryStorage,
38
+ createTelemetryClient,
39
+ createTraceContext,
40
+ journeyHeaders,
41
+ parseTraceparent,
42
+ rtcSummaryAttributes,
43
+ summarizeRtcStats,
44
+ syncTelemetryCorrelation,
45
+ toJourneyIntakeEvent,
46
+ traceContextFromJourney,
47
+ withSyncTelemetryCorrelation
48
+ };
@@ -0,0 +1,52 @@
1
+ import { type RtcConnectionStateSnapshot, type RtcStatsLike } from "./rtc";
2
+ import type { TelemetryAttributeNormalizationOptions } from "./attributes";
3
+ import type { JourneyPhase, JourneyState, JourneyTelemetryContext, TelemetryAttributes, TelemetryEvent, TelemetryEventDraft } from "./types";
4
+ export type StartJourneyOptions = {
5
+ readonly attributes?: TelemetryAttributes;
6
+ readonly journeyId?: string;
7
+ readonly kind: string;
8
+ readonly parent?: TelemetryJourney;
9
+ readonly traceparent?: string;
10
+ readonly tracestate?: string;
11
+ };
12
+ export type HttpRequestObservation = {
13
+ readonly durationMs?: number;
14
+ readonly method: string;
15
+ readonly route: string;
16
+ readonly statusCode?: number;
17
+ readonly state?: Extract<JourneyState, "failed" | "observed" | "succeeded">;
18
+ };
19
+ export type SyncFrameObservation = {
20
+ readonly direction: "client_to_server" | "server_to_client";
21
+ readonly frameType: string;
22
+ readonly state?: Extract<JourneyState, "failed" | "observed" | "succeeded">;
23
+ };
24
+ export type DiagnosticObservation = {
25
+ readonly category: "connection" | "device" | "episode" | "network" | "permission" | "recovery" | "whiteboard_renderer";
26
+ readonly code: string;
27
+ readonly attributes?: TelemetryAttributes;
28
+ readonly metricValue?: number;
29
+ readonly phase?: JourneyPhase;
30
+ readonly state?: Extract<JourneyState, "failed" | "observed" | "succeeded">;
31
+ };
32
+ export type JourneyTelemetryHost = {
33
+ emit(context: JourneyTelemetryContext, sequence: number, draft: TelemetryEventDraft, options?: TelemetryAttributeNormalizationOptions): TelemetryEvent;
34
+ startJourney(options: StartJourneyOptions): TelemetryJourney;
35
+ };
36
+ export declare class TelemetryJourney {
37
+ #private;
38
+ readonly context: JourneyTelemetryContext;
39
+ constructor(telemetry: JourneyTelemetryHost, context: JourneyTelemetryContext);
40
+ get headers(): Record<string, string>;
41
+ phase(phase: Exclude<JourneyPhase, "root" | "terminal">, attributes?: TelemetryAttributes): TelemetryEvent | undefined;
42
+ terminal(state: Extract<JourneyState, "cancelled" | "failed" | "succeeded">, attributes?: TelemetryAttributes): TelemetryEvent;
43
+ recordHttpRequest(observation: HttpRequestObservation): TelemetryEvent | undefined;
44
+ recordSyncFrame(observation: SyncFrameObservation): TelemetryEvent | undefined;
45
+ recordRtcSummary(connection: RtcConnectionStateSnapshot, stats: Iterable<RtcStatsLike>, state?: Extract<JourneyState, "failed" | "observed" | "succeeded">): TelemetryEvent | undefined;
46
+ recordDiagnostic(observation: DiagnosticObservation): TelemetryEvent | undefined;
47
+ startChild(options: Omit<StartJourneyOptions, "parent">): TelemetryJourney;
48
+ record(draft: TelemetryEventDraft, options?: TelemetryAttributeNormalizationOptions): TelemetryEvent;
49
+ linkChild(child: JourneyTelemetryContext): string;
50
+ start(kind: string, attributes: TelemetryAttributes | undefined, parentEventId: string | undefined): void;
51
+ }
52
+ //# sourceMappingURL=journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.d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CAAC,WAAW,EAAE,sBAAsB,GAAG,cAAc,GAAG,SAAS,CASjF;IAED,eAAe,CAAC,WAAW,EAAE,oBAAoB,GAAG,cAAc,GAAG,SAAS,CAU7E;IAED,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,GAAE,OAAO,CAAC,YAAY,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAc,GAAG,cAAc,GAAG,SAAS,CAGlM;IAED,gBAAgB,CAAC,WAAW,EAAE,qBAAqB,GAAG,cAAc,GAAG,SAAS,CAiB/E;IAED,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,GAAG,gBAAgB,CAEzE;IAED,MAAM,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,sCAAsC,GAAG,cAAc,CAYnG;IAED,SAAS,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAShD;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAUxG;CACF"}
@@ -0,0 +1,18 @@
1
+ import { Context, Layer } from "effect";
2
+ type TelemetryRandom = {
3
+ readonly nextIntUnsafe: () => number;
4
+ };
5
+ export type TelemetryEventSource = {
6
+ readonly createUuid: () => string;
7
+ readonly now: () => Date;
8
+ readonly randomHex: (byteLength: number) => string;
9
+ };
10
+ declare const TelemetryEventSourceService_base: Context.ServiceClass<TelemetryEventSourceService, "@chalk/telemetry/TelemetryEventSource", TelemetryEventSource>;
11
+ export declare class TelemetryEventSourceService extends TelemetryEventSourceService_base {
12
+ }
13
+ /** Uses Effect's production Clock and Random services, while retaining the public `now` override. */
14
+ export declare const makeTelemetryEventSourceLayer: (now?: () => Date) => Layer.Layer<TelemetryEventSourceService, never, never>;
15
+ export declare function randomHex(byteLength: number, random?: TelemetryRandom): string;
16
+ export declare function createUuid(random?: TelemetryRandom): string;
17
+ export {};
18
+ //# sourceMappingURL=random.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/telemetry/random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAU,KAAK,EAAU,MAAM,QAAQ,CAAC;AAE/D,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,aAAa,EAAE,MAAM,MAAM,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,MAAM,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACpD,CAAC;;AAEF,qBAAa,2BAA4B,SAAQ,gCAA6G;CAAG;AAEjK,qGAAqG;AACrG,eAAO,MAAM,6BAA6B,SAAU,MAAM,IAAI,2DAY3D,CAAC;AAEJ,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAE,eAA+C,GAAG,MAAM,CAE7G;AAED,wBAAgB,UAAU,CAAC,MAAM,GAAE,eAA+C,GAAG,MAAM,CAM1F"}
@@ -0,0 +1,35 @@
1
+ import type { TelemetryAttributes } from "./types";
2
+ export type RtcConnectionStateSnapshot = {
3
+ readonly connectionState?: string;
4
+ readonly iceConnectionState?: string;
5
+ readonly signalingState?: string;
6
+ };
7
+ export type RtcStatsLike = {
8
+ readonly type?: string;
9
+ readonly kind?: string;
10
+ readonly bytesReceived?: number;
11
+ readonly bytesSent?: number;
12
+ readonly framesDropped?: number;
13
+ readonly jitter?: number;
14
+ readonly packetsLost?: number;
15
+ readonly packetsReceived?: number;
16
+ readonly packetsSent?: number;
17
+ readonly roundTripTime?: number;
18
+ };
19
+ export type RtcStatsSummary = {
20
+ readonly bytesReceived: number;
21
+ readonly bytesSent: number;
22
+ readonly framesDropped: number;
23
+ readonly inboundStreams: number;
24
+ readonly jitterMs?: number;
25
+ readonly outboundStreams: number;
26
+ readonly packetsLost: number;
27
+ readonly packetsReceived: number;
28
+ readonly packetsSent: number;
29
+ readonly roundTripTimeMs?: number;
30
+ readonly transportEntries: number;
31
+ };
32
+ export declare function summarizeRtcStats(stats: Iterable<RtcStatsLike>): RtcStatsSummary;
33
+ /** Produces only connection states and aggregated counters. Raw SDP, candidates, tracks, and media content are intentionally excluded. */
34
+ export declare function rtcSummaryAttributes(connection: RtcConnectionStateSnapshot, stats: Iterable<RtcStatsLike>): TelemetryAttributes;
35
+ //# sourceMappingURL=rtc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtc.d.ts","sourceRoot":"","sources":["../../src/telemetry/rtc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC,CAAC;AAgBF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,eAAe,CAoBhF;AAED,0IAA0I;AAC1I,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,0BAA0B,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,mBAAmB,CAkB/H"}
@@ -0,0 +1,22 @@
1
+ import type { TelemetryEvent } from "./types";
2
+ export interface TelemetryStorage {
3
+ load(): Promise<readonly TelemetryEvent[]>;
4
+ save(events: readonly TelemetryEvent[]): Promise<void>;
5
+ }
6
+ export interface TelemetryKeyValueStorage {
7
+ getItem(key: string): Promise<string | null>;
8
+ setItem(key: string, value: string): Promise<void>;
9
+ }
10
+ export declare function createMemoryTelemetryStorage(initialEvents?: readonly TelemetryEvent[]): TelemetryStorage;
11
+ /** Adapts browser storage, Expo storage, or another platform key-value store without adding a platform dependency. */
12
+ export declare function createKeyValueTelemetryStorage(storage: TelemetryKeyValueStorage, key?: string): TelemetryStorage;
13
+ export declare function createBrowserTelemetryStorage(key?: string): TelemetryStorage | undefined;
14
+ /**
15
+ * Creates a durable localStorage queue with a unique runtime key.
16
+ *
17
+ * Each runtime preserves its own queue and adopts sibling queues when it starts.
18
+ * This avoids cross-tab overwrites while allowing a later tab to recover journeys
19
+ * left behind by a closed tab.
20
+ */
21
+ export declare function createBrowserRuntimeTelemetryStorage(keyPrefix?: string): TelemetryStorage | undefined;
22
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/telemetry/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AASD,wBAAgB,4BAA4B,CAAC,aAAa,GAAE,SAAS,cAAc,EAAO,GAAG,gBAAgB,CAW5G;AAED,sHAAsH;AACtH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,wBAAwB,EAAE,GAAG,SAAuB,GAAG,gBAAgB,CAc9H;AAED,wBAAgB,6BAA6B,CAAC,GAAG,SAAuB,GAAG,gBAAgB,GAAG,SAAS,CAetG;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAAC,SAAS,SAAuB,GAAG,gBAAgB,GAAG,SAAS,CAenH"}
@@ -0,0 +1,10 @@
1
+ import type { JourneyTelemetryContext } from "./types";
2
+ export type SyncTelemetryCorrelation = {
3
+ readonly journey_id: string;
4
+ readonly traceparent: string;
5
+ readonly tracestate?: string;
6
+ };
7
+ /** Adds the v1 optional correlation fields accepted by the sync hello frame without changing application frame fields. */
8
+ export declare function withSyncTelemetryCorrelation<TFrame extends object>(frame: TFrame, context: JourneyTelemetryContext): TFrame & SyncTelemetryCorrelation;
9
+ export declare function syncTelemetryCorrelation(context: JourneyTelemetryContext): SyncTelemetryCorrelation;
10
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/telemetry/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAQvD,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAOF,0HAA0H;AAC1H,wBAAgB,4BAA4B,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,GAAG,wBAAwB,CAOtJ;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,uBAAuB,GAAG,wBAAwB,CAEnG"}
@@ -0,0 +1,51 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { TelemetryExporterService, TelemetryStorageService, type TelemetryDeliveryEffectService, type TelemetryDeliveryOptions } from "./delivery";
3
+ import type { TelemetryExporter, TelemetryExportOptions } from "./exporter";
4
+ import type { TelemetryEvent } from "./types";
5
+ export type RecordedExport = {
6
+ readonly events: readonly {
7
+ readonly event_id: string;
8
+ readonly name: string;
9
+ readonly journey_id: string;
10
+ }[];
11
+ readonly options?: TelemetryExportOptions;
12
+ };
13
+ export type ScriptedExporter = {
14
+ readonly calls: RecordedExport[];
15
+ readonly layer: Layer.Layer<TelemetryExporterService>;
16
+ failNext(cause: unknown, retriable: boolean): void;
17
+ waitNext(next?: "succeed" | {
18
+ readonly cause: unknown;
19
+ readonly retriable: boolean;
20
+ }): () => void;
21
+ };
22
+ export declare function makeScriptedExporter(): ScriptedExporter;
23
+ export type ScriptedStorage = {
24
+ readonly saves: readonly (readonly TelemetryEvent[])[];
25
+ readonly layer: Layer.Layer<TelemetryStorageService>;
26
+ resolveLoad(events: readonly TelemetryEvent[]): void;
27
+ };
28
+ export declare function makeScriptedStorage(options?: {
29
+ readonly load?: readonly TelemetryEvent[];
30
+ readonly waitForLoad?: boolean;
31
+ }): ScriptedStorage;
32
+ export type DeferredFacadeExport = {
33
+ release(): void;
34
+ started(): Promise<void>;
35
+ };
36
+ export type DeferredFacadeExporter = {
37
+ readonly calls: RecordedExport[];
38
+ readonly exporter: TelemetryExporter;
39
+ holdNext(): DeferredFacadeExport;
40
+ };
41
+ export declare function makeDeferredFacadeExporter(): DeferredFacadeExporter;
42
+ export type DeliveryHarness = {
43
+ readonly delivery: TelemetryDeliveryEffectService;
44
+ adjust(duration: number): Promise<void>;
45
+ ready(): Promise<void>;
46
+ run<A, E>(effect: Effect.Effect<A, E>): Promise<A>;
47
+ settle(): Promise<void>;
48
+ dispose(): Promise<void>;
49
+ };
50
+ export declare function makeDeliveryHarness(options: Omit<TelemetryDeliveryOptions, "exporter" | "storage">, exporter?: ScriptedExporter, storage?: ScriptedStorage): DeliveryHarness;
51
+ //# sourceMappingURL=test-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-support.d.ts","sourceRoot":"","sources":["../../src/telemetry/test-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAEjE,OAAO,EAAoD,wBAAwB,EAAE,uBAAuB,EAA0C,KAAK,8BAA8B,EAAE,KAAK,wBAAwB,EAAE,M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E,SAAS,cAAc,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,eAAe,CAmBhJ;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,IAAI,oBAAoB,CAAC;CAClC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,sBAAsB,CA4BnE;AAMD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,CAAC;IAClD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,SAAS,CAAC,EAAE,QAAQ,mBAAyB,EAAE,OAAO,kBAAwB,GAAG,eAAe,CAuBxL"}
@@ -0,0 +1,18 @@
1
+ import type { JourneyTelemetryContext } from "./types";
2
+ export declare const CHALK_JOURNEY_ID_HEADER = "x-chalk-journey-id";
3
+ export declare const TRACEPARENT_HEADER = "traceparent";
4
+ export declare const TRACESTATE_HEADER = "tracestate";
5
+ export type TraceContext = {
6
+ readonly traceId: string;
7
+ readonly spanId: string;
8
+ readonly traceFlags: string;
9
+ readonly traceparent: string;
10
+ readonly tracestate?: string;
11
+ };
12
+ type ParsedTraceparent = Omit<TraceContext, "traceparent" | "tracestate">;
13
+ export declare function createTraceContext(parentTraceparent?: string, tracestate?: string): TraceContext;
14
+ export declare function parseTraceparent(value: string | undefined): ParsedTraceparent | undefined;
15
+ export declare function journeyHeaders(context: JourneyTelemetryContext): Record<string, string>;
16
+ export declare function traceContextFromJourney(context: JourneyTelemetryContext): TraceContext;
17
+ export {};
18
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/telemetry/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGvD,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAC5D,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAChD,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,KAAK,iBAAiB,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,YAAY,CAAC,CAAC;AAI1E,wBAAgB,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAahG;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAMzF;AAgBD,wBAAgB,cAAc,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMvF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,uBAAuB,GAAG,YAAY,CAWtF"}
@@ -0,0 +1,109 @@
1
+ export declare const TELEMETRY_EVENT_VERSION: 1;
2
+ export type TelemetryAttributeValue = boolean | number | string;
3
+ export type TelemetryAttributes = Readonly<Record<string, TelemetryAttributeValue>>;
4
+ export type JourneyPhase = "root" | "authentication" | "signaling" | "media" | "recovery" | "terminal";
5
+ export type JourneyState = "started" | "in_progress" | "succeeded" | "failed" | "cancelled" | "observed";
6
+ export type TelemetryOriginKind = "client" | "diagnostic" | "http" | "rtc" | "sync";
7
+ export type TelemetryUpstreamVisibility = "local" | "propagated";
8
+ export type TelemetryEventBase = {
9
+ readonly version: typeof TELEMETRY_EVENT_VERSION;
10
+ readonly event_id: string;
11
+ readonly journey_id: string;
12
+ readonly sequence: number;
13
+ readonly occurred_at: string;
14
+ readonly phase: JourneyPhase;
15
+ readonly state: JourneyState;
16
+ readonly origin_kind: TelemetryOriginKind;
17
+ readonly first_observed_layer: TelemetryOriginKind;
18
+ readonly upstream_visibility: TelemetryUpstreamVisibility;
19
+ readonly parent_event_id?: string;
20
+ readonly trace_id?: string;
21
+ readonly span_id?: string;
22
+ readonly traceparent?: string;
23
+ readonly tracestate?: string;
24
+ readonly attributes?: TelemetryAttributes;
25
+ };
26
+ export type JourneyStartedEvent = TelemetryEventBase & {
27
+ readonly name: "journey.started";
28
+ readonly phase: "root";
29
+ readonly state: "started";
30
+ readonly origin_kind: "client";
31
+ };
32
+ export type JourneyPhaseEvent = TelemetryEventBase & {
33
+ readonly name: "journey.phase";
34
+ readonly phase: Exclude<JourneyPhase, "root" | "terminal">;
35
+ readonly state: "in_progress" | "observed";
36
+ readonly origin_kind: "client";
37
+ };
38
+ export type JourneyTerminalEvent = TelemetryEventBase & {
39
+ readonly name: "journey.terminal";
40
+ readonly phase: "terminal";
41
+ readonly state: "succeeded" | "failed" | "cancelled";
42
+ readonly origin_kind: "client";
43
+ };
44
+ export type JourneyLinkedEvent = TelemetryEventBase & {
45
+ readonly name: "journey.linked";
46
+ readonly phase: "root";
47
+ readonly state: "observed";
48
+ readonly origin_kind: "client";
49
+ readonly parent_event_id: string;
50
+ };
51
+ export type HttpRequestTelemetryEvent = TelemetryEventBase & {
52
+ readonly name: "http.request";
53
+ readonly origin_kind: "http";
54
+ };
55
+ export type SyncFrameTelemetryEvent = TelemetryEventBase & {
56
+ readonly name: "sync.frame";
57
+ readonly origin_kind: "sync";
58
+ };
59
+ export type RtcSummaryTelemetryEvent = TelemetryEventBase & {
60
+ readonly name: "rtc.summary";
61
+ readonly origin_kind: "rtc";
62
+ };
63
+ export type DiagnosticTimelineTelemetryEvent = TelemetryEventBase & {
64
+ readonly name: "diagnostic.timeline";
65
+ readonly origin_kind: "diagnostic";
66
+ };
67
+ /** A stable, versioned client event union. Exporters remove only `version`, because the v1 intake path carries the API version. */
68
+ export type TelemetryEvent = DiagnosticTimelineTelemetryEvent | HttpRequestTelemetryEvent | JourneyLinkedEvent | JourneyPhaseEvent | JourneyStartedEvent | JourneyTerminalEvent | RtcSummaryTelemetryEvent | SyncFrameTelemetryEvent;
69
+ export type TelemetryEventName = TelemetryEvent["name"];
70
+ type TelemetryEventDraftFor<TEvent extends TelemetryEvent> = TEvent extends TelemetryEvent ? Pick<TEvent, "name" | "origin_kind" | "phase" | "state"> & {
71
+ readonly first_observed_layer?: TelemetryOriginKind;
72
+ readonly upstream_visibility?: TelemetryUpstreamVisibility;
73
+ readonly attributes?: TelemetryAttributes;
74
+ } & (TEvent extends {
75
+ readonly parent_event_id: string;
76
+ } ? Pick<TEvent, "parent_event_id"> : {
77
+ readonly parent_event_id?: string;
78
+ }) : never;
79
+ export type TelemetryEventDraft = TelemetryEventDraftFor<TelemetryEvent>;
80
+ export type JourneyTelemetryContext = {
81
+ readonly journeyId: string;
82
+ readonly rootJourneyId: string;
83
+ readonly traceparent: string;
84
+ readonly tracestate?: string;
85
+ };
86
+ export type JourneyIntakeEvent = {
87
+ readonly event_id: string;
88
+ readonly journey_id: string;
89
+ readonly sequence: number;
90
+ readonly occurred_at: string;
91
+ readonly name: TelemetryEventName;
92
+ readonly phase: JourneyPhase;
93
+ readonly state: JourneyState;
94
+ readonly origin_kind: TelemetryOriginKind;
95
+ readonly first_observed_layer: TelemetryOriginKind;
96
+ readonly upstream_visibility: TelemetryUpstreamVisibility;
97
+ readonly parent_event_id?: string;
98
+ readonly trace_id?: string;
99
+ readonly span_id?: string;
100
+ readonly traceparent?: string;
101
+ readonly tracestate?: string;
102
+ readonly attributes?: TelemetryAttributes;
103
+ };
104
+ export type JourneyIntakeResponse = {
105
+ readonly accepted_count: number;
106
+ readonly duplicate_count: number;
107
+ };
108
+ export {};
109
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/telemetry/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAChE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,gBAAgB,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AACvG,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;AACzG,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AACpF,MAAM,MAAM,2BAA2B,GAAG,OAAO,GAAG,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,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B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,CAAC;IACnD,QAAQ,CAAC,mBAAmB,EAAE,2BAA2B,CAAC;IAC1D,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC,CAAC"}
@@ -0,0 +1,31 @@
1
+ // src/webhooks/errors.ts
2
+ var messages = {
3
+ missing_headers: "Required webhook headers are missing.",
4
+ malformed_headers: "Webhook headers are malformed.",
5
+ invalid_secret: "A webhook signing secret is invalid.",
6
+ stale_timestamp: "The webhook timestamp is outside the allowed tolerance.",
7
+ invalid_signature: "The webhook signature is invalid.",
8
+ invalid_json: "The webhook body is not valid JSON.",
9
+ identifier_mismatch: "The webhook identifiers do not match.",
10
+ unsupported_api_version: "The webhook API version is unsupported.",
11
+ invalid_event_body: "The webhook Event body is invalid."
12
+ };
13
+ var WebhookVerificationError = class extends Error {
14
+ code;
15
+ constructor(code) {
16
+ super(messages[code]);
17
+ this.name = "WebhookVerificationError";
18
+ this.code = code;
19
+ }
20
+ };
21
+ var WebhookServerOnlyError = class extends Error {
22
+ constructor() {
23
+ super("Chalk webhook receivers are available only in server and edge runtimes.");
24
+ this.name = "WebhookServerOnlyError";
25
+ }
26
+ };
27
+
28
+ export {
29
+ WebhookVerificationError,
30
+ WebhookServerOnlyError
31
+ };
@@ -0,0 +1,8 @@
1
+ export type WebhookErrorCode = "missing_headers" | "malformed_headers" | "invalid_secret" | "stale_timestamp" | "invalid_signature" | "invalid_json" | "identifier_mismatch" | "unsupported_api_version" | "invalid_event_body";
2
+ export declare class WebhookVerificationError extends Error {
3
+ readonly code: WebhookErrorCode;
4
+ constructor(code: WebhookErrorCode);
5
+ }
6
+ export declare class WebhookServerOnlyError extends Error {
7
+ constructor();
8
+ }
@@ -0,0 +1,9 @@
1
+ export type WebhookErrorCode = "missing_headers" | "malformed_headers" | "invalid_secret" | "stale_timestamp" | "invalid_signature" | "invalid_json" | "identifier_mismatch" | "unsupported_api_version" | "invalid_event_body";
2
+ export declare class WebhookVerificationError extends Error {
3
+ readonly code: WebhookErrorCode;
4
+ constructor(code: WebhookErrorCode);
5
+ }
6
+ export declare class WebhookServerOnlyError extends Error {
7
+ constructor();
8
+ }
9
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/webhooks/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,cAAc,GAAG,qBAAqB,GAAG,yBAAyB,GAAG,oBAAoB,CAAC;AAchO,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC,YAAY,IAAI,EAAE,gBAAgB,EAIjC;CACF;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,cAGC;CACF"}