@dunbackmeadow/commerce-sdk 0.10.0 → 0.11.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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AppInfo, V as VenueLocation, C as CuisineQuery, a as Cuisine, R as RestaurantSummary, D as DrinkType, b as CuisineCatalog, c as CateringRequestInput, d as CateringRequest, S as SelectOptionInput, O as Order, U as UpdateDeliveryInput, e as CancelOrderOptions, L as LateRefundRequestInput, f as LateRefundRequest, W as WebhookEvent } from './luma-WIhD5QRd.js';
2
- export { g as ATTENDING_STATUSES, h as Address, i as AllergyCoverage, j as Attendee, B as BuildCateringRequestArgs, k as CateringBudgetResult, l as CateringItem, m as CateringMealType, n as CateringOption, o as CateringPolicies, p as CateringRequestStatus, q as CateringServiceStyle, r as CuisineId, s as CustomCuisineId, t as DUNBACK_REGISTRATION_QUESTION, u as DeliveredLateData, v as DrinkTypeId, w as DunbackEventSettings, x as LumaEventLike, y as LumaGuestLike, z as OrderCancellation, E as OrderDelivery, F as OrderRevision, G as OrderStatus, P as PartyDiet, H as PingData, I as Price, J as PriceLine, K as RefundDecidedData, M as StandardCuisineId, N as UnavailableReason, Q as UnavailableReasonCode, T as UnfedGuests, X as UsdcPaymentInstructions, Y as WebhookEventType, Z as buildCateringRequest, _ as canOrderFood, $ as guestsWithUnsharedAllergies, a0 as toDunbackAddress, a1 as toDunbackAttendees, a2 as toVenueLocation } from './luma-WIhD5QRd.js';
1
+ import { A as AppInfo, V as VenueLocation, C as CuisineQuery, a as Cuisine, R as RestaurantSummary, D as DrinkType, b as CuisineCatalog, c as CateringRequestInput, d as CateringRequest, S as SelectOptionInput, O as Order, U as UpdateDeliveryInput, e as CancelOrderOptions, L as LateRefundRequestInput, f as LateRefundRequest, P as ProblemReportInput, g as ProblemReport, W as WebhookEvent } from './luma-BwA6aHtI.js';
2
+ export { h as ATTENDING_STATUSES, i as Address, j as AllergyCoverage, k as Attendee, B as BuildCateringRequestArgs, l as CateringBudgetResult, m as CateringItem, n as CateringMealType, o as CateringOption, p as CateringPolicies, q as CateringRequestStatus, r as CateringServiceStyle, s as CuisineId, t as CustomCuisineId, u as DUNBACK_REGISTRATION_QUESTION, v as DeliveredData, w as DeliveredLateData, x as DeliveryProblemType, y as DrinkTypeId, z as DunbackEventSettings, E as LumaEventLike, F as LumaGuestLike, G as OrderCancellation, H as OrderDelivery, I as OrderRevision, J as OrderStatus, K as PartyDiet, M as PingData, N as Price, Q as PriceLine, T as RefundDecidedData, X as StandardCuisineId, Y as UnavailableReason, Z as UnavailableReasonCode, _ as UnfedGuests, $ as UsdcPaymentInstructions, a0 as WebhookEventType, a1 as buildCateringRequest, a2 as canOrderFood, a3 as guestsWithUnsharedAllergies, a4 as toDunbackAddress, a5 as toDunbackAttendees, a6 as toVenueLocation } from './luma-BwA6aHtI.js';
3
3
 
4
4
  /** Any non-2xx answer from the Partner API. */
5
5
  declare class DunbackApiError extends Error {
@@ -133,6 +133,22 @@ declare class DunbackClient {
133
133
  * `already_requested`, `request_window_closed`.
134
134
  */
135
135
  requestRefund: (orderId: string, input: LateRefundRequestInput) => Promise<LateRefundRequest>;
136
+ /**
137
+ * The host confirms a delivery arrived (within 48 hours of it; see
138
+ * `order.deliveries[].canConfirm`). Without `restaurantOrderId`, every
139
+ * recorded delivery. Errors: 409 `not_delivered`.
140
+ */
141
+ confirmDelivery: (orderId: string, restaurantOrderId?: string) => Promise<Order>;
142
+ /**
143
+ * Reports a problem with a delivery (missing items, damaged food, no
144
+ * setup, the driver's or courier's conduct...), within 48 hours of it
145
+ * (`order.deliveries[].canReportProblem`), optionally with photos and a
146
+ * refund request. The restaurant is told at once; a refund is decided by
147
+ * Dunback (webhook `order.refund_decided`). Errors: 409 `not_delivered`,
148
+ * `already_reported`, `report_window_closed`; 413 `photo_too_large`;
149
+ * 415 `invalid_photo`.
150
+ */
151
+ reportProblem: (orderId: string, input: ProblemReportInput) => Promise<ProblemReport>;
136
152
  /** Polls until the order leaves AWAITING_PAYMENT/PAID/FULFILLING. */
137
153
  waitForSettlement: (orderId: string, { timeoutMs, intervalMs }?: {
138
154
  timeoutMs?: number | undefined;
@@ -212,4 +228,4 @@ declare function payOrderWithX402(order: Pick<Order, "id" | "payment">, signer:
212
228
  maxAmountUsdc?: number;
213
229
  }): Promise<Order>;
214
230
 
215
- export { AppInfo, CancelOrderOptions, CateringRequest, CateringRequestInput, Cuisine, CuisineCatalog, CuisineQuery, DEFAULT_BASE_URL, DrinkType, DunbackApiError, DunbackClient, type DunbackClientOptions, LateRefundRequest, LateRefundRequestInput, Order, PAYMENT_ERROR_CODES, RestaurantSummary, SANDBOX_BASE_URL, SelectOptionInput, type TypedDataToSign, UpdateDeliveryInput, VenueLocation, WebhookEvent, type X402Signer, isPaymentError, payOrderWithX402, signWebhookPayload, verifyWebhook };
231
+ export { AppInfo, CancelOrderOptions, CateringRequest, CateringRequestInput, Cuisine, CuisineCatalog, CuisineQuery, DEFAULT_BASE_URL, DrinkType, DunbackApiError, DunbackClient, type DunbackClientOptions, LateRefundRequest, LateRefundRequestInput, Order, PAYMENT_ERROR_CODES, ProblemReport, ProblemReportInput, RestaurantSummary, SANDBOX_BASE_URL, SelectOptionInput, type TypedDataToSign, UpdateDeliveryInput, VenueLocation, WebhookEvent, type X402Signer, isPaymentError, payOrderWithX402, signWebhookPayload, verifyWebhook };
package/dist/index.js CHANGED
@@ -212,6 +212,22 @@ var DunbackClient = class {
212
212
  * `already_requested`, `request_window_closed`.
213
213
  */
214
214
  requestRefund: (orderId, input) => this.request("POST", `/orders/${encodeURIComponent(orderId)}/refund-requests`, input),
215
+ /**
216
+ * The host confirms a delivery arrived (within 48 hours of it; see
217
+ * `order.deliveries[].canConfirm`). Without `restaurantOrderId`, every
218
+ * recorded delivery. Errors: 409 `not_delivered`.
219
+ */
220
+ confirmDelivery: (orderId, restaurantOrderId) => this.request("POST", `/orders/${encodeURIComponent(orderId)}/deliveries/confirm`, restaurantOrderId ? { restaurantOrderId } : {}),
221
+ /**
222
+ * Reports a problem with a delivery (missing items, damaged food, no
223
+ * setup, the driver's or courier's conduct...), within 48 hours of it
224
+ * (`order.deliveries[].canReportProblem`), optionally with photos and a
225
+ * refund request. The restaurant is told at once; a refund is decided by
226
+ * Dunback (webhook `order.refund_decided`). Errors: 409 `not_delivered`,
227
+ * `already_reported`, `report_window_closed`; 413 `photo_too_large`;
228
+ * 415 `invalid_photo`.
229
+ */
230
+ reportProblem: (orderId, input) => this.request("POST", `/orders/${encodeURIComponent(orderId)}/problem-reports`, input),
215
231
  /** Polls until the order leaves AWAITING_PAYMENT/PAID/FULFILLING. */
216
232
  waitForSettlement: async (orderId, { timeoutMs = 15 * 6e4, intervalMs = 5e3 } = {}) => {
217
233
  const until = Date.now() + timeoutMs;
@@ -461,17 +461,6 @@ interface UsdcPaymentInstructions {
461
461
  /** For agents: POST here to pay with x402 (see payOrderWithX402). */
462
462
  x402Url?: string;
463
463
  }
464
- /** Where an order is delivered. `deliveryNotes` is your note only, without the catering and allergy text Dunback adds for the restaurant. */
465
- interface OrderDelivery {
466
- address: Required<Address>;
467
- onsiteContact: {
468
- name: string;
469
- phone: string;
470
- };
471
- deliveryNotes: string;
472
- /** True while the order is AWAITING_PAYMENT: the details can still be corrected (orders.updateDelivery). */
473
- editable: boolean;
474
- }
475
464
  /** POST /orders/:id/delivery: correct the delivery details before payment. */
476
465
  interface UpdateDeliveryInput {
477
466
  deliveryAddress: Address;
@@ -588,6 +577,13 @@ interface Order {
588
577
  afterMinutes: number;
589
578
  requestableFrom: string | null;
590
579
  };
580
+ /**
581
+ * Each restaurant order's delivery. For 48 hours after a delivery is
582
+ * recorded the host can confirm it (`orders.confirmDelivery`) or report a
583
+ * problem (`orders.reportProblem`): offer those while `canConfirm` /
584
+ * `canReportProblem` are true. Webhook `order.delivered` when one is recorded.
585
+ */
586
+ deliveries?: OrderDelivery[];
591
587
  error: {
592
588
  code: string;
593
589
  message: string;
@@ -649,6 +645,88 @@ interface LateRefundRequest {
649
645
  policy: string;
650
646
  requestedAt: string;
651
647
  }
648
+ /** Where an order is delivered. `deliveryNotes` is your note only, without the catering and allergy text Dunback adds for the restaurant. */
649
+ interface OrderDelivery {
650
+ address: Required<Address>;
651
+ onsiteContact: {
652
+ name: string;
653
+ phone: string;
654
+ };
655
+ deliveryNotes: string;
656
+ /** True while the order is AWAITING_PAYMENT: the details can still be corrected (orders.updateDelivery). */
657
+ editable: boolean;
658
+ }
659
+ interface OrderDelivery {
660
+ restaurantOrderId: string;
661
+ status: "pending" | "on_the_way" | "delivered" | "not_delivered" | "cancelled";
662
+ deliveredAt: string | null;
663
+ lateMinutes: number;
664
+ /** A Dunback or restaurant staff "driver", or a "courier" company the restaurant booked. */
665
+ deliveredBy: "driver" | "courier" | null;
666
+ courierCompany: string | null;
667
+ /**
668
+ * Who recorded the delivery time: the "driver" or "courier" (Dunback's clock,
669
+ * with a photo and location), or the "restaurant" (from the courier's proof
670
+ * of delivery, when the courier didn't record it). Show it with the time.
671
+ */
672
+ timeRecordedBy: "driver" | "courier" | "restaurant" | null;
673
+ hostConfirmedAt: string | null;
674
+ problemReport: {
675
+ type: DeliveryProblemType;
676
+ label: string;
677
+ description: string;
678
+ reportedAt: string;
679
+ wantsRefund: boolean;
680
+ photoCount: number;
681
+ } | null;
682
+ /** 48 hours after delivery. */
683
+ problemReportableUntil: string | null;
684
+ canConfirm: boolean;
685
+ canReportProblem: boolean;
686
+ }
687
+ type DeliveryProblemType = "MISSING_ITEMS" | "DAMAGED" | "WRONG_ORDER" | "NO_SETUP" | "CONDUCT" | "LATE" | "NOT_RECEIVED" | "OTHER";
688
+ /**
689
+ * orders.reportProblem(): anything wrong with a delivery, within 48 hours of
690
+ * it. The restaurant is told at once. With `wantsRefund`, Dunback reviews the
691
+ * report against its records of the delivery and decides the refund (0 up to
692
+ * the restaurant's part; Dunback's fees aren't refunded): webhook
693
+ * `order.refund_decided` (basis "delivery_problem", or "late_delivery" for a
694
+ * LATE report of a delivery recorded as late).
695
+ */
696
+ interface ProblemReportInput {
697
+ /** Which delivery (order.deliveries[].restaurantOrderId); default: every reportable one. */
698
+ restaurantOrderId?: string;
699
+ type: DeliveryProblemType;
700
+ /** What happened, in the host's words (10 to 2000 characters). */
701
+ description: string;
702
+ wantsRefund?: boolean;
703
+ /** Up to 3 photos, 5 MB each, base64 without the data: prefix. */
704
+ photos?: Array<{
705
+ contentType: "image/jpeg" | "image/png" | "image/webp";
706
+ data: string;
707
+ }>;
708
+ }
709
+ /** 202 from orders.reportProblem(). */
710
+ interface ProblemReport {
711
+ object: "problem_report";
712
+ orderId: string;
713
+ reportedAt: string;
714
+ reports: Array<{
715
+ restaurantOrderId: string;
716
+ type: DeliveryProblemType;
717
+ refundRequested: boolean;
718
+ refundBasis: "delivery_problem" | "late_delivery" | null;
719
+ /** The most the refund can be: the restaurant's part of that delivery. */
720
+ maximum: number | null;
721
+ }>;
722
+ order: Order;
723
+ }
724
+ /** `data` of `order.delivered`: the order, and which deliveries were just recorded. */
725
+ interface DeliveredData extends Order {
726
+ deliveredNow: string[];
727
+ /** How long the host can confirm or report a problem (48). */
728
+ problemReportHours: number;
729
+ }
652
730
  /** `data` of `order.delivered_late`: the order, and which deliveries were late. */
653
731
  interface DeliveredLateData extends Order {
654
732
  lateDeliveries: Array<{
@@ -671,8 +749,8 @@ interface CancelOrderOptions {
671
749
  interface RefundDecidedData extends Order {
672
750
  refundDecision: {
673
751
  restaurantOrderId: string;
674
- /** Why the refund was decided: a cancellation after the commitment deadline, or a late delivery. */
675
- basis: "cancelled_after_commitment" | "late_delivery";
752
+ /** Why the refund was decided: a cancellation after the commitment deadline, a late delivery, or a reported delivery problem. */
753
+ basis: "cancelled_after_commitment" | "late_delivery" | "delivery_problem";
676
754
  percentage: number;
677
755
  amount: number;
678
756
  explanation: string;
@@ -700,7 +778,7 @@ interface OrderRevision {
700
778
  reason: string;
701
779
  }>;
702
780
  }
703
- type WebhookEventType = "catering.options_ready" | "catering.no_options" | "catering.failed" | "order.created" | "order.confirmed" | "order.payment_failed" | "order.expired" | "order.failed" | "order.needs_attention" | "order.cancelled" | "order.refunded" | "order.refund_decided" | "order.delivered_late" | "order.delivery_updated" | "order.revised" | "ping";
781
+ type WebhookEventType = "catering.options_ready" | "catering.no_options" | "catering.failed" | "order.created" | "order.confirmed" | "order.payment_failed" | "order.expired" | "order.failed" | "order.needs_attention" | "order.cancelled" | "order.refunded" | "order.refund_decided" | "order.delivered" | "order.delivered_late" | "order.delivery_updated" | "order.revised" | "ping";
704
782
  /** `data` of a `ping` event, sent by "Send test event" in the Developer Dashboard. */
705
783
  interface PingData {
706
784
  object: "ping";
@@ -911,4 +989,4 @@ declare function canOrderFood(settings: DunbackEventSettings | null | undefined,
911
989
  reason?: string;
912
990
  };
913
991
 
914
- export { guestsWithUnsharedAllergies as $, type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C, type DrinkType as D, type OrderDelivery as E, type OrderRevision as F, type OrderStatus as G, type PingData as H, type Price as I, type PriceLine as J, type RefundDecidedData as K, type LateRefundRequestInput as L, type StandardCuisineId as M, type UnavailableReason as N, type Order as O, type PartyDiet as P, type UnavailableReasonCode as Q, type RestaurantSummary as R, type SelectOptionInput as S, type UnfedGuests as T, type UpdateDeliveryInput as U, type VenueLocation as V, type WebhookEvent as W, type UsdcPaymentInstructions as X, type WebhookEventType as Y, buildCateringRequest as Z, canOrderFood as _, type Cuisine as a, toDunbackAddress as a0, toDunbackAttendees as a1, toVenueLocation as a2, type CuisineCatalog as b, type CateringRequestInput as c, type CateringRequest as d, type CancelOrderOptions as e, type LateRefundRequest as f, ATTENDING_STATUSES as g, type Address as h, type AllergyCoverage as i, type Attendee as j, type CateringBudgetResult as k, type CateringItem as l, type CateringMealType as m, type CateringOption as n, type CateringPolicies as o, type CateringRequestStatus as p, type CateringServiceStyle as q, type CuisineId as r, type CustomCuisineId as s, DUNBACK_REGISTRATION_QUESTION as t, type DeliveredLateData as u, type DrinkTypeId as v, type DunbackEventSettings as w, type LumaEventLike as x, type LumaGuestLike as y, type OrderCancellation as z };
992
+ export { type UsdcPaymentInstructions as $, type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C, type DrinkType as D, type LumaEventLike as E, type LumaGuestLike as F, type OrderCancellation as G, type OrderDelivery as H, type OrderRevision as I, type OrderStatus as J, type PartyDiet as K, type LateRefundRequestInput as L, type PingData as M, type Price as N, type Order as O, type ProblemReportInput as P, type PriceLine as Q, type RestaurantSummary as R, type SelectOptionInput as S, type RefundDecidedData as T, type UpdateDeliveryInput as U, type VenueLocation as V, type WebhookEvent as W, type StandardCuisineId as X, type UnavailableReason as Y, type UnavailableReasonCode as Z, type UnfedGuests as _, type Cuisine as a, type WebhookEventType as a0, buildCateringRequest as a1, canOrderFood as a2, guestsWithUnsharedAllergies as a3, toDunbackAddress as a4, toDunbackAttendees as a5, toVenueLocation as a6, type CuisineCatalog as b, type CateringRequestInput as c, type CateringRequest as d, type CancelOrderOptions as e, type LateRefundRequest as f, type ProblemReport as g, ATTENDING_STATUSES as h, type Address as i, type AllergyCoverage as j, type Attendee as k, type CateringBudgetResult as l, type CateringItem as m, type CateringMealType as n, type CateringOption as o, type CateringPolicies as p, type CateringRequestStatus as q, type CateringServiceStyle as r, type CuisineId as s, type CustomCuisineId as t, DUNBACK_REGISTRATION_QUESTION as u, type DeliveredData as v, type DeliveredLateData as w, type DeliveryProblemType as x, type DrinkTypeId as y, type DunbackEventSettings as z };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { n as CateringOption, a as Cuisine, w as DunbackEventSettings, R as RestaurantSummary, D as DrinkType, O as Order, I as Price } from '../luma-WIhD5QRd.js';
2
+ import { o as CateringOption, a as Cuisine, z as DunbackEventSettings, R as RestaurantSummary, D as DrinkType, O as Order, N as Price } from '../luma-BwA6aHtI.js';
3
3
 
4
4
  /**
5
5
  * Optional, unstyled-by-default React building blocks for the three Luma