order3000 0.16.0 → 0.18.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.cjs +395 -5
- package/dist/client.d.cts +890 -14
- package/dist/client.d.mts +890 -14
- package/dist/client.mjs +392 -6
- package/package.json +3 -3
package/dist/client.d.mts
CHANGED
|
@@ -14,16 +14,43 @@ declare class TokenManager {
|
|
|
14
14
|
initialize(): Promise<void>;
|
|
15
15
|
getToken(): Promise<string>;
|
|
16
16
|
getVenueId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Async counterpart to {@link getVenueId}. Fetches the token if it
|
|
19
|
+
* hasn't been loaded yet (which is what populates `defaultVenueId` via
|
|
20
|
+
* `setDefaultVenueId`), then returns the venue id.
|
|
21
|
+
*
|
|
22
|
+
* Prefer this over `getVenueId()` from request paths — a cold SDK
|
|
23
|
+
* instance will otherwise synchronously throw "No venue ID available"
|
|
24
|
+
* before the token has had a chance to load.
|
|
25
|
+
*/
|
|
26
|
+
getVenueIdAsync(): Promise<string>;
|
|
17
27
|
private refreshToken;
|
|
18
28
|
private setDefaultVenueId;
|
|
19
29
|
}
|
|
20
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Per-call cache override. Default behaviour is `cache: 'no-store'`
|
|
33
|
+
* — correct for live-read endpoints (basket, team-order, payment
|
|
34
|
+
* intents) where any caching causes stale responses against realtime
|
|
35
|
+
* mutations. Resources that surface near-static data consumed during
|
|
36
|
+
* static generation (e.g. `events.getByAccessor` for the Tiffinbox
|
|
37
|
+
* event schedule) can override with `next: { revalidate: N }` so
|
|
38
|
+
* Next.js can pre-render the calling page during the build instead
|
|
39
|
+
* of bailing out to dynamic rendering with `DYNAMIC_SERVER_USAGE`.
|
|
40
|
+
*/
|
|
41
|
+
interface RequestCacheOptions {
|
|
42
|
+
cache?: RequestCache;
|
|
43
|
+
next?: {
|
|
44
|
+
revalidate?: number | false;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
21
48
|
declare abstract class BaseResource {
|
|
22
49
|
protected readonly tokenManager: TokenManager;
|
|
23
50
|
protected readonly baseUrl: string;
|
|
24
51
|
protected readonly resourcePath: string;
|
|
25
52
|
constructor(tokenManager: TokenManager, baseUrl: string, resourcePath: string);
|
|
26
|
-
protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown): Promise<T>;
|
|
53
|
+
protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown, cacheOptions?: RequestCacheOptions): Promise<T>;
|
|
27
54
|
}
|
|
28
55
|
|
|
29
56
|
interface components {
|
|
@@ -118,18 +145,20 @@ interface components {
|
|
|
118
145
|
/** @enum {string|null} */
|
|
119
146
|
paymentMethod?: "card" | "cash" | "voucher" | null;
|
|
120
147
|
/** @enum {string} */
|
|
121
|
-
paymentStatus?: "unpaid" | "paid" | "refunded";
|
|
148
|
+
paymentStatus?: "unpaid" | "paid" | "refunded" | "authorized" | "cash_pending";
|
|
122
149
|
taxAmount: number;
|
|
123
150
|
totalAmount: number;
|
|
124
151
|
/** @enum {string} */
|
|
125
152
|
currency?: "EUR" | "CHF";
|
|
126
153
|
/** @enum {string|null} */
|
|
127
154
|
fulfillmentType?: "pickup" | "delivery" | null;
|
|
128
|
-
fulfillmentAt
|
|
155
|
+
fulfillmentAt?: unknown;
|
|
129
156
|
orderedAt?: unknown;
|
|
130
157
|
orderedBy: string;
|
|
131
158
|
updatedAt?: unknown;
|
|
132
159
|
updatedBy?: string | null;
|
|
160
|
+
teamOrderId?: string | null;
|
|
161
|
+
participantDisplayName?: string | null;
|
|
133
162
|
};
|
|
134
163
|
/** PlaceOrderResponse */
|
|
135
164
|
PlaceOrderResponse: {
|
|
@@ -144,7 +173,7 @@ interface components {
|
|
|
144
173
|
/** @enum {string|null} */
|
|
145
174
|
paymentMethod: "card" | "cash" | "voucher" | null;
|
|
146
175
|
/** @enum {string} */
|
|
147
|
-
paymentStatus: "unpaid" | "paid" | "refunded";
|
|
176
|
+
paymentStatus: "unpaid" | "paid" | "refunded" | "authorized" | "cash_pending";
|
|
148
177
|
taxAmount: number;
|
|
149
178
|
totalAmount: number;
|
|
150
179
|
/** @enum {string} */
|
|
@@ -156,6 +185,8 @@ interface components {
|
|
|
156
185
|
orderedBy: string;
|
|
157
186
|
updatedAt: unknown;
|
|
158
187
|
updatedBy: string | null;
|
|
188
|
+
teamOrderId: string | null;
|
|
189
|
+
participantDisplayName: string | null;
|
|
159
190
|
};
|
|
160
191
|
/**
|
|
161
192
|
* MakeReservationRequest
|
|
@@ -316,8 +347,13 @@ type OrderFulfillmentType = 'pickup' | 'delivery';
|
|
|
316
347
|
type PlaceOrderRequest = Omit<schemas['PlaceOrderRequest'], 'taxAmount' | 'totalAmount' | 'fulfillmentAt'> & {
|
|
317
348
|
/** Fulfillment type for the order (pickup or delivery) */
|
|
318
349
|
fulfillmentType?: OrderFulfillmentType;
|
|
319
|
-
/**
|
|
320
|
-
|
|
350
|
+
/**
|
|
351
|
+
* When the order should be fulfilled (ISO 8601 datetime or Date).
|
|
352
|
+
* Null / omitted in team-order mode — the Lead's pickup-time decision
|
|
353
|
+
* is attached to the team row and backfilled onto each child order at
|
|
354
|
+
* submit time.
|
|
355
|
+
*/
|
|
356
|
+
fulfillmentAt?: Date | string | null;
|
|
321
357
|
/** Guest session identifier for customer lookup */
|
|
322
358
|
sessionId?: string;
|
|
323
359
|
/** Customer first name (for cash orders) */
|
|
@@ -326,8 +362,12 @@ type PlaceOrderRequest = Omit<schemas['PlaceOrderRequest'], 'taxAmount' | 'total
|
|
|
326
362
|
customerLastName?: string;
|
|
327
363
|
/** Customer email address (for cash orders) */
|
|
328
364
|
customerEmail?: string;
|
|
329
|
-
/**
|
|
330
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Deposit containers the customer declares they will return at pickup.
|
|
367
|
+
* Per-template references only — order3000 refuses any inbound deposit
|
|
368
|
+
* money amount.
|
|
369
|
+
*/
|
|
370
|
+
declaredReturns?: DeclaredReturn[];
|
|
331
371
|
};
|
|
332
372
|
type PlaceOrderResponse = schemas['PlaceOrderResponse'];
|
|
333
373
|
type MakeReservationRequest = schemas['MakeReservationRequest'];
|
|
@@ -533,7 +573,24 @@ interface GetMenuOptions {
|
|
|
533
573
|
expand?: ('items' | 'assets')[];
|
|
534
574
|
}
|
|
535
575
|
interface MenuBundleDeposit {
|
|
576
|
+
/**
|
|
577
|
+
* Primary reference. Clients declare returns against this id +
|
|
578
|
+
* a count; they never specify a deposit money amount. order3000
|
|
579
|
+
* refuses to accept a deposit amount on any inbound payload.
|
|
580
|
+
*/
|
|
581
|
+
depositwareTemplateId: string;
|
|
582
|
+
/**
|
|
583
|
+
* Stable, human-readable handle for the underlying depositware
|
|
584
|
+
* template (e.g. `tiffinbox-3-1ee95d`). Lets app code target a
|
|
585
|
+
* canonical template by a code-level constant without hardcoding
|
|
586
|
+
* an environment-specific UUID.
|
|
587
|
+
*/
|
|
588
|
+
accessor: string;
|
|
536
589
|
name: Record<string, string>;
|
|
590
|
+
/**
|
|
591
|
+
* Display-only. Derived from `depositware_templates.deposit_base`.
|
|
592
|
+
* Never round-trip this value back to the server.
|
|
593
|
+
*/
|
|
537
594
|
amount: number;
|
|
538
595
|
currency: CurrencyCode;
|
|
539
596
|
}
|
|
@@ -600,6 +657,102 @@ interface GetEventOptions {
|
|
|
600
657
|
/** Expand related resources (schedule, timeSlots, menus, posters) */
|
|
601
658
|
expand?: ('schedule' | 'timeSlots' | 'menus' | 'posters')[];
|
|
602
659
|
}
|
|
660
|
+
type AreaBookingMode = 'slot' | 'day';
|
|
661
|
+
type AreaBookingRequestStatus = 'pending' | 'approved' | 'rejected' | 'cancelled';
|
|
662
|
+
type AreaBookingRequestSource = 'website' | 'phone' | 'walk_in';
|
|
663
|
+
type AreaBookingStatus = 'confirmed' | 'arrived' | 'completed' | 'cancelled' | 'no_show';
|
|
664
|
+
interface AreaAsset {
|
|
665
|
+
id: string;
|
|
666
|
+
type: 'image' | 'video' | 'document';
|
|
667
|
+
tags: string[] | null;
|
|
668
|
+
filename: string;
|
|
669
|
+
contentType: string;
|
|
670
|
+
metadata: {
|
|
671
|
+
width?: number;
|
|
672
|
+
height?: number;
|
|
673
|
+
duration?: number;
|
|
674
|
+
} | null;
|
|
675
|
+
cropArea: CropArea | null;
|
|
676
|
+
publicUrl: string;
|
|
677
|
+
}
|
|
678
|
+
interface AreaFeature {
|
|
679
|
+
icon: string;
|
|
680
|
+
label: Record<string, string>;
|
|
681
|
+
description?: Record<string, string>;
|
|
682
|
+
}
|
|
683
|
+
interface Area {
|
|
684
|
+
id: string;
|
|
685
|
+
venueId: string;
|
|
686
|
+
accessor: string;
|
|
687
|
+
name: Record<string, string>;
|
|
688
|
+
description: Record<string, string> | null;
|
|
689
|
+
longDescription: Record<string, string> | null;
|
|
690
|
+
minCapacity: number | null;
|
|
691
|
+
maxCapacity: number;
|
|
692
|
+
currency: Currency;
|
|
693
|
+
/** Base price in cents (flat price per booking). Null when pricing is per-person only. */
|
|
694
|
+
basePrice: number | null;
|
|
695
|
+
/** Per-guest price in cents. Null when pricing is base-only. */
|
|
696
|
+
perPersonPrice: number | null;
|
|
697
|
+
features: AreaFeature[] | null;
|
|
698
|
+
bookingMode: AreaBookingMode;
|
|
699
|
+
assets?: AreaAsset[];
|
|
700
|
+
}
|
|
701
|
+
interface GetAreaOptions {
|
|
702
|
+
expand?: 'assets'[];
|
|
703
|
+
}
|
|
704
|
+
interface AreaAvailabilityWindow {
|
|
705
|
+
/** YYYY-MM-DD */
|
|
706
|
+
date: string;
|
|
707
|
+
/** HH:MM:SS, null for day-mode bookings */
|
|
708
|
+
startTime: string | null;
|
|
709
|
+
endTime: string | null;
|
|
710
|
+
}
|
|
711
|
+
interface AreaAvailabilityResponse {
|
|
712
|
+
from: string;
|
|
713
|
+
to: string;
|
|
714
|
+
bookingMode: AreaBookingMode;
|
|
715
|
+
occupied: AreaAvailabilityWindow[];
|
|
716
|
+
}
|
|
717
|
+
interface GetAreaAvailabilityOptions {
|
|
718
|
+
/** YYYY-MM-DD — defaults to today */
|
|
719
|
+
from?: string;
|
|
720
|
+
/** YYYY-MM-DD — defaults to today + 90d */
|
|
721
|
+
to?: string;
|
|
722
|
+
}
|
|
723
|
+
interface SubmitAreaBookingRequestPayload {
|
|
724
|
+
/** YYYY-MM-DD */
|
|
725
|
+
requestedDate: string;
|
|
726
|
+
/** HH:MM:SS — omit for day-mode bookings */
|
|
727
|
+
requestedStartTime?: string;
|
|
728
|
+
requestedEndTime?: string;
|
|
729
|
+
partySize: number;
|
|
730
|
+
customerFirstName: string;
|
|
731
|
+
customerLastName: string;
|
|
732
|
+
customerEmail: string;
|
|
733
|
+
customerPhone?: string;
|
|
734
|
+
message?: string;
|
|
735
|
+
source?: AreaBookingRequestSource;
|
|
736
|
+
}
|
|
737
|
+
interface AreaBookingRequestResponse {
|
|
738
|
+
id: string;
|
|
739
|
+
venueId: string;
|
|
740
|
+
areaId: string;
|
|
741
|
+
requestedDate: string;
|
|
742
|
+
requestedStartTime: string | null;
|
|
743
|
+
requestedEndTime: string | null;
|
|
744
|
+
partySize: number;
|
|
745
|
+
customerFirstName: string;
|
|
746
|
+
customerLastName: string;
|
|
747
|
+
customerEmail: string;
|
|
748
|
+
customerPhone: string | null;
|
|
749
|
+
message: string | null;
|
|
750
|
+
source: AreaBookingRequestSource;
|
|
751
|
+
status: AreaBookingRequestStatus;
|
|
752
|
+
areaBookingId: string | null;
|
|
753
|
+
createdAt: string | null;
|
|
754
|
+
updatedAt: string | null;
|
|
755
|
+
}
|
|
603
756
|
type BasketStatus = 'active' | 'abandoned' | 'converted';
|
|
604
757
|
type Currency = 'EUR' | 'CHF';
|
|
605
758
|
/**
|
|
@@ -628,6 +781,17 @@ interface BasketItemMetadata {
|
|
|
628
781
|
price?: number;
|
|
629
782
|
[key: string]: unknown;
|
|
630
783
|
}
|
|
784
|
+
/**
|
|
785
|
+
* Deposit info on a basket item — **always server-derived** from the row's
|
|
786
|
+
* `depositware_template_id` column. order3000 refuses any inbound deposit
|
|
787
|
+
* money amount; this object is outbound-only, for UI display.
|
|
788
|
+
*/
|
|
789
|
+
interface BasketItemDeposit {
|
|
790
|
+
depositwareTemplateId: string;
|
|
791
|
+
name: Record<string, string>;
|
|
792
|
+
amount: number;
|
|
793
|
+
currency: Currency;
|
|
794
|
+
}
|
|
631
795
|
/**
|
|
632
796
|
* A basket item represents a single physical product in the basket.
|
|
633
797
|
*
|
|
@@ -638,6 +802,7 @@ interface BasketItemMetadata {
|
|
|
638
802
|
interface BasketItem {
|
|
639
803
|
id: string;
|
|
640
804
|
metadata: BasketItemMetadata | null;
|
|
805
|
+
deposit: BasketItemDeposit | null;
|
|
641
806
|
menuItems: BasketItemMenuItemRef[];
|
|
642
807
|
}
|
|
643
808
|
interface Basket {
|
|
@@ -647,10 +812,99 @@ interface Basket {
|
|
|
647
812
|
currency: Currency;
|
|
648
813
|
items: BasketItem[];
|
|
649
814
|
itemCount: number;
|
|
815
|
+
/**
|
|
816
|
+
* Canonical totals computed server-side and shipped inline with the
|
|
817
|
+
* basket. Computed using `declaredReturns` below, so the deposit
|
|
818
|
+
* credit is already baked into `effectiveTotal` — clients render the
|
|
819
|
+
* final value on first paint without a follow-up chip-hydration round
|
|
820
|
+
* trip. Use `POST /baskets/:id/totals` only when the user interacts
|
|
821
|
+
* with the stepper to recompute with new counts.
|
|
822
|
+
*/
|
|
823
|
+
totals: BasketTotals;
|
|
824
|
+
/**
|
|
825
|
+
* Server-persisted declared-return counts (from `baskets.declared_returns`).
|
|
826
|
+
* Reflects the participant's last chip click. Clients seed their
|
|
827
|
+
* local `declaredReturns` store from this at hydration time so the
|
|
828
|
+
* chip count + Gesamt are consistent on first paint. Only positive
|
|
829
|
+
* counts are present; zero entries are stripped.
|
|
830
|
+
*/
|
|
831
|
+
declaredReturns: DeclaredReturn[];
|
|
650
832
|
expiresAt: string;
|
|
651
833
|
createdAt: string | null;
|
|
652
834
|
updatedAt: string | null;
|
|
653
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* Order workflow status (matches `order_status` enum in order3000).
|
|
838
|
+
*/
|
|
839
|
+
type OrderStatus = 'pending' | 'in_progress' | 'ready' | 'completed' | 'cancelled';
|
|
840
|
+
/**
|
|
841
|
+
* Payment workflow status (matches `payment_status` enum in order3000).
|
|
842
|
+
*/
|
|
843
|
+
type PaymentStatus = 'unpaid' | 'authorized' | 'cash_pending' | 'paid' | 'refunded' | 'failed';
|
|
844
|
+
/**
|
|
845
|
+
* The most recent non-team order for a guest session, with the captured
|
|
846
|
+
* basket items + totals + declared returns inlined. Returned by
|
|
847
|
+
* `orders.getLatest(sessionId)`. Used by thamarai to drive the
|
|
848
|
+
* post-placement read-only view of the ThermoBox stepper.
|
|
849
|
+
*
|
|
850
|
+
* `null` when the session has no qualifying order — fresh sessionIds
|
|
851
|
+
* and team-only sessions both fall through to `null`.
|
|
852
|
+
*/
|
|
853
|
+
interface LatestOrder {
|
|
854
|
+
id: string;
|
|
855
|
+
/** URL-safe non-guessable id (e.g. `ORD-A3B7K2`). Nullable until backfill. */
|
|
856
|
+
publicId: string | null;
|
|
857
|
+
/** Cycling 100→999 per venue. Nullable until PaymentIntent assigns. */
|
|
858
|
+
quickReferenceNumber: number | null;
|
|
859
|
+
status: OrderStatus;
|
|
860
|
+
paymentStatus: PaymentStatus;
|
|
861
|
+
fulfillmentType: OrderFulfillmentType | null;
|
|
862
|
+
/** ISO timestamp of pickup / delivery. */
|
|
863
|
+
fulfillmentAt: string | null;
|
|
864
|
+
orderedAt: string;
|
|
865
|
+
totalAmount: number;
|
|
866
|
+
currency: Currency;
|
|
867
|
+
/** Captured basket items — same shape `Basket.items` uses. */
|
|
868
|
+
items: BasketItem[];
|
|
869
|
+
itemCount: number;
|
|
870
|
+
/** Captured basket totals; `effectiveTotal` already reflects the credit. */
|
|
871
|
+
totals: BasketTotals;
|
|
872
|
+
/** Declared-return counts the customer locked in at submit time. */
|
|
873
|
+
declaredReturns: DeclaredReturn[];
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* One "I'll return N of this template" declaration. Canonical deposit
|
|
877
|
+
* input across every order3000 endpoint — clients never specify a
|
|
878
|
+
* deposit money amount.
|
|
879
|
+
*/
|
|
880
|
+
interface DeclaredReturn {
|
|
881
|
+
depositwareTemplateId: string;
|
|
882
|
+
count: number;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Canonical basket totals (all cents). The single figure clients read
|
|
886
|
+
* for every displayed monetary value; replaces every local amount-times-
|
|
887
|
+
* count multiplication.
|
|
888
|
+
*/
|
|
889
|
+
interface BasketTotals {
|
|
890
|
+
currency: Currency;
|
|
891
|
+
/** Food prices summed across basket items (tax-inclusive, no deposits). */
|
|
892
|
+
itemsTotal: number;
|
|
893
|
+
/** Tax portion extracted from `itemsTotal`. */
|
|
894
|
+
taxAmount: number;
|
|
895
|
+
/** Sum of deposits currently in the basket (one per returnable item). */
|
|
896
|
+
depositCharge: number;
|
|
897
|
+
/** `itemsTotal + depositCharge` — what an un-declared customer pays. */
|
|
898
|
+
grossTotal: number;
|
|
899
|
+
/** Credit owed for declared returns (bounded per-template by `returnable`). */
|
|
900
|
+
depositCredit: number;
|
|
901
|
+
/** `grossTotal − depositCredit`, clamped to zero. */
|
|
902
|
+
effectiveTotal: number;
|
|
903
|
+
/** When `depositCredit > grossTotal`, the excess is a cash refund due. */
|
|
904
|
+
cashRefund: number;
|
|
905
|
+
/** How many units of each depositware template the basket currently holds. */
|
|
906
|
+
returnable: DeclaredReturn[];
|
|
907
|
+
}
|
|
654
908
|
/**
|
|
655
909
|
* Request to add an item to the basket.
|
|
656
910
|
*
|
|
@@ -670,31 +924,121 @@ interface AddToBasketRequest {
|
|
|
670
924
|
interface AddToBasketResponse {
|
|
671
925
|
basketItemId: string;
|
|
672
926
|
itemCount: number;
|
|
927
|
+
deposit: BasketItemDeposit | null;
|
|
928
|
+
/**
|
|
929
|
+
* Fresh canonical totals for the mutated basket (declaredReturns=[]).
|
|
930
|
+
* Clients apply this directly to their store — no extra round trip.
|
|
931
|
+
*/
|
|
932
|
+
totals: BasketTotals;
|
|
673
933
|
}
|
|
674
934
|
interface RemoveFromBasketResponse {
|
|
675
935
|
success: boolean;
|
|
676
936
|
basketItemId: string;
|
|
677
937
|
itemCount: number;
|
|
938
|
+
/**
|
|
939
|
+
* Fresh canonical totals for the mutated basket (declaredReturns=[]).
|
|
940
|
+
* `null` when the basket has no items left after the removal.
|
|
941
|
+
*/
|
|
942
|
+
totals: BasketTotals | null;
|
|
678
943
|
}
|
|
679
944
|
interface CreatePaymentIntentRequest {
|
|
680
945
|
basketId: string;
|
|
681
946
|
currency: Currency;
|
|
682
947
|
sessionId: string;
|
|
683
948
|
fulfillmentType?: OrderFulfillmentType;
|
|
684
|
-
/**
|
|
685
|
-
|
|
949
|
+
/**
|
|
950
|
+
* Optional — null / omitted in team-order mode. The Lead's pickup-time
|
|
951
|
+
* decision is stored on the team row and backfilled onto each child
|
|
952
|
+
* order at submit time.
|
|
953
|
+
*/
|
|
954
|
+
fulfillmentAt?: Date | string | null;
|
|
686
955
|
/** Customer first name (for Stripe metadata and customer record) */
|
|
687
956
|
customerFirstName?: string;
|
|
688
957
|
/** Customer last name (for Stripe metadata and customer record) */
|
|
689
958
|
customerLastName?: string;
|
|
690
|
-
/**
|
|
691
|
-
|
|
959
|
+
/**
|
|
960
|
+
* Deposit containers the customer declares they will return at pickup.
|
|
961
|
+
* Per-template references only — order3000 refuses any inbound deposit
|
|
962
|
+
* money amount.
|
|
963
|
+
*/
|
|
964
|
+
declaredReturns?: DeclaredReturn[];
|
|
965
|
+
/**
|
|
966
|
+
* The team order's public identifier (URL `?publicId=…`) when the
|
|
967
|
+
* caller is checking out as a team participant. Omitted for individual
|
|
968
|
+
* checkout. The server enters team-participant mode (manual-capture PI
|
|
969
|
+
* awaiting the Lead's submit) only when this is present AND matches the
|
|
970
|
+
* basket's attached team. Stale `basket.teamOrderId` without a matching
|
|
971
|
+
* `teamOrderPublicId` is treated as individual — the basket simply
|
|
972
|
+
* carries a dead pointer from an abandoned prior session.
|
|
973
|
+
*/
|
|
974
|
+
teamOrderPublicId?: string;
|
|
692
975
|
}
|
|
693
976
|
interface CreatePaymentIntentResponse {
|
|
694
977
|
clientSecret: string;
|
|
695
978
|
paymentIntentId: string;
|
|
696
979
|
orderId: string;
|
|
697
980
|
}
|
|
981
|
+
interface CreateDeltaPaymentIntentRequest {
|
|
982
|
+
basketId: string;
|
|
983
|
+
sessionId: string;
|
|
984
|
+
currency: Currency;
|
|
985
|
+
/**
|
|
986
|
+
* Deposit containers the participant declares they will return at
|
|
987
|
+
* pickup. Used to apply deposit credit against the delta amount so the
|
|
988
|
+
* server's `currentTotal` matches the client's displayed effective
|
|
989
|
+
* total. Per-template references only.
|
|
990
|
+
*/
|
|
991
|
+
declaredReturns?: DeclaredReturn[];
|
|
992
|
+
}
|
|
993
|
+
interface CreateDeltaPaymentIntentResponse {
|
|
994
|
+
/** null when Stripe confirmed the off-session PI without further action. */
|
|
995
|
+
clientSecret: string | null;
|
|
996
|
+
paymentIntentId: string;
|
|
997
|
+
orderId: string;
|
|
998
|
+
/** Delta amount actually charged (cents). */
|
|
999
|
+
amount: number;
|
|
1000
|
+
/**
|
|
1001
|
+
* Stripe PaymentIntent status after confirm. Typically:
|
|
1002
|
+
* - 'requires_capture' → one-tap succeeded; capture happens at submit
|
|
1003
|
+
* - 'requires_action' → 3DS prompt required; client completes via clientSecret
|
|
1004
|
+
* - 'succeeded' (rare here, auto-capture would have to be set)
|
|
1005
|
+
*/
|
|
1006
|
+
status: string;
|
|
1007
|
+
}
|
|
1008
|
+
interface ReduceDeltaPaymentIntentRequest {
|
|
1009
|
+
basketId: string;
|
|
1010
|
+
sessionId: string;
|
|
1011
|
+
currency: Currency;
|
|
1012
|
+
/**
|
|
1013
|
+
* Deposit containers the participant declares they will return at pickup.
|
|
1014
|
+
* Per-template references only; order3000 refuses any deposit money
|
|
1015
|
+
* amount on input.
|
|
1016
|
+
*/
|
|
1017
|
+
declaredReturns?: DeclaredReturn[];
|
|
1018
|
+
}
|
|
1019
|
+
interface ReduceDeltaPaymentIntentResponse {
|
|
1020
|
+
orderId: string;
|
|
1021
|
+
/** New authorised total (cents) after the reduction. */
|
|
1022
|
+
paidTotal: number;
|
|
1023
|
+
/** Amount actually released (cents). */
|
|
1024
|
+
released: number;
|
|
1025
|
+
}
|
|
1026
|
+
interface AddCashDeltaRequest {
|
|
1027
|
+
basketId: string;
|
|
1028
|
+
sessionId: string;
|
|
1029
|
+
/**
|
|
1030
|
+
* Deposit containers the participant declares they will return at pickup.
|
|
1031
|
+
* Per-template references only.
|
|
1032
|
+
*/
|
|
1033
|
+
declaredReturns?: DeclaredReturn[];
|
|
1034
|
+
}
|
|
1035
|
+
interface AddCashDeltaResponse {
|
|
1036
|
+
orderId: string;
|
|
1037
|
+
/** Delta amount (cents) recorded in this call. */
|
|
1038
|
+
amount: number;
|
|
1039
|
+
/** Sum of all active cash payments on this order after the delta row was inserted. */
|
|
1040
|
+
paidTotal: number;
|
|
1041
|
+
}
|
|
698
1042
|
interface ConfirmOrderRequest {
|
|
699
1043
|
paymentIntentId: string;
|
|
700
1044
|
}
|
|
@@ -702,6 +1046,8 @@ interface ConfirmOrderResponse {
|
|
|
702
1046
|
id: string;
|
|
703
1047
|
status: string;
|
|
704
1048
|
publicId: string | null;
|
|
1049
|
+
/** Cycling 100→999 short reference printed on receipts and shown to staff. */
|
|
1050
|
+
quickReferenceNumber: number | null;
|
|
705
1051
|
/** Customer ID for the order (for client-side tracking) */
|
|
706
1052
|
customerId?: string;
|
|
707
1053
|
}
|
|
@@ -764,6 +1110,27 @@ interface SubscriptionCredit {
|
|
|
764
1110
|
createdAt: string | null;
|
|
765
1111
|
}
|
|
766
1112
|
|
|
1113
|
+
declare class AreasResource extends BaseResource {
|
|
1114
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
1115
|
+
/**
|
|
1116
|
+
* List bookable + public areas for the venue.
|
|
1117
|
+
*/
|
|
1118
|
+
list(options?: GetAreaOptions): Promise<Area[]>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Fetch a single area by id or accessor.
|
|
1121
|
+
*/
|
|
1122
|
+
getByAccessor(accessor: string, options?: GetAreaOptions): Promise<Area>;
|
|
1123
|
+
/**
|
|
1124
|
+
* List occupied date/time windows for an area between `from` and `to`.
|
|
1125
|
+
*/
|
|
1126
|
+
getAvailability(accessor: string, options?: GetAreaAvailabilityOptions): Promise<AreaAvailabilityResponse>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Submit a public booking request for an area.
|
|
1129
|
+
*/
|
|
1130
|
+
submitBookingRequest(accessor: string, payload: SubmitAreaBookingRequestPayload): Promise<AreaBookingRequestResponse>;
|
|
1131
|
+
private buildExpandQuery;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
767
1134
|
declare class BasketsResource extends BaseResource {
|
|
768
1135
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
769
1136
|
/**
|
|
@@ -790,6 +1157,49 @@ declare class BasketsResource extends BaseResource {
|
|
|
790
1157
|
* @returns The response with item count
|
|
791
1158
|
*/
|
|
792
1159
|
remove(sessionId: string, basketItemId: string): Promise<RemoveFromBasketResponse>;
|
|
1160
|
+
/**
|
|
1161
|
+
* Canonical totals for a basket. Clients read every displayed monetary
|
|
1162
|
+
* figure (effective total, deposit credit, cash refund) from this
|
|
1163
|
+
* endpoint — they never multiply deposit counts by amounts locally.
|
|
1164
|
+
*
|
|
1165
|
+
* Pass `declaredReturns` as references to depositware templates plus a
|
|
1166
|
+
* count. order3000 refuses deposit money amounts on input.
|
|
1167
|
+
*/
|
|
1168
|
+
getTotals(basketId: string, body?: {
|
|
1169
|
+
declaredReturns?: DeclaredReturn[];
|
|
1170
|
+
}): Promise<BasketTotals>;
|
|
1171
|
+
/**
|
|
1172
|
+
* Mark every active basket for the session as `abandoned`.
|
|
1173
|
+
*
|
|
1174
|
+
* Used by thamarai's "Neu starten" flow: after a non-team order
|
|
1175
|
+
* has been placed (its basket converted), the user might want to
|
|
1176
|
+
* start a fresh order. A subsequent `add()` call would otherwise
|
|
1177
|
+
* reuse any leftover active basket on the same session — which
|
|
1178
|
+
* can happen if a prior compose flow left an active row behind.
|
|
1179
|
+
* Calling `abandon()` first guarantees the next `add()` inserts a
|
|
1180
|
+
* brand-new active basket with exactly one item.
|
|
1181
|
+
*/
|
|
1182
|
+
abandon(sessionId: string): Promise<{
|
|
1183
|
+
abandonedCount: number;
|
|
1184
|
+
}>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Persist per-template declared-return counts onto the basket.
|
|
1187
|
+
*
|
|
1188
|
+
* Used by team-order participants so the Lead's breakdown popover
|
|
1189
|
+
* sees every member's intent in real time (the standard
|
|
1190
|
+
* `useTeamOrderRealtime` postgres-changes subscription on
|
|
1191
|
+
* `baskets` then propagates the change to the team).
|
|
1192
|
+
*
|
|
1193
|
+
* Server validates `sessionId === basket.session_id` — only the
|
|
1194
|
+
* basket's owner can write to its declared returns.
|
|
1195
|
+
*/
|
|
1196
|
+
setDeclaredReturns(basketId: string, body: {
|
|
1197
|
+
sessionId: string;
|
|
1198
|
+
declaredReturns: DeclaredReturn[];
|
|
1199
|
+
}): Promise<{
|
|
1200
|
+
basketId: string;
|
|
1201
|
+
declaredReturns: DeclaredReturn[];
|
|
1202
|
+
}>;
|
|
793
1203
|
}
|
|
794
1204
|
|
|
795
1205
|
declare class EventsResource extends BaseResource {
|
|
@@ -855,6 +1265,13 @@ declare class MenusResource extends BaseResource {
|
|
|
855
1265
|
|
|
856
1266
|
declare class OrdersResource extends BaseResource {
|
|
857
1267
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
1268
|
+
/**
|
|
1269
|
+
* Most recent non-team order for the guest session, with captured
|
|
1270
|
+
* basket items + totals + declared returns inlined. `null` when the
|
|
1271
|
+
* session has no qualifying order yet (fresh session, or only team
|
|
1272
|
+
* orders which go through `teamOrders` instead).
|
|
1273
|
+
*/
|
|
1274
|
+
getLatest(sessionId: string): Promise<LatestOrder | null>;
|
|
858
1275
|
/**
|
|
859
1276
|
* Place a new order.
|
|
860
1277
|
*
|
|
@@ -873,6 +1290,12 @@ declare class OrdersResource extends BaseResource {
|
|
|
873
1290
|
* the order to 'paid' status.
|
|
874
1291
|
*/
|
|
875
1292
|
confirm(orderId: string, request: ConfirmOrderRequest): Promise<ConfirmOrderResponse>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Record an additional cash handover amount for a team-order participant
|
|
1295
|
+
* who has added items after their initial cash payment. No Stripe
|
|
1296
|
+
* interaction — this updates the handover total the Lead will collect.
|
|
1297
|
+
*/
|
|
1298
|
+
addCashDelta(request: AddCashDeltaRequest): Promise<AddCashDeltaResponse>;
|
|
876
1299
|
}
|
|
877
1300
|
|
|
878
1301
|
declare class PaymentIntentsResource extends BaseResource {
|
|
@@ -884,6 +1307,20 @@ declare class PaymentIntentsResource extends BaseResource {
|
|
|
884
1307
|
* for the draft order that was created.
|
|
885
1308
|
*/
|
|
886
1309
|
create(request: CreatePaymentIntentRequest): Promise<CreatePaymentIntentResponse>;
|
|
1310
|
+
/**
|
|
1311
|
+
* Create a delta PaymentIntent for a team-order participant who added
|
|
1312
|
+
* items after paying. Reuses the saved card from the initial auth so the
|
|
1313
|
+
* client only needs one tap (unless Stripe triggers 3DS).
|
|
1314
|
+
*/
|
|
1315
|
+
createDelta(request: CreateDeltaPaymentIntentRequest): Promise<CreateDeltaPaymentIntentResponse>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Release part of a team-order participant's existing Stripe authorisation
|
|
1318
|
+
* when they remove items from their basket. Walks payments newest-first,
|
|
1319
|
+
* cancelling fully-consumed PIs and `update({ amount })`-ing the last
|
|
1320
|
+
* partially-trimmed one. No client-side confirmation — lowering a
|
|
1321
|
+
* `requires_capture` PI's amount is a single server round-trip.
|
|
1322
|
+
*/
|
|
1323
|
+
reduceDelta(request: ReduceDeltaPaymentIntentRequest): Promise<ReduceDeltaPaymentIntentResponse>;
|
|
887
1324
|
}
|
|
888
1325
|
|
|
889
1326
|
declare class ReservationsResource extends BaseResource {
|
|
@@ -939,6 +1376,443 @@ declare class SubscriptionsResource extends BaseResource {
|
|
|
939
1376
|
getCredits(subscriptionIdOrAccessor: string, subscriberId: string, status?: SubscriptionCreditStatus): Promise<SubscriptionCredit[]>;
|
|
940
1377
|
}
|
|
941
1378
|
|
|
1379
|
+
/**
|
|
1380
|
+
* Runtime enum objects that mirror order3000's Drizzle `pgEnum` shape —
|
|
1381
|
+
* they carry an `enumValues` tuple. This lets SDK consumers write the exact
|
|
1382
|
+
* same `z.enum(paymentMethodEnum.enumValues)` expression they would write
|
|
1383
|
+
* against a real pgEnum, keeping one consistent pattern across the
|
|
1384
|
+
* codebase (order3000's server imports the actual pgEnum from
|
|
1385
|
+
* `@/drizzle/enums`; thamarai and other SDK consumers import these
|
|
1386
|
+
* shape-compatible objects from 'order3000').
|
|
1387
|
+
*
|
|
1388
|
+
* The tuples themselves must stay in sync with the matching pgEnum in
|
|
1389
|
+
* `apps/order3000/src/drizzle/enums.ts`. That's a manual mirror — the SDK
|
|
1390
|
+
* is a standalone package and can't import from the app's Drizzle schema.
|
|
1391
|
+
*/
|
|
1392
|
+
declare const paymentMethodEnum: {
|
|
1393
|
+
enumValues: readonly ["card", "cash", "voucher"];
|
|
1394
|
+
};
|
|
1395
|
+
declare const fulfillmentTypeEnum: {
|
|
1396
|
+
enumValues: readonly ["pickup", "delivery"];
|
|
1397
|
+
};
|
|
1398
|
+
declare const teamOrderStatusEnum: {
|
|
1399
|
+
enumValues: readonly ["draft", "collecting", "locked", "placed", "ready", "completed", "cancelled"];
|
|
1400
|
+
};
|
|
1401
|
+
declare const participantStatusEnum: {
|
|
1402
|
+
enumValues: readonly ["browsing", "authorized", "cash_pending", "placed", "completed", "cancelled"];
|
|
1403
|
+
};
|
|
1404
|
+
type PaymentMethod = (typeof paymentMethodEnum.enumValues)[number];
|
|
1405
|
+
type FulfillmentType = (typeof fulfillmentTypeEnum.enumValues)[number];
|
|
1406
|
+
type TeamOrderStatus = (typeof teamOrderStatusEnum.enumValues)[number];
|
|
1407
|
+
type ParticipantStatus = (typeof participantStatusEnum.enumValues)[number];
|
|
1408
|
+
interface TeamDeliveryAddress {
|
|
1409
|
+
street: string;
|
|
1410
|
+
city: string;
|
|
1411
|
+
state: string;
|
|
1412
|
+
postalCode: string;
|
|
1413
|
+
country: string;
|
|
1414
|
+
}
|
|
1415
|
+
interface CreateTeamOrderRequest {
|
|
1416
|
+
sessionId: string;
|
|
1417
|
+
menuId: string;
|
|
1418
|
+
leadDisplayName: string;
|
|
1419
|
+
teamName?: string;
|
|
1420
|
+
logoUrl?: string;
|
|
1421
|
+
/**
|
|
1422
|
+
* Optional ISO 8601 datetime. The Lead's "close the window" decision —
|
|
1423
|
+
* unset on FAST-share creation. When null, the team never auto-locks;
|
|
1424
|
+
* the Lead explicitly submits when ready.
|
|
1425
|
+
*/
|
|
1426
|
+
deadlineAt?: string | null;
|
|
1427
|
+
fulfillmentType: FulfillmentType;
|
|
1428
|
+
/**
|
|
1429
|
+
* Optional ISO 8601 datetime. The Lead's pickup-time decision — unset
|
|
1430
|
+
* at team creation, set later on the Lead's Fulfilment step. Backfilled
|
|
1431
|
+
* onto each child `orders.fulfillmentAt` when `submitTeamOrder` fires.
|
|
1432
|
+
*/
|
|
1433
|
+
fulfillmentAt?: string | null;
|
|
1434
|
+
deliveryAddress?: TeamDeliveryAddress;
|
|
1435
|
+
allowedPaymentMethods: PaymentMethod[];
|
|
1436
|
+
eventId?: string;
|
|
1437
|
+
}
|
|
1438
|
+
interface CreateTeamOrderResponse {
|
|
1439
|
+
publicId: string;
|
|
1440
|
+
teamOrderId: string;
|
|
1441
|
+
}
|
|
1442
|
+
interface TeamOrderBasketItemMenuItemRef {
|
|
1443
|
+
menuItemId: string;
|
|
1444
|
+
role: string | null;
|
|
1445
|
+
quantity: number;
|
|
1446
|
+
unit: 'grams' | 'kilograms' | 'liters' | 'milliliters' | 'pieces';
|
|
1447
|
+
}
|
|
1448
|
+
interface TeamOrderBasketItem {
|
|
1449
|
+
id: string;
|
|
1450
|
+
metadata: BasketItemMetadata | null;
|
|
1451
|
+
menuItems: TeamOrderBasketItemMenuItemRef[];
|
|
1452
|
+
/**
|
|
1453
|
+
* `true` when the item's cumulative price (folded across the
|
|
1454
|
+
* participant's basket items in `basket_items.created_at` order)
|
|
1455
|
+
* is fully covered by the participant's `paidTotal`. `false`
|
|
1456
|
+
* when the item is part of an outstanding delta — typically an
|
|
1457
|
+
* item the participant added after their last authorisation but
|
|
1458
|
+
* hasn't run a delta payment for yet. Drives the per-item
|
|
1459
|
+
* "Confirmed" vs "Pending" badge in the team-mode BasketReview;
|
|
1460
|
+
* the Lead therefore can't be tricked into submitting while a
|
|
1461
|
+
* teammate has unpaid items in their cart.
|
|
1462
|
+
*/
|
|
1463
|
+
isPaid: boolean;
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Active payment row surfaced for a participant. "Active" excludes voided
|
|
1467
|
+
* and failed rows — those never reach the client.
|
|
1468
|
+
*/
|
|
1469
|
+
type TeamOrderParticipantPaymentStatus = 'authorized' | 'captured' | 'cash_pending' | 'cash_received';
|
|
1470
|
+
interface TeamOrderParticipantPayment {
|
|
1471
|
+
amount: number;
|
|
1472
|
+
method: PaymentMethod;
|
|
1473
|
+
status: TeamOrderParticipantPaymentStatus;
|
|
1474
|
+
createdAt: string;
|
|
1475
|
+
/**
|
|
1476
|
+
* Last 4 digits of the card used for this card payment. Populated
|
|
1477
|
+
* lazily by `fetchTeamOrder` for the *current viewer's* card rows
|
|
1478
|
+
* only (one Stripe round-trip per render, then cached on the
|
|
1479
|
+
* `team_order_payments` row), so the delta-payment UI can render
|
|
1480
|
+
* `Card **** 4242` and tell the user which card will be charged
|
|
1481
|
+
* or refunded. `null` for cash rows or while the lookup hasn't
|
|
1482
|
+
* landed yet.
|
|
1483
|
+
*/
|
|
1484
|
+
cardLast4: string | null;
|
|
1485
|
+
}
|
|
1486
|
+
interface TeamOrderParticipant {
|
|
1487
|
+
customerId: string;
|
|
1488
|
+
basketId: string | null;
|
|
1489
|
+
orderId: string | null;
|
|
1490
|
+
/**
|
|
1491
|
+
* Consecutive, never-reused join-order number. 1 for the lead; 2, 3, ...
|
|
1492
|
+
* for joiners in arrival order. Clients fall back to `Person {n}` when
|
|
1493
|
+
* `displayName` is null. Stays stable even if an earlier participant is
|
|
1494
|
+
* later dropped — numbers are not recycled.
|
|
1495
|
+
*/
|
|
1496
|
+
participantNumber: number | null;
|
|
1497
|
+
displayName: string | null;
|
|
1498
|
+
status: ParticipantStatus;
|
|
1499
|
+
bundleCount: number;
|
|
1500
|
+
amount: number;
|
|
1501
|
+
paymentMethod: PaymentMethod | null;
|
|
1502
|
+
isLead: boolean;
|
|
1503
|
+
/** True when this participant is the current caller (session match). */
|
|
1504
|
+
isMe: boolean;
|
|
1505
|
+
joinedAt: string;
|
|
1506
|
+
/**
|
|
1507
|
+
* Participant's current basket contents in SDK format (identical to what
|
|
1508
|
+
* `baskets.get` returns). The thamarai client feeds these straight into
|
|
1509
|
+
* its existing `hydrateBasket` → `transformBasketItem` transform.
|
|
1510
|
+
*/
|
|
1511
|
+
items: TeamOrderBasketItem[];
|
|
1512
|
+
/**
|
|
1513
|
+
* Per-participant payment trail — one row per auth (initial + each delta
|
|
1514
|
+
* round). Empty until the participant has checked out.
|
|
1515
|
+
*/
|
|
1516
|
+
payments: TeamOrderParticipantPayment[];
|
|
1517
|
+
/** Sum of `payments[].amount` (authorised/collected total). */
|
|
1518
|
+
paidTotal: number;
|
|
1519
|
+
/** `amount` − `paidTotal`, floored at 0. Positive = delta owed. */
|
|
1520
|
+
amountDue: number;
|
|
1521
|
+
/**
|
|
1522
|
+
* Server-persisted declared-return counts per depositware template,
|
|
1523
|
+
* captured the last time the participant authorised payment (or
|
|
1524
|
+
* resubmitted via a delta). Empty until they've checked out — and
|
|
1525
|
+
* always reflects what the server actually has on file (i.e.
|
|
1526
|
+
* `orderDeposits.declaredReturningCount`).
|
|
1527
|
+
*
|
|
1528
|
+
* Clients use this to hydrate the local "I'm returning N empties"
|
|
1529
|
+
* UI on refresh: without it, the local Zustand store starts empty,
|
|
1530
|
+
* so `useBasketTotals` recomputes `effectiveTotal` *without* the
|
|
1531
|
+
* deposit credit that was actually applied at auth time, causing
|
|
1532
|
+
* the delta-payment view to incorrectly demand or refund money.
|
|
1533
|
+
*/
|
|
1534
|
+
declaredReturns: Array<{
|
|
1535
|
+
depositwareTemplateId: string;
|
|
1536
|
+
count: number;
|
|
1537
|
+
}>;
|
|
1538
|
+
/**
|
|
1539
|
+
* ISO timestamp the team Lead checked off this participant on
|
|
1540
|
+
* their post-placement settle-up checklist — a private "this
|
|
1541
|
+
* person has handed over what they owe me" tick. `null` while
|
|
1542
|
+
* unchecked. Lead-private; consumer-side rendering decides
|
|
1543
|
+
* whether to surface it.
|
|
1544
|
+
*/
|
|
1545
|
+
leadSettledAt: string | null;
|
|
1546
|
+
}
|
|
1547
|
+
interface ThresholdCheck {
|
|
1548
|
+
meets: boolean;
|
|
1549
|
+
failedConstraints: Array<'quantity' | 'amount'>;
|
|
1550
|
+
requiredQuantity: number | null;
|
|
1551
|
+
currentQuantity: number;
|
|
1552
|
+
requiredAmount: number | null;
|
|
1553
|
+
currentAmount: number;
|
|
1554
|
+
}
|
|
1555
|
+
interface FetchTeamOrderResponse {
|
|
1556
|
+
teamOrder: {
|
|
1557
|
+
id: string;
|
|
1558
|
+
publicId: string;
|
|
1559
|
+
venueId: string;
|
|
1560
|
+
menuId: string;
|
|
1561
|
+
eventId: string | null;
|
|
1562
|
+
teamName: string | null;
|
|
1563
|
+
logoUrl: string | null;
|
|
1564
|
+
leadDisplayName: string;
|
|
1565
|
+
status: TeamOrderStatus;
|
|
1566
|
+
allowedPaymentMethods: PaymentMethod[];
|
|
1567
|
+
fulfillmentType: FulfillmentType;
|
|
1568
|
+
fulfillmentAt: string | null;
|
|
1569
|
+
deadlineAt: string | null;
|
|
1570
|
+
lockedAt: string | null;
|
|
1571
|
+
placedAt: string | null;
|
|
1572
|
+
cancelledAt: string | null;
|
|
1573
|
+
/**
|
|
1574
|
+
* Free-text reason the Lead provided when dissolving the team order.
|
|
1575
|
+
* Surfaced to non-Lead participants via the `cancelledByLeadToast`
|
|
1576
|
+
* broadcast so they see context alongside the cancellation event.
|
|
1577
|
+
*/
|
|
1578
|
+
cancelReason: string | null;
|
|
1579
|
+
deliveryAddressId: string | null;
|
|
1580
|
+
/**
|
|
1581
|
+
* Free-form text the Lead types on the Fulfilment step describing
|
|
1582
|
+
* where the team will sit down to eat (e.g. "Kitchen K3, Building X").
|
|
1583
|
+
* `null` until the Lead enters a value.
|
|
1584
|
+
*/
|
|
1585
|
+
diningLocation: string | null;
|
|
1586
|
+
/**
|
|
1587
|
+
* HH:MM time (venue timezone) at which the team starts eating.
|
|
1588
|
+
* Derived server-side from `fulfillmentAt + effectiveOffset` where
|
|
1589
|
+
* `effectiveOffset = dining_offset_minutes ?? 15`. `null` only when
|
|
1590
|
+
* `fulfillmentAt` hasn't been set yet.
|
|
1591
|
+
*/
|
|
1592
|
+
diningTime: string | null;
|
|
1593
|
+
/**
|
|
1594
|
+
* Whether the team's menu is configured for delivery fulfillment.
|
|
1595
|
+
* Snapshotted from `menus.metadata.isDeliveryEnabled` at fetch time.
|
|
1596
|
+
* Clients use this to gate the Lead's "Switch to delivery" control.
|
|
1597
|
+
*/
|
|
1598
|
+
isDeliveryEnabled: boolean;
|
|
1599
|
+
/**
|
|
1600
|
+
* Cycling 100→999 short reference, repurposed from the Lead's own
|
|
1601
|
+
* `orders.quickReferenceNumber` so the team has exactly one number
|
|
1602
|
+
* — the same number printed on the consolidated kitchen receipt
|
|
1603
|
+
* and surfaced in the customer's Abwicklung view. `null` until the
|
|
1604
|
+
* Lead has authorised payment (the Lead's order row is created at
|
|
1605
|
+
* PaymentIntent time, which is when the quickRef is assigned).
|
|
1606
|
+
*/
|
|
1607
|
+
quickReferenceNumber: number | null;
|
|
1608
|
+
};
|
|
1609
|
+
deliveryThreshold: {
|
|
1610
|
+
amount: number | null;
|
|
1611
|
+
quantity: number | null;
|
|
1612
|
+
};
|
|
1613
|
+
participants: TeamOrderParticipant[];
|
|
1614
|
+
aggregatedTotals: {
|
|
1615
|
+
confirmedBundleCount: number;
|
|
1616
|
+
confirmedAmount: number;
|
|
1617
|
+
totalBundleCount: number;
|
|
1618
|
+
};
|
|
1619
|
+
thresholdCheck: ThresholdCheck;
|
|
1620
|
+
isLead: boolean;
|
|
1621
|
+
}
|
|
1622
|
+
interface JoinTeamOrderRequest {
|
|
1623
|
+
sessionId: string;
|
|
1624
|
+
displayName?: string;
|
|
1625
|
+
}
|
|
1626
|
+
interface JoinTeamOrderResponse {
|
|
1627
|
+
teamOrderId: string;
|
|
1628
|
+
basketId: string;
|
|
1629
|
+
customerId: string;
|
|
1630
|
+
status: TeamOrderStatus;
|
|
1631
|
+
isLead: boolean;
|
|
1632
|
+
alreadyJoined: boolean;
|
|
1633
|
+
}
|
|
1634
|
+
interface SubmitTeamOrderResponse {
|
|
1635
|
+
teamOrderId: string;
|
|
1636
|
+
status: TeamOrderStatus;
|
|
1637
|
+
capturedOrderIds: string[];
|
|
1638
|
+
cashPendingOrderIds: string[];
|
|
1639
|
+
droppedBasketIds: string[];
|
|
1640
|
+
placedAt: string;
|
|
1641
|
+
}
|
|
1642
|
+
interface CancelTeamOrderResponse {
|
|
1643
|
+
teamOrderId: string;
|
|
1644
|
+
status: TeamOrderStatus;
|
|
1645
|
+
voidedPaymentIntentIds: string[];
|
|
1646
|
+
cancelledAt: string;
|
|
1647
|
+
}
|
|
1648
|
+
interface ExtendDeadlineResponse {
|
|
1649
|
+
teamOrderId: string;
|
|
1650
|
+
status: TeamOrderStatus;
|
|
1651
|
+
deadlineAt: string | null;
|
|
1652
|
+
}
|
|
1653
|
+
interface SwitchFulfillmentResponse {
|
|
1654
|
+
teamOrderId: string;
|
|
1655
|
+
status: TeamOrderStatus;
|
|
1656
|
+
fulfillmentType: FulfillmentType;
|
|
1657
|
+
deliveryAddressId: string | null;
|
|
1658
|
+
}
|
|
1659
|
+
interface UpdateDeliveryAddressResponse {
|
|
1660
|
+
teamOrderId: string;
|
|
1661
|
+
deliveryAddressId: string;
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Team Orders SDK resource.
|
|
1665
|
+
*
|
|
1666
|
+
* Mixes venue-scoped and publicId-scoped endpoints, so it doesn't inherit
|
|
1667
|
+
* from BaseResource (which hard-codes /venues/{venueId}). Create goes to
|
|
1668
|
+
* `/venues/{venueId}/team-orders`; everything else targets
|
|
1669
|
+
* `/team-orders/{publicId}/...` because publicId is globally unique and the
|
|
1670
|
+
* venue is resolved server-side via a helper.
|
|
1671
|
+
*/
|
|
1672
|
+
declare class TeamOrdersResource {
|
|
1673
|
+
private readonly tokenManager;
|
|
1674
|
+
private readonly baseUrl;
|
|
1675
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
1676
|
+
private request;
|
|
1677
|
+
/**
|
|
1678
|
+
* Lead creates a team order from their active basket.
|
|
1679
|
+
* Returns the unguessable `publicId` the lead shares with coworkers.
|
|
1680
|
+
*/
|
|
1681
|
+
create(request: CreateTeamOrderRequest): Promise<CreateTeamOrderResponse>;
|
|
1682
|
+
/**
|
|
1683
|
+
* Public read by publicId. Pass the caller's sessionId so the response
|
|
1684
|
+
* can set `isLead` correctly for UI gating.
|
|
1685
|
+
*/
|
|
1686
|
+
get(publicId: string, sessionId?: string): Promise<FetchTeamOrderResponse>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Participant joins a team order. Idempotent: safe to call on every page
|
|
1689
|
+
* mount of the shared URL.
|
|
1690
|
+
*/
|
|
1691
|
+
join(publicId: string, request: JoinTeamOrderRequest): Promise<JoinTeamOrderResponse>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Lead submits the team order. Drops basket-only participants, captures
|
|
1694
|
+
* every authorised Stripe PaymentIntent atomically, flips child orders to
|
|
1695
|
+
* `pending`. The "Submit anyways" UX is a client-side confirmation dialog
|
|
1696
|
+
* that calls the same endpoint — no server variant exists.
|
|
1697
|
+
*/
|
|
1698
|
+
submit(publicId: string, request: {
|
|
1699
|
+
sessionId: string;
|
|
1700
|
+
}): Promise<SubmitTeamOrderResponse>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Lead cancels pre-placement. Voids every authorised Stripe
|
|
1703
|
+
* PaymentIntent (no refunds needed — nothing was captured).
|
|
1704
|
+
*/
|
|
1705
|
+
cancel(publicId: string, request: {
|
|
1706
|
+
sessionId: string;
|
|
1707
|
+
reason?: string;
|
|
1708
|
+
}): Promise<CancelTeamOrderResponse>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Lead pushes the deadline. A `locked` team flips back to `collecting`
|
|
1711
|
+
* when the new deadline is in the future.
|
|
1712
|
+
*/
|
|
1713
|
+
extendDeadline(publicId: string, request: {
|
|
1714
|
+
sessionId: string;
|
|
1715
|
+
newDeadlineAt: string;
|
|
1716
|
+
}): Promise<ExtendDeadlineResponse>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Lead commits (or changes) the shared pickup/delivery time. Required
|
|
1719
|
+
* before `submit` — which backfills each child order's `fulfillmentAt`
|
|
1720
|
+
* from this value at capture time.
|
|
1721
|
+
*/
|
|
1722
|
+
setFulfillmentAt(publicId: string, request: {
|
|
1723
|
+
sessionId: string;
|
|
1724
|
+
fulfillmentAt: string;
|
|
1725
|
+
}): Promise<{
|
|
1726
|
+
teamOrderId: string;
|
|
1727
|
+
status: TeamOrderStatus;
|
|
1728
|
+
fulfillmentAt: string;
|
|
1729
|
+
/**
|
|
1730
|
+
* Returned so callers can re-sync the deadline wheel — the server
|
|
1731
|
+
* clamps `deadlineAt` down to the new `fulfillmentAt` whenever the
|
|
1732
|
+
* old deadline would have sat past it.
|
|
1733
|
+
*/
|
|
1734
|
+
deadlineAt: string | null;
|
|
1735
|
+
}>;
|
|
1736
|
+
/**
|
|
1737
|
+
* Lead sets the free-form "where we'll eat" text on the team order.
|
|
1738
|
+
* Broadcast to participants via the standard realtime refetch path.
|
|
1739
|
+
*/
|
|
1740
|
+
setDiningLocation(publicId: string, request: {
|
|
1741
|
+
sessionId: string;
|
|
1742
|
+
diningLocation: string;
|
|
1743
|
+
}): Promise<{
|
|
1744
|
+
teamOrderId: string;
|
|
1745
|
+
status: TeamOrderStatus;
|
|
1746
|
+
diningLocation: string | null;
|
|
1747
|
+
}>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Lead sets when the team will start eating. Client sends HH:MM; server
|
|
1750
|
+
* computes the delta against `fulfillmentAt` and stores it as
|
|
1751
|
+
* `dining_offset_minutes` so the intent survives any later pickup change.
|
|
1752
|
+
*/
|
|
1753
|
+
setDiningTime(publicId: string, request: {
|
|
1754
|
+
sessionId: string;
|
|
1755
|
+
diningTime: string;
|
|
1756
|
+
}): Promise<{
|
|
1757
|
+
teamOrderId: string;
|
|
1758
|
+
status: TeamOrderStatus;
|
|
1759
|
+
diningTime: string;
|
|
1760
|
+
diningOffsetMinutes: number;
|
|
1761
|
+
}>;
|
|
1762
|
+
/**
|
|
1763
|
+
* Toggle a participant's "settled" tick on the team Lead's
|
|
1764
|
+
* post-placement settle-up checklist. Writes to
|
|
1765
|
+
* `orders.leadSettledAt` — sets it to `NOW()` when `settled` is
|
|
1766
|
+
* `true`, clears it back to `null` when `false`.
|
|
1767
|
+
*
|
|
1768
|
+
* Authorized only for the team Lead's session — server rejects
|
|
1769
|
+
* non-Lead callers and `orderId`s that don't belong to this team.
|
|
1770
|
+
*/
|
|
1771
|
+
setOrderLeadSettled(publicId: string, request: {
|
|
1772
|
+
sessionId: string;
|
|
1773
|
+
orderId: string;
|
|
1774
|
+
settled: boolean;
|
|
1775
|
+
}): Promise<{
|
|
1776
|
+
orderId: string;
|
|
1777
|
+
leadSettledAt: string | null;
|
|
1778
|
+
}>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Any participant proposes an auto-extend when their local clock sees
|
|
1781
|
+
* that `fulfillmentAt` has passed while the team order is still
|
|
1782
|
+
* collecting. Idempotent on the server side: concurrent callers race
|
|
1783
|
+
* but only one write lands.
|
|
1784
|
+
*/
|
|
1785
|
+
autoExtendFulfillmentIfExpired(publicId: string, request: {
|
|
1786
|
+
sessionId: string;
|
|
1787
|
+
proposedFulfillmentAt: string;
|
|
1788
|
+
}): Promise<{
|
|
1789
|
+
extended: boolean;
|
|
1790
|
+
teamOrderId: string;
|
|
1791
|
+
status: TeamOrderStatus;
|
|
1792
|
+
fulfillmentAt: string;
|
|
1793
|
+
deadlineAt: string | null;
|
|
1794
|
+
previousFulfillmentAt: string;
|
|
1795
|
+
waitingCount: number;
|
|
1796
|
+
}>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Lead flips pickup ↔ delivery. Pass `deliveryAddress` when switching
|
|
1799
|
+
* TO delivery if no address is already set on the team order.
|
|
1800
|
+
*/
|
|
1801
|
+
switchFulfillment(publicId: string, request: {
|
|
1802
|
+
sessionId: string;
|
|
1803
|
+
fulfillmentType: FulfillmentType;
|
|
1804
|
+
deliveryAddress?: TeamDeliveryAddress;
|
|
1805
|
+
}): Promise<SwitchFulfillmentResponse>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Lead replaces the delivery address (inserts a new row in the shared
|
|
1808
|
+
* addresses table with type='PHYSICAL' and links it to the team order).
|
|
1809
|
+
*/
|
|
1810
|
+
updateDeliveryAddress(publicId: string, request: {
|
|
1811
|
+
sessionId: string;
|
|
1812
|
+
deliveryAddress: TeamDeliveryAddress;
|
|
1813
|
+
}): Promise<UpdateDeliveryAddressResponse>;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
942
1816
|
type RealtimeEvent = 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
943
1817
|
type RealtimeRow = {
|
|
944
1818
|
[key: string]: any;
|
|
@@ -1097,6 +1971,7 @@ interface Order3000ClientConfig {
|
|
|
1097
1971
|
tokenUrl?: string;
|
|
1098
1972
|
}
|
|
1099
1973
|
declare class Order3000Client {
|
|
1974
|
+
areas: AreasResource;
|
|
1100
1975
|
baskets: BasketsResource;
|
|
1101
1976
|
events: EventsResource;
|
|
1102
1977
|
menus: MenusResource;
|
|
@@ -1104,11 +1979,12 @@ declare class Order3000Client {
|
|
|
1104
1979
|
paymentIntents: PaymentIntentsResource;
|
|
1105
1980
|
reservations: ReservationsResource;
|
|
1106
1981
|
subscriptions: SubscriptionsResource;
|
|
1982
|
+
teamOrders: TeamOrdersResource;
|
|
1107
1983
|
realtime: RealtimeManager;
|
|
1108
1984
|
private readonly baseUrl;
|
|
1109
1985
|
private readonly tokenManager;
|
|
1110
1986
|
constructor(config: Order3000ClientConfig);
|
|
1111
1987
|
}
|
|
1112
1988
|
|
|
1113
|
-
export { Order3000Client, getScheduleInfo };
|
|
1114
|
-
export type { AddToBasketRequest, AddToBasketResponse, Basket, BasketItem, BasketItemMenuItemRef, BasketItemMetadata, BasketStatus, ConfirmOrderRequest, ConfirmOrderResponse, CreatePaymentIntentRequest, CreatePaymentIntentResponse, CropArea, Currency, DayOfWeek, Event, EventByAccessor, EventMenu, EventPoster, EventRow, GetEventOptions, GetMenuOptions, ListEventsOptions, ListEventsResponse, Menu, MenuAsset, MenuBeverage, MenuBundle, MenuBundleDeposit, MenuDish, MenuItem, MenuItemRow, MenuItemType, MenuSubscription, MenuSubscriptionPoster, Order3000ClientConfig, OrderFulfillmentType, PlaceOrderRequest, Promotion, RealtimeConfig, RealtimeEvent, RealtimeSubscription, RemoveFromBasketResponse, Schedule, ScheduleInfo, ScheduleOverride, ScheduleOverrideRow, ScheduleRow, ScheduleTimeSlot, ScheduleWithTimeSlots, SubscribeRequest, SubscribeResponse, SubscriberStatus, SubscriptionCredit, SubscriptionCreditStatus, SubscriptionOptions, SubscriptionPeriod, TimeSlot, Unit };
|
|
1989
|
+
export { Order3000Client, fulfillmentTypeEnum, getScheduleInfo, participantStatusEnum, paymentMethodEnum, teamOrderStatusEnum };
|
|
1990
|
+
export type { AddCashDeltaRequest, AddCashDeltaResponse, AddToBasketRequest, AddToBasketResponse, Area, AreaAsset, AreaAvailabilityResponse, AreaAvailabilityWindow, AreaBookingMode, AreaBookingRequestResponse, AreaBookingRequestSource, AreaBookingRequestStatus, AreaBookingStatus, AreaFeature, Basket, BasketItem, BasketItemDeposit, BasketItemMenuItemRef, BasketItemMetadata, BasketStatus, BasketTotals, CancelTeamOrderResponse, ConfirmOrderRequest, ConfirmOrderResponse, CreateDeltaPaymentIntentRequest, CreateDeltaPaymentIntentResponse, CreatePaymentIntentRequest, CreatePaymentIntentResponse, CreateTeamOrderRequest, CreateTeamOrderResponse, CropArea, Currency, DayOfWeek, DeclaredReturn, Event, EventByAccessor, EventMenu, EventPoster, EventRow, ExtendDeadlineResponse as ExtendTeamOrderDeadlineResponse, FetchTeamOrderResponse, GetAreaAvailabilityOptions, GetAreaOptions, GetEventOptions, GetMenuOptions, JoinTeamOrderRequest, JoinTeamOrderResponse, LatestOrder, ListEventsOptions, ListEventsResponse, Menu, MenuAsset, MenuBeverage, MenuBundle, MenuBundleDeposit, MenuDish, MenuItem, MenuItemRow, MenuItemType, MenuSubscription, MenuSubscriptionPoster, Order3000ClientConfig, OrderFulfillmentType, OrderStatus, PaymentStatus, PlaceOrderRequest, Promotion, RealtimeConfig, RealtimeEvent, RealtimeSubscription, RemoveFromBasketResponse, Schedule, ScheduleInfo, ScheduleOverride, ScheduleOverrideRow, ScheduleRow, ScheduleTimeSlot, ScheduleWithTimeSlots, SubmitAreaBookingRequestPayload, SubmitTeamOrderResponse, SubscribeRequest, SubscribeResponse, SubscriberStatus, SubscriptionCredit, SubscriptionCreditStatus, SubscriptionOptions, SubscriptionPeriod, SwitchFulfillmentResponse as SwitchTeamOrderFulfillmentResponse, TeamDeliveryAddress, TeamOrderBasketItem, TeamOrderBasketItemMenuItemRef, FulfillmentType as TeamOrderFulfillmentType, TeamOrderParticipant, ParticipantStatus as TeamOrderParticipantStatus, PaymentMethod as TeamOrderPaymentMethod, TeamOrderStatus, ThresholdCheck as TeamOrderThresholdCheck, TimeSlot, Unit, UpdateDeliveryAddressResponse as UpdateTeamOrderDeliveryAddressResponse };
|