@seatlayer/js 0.28.2 → 0.28.4

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.cjs CHANGED
@@ -85,10 +85,13 @@ var PubApi = class {
85
85
  body: { selections, ...ttlMs ? { ttlMs } : {}, ...replaceHoldId ? { replaceHoldId } : {} }
86
86
  });
87
87
  }
88
- bestAvailable(key, qty, categoryKey) {
88
+ // `zoneId` scopes the pick to one zone and `ttlMs` carries the host's checkout
89
+ // window — both are part of the route contract, and dropping either here made
90
+ // the SDK quietly pick venue-wide and hold for the server default instead.
91
+ bestAvailable(key, qty, categoryKey, zoneId, ttlMs) {
89
92
  return request(this.base, `/pub/events/${encodeURIComponent(key)}/best-available`, {
90
93
  method: "POST",
91
- body: { qty, ...categoryKey ? { categoryKey } : {} }
94
+ body: { qty, ...categoryKey ? { categoryKey } : {}, ...zoneId ? { zoneId } : {}, ...ttlMs ? { ttlMs } : {} }
92
95
  });
93
96
  }
94
97
  resume(key, holdId) {
@@ -355,18 +358,22 @@ var SeatingChart = class {
355
358
  const h = await this.controller.holdGA(areaId, qty, options);
356
359
  return h ? { holdId: h.holdId, expiresAt: h.expiresAt, seats: h.seats, items: h.items } : null;
357
360
  }
358
- /** Ask the server for the `qty` best free seats and hold them atomically. */
359
- async bestAvailable(qty, categoryKey) {
361
+ /**
362
+ * Ask the server for the `qty` best free seats and hold them atomically.
363
+ * `options.ttlMs` sets the checkout window exactly like {@link hold}; omit it
364
+ * and the server falls back to the event setting, then its own default.
365
+ */
366
+ async bestAvailable(qty, categoryKey, options = {}) {
360
367
  try {
361
- return await this.bestAvailableOrThrow(qty, categoryKey);
368
+ return await this.bestAvailableOrThrow(qty, categoryKey, options);
362
369
  } catch (err) {
363
370
  this.opts.onError?.(err);
364
371
  return null;
365
372
  }
366
373
  }
367
374
  /** @internal Throwing variant of {@link bestAvailable} for the native host adapter. See {@link holdOrThrow}. */
368
- async bestAvailableOrThrow(qty, categoryKey) {
369
- const h = await this.controller.bestAvailable(qty, categoryKey);
375
+ async bestAvailableOrThrow(qty, categoryKey, options = {}) {
376
+ const h = await this.controller.bestAvailable(qty, categoryKey, options);
370
377
  return h ? { holdId: h.holdId, expiresAt: h.expiresAt, labels: h.labels, seats: h.seats, items: h.items } : null;
371
378
  }
372
379
  /**
@@ -3432,7 +3439,7 @@ var SeatPicker = class _SeatPicker {
3432
3439
  }
3433
3440
  if (held) {
3434
3441
  try {
3435
- const updated = await this.controller.replaceTableQuantity(table.label, table.quantity);
3442
+ const updated = await this.controller.replaceTableQuantity(table.label, table.quantity, this.opts.holdTtlMs);
3436
3443
  if (!updated) {
3437
3444
  this.toast("That guest count could not be secured. Your current table hold is unchanged.", "warning");
3438
3445
  this.renderTableDialogState();
@@ -4411,7 +4418,7 @@ var SeatPicker = class _SeatPicker {
4411
4418
  button.innerHTML = '<span class="sl-ba-spin" aria-hidden="true"></span>Finding\u2026';
4412
4419
  }
4413
4420
  try {
4414
- const h = await this.controller.bestAvailable(qty, categoryKey, opts);
4421
+ const h = await this.controller.bestAvailable(qty, categoryKey, { ...opts, ttlMs: this.opts.holdTtlMs });
4415
4422
  if (h) {
4416
4423
  this.hold = { holdId: h.holdId, expiresAt: h.expiresAt, seats: h.seats, items: h.items };
4417
4424
  this.handedOff = false;