@covalenthq/client-sdk 2.2.6 → 2.3.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.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "2.2.6";
3
+ var version = "2.3.0";
4
4
 
5
5
  const bigIntParser = (val) => {
6
6
  if (val === null || val === undefined) {
@@ -2410,6 +2410,1238 @@ class SecurityService {
2410
2410
  }
2411
2411
  }
2412
2412
 
2413
+ function extendedTypeof(val) {
2414
+ if (val === null) {
2415
+ return "null";
2416
+ }
2417
+ if (Array.isArray(val)) {
2418
+ return "array";
2419
+ }
2420
+ return typeof val;
2421
+ }
2422
+ function isObject(val) {
2423
+ return extendedTypeof(val) === "object";
2424
+ }
2425
+ function areGraphQLFormattedErrors(obj) {
2426
+ return Array.isArray(obj) && // must be at least one error
2427
+ obj.length > 0 && // error has at least a message
2428
+ obj.every((ob) => "message" in ob);
2429
+ }
2430
+ function limitCloseReason(reason, whenTooLong) {
2431
+ return reason.length < 124 ? reason : whenTooLong;
2432
+ }
2433
+
2434
+ const GRAPHQL_TRANSPORT_WS_PROTOCOL = "graphql-transport-ws";
2435
+ var CloseCode = /* @__PURE__ */ ((CloseCode2) => {
2436
+ CloseCode2[CloseCode2["InternalServerError"] = 4500] = "InternalServerError";
2437
+ CloseCode2[CloseCode2["InternalClientError"] = 4005] = "InternalClientError";
2438
+ CloseCode2[CloseCode2["BadRequest"] = 4400] = "BadRequest";
2439
+ CloseCode2[CloseCode2["BadResponse"] = 4004] = "BadResponse";
2440
+ CloseCode2[CloseCode2["Unauthorized"] = 4401] = "Unauthorized";
2441
+ CloseCode2[CloseCode2["Forbidden"] = 4403] = "Forbidden";
2442
+ CloseCode2[CloseCode2["SubprotocolNotAcceptable"] = 4406] = "SubprotocolNotAcceptable";
2443
+ CloseCode2[CloseCode2["ConnectionInitialisationTimeout"] = 4408] = "ConnectionInitialisationTimeout";
2444
+ CloseCode2[CloseCode2["ConnectionAcknowledgementTimeout"] = 4504] = "ConnectionAcknowledgementTimeout";
2445
+ CloseCode2[CloseCode2["SubscriberAlreadyExists"] = 4409] = "SubscriberAlreadyExists";
2446
+ CloseCode2[CloseCode2["TooManyInitialisationRequests"] = 4429] = "TooManyInitialisationRequests";
2447
+ return CloseCode2;
2448
+ })(CloseCode || {});
2449
+ var MessageType = /* @__PURE__ */ ((MessageType2) => {
2450
+ MessageType2["ConnectionInit"] = "connection_init";
2451
+ MessageType2["ConnectionAck"] = "connection_ack";
2452
+ MessageType2["Ping"] = "ping";
2453
+ MessageType2["Pong"] = "pong";
2454
+ MessageType2["Subscribe"] = "subscribe";
2455
+ MessageType2["Next"] = "next";
2456
+ MessageType2["Error"] = "error";
2457
+ MessageType2["Complete"] = "complete";
2458
+ return MessageType2;
2459
+ })(MessageType || {});
2460
+ function validateMessage(val) {
2461
+ if (!isObject(val)) {
2462
+ throw new Error(
2463
+ `Message is expected to be an object, but got ${extendedTypeof(val)}`
2464
+ );
2465
+ }
2466
+ if (!val.type) {
2467
+ throw new Error(`Message is missing the 'type' property`);
2468
+ }
2469
+ if (typeof val.type !== "string") {
2470
+ throw new Error(
2471
+ `Message is expects the 'type' property to be a string, but got ${extendedTypeof(
2472
+ val.type
2473
+ )}`
2474
+ );
2475
+ }
2476
+ switch (val.type) {
2477
+ case "connection_init" /* ConnectionInit */:
2478
+ case "connection_ack" /* ConnectionAck */:
2479
+ case "ping" /* Ping */:
2480
+ case "pong" /* Pong */: {
2481
+ if (val.payload != null && !isObject(val.payload)) {
2482
+ throw new Error(
2483
+ `"${val.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${val.payload}"`
2484
+ );
2485
+ }
2486
+ break;
2487
+ }
2488
+ case "subscribe" /* Subscribe */: {
2489
+ if (typeof val.id !== "string") {
2490
+ throw new Error(
2491
+ `"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(
2492
+ val.id
2493
+ )}`
2494
+ );
2495
+ }
2496
+ if (!val.id) {
2497
+ throw new Error(
2498
+ `"${val.type}" message requires a non-empty 'id' property`
2499
+ );
2500
+ }
2501
+ if (!isObject(val.payload)) {
2502
+ throw new Error(
2503
+ `"${val.type}" message expects the 'payload' property to be an object, but got ${extendedTypeof(
2504
+ val.payload
2505
+ )}`
2506
+ );
2507
+ }
2508
+ if (typeof val.payload.query !== "string") {
2509
+ throw new Error(
2510
+ `"${val.type}" message payload expects the 'query' property to be a string, but got ${extendedTypeof(
2511
+ val.payload.query
2512
+ )}`
2513
+ );
2514
+ }
2515
+ if (val.payload.variables != null && !isObject(val.payload.variables)) {
2516
+ throw new Error(
2517
+ `"${val.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${extendedTypeof(
2518
+ val.payload.variables
2519
+ )}`
2520
+ );
2521
+ }
2522
+ if (val.payload.operationName != null && extendedTypeof(val.payload.operationName) !== "string") {
2523
+ throw new Error(
2524
+ `"${val.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${extendedTypeof(
2525
+ val.payload.operationName
2526
+ )}`
2527
+ );
2528
+ }
2529
+ if (val.payload.extensions != null && !isObject(val.payload.extensions)) {
2530
+ throw new Error(
2531
+ `"${val.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${extendedTypeof(
2532
+ val.payload.extensions
2533
+ )}`
2534
+ );
2535
+ }
2536
+ break;
2537
+ }
2538
+ case "next" /* Next */: {
2539
+ if (typeof val.id !== "string") {
2540
+ throw new Error(
2541
+ `"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(
2542
+ val.id
2543
+ )}`
2544
+ );
2545
+ }
2546
+ if (!val.id) {
2547
+ throw new Error(
2548
+ `"${val.type}" message requires a non-empty 'id' property`
2549
+ );
2550
+ }
2551
+ if (!isObject(val.payload)) {
2552
+ throw new Error(
2553
+ `"${val.type}" message expects the 'payload' property to be an object, but got ${extendedTypeof(
2554
+ val.payload
2555
+ )}`
2556
+ );
2557
+ }
2558
+ break;
2559
+ }
2560
+ case "error" /* Error */: {
2561
+ if (typeof val.id !== "string") {
2562
+ throw new Error(
2563
+ `"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(
2564
+ val.id
2565
+ )}`
2566
+ );
2567
+ }
2568
+ if (!val.id) {
2569
+ throw new Error(
2570
+ `"${val.type}" message requires a non-empty 'id' property`
2571
+ );
2572
+ }
2573
+ if (!areGraphQLFormattedErrors(val.payload)) {
2574
+ throw new Error(
2575
+ `"${val.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(
2576
+ val.payload
2577
+ )}`
2578
+ );
2579
+ }
2580
+ break;
2581
+ }
2582
+ case "complete" /* Complete */: {
2583
+ if (typeof val.id !== "string") {
2584
+ throw new Error(
2585
+ `"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(
2586
+ val.id
2587
+ )}`
2588
+ );
2589
+ }
2590
+ if (!val.id) {
2591
+ throw new Error(
2592
+ `"${val.type}" message requires a non-empty 'id' property`
2593
+ );
2594
+ }
2595
+ break;
2596
+ }
2597
+ default:
2598
+ throw new Error(`Invalid message 'type' property "${val.type}"`);
2599
+ }
2600
+ return val;
2601
+ }
2602
+ function parseMessage(data, reviver) {
2603
+ return validateMessage(
2604
+ typeof data === "string" ? JSON.parse(data, reviver) : data
2605
+ );
2606
+ }
2607
+ function stringifyMessage(msg, replacer) {
2608
+ validateMessage(msg);
2609
+ return JSON.stringify(msg, replacer);
2610
+ }
2611
+
2612
+ function createClient(options) {
2613
+ const {
2614
+ url,
2615
+ connectionParams,
2616
+ lazy = true,
2617
+ onNonLazyError = console.error,
2618
+ lazyCloseTimeout: lazyCloseTimeoutMs = 0,
2619
+ keepAlive = 0,
2620
+ disablePong,
2621
+ connectionAckWaitTimeout = 0,
2622
+ retryAttempts = 5,
2623
+ retryWait = async function randomisedExponentialBackoff(retries2) {
2624
+ const retryDelaySeconds = Math.pow(2, retries2);
2625
+ await new Promise(
2626
+ (resolve) => setTimeout(
2627
+ resolve,
2628
+ retryDelaySeconds * 1e3 + // add random timeout from 300ms to 3s
2629
+ Math.floor(Math.random() * (3e3 - 300) + 300)
2630
+ )
2631
+ );
2632
+ },
2633
+ shouldRetry = isLikeCloseEvent,
2634
+ on,
2635
+ webSocketImpl,
2636
+ /**
2637
+ * Generates a v4 UUID to be used as the ID using `Math`
2638
+ * as the random number generator. Supply your own generator
2639
+ * in case you need more uniqueness.
2640
+ *
2641
+ * Reference: https://gist.github.com/jed/982883
2642
+ */
2643
+ generateID = function generateUUID() {
2644
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
2645
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
2646
+ return v.toString(16);
2647
+ });
2648
+ },
2649
+ jsonMessageReplacer: replacer,
2650
+ jsonMessageReviver: reviver
2651
+ } = options;
2652
+ let ws;
2653
+ if (webSocketImpl) {
2654
+ if (!isWebSocket(webSocketImpl)) {
2655
+ throw new Error("Invalid WebSocket implementation provided");
2656
+ }
2657
+ ws = webSocketImpl;
2658
+ } else if (typeof WebSocket !== "undefined") {
2659
+ ws = WebSocket;
2660
+ } else if (typeof global !== "undefined") {
2661
+ ws = global.WebSocket || // @ts-expect-error: Support more browsers
2662
+ global.MozWebSocket;
2663
+ } else if (typeof window !== "undefined") {
2664
+ ws = window.WebSocket || // @ts-expect-error: Support more browsers
2665
+ window.MozWebSocket;
2666
+ }
2667
+ if (!ws)
2668
+ throw new Error(
2669
+ "WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`"
2670
+ );
2671
+ const WebSocketImpl = ws;
2672
+ const emitter = (() => {
2673
+ const message = /* @__PURE__ */ (() => {
2674
+ const listeners2 = {};
2675
+ return {
2676
+ on(id, listener) {
2677
+ listeners2[id] = listener;
2678
+ return () => {
2679
+ delete listeners2[id];
2680
+ };
2681
+ },
2682
+ emit(message2) {
2683
+ if ("id" in message2) listeners2[message2.id]?.(message2);
2684
+ }
2685
+ };
2686
+ })();
2687
+ const listeners = {
2688
+ connecting: on?.connecting ? [on.connecting] : [],
2689
+ opened: on?.opened ? [on.opened] : [],
2690
+ connected: on?.connected ? [on.connected] : [],
2691
+ ping: on?.ping ? [on.ping] : [],
2692
+ pong: on?.pong ? [on.pong] : [],
2693
+ message: on?.message ? [message.emit, on.message] : [message.emit],
2694
+ closed: on?.closed ? [on.closed] : [],
2695
+ error: on?.error ? [on.error] : []
2696
+ };
2697
+ return {
2698
+ onMessage: message.on,
2699
+ on(event, listener) {
2700
+ const l = listeners[event];
2701
+ l.push(listener);
2702
+ return () => {
2703
+ l.splice(l.indexOf(listener), 1);
2704
+ };
2705
+ },
2706
+ emit(event, ...args) {
2707
+ for (const listener of [...listeners[event]]) {
2708
+ listener(...args);
2709
+ }
2710
+ }
2711
+ };
2712
+ })();
2713
+ function errorOrClosed(cb) {
2714
+ const listening = [
2715
+ // errors are fatal and more critical than close events, throw them first
2716
+ emitter.on("error", (err) => {
2717
+ listening.forEach((unlisten) => unlisten());
2718
+ cb(err);
2719
+ }),
2720
+ // closes can be graceful and not fatal, throw them second (if error didnt throw)
2721
+ emitter.on("closed", (event) => {
2722
+ listening.forEach((unlisten) => unlisten());
2723
+ cb(event);
2724
+ })
2725
+ ];
2726
+ }
2727
+ let connecting, locks = 0, lazyCloseTimeout, retrying = false, retries = 0, disposed = false;
2728
+ async function connect() {
2729
+ clearTimeout(lazyCloseTimeout);
2730
+ const [socket, throwOnClose] = await (connecting ?? (connecting = new Promise(
2731
+ (connected, denied) => (async () => {
2732
+ if (retrying) {
2733
+ await retryWait(retries);
2734
+ if (!locks) {
2735
+ connecting = undefined;
2736
+ return denied({ code: 1e3, reason: "All Subscriptions Gone" });
2737
+ }
2738
+ retries++;
2739
+ }
2740
+ emitter.emit("connecting", retrying);
2741
+ const socket2 = new WebSocketImpl(
2742
+ typeof url === "function" ? await url() : url,
2743
+ GRAPHQL_TRANSPORT_WS_PROTOCOL
2744
+ );
2745
+ let connectionAckTimeout, queuedPing;
2746
+ function enqueuePing() {
2747
+ if (isFinite(keepAlive) && keepAlive > 0) {
2748
+ clearTimeout(queuedPing);
2749
+ queuedPing = setTimeout(() => {
2750
+ if (socket2.readyState === WebSocketImpl.OPEN) {
2751
+ socket2.send(stringifyMessage({ type: MessageType.Ping }));
2752
+ emitter.emit("ping", false, undefined);
2753
+ }
2754
+ }, keepAlive);
2755
+ }
2756
+ }
2757
+ errorOrClosed((errOrEvent) => {
2758
+ connecting = undefined;
2759
+ clearTimeout(connectionAckTimeout);
2760
+ clearTimeout(queuedPing);
2761
+ denied(errOrEvent);
2762
+ if (errOrEvent instanceof TerminatedCloseEvent) {
2763
+ socket2.close(4499, "Terminated");
2764
+ socket2.onerror = null;
2765
+ socket2.onclose = null;
2766
+ }
2767
+ });
2768
+ socket2.onerror = (err) => emitter.emit("error", err);
2769
+ socket2.onclose = (event) => emitter.emit("closed", event);
2770
+ socket2.onopen = async () => {
2771
+ try {
2772
+ emitter.emit("opened", socket2);
2773
+ const payload = typeof connectionParams === "function" ? await connectionParams() : connectionParams;
2774
+ if (socket2.readyState !== WebSocketImpl.OPEN) return;
2775
+ socket2.send(
2776
+ stringifyMessage(
2777
+ payload ? {
2778
+ type: MessageType.ConnectionInit,
2779
+ payload
2780
+ } : {
2781
+ type: MessageType.ConnectionInit
2782
+ // payload is completely absent if not provided
2783
+ },
2784
+ replacer
2785
+ )
2786
+ );
2787
+ if (isFinite(connectionAckWaitTimeout) && connectionAckWaitTimeout > 0) {
2788
+ connectionAckTimeout = setTimeout(() => {
2789
+ socket2.close(
2790
+ CloseCode.ConnectionAcknowledgementTimeout,
2791
+ "Connection acknowledgement timeout"
2792
+ );
2793
+ }, connectionAckWaitTimeout);
2794
+ }
2795
+ enqueuePing();
2796
+ } catch (err) {
2797
+ emitter.emit("error", err);
2798
+ socket2.close(
2799
+ CloseCode.InternalClientError,
2800
+ limitCloseReason(
2801
+ err instanceof Error ? err.message : String(err),
2802
+ "Internal client error"
2803
+ )
2804
+ );
2805
+ }
2806
+ };
2807
+ let acknowledged = false;
2808
+ socket2.onmessage = ({ data }) => {
2809
+ try {
2810
+ const message = parseMessage(data, reviver);
2811
+ emitter.emit("message", message);
2812
+ if (message.type === "ping" || message.type === "pong") {
2813
+ emitter.emit(message.type, true, message.payload);
2814
+ if (message.type === "pong") {
2815
+ enqueuePing();
2816
+ } else if (!disablePong) {
2817
+ socket2.send(
2818
+ stringifyMessage(
2819
+ message.payload ? {
2820
+ type: MessageType.Pong,
2821
+ payload: message.payload
2822
+ } : {
2823
+ type: MessageType.Pong
2824
+ // payload is completely absent if not provided
2825
+ }
2826
+ )
2827
+ );
2828
+ emitter.emit("pong", false, message.payload);
2829
+ }
2830
+ return;
2831
+ }
2832
+ if (acknowledged) return;
2833
+ if (message.type !== MessageType.ConnectionAck)
2834
+ throw new Error(
2835
+ `First message cannot be of type ${message.type}`
2836
+ );
2837
+ clearTimeout(connectionAckTimeout);
2838
+ acknowledged = true;
2839
+ emitter.emit("connected", socket2, message.payload, retrying);
2840
+ retrying = false;
2841
+ retries = 0;
2842
+ connected([
2843
+ socket2,
2844
+ new Promise((_, reject) => errorOrClosed(reject))
2845
+ ]);
2846
+ } catch (err) {
2847
+ socket2.onmessage = null;
2848
+ emitter.emit("error", err);
2849
+ socket2.close(
2850
+ CloseCode.BadResponse,
2851
+ limitCloseReason(
2852
+ err instanceof Error ? err.message : String(err),
2853
+ "Bad response"
2854
+ )
2855
+ );
2856
+ }
2857
+ };
2858
+ })()
2859
+ )));
2860
+ if (socket.readyState === WebSocketImpl.CLOSING) await throwOnClose;
2861
+ let release = () => {
2862
+ };
2863
+ const released = new Promise((resolve) => release = resolve);
2864
+ return [
2865
+ socket,
2866
+ release,
2867
+ Promise.race([
2868
+ // wait for
2869
+ released.then(() => {
2870
+ if (!locks) {
2871
+ const complete = () => socket.close(1e3, "Normal Closure");
2872
+ if (isFinite(lazyCloseTimeoutMs) && lazyCloseTimeoutMs > 0) {
2873
+ lazyCloseTimeout = setTimeout(() => {
2874
+ if (socket.readyState === WebSocketImpl.OPEN) complete();
2875
+ }, lazyCloseTimeoutMs);
2876
+ } else {
2877
+ complete();
2878
+ }
2879
+ }
2880
+ }),
2881
+ // or
2882
+ throwOnClose
2883
+ ])
2884
+ ];
2885
+ }
2886
+ function shouldRetryConnectOrThrow(errOrCloseEvent) {
2887
+ if (isLikeCloseEvent(errOrCloseEvent) && (isFatalInternalCloseCode(errOrCloseEvent.code) || [
2888
+ CloseCode.InternalServerError,
2889
+ CloseCode.InternalClientError,
2890
+ CloseCode.BadRequest,
2891
+ CloseCode.BadResponse,
2892
+ CloseCode.Unauthorized,
2893
+ // CloseCode.Forbidden, might grant access out after retry
2894
+ CloseCode.SubprotocolNotAcceptable,
2895
+ // CloseCode.ConnectionInitialisationTimeout, might not time out after retry
2896
+ // CloseCode.ConnectionAcknowledgementTimeout, might not time out after retry
2897
+ CloseCode.SubscriberAlreadyExists,
2898
+ CloseCode.TooManyInitialisationRequests
2899
+ // 4499, // Terminated, probably because the socket froze, we want to retry
2900
+ ].includes(errOrCloseEvent.code)))
2901
+ throw errOrCloseEvent;
2902
+ if (disposed) return false;
2903
+ if (isLikeCloseEvent(errOrCloseEvent) && errOrCloseEvent.code === 1e3)
2904
+ return locks > 0;
2905
+ if (!retryAttempts || retries >= retryAttempts) throw errOrCloseEvent;
2906
+ if (!shouldRetry(errOrCloseEvent)) throw errOrCloseEvent;
2907
+ return retrying = true;
2908
+ }
2909
+ if (!lazy) {
2910
+ (async () => {
2911
+ locks++;
2912
+ for (; ; ) {
2913
+ try {
2914
+ const [, , throwOnClose] = await connect();
2915
+ await throwOnClose;
2916
+ } catch (errOrCloseEvent) {
2917
+ try {
2918
+ if (!shouldRetryConnectOrThrow(errOrCloseEvent)) return;
2919
+ } catch (errOrCloseEvent2) {
2920
+ return onNonLazyError?.(errOrCloseEvent2);
2921
+ }
2922
+ }
2923
+ }
2924
+ })();
2925
+ }
2926
+ function subscribe(payload, sink) {
2927
+ const id = generateID(payload);
2928
+ let done = false, errored = false, releaser = () => {
2929
+ locks--;
2930
+ done = true;
2931
+ };
2932
+ (async () => {
2933
+ locks++;
2934
+ for (; ; ) {
2935
+ try {
2936
+ const [socket, release, waitForReleaseOrThrowOnClose] = await connect();
2937
+ if (done) return release();
2938
+ const unlisten = emitter.onMessage(id, (message) => {
2939
+ switch (message.type) {
2940
+ case MessageType.Next: {
2941
+ sink.next(message.payload);
2942
+ return;
2943
+ }
2944
+ case MessageType.Error: {
2945
+ errored = true, done = true;
2946
+ sink.error(message.payload);
2947
+ releaser();
2948
+ return;
2949
+ }
2950
+ case MessageType.Complete: {
2951
+ done = true;
2952
+ releaser();
2953
+ return;
2954
+ }
2955
+ }
2956
+ });
2957
+ socket.send(
2958
+ stringifyMessage(
2959
+ {
2960
+ id,
2961
+ type: MessageType.Subscribe,
2962
+ payload
2963
+ },
2964
+ replacer
2965
+ )
2966
+ );
2967
+ releaser = () => {
2968
+ if (!done && socket.readyState === WebSocketImpl.OPEN)
2969
+ socket.send(
2970
+ stringifyMessage(
2971
+ {
2972
+ id,
2973
+ type: MessageType.Complete
2974
+ },
2975
+ replacer
2976
+ )
2977
+ );
2978
+ locks--;
2979
+ done = true;
2980
+ release();
2981
+ };
2982
+ await waitForReleaseOrThrowOnClose.finally(unlisten);
2983
+ return;
2984
+ } catch (errOrCloseEvent) {
2985
+ if (!shouldRetryConnectOrThrow(errOrCloseEvent)) return;
2986
+ }
2987
+ }
2988
+ })().then(() => {
2989
+ if (!errored) sink.complete();
2990
+ }).catch((err) => {
2991
+ sink.error(err);
2992
+ });
2993
+ return () => {
2994
+ if (!done) releaser();
2995
+ };
2996
+ }
2997
+ return {
2998
+ on: emitter.on,
2999
+ subscribe,
3000
+ iterate(request) {
3001
+ const pending = [];
3002
+ const deferred = {
3003
+ done: false,
3004
+ error: null,
3005
+ resolve: () => {
3006
+ }
3007
+ };
3008
+ const dispose = subscribe(request, {
3009
+ next(val) {
3010
+ pending.push(val);
3011
+ deferred.resolve();
3012
+ },
3013
+ error(err) {
3014
+ deferred.done = true;
3015
+ deferred.error = err;
3016
+ deferred.resolve();
3017
+ },
3018
+ complete() {
3019
+ deferred.done = true;
3020
+ deferred.resolve();
3021
+ }
3022
+ });
3023
+ const iterator = async function* iterator2() {
3024
+ for (; ; ) {
3025
+ if (!pending.length) {
3026
+ await new Promise((resolve) => deferred.resolve = resolve);
3027
+ }
3028
+ while (pending.length) {
3029
+ yield pending.shift();
3030
+ }
3031
+ if (deferred.error) {
3032
+ throw deferred.error;
3033
+ }
3034
+ if (deferred.done) {
3035
+ return;
3036
+ }
3037
+ }
3038
+ }();
3039
+ iterator.throw = async (err) => {
3040
+ if (!deferred.done) {
3041
+ deferred.done = true;
3042
+ deferred.error = err;
3043
+ deferred.resolve();
3044
+ }
3045
+ return { done: true, value: undefined };
3046
+ };
3047
+ iterator.return = async () => {
3048
+ dispose();
3049
+ return { done: true, value: undefined };
3050
+ };
3051
+ return iterator;
3052
+ },
3053
+ async dispose() {
3054
+ disposed = true;
3055
+ if (connecting) {
3056
+ const [socket] = await connecting;
3057
+ socket.close(1e3, "Normal Closure");
3058
+ }
3059
+ },
3060
+ terminate() {
3061
+ if (connecting) {
3062
+ emitter.emit("closed", new TerminatedCloseEvent());
3063
+ }
3064
+ }
3065
+ };
3066
+ }
3067
+ class TerminatedCloseEvent extends Error {
3068
+ name = "TerminatedCloseEvent";
3069
+ message = "4499: Terminated";
3070
+ code = 4499;
3071
+ reason = "Terminated";
3072
+ wasClean = false;
3073
+ }
3074
+ function isLikeCloseEvent(val) {
3075
+ return isObject(val) && "code" in val && "reason" in val;
3076
+ }
3077
+ function isFatalInternalCloseCode(code) {
3078
+ if ([
3079
+ 1e3,
3080
+ // Normal Closure is not an erroneous close code
3081
+ 1001,
3082
+ // Going Away
3083
+ 1006,
3084
+ // Abnormal Closure
3085
+ 1005,
3086
+ // No Status Received
3087
+ 1012,
3088
+ // Service Restart
3089
+ 1013,
3090
+ // Try Again Later
3091
+ 1014
3092
+ // Bad Gateway
3093
+ ].includes(code))
3094
+ return false;
3095
+ return code >= 1e3 && code <= 1999;
3096
+ }
3097
+ function isWebSocket(val) {
3098
+ return typeof val === "function" && "constructor" in val && "CLOSED" in val && "CLOSING" in val && "CONNECTING" in val && "OPEN" in val;
3099
+ }
3100
+
3101
+ /**
3102
+ * Streaming API Service
3103
+ *
3104
+ */
3105
+ class StreamingService {
3106
+ constructor(apiKey, config) {
3107
+ this.defaultConfig = {
3108
+ shouldRetry: (retries) => retries < 5,
3109
+ maxReconnectAttempts: 5,
3110
+ onConnecting: () => {
3111
+ console.info("StreamingService Connection Connecting...");
3112
+ },
3113
+ onOpened: () => {
3114
+ console.info("StreamingService Connection Established Successfully!");
3115
+ },
3116
+ onClosed: () => {
3117
+ console.info("StreamingService Connection Closed");
3118
+ },
3119
+ onError: (err) => {
3120
+ console.error("StreamingService Connection Error:", err);
3121
+ },
3122
+ };
3123
+ StreamingWebSocketClient.configure(apiKey, {
3124
+ ...this.defaultConfig,
3125
+ ...config,
3126
+ });
3127
+ StreamingWebSocketClient.getInstance();
3128
+ }
3129
+ /**
3130
+ * Initialize the streaming connection
3131
+ */
3132
+ getClient() {
3133
+ return StreamingWebSocketClient.getClient();
3134
+ }
3135
+ /**
3136
+ * Disconnect from the streaming service
3137
+ */
3138
+ async disconnect() {
3139
+ await StreamingWebSocketClient.disconnect();
3140
+ }
3141
+ /**
3142
+ * Check if the client is connected
3143
+ */
3144
+ get isConnected() {
3145
+ return StreamingWebSocketClient.isConnected;
3146
+ }
3147
+ /**
3148
+ * Subscribe to a custom GraphQL subscription
3149
+ * This allows for advanced usage and future extensibility
3150
+ *
3151
+ * @param query - GraphQL subscription query
3152
+ * @param variables - Query variables
3153
+ * @param callbacks - Subscription callbacks
3154
+ * @returns Unsubscribe function
3155
+ */
3156
+ rawQuery(query, variables, callbacks) {
3157
+ const client = StreamingWebSocketClient.getClient();
3158
+ return client.subscribe({
3159
+ query,
3160
+ variables,
3161
+ }, {
3162
+ next: (data) => callbacks.next(data),
3163
+ error: callbacks.error || (() => { }),
3164
+ complete: callbacks.complete || (() => { }),
3165
+ });
3166
+ }
3167
+ /**
3168
+ * Subscribe to OHLCV data for specific pairs
3169
+ *
3170
+ * @param params - Parameters for the OHLCV pairs stream
3171
+ * @param callbacks - Subscription callbacks
3172
+ * @returns Unsubscribe function
3173
+ *
3174
+ * @example
3175
+ * ```typescript
3176
+ * const unsubscribe = streamingService.subscribeToOHLCVPairs(
3177
+ * {
3178
+ * chain_name: StreamingChain.BASE_MAINNET,
3179
+ * pair_addresses: ["0x9c087Eb773291e50CF6c6a90ef0F4500e349B903"],
3180
+ * interval: StreamingInterval.ONE_MINUTE,
3181
+ * timeframe: StreamingTimeframe.ONE_HOUR
3182
+ * },
3183
+ * {
3184
+ * next: (data) => console.log("OHLCV Data:", data),
3185
+ * error: (err) => console.error("Error:", err),
3186
+ * complete: () => console.log("Stream completed")
3187
+ * }
3188
+ * );
3189
+ * ```
3190
+ */
3191
+ subscribeToOHLCVPairs(params, callbacks) {
3192
+ // Format the pair addresses array for the query
3193
+ const pairAddressesString = params.pair_addresses
3194
+ .map((addr) => `"${addr}"`)
3195
+ .join(", ");
3196
+ const query = `
3197
+ subscription {
3198
+ ohlcvCandlesForPair(
3199
+ chain_name: ${params.chain_name}
3200
+ pair_addresses: [${pairAddressesString}]
3201
+ interval: ${params.interval}
3202
+ timeframe: ${params.timeframe}
3203
+ ${params.limit ? `limit: ${params.limit}` : ""}
3204
+ ) {
3205
+ open
3206
+ high
3207
+ low
3208
+ close
3209
+ volume
3210
+ price_usd
3211
+ volume_usd
3212
+ chain_name
3213
+ pair_address
3214
+ interval
3215
+ timeframe
3216
+ timestamp
3217
+ base_token {
3218
+ contract_name
3219
+ contract_address
3220
+ contract_decimals
3221
+ contract_ticker_symbol
3222
+ }
3223
+ quote_token {
3224
+ contract_name
3225
+ contract_address
3226
+ contract_decimals
3227
+ contract_ticker_symbol
3228
+ }
3229
+ }
3230
+ }
3231
+ `;
3232
+ const client = StreamingWebSocketClient.getClient();
3233
+ return client.subscribe({
3234
+ query,
3235
+ }, {
3236
+ next: (data) => {
3237
+ if (data.data) {
3238
+ const ohlcvData = data.data.ohlcvCandlesForPair;
3239
+ if (ohlcvData) {
3240
+ callbacks.next(ohlcvData);
3241
+ }
3242
+ }
3243
+ else if (data.errors) {
3244
+ callbacks.error?.(data.errors);
3245
+ }
3246
+ },
3247
+ error: callbacks.error || (() => { }),
3248
+ complete: callbacks.complete || (() => { }),
3249
+ });
3250
+ }
3251
+ /**
3252
+ * Subscribe to OHLCV data for specific tokens
3253
+ *
3254
+ * @param params - Parameters for the OHLCV tokens stream
3255
+ * @param callbacks - Subscription callbacks
3256
+ * @returns Unsubscribe function
3257
+ *
3258
+ * @example
3259
+ * ```typescript
3260
+ * const unsubscribe = streamingService.subscribeToOHLCVTokens(
3261
+ * {
3262
+ * chain_name: StreamingChain.BASE_MAINNET,
3263
+ * token_addresses: ["0x4B6104755AfB5Da4581B81C552DA3A25608c73B8"],
3264
+ * interval: StreamingInterval.ONE_MINUTE,
3265
+ * timeframe: StreamingTimeframe.ONE_HOUR
3266
+ * },
3267
+ * {
3268
+ * next: (data) => console.log("OHLCV Token Data:", data),
3269
+ * error: (err) => console.error("Error:", err),
3270
+ * complete: () => console.log("Stream completed")
3271
+ * }
3272
+ * );
3273
+ * ```
3274
+ */
3275
+ subscribeToOHLCVTokens(params, callbacks) {
3276
+ // Format the token addresses array for the query
3277
+ const tokenAddressesString = params.token_addresses
3278
+ .map((addr) => `"${addr}"`)
3279
+ .join(", ");
3280
+ const query = `
3281
+ subscription {
3282
+ ohlcvCandlesForToken(
3283
+ chain_name: ${params.chain_name}
3284
+ token_addresses: [${tokenAddressesString}]
3285
+ interval: ${params.interval}
3286
+ timeframe: ${params.timeframe}
3287
+ ${params.limit ? `limit: ${params.limit}` : ""}
3288
+ ) {
3289
+ chain_name
3290
+ pair_address
3291
+ interval
3292
+ timeframe
3293
+ timestamp
3294
+ open
3295
+ high
3296
+ low
3297
+ close
3298
+ volume
3299
+ volume_usd
3300
+ quote_rate
3301
+ quote_rate_usd
3302
+ base_token {
3303
+ contract_name
3304
+ contract_address
3305
+ contract_decimals
3306
+ contract_ticker_symbol
3307
+ }
3308
+ quote_token {
3309
+ contract_name
3310
+ contract_address
3311
+ contract_decimals
3312
+ contract_ticker_symbol
3313
+ }
3314
+ }
3315
+ }
3316
+ `;
3317
+ const client = StreamingWebSocketClient.getClient();
3318
+ return client.subscribe({
3319
+ query,
3320
+ }, {
3321
+ next: (data) => {
3322
+ if (data.data) {
3323
+ const ohlcvData = data.data.ohlcvCandlesForToken;
3324
+ if (ohlcvData) {
3325
+ callbacks.next(ohlcvData);
3326
+ }
3327
+ }
3328
+ else if (data.errors) {
3329
+ callbacks.error?.(data.errors);
3330
+ }
3331
+ },
3332
+ error: callbacks.error || (() => { }),
3333
+ complete: callbacks.complete || (() => { }),
3334
+ });
3335
+ }
3336
+ /**
3337
+ * Subscribe to new DEX pairs created on supported decentralized exchanges
3338
+ *
3339
+ * @param params - Parameters for the new pairs stream
3340
+ * @param callbacks - Subscription callbacks
3341
+ * @returns Unsubscribe function
3342
+ *
3343
+ * @example
3344
+ * ```typescript
3345
+ * const unsubscribe = streamingService.subscribeToNewPairs(
3346
+ * {
3347
+ * chain_name: StreamingChain.BASE_MAINNET,
3348
+ * protocols: [StreamingProtocol.UNISWAP_V2, StreamingProtocol.UNISWAP_V3]
3349
+ * },
3350
+ * {
3351
+ * next: (data) => console.log("New Pairs:", data),
3352
+ * error: (err) => console.error("Error:", err),
3353
+ * complete: () => console.log("Stream completed")
3354
+ * }
3355
+ * );
3356
+ * ```
3357
+ */
3358
+ subscribeToNewPairs(params, callbacks) {
3359
+ const query = `
3360
+ subscription {
3361
+ newPairs(
3362
+ chain_name: ${params.chain_name},
3363
+ protocols: [${params.protocols.join(", ")}]
3364
+ ) {
3365
+ chain_name
3366
+ protocol
3367
+ protocol_version
3368
+ pair_address
3369
+ deployer_address
3370
+ tx_hash
3371
+ block_signed_at
3372
+ liquidity
3373
+ supply
3374
+ market_cap
3375
+ event_name
3376
+ quote_rate
3377
+ quote_rate_usd
3378
+ base_token_metadata {
3379
+ contract_address
3380
+ contract_decimals
3381
+ contract_name
3382
+ contract_ticker_symbol
3383
+ }
3384
+ pair_metadata {
3385
+ contract_address
3386
+ contract_decimals
3387
+ contract_name
3388
+ contract_ticker_symbol
3389
+ }
3390
+ quote_token_metadata {
3391
+ contract_address
3392
+ contract_decimals
3393
+ contract_name
3394
+ contract_ticker_symbol
3395
+ }
3396
+ prices {
3397
+ last_5m
3398
+ last_1hr
3399
+ last_6hr
3400
+ last_24hr
3401
+ }
3402
+ swaps {
3403
+ last_5m
3404
+ last_1hr
3405
+ last_6hr
3406
+ last_24hr
3407
+ }
3408
+ }
3409
+ }
3410
+ `;
3411
+ const client = StreamingWebSocketClient.getClient();
3412
+ return client.subscribe({
3413
+ query,
3414
+ }, {
3415
+ next: (data) => {
3416
+ if (data.data) {
3417
+ const newPairsData = data.data.newPairs;
3418
+ if (newPairsData) {
3419
+ callbacks.next(newPairsData);
3420
+ }
3421
+ }
3422
+ else if (data.errors) {
3423
+ callbacks.error?.(data.errors);
3424
+ }
3425
+ },
3426
+ error: callbacks.error || (() => { }),
3427
+ complete: callbacks.complete || (() => { }),
3428
+ });
3429
+ }
3430
+ /**
3431
+ * Subscribe to real-time token balance updates for a specific wallet address
3432
+ *
3433
+ * @param params - Parameters for the token balances stream
3434
+ * @param callbacks - Subscription callbacks
3435
+ * @returns Unsubscribe function
3436
+ *
3437
+ * @example
3438
+ * ```typescript
3439
+ * const unsubscribe = streamingService.subscribeToTokenBalances(
3440
+ * {
3441
+ * chain_name: StreamingChain.BASE_MAINNET,
3442
+ * wallet_address: "0x198ef79f1f515f02dfe9e3115ed9fc07183f02fc"
3443
+ * },
3444
+ * {
3445
+ * next: (data) => console.log("Token Balances:", data),
3446
+ * error: (err) => console.error("Error:", err),
3447
+ * complete: () => console.log("Stream completed")
3448
+ * }
3449
+ * );
3450
+ * ```
3451
+ */
3452
+ subscribeToTokenBalances(params, callbacks) {
3453
+ const query = `
3454
+ subscription {
3455
+ tokenBalancesForWalletAddress(
3456
+ chain_name: ${params.chain_name},
3457
+ wallet_address: "${params.wallet_address}"
3458
+ ) {
3459
+ wallet_address
3460
+ chain_name
3461
+ last_block
3462
+ items {
3463
+ balance
3464
+ balance_pretty
3465
+ quote_rate_usd
3466
+ quote_usd
3467
+ metadata {
3468
+ contract_name
3469
+ contract_address
3470
+ contract_decimals
3471
+ contract_ticker_symbol
3472
+ }
3473
+ is_native
3474
+ }
3475
+ }
3476
+ }
3477
+ `;
3478
+ const client = StreamingWebSocketClient.getClient();
3479
+ return client.subscribe({
3480
+ query,
3481
+ }, {
3482
+ next: (data) => {
3483
+ if (data.data) {
3484
+ const tokenBalancesData = data.data.tokenBalancesForWalletAddress;
3485
+ if (tokenBalancesData) {
3486
+ callbacks.next(tokenBalancesData);
3487
+ }
3488
+ }
3489
+ else if (data.errors) {
3490
+ callbacks.error?.(data.errors);
3491
+ }
3492
+ },
3493
+ error: callbacks.error || (() => { }),
3494
+ complete: callbacks.complete || (() => { }),
3495
+ });
3496
+ }
3497
+ /**
3498
+ * Subscribe to real-time wallet activity including transactions, token transfers, and smart contract interactions
3499
+ *
3500
+ * @param params - Parameters for the wallet activity stream
3501
+ * @param callbacks - Subscription callbacks
3502
+ * @returns Unsubscribe function
3503
+ *
3504
+ * @example
3505
+ * ```typescript
3506
+ * const unsubscribe = streamingService.subscribeToWalletActivity(
3507
+ * {
3508
+ * chain_name: StreamingChain.BASE_MAINNET,
3509
+ * wallet_addresses: ["0x198ef79f1f515f02dfe9e3115ed9fc07183f02fc"]
3510
+ * },
3511
+ * {
3512
+ * next: (data) => console.log("Wallet Activity:", data),
3513
+ * error: (err) => console.error("Error:", err),
3514
+ * complete: () => console.log("Stream completed")
3515
+ * }
3516
+ * );
3517
+ * ```
3518
+ */
3519
+ subscribeToWalletActivity(params, callbacks) {
3520
+ // Format the wallet addresses array for the query
3521
+ const walletAddressesString = params.wallet_addresses
3522
+ .map((addr) => `"${addr}"`)
3523
+ .join(", ");
3524
+ const query = `
3525
+ subscription {
3526
+ walletTxs(
3527
+ chain_name: ${params.chain_name},
3528
+ wallet_addresses: [${walletAddressesString}]
3529
+ ) {
3530
+ tx_hash
3531
+ from_address
3532
+ to_address
3533
+ value
3534
+ chain_name
3535
+ block_signed_at
3536
+ block_height
3537
+ block_hash
3538
+ miner_address
3539
+ gas_used
3540
+ tx_offset
3541
+ successful
3542
+ decoded_type
3543
+ logs {
3544
+ emitter_address
3545
+ log_offset
3546
+ data
3547
+ topics
3548
+ }
3549
+ }
3550
+ }
3551
+ `;
3552
+ const client = StreamingWebSocketClient.getClient();
3553
+ return client.subscribe({
3554
+ query,
3555
+ }, {
3556
+ next: (data) => {
3557
+ if (data.data) {
3558
+ const walletActivityData = data.data.walletTxs;
3559
+ if (walletActivityData) {
3560
+ callbacks.next(walletActivityData);
3561
+ }
3562
+ }
3563
+ else if (data.errors) {
3564
+ callbacks.error?.(data.errors);
3565
+ }
3566
+ },
3567
+ error: callbacks.error || (() => { }),
3568
+ complete: callbacks.complete || (() => { }),
3569
+ });
3570
+ }
3571
+ }
3572
+ /**
3573
+ * Singleton WebSocket Client for GoldRush Streaming
3574
+ *
3575
+ */
3576
+ class StreamingWebSocketClient {
3577
+ constructor() { }
3578
+ static getInstance() {
3579
+ if (!StreamingWebSocketClient.instance) {
3580
+ StreamingWebSocketClient.instance = new StreamingWebSocketClient();
3581
+ }
3582
+ return StreamingWebSocketClient.instance;
3583
+ }
3584
+ static configure(apiKey, config) {
3585
+ StreamingWebSocketClient.apiKey = apiKey;
3586
+ StreamingWebSocketClient.config = config;
3587
+ }
3588
+ static getClient() {
3589
+ if (!StreamingWebSocketClient.client ||
3590
+ !StreamingWebSocketClient.connected) {
3591
+ StreamingWebSocketClient.connect();
3592
+ }
3593
+ return StreamingWebSocketClient.client;
3594
+ }
3595
+ static connect() {
3596
+ if (StreamingWebSocketClient.client)
3597
+ return;
3598
+ StreamingWebSocketClient.client = createClient({
3599
+ url: "wss://gr-staging.streaming.covalenthq.com/graphql",
3600
+ connectionParams: {
3601
+ GOLDRUSH_API_KEY: StreamingWebSocketClient.apiKey,
3602
+ },
3603
+ shouldRetry: () => StreamingWebSocketClient.config.shouldRetry(StreamingWebSocketClient.reconnectAttempts),
3604
+ on: {
3605
+ connecting: () => {
3606
+ StreamingWebSocketClient.config.onConnecting();
3607
+ },
3608
+ opened: () => {
3609
+ StreamingWebSocketClient.config.onOpened();
3610
+ StreamingWebSocketClient.reconnectAttempts = 0;
3611
+ StreamingWebSocketClient.connected = true;
3612
+ },
3613
+ closed: () => {
3614
+ StreamingWebSocketClient.config.onClosed();
3615
+ StreamingWebSocketClient.connected = false;
3616
+ },
3617
+ error: (err) => {
3618
+ StreamingWebSocketClient.config.onError(err);
3619
+ StreamingWebSocketClient.connected = false;
3620
+ },
3621
+ },
3622
+ });
3623
+ }
3624
+ static get isConnected() {
3625
+ return StreamingWebSocketClient.connected;
3626
+ }
3627
+ static async disconnect() {
3628
+ if (!StreamingWebSocketClient.client)
3629
+ return;
3630
+ if (!StreamingWebSocketClient.connected)
3631
+ return;
3632
+ // * INFO: Is a fire & forget
3633
+ await StreamingWebSocketClient.client.dispose();
3634
+ StreamingWebSocketClient.client = null;
3635
+ StreamingWebSocketClient.connected = false;
3636
+ // * INFO: Wait for the client to disconnect
3637
+ await new Promise((resolve) => setTimeout(resolve, 1000));
3638
+ }
3639
+ }
3640
+ StreamingWebSocketClient.instance = null;
3641
+ StreamingWebSocketClient.client = null;
3642
+ StreamingWebSocketClient.connected = false;
3643
+ StreamingWebSocketClient.reconnectAttempts = 0;
3644
+
2413
3645
  /**
2414
3646
  * Transactions API
2415
3647
  *
@@ -3219,7 +4451,7 @@ const isValidApiKey = (apiKey) => {
3219
4451
  * GoldRushClient Class
3220
4452
  */
3221
4453
  class GoldRushClient {
3222
- constructor(apiKey, settings = {}) {
4454
+ constructor(apiKey, settings = {}, streamingConfig = {}) {
3223
4455
  this.userAgent = `com.covalenthq.sdk.typescript/${version}`;
3224
4456
  const validKey = isValidApiKey(apiKey);
3225
4457
  if (!validKey) {
@@ -3244,6 +4476,7 @@ class GoldRushClient {
3244
4476
  this.PricingService = new PricingService(execution);
3245
4477
  this.SecurityService = new SecurityService(execution);
3246
4478
  this.TransactionService = new TransactionService(execution);
4479
+ this.StreamingService = new StreamingService(apiKey, streamingConfig);
3247
4480
  }
3248
4481
  }
3249
4482
 
@@ -4422,6 +5655,45 @@ const timestampParser = (timestamp, type) => {
4422
5655
  }
4423
5656
  };
4424
5657
 
5658
+ /**
5659
+ * Common enums and types for Streaming API
5660
+ */
5661
+ exports.StreamingChain = void 0;
5662
+ (function (StreamingChain) {
5663
+ StreamingChain["BASE_MAINNET"] = "BASE_MAINNET";
5664
+ StreamingChain["ETH_MAINNET"] = "ETH_MAINNET";
5665
+ StreamingChain["BSC_MAINNET"] = "BSC_MAINNET";
5666
+ })(exports.StreamingChain || (exports.StreamingChain = {}));
5667
+ exports.StreamingInterval = void 0;
5668
+ (function (StreamingInterval) {
5669
+ StreamingInterval["FIFTEEN_SECONDS"] = "FIFTEEN_SECONDS";
5670
+ StreamingInterval["THIRTY_SECONDS"] = "THIRTY_SECONDS";
5671
+ StreamingInterval["ONE_MINUTE"] = "ONE_MINUTE";
5672
+ StreamingInterval["FIVE_MINUTES"] = "FIVE_MINUTES";
5673
+ StreamingInterval["FIFTEEN_MINUTES"] = "FIFTEEN_MINUTES";
5674
+ StreamingInterval["THIRTY_MINUTES"] = "THIRTY_MINUTES";
5675
+ StreamingInterval["ONE_HOUR"] = "ONE_HOUR";
5676
+ StreamingInterval["FOUR_HOURS"] = "FOUR_HOURS";
5677
+ StreamingInterval["ONE_DAY"] = "ONE_DAY";
5678
+ })(exports.StreamingInterval || (exports.StreamingInterval = {}));
5679
+ exports.StreamingTimeframe = void 0;
5680
+ (function (StreamingTimeframe) {
5681
+ StreamingTimeframe["ONE_MINUTE"] = "ONE_MINUTE";
5682
+ StreamingTimeframe["FIVE_MINUTES"] = "FIVE_MINUTES";
5683
+ StreamingTimeframe["FIFTEEN_MINUTES"] = "FIFTEEN_MINUTES";
5684
+ StreamingTimeframe["THIRTY_MINUTES"] = "THIRTY_MINUTES";
5685
+ StreamingTimeframe["ONE_HOUR"] = "ONE_HOUR";
5686
+ StreamingTimeframe["FOUR_HOURS"] = "FOUR_HOURS";
5687
+ StreamingTimeframe["ONE_DAY"] = "ONE_DAY";
5688
+ StreamingTimeframe["ONE_WEEK"] = "ONE_WEEK";
5689
+ StreamingTimeframe["ONE_MONTH"] = "ONE_MONTH";
5690
+ })(exports.StreamingTimeframe || (exports.StreamingTimeframe = {}));
5691
+ exports.StreamingProtocol = void 0;
5692
+ (function (StreamingProtocol) {
5693
+ StreamingProtocol["UNISWAP_V2"] = "UNISWAP_V2";
5694
+ StreamingProtocol["UNISWAP_V3"] = "UNISWAP_V3";
5695
+ })(exports.StreamingProtocol || (exports.StreamingProtocol = {}));
5696
+
4425
5697
  exports.GoldRushClient = GoldRushClient;
4426
5698
  exports.bigIntParser = bigIntParser;
4427
5699
  exports.calculatePrettyBalance = calculatePrettyBalance;