order3000 1.10.0 → 1.12.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/client.mjs CHANGED
@@ -626,6 +626,56 @@ class BasketsResource extends BaseResource {
626
626
  }
627
627
  }
628
628
 
629
+ class BeveragesResource extends BaseResource {
630
+ constructor(tokenManager, baseUrl) {
631
+ super(tokenManager, baseUrl, "/beverages");
632
+ }
633
+ /**
634
+ * Fetch a beverage by its `accessor` slug (localized name/description,
635
+ * price, assets with public URLs). Pair with `patch` for a safe
636
+ * read-modify-write rename that preserves untouched locales.
637
+ */
638
+ async get(accessor) {
639
+ return this.request(
640
+ "GET",
641
+ `/${encodeURIComponent(accessor)}`
642
+ );
643
+ }
644
+ /**
645
+ * Edit a beverage by id. `editBeverage` replaces the fields it receives,
646
+ * so callers wanting a partial change should read the beverage with `get`
647
+ * first and merge. Returns the updated beverage row.
648
+ */
649
+ async patch(beverageId, body) {
650
+ return this.request(
651
+ "PATCH",
652
+ `/${encodeURIComponent(beverageId)}`,
653
+ body
654
+ );
655
+ }
656
+ /**
657
+ * Upload an asset image for a beverage. The SDK builds the multipart body
658
+ * internally — pass a Buffer/Uint8Array, the original filename, the MIME type,
659
+ * and optional discovery `tags` (e.g. `['lunch-menu']`). The asset is stored,
660
+ * tagged, and linked to the beverage via `beverage_assets`; returns the new
661
+ * asset and its public URL. The beverage is addressed by its accessor.
662
+ */
663
+ async uploadAsset(idOrAccessor, file) {
664
+ const form = new FormData();
665
+ form.append(
666
+ "file",
667
+ new Blob([new Uint8Array(file.data)], { type: file.contentType }),
668
+ file.filename
669
+ );
670
+ if (file.tags?.length) form.append("tags", file.tags.join(","));
671
+ return this.requestMultipart(
672
+ "POST",
673
+ `/${encodeURIComponent(idOrAccessor)}/assets`,
674
+ form
675
+ );
676
+ }
677
+ }
678
+
629
679
  class CalloutsResource extends BaseResource {
630
680
  constructor(tokenManager, baseUrl) {
631
681
  super(tokenManager, baseUrl, "/callouts");
@@ -667,6 +717,56 @@ class CalloutsResource extends BaseResource {
667
717
  }
668
718
  }
669
719
 
720
+ class DishesResource extends BaseResource {
721
+ constructor(tokenManager, baseUrl) {
722
+ super(tokenManager, baseUrl, "/dishes");
723
+ }
724
+ /**
725
+ * Fetch a dish by its `accessor` slug (localized name/description, dietary
726
+ * flags, price, assets with public URLs). Pair with `patch` for a safe
727
+ * read-modify-write rename that preserves untouched locales + flags.
728
+ */
729
+ async get(accessor) {
730
+ return this.request(
731
+ "GET",
732
+ `/${encodeURIComponent(accessor)}`
733
+ );
734
+ }
735
+ /**
736
+ * Edit a dish by id. `editDish` replaces the fields it receives (localized
737
+ * `name` is required), so callers wanting a partial change should read the
738
+ * dish with `get` first and merge. Returns the updated dish row.
739
+ */
740
+ async patch(dishId, body) {
741
+ return this.request(
742
+ "PATCH",
743
+ `/${encodeURIComponent(dishId)}`,
744
+ body
745
+ );
746
+ }
747
+ /**
748
+ * Upload an asset image for a dish. The SDK builds the multipart body
749
+ * internally — pass a Buffer/Uint8Array, the original filename, the MIME type,
750
+ * and optional discovery `tags` (e.g. `['lunch-menu']`). The asset is stored,
751
+ * tagged, and linked to the dish via `dish_assets`; returns the new asset and
752
+ * its public URL. The dish is addressed by its accessor.
753
+ */
754
+ async uploadAsset(idOrAccessor, file) {
755
+ const form = new FormData();
756
+ form.append(
757
+ "file",
758
+ new Blob([new Uint8Array(file.data)], { type: file.contentType }),
759
+ file.filename
760
+ );
761
+ if (file.tags?.length) form.append("tags", file.tags.join(","));
762
+ return this.requestMultipart(
763
+ "POST",
764
+ `/${encodeURIComponent(idOrAccessor)}/assets`,
765
+ form
766
+ );
767
+ }
768
+ }
769
+
670
770
  class EventsResource extends BaseResource {
671
771
  constructor(tokenManager, baseUrl) {
672
772
  super(tokenManager, baseUrl, "/events");
@@ -760,16 +860,20 @@ class EventsResource extends BaseResource {
760
860
  return event.assets ?? [];
761
861
  }
762
862
  /**
763
- * Per-start-slot occupancy availability for an event on a date. Each slot's
764
- * `offered` honours the venue's reservation mode (`passive`: every slot;
765
- * `auto_steer`: only acceptable slots), so a public widget can pre-exclude
766
- * fully-booked start times.
863
+ * Per-start-slot availability for an event on a date, per booking channel.
864
+ * Reservation channel: each slot's `offered` honours the venue's
865
+ * reservation mode (`passive`: every slot; `auto_steer`: only acceptable
866
+ * slots), so a public widget can pre-exclude fully-booked start times.
867
+ * Order channel: the event's order-pickup grid gated by per-slot caps and
868
+ * the order booking window (no table occupancy); events without a
869
+ * dedicated order grid inherit the reservation grid.
767
870
  */
768
871
  async getSlotAvailability(idOrAccessor, options) {
769
872
  const params = new URLSearchParams();
770
873
  params.set("reservationDate", options.reservationDate);
771
874
  params.set("partySize", String(options.partySize));
772
875
  if (options.areaId) params.set("areaId", options.areaId);
876
+ if (options.channel) params.set("channel", options.channel);
773
877
  return this.request(
774
878
  "GET",
775
879
  `/${encodeURIComponent(idOrAccessor)}/slot-availability?${params.toString()}`
@@ -1623,7 +1727,9 @@ class O3KClient {
1623
1727
  __publicField(this, "articles");
1624
1728
  __publicField(this, "assets");
1625
1729
  __publicField(this, "baskets");
1730
+ __publicField(this, "beverages");
1626
1731
  __publicField(this, "callouts");
1732
+ __publicField(this, "dishes");
1627
1733
  __publicField(this, "events");
1628
1734
  __publicField(this, "menus");
1629
1735
  __publicField(this, "orders");
@@ -1650,7 +1756,9 @@ class O3KClient {
1650
1756
  this.articles = new ArticlesResource(this.tokenManager, this.baseUrl);
1651
1757
  this.assets = new AssetsResource(this.tokenManager, this.baseUrl);
1652
1758
  this.baskets = new BasketsResource(this.tokenManager, this.baseUrl);
1759
+ this.beverages = new BeveragesResource(this.tokenManager, this.baseUrl);
1653
1760
  this.callouts = new CalloutsResource(this.tokenManager, this.baseUrl);
1761
+ this.dishes = new DishesResource(this.tokenManager, this.baseUrl);
1654
1762
  this.events = new EventsResource(this.tokenManager, this.baseUrl);
1655
1763
  this.menus = new MenusResource(this.tokenManager, this.baseUrl);
1656
1764
  this.orders = new OrdersResource(this.tokenManager, this.baseUrl);