@secondlayer/sdk 6.38.0 → 6.39.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.
@@ -1153,8 +1153,19 @@ type IndexPrint = IndexEventBase & {
1153
1153
  /** Decoded chain event, discriminated by `event_type`. */
1154
1154
  type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
1155
1155
  type IndexEventType = IndexEvent["event_type"];
1156
- type EventsEnvelope<T extends IndexEventType = IndexEventType> = {
1157
- events: IndexEventOf<T>[]
1156
+ /** Fields every read returns regardless of `fields` — the consume contract
1157
+ * (`cursor`, `block_height`) plus the union discriminant. */
1158
+ type IndexAlwaysFields = "cursor" | "block_height" | "event_type";
1159
+ /** An event row narrowed to a `fields` selection (plus what always ships). */
1160
+ type IndexEventFields<
1161
+ T extends IndexEventType,
1162
+ F extends keyof IndexEventOf<T> & string
1163
+ > = Pick<IndexEventOf<T>, (F | IndexAlwaysFields) & keyof IndexEventOf<T>>;
1164
+ type EventsEnvelope<
1165
+ T extends IndexEventType = IndexEventType,
1166
+ TRow = IndexEventOf<T>
1167
+ > = {
1168
+ events: TRow[]
1158
1169
  next_cursor: string | null
1159
1170
  tip: IndexTip
1160
1171
  reorgs: IndexReorg[]
@@ -1187,6 +1198,21 @@ type EventsListParams<T extends IndexEventType = IndexEventType> = {
1187
1198
  * Avoids a `/v1/index/transactions` call per event; for `print` events it's
1188
1199
  * the only source of the submitting sender. */
1189
1200
  txContext?: boolean
1201
+ /**
1202
+ * Return only these columns. The server projects the SELECT, so an
1203
+ * unrequested field is physically absent — and the returned row type
1204
+ * narrows to match, making a read of one a compile error rather than
1205
+ * `undefined`.
1206
+ *
1207
+ * `cursor`, `block_height`, and `event_type` come back regardless: the
1208
+ * first two are the consume contract, the third carries the discriminant.
1209
+ * Don't list them.
1210
+ *
1211
+ * Cost note: this does NOT change your bill — Index meters per row read,
1212
+ * not per field. What it buys is wire bytes, plus skipping the `blocks`
1213
+ * join when `block_time` is omitted.
1214
+ */
1215
+ fields?: readonly (keyof IndexEventOf<T> & string)[]
1190
1216
  };
1191
1217
  type EventsWalkParams<T extends IndexEventType = IndexEventType> = Omit<EventsListParams<T>, "limit"> & {
1192
1218
  batchSize?: number
@@ -1887,6 +1913,15 @@ interface NftTransfersResource {
1887
1913
  /** `index.events` — callable shorthand for `.list()`; `eventType` is required. */
1888
1914
  interface IndexEventsResource {
1889
1915
  <T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
1916
+ /** Narrowing overload: `fields` shrinks the returned row type to exactly
1917
+ * the requested columns plus {@link IndexAlwaysFields}. `const F` means no
1918
+ * `as const` at the call site. */
1919
+ list<
1920
+ T extends IndexEventType,
1921
+ const F extends keyof IndexEventOf<T> & string
1922
+ >(params: EventsListParams<T> & {
1923
+ fields: readonly F[]
1924
+ }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
1890
1925
  list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
1891
1926
  walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
1892
1927
  consume<
@@ -1113,7 +1113,8 @@ class Index extends BaseClient {
1113
1113
  from_height: params.fromHeight,
1114
1114
  to_height: params.toHeight,
1115
1115
  trait: params.trait,
1116
- tx_context: params.txContext ? "true" : undefined
1116
+ tx_context: params.txContext ? "true" : undefined,
1117
+ fields: params.fields?.join(",")
1117
1118
  })}`);
1118
1119
  }
1119
1120
  walkEvents(params) {
@@ -2148,5 +2149,5 @@ export {
2148
2149
  Subgraphs
2149
2150
  };
2150
2151
 
2151
- //# debugId=E16E22A43378758864756E2164756E21
2152
+ //# debugId=F62665719058CC2664756E2164756E21
2152
2153
  //# sourceMappingURL=index.js.map