@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.
package/dist/index.d.ts CHANGED
@@ -567,13 +567,18 @@ type StreamsReorg = {
567
567
  */
568
568
  new_canonical_tip: string
569
569
  };
570
- type StreamsEventsEnvelope = {
571
- events: StreamsEvent[]
570
+ type StreamsEventsEnvelope<TEvent = StreamsEvent> = {
571
+ events: TEvent[]
572
572
  next_cursor: string | null
573
573
  tip: StreamsTip
574
574
  reorgs: StreamsReorg[]
575
575
  };
576
576
  type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
577
+ /** The StreamsEvent union narrowed to a `types` selection — what a
578
+ * const-generic `types: ["ft_transfer"]` buys at the type level. */
579
+ type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
580
+ event_type: T[number]
581
+ }>;
577
582
  type StreamsReorgsListParams = {
578
583
  since: string
579
584
  limit?: number
@@ -817,9 +822,9 @@ type StreamsEventsConsumeParams<
817
822
  * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
818
823
  * `cursor` (the checkpoint to persist and resume from).
819
824
  */
820
- type StreamsBatch = {
825
+ type StreamsBatch<TEvent = StreamsEvent> = {
821
826
  /** Canonical events of this page, in cursor order. */
822
- events: StreamsEvent[]
827
+ events: TEvent[]
823
828
  /** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
824
829
  cursor: string | null
825
830
  tip: StreamsTip
@@ -835,6 +840,9 @@ type StreamsConsumeParams = {
835
840
  sender?: StreamsFilterValue
836
841
  recipient?: StreamsFilterValue
837
842
  assetIdentifier?: string
843
+ /** Labelled OR-groups — same semantics as `events.consume`; each returned
844
+ * event echoes the labels it matched. */
845
+ filters?: StreamsFilterMap
838
846
  /** Events per page (the `limit` query param). Default 100. */
839
847
  batchSize?: number
840
848
  /** Poll interval while caught up at the tip, in ms. Default 2000. */
@@ -871,6 +879,13 @@ type StreamsEventsReplayParams = {
871
879
  maxPages?: number
872
880
  maxEmptyPolls?: number
873
881
  signal?: AbortSignal
882
+ /** Narrow the LIVE TAIL after the dump phase. The dump files themselves are
883
+ * always all-type (block-partitioned parquet) — filter those in your own
884
+ * tooling while processing each file. */
885
+ types?: readonly StreamsEventType[]
886
+ notTypes?: readonly StreamsEventType[]
887
+ /** Labelled OR-groups for the live tail, like `consume`. */
888
+ filters?: StreamsFilterMap
874
889
  };
875
890
  type FetchLike2 = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
876
891
  /** One bulk parquet file in the dumps manifest. `path` is the object key under
@@ -931,8 +946,17 @@ type StreamsClient = {
931
946
  * rewound automatically — use `events.consume` with `onReorg` for managed
932
947
  * rollback semantics.
933
948
  */
949
+ /** Narrowing overload: a literal `types` array narrows every batch's
950
+ * event union to exactly those members. */
951
+ consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeParams & {
952
+ types: T
953
+ }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>
934
954
  consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>
935
955
  events: {
956
+ /** Narrowing overload, matching `consume`. */
957
+ list<const T extends readonly StreamsEventType[]>(params: StreamsEventsListParams & {
958
+ types: T
959
+ }): Promise<StreamsEventsEnvelope<StreamsEventOfTypes<T>>>
936
960
  list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
937
961
  byTxId(txId: string): Promise<StreamsEventsListEnvelope>
938
962
  /**
@@ -966,6 +990,10 @@ type StreamsClient = {
966
990
  * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
967
991
  * `maxEmptyPolls` stops it.
968
992
  */
993
+ /** Narrowing overload, matching `consume`. */
994
+ stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamParams & {
995
+ types: T
996
+ }): AsyncIterable<StreamsEventOfTypes<T>>
969
997
  stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
970
998
  /**
971
999
  * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
package/dist/index.js CHANGED
@@ -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,
@@ -2887,5 +2892,5 @@ export {
2887
2892
  ApiError
2888
2893
  };
2889
2894
 
2890
- //# debugId=558D930AE661BCE364756E2164756E21
2895
+ //# debugId=8DFD8103C4A93D9164756E2164756E21
2891
2896
  //# sourceMappingURL=index.js.map