@secondlayer/sdk 6.46.0 → 6.47.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.
@@ -511,13 +511,18 @@ type StreamsReorg = {
511
511
  */
512
512
  new_canonical_tip: string
513
513
  };
514
- type StreamsEventsEnvelope = {
515
- events: StreamsEvent[]
514
+ type StreamsEventsEnvelope<TEvent = StreamsEvent> = {
515
+ events: TEvent[]
516
516
  next_cursor: string | null
517
517
  tip: StreamsTip
518
518
  reorgs: StreamsReorg[]
519
519
  };
520
520
  type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
521
+ /** The StreamsEvent union narrowed to a `types` selection — what a
522
+ * const-generic `types: ["ft_transfer"]` buys at the type level. */
523
+ type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
524
+ event_type: T[number]
525
+ }>;
521
526
  type StreamsReorgsListParams = {
522
527
  since: string
523
528
  limit?: number
@@ -761,9 +766,9 @@ type StreamsEventsConsumeParams<
761
766
  * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
762
767
  * `cursor` (the checkpoint to persist and resume from).
763
768
  */
764
- type StreamsBatch = {
769
+ type StreamsBatch<TEvent = StreamsEvent> = {
765
770
  /** Canonical events of this page, in cursor order. */
766
- events: StreamsEvent[]
771
+ events: TEvent[]
767
772
  /** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
768
773
  cursor: string | null
769
774
  tip: StreamsTip
@@ -779,6 +784,9 @@ type StreamsConsumeParams = {
779
784
  sender?: StreamsFilterValue
780
785
  recipient?: StreamsFilterValue
781
786
  assetIdentifier?: string
787
+ /** Labelled OR-groups — same semantics as `events.consume`; each returned
788
+ * event echoes the labels it matched. */
789
+ filters?: StreamsFilterMap
782
790
  /** Events per page (the `limit` query param). Default 100. */
783
791
  batchSize?: number
784
792
  /** Poll interval while caught up at the tip, in ms. Default 2000. */
@@ -815,6 +823,13 @@ type StreamsEventsReplayParams = {
815
823
  maxPages?: number
816
824
  maxEmptyPolls?: number
817
825
  signal?: AbortSignal
826
+ /** Narrow the LIVE TAIL after the dump phase. The dump files themselves are
827
+ * always all-type (block-partitioned parquet) — filter those in your own
828
+ * tooling while processing each file. */
829
+ types?: readonly StreamsEventType[]
830
+ notTypes?: readonly StreamsEventType[]
831
+ /** Labelled OR-groups for the live tail, like `consume`. */
832
+ filters?: StreamsFilterMap
818
833
  };
819
834
  /** One bulk parquet file in the dumps manifest. `path` is the object key under
820
835
  * the dumps base URL. */
@@ -874,8 +889,17 @@ type StreamsClient = {
874
889
  * rewound automatically — use `events.consume` with `onReorg` for managed
875
890
  * rollback semantics.
876
891
  */
892
+ /** Narrowing overload: a literal `types` array narrows every batch's
893
+ * event union to exactly those members. */
894
+ consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeParams & {
895
+ types: T
896
+ }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>
877
897
  consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>
878
898
  events: {
899
+ /** Narrowing overload, matching `consume`. */
900
+ list<const T extends readonly StreamsEventType[]>(params: StreamsEventsListParams & {
901
+ types: T
902
+ }): Promise<StreamsEventsEnvelope<StreamsEventOfTypes<T>>>
879
903
  list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
880
904
  byTxId(txId: string): Promise<StreamsEventsListEnvelope>
881
905
  /**
@@ -909,6 +933,10 @@ type StreamsClient = {
909
933
  * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
910
934
  * `maxEmptyPolls` stops it.
911
935
  */
936
+ /** Narrowing overload, matching `consume`. */
937
+ stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamParams & {
938
+ types: T
939
+ }): AsyncIterable<StreamsEventOfTypes<T>>
912
940
  stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
913
941
  /**
914
942
  * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
@@ -1949,6 +1949,7 @@ function createStreamsClient(options) {
1949
1949
  sender: params.sender,
1950
1950
  recipient: params.recipient,
1951
1951
  assetIdentifier: params.assetIdentifier,
1952
+ filters: params.filters,
1952
1953
  signal: params.signal,
1953
1954
  fetchEvents
1954
1955
  });
@@ -1968,6 +1969,7 @@ function createStreamsClient(options) {
1968
1969
  sender: params.sender,
1969
1970
  recipient: params.recipient,
1970
1971
  assetIdentifier: params.assetIdentifier,
1972
+ filters: params.filters,
1971
1973
  batchSize: params.batchSize ?? 100,
1972
1974
  emptyBackoffMs: params.emptyBackoffMs,
1973
1975
  maxPages: params.maxPages,
@@ -2001,6 +2003,9 @@ function createStreamsClient(options) {
2001
2003
  fromCursor: seam,
2002
2004
  mode: params.mode ?? "tail",
2003
2005
  batchSize: params.batchSize ?? 100,
2006
+ types: params.types,
2007
+ notTypes: params.notTypes,
2008
+ filters: params.filters,
2004
2009
  fetchEvents,
2005
2010
  onBatch: params.onBatch,
2006
2011
  onReorg: params.onReorg,
@@ -2191,5 +2196,5 @@ export {
2191
2196
  Subgraphs
2192
2197
  };
2193
2198
 
2194
- //# debugId=D9B14FC081B552ED64756E2164756E21
2199
+ //# debugId=D54DFB03E93AA1D464756E2164756E21
2195
2200
  //# sourceMappingURL=index.js.map