order3000 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/client.cjs +46 -0
- package/dist/client.d.cts +100 -4
- package/dist/client.d.mts +100 -4
- package/dist/client.mjs +46 -0
- package/package.json +5 -4
package/dist/client.cjs
CHANGED
|
@@ -255,6 +255,14 @@ class MenusResource extends BaseResource {
|
|
|
255
255
|
const queryString = this.buildQueryString(options);
|
|
256
256
|
return this.request("GET", `/${accessor}${queryString}`);
|
|
257
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Get all bundles for a menu
|
|
260
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
261
|
+
* @returns Array of menu bundles
|
|
262
|
+
*/
|
|
263
|
+
async getBundles(menuIdOrAccessor) {
|
|
264
|
+
return this.request("GET", `/${menuIdOrAccessor}/bundles`);
|
|
265
|
+
}
|
|
258
266
|
buildQueryString(options) {
|
|
259
267
|
if (!options?.expand?.length) return "";
|
|
260
268
|
return `?expand=${options.expand.join(",")}`;
|
|
@@ -265,12 +273,45 @@ class OrdersResource extends BaseResource {
|
|
|
265
273
|
constructor(tokenManager, baseUrl) {
|
|
266
274
|
super(tokenManager, baseUrl, "/orders");
|
|
267
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Place a new order.
|
|
278
|
+
*
|
|
279
|
+
* The order3000 backend calculates taxAmount and totalAmount from the basket items:
|
|
280
|
+
* - totalAmount: derived from basket items' prices (bundleId -> price)
|
|
281
|
+
* - taxAmount: derived from basket items' tax rates (bundleId -> taxRateId -> rate)
|
|
282
|
+
*
|
|
283
|
+
* SDK callers cannot provide these values - they're implicit from the basket contents.
|
|
284
|
+
*/
|
|
268
285
|
async place(order) {
|
|
269
286
|
return this.request("POST", "", order);
|
|
270
287
|
}
|
|
271
288
|
async get(orderId) {
|
|
272
289
|
return this.request("GET", `/${orderId}`);
|
|
273
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Confirm an order after client-side Stripe payment has succeeded.
|
|
293
|
+
*
|
|
294
|
+
* Verifies the PaymentIntent status with Stripe and transitions
|
|
295
|
+
* the order to 'paid' status.
|
|
296
|
+
*/
|
|
297
|
+
async confirm(orderId, request) {
|
|
298
|
+
return this.request("POST", `/${orderId}/confirm`, request);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
class PaymentIntentsResource extends BaseResource {
|
|
303
|
+
constructor(tokenManager, baseUrl) {
|
|
304
|
+
super(tokenManager, baseUrl, "/payment-intents");
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Create a Stripe PaymentIntent via order3000's Stripe Connect integration.
|
|
308
|
+
*
|
|
309
|
+
* Returns a clientSecret for client-side payment confirmation and an orderId
|
|
310
|
+
* for the draft order that was created.
|
|
311
|
+
*/
|
|
312
|
+
async create(request) {
|
|
313
|
+
return this.request("POST", "", request);
|
|
314
|
+
}
|
|
274
315
|
}
|
|
275
316
|
|
|
276
317
|
class ReservationsResource extends BaseResource {
|
|
@@ -623,6 +664,7 @@ class Order3000Client {
|
|
|
623
664
|
__publicField(this, "events");
|
|
624
665
|
__publicField(this, "menus");
|
|
625
666
|
__publicField(this, "orders");
|
|
667
|
+
__publicField(this, "paymentIntents");
|
|
626
668
|
__publicField(this, "reservations");
|
|
627
669
|
__publicField(this, "realtime");
|
|
628
670
|
__publicField(this, "baseUrl");
|
|
@@ -639,6 +681,10 @@ class Order3000Client {
|
|
|
639
681
|
this.events = new EventsResource(this.tokenManager, this.baseUrl);
|
|
640
682
|
this.menus = new MenusResource(this.tokenManager, this.baseUrl);
|
|
641
683
|
this.orders = new OrdersResource(this.tokenManager, this.baseUrl);
|
|
684
|
+
this.paymentIntents = new PaymentIntentsResource(
|
|
685
|
+
this.tokenManager,
|
|
686
|
+
this.baseUrl
|
|
687
|
+
);
|
|
642
688
|
this.reservations = new ReservationsResource(
|
|
643
689
|
this.tokenManager,
|
|
644
690
|
this.baseUrl
|
package/dist/client.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CurrencyCode } from '@kolaveri/money';
|
|
1
2
|
import { RealtimePostgresChangesPayload, RealtimeChannel, SupabaseClient } from '@supabase/supabase-js';
|
|
2
3
|
|
|
3
4
|
declare class TokenManager {
|
|
@@ -67,6 +68,7 @@ interface components {
|
|
|
67
68
|
intervalMinutes?: number | null;
|
|
68
69
|
durationMinutes?: number | null;
|
|
69
70
|
} | null;
|
|
71
|
+
venueAccessor: string;
|
|
70
72
|
};
|
|
71
73
|
/**
|
|
72
74
|
* CreateEventResponse
|
|
@@ -108,6 +110,8 @@ interface components {
|
|
|
108
110
|
id?: string;
|
|
109
111
|
venueId: string;
|
|
110
112
|
basketId: string;
|
|
113
|
+
publicId?: string | null;
|
|
114
|
+
quickReferenceNumber?: number | null;
|
|
111
115
|
/** @enum {string} */
|
|
112
116
|
status?: "draft" | "pending" | "paid" | "fulfilled" | "cancelled" | "refunded";
|
|
113
117
|
paymentIntentId?: string | null;
|
|
@@ -117,6 +121,9 @@ interface components {
|
|
|
117
121
|
totalAmount: number;
|
|
118
122
|
/** @enum {string} */
|
|
119
123
|
currency?: "EUR" | "CHF";
|
|
124
|
+
/** @enum {string|null} */
|
|
125
|
+
fulfillmentType?: "pickup" | "delivery" | null;
|
|
126
|
+
fulfillmentAt?: unknown;
|
|
120
127
|
orderedAt?: unknown;
|
|
121
128
|
orderedBy: string;
|
|
122
129
|
updatedAt?: unknown;
|
|
@@ -127,6 +134,8 @@ interface components {
|
|
|
127
134
|
id: string;
|
|
128
135
|
venueId: string;
|
|
129
136
|
basketId: string;
|
|
137
|
+
publicId: string | null;
|
|
138
|
+
quickReferenceNumber: number | null;
|
|
130
139
|
/** @enum {string} */
|
|
131
140
|
status: "draft" | "pending" | "paid" | "fulfilled" | "cancelled" | "refunded";
|
|
132
141
|
paymentIntentId: string | null;
|
|
@@ -136,6 +145,9 @@ interface components {
|
|
|
136
145
|
totalAmount: number;
|
|
137
146
|
/** @enum {string} */
|
|
138
147
|
currency: "EUR" | "CHF";
|
|
148
|
+
/** @enum {string|null} */
|
|
149
|
+
fulfillmentType: "pickup" | "delivery" | null;
|
|
150
|
+
fulfillmentAt: unknown;
|
|
139
151
|
orderedAt: unknown;
|
|
140
152
|
orderedBy: string;
|
|
141
153
|
updatedAt: unknown;
|
|
@@ -189,6 +201,7 @@ interface components {
|
|
|
189
201
|
specialRequests: string | null;
|
|
190
202
|
/** @description Preferred seating area or table type (e.g., "window seat", "quiet area", "patio") */
|
|
191
203
|
tablePreference: string | null;
|
|
204
|
+
venueAccessor: string;
|
|
192
205
|
};
|
|
193
206
|
/**
|
|
194
207
|
* MakeReservationResponse
|
|
@@ -289,7 +302,17 @@ interface components {
|
|
|
289
302
|
type schemas = components['schemas'];
|
|
290
303
|
type CreateEventRequest = schemas['CreateEventRequest'];
|
|
291
304
|
type CreateEventResponse = schemas['CreateEventResponse'];
|
|
292
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Order fulfillment type - matches order_fulfillment_type enum in order3000 database.
|
|
307
|
+
* Keep in sync with apps/order3000/src/drizzle/enums.ts
|
|
308
|
+
*/
|
|
309
|
+
type OrderFulfillmentType = 'pickup' | 'delivery';
|
|
310
|
+
type PlaceOrderRequest = Omit<schemas['PlaceOrderRequest'], 'taxAmount' | 'totalAmount'> & {
|
|
311
|
+
/** Fulfillment type for the order (pickup or delivery) */
|
|
312
|
+
fulfillmentType?: OrderFulfillmentType;
|
|
313
|
+
/** When the order should be fulfilled (pickup/delivery time) */
|
|
314
|
+
fulfillmentAt?: Date;
|
|
315
|
+
};
|
|
293
316
|
type PlaceOrderResponse = schemas['PlaceOrderResponse'];
|
|
294
317
|
type MakeReservationRequest = schemas['MakeReservationRequest'];
|
|
295
318
|
type MakeReservationResponse = schemas['MakeReservationResponse'];
|
|
@@ -458,7 +481,8 @@ interface MenuItem {
|
|
|
458
481
|
id: string;
|
|
459
482
|
type: MenuItemType;
|
|
460
483
|
tags: string[] | null;
|
|
461
|
-
price
|
|
484
|
+
/** Price adjustment in cents (adds to bundle base price) */
|
|
485
|
+
priceAdjustment: number;
|
|
462
486
|
currency: string;
|
|
463
487
|
isActive: boolean;
|
|
464
488
|
sortIndex: string | null;
|
|
@@ -477,6 +501,24 @@ interface GetMenuOptions {
|
|
|
477
501
|
/** Expand related resources (items, assets) */
|
|
478
502
|
expand?: ('items' | 'assets')[];
|
|
479
503
|
}
|
|
504
|
+
interface MenuBundleDeposit {
|
|
505
|
+
name: Record<string, string>;
|
|
506
|
+
amount: number;
|
|
507
|
+
currency: CurrencyCode;
|
|
508
|
+
}
|
|
509
|
+
interface MenuBundle {
|
|
510
|
+
id: string;
|
|
511
|
+
menuId: string;
|
|
512
|
+
name: Record<string, string>;
|
|
513
|
+
description: Record<string, string> | null;
|
|
514
|
+
tags: string[];
|
|
515
|
+
price: number;
|
|
516
|
+
currency: CurrencyCode;
|
|
517
|
+
taxRateId: string;
|
|
518
|
+
isActive: boolean;
|
|
519
|
+
sortIndex: string | null;
|
|
520
|
+
deposit: MenuBundleDeposit | null;
|
|
521
|
+
}
|
|
480
522
|
interface ScheduleTimeSlot {
|
|
481
523
|
dayOfWeek: DayOfWeek | null;
|
|
482
524
|
timeSlot: {
|
|
@@ -601,6 +643,26 @@ interface RemoveFromBasketResponse {
|
|
|
601
643
|
basketItemId: string;
|
|
602
644
|
itemCount: number;
|
|
603
645
|
}
|
|
646
|
+
interface CreatePaymentIntentRequest {
|
|
647
|
+
basketId: string;
|
|
648
|
+
currency: Currency;
|
|
649
|
+
sessionId: string;
|
|
650
|
+
fulfillmentType?: OrderFulfillmentType;
|
|
651
|
+
fulfillmentTime?: string;
|
|
652
|
+
}
|
|
653
|
+
interface CreatePaymentIntentResponse {
|
|
654
|
+
clientSecret: string;
|
|
655
|
+
paymentIntentId: string;
|
|
656
|
+
orderId: string;
|
|
657
|
+
}
|
|
658
|
+
interface ConfirmOrderRequest {
|
|
659
|
+
paymentIntentId: string;
|
|
660
|
+
}
|
|
661
|
+
interface ConfirmOrderResponse {
|
|
662
|
+
id: string;
|
|
663
|
+
status: string;
|
|
664
|
+
publicId: string | null;
|
|
665
|
+
}
|
|
604
666
|
|
|
605
667
|
declare class BasketsResource extends BaseResource {
|
|
606
668
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
@@ -676,13 +738,46 @@ declare class MenusResource extends BaseResource {
|
|
|
676
738
|
* @returns The menu with optional items and assets
|
|
677
739
|
*/
|
|
678
740
|
getByAccessor(accessor: string, options?: GetMenuOptions): Promise<Menu>;
|
|
741
|
+
/**
|
|
742
|
+
* Get all bundles for a menu
|
|
743
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
744
|
+
* @returns Array of menu bundles
|
|
745
|
+
*/
|
|
746
|
+
getBundles(menuIdOrAccessor: string): Promise<MenuBundle[]>;
|
|
679
747
|
private buildQueryString;
|
|
680
748
|
}
|
|
681
749
|
|
|
682
750
|
declare class OrdersResource extends BaseResource {
|
|
683
751
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
752
|
+
/**
|
|
753
|
+
* Place a new order.
|
|
754
|
+
*
|
|
755
|
+
* The order3000 backend calculates taxAmount and totalAmount from the basket items:
|
|
756
|
+
* - totalAmount: derived from basket items' prices (bundleId -> price)
|
|
757
|
+
* - taxAmount: derived from basket items' tax rates (bundleId -> taxRateId -> rate)
|
|
758
|
+
*
|
|
759
|
+
* SDK callers cannot provide these values - they're implicit from the basket contents.
|
|
760
|
+
*/
|
|
684
761
|
place(order: PlaceOrderRequest): Promise<PlaceOrderResponse>;
|
|
685
762
|
get(orderId: string): Promise<PlaceOrderRequest>;
|
|
763
|
+
/**
|
|
764
|
+
* Confirm an order after client-side Stripe payment has succeeded.
|
|
765
|
+
*
|
|
766
|
+
* Verifies the PaymentIntent status with Stripe and transitions
|
|
767
|
+
* the order to 'paid' status.
|
|
768
|
+
*/
|
|
769
|
+
confirm(orderId: string, request: ConfirmOrderRequest): Promise<ConfirmOrderResponse>;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
declare class PaymentIntentsResource extends BaseResource {
|
|
773
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
774
|
+
/**
|
|
775
|
+
* Create a Stripe PaymentIntent via order3000's Stripe Connect integration.
|
|
776
|
+
*
|
|
777
|
+
* Returns a clientSecret for client-side payment confirmation and an orderId
|
|
778
|
+
* for the draft order that was created.
|
|
779
|
+
*/
|
|
780
|
+
create(request: CreatePaymentIntentRequest): Promise<CreatePaymentIntentResponse>;
|
|
686
781
|
}
|
|
687
782
|
|
|
688
783
|
declare class ReservationsResource extends BaseResource {
|
|
@@ -725,7 +820,7 @@ interface MenuItemRow {
|
|
|
725
820
|
type: 'dish' | 'beverage';
|
|
726
821
|
dish_id: string | null;
|
|
727
822
|
beverage_id: string | null;
|
|
728
|
-
|
|
823
|
+
price_adjustment: number;
|
|
729
824
|
currency: string;
|
|
730
825
|
is_active: boolean;
|
|
731
826
|
tags: string[] | null;
|
|
@@ -862,6 +957,7 @@ declare class Order3000Client {
|
|
|
862
957
|
events: EventsResource;
|
|
863
958
|
menus: MenusResource;
|
|
864
959
|
orders: OrdersResource;
|
|
960
|
+
paymentIntents: PaymentIntentsResource;
|
|
865
961
|
reservations: ReservationsResource;
|
|
866
962
|
realtime: RealtimeManager;
|
|
867
963
|
private readonly baseUrl;
|
|
@@ -869,4 +965,4 @@ declare class Order3000Client {
|
|
|
869
965
|
constructor(config: Order3000ClientConfig);
|
|
870
966
|
}
|
|
871
967
|
|
|
872
|
-
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, Order3000Client, type Order3000ClientConfig, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscriptionOptions, type TimeSlot, type Unit, getScheduleInfo };
|
|
968
|
+
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type ConfirmOrderRequest, type ConfirmOrderResponse, type CreatePaymentIntentRequest, type CreatePaymentIntentResponse, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuBundle, type MenuBundleDeposit, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, Order3000Client, type Order3000ClientConfig, type OrderFulfillmentType, type PlaceOrderRequest, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscriptionOptions, type TimeSlot, type Unit, getScheduleInfo };
|
package/dist/client.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CurrencyCode } from '@kolaveri/money';
|
|
1
2
|
import { RealtimePostgresChangesPayload, RealtimeChannel, SupabaseClient } from '@supabase/supabase-js';
|
|
2
3
|
|
|
3
4
|
declare class TokenManager {
|
|
@@ -67,6 +68,7 @@ interface components {
|
|
|
67
68
|
intervalMinutes?: number | null;
|
|
68
69
|
durationMinutes?: number | null;
|
|
69
70
|
} | null;
|
|
71
|
+
venueAccessor: string;
|
|
70
72
|
};
|
|
71
73
|
/**
|
|
72
74
|
* CreateEventResponse
|
|
@@ -108,6 +110,8 @@ interface components {
|
|
|
108
110
|
id?: string;
|
|
109
111
|
venueId: string;
|
|
110
112
|
basketId: string;
|
|
113
|
+
publicId?: string | null;
|
|
114
|
+
quickReferenceNumber?: number | null;
|
|
111
115
|
/** @enum {string} */
|
|
112
116
|
status?: "draft" | "pending" | "paid" | "fulfilled" | "cancelled" | "refunded";
|
|
113
117
|
paymentIntentId?: string | null;
|
|
@@ -117,6 +121,9 @@ interface components {
|
|
|
117
121
|
totalAmount: number;
|
|
118
122
|
/** @enum {string} */
|
|
119
123
|
currency?: "EUR" | "CHF";
|
|
124
|
+
/** @enum {string|null} */
|
|
125
|
+
fulfillmentType?: "pickup" | "delivery" | null;
|
|
126
|
+
fulfillmentAt?: unknown;
|
|
120
127
|
orderedAt?: unknown;
|
|
121
128
|
orderedBy: string;
|
|
122
129
|
updatedAt?: unknown;
|
|
@@ -127,6 +134,8 @@ interface components {
|
|
|
127
134
|
id: string;
|
|
128
135
|
venueId: string;
|
|
129
136
|
basketId: string;
|
|
137
|
+
publicId: string | null;
|
|
138
|
+
quickReferenceNumber: number | null;
|
|
130
139
|
/** @enum {string} */
|
|
131
140
|
status: "draft" | "pending" | "paid" | "fulfilled" | "cancelled" | "refunded";
|
|
132
141
|
paymentIntentId: string | null;
|
|
@@ -136,6 +145,9 @@ interface components {
|
|
|
136
145
|
totalAmount: number;
|
|
137
146
|
/** @enum {string} */
|
|
138
147
|
currency: "EUR" | "CHF";
|
|
148
|
+
/** @enum {string|null} */
|
|
149
|
+
fulfillmentType: "pickup" | "delivery" | null;
|
|
150
|
+
fulfillmentAt: unknown;
|
|
139
151
|
orderedAt: unknown;
|
|
140
152
|
orderedBy: string;
|
|
141
153
|
updatedAt: unknown;
|
|
@@ -189,6 +201,7 @@ interface components {
|
|
|
189
201
|
specialRequests: string | null;
|
|
190
202
|
/** @description Preferred seating area or table type (e.g., "window seat", "quiet area", "patio") */
|
|
191
203
|
tablePreference: string | null;
|
|
204
|
+
venueAccessor: string;
|
|
192
205
|
};
|
|
193
206
|
/**
|
|
194
207
|
* MakeReservationResponse
|
|
@@ -289,7 +302,17 @@ interface components {
|
|
|
289
302
|
type schemas = components['schemas'];
|
|
290
303
|
type CreateEventRequest = schemas['CreateEventRequest'];
|
|
291
304
|
type CreateEventResponse = schemas['CreateEventResponse'];
|
|
292
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Order fulfillment type - matches order_fulfillment_type enum in order3000 database.
|
|
307
|
+
* Keep in sync with apps/order3000/src/drizzle/enums.ts
|
|
308
|
+
*/
|
|
309
|
+
type OrderFulfillmentType = 'pickup' | 'delivery';
|
|
310
|
+
type PlaceOrderRequest = Omit<schemas['PlaceOrderRequest'], 'taxAmount' | 'totalAmount'> & {
|
|
311
|
+
/** Fulfillment type for the order (pickup or delivery) */
|
|
312
|
+
fulfillmentType?: OrderFulfillmentType;
|
|
313
|
+
/** When the order should be fulfilled (pickup/delivery time) */
|
|
314
|
+
fulfillmentAt?: Date;
|
|
315
|
+
};
|
|
293
316
|
type PlaceOrderResponse = schemas['PlaceOrderResponse'];
|
|
294
317
|
type MakeReservationRequest = schemas['MakeReservationRequest'];
|
|
295
318
|
type MakeReservationResponse = schemas['MakeReservationResponse'];
|
|
@@ -458,7 +481,8 @@ interface MenuItem {
|
|
|
458
481
|
id: string;
|
|
459
482
|
type: MenuItemType;
|
|
460
483
|
tags: string[] | null;
|
|
461
|
-
price
|
|
484
|
+
/** Price adjustment in cents (adds to bundle base price) */
|
|
485
|
+
priceAdjustment: number;
|
|
462
486
|
currency: string;
|
|
463
487
|
isActive: boolean;
|
|
464
488
|
sortIndex: string | null;
|
|
@@ -477,6 +501,24 @@ interface GetMenuOptions {
|
|
|
477
501
|
/** Expand related resources (items, assets) */
|
|
478
502
|
expand?: ('items' | 'assets')[];
|
|
479
503
|
}
|
|
504
|
+
interface MenuBundleDeposit {
|
|
505
|
+
name: Record<string, string>;
|
|
506
|
+
amount: number;
|
|
507
|
+
currency: CurrencyCode;
|
|
508
|
+
}
|
|
509
|
+
interface MenuBundle {
|
|
510
|
+
id: string;
|
|
511
|
+
menuId: string;
|
|
512
|
+
name: Record<string, string>;
|
|
513
|
+
description: Record<string, string> | null;
|
|
514
|
+
tags: string[];
|
|
515
|
+
price: number;
|
|
516
|
+
currency: CurrencyCode;
|
|
517
|
+
taxRateId: string;
|
|
518
|
+
isActive: boolean;
|
|
519
|
+
sortIndex: string | null;
|
|
520
|
+
deposit: MenuBundleDeposit | null;
|
|
521
|
+
}
|
|
480
522
|
interface ScheduleTimeSlot {
|
|
481
523
|
dayOfWeek: DayOfWeek | null;
|
|
482
524
|
timeSlot: {
|
|
@@ -601,6 +643,26 @@ interface RemoveFromBasketResponse {
|
|
|
601
643
|
basketItemId: string;
|
|
602
644
|
itemCount: number;
|
|
603
645
|
}
|
|
646
|
+
interface CreatePaymentIntentRequest {
|
|
647
|
+
basketId: string;
|
|
648
|
+
currency: Currency;
|
|
649
|
+
sessionId: string;
|
|
650
|
+
fulfillmentType?: OrderFulfillmentType;
|
|
651
|
+
fulfillmentTime?: string;
|
|
652
|
+
}
|
|
653
|
+
interface CreatePaymentIntentResponse {
|
|
654
|
+
clientSecret: string;
|
|
655
|
+
paymentIntentId: string;
|
|
656
|
+
orderId: string;
|
|
657
|
+
}
|
|
658
|
+
interface ConfirmOrderRequest {
|
|
659
|
+
paymentIntentId: string;
|
|
660
|
+
}
|
|
661
|
+
interface ConfirmOrderResponse {
|
|
662
|
+
id: string;
|
|
663
|
+
status: string;
|
|
664
|
+
publicId: string | null;
|
|
665
|
+
}
|
|
604
666
|
|
|
605
667
|
declare class BasketsResource extends BaseResource {
|
|
606
668
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
@@ -676,13 +738,46 @@ declare class MenusResource extends BaseResource {
|
|
|
676
738
|
* @returns The menu with optional items and assets
|
|
677
739
|
*/
|
|
678
740
|
getByAccessor(accessor: string, options?: GetMenuOptions): Promise<Menu>;
|
|
741
|
+
/**
|
|
742
|
+
* Get all bundles for a menu
|
|
743
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
744
|
+
* @returns Array of menu bundles
|
|
745
|
+
*/
|
|
746
|
+
getBundles(menuIdOrAccessor: string): Promise<MenuBundle[]>;
|
|
679
747
|
private buildQueryString;
|
|
680
748
|
}
|
|
681
749
|
|
|
682
750
|
declare class OrdersResource extends BaseResource {
|
|
683
751
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
752
|
+
/**
|
|
753
|
+
* Place a new order.
|
|
754
|
+
*
|
|
755
|
+
* The order3000 backend calculates taxAmount and totalAmount from the basket items:
|
|
756
|
+
* - totalAmount: derived from basket items' prices (bundleId -> price)
|
|
757
|
+
* - taxAmount: derived from basket items' tax rates (bundleId -> taxRateId -> rate)
|
|
758
|
+
*
|
|
759
|
+
* SDK callers cannot provide these values - they're implicit from the basket contents.
|
|
760
|
+
*/
|
|
684
761
|
place(order: PlaceOrderRequest): Promise<PlaceOrderResponse>;
|
|
685
762
|
get(orderId: string): Promise<PlaceOrderRequest>;
|
|
763
|
+
/**
|
|
764
|
+
* Confirm an order after client-side Stripe payment has succeeded.
|
|
765
|
+
*
|
|
766
|
+
* Verifies the PaymentIntent status with Stripe and transitions
|
|
767
|
+
* the order to 'paid' status.
|
|
768
|
+
*/
|
|
769
|
+
confirm(orderId: string, request: ConfirmOrderRequest): Promise<ConfirmOrderResponse>;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
declare class PaymentIntentsResource extends BaseResource {
|
|
773
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
774
|
+
/**
|
|
775
|
+
* Create a Stripe PaymentIntent via order3000's Stripe Connect integration.
|
|
776
|
+
*
|
|
777
|
+
* Returns a clientSecret for client-side payment confirmation and an orderId
|
|
778
|
+
* for the draft order that was created.
|
|
779
|
+
*/
|
|
780
|
+
create(request: CreatePaymentIntentRequest): Promise<CreatePaymentIntentResponse>;
|
|
686
781
|
}
|
|
687
782
|
|
|
688
783
|
declare class ReservationsResource extends BaseResource {
|
|
@@ -725,7 +820,7 @@ interface MenuItemRow {
|
|
|
725
820
|
type: 'dish' | 'beverage';
|
|
726
821
|
dish_id: string | null;
|
|
727
822
|
beverage_id: string | null;
|
|
728
|
-
|
|
823
|
+
price_adjustment: number;
|
|
729
824
|
currency: string;
|
|
730
825
|
is_active: boolean;
|
|
731
826
|
tags: string[] | null;
|
|
@@ -862,6 +957,7 @@ declare class Order3000Client {
|
|
|
862
957
|
events: EventsResource;
|
|
863
958
|
menus: MenusResource;
|
|
864
959
|
orders: OrdersResource;
|
|
960
|
+
paymentIntents: PaymentIntentsResource;
|
|
865
961
|
reservations: ReservationsResource;
|
|
866
962
|
realtime: RealtimeManager;
|
|
867
963
|
private readonly baseUrl;
|
|
@@ -869,4 +965,4 @@ declare class Order3000Client {
|
|
|
869
965
|
constructor(config: Order3000ClientConfig);
|
|
870
966
|
}
|
|
871
967
|
|
|
872
|
-
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, Order3000Client, type Order3000ClientConfig, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscriptionOptions, type TimeSlot, type Unit, getScheduleInfo };
|
|
968
|
+
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type ConfirmOrderRequest, type ConfirmOrderResponse, type CreatePaymentIntentRequest, type CreatePaymentIntentResponse, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuBundle, type MenuBundleDeposit, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, Order3000Client, type Order3000ClientConfig, type OrderFulfillmentType, type PlaceOrderRequest, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscriptionOptions, type TimeSlot, type Unit, getScheduleInfo };
|
package/dist/client.mjs
CHANGED
|
@@ -253,6 +253,14 @@ class MenusResource extends BaseResource {
|
|
|
253
253
|
const queryString = this.buildQueryString(options);
|
|
254
254
|
return this.request("GET", `/${accessor}${queryString}`);
|
|
255
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Get all bundles for a menu
|
|
258
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
259
|
+
* @returns Array of menu bundles
|
|
260
|
+
*/
|
|
261
|
+
async getBundles(menuIdOrAccessor) {
|
|
262
|
+
return this.request("GET", `/${menuIdOrAccessor}/bundles`);
|
|
263
|
+
}
|
|
256
264
|
buildQueryString(options) {
|
|
257
265
|
if (!options?.expand?.length) return "";
|
|
258
266
|
return `?expand=${options.expand.join(",")}`;
|
|
@@ -263,12 +271,45 @@ class OrdersResource extends BaseResource {
|
|
|
263
271
|
constructor(tokenManager, baseUrl) {
|
|
264
272
|
super(tokenManager, baseUrl, "/orders");
|
|
265
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Place a new order.
|
|
276
|
+
*
|
|
277
|
+
* The order3000 backend calculates taxAmount and totalAmount from the basket items:
|
|
278
|
+
* - totalAmount: derived from basket items' prices (bundleId -> price)
|
|
279
|
+
* - taxAmount: derived from basket items' tax rates (bundleId -> taxRateId -> rate)
|
|
280
|
+
*
|
|
281
|
+
* SDK callers cannot provide these values - they're implicit from the basket contents.
|
|
282
|
+
*/
|
|
266
283
|
async place(order) {
|
|
267
284
|
return this.request("POST", "", order);
|
|
268
285
|
}
|
|
269
286
|
async get(orderId) {
|
|
270
287
|
return this.request("GET", `/${orderId}`);
|
|
271
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Confirm an order after client-side Stripe payment has succeeded.
|
|
291
|
+
*
|
|
292
|
+
* Verifies the PaymentIntent status with Stripe and transitions
|
|
293
|
+
* the order to 'paid' status.
|
|
294
|
+
*/
|
|
295
|
+
async confirm(orderId, request) {
|
|
296
|
+
return this.request("POST", `/${orderId}/confirm`, request);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
class PaymentIntentsResource extends BaseResource {
|
|
301
|
+
constructor(tokenManager, baseUrl) {
|
|
302
|
+
super(tokenManager, baseUrl, "/payment-intents");
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Create a Stripe PaymentIntent via order3000's Stripe Connect integration.
|
|
306
|
+
*
|
|
307
|
+
* Returns a clientSecret for client-side payment confirmation and an orderId
|
|
308
|
+
* for the draft order that was created.
|
|
309
|
+
*/
|
|
310
|
+
async create(request) {
|
|
311
|
+
return this.request("POST", "", request);
|
|
312
|
+
}
|
|
272
313
|
}
|
|
273
314
|
|
|
274
315
|
class ReservationsResource extends BaseResource {
|
|
@@ -621,6 +662,7 @@ class Order3000Client {
|
|
|
621
662
|
__publicField(this, "events");
|
|
622
663
|
__publicField(this, "menus");
|
|
623
664
|
__publicField(this, "orders");
|
|
665
|
+
__publicField(this, "paymentIntents");
|
|
624
666
|
__publicField(this, "reservations");
|
|
625
667
|
__publicField(this, "realtime");
|
|
626
668
|
__publicField(this, "baseUrl");
|
|
@@ -637,6 +679,10 @@ class Order3000Client {
|
|
|
637
679
|
this.events = new EventsResource(this.tokenManager, this.baseUrl);
|
|
638
680
|
this.menus = new MenusResource(this.tokenManager, this.baseUrl);
|
|
639
681
|
this.orders = new OrdersResource(this.tokenManager, this.baseUrl);
|
|
682
|
+
this.paymentIntents = new PaymentIntentsResource(
|
|
683
|
+
this.tokenManager,
|
|
684
|
+
this.baseUrl
|
|
685
|
+
);
|
|
640
686
|
this.reservations = new ReservationsResource(
|
|
641
687
|
this.tokenManager,
|
|
642
688
|
this.baseUrl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "order3000",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "order3000 node.js sdk",
|
|
5
5
|
"main": "./dist/client.cjs",
|
|
6
6
|
"module": "./dist/client.mjs",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"@types/react-type-animation": "^2.0.0",
|
|
21
21
|
"i18next": "^25.6.0",
|
|
22
22
|
"i18next-fs-backend": "^2.6.0",
|
|
23
|
-
"react-type-animation": "^3.2.0"
|
|
23
|
+
"react-type-animation": "^3.2.0",
|
|
24
|
+
"@kolaveri/money": "1.1.3"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/node": "^24.10.0",
|
|
@@ -30,8 +31,8 @@
|
|
|
30
31
|
"tsx": "^4.19.2",
|
|
31
32
|
"typescript": "^5.9.3",
|
|
32
33
|
"@kolaveri/prettier-config": "1.0.6",
|
|
33
|
-
"@kolaveri/
|
|
34
|
-
"@kolaveri/
|
|
34
|
+
"@kolaveri/tsconfig": "1.0.1",
|
|
35
|
+
"@kolaveri/eslint-config": "1.4.0"
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
37
38
|
"dist"
|