@spacelr/sdk 0.10.3 → 0.10.5

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.mjs CHANGED
@@ -58,6 +58,12 @@ var SpacelrSearchFilterRequiredError = class extends SpacelrError {
58
58
  this.missingFields = Array.isArray(fields) ? fields.filter((f) => typeof f === "string") : [];
59
59
  }
60
60
  };
61
+ var SpacelrScanLimitExceededError = class extends SpacelrError {
62
+ constructor(message, details) {
63
+ super(message, "SCAN_LIMIT_EXCEEDED", 400, details);
64
+ this.name = "SpacelrScanLimitExceededError";
65
+ }
66
+ };
61
67
  var SpacelrEmailVerificationRequiredError = class extends SpacelrError {
62
68
  constructor(emailSent, details) {
63
69
  super(
@@ -313,6 +319,10 @@ var HttpClient = class {
313
319
  const missingFields = Array.isArray(flatBody["missingFields"]) ? flatBody["missingFields"] : [];
314
320
  throw new SpacelrSearchFilterRequiredError(flatMessage, { missingFields });
315
321
  }
322
+ if (statusCode === 400 && flatBody["errorCode"] === "SCAN_LIMIT_EXCEEDED") {
323
+ const flatMessage = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
324
+ throw new SpacelrScanLimitExceededError(flatMessage);
325
+ }
316
326
  if (statusCode === 401 || statusCode === 403) {
317
327
  throw new SpacelrAuthError(message, statusCode, details);
318
328
  }
@@ -1325,7 +1335,11 @@ var RealtimeClient = class {
1325
1335
  buildStreamPayload(state) {
1326
1336
  const { projectId, collectionName, where } = state.options;
1327
1337
  const payload = { projectId, collectionName };
1328
- if (state.lastDeliveredId) payload["sinceId"] = state.lastDeliveredId;
1338
+ if (state.lastDeliveredId) {
1339
+ payload["sinceId"] = state.lastDeliveredId;
1340
+ } else if (state.options.fromStart) {
1341
+ payload["fromStart"] = true;
1342
+ }
1329
1343
  if (where && Object.keys(where).length > 0) payload["where"] = where;
1330
1344
  return payload;
1331
1345
  }
@@ -2312,7 +2326,7 @@ var Paginator = class {
2312
2326
  return { documents: [], hasMore: false };
2313
2327
  }
2314
2328
  this.cursor = result.documents[result.documents.length - 1]._id;
2315
- const hasMore = result.mode === "cursor" ? result.hasMore : result.documents.length < result.total;
2329
+ const hasMore = result.mode === "cursor" ? result.hasMore : result.hasMore ?? (result.total !== void 0 ? result.documents.length < result.total : false);
2316
2330
  return { documents: result.documents, hasMore };
2317
2331
  }
2318
2332
  };
@@ -2639,6 +2653,9 @@ var CollectionRef = class {
2639
2653
  projectId: this.projectId,
2640
2654
  collectionName: this.collectionName,
2641
2655
  sinceId,
2656
+ // #685 — only meaningful on a fresh subscription (no sinceId/cursor);
2657
+ // buildStreamPayload ignores it once a cursor exists.
2658
+ fromStart: handlers.fromStart,
2642
2659
  where: handlers.where,
2643
2660
  onEvent,
2644
2661
  onGap: handlers.onGap,
@@ -3335,6 +3352,7 @@ export {
3335
3352
  SpacelrEmailVerificationRequiredError,
3336
3353
  SpacelrError,
3337
3354
  SpacelrNetworkError,
3355
+ SpacelrScanLimitExceededError,
3338
3356
  SpacelrSearchFilterRequiredError,
3339
3357
  SpacelrTimeoutError,
3340
3358
  SpacelrTwoFactorRequiredError,