@secondlayer/sdk 6.46.1 → 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
  });
@@ -2002,6 +2003,9 @@ function createStreamsClient(options) {
2002
2003
  fromCursor: seam,
2003
2004
  mode: params.mode ?? "tail",
2004
2005
  batchSize: params.batchSize ?? 100,
2006
+ types: params.types,
2007
+ notTypes: params.notTypes,
2008
+ filters: params.filters,
2005
2009
  fetchEvents,
2006
2010
  onBatch: params.onBatch,
2007
2011
  onReorg: params.onReorg,
@@ -2192,5 +2196,5 @@ export {
2192
2196
  Subgraphs
2193
2197
  };
2194
2198
 
2195
- //# debugId=6CD736056FB972AC64756E2164756E21
2199
+ //# debugId=D54DFB03E93AA1D464756E2164756E21
2196
2200
  //# sourceMappingURL=index.js.map