@bowlos/reservations 0.29.0 → 0.31.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/index.cjs CHANGED
@@ -323,6 +323,69 @@ function createBowlosClient(config) {
323
323
  return new BowlosClient(config);
324
324
  }
325
325
 
326
+ // ../shared/src/inquiry.ts
327
+ var INQUIRY_FORMS = {
328
+ contact: {
329
+ label: "Contact",
330
+ fields: [
331
+ { key: "contactName", label: "Contact Name", required: true },
332
+ { key: "companyName", label: "Company Name" },
333
+ { key: "email", label: "Email", required: true },
334
+ { key: "mobile", label: "Mobile" },
335
+ { key: "message", label: "Message", required: true }
336
+ ]
337
+ },
338
+ event_party: {
339
+ label: "Party / event inquiry",
340
+ fields: [
341
+ { key: "contactName", label: "Contact Name", required: true },
342
+ { key: "companyName", label: "Company Name" },
343
+ { key: "email", label: "Email", required: true },
344
+ { key: "mobile", label: "Mobile" },
345
+ { key: "peopleCount", label: "People count" },
346
+ { key: "date", label: "Date" },
347
+ { key: "time", label: "Time" },
348
+ { key: "notes", label: "Notes" }
349
+ ]
350
+ }
351
+ };
352
+ async function hmacHex(secret, message) {
353
+ const encoder = new TextEncoder();
354
+ const key = await globalThis.crypto.subtle.importKey(
355
+ "raw",
356
+ encoder.encode(secret),
357
+ { name: "HMAC", hash: "SHA-256" },
358
+ false,
359
+ ["sign"]
360
+ );
361
+ const sig = await globalThis.crypto.subtle.sign("HMAC", key, encoder.encode(message));
362
+ return Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
363
+ }
364
+ async function signInquiryBody(secret, rawBody) {
365
+ return hmacHex(secret, rawBody);
366
+ }
367
+
368
+ // src/inquiry.ts
369
+ async function forwardInquiry(input, config) {
370
+ const root = config.baseUrl.replace(/\/+$/, "").replace(/\/api\/public\/v1$/, "");
371
+ const body = JSON.stringify({
372
+ brandId: config.brandId,
373
+ centerId: config.centerId,
374
+ formType: input.formType,
375
+ fields: input.fields
376
+ });
377
+ const signature = await signInquiryBody(config.secret, body);
378
+ const res = await fetch(`${root}/forms/inbound`, {
379
+ method: "POST",
380
+ headers: {
381
+ "content-type": "application/json",
382
+ "X-Bowlos-Signature": signature
383
+ },
384
+ body
385
+ });
386
+ return { ok: res.ok, status: res.status };
387
+ }
388
+
326
389
  // src/doctor.ts
327
390
  var GATEWAY_SUFFIX = "/api/public/v1";
328
391
  async function runDoctor(options) {
@@ -741,10 +804,37 @@ function listPublicMemberships(client, args) {
741
804
  function listGameCards(client, args) {
742
805
  return client.call("listPublicGameCards", args);
743
806
  }
807
+ function listRetailPricing(client, args) {
808
+ return client.call("listRetailPricing", args);
809
+ }
810
+
811
+ // src/packages.ts
812
+ function usesPerWeekdayStartTimes(pkg) {
813
+ return !!pkg.startTimesByWeekday && pkg.startTimesByWeekday.length > 0;
814
+ }
815
+ function weekdayForDateISO(dateISO) {
816
+ const [y, m, d] = dateISO.split("-").map(Number);
817
+ return new Date(Date.UTC(y, m - 1, d)).getUTCDay();
818
+ }
819
+ function resolvePackageStartTimesForWeekday(pkg, dayOfWeek) {
820
+ if (pkg.startTimesByWeekday && pkg.startTimesByWeekday.length > 0) {
821
+ const entry = pkg.startTimesByWeekday.find((e) => e.dayOfWeek === dayOfWeek);
822
+ if (!entry || entry.startTimes.length === 0) return [];
823
+ return [...entry.startTimes].sort((a, b) => a - b);
824
+ }
825
+ if (pkg.applicabilityDays && pkg.applicabilityDays.length > 0 && !pkg.applicabilityDays.includes(dayOfWeek)) {
826
+ return [];
827
+ }
828
+ if (pkg.allowedStartTimes && pkg.allowedStartTimes.length > 0) {
829
+ return [...pkg.allowedStartTimes].sort((a, b) => a - b);
830
+ }
831
+ return null;
832
+ }
744
833
 
745
834
  exports.BOWLOS_ERROR_CODES = BOWLOS_ERROR_CODES;
746
835
  exports.BowlosApiError = BowlosApiError;
747
836
  exports.BowlosClient = BowlosClient;
837
+ exports.INQUIRY_FORMS = INQUIRY_FORMS;
748
838
  exports.abandonCheckout = abandonCheckout;
749
839
  exports.availableUnitCount = availableUnitCount;
750
840
  exports.bookingPreview = bookingPreview;
@@ -762,6 +852,7 @@ exports.createGameCardOrder = createGameCardOrder;
762
852
  exports.createMembershipOrder = createMembershipOrder;
763
853
  exports.createMembershipSubscriptionOrder = createMembershipSubscriptionOrder;
764
854
  exports.createPackageOrder = createPackageOrder;
855
+ exports.forwardInquiry = forwardInquiry;
765
856
  exports.generateIdempotencyKey = generateIdempotencyKey;
766
857
  exports.getCenterHours = getCenterHours;
767
858
  exports.getCheckoutStatus = getCheckoutStatus;
@@ -792,6 +883,7 @@ exports.listGameCards = listGameCards;
792
883
  exports.listPackages = listPackages;
793
884
  exports.listProducts = listProducts;
794
885
  exports.listPublicMemberships = listPublicMemberships;
886
+ exports.listRetailPricing = listRetailPricing;
795
887
  exports.listStartTimes = listStartTimes;
796
888
  exports.localStorageTokenStore = localStorageTokenStore;
797
889
  exports.previewEventOrderCancellation = previewEventOrderCancellation;
@@ -803,6 +895,9 @@ exports.previewMembershipSubscription = previewMembershipSubscription;
803
895
  exports.previewPackage = previewPackage;
804
896
  exports.previewPackageOrderCancellation = previewPackageOrderCancellation;
805
897
  exports.previewReservationCancellation = previewReservationCancellation;
898
+ exports.resolvePackageStartTimesForWeekday = resolvePackageStartTimesForWeekday;
806
899
  exports.runDoctor = runDoctor;
900
+ exports.usesPerWeekdayStartTimes = usesPerWeekdayStartTimes;
901
+ exports.weekdayForDateISO = weekdayForDateISO;
807
902
  //# sourceMappingURL=index.cjs.map
808
903
  //# sourceMappingURL=index.cjs.map