@secondlayer/sdk 6.47.0 → 6.48.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.js CHANGED
@@ -592,6 +592,11 @@ function assertFinalizedCheckpoint(returned, checkpoint) {
592
592
  throw new ValidationError(`onBatch returned cursor "${returned}", above the last delivered finalized event${boundary}. With finalizedOnly, events past that point were filtered out and will be re-read once finalized — committing beyond it skips them permanently. Return ctx.cursor (or nothing); never envelope.next_cursor.`, 400);
593
593
  }
594
594
  }
595
+ function assertSinkModeCompatible(sink, finalizedOnly) {
596
+ if (sink?.capabilities?.finalizedOnly && !finalizedOnly) {
597
+ throw new ValidationError("This sink declares capabilities.finalizedOnly — it cannot roll back reorged rows, and following the unfinalized tip would corrupt it at the first fork. Pass finalizedOnly: true to consume(), or use a sink that implements rollback.", 400);
598
+ }
599
+ }
595
600
  function batchContext(cursor, height, tip, reorgs = []) {
596
601
  const tipHeight = tip.block_height;
597
602
  return {
@@ -658,6 +663,7 @@ async function consumeStreamsEvents(opts) {
658
663
  const emptyBackoffMs = opts.emptyBackoffMs ?? 500;
659
664
  const maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;
660
665
  const maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;
666
+ assertSinkModeCompatible(opts.sink, finalizedOnly);
661
667
  const committedCursor = await opts.sink?.loadCursor() ?? null;
662
668
  let cursor = opts.fromCursor ?? committedCursor;
663
669
  const handledReorgs = new Set;
@@ -824,6 +830,7 @@ async function consumeIndexFeed(opts) {
824
830
  const emptyBackoffMs = opts.emptyBackoffMs ?? 500;
825
831
  const maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;
826
832
  const maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;
833
+ assertSinkModeCompatible(opts.sink, finalizedOnly);
827
834
  const committedCursor = await opts.sink?.loadCursor() ?? null;
828
835
  let cursor = opts.fromCursor ?? committedCursor;
829
836
  const handledReorgs = new Set;
@@ -2892,5 +2899,5 @@ export {
2892
2899
  ApiError
2893
2900
  };
2894
2901
 
2895
- //# debugId=8DFD8103C4A93D9164756E2164756E21
2902
+ //# debugId=AADEB8FAB0EE368C64756E2164756E21
2896
2903
  //# sourceMappingURL=index.js.map