@rebasepro/server 0.13.0 → 0.13.1-canary.g3660bd5

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.
Files changed (39) hide show
  1. package/dist/{admin_block-CcSGdH7M.js → admin_block-EmIHae6X.js} +2 -1
  2. package/dist/admin_block-EmIHae6X.js.map +1 -0
  3. package/dist/api/errors.d.ts +0 -6
  4. package/dist/api/openapi-generator.d.ts +14 -0
  5. package/dist/api/rest/idempotency.d.ts +41 -4
  6. package/dist/api/rest/write-validation.d.ts +12 -5
  7. package/dist/auth/index.d.ts +1 -1
  8. package/dist/auth/jwt.d.ts +12 -0
  9. package/dist/{auth-CuC9M2x6.js → auth-BE_FSK1l.js} +17 -37
  10. package/dist/auth-BE_FSK1l.js.map +1 -0
  11. package/dist/{backup-CVggVhR2.js → backup-BJiY_mM-.js} +2 -2
  12. package/dist/{backup-CVggVhR2.js.map → backup-BJiY_mM-.js.map} +1 -1
  13. package/dist/{cron-routes-CrQ0tK-_.js → cron-routes-D5a9v1HY.js} +2 -2
  14. package/dist/{cron-routes-CrQ0tK-_.js.map → cron-routes-D5a9v1HY.js.map} +1 -1
  15. package/dist/{cron-scheduler-B3RFt0HS.js → cron-scheduler-BhFZWR0T.js} +21 -2
  16. package/dist/cron-scheduler-BhFZWR0T.js.map +1 -0
  17. package/dist/{cron-store-BywZsyfZ.js → cron-store-Cu4sOseb.js} +11 -1
  18. package/dist/cron-store-Cu4sOseb.js.map +1 -0
  19. package/dist/{errors-CgkCzoj7.js → errors-BpudWAVU.js} +2 -10
  20. package/dist/errors-BpudWAVU.js.map +1 -0
  21. package/dist/index.es.js +220 -164
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/{jwt-DD6EtpGj.js → jwt-CzeviDcB.js} +17 -2
  24. package/dist/{jwt-DD6EtpGj.js.map → jwt-CzeviDcB.js.map} +1 -1
  25. package/dist/{openapi-generator-BEwyiaAr.js → openapi-generator-C-Rqz9sp.js} +99 -102
  26. package/dist/openapi-generator-C-Rqz9sp.js.map +1 -0
  27. package/dist/{schema-editor-routes-CbF20Mf1.js → schema-editor-routes-C1DxDnDR.js} +3 -3
  28. package/dist/{schema-editor-routes-CbF20Mf1.js.map → schema-editor-routes-C1DxDnDR.js.map} +1 -1
  29. package/dist/{src-Cum9kox5.js → src-7U0xuQo3.js} +65 -15
  30. package/dist/src-7U0xuQo3.js.map +1 -0
  31. package/dist/utils/logging.d.ts +0 -4
  32. package/package.json +5 -5
  33. package/dist/admin_block-CcSGdH7M.js.map +0 -1
  34. package/dist/auth-CuC9M2x6.js.map +0 -1
  35. package/dist/cron-scheduler-B3RFt0HS.js.map +0 -1
  36. package/dist/cron-store-BywZsyfZ.js.map +0 -1
  37. package/dist/errors-CgkCzoj7.js.map +0 -1
  38. package/dist/openapi-generator-BEwyiaAr.js.map +0 -1
  39. package/dist/src-Cum9kox5.js.map +0 -1
@@ -235,6 +235,27 @@ var policy = {
235
235
  authUid: () => ({ kind: "authUid" }),
236
236
  authRoles: () => ({ kind: "authRoles" })
237
237
  };
238
+ /** Hard ceiling clamped onto any client-supplied `limit`, on every surface. */
239
+ var MAX_LIST_LIMIT = 1e3;
240
+ /**
241
+ * Resolve a client-supplied list `limit` into a safe, always-defined value.
242
+ *
243
+ * - A provided limit is coerced to an integer and clamped to `[1, maxLimit]`,
244
+ * so `0`, negatives, and absurd values can never bypass the cap.
245
+ * - An absent / blank / non-numeric limit falls back to the mode default:
246
+ * `vectorDefaultLimit` for a vector search, otherwise `defaultLimit`.
247
+ *
248
+ * The return is never `undefined` — no ingress that routes its client limit
249
+ * through this can produce an unbounded read.
250
+ */
251
+ function resolveClientListLimit(rawLimit, opts = {}) {
252
+ const maxLimit = opts.maxLimit ?? 1e3;
253
+ if (rawLimit != null && String(rawLimit).trim() !== "") {
254
+ const parsed = typeof rawLimit === "number" ? rawLimit : parseInt(String(rawLimit), 10);
255
+ if (Number.isFinite(parsed)) return Math.min(Math.max(1, Math.floor(parsed)), maxLimit);
256
+ }
257
+ return opts.vectorSearch ? opts.vectorDefaultLimit ?? 10 : opts.defaultLimit ?? 50;
258
+ }
238
259
  (/* @__PURE__ */ __commonJSMin(((exports, module) => {
239
260
  (function(e) {
240
261
  var t;
@@ -2941,6 +2962,30 @@ var RebasePaginationError = class RebasePaginationError extends Error {
2941
2962
  Object.setPrototypeOf(this, RebasePaginationError.prototype);
2942
2963
  }
2943
2964
  };
2965
+ /**
2966
+ * Resolve `limit`/`offset`/`page` into the window a read will actually use.
2967
+ *
2968
+ * Lives here, next to the walk, for the reason at the top of this file: every
2969
+ * transport has to mean the same thing by "page two". Four of them did not —
2970
+ * the REST layer strode by {@link DEFAULT_LIST_LIMIT}, the local-first
2971
+ * evaluator by {@link DEFAULT_PAGE_SIZE}, the in-process accessor by 20, and
2972
+ * the published type documented a fourth number. Pages that overlap or skip
2973
+ * rows are the mildest of those outcomes.
2974
+ *
2975
+ * `page` wins over `offset`, as {@link FindParams} documents. `driverOffset`
2976
+ * is the value to hand a driver: it stays `undefined` when the caller named no
2977
+ * offset, because keyset pagination seeks with a `where` clause and must not
2978
+ * look like it is paging by offset.
2979
+ */
2980
+ function resolveFindWindow(params) {
2981
+ const limit = params?.limit ?? 50;
2982
+ const offset = params?.page != null ? Math.max(0, (params.page - 1) * limit) : params?.offset ?? 0;
2983
+ return {
2984
+ limit,
2985
+ offset,
2986
+ driverOffset: params?.page != null ? offset : params?.offset
2987
+ };
2988
+ }
2944
2989
  function normalizePageSize(raw) {
2945
2990
  if (raw === void 0 || !Number.isFinite(raw)) return 200;
2946
2991
  return Math.max(1, Math.floor(raw));
@@ -3390,21 +3435,22 @@ function createDriverAccessor(driver, slug, getPks = () => []) {
3390
3435
  const accessor = {
3391
3436
  async find(params) {
3392
3437
  const filter = params?.where ? deserializeFilter(params.where) : void 0;
3393
- const limit = params?.limit ?? 20;
3394
- const offset = params?.offset ?? 0;
3438
+ const { limit, offset, driverOffset } = resolveFindWindow(params);
3395
3439
  const fetchService = driver.restFetchService;
3396
3440
  const rows = fetchService ? await fetchService.fetchCollectionForRest(slug, {
3397
3441
  filter,
3398
- limit: params?.limit,
3399
- offset: params?.offset,
3442
+ logical: params?.logical,
3443
+ limit,
3444
+ offset: driverOffset,
3400
3445
  orderBy: params?.orderBy?.[0],
3401
3446
  order: params?.orderBy?.[1],
3402
3447
  searchString: params?.searchString
3403
3448
  }, params?.include) : await driver.fetchCollection({
3404
3449
  path: slug,
3405
- limit: params?.limit,
3406
- offset: params?.offset,
3450
+ limit,
3451
+ offset: driverOffset,
3407
3452
  filter,
3453
+ logical: params?.logical,
3408
3454
  orderBy: params?.orderBy?.[0],
3409
3455
  order: params?.orderBy?.[1],
3410
3456
  searchString: params?.searchString
@@ -3414,7 +3460,9 @@ function createDriverAccessor(driver, slug, getPks = () => []) {
3414
3460
  if (driver.count) {
3415
3461
  total = await driver.count({
3416
3462
  path: slug,
3417
- filter
3463
+ filter,
3464
+ logical: params?.logical,
3465
+ searchString: params?.searchString
3418
3466
  });
3419
3467
  hasMore = offset + rows.length < total;
3420
3468
  }
@@ -3470,18 +3518,20 @@ function createDriverAccessor(driver, slug, getPks = () => []) {
3470
3518
  const filter = params?.where ? deserializeFilter(params.where) : void 0;
3471
3519
  return driver.count({
3472
3520
  path: slug,
3473
- filter
3521
+ filter,
3522
+ logical: params?.logical,
3523
+ searchString: params?.searchString
3474
3524
  });
3475
3525
  } : void 0,
3476
3526
  listen: driver.listenCollection ? (params, onUpdate, onError) => {
3477
- const limit = params?.limit ?? 20;
3478
- const offset = params?.offset ?? 0;
3527
+ const { limit, offset, driverOffset } = resolveFindWindow(params);
3479
3528
  const normalize = driver.restFetchService ? inlineRelationRefs : (row) => row;
3480
3529
  return driver.listenCollection({
3481
3530
  path: slug,
3482
- limit: params?.limit,
3483
- offset: params?.offset,
3531
+ limit,
3532
+ offset: driverOffset,
3484
3533
  filter: params?.where,
3534
+ logical: params?.logical,
3485
3535
  orderBy: params?.orderBy?.[0],
3486
3536
  order: params?.orderBy?.[1],
3487
3537
  searchString: params?.searchString,
@@ -3489,7 +3539,7 @@ function createDriverAccessor(driver, slug, getPks = () => []) {
3489
3539
  onUpdate({
3490
3540
  data: entities.map((row) => rowToEntity(normalize(row), slug, getPks())),
3491
3541
  meta: {
3492
- total: entities.length,
3542
+ total: offset + entities.length,
3493
3543
  limit,
3494
3544
  offset,
3495
3545
  hasMore: entities.length >= limit
@@ -3772,6 +3822,6 @@ function buildRoutedRebaseData({ defaultData, sources, resolveKey }) {
3772
3822
  } });
3773
3823
  }
3774
3824
  //#endregion
3775
- export { Vector as S, ANONYMOUS_USER_ID as _, serializeFilter as a, EntityRelation as b, paginateFind as c, resolveDataSource as d, getEffectiveSecurityRules as f, toSnakeCase as g, buildCompositeId as h, deserializeLogicalCondition as i, CollectionRegistry as l, resolveCollectionRelations as m, buildSdkData as n, serializeLogicalCondition as o, findRelation as p, deserializeFilter as r, collectAllPages as s, buildRoutedRebaseData as t, createDataSourceRegistry as u, isAnonymousUid as v, GeoPoint as x, EntityReference as y };
3825
+ export { EntityReference as C, Vector as E, isAnonymousUid as S, GeoPoint as T, resolvePrimaryKeys as _, serializeFilter as a, resolveClientListLimit as b, paginateFind as c, createDataSourceRegistry as d, resolveDataSource as f, buildCompositeId as g, resolveCollectionRelations as h, deserializeLogicalCondition as i, resolveFindWindow as l, findRelation as m, buildSdkData as n, serializeLogicalCondition as o, getEffectiveSecurityRules as p, deserializeFilter as r, collectAllPages as s, buildRoutedRebaseData as t, CollectionRegistry as u, toSnakeCase as v, EntityRelation as w, ANONYMOUS_USER_ID as x, MAX_LIST_LIMIT as y };
3776
3826
 
3777
- //# sourceMappingURL=src-Cum9kox5.js.map
3827
+ //# sourceMappingURL=src-7U0xuQo3.js.map