@flowrensic/temporal-flowrensic-node-sdk 0.0.0-stage → 0.6.64

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 (235) hide show
  1. package/README.md +151 -2
  2. package/dist/cjs/ci.d.ts +47 -0
  3. package/dist/cjs/ci.d.ts.map +1 -0
  4. package/dist/cjs/ci.js +70 -0
  5. package/dist/cjs/ci.js.map +1 -0
  6. package/dist/cjs/client-interceptor.d.ts +46 -0
  7. package/dist/cjs/client-interceptor.d.ts.map +1 -0
  8. package/dist/cjs/client-interceptor.js +129 -0
  9. package/dist/cjs/client-interceptor.js.map +1 -0
  10. package/dist/cjs/client.d.ts +44 -0
  11. package/dist/cjs/client.d.ts.map +1 -0
  12. package/dist/cjs/client.js +77 -0
  13. package/dist/cjs/client.js.map +1 -0
  14. package/dist/cjs/gen/flowrensic/v1/activity_metrics_pb.d.ts +702 -0
  15. package/dist/cjs/gen/flowrensic/v1/activity_metrics_pb.d.ts.map +1 -0
  16. package/dist/cjs/gen/flowrensic/v1/activity_metrics_pb.js +123 -0
  17. package/dist/cjs/gen/flowrensic/v1/activity_metrics_pb.js.map +1 -0
  18. package/dist/cjs/gen/flowrensic/v1/catalog_pb.d.ts +314 -0
  19. package/dist/cjs/gen/flowrensic/v1/catalog_pb.d.ts.map +1 -0
  20. package/dist/cjs/gen/flowrensic/v1/catalog_pb.js +92 -0
  21. package/dist/cjs/gen/flowrensic/v1/catalog_pb.js.map +1 -0
  22. package/dist/cjs/gen/flowrensic/v1/catch_up_pb.d.ts +180 -0
  23. package/dist/cjs/gen/flowrensic/v1/catch_up_pb.d.ts.map +1 -0
  24. package/dist/cjs/gen/flowrensic/v1/catch_up_pb.js +29 -0
  25. package/dist/cjs/gen/flowrensic/v1/catch_up_pb.js.map +1 -0
  26. package/dist/cjs/gen/flowrensic/v1/client_calls_pb.d.ts +216 -0
  27. package/dist/cjs/gen/flowrensic/v1/client_calls_pb.d.ts.map +1 -0
  28. package/dist/cjs/gen/flowrensic/v1/client_calls_pb.js +69 -0
  29. package/dist/cjs/gen/flowrensic/v1/client_calls_pb.js.map +1 -0
  30. package/dist/cjs/gen/flowrensic/v1/cost_pb.d.ts +257 -0
  31. package/dist/cjs/gen/flowrensic/v1/cost_pb.d.ts.map +1 -0
  32. package/dist/cjs/gen/flowrensic/v1/cost_pb.js +54 -0
  33. package/dist/cjs/gen/flowrensic/v1/cost_pb.js.map +1 -0
  34. package/dist/cjs/gen/flowrensic/v1/deploy_pb.d.ts +222 -0
  35. package/dist/cjs/gen/flowrensic/v1/deploy_pb.d.ts.map +1 -0
  36. package/dist/cjs/gen/flowrensic/v1/deploy_pb.js +53 -0
  37. package/dist/cjs/gen/flowrensic/v1/deploy_pb.js.map +1 -0
  38. package/dist/cjs/gen/flowrensic/v1/ephemeral_run_pb.d.ts +850 -0
  39. package/dist/cjs/gen/flowrensic/v1/ephemeral_run_pb.d.ts.map +1 -0
  40. package/dist/cjs/gen/flowrensic/v1/ephemeral_run_pb.js +170 -0
  41. package/dist/cjs/gen/flowrensic/v1/ephemeral_run_pb.js.map +1 -0
  42. package/dist/cjs/gen/flowrensic/v1/finding_pb.d.ts +896 -0
  43. package/dist/cjs/gen/flowrensic/v1/finding_pb.d.ts.map +1 -0
  44. package/dist/cjs/gen/flowrensic/v1/finding_pb.js +451 -0
  45. package/dist/cjs/gen/flowrensic/v1/finding_pb.js.map +1 -0
  46. package/dist/cjs/gen/flowrensic/v1/job_pb.d.ts +104 -0
  47. package/dist/cjs/gen/flowrensic/v1/job_pb.d.ts.map +1 -0
  48. package/dist/cjs/gen/flowrensic/v1/job_pb.js +28 -0
  49. package/dist/cjs/gen/flowrensic/v1/job_pb.js.map +1 -0
  50. package/dist/cjs/gen/flowrensic/v1/load_pb.d.ts +333 -0
  51. package/dist/cjs/gen/flowrensic/v1/load_pb.d.ts.map +1 -0
  52. package/dist/cjs/gen/flowrensic/v1/load_pb.js +53 -0
  53. package/dist/cjs/gen/flowrensic/v1/load_pb.js.map +1 -0
  54. package/dist/cjs/gen/flowrensic/v1/page_pb.d.ts +67 -0
  55. package/dist/cjs/gen/flowrensic/v1/page_pb.d.ts.map +1 -0
  56. package/dist/cjs/gen/flowrensic/v1/page_pb.js +22 -0
  57. package/dist/cjs/gen/flowrensic/v1/page_pb.js.map +1 -0
  58. package/dist/cjs/gen/flowrensic/v1/remediation_pb.d.ts +395 -0
  59. package/dist/cjs/gen/flowrensic/v1/remediation_pb.d.ts.map +1 -0
  60. package/dist/cjs/gen/flowrensic/v1/remediation_pb.js +103 -0
  61. package/dist/cjs/gen/flowrensic/v1/remediation_pb.js.map +1 -0
  62. package/dist/cjs/gen/flowrensic/v1/replay_pb.d.ts +805 -0
  63. package/dist/cjs/gen/flowrensic/v1/replay_pb.d.ts.map +1 -0
  64. package/dist/cjs/gen/flowrensic/v1/replay_pb.js +179 -0
  65. package/dist/cjs/gen/flowrensic/v1/replay_pb.js.map +1 -0
  66. package/dist/cjs/gen/flowrensic/v1/server_config_pb.d.ts +220 -0
  67. package/dist/cjs/gen/flowrensic/v1/server_config_pb.d.ts.map +1 -0
  68. package/dist/cjs/gen/flowrensic/v1/server_config_pb.js +44 -0
  69. package/dist/cjs/gen/flowrensic/v1/server_config_pb.js.map +1 -0
  70. package/dist/cjs/gen/flowrensic/v1/services_pb.d.ts +561 -0
  71. package/dist/cjs/gen/flowrensic/v1/services_pb.d.ts.map +1 -0
  72. package/dist/cjs/gen/flowrensic/v1/services_pb.js +59 -0
  73. package/dist/cjs/gen/flowrensic/v1/services_pb.js.map +1 -0
  74. package/dist/cjs/gen/flowrensic/v1/stored_data_pb.d.ts +120 -0
  75. package/dist/cjs/gen/flowrensic/v1/stored_data_pb.d.ts.map +1 -0
  76. package/dist/cjs/gen/flowrensic/v1/stored_data_pb.js +33 -0
  77. package/dist/cjs/gen/flowrensic/v1/stored_data_pb.js.map +1 -0
  78. package/dist/cjs/gen/flowrensic/v1/workflow_history_pb.d.ts +204 -0
  79. package/dist/cjs/gen/flowrensic/v1/workflow_history_pb.d.ts.map +1 -0
  80. package/dist/cjs/gen/flowrensic/v1/workflow_history_pb.js +135 -0
  81. package/dist/cjs/gen/flowrensic/v1/workflow_history_pb.js.map +1 -0
  82. package/dist/cjs/gen/flowrensic/v1/workflow_types_pb.d.ts +505 -0
  83. package/dist/cjs/gen/flowrensic/v1/workflow_types_pb.d.ts.map +1 -0
  84. package/dist/cjs/gen/flowrensic/v1/workflow_types_pb.js +56 -0
  85. package/dist/cjs/gen/flowrensic/v1/workflow_types_pb.js.map +1 -0
  86. package/dist/cjs/index.d.ts +29 -0
  87. package/dist/cjs/index.d.ts.map +1 -0
  88. package/dist/cjs/index.js +49 -0
  89. package/dist/cjs/index.js.map +1 -0
  90. package/dist/cjs/interceptor-names.d.ts +11 -0
  91. package/dist/cjs/interceptor-names.d.ts.map +1 -0
  92. package/dist/cjs/interceptor-names.js +27 -0
  93. package/dist/cjs/interceptor-names.js.map +1 -0
  94. package/dist/cjs/interceptor.d.ts +39 -0
  95. package/dist/cjs/interceptor.d.ts.map +1 -0
  96. package/dist/cjs/interceptor.js +113 -0
  97. package/dist/cjs/interceptor.js.map +1 -0
  98. package/dist/cjs/package.json +1 -0
  99. package/dist/cjs/query-sink.d.ts +31 -0
  100. package/dist/cjs/query-sink.d.ts.map +1 -0
  101. package/dist/cjs/query-sink.js +64 -0
  102. package/dist/cjs/query-sink.js.map +1 -0
  103. package/dist/cjs/replay.d.ts +119 -0
  104. package/dist/cjs/replay.d.ts.map +1 -0
  105. package/dist/cjs/replay.js +204 -0
  106. package/dist/cjs/replay.js.map +1 -0
  107. package/dist/cjs/sink.d.ts +79 -0
  108. package/dist/cjs/sink.d.ts.map +1 -0
  109. package/dist/cjs/sink.js +320 -0
  110. package/dist/cjs/sink.js.map +1 -0
  111. package/dist/cjs/telemetry.d.ts +128 -0
  112. package/dist/cjs/telemetry.d.ts.map +1 -0
  113. package/dist/cjs/telemetry.js +420 -0
  114. package/dist/cjs/telemetry.js.map +1 -0
  115. package/dist/cjs/workflow.d.ts +15 -0
  116. package/dist/cjs/workflow.d.ts.map +1 -0
  117. package/dist/cjs/workflow.js +39 -0
  118. package/dist/cjs/workflow.js.map +1 -0
  119. package/dist/esm/ci.d.ts +47 -0
  120. package/dist/esm/ci.d.ts.map +1 -0
  121. package/dist/esm/ci.js +64 -0
  122. package/dist/esm/ci.js.map +1 -0
  123. package/dist/esm/client-interceptor.d.ts +46 -0
  124. package/dist/esm/client-interceptor.d.ts.map +1 -0
  125. package/dist/esm/client-interceptor.js +124 -0
  126. package/dist/esm/client-interceptor.js.map +1 -0
  127. package/dist/esm/client.d.ts +44 -0
  128. package/dist/esm/client.d.ts.map +1 -0
  129. package/dist/esm/client.js +69 -0
  130. package/dist/esm/client.js.map +1 -0
  131. package/dist/esm/gen/flowrensic/v1/activity_metrics_pb.d.ts +702 -0
  132. package/dist/esm/gen/flowrensic/v1/activity_metrics_pb.d.ts.map +1 -0
  133. package/dist/esm/gen/flowrensic/v1/activity_metrics_pb.js +120 -0
  134. package/dist/esm/gen/flowrensic/v1/activity_metrics_pb.js.map +1 -0
  135. package/dist/esm/gen/flowrensic/v1/catalog_pb.d.ts +314 -0
  136. package/dist/esm/gen/flowrensic/v1/catalog_pb.d.ts.map +1 -0
  137. package/dist/esm/gen/flowrensic/v1/catalog_pb.js +89 -0
  138. package/dist/esm/gen/flowrensic/v1/catalog_pb.js.map +1 -0
  139. package/dist/esm/gen/flowrensic/v1/catch_up_pb.d.ts +180 -0
  140. package/dist/esm/gen/flowrensic/v1/catch_up_pb.d.ts.map +1 -0
  141. package/dist/esm/gen/flowrensic/v1/catch_up_pb.js +26 -0
  142. package/dist/esm/gen/flowrensic/v1/catch_up_pb.js.map +1 -0
  143. package/dist/esm/gen/flowrensic/v1/client_calls_pb.d.ts +216 -0
  144. package/dist/esm/gen/flowrensic/v1/client_calls_pb.d.ts.map +1 -0
  145. package/dist/esm/gen/flowrensic/v1/client_calls_pb.js +66 -0
  146. package/dist/esm/gen/flowrensic/v1/client_calls_pb.js.map +1 -0
  147. package/dist/esm/gen/flowrensic/v1/cost_pb.d.ts +257 -0
  148. package/dist/esm/gen/flowrensic/v1/cost_pb.d.ts.map +1 -0
  149. package/dist/esm/gen/flowrensic/v1/cost_pb.js +51 -0
  150. package/dist/esm/gen/flowrensic/v1/cost_pb.js.map +1 -0
  151. package/dist/esm/gen/flowrensic/v1/deploy_pb.d.ts +222 -0
  152. package/dist/esm/gen/flowrensic/v1/deploy_pb.d.ts.map +1 -0
  153. package/dist/esm/gen/flowrensic/v1/deploy_pb.js +50 -0
  154. package/dist/esm/gen/flowrensic/v1/deploy_pb.js.map +1 -0
  155. package/dist/esm/gen/flowrensic/v1/ephemeral_run_pb.d.ts +850 -0
  156. package/dist/esm/gen/flowrensic/v1/ephemeral_run_pb.d.ts.map +1 -0
  157. package/dist/esm/gen/flowrensic/v1/ephemeral_run_pb.js +167 -0
  158. package/dist/esm/gen/flowrensic/v1/ephemeral_run_pb.js.map +1 -0
  159. package/dist/esm/gen/flowrensic/v1/finding_pb.d.ts +896 -0
  160. package/dist/esm/gen/flowrensic/v1/finding_pb.d.ts.map +1 -0
  161. package/dist/esm/gen/flowrensic/v1/finding_pb.js +448 -0
  162. package/dist/esm/gen/flowrensic/v1/finding_pb.js.map +1 -0
  163. package/dist/esm/gen/flowrensic/v1/job_pb.d.ts +104 -0
  164. package/dist/esm/gen/flowrensic/v1/job_pb.d.ts.map +1 -0
  165. package/dist/esm/gen/flowrensic/v1/job_pb.js +25 -0
  166. package/dist/esm/gen/flowrensic/v1/job_pb.js.map +1 -0
  167. package/dist/esm/gen/flowrensic/v1/load_pb.d.ts +333 -0
  168. package/dist/esm/gen/flowrensic/v1/load_pb.d.ts.map +1 -0
  169. package/dist/esm/gen/flowrensic/v1/load_pb.js +50 -0
  170. package/dist/esm/gen/flowrensic/v1/load_pb.js.map +1 -0
  171. package/dist/esm/gen/flowrensic/v1/page_pb.d.ts +67 -0
  172. package/dist/esm/gen/flowrensic/v1/page_pb.d.ts.map +1 -0
  173. package/dist/esm/gen/flowrensic/v1/page_pb.js +19 -0
  174. package/dist/esm/gen/flowrensic/v1/page_pb.js.map +1 -0
  175. package/dist/esm/gen/flowrensic/v1/remediation_pb.d.ts +395 -0
  176. package/dist/esm/gen/flowrensic/v1/remediation_pb.d.ts.map +1 -0
  177. package/dist/esm/gen/flowrensic/v1/remediation_pb.js +100 -0
  178. package/dist/esm/gen/flowrensic/v1/remediation_pb.js.map +1 -0
  179. package/dist/esm/gen/flowrensic/v1/replay_pb.d.ts +805 -0
  180. package/dist/esm/gen/flowrensic/v1/replay_pb.d.ts.map +1 -0
  181. package/dist/esm/gen/flowrensic/v1/replay_pb.js +176 -0
  182. package/dist/esm/gen/flowrensic/v1/replay_pb.js.map +1 -0
  183. package/dist/esm/gen/flowrensic/v1/server_config_pb.d.ts +220 -0
  184. package/dist/esm/gen/flowrensic/v1/server_config_pb.d.ts.map +1 -0
  185. package/dist/esm/gen/flowrensic/v1/server_config_pb.js +41 -0
  186. package/dist/esm/gen/flowrensic/v1/server_config_pb.js.map +1 -0
  187. package/dist/esm/gen/flowrensic/v1/services_pb.d.ts +561 -0
  188. package/dist/esm/gen/flowrensic/v1/services_pb.d.ts.map +1 -0
  189. package/dist/esm/gen/flowrensic/v1/services_pb.js +56 -0
  190. package/dist/esm/gen/flowrensic/v1/services_pb.js.map +1 -0
  191. package/dist/esm/gen/flowrensic/v1/stored_data_pb.d.ts +120 -0
  192. package/dist/esm/gen/flowrensic/v1/stored_data_pb.d.ts.map +1 -0
  193. package/dist/esm/gen/flowrensic/v1/stored_data_pb.js +30 -0
  194. package/dist/esm/gen/flowrensic/v1/stored_data_pb.js.map +1 -0
  195. package/dist/esm/gen/flowrensic/v1/workflow_history_pb.d.ts +204 -0
  196. package/dist/esm/gen/flowrensic/v1/workflow_history_pb.d.ts.map +1 -0
  197. package/dist/esm/gen/flowrensic/v1/workflow_history_pb.js +132 -0
  198. package/dist/esm/gen/flowrensic/v1/workflow_history_pb.js.map +1 -0
  199. package/dist/esm/gen/flowrensic/v1/workflow_types_pb.d.ts +505 -0
  200. package/dist/esm/gen/flowrensic/v1/workflow_types_pb.d.ts.map +1 -0
  201. package/dist/esm/gen/flowrensic/v1/workflow_types_pb.js +53 -0
  202. package/dist/esm/gen/flowrensic/v1/workflow_types_pb.js.map +1 -0
  203. package/dist/esm/index.d.ts +29 -0
  204. package/dist/esm/index.d.ts.map +1 -0
  205. package/dist/esm/index.js +16 -0
  206. package/dist/esm/index.js.map +1 -0
  207. package/dist/esm/interceptor-names.d.ts +11 -0
  208. package/dist/esm/interceptor-names.d.ts.map +1 -0
  209. package/dist/esm/interceptor-names.js +23 -0
  210. package/dist/esm/interceptor-names.js.map +1 -0
  211. package/dist/esm/interceptor.d.ts +39 -0
  212. package/dist/esm/interceptor.d.ts.map +1 -0
  213. package/dist/esm/interceptor.js +108 -0
  214. package/dist/esm/interceptor.js.map +1 -0
  215. package/dist/esm/query-sink.d.ts +31 -0
  216. package/dist/esm/query-sink.d.ts.map +1 -0
  217. package/dist/esm/query-sink.js +61 -0
  218. package/dist/esm/query-sink.js.map +1 -0
  219. package/dist/esm/replay.d.ts +119 -0
  220. package/dist/esm/replay.d.ts.map +1 -0
  221. package/dist/esm/replay.js +197 -0
  222. package/dist/esm/replay.js.map +1 -0
  223. package/dist/esm/sink.d.ts +79 -0
  224. package/dist/esm/sink.d.ts.map +1 -0
  225. package/dist/esm/sink.js +315 -0
  226. package/dist/esm/sink.js.map +1 -0
  227. package/dist/esm/telemetry.d.ts +128 -0
  228. package/dist/esm/telemetry.d.ts.map +1 -0
  229. package/dist/esm/telemetry.js +414 -0
  230. package/dist/esm/telemetry.js.map +1 -0
  231. package/dist/esm/workflow.d.ts +15 -0
  232. package/dist/esm/workflow.d.ts.map +1 -0
  233. package/dist/esm/workflow.js +35 -0
  234. package/dist/esm/workflow.js.map +1 -0
  235. package/package.json +75 -4
@@ -0,0 +1,47 @@
1
+ /** Whether a call failed because nothing answered in time or no connection could be made. */
2
+ export declare function notReached(error: unknown): boolean;
3
+ /**
4
+ * The message a CI call stops with: that Flowrensic could not be reached in
5
+ * time, or what it answered, the code in brackets as Connect writes it and the
6
+ * message. what names the call, such as deploy report.
7
+ */
8
+ export declare function ciFailure(what: string, serverBaseUrl: string, timeoutMs: number, error: unknown): string;
9
+ /**
10
+ * The error a CI call that has to fail throws. An answer of Flowrensic is
11
+ * passed on as the ConnectError it is, whose text is the code in brackets and
12
+ * the message, so a caller can still read its code. Anything else gets the
13
+ * message that says Flowrensic could not be reached.
14
+ */
15
+ export declare function ciError(what: string, serverBaseUrl: string, timeoutMs: number, error: unknown): Error;
16
+ export interface DeployStageOptions {
17
+ /** The Flowrensic server to send to. */
18
+ serverBaseUrl: string;
19
+ /** The env of the deploy, sent in the header Flowrensic-Current-Env. */
20
+ currentEnv: string;
21
+ /** The access key of the env. */
22
+ envAccessKey: string;
23
+ /** The ephemeral run of the env, such as the CI build number. For an env of kind ephemeral, without one the run is default. */
24
+ currentEphemeralRun?: string;
25
+ deployId: string;
26
+ /** initiated, started, replay, testsStarted, testsDone or finished. */
27
+ stage: string;
28
+ declaredStages?: readonly string[];
29
+ rollingOutVersion?: string;
30
+ outcome?: string;
31
+ /** How long the report may take, in milliseconds. Left out, 10 seconds. */
32
+ timeoutMs?: number;
33
+ /**
34
+ * Whether a report that failed rejects, so the CI job fails. Left out,
35
+ * false: the report resolves with sent false and the message.
36
+ */
37
+ failOnError?: boolean;
38
+ }
39
+ export interface DeployStageResult {
40
+ /** Whether Flowrensic took the write. */
41
+ readonly sent: boolean;
42
+ /** What happened, in one line, for the CI log. */
43
+ readonly message: string;
44
+ }
45
+ /** Sends one stage of a deploy to Flowrensic, with a time limit, and never hangs. */
46
+ export declare function reportDeployStage(options: DeployStageOptions): Promise<DeployStageResult>;
47
+ //# sourceMappingURL=ci.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../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} from '@connectrpc/connect';
2
+ import { contextOf, createFlowrensicClient } from './client.js';
3
+ /** The name Connect gives a code on the wire, such as failed_precondition. */
4
+ function codeName(code) {
5
+ return Code[code].replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
6
+ }
7
+ /** Whether a call failed because nothing answered in time or no connection could be made. */
8
+ export function notReached(error) {
9
+ if (!(error instanceof ConnectError))
10
+ return true;
11
+ if (error.code === Code.DeadlineExceeded || error.code === Code.Canceled)
12
+ return true;
13
+ const cause = error.cause;
14
+ return typeof cause === 'object' && cause !== null && 'code' in cause && typeof cause.code === 'string' && /^E[A-Z]+$/.test(cause.code);
15
+ }
16
+ /**
17
+ * The message a CI call stops with: that Flowrensic could not be reached in
18
+ * time, or what it answered, the code in brackets as Connect writes it and the
19
+ * message. what names the call, such as deploy report.
20
+ */
21
+ export function ciFailure(what, serverBaseUrl, timeoutMs, error) {
22
+ if (notReached(error)) {
23
+ const cause = error instanceof ConnectError ? error.rawMessage : error instanceof Error ? error.message : String(error);
24
+ return `${what}: Flowrensic at ${serverBaseUrl} could not be reached within ${String(timeoutMs / 1000)} seconds: ${cause}`;
25
+ }
26
+ if (!(error instanceof ConnectError))
27
+ return `${what}: Flowrensic at ${serverBaseUrl} failed: ${String(error)}`;
28
+ return `${what}: Flowrensic at ${serverBaseUrl} answered [${codeName(error.code)}] ${error.rawMessage}`;
29
+ }
30
+ /**
31
+ * The error a CI call that has to fail throws. An answer of Flowrensic is
32
+ * passed on as the ConnectError it is, whose text is the code in brackets and
33
+ * the message, so a caller can still read its code. Anything else gets the
34
+ * message that says Flowrensic could not be reached.
35
+ */
36
+ export function ciError(what, serverBaseUrl, timeoutMs, error) {
37
+ if (error instanceof ConnectError && !notReached(error))
38
+ return error;
39
+ return new Error(ciFailure(what, serverBaseUrl, timeoutMs, error), { cause: error });
40
+ }
41
+ const deployReportTimeoutMs = 10_000;
42
+ /** Sends one stage of a deploy to Flowrensic, with a time limit, and never hangs. */
43
+ export async function reportDeployStage(options) {
44
+ const { serverBaseUrl, deployId, stage } = options;
45
+ const timeoutMs = options.timeoutMs ?? deployReportTimeoutMs;
46
+ const client = createFlowrensicClient(serverBaseUrl, contextOf(options));
47
+ try {
48
+ await client.ingest.ingestDeployStage({
49
+ deployId,
50
+ stage,
51
+ declaredStages: [...(options.declaredStages ?? [])],
52
+ rollingOutVersion: options.rollingOutVersion ?? '',
53
+ outcome: options.outcome ?? '',
54
+ }, { timeoutMs });
55
+ return { sent: true, message: `deploy report: Flowrensic at ${serverBaseUrl} took the stage ${stage} of ${deployId}` };
56
+ }
57
+ catch (error) {
58
+ const message = ciFailure('deploy report', serverBaseUrl, timeoutMs, error);
59
+ if (options.failOnError === true)
60
+ throw ciError('deploy report', serverBaseUrl, timeoutMs, error);
61
+ return { sent: false, message };
62
+ }
63
+ }
64
+ //# sourceMappingURL=ci.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci.js","sourceRoot":"","sources":["../../src/ci.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEhE,8EAA8E;AAC9E,SAAS,QAAQ,CAAC,IAAU;IAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACtE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,CAAC,CAAC,KAAK,YAAY,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACtF,MAAM,KAAK,GAAY,KAAK,CAAC,KAAK,CAAC;IACnC,OAAO,OAAO,KAAK,K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AM,qBAAqB,GAAG,MAAM,CAAC;AAErC,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA2B;IACjE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACnD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,qBAAqB,CAAC;IAC7D,MAAM,MAAM,GAAG,sBAAsB,CAAC,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,MAAM,CAAC,iBAAiB,CACnC;YACE,QAAQ;YACR,KAAK;YACL,cAAc,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;YACnD,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,EAAE;YAClD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;SAC/B,EACD,EAAE,SAAS,EAAE,CACd,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gCAAgC,aAAa,mBAAmB,KAAK,OAAO,QAAQ,EAAE,EAAE,CAAC;IACzH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC5E,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI;YAAE,MAAM,OAAO,CAAC,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAClG,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAClC,CAAC;AACH,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { ClientOptions, ClientPlugin, WorkflowClientInterceptor, WorkflowQueryInput, WorkflowSignalInput } from '@temporalio/client';
2
+ import type { Next } from '@temporalio/common';
3
+ import { type ClientContext } from './client.js';
4
+ import { type BufferOptions, type SinkCounts } from './sink.js';
5
+ export interface ClientInterceptorOptions extends BufferOptions, ClientContext {
6
+ /** The Flowrensic server to send to. */
7
+ serverBaseUrl: string;
8
+ /** The env of the client, sent with its key and ephemeral run in the headers of every send. */
9
+ currentEnv: string;
10
+ }
11
+ /**
12
+ * Sends every query and signal that throws to Flowrensic, with its name, the
13
+ * workflow it was for and whether it ended on its deadline. A call that works
14
+ * is not sent. The calls wait in a buffer and are sent in batches, as the
15
+ * worker sink sends attempts, so sending never changes what the caller gets or
16
+ * how long it waits. It is a client plugin too: put in the plugins of the
17
+ * Temporal client, it reads the namespace of the client and puts itself in its
18
+ * workflow interceptors.
19
+ */
20
+ export declare class FlowrensicClientInterceptor implements WorkflowClientInterceptor, ClientPlugin {
21
+ private readonly buffer;
22
+ private namespace;
23
+ /** The name of the plugin. */
24
+ readonly name: string;
25
+ constructor(options: ClientInterceptorOptions);
26
+ /** Reads the namespace of the client and adds this interceptor to its workflow interceptors. */
27
+ configureClient(options: Omit<ClientOptions, 'plugins'>): Omit<ClientOptions, 'plugins'>;
28
+ query(input: WorkflowQueryInput, next: Next<WorkflowClientInterceptor, 'query'>): Promise<unknown>;
29
+ signal(input: WorkflowSignalInput, next: Next<WorkflowClientInterceptor, 'signal'>): Promise<void>;
30
+ /** Send what is buffered and wait for it to land. */
31
+ flush(): Promise<void>;
32
+ /** Send what is buffered and stop. */
33
+ close(): Promise<void>;
34
+ /** What the buffer lost and holds. */
35
+ counts(): SinkCounts;
36
+ /** Records a call that threw, and never throws itself, so the caller gets the error Temporal gave. */
37
+ private record;
38
+ private callOf;
39
+ }
40
+ /**
41
+ * Pass to `new Client({ namespace, plugins: [flowrensicClientInterceptor({ serverBaseUrl, currentEnv, envAccessKey })] })`.
42
+ * The calls are sent under the namespace of that client. Call close before the
43
+ * process ends, so the calls still waiting are sent.
44
+ */
45
+ export declare function flowrensicClientInterceptor(options: ClientInterceptorOptions): FlowrensicClientInterceptor;
46
+ //# sourceMapp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K,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,sCAAsC;IAChC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,sCAAsC;IACtC,MAAM,IAAI,UAAU,CAEnB;IAED,sGAAsG;IACtG,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,MAAM;CAcf;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,GAAG,2BAA2B,CAE1G"}
@@ -0,0 +1,124 @@
1
+ import { timestampFromDate } from '@bufbuild/protobuf/wkt';
2
+ import { contextOf, createFlowrensicClient } from './client.js';
3
+ import { ClientCallOutcome } from './gen/flowrensic/v1/client_calls_pb.js';
4
+ import { createRecordBuffer } from './sink.js';
5
+ /** The gRPC status a call that ended on its deadline carries. */
6
+ const DEADLINE_EXCEEDED = 4;
7
+ /** The gRPC status of a cancelled call. */
8
+ const CANCELLED = 1;
9
+ /** The details grpc-js gives a call the client itself cancelled. */
10
+ const CANCELLED_ON_CLIENT = 'Cancelled on client';
11
+ function grpcStatus(err) {
12
+ for (let e = err; e !== undefined && e !== null; e = e.cause) {
13
+ const { code, details } = e;
14
+ if (typeof code === 'number')
15
+ return { code, details: typeof details === 'string' ? details : '' };
16
+ if (typeof e !== 'object')
17
+ return undefined;
18
+ }
19
+ return undefined;
20
+ }
21
+ /** True when the call ended on its deadline: DEADLINE_EXCEEDED, or CANCELLED by the server and not by the client. */
22
+ function endedOnDeadline(err) {
23
+ const status = grpcStatus(err);
24
+ if (status === undefined)
25
+ return false;
26
+ if (status.code === DEADLINE_EXCEEDED)
27
+ return true;
28
+ return status.code === CANCELLED && status.details !== CANCELLED_ON_CLIENT;
29
+ }
30
+ /** The namespace a Temporal client talks to when its options name none. */
31
+ const DEFAULT_NAMESPACE = 'default';
32
+ /**
33
+ * Sends every query and signal that throws to Flowrensic, with its name, the
34
+ * workflow it was for and whether it ended on its deadline. A call that works
35
+ * is not sent. The calls wait in a buffer and are sent in batches, as the
36
+ * worker sink sends attempts, so sending never changes what the caller gets or
37
+ * how long it waits. It is a client plugin too: put in the plugins of the
38
+ * Temporal client, it reads the namespace of the client and puts itself in its
39
+ * workflow interceptors.
40
+ */
41
+ export class FlowrensicClientInterceptor {
42
+ buffer;
43
+ namespace = DEFAULT_NAMESPACE;
44
+ /** The name of the plugin. */
45
+ name = 'flowrensic.client';
46
+ constructor(options) {
47
+ const client = createFlowrensicClient(options.serverBaseUrl, contextOf(options));
48
+ this.buffer = createRecordBuffer({
49
+ async send(calls, timeoutMs, id) {
50
+ await client.ingest.ingestClientCalls({ calls, ...id }, { timeoutMs });
51
+ },
52
+ envOf: () => options.currentEnv,
53
+ }, options);
54
+ }
55
+ /** Reads the namespace of the client and adds this interceptor to its workflow interceptors. */
56
+ configureClient(options) {
57
+ this.namespace = options.namespace ?? DEFAULT_NAMESPACE;
58
+ const workflow = options.interceptors?.workflow;
59
+ const list = Array.isArray(workflow) ? workflow : [];
60
+ return { ...options, interceptors: { ...options.interceptors, workflow: [...list, this] } };
61
+ }
62
+ async query(input, next) {
63
+ try {
64
+ return await next(input);
65
+ }
66
+ catch (err) {
67
+ this.record('query', input.queryType, input.workflowExecution, err);
68
+ throw err;
69
+ }
70
+ }
71
+ async signal(input, next) {
72
+ try {
73
+ await next(input);
74
+ }
75
+ catch (err) {
76
+ this.record('signal', input.signalName, input.workflowExecution, err);
77
+ throw err;
78
+ }
79
+ }
80
+ /** Send what is buffered and wait for it to land. */
81
+ async flush() {
82
+ await this.buffer.flush();
83
+ }
84
+ /** Send what is buffered and stop. */
85
+ async close() {
86
+ await this.buffer.close();
87
+ }
88
+ /** What the buffer lost and holds. */
89
+ counts() {
90
+ return this.buffer.counts();
91
+ }
92
+ /** Records a call that threw, and never throws itself, so the caller gets the error Temporal gave. */
93
+ record(kind, name, execution, err) {
94
+ try {
95
+ this.buffer.record(this.callOf(kind, name, execution, err));
96
+ }
97
+ catch {
98
+ return;
99
+ }
100
+ }
101
+ callOf(kind, name, execution, err) {
102
+ const timedOut = endedOnDeadline(err);
103
+ return {
104
+ $typeName: 'flowrensic.v1.ClientCall',
105
+ namespace: this.namespace,
106
+ workflowId: execution.workflowId,
107
+ runId: execution.runId ?? '',
108
+ kind,
109
+ name,
110
+ outcome: timedOut ? ClientCallOutcome.TIMED_OUT : ClientCallOutcome.FAILED,
111
+ errorType: err instanceof Error ? err.constructor.name : 'Unknown',
112
+ endedAt: timestampFromDate(new Date()),
113
+ };
114
+ }
115
+ }
116
+ /**
117
+ * Pass to `new Client({ namespace, plugins: [flowrensicClientInterceptor({ serverBaseUrl, currentEnv, envAccessKey })] })`.
118
+ * The calls are sent under the namespace of that client. Call close before the
119
+ * process ends, so the calls still waiting are sent.
120
+ */
121
+ export function flowrensicClientInterceptor(options) {
122
+ return new FlowrensicClientInterceptor(options);
123
+ }
124
+ //# sourceMappingURL=client-interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-interceptor.js","sourceRoot":"","sources":["../../src/client-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAI3D,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAsB,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAmB,MAAM,wCAAwC,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAwD,MAAM,WAAW,CAAC;AAErG,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,2CAA2C;AAC3C,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,oEAAoE;AACpE,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAclD,SAAS,UAAU,CAAC,GAAY;IAC9B,KAAK,IAAI,CAAC,GAAY,GAAG,EAAE,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,GAAI,CAAyB,CAAC,KAAK,EAAE,CAAC;QAC/F,MAAM,EAAE,IAAI,EAAE,OAAO,EAA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';
2
+ import { CatalogService, IngestService, JobService, QueryService, RemediationService } from './gen/flowrensic/v1/services_pb.js';
3
+ export interface FlowrensicClient {
4
+ catalog: Client<typeof CatalogService>;
5
+ ingest: Client<typeof IngestService>;
6
+ query: Client<typeof QueryService>;
7
+ remediation: Client<typeof RemediationService>;
8
+ jobs: Client<typeof JobService>;
9
+ }
10
+ /**
11
+ * Who the client is: its env, the access key of that env and the ephemeral run
12
+ * of that env. Every call of IngestService and every ListReplayHistories call
13
+ * carries them in headers.
14
+ */
15
+ export interface ClientContext {
16
+ /** The env of this client, as FLOWRENSIC_KNOWN_ENVS names it. */
17
+ currentEnv?: string;
18
+ /** The access key of that env. */
19
+ envAccessKey?: string;
20
+ /** The ephemeral run of that env, such as the CI build number. For an env of kind ephemeral, without one the run is default. */
21
+ currentEphemeralRun?: string;
22
+ }
23
+ export interface FlowrensicClientOptions extends ClientContext {
24
+ /** The admin key of the server. Every call of JobService carries it. */
25
+ adminKey?: string;
26
+ }
27
+ /** The header a client call names its env in. */
28
+ export declare const CURRENT_ENV_HEADER = "Flowrensic-Current-Env";
29
+ /** The header a client call carries the access key of its env in. */
30
+ export declare const ENV_ACCESS_KEY_HEADER = "Flowrensic-Env-Access-Key";
31
+ /** The header a client call carries the ephemeral run of its env in. */
32
+ export declare const CURRENT_EPHEMERAL_RUN_HEADER = "Flowrensic-Current-Ephemeral-Run";
33
+ /** The headers of a client context, each one only when it is set. */
34
+ export declare function clientContextHeaders(context: ClientContext): Record<string, string>;
35
+ /** Puts the headers of the context on every call of IngestService, every ListReplayHistories call and every GetEphemeralRunSummary call. */
36
+ export declare function clientContextInterceptor(context: ClientContext): Interceptor;
37
+ /** The header every JobService call carries the server's admin key in. */
38
+ export declare const ADMIN_KEY_HEADER = "Flowrensic-Admin-Key";
39
+ /** Puts adminKey on every call of JobService. */
40
+ export declare function adminKeyInterceptor(adminKey: string): Interceptor;
41
+ /** The client context of options, with only the fields that are set. */
42
+ export declare function contextOf(options: ClientContext): ClientContext;
43
+ export declare function createFlowrensicClient(serverBaseUrl: string, options?: FlowrensicClientOptions): FlowrensicClient;
44
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAEjI,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gIAAgI;IAChI,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,iDAAiD;AACjD,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAEjE,wEAAwE;AACxE,eAAO,MAAM,4BAA4B,qCAAqC,CAAC;AAE/E,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMnF;AAED,4IAA4I;AAC5I,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,CAU5E;AAED,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AAEvD,iDAAiD;AACjD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAKjE;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAM/D;AAED,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CAgBlB"}
@@ -0,0 +1,69 @@
1
+ import { createClient } from '@connectrpc/connect';
2
+ import { createConnectTransport } from '@connectrpc/connect-node';
3
+ import { CatalogService, IngestService, JobService, QueryService, RemediationService } from './gen/flowrensic/v1/services_pb.js';
4
+ /** The header a client call names its env in. */
5
+ export const CURRENT_ENV_HEADER = 'Flowrensic-Current-Env';
6
+ /** The header a client call carries the access key of its env in. */
7
+ export const ENV_ACCESS_KEY_HEADER = 'Flowrensic-Env-Access-Key';
8
+ /** The header a client call carries the ephemeral run of its env in. */
9
+ export const CURRENT_EPHEMERAL_RUN_HEADER = 'Flowrensic-Current-Ephemeral-Run';
10
+ /** The headers of a client context, each one only when it is set. */
11
+ export function clientContextHeaders(context) {
12
+ const headers = {};
13
+ if (context.currentEnv !== undefined)
14
+ headers[CURRENT_ENV_HEADER] = context.currentEnv;
15
+ if (context.envAccessKey !== undefined)
16
+ headers[ENV_ACCESS_KEY_HEADER] = context.envAccessKey;
17
+ if (context.currentEphemeralRun !== undefined)
18
+ headers[CURRENT_EPHEMERAL_RUN_HEADER] = context.currentEphemeralRun;
19
+ return headers;
20
+ }
21
+ /** Puts the headers of the context on every call of IngestService, every ListReplayHistories call and every GetEphemeralRunSummary call. */
22
+ export function clientContextInterceptor(context) {
23
+ const headers = Object.entries(clientContextHeaders(context));
24
+ return (next) => async (req) => {
25
+ const ingest = req.service.typeName === IngestService.typeName;
26
+ const query = req.service.typeName === QueryService.typeName;
27
+ const replaySet = query && (req.method.name === QueryService.method.listReplayHistories.name || req.method.name === QueryService.method.getEphemeralRunSummary.name);
28
+ if (ingest || replaySet)
29
+ for (const [name, value] of headers)
30
+ req.header.set(name, value);
31
+ return await next(req);
32
+ };
33
+ }
34
+ /** The header every JobService call carries the server's admin key in. */
35
+ export const ADMIN_KEY_HEADER = 'Flowrensic-Admin-Key';
36
+ /** Puts adminKey on every call of JobService. */
37
+ export function adminKeyInterceptor(adminKey) {
38
+ return (next) => async (req) => {
39
+ if (req.service.typeName === JobService.typeName)
40
+ req.header.set(ADMIN_KEY_HEADER, adminKey);
41
+ return await next(req);
42
+ };
43
+ }
44
+ /** The client context of options, with only the fields that are set. */
45
+ export function contextOf(options) {
46
+ return {
47
+ ...(options.currentEnv === undefined ? {} : { currentEnv: options.currentEnv }),
48
+ ...(options.envAccessKey === undefined ? {} : { envAccessKey: options.envAccessKey }),
49
+ ...(options.currentEphemeralRun === undefined ? {} : { currentEphemeralRun: options.currentEphemeralRun }),
50
+ };
51
+ }
52
+ export function createFlowrensicClient(serverBaseUrl, options = {}) {
53
+ const transport = createConnectTransport({
54
+ baseUrl: serverBaseUrl,
55
+ httpVersion: '1.1',
56
+ interceptors: [
57
+ clientContextInterceptor(options),
58
+ ...(options.adminKey === undefined ? [] : [adminKeyInterceptor(options.adminKey)]),
59
+ ],
60
+ });
61
+ return {
62
+ catalog: createClient(CatalogService, transport),
63
+ ingest: createClient(IngestService, transport),
64
+ query: createClient(QueryService, transport),
65
+ remediation: createClient(RemediationService, transport),
66
+ jobs: createClient(JobService, transport),
67
+ };
68
+ }
69
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,sBAAsB,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