@open-tender/utils 0.5.72 → 0.5.74

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,469 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../utils");
4
+ const makeOption = (id, posExtId, optionGroups = []) => ({
5
+ id,
6
+ name: `option ${id}`,
7
+ pos_ext_id: posExtId,
8
+ price: '0.00',
9
+ allergens: '',
10
+ tags: '',
11
+ opt_is_default: false,
12
+ min_quantity: 0,
13
+ max_quantity: 10,
14
+ increment: 1,
15
+ suspend_until: null,
16
+ nutritional_info: null,
17
+ option_groups: optionGroups
18
+ });
19
+ const makeGroup = (id, options, minOptions = 0) => ({
20
+ id,
21
+ name: `group ${id}`,
22
+ included: 0,
23
+ min_options: minOptions,
24
+ option_items: options
25
+ });
26
+ const makeMenuItem = (id, posExtId, groups = []) => ({
27
+ id,
28
+ name: `item ${id}`,
29
+ pos_ext_id: posExtId,
30
+ price: '10.00',
31
+ allergens: '',
32
+ tags: '',
33
+ increment: 1,
34
+ min_quantity: 1,
35
+ max_quantity: 10,
36
+ suspend_until: null,
37
+ nutritional_info: null,
38
+ option_groups: groups
39
+ });
40
+ const makeSimpleItem = (id, posExtId, groups = []) => ({
41
+ id,
42
+ name: `old item ${id}`,
43
+ pos_ext_id: posExtId,
44
+ quantity: 2,
45
+ groups
46
+ });
47
+ const reorderCart = (menuItems, simpleCart) => (0, utils_1.rehydrateCart)(menuItems, simpleCart, [], { isReorder: true });
48
+ describe('rehydrateCart with isReorder', () => {
49
+ it('matches an item by id when the order has no Checkmate id', () => {
50
+ const menuItems = [makeMenuItem(10, null)];
51
+ const { cart, unavailable } = reorderCart(menuItems, [
52
+ makeSimpleItem(10, null)
53
+ ]);
54
+ expect(cart.map(i => i.id)).toEqual([10]);
55
+ expect(cart[0].quantity).toBe(2);
56
+ expect(unavailable).toEqual([]);
57
+ });
58
+ it('finds a renamed item by its Checkmate id', () => {
59
+ const menuItems = [makeMenuItem(99, 'cm-item')];
60
+ const { cart, unavailable } = reorderCart(menuItems, [
61
+ makeSimpleItem(10, 'cm-item')
62
+ ]);
63
+ expect(cart.map(i => i.id)).toEqual([99]);
64
+ expect(unavailable).toEqual([]);
65
+ });
66
+ it('prefers the old id when the same Checkmate item is on the menu twice', () => {
67
+ const menuItems = [
68
+ makeMenuItem(99, 'cm-item'),
69
+ makeMenuItem(120, 'cm-item')
70
+ ];
71
+ const { cart } = reorderCart(menuItems, [makeSimpleItem(120, 'cm-item')]);
72
+ expect(cart.map(i => i.id)).toEqual([120]);
73
+ });
74
+ it('uses the first match when the old id is not on the menu any more', () => {
75
+ const menuItems = [
76
+ makeMenuItem(99, 'cm-item'),
77
+ makeMenuItem(120, 'cm-item')
78
+ ];
79
+ const { cart } = reorderCart(menuItems, [makeSimpleItem(10, 'cm-item')]);
80
+ expect(cart.map(i => i.id)).toEqual([99]);
81
+ });
82
+ it('falls back to the id when the Checkmate id is not on the menu', () => {
83
+ const menuItems = [makeMenuItem(10, 'cm-other')];
84
+ const { cart } = reorderCart(menuItems, [makeSimpleItem(10, 'cm-item')]);
85
+ expect(cart.map(i => i.id)).toEqual([10]);
86
+ });
87
+ it('reports items that are no longer on the menu and keeps the others', () => {
88
+ const menuItems = [makeMenuItem(10, 'cm-a')];
89
+ const { cart, unavailable } = reorderCart(menuItems, [
90
+ makeSimpleItem(10, 'cm-a'),
91
+ makeSimpleItem(11, 'cm-gone')
92
+ ]);
93
+ expect(cart.map(i => i.id)).toEqual([10]);
94
+ expect(unavailable).toEqual([{ name: 'old item 11' }]);
95
+ });
96
+ it('restores an option after its group and id changed', () => {
97
+ const menuItems = [
98
+ makeMenuItem(99, 'cm-item', [makeGroup(7, [makeOption(55, 'cm-mod')])])
99
+ ];
100
+ const simple = makeSimpleItem(10, 'cm-item', [
101
+ {
102
+ id: 5,
103
+ options: [
104
+ {
105
+ id: 20,
106
+ name: 'Cheese',
107
+ pos_ext_id: 'cm-mod',
108
+ quantity: 3,
109
+ groups: []
110
+ }
111
+ ]
112
+ }
113
+ ]);
114
+ const { cart, unavailable } = reorderCart(menuItems, [simple]);
115
+ const option = cart[0].groups[0].options[0];
116
+ expect(option.id).toBe(55);
117
+ expect(option.quantity).toBe(3);
118
+ expect(unavailable).toEqual([]);
119
+ });
120
+ it('restores nested options by their Checkmate id', () => {
121
+ const nestedGroup = makeGroup(8, [makeOption(77, 'cm-nested')]);
122
+ const menuItems = [
123
+ makeMenuItem(99, 'cm-item', [
124
+ makeGroup(7, [makeOption(55, 'cm-mod', [nestedGroup])])
125
+ ])
126
+ ];
127
+ const simple = makeSimpleItem(10, 'cm-item', [
128
+ {
129
+ id: 5,
130
+ options: [
131
+ {
132
+ id: 20,
133
+ pos_ext_id: 'cm-mod',
134
+ quantity: 1,
135
+ groups: [
136
+ {
137
+ id: 6,
138
+ options: [
139
+ { id: 30, pos_ext_id: 'cm-nested', quantity: 2, groups: [] }
140
+ ]
141
+ }
142
+ ]
143
+ }
144
+ ]
145
+ }
146
+ ]);
147
+ const { cart } = reorderCart(menuItems, [simple]);
148
+ const nested = cart[0].groups[0].options[0].groups[0].options[0];
149
+ expect(nested.id).toBe(77);
150
+ expect(nested.quantity).toBe(2);
151
+ });
152
+ it('uses each saved option once when a modifier is in two current groups', () => {
153
+ const menuItems = [
154
+ makeMenuItem(99, 'cm-item', [
155
+ makeGroup(7, [makeOption(55, 'cm-mod')]),
156
+ makeGroup(8, [makeOption(66, 'cm-mod')])
157
+ ])
158
+ ];
159
+ const simple = makeSimpleItem(10, 'cm-item', [
160
+ {
161
+ id: 5,
162
+ options: [{ id: 20, pos_ext_id: 'cm-mod', quantity: 1, groups: [] }]
163
+ }
164
+ ]);
165
+ const { cart } = reorderCart(menuItems, [simple]);
166
+ const quantities = cart[0].groups.map(g => g.options[0].quantity);
167
+ expect(quantities.sort()).toEqual([0, 1]);
168
+ });
169
+ it('keeps matching options by group and id when there is no Checkmate id', () => {
170
+ const menuItems = [
171
+ makeMenuItem(10, null, [makeGroup(5, [makeOption(20, null)])])
172
+ ];
173
+ const simple = makeSimpleItem(10, null, [
174
+ { id: 5, options: [{ id: 20, quantity: 2, groups: [] }] }
175
+ ]);
176
+ const { cart, unavailable } = reorderCart(menuItems, [simple]);
177
+ expect(cart[0].groups[0].options[0].quantity).toBe(2);
178
+ expect(unavailable).toEqual([]);
179
+ });
180
+ it('drops an item when one of its options is no longer on the item', () => {
181
+ const menuItems = [
182
+ makeMenuItem(99, 'cm-item', [makeGroup(7, [makeOption(55, 'cm-other')])])
183
+ ];
184
+ const simple = makeSimpleItem(10, 'cm-item', [
185
+ {
186
+ id: 5,
187
+ options: [
188
+ {
189
+ id: 20,
190
+ name: 'Old Topping',
191
+ pos_ext_id: 'cm-gone',
192
+ quantity: 1,
193
+ groups: []
194
+ }
195
+ ]
196
+ }
197
+ ]);
198
+ const { cart, unavailable } = reorderCart(menuItems, [simple]);
199
+ expect(cart).toEqual([]);
200
+ expect(unavailable).toEqual([{ name: 'old item 10' }]);
201
+ });
202
+ it('drops an item whose whole option group is gone and keeps the others', () => {
203
+ const menuItems = [
204
+ makeMenuItem(99, 'cm-item', [makeGroup(7, [makeOption(55, 'cm-kept')])]),
205
+ makeMenuItem(98, 'cm-plain')
206
+ ];
207
+ const withGroup = makeSimpleItem(10, 'cm-item', [
208
+ {
209
+ id: 5,
210
+ options: [
211
+ { id: 21, pos_ext_id: 'cm-kept', quantity: 1, groups: [] },
212
+ { id: 22, pos_ext_id: 'cm-gone', quantity: 1, groups: [] }
213
+ ]
214
+ }
215
+ ]);
216
+ const { cart, unavailable } = reorderCart(menuItems, [
217
+ withGroup,
218
+ makeSimpleItem(11, 'cm-plain')
219
+ ]);
220
+ expect(cart.map(i => i.id)).toEqual([98]);
221
+ expect(unavailable).toEqual([{ name: 'old item 10' }]);
222
+ });
223
+ it('drops an item with a required group the past order did not fill', () => {
224
+ const menuItems = [
225
+ makeMenuItem(99, 'cm-item', [
226
+ makeGroup(7, [makeOption(55, 'cm-new')], 1)
227
+ ]),
228
+ makeMenuItem(98, 'cm-plain')
229
+ ];
230
+ const { cart, unavailable } = reorderCart(menuItems, [
231
+ makeSimpleItem(10, 'cm-item'),
232
+ makeSimpleItem(11, 'cm-plain')
233
+ ]);
234
+ expect(cart.map(i => i.id)).toEqual([98]);
235
+ expect(unavailable).toEqual([{ name: 'old item 10' }]);
236
+ });
237
+ it('keeps an item whose required group is filled by the past order', () => {
238
+ const menuItems = [
239
+ makeMenuItem(99, 'cm-item', [makeGroup(7, [makeOption(55, 'cm-opt')], 1)])
240
+ ];
241
+ const simple = makeSimpleItem(10, 'cm-item', [
242
+ {
243
+ id: 7,
244
+ options: [{ id: 55, pos_ext_id: 'cm-opt', quantity: 1, groups: [] }]
245
+ }
246
+ ]);
247
+ const { cart, unavailable } = reorderCart(menuItems, [simple]);
248
+ expect(cart.map(i => i.id)).toEqual([99]);
249
+ expect(unavailable).toEqual([]);
250
+ });
251
+ it('drops an item when a nested option is gone', () => {
252
+ const menuItems = [
253
+ makeMenuItem(99, 'cm-item', [
254
+ makeGroup(7, [
255
+ makeOption(55, 'cm-parent', [
256
+ makeGroup(8, [makeOption(66, 'cm-other')])
257
+ ])
258
+ ])
259
+ ])
260
+ ];
261
+ const simple = makeSimpleItem(10, 'cm-item', [
262
+ {
263
+ id: 7,
264
+ options: [
265
+ {
266
+ id: 55,
267
+ pos_ext_id: 'cm-parent',
268
+ quantity: 1,
269
+ groups: [
270
+ {
271
+ id: 8,
272
+ options: [
273
+ { id: 67, pos_ext_id: 'cm-gone', quantity: 1, groups: [] }
274
+ ]
275
+ }
276
+ ]
277
+ }
278
+ ]
279
+ }
280
+ ]);
281
+ const { cart, unavailable } = reorderCart(menuItems, [simple]);
282
+ expect(cart).toEqual([]);
283
+ expect(unavailable).toEqual([{ name: 'old item 10' }]);
284
+ });
285
+ });
286
+ describe('rehydrateCart without isReorder', () => {
287
+ it('matches by id only and ignores the Checkmate id', () => {
288
+ const menuItems = [
289
+ makeMenuItem(99, 'cm-item'),
290
+ makeMenuItem(10, 'cm-other')
291
+ ];
292
+ const { cart, unavailable } = (0, utils_1.rehydrateCart)(menuItems, [
293
+ makeSimpleItem(10, 'cm-item'),
294
+ makeSimpleItem(11, 'cm-item')
295
+ ]);
296
+ expect(cart.map(i => i.id)).toEqual([10]);
297
+ expect(unavailable).toEqual([]);
298
+ });
299
+ it('keeps an item when one of its options is gone and leaves the defaults', () => {
300
+ const menuItems = [
301
+ makeMenuItem(10, 'cm-item', [makeGroup(7, [makeOption(55, 'cm-other')])])
302
+ ];
303
+ const simple = makeSimpleItem(10, 'cm-item', [
304
+ {
305
+ id: 7,
306
+ options: [{ id: 20, pos_ext_id: 'cm-gone', quantity: 1, groups: [] }]
307
+ }
308
+ ]);
309
+ const { cart, unavailable } = (0, utils_1.rehydrateCart)(menuItems, [simple]);
310
+ expect(cart.map(i => i.id)).toEqual([10]);
311
+ expect(cart[0].groups[0].options[0].quantity).toBe(0);
312
+ expect(unavailable).toEqual([]);
313
+ });
314
+ it('keeps an item whose required group the saved cart did not fill', () => {
315
+ const menuItems = [
316
+ makeMenuItem(10, null, [makeGroup(7, [makeOption(55, null)], 1)])
317
+ ];
318
+ const { cart } = (0, utils_1.rehydrateCart)(menuItems, [makeSimpleItem(10, null)]);
319
+ expect(cart.map(i => i.id)).toEqual([10]);
320
+ });
321
+ it('does not move a saved option into another group by its Checkmate id', () => {
322
+ const menuItems = [
323
+ makeMenuItem(10, null, [
324
+ makeGroup(7, [makeOption(55, 'cm-mod')]),
325
+ makeGroup(8, [makeOption(66, 'cm-mod')])
326
+ ])
327
+ ];
328
+ const simple = makeSimpleItem(10, null, [
329
+ {
330
+ id: 5,
331
+ options: [{ id: 20, pos_ext_id: 'cm-mod', quantity: 1, groups: [] }]
332
+ }
333
+ ]);
334
+ const { cart } = (0, utils_1.rehydrateCart)(menuItems, [simple]);
335
+ const quantities = cart[0].groups.map(g => g.options[0].quantity);
336
+ expect(quantities).toEqual([0, 0]);
337
+ });
338
+ it('matches options by group and id like before', () => {
339
+ const menuItems = [
340
+ makeMenuItem(10, 'cm-item', [makeGroup(5, [makeOption(20, 'cm-mod')])])
341
+ ];
342
+ const simple = makeSimpleItem(10, 'cm-item', [
343
+ {
344
+ id: 5,
345
+ options: [{ id: 20, pos_ext_id: 'cm-mod', quantity: 2, groups: [] }]
346
+ }
347
+ ]);
348
+ const { cart } = (0, utils_1.rehydrateCart)(menuItems, [simple]);
349
+ expect(cart[0].groups[0].options[0].quantity).toBe(2);
350
+ });
351
+ });
352
+ describe('rehydrateOrderItem', () => {
353
+ it('returns the priced item only', () => {
354
+ const item = (0, utils_1.rehydrateOrderItem)(makeMenuItem(10, null), makeSimpleItem(10, null));
355
+ expect(item.id).toBe(10);
356
+ expect(item.quantity).toBe(2);
357
+ });
358
+ });
359
+ describe('makeReorderCart', () => {
360
+ it('keeps names and Checkmate ids and drops options with zero quantity', () => {
361
+ const orderCart = [
362
+ {
363
+ id: 10,
364
+ name: 'Pizza',
365
+ pos_ext_id: 'cm-item',
366
+ quantity: 1,
367
+ madeFor: 'Sam',
368
+ notes: 'extra crispy',
369
+ groups: [
370
+ {
371
+ id: 5,
372
+ options: [
373
+ {
374
+ id: 20,
375
+ name: 'Cheese',
376
+ pos_ext_id: 'cm-mod',
377
+ quantity: 2,
378
+ groups: []
379
+ },
380
+ {
381
+ id: 21,
382
+ name: 'Olives',
383
+ pos_ext_id: 'cm-olive',
384
+ quantity: 0,
385
+ groups: []
386
+ }
387
+ ]
388
+ }
389
+ ]
390
+ }
391
+ ];
392
+ const cart = (0, utils_1.makeReorderCart)(orderCart);
393
+ expect(cart).toEqual([
394
+ {
395
+ id: 10,
396
+ name: 'Pizza',
397
+ pos_ext_id: 'cm-item',
398
+ quantity: 1,
399
+ made_for: 'Sam',
400
+ notes: 'extra crispy',
401
+ groups: [
402
+ {
403
+ id: 5,
404
+ options: [
405
+ {
406
+ id: 20,
407
+ name: 'Cheese',
408
+ pos_ext_id: 'cm-mod',
409
+ quantity: 2,
410
+ groups: []
411
+ }
412
+ ]
413
+ }
414
+ ]
415
+ }
416
+ ]);
417
+ });
418
+ it('uses null for a missing Checkmate id', () => {
419
+ const cart = (0, utils_1.makeReorderCart)([
420
+ { id: 10, quantity: 1, groups: [] }
421
+ ]);
422
+ expect(cart[0].pos_ext_id).toBeNull();
423
+ });
424
+ });
425
+ describe('reorder null safety', () => {
426
+ it('makeReorderCart tolerates a missing cart, groups and options', () => {
427
+ expect((0, utils_1.makeReorderCart)(null)).toEqual([]);
428
+ const cart = [
429
+ { id: 1, quantity: 1, groups: undefined },
430
+ { id: 2, quantity: 1, groups: [{ id: 5, options: undefined }] }
431
+ ];
432
+ const result = (0, utils_1.makeReorderCart)(cart);
433
+ expect(result.map(i => i.groups)).toEqual([[], [{ id: 5, options: [] }]]);
434
+ });
435
+ it('rehydrateCart with isReorder reports every item when the menu is null', () => {
436
+ const items = [makeSimpleItem(1, 'a'), makeSimpleItem(2, null)];
437
+ const { cart, unavailable } = (0, utils_1.rehydrateCart)(null, items, [], {
438
+ isReorder: true
439
+ });
440
+ expect(cart).toEqual([]);
441
+ expect(unavailable.map(i => i.name)).toEqual(['old item 1', 'old item 2']);
442
+ });
443
+ it('rehydrateCart with isReorder returns an empty cart for null items', () => {
444
+ const result = (0, utils_1.rehydrateCart)([makeMenuItem(1, 'a')], null, [], {
445
+ isReorder: true
446
+ });
447
+ expect(result.cart).toEqual([]);
448
+ expect(result.unavailable).toEqual([]);
449
+ });
450
+ it('rehydrateCart with isReorder skips a null line and keeps the others', () => {
451
+ const items = [null, makeSimpleItem(1, 'a')];
452
+ const result = (0, utils_1.rehydrateCart)([makeMenuItem(1, 'a')], items, [], {
453
+ isReorder: true
454
+ });
455
+ expect(result.cart).toHaveLength(1);
456
+ expect(result.unavailable).toEqual([]);
457
+ });
458
+ it('rehydrateCart with isReorder tolerates a menu item with no option groups', () => {
459
+ const menuItem = Object.assign(Object.assign({}, makeMenuItem(1, 'a')), { option_groups: undefined });
460
+ const saved = makeSimpleItem(1, 'a', [
461
+ { id: 9, options: [{ id: 3, quantity: 1, pos_ext_id: 'x', groups: [] }] }
462
+ ]);
463
+ const result = (0, utils_1.rehydrateCart)([menuItem], [saved], [], {
464
+ isReorder: true
465
+ });
466
+ expect(result.cart).toEqual([]);
467
+ expect(result.unavailable).toHaveLength(1);
468
+ });
469
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const datetimes_1 = require("../../utils/datetimes");
4
+ const TZ = 'America/New_York';
5
+ beforeEach(() => {
6
+ jest.useFakeTimers().setSystemTime(new Date('2026-01-15T17:00:00Z'));
7
+ });
8
+ afterEach(() => {
9
+ jest.useRealTimers();
10
+ });
11
+ test('returns ASAP unchanged regardless of rangeMinutes', () => {
12
+ expect((0, datetimes_1.makeRequestedAtStr)('asap', TZ, true, 30)).toBe('ASAP');
13
+ expect((0, datetimes_1.makeRequestedAtStr)(null, TZ, true, 30)).toBe('ASAP');
14
+ });
15
+ test('no rangeMinutes preserves existing single-time behavior', () => {
16
+ const iso = '2026-01-15T20:30:00.000Z'; // 3:30pm ET
17
+ expect((0, datetimes_1.makeRequestedAtStr)(iso, TZ, true)).toBe('Today @ 3:30pm');
18
+ });
19
+ test('a configured range appends the end time on the same day', () => {
20
+ const iso = '2026-01-15T20:30:00.000Z'; // 3:30pm ET
21
+ expect((0, datetimes_1.makeRequestedAtStr)(iso, TZ, true, 30)).toBe('Today @ 3:30pm-4:00pm');
22
+ });
23
+ test('a range crossing midnight still shows the wrapped end time', () => {
24
+ const iso = '2026-01-16T04:45:00.000Z'; // 11:45pm ET
25
+ expect((0, datetimes_1.makeRequestedAtStr)(iso, TZ, true, 30)).toBe('Today @ 11:45pm-12:15am');
26
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const revenueCenters_1 = require("../../utils/revenueCenters");
4
+ const baseRc = {
5
+ status: 'OPEN',
6
+ timezone: 'US/Eastern',
7
+ first_times: {
8
+ DELIVERY: {
9
+ has_asap: true,
10
+ date: '2026-01-15',
11
+ utc: '2026-01-15T20:00:00Z'
12
+ },
13
+ PICKUP: { has_asap: true, date: '2026-01-15', utc: '2026-01-15T20:00:00Z' }
14
+ },
15
+ order_times: { DELIVERY: null, PICKUP: null },
16
+ wait_times: { DELIVERY: 30, PICKUP: 15 },
17
+ time_ranges: { DELIVERY: 30, PICKUP: 30 }
18
+ };
19
+ test('opt-in (showDeliveryRange=true) widens the DELIVERY ASAP estimate', () => {
20
+ const { message } = (0, revenueCenters_1.makeRevenueCenterMsg)(baseRc, 'DELIVERY', 'asap', {}, true);
21
+ expect(message).toContain('in about 30-60 minutes');
22
+ });
23
+ test('default (no 5th arg, matches every existing mobile/web caller) leaves DELIVERY unchanged', () => {
24
+ const { message } = (0, revenueCenters_1.makeRevenueCenterMsg)(baseRc, 'DELIVERY', 'asap', {});
25
+ expect(message).toContain('in about 30 minutes');
26
+ expect(message).not.toContain('-');
27
+ });
28
+ test('PICKUP is unaffected even with showDeliveryRange=true and a pickup range configured', () => {
29
+ const { message } = (0, revenueCenters_1.makeRevenueCenterMsg)(baseRc, 'PICKUP', 'asap', {}, true);
30
+ expect(message).toContain('in about 15 minutes');
31
+ expect(message).not.toContain('-');
32
+ });
33
+ test('a zero wait time with a configured range produces 0-range, not a missing range', () => {
34
+ const rc = Object.assign(Object.assign({}, baseRc), { wait_times: { DELIVERY: 0, PICKUP: 15 } });
35
+ const { message } = (0, revenueCenters_1.makeRevenueCenterMsg)(rc, 'DELIVERY', 'asap', {}, true);
36
+ expect(message).toContain('in about 0-30 minutes');
37
+ });
@@ -1,4 +1,4 @@
1
- import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem, FavoritesLookup, RequestedAt } from '@open-tender/types';
1
+ import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, ReorderUnavailableLine, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem, FavoritesLookup, RequestedAt } from '@open-tender/types';
2
2
  export declare const getItemOptions: <T extends BaseItem>(item: T) => BaseItem[];
3
3
  export declare const makeModifierNames: <T extends BaseItem>(item: T) => string;
4
4
  export declare const makeModifierNamesForGroups: (groups: CartItemGroups) => string;
@@ -14,7 +14,9 @@ export declare const checkSoldOut: (id: number, suspendUntil: number | null, sol
14
14
  export declare const makeOrderItem: (item: MenuItem, isEdit?: boolean, soldOut?: SoldOut, simpleItem?: SimpleCartItem, hasPoints?: boolean, requestedAt?: RequestedAt | null) => CartItemOption | CartItem;
15
15
  export declare const calcCartCounts: (cart: Cart) => Record<string, number>;
16
16
  export declare const rehydrateOrderItem: (menuItem: MenuItem, simpleCartItem: SimpleCartItem, soldOut?: number[], requestedAt?: RequestedAt | null) => CartItem;
17
- export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: SimpleCart, soldOut?: number[]) => {
17
+ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: SimpleCart, soldOut?: number[], options?: {
18
+ isReorder?: boolean;
19
+ }) => {
18
20
  cart: {
19
21
  index: number;
20
22
  cartGuestId: number | null;
@@ -62,6 +64,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
62
64
  excludeFromBuilder: boolean;
63
65
  }[];
64
66
  cartCounts: Record<string, number>;
67
+ unavailable: ReorderUnavailableLine[];
65
68
  };
66
69
  export declare const rehydrateCheckoutForm: (order: Order) => {
67
70
  details: {
@@ -210,6 +213,25 @@ export declare const makeSimpleCart: <C extends {
210
213
  made_for: string;
211
214
  notes: string;
212
215
  }[];
216
+ export declare const makeReorderCart: <C extends {
217
+ id: number;
218
+ name?: string | undefined;
219
+ pos_ext_id?: string | null | undefined;
220
+ quantity: number;
221
+ groups: T[];
222
+ madeFor?: string | null | undefined;
223
+ made_for?: string | null | undefined;
224
+ notes?: string | null | undefined;
225
+ }[], T extends {
226
+ id: number;
227
+ options: K[];
228
+ }, K extends {
229
+ id: number;
230
+ name?: string | undefined;
231
+ pos_ext_id?: string | null | undefined;
232
+ quantity: number;
233
+ groups: T[];
234
+ }>(cart: C) => SimpleCart;
213
235
  export declare const validateCart: (cart: Cart, categories: MenuCategories, soldOut: SoldOut, requestedAt: RequestedAt) => {
214
236
  newCart: Cart;
215
237
  errors: CartErrors | null;