@drakkar.software/starfish-client 3.0.0-alpha.18 → 3.0.0-alpha.19

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/client.d.ts CHANGED
@@ -31,6 +31,13 @@ export interface AppendPullOptions {
31
31
  since?: number;
32
32
  /** Return only the last K items (applied after `since` filter). Sent as `?last=`. */
33
33
  last?: number;
34
+ /** Return only the last K items. Alias of `last`; sent as `?limit=`. When both
35
+ * are given, `limit` wins. */
36
+ limit?: number;
37
+ /** Explicitly fetch the whole collection (sent as `?full=true`). Mutually
38
+ * exclusive with `since`/`limit`/`last` — the server requires a pull to declare
39
+ * exactly one of {checkpoint, limit/last, full}. */
40
+ full?: boolean;
34
41
  }
35
42
  /**
36
43
  * Options for a structured (non-append) pull.
package/dist/index.js CHANGED
@@ -196,14 +196,24 @@ var StarfishClient = class {
196
196
  }
197
197
  } else {
198
198
  appendField = opts.appendField ?? APPEND_DEFAULT_FIELD;
199
+ if (opts.full && (opts.since != null || opts.limit != null || opts.last != null)) {
200
+ throw new Error("full cannot be combined with since, limit, or last");
201
+ }
199
202
  if (opts.since != null) {
200
203
  if (opts.since < 0) throw new Error("since must be non-negative");
201
204
  params.set("checkpoint", String(opts.since));
202
205
  }
206
+ if (opts.limit != null) {
207
+ if (opts.limit < 0) throw new Error("limit must be non-negative");
208
+ params.set("limit", String(opts.limit));
209
+ }
203
210
  if (opts.last != null) {
204
211
  if (opts.last < 0) throw new Error("last must be non-negative");
205
212
  params.set("last", String(opts.last));
206
213
  }
214
+ if (opts.full) {
215
+ params.set("full", "true");
216
+ }
207
217
  }
208
218
  if (params.size > 0) pathAndQuery += `?${params.toString()}`;
209
219
  }
@@ -776,7 +786,7 @@ var AppendLogCursor = class {
776
786
  const start = performance.now();
777
787
  try {
778
788
  const since = this.lastCheckpoint;
779
- const opts = since > 0 ? { appendField: this.appendField, since } : { appendField: this.appendField };
789
+ const opts = since > 0 ? { appendField: this.appendField, since } : { appendField: this.appendField, full: true };
780
790
  const raw = await this.client.pull(this.pullPath, opts);
781
791
  const batch = [];
782
792
  const stored = [];