@tiquo/dom-package 1.3.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +136 -9
- package/dist/index.d.ts +136 -9
- package/dist/index.js +66 -4
- package/dist/index.mjs +66 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -325,10 +325,17 @@ interface TiquoOrderItem {
|
|
|
325
325
|
total: number;
|
|
326
326
|
type: 'product' | 'booking' | 'custom';
|
|
327
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* An order belonging to the authenticated customer.
|
|
330
|
+
*
|
|
331
|
+
* Note: `lost_cart` (abandoned) and `pending` (unprocessed/awaiting-payment)
|
|
332
|
+
* orders are never returned — they're internal state, not part of the
|
|
333
|
+
* customer's purchase history.
|
|
334
|
+
*/
|
|
328
335
|
interface TiquoOrder {
|
|
329
336
|
id: string;
|
|
330
337
|
orderNumber: string;
|
|
331
|
-
status: 'draft' | '
|
|
338
|
+
status: 'draft' | 'processing' | 'completed' | 'cancelled' | 'refunded' | 'open_tab';
|
|
332
339
|
paymentStatus: 'pending' | 'paid' | 'partial' | 'refunded' | 'partially_refunded' | 'failed' | 'cancelled';
|
|
333
340
|
total: number;
|
|
334
341
|
subtotal: number;
|
|
@@ -337,7 +344,7 @@ interface TiquoOrder {
|
|
|
337
344
|
items: TiquoOrderItem[];
|
|
338
345
|
createdAt: number;
|
|
339
346
|
completedAt?: number;
|
|
340
|
-
customerRole: 'primary' | 'attendee' | '
|
|
347
|
+
customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
|
|
341
348
|
}
|
|
342
349
|
interface GetOrdersOptions {
|
|
343
350
|
limit?: number;
|
|
@@ -349,16 +356,95 @@ interface GetOrdersResult {
|
|
|
349
356
|
hasMore: boolean;
|
|
350
357
|
nextCursor?: string;
|
|
351
358
|
}
|
|
359
|
+
interface TiquoReceiptItem {
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
quantity: number;
|
|
363
|
+
unitPrice: number;
|
|
364
|
+
subtotal: number;
|
|
365
|
+
tax: number;
|
|
366
|
+
discount: number;
|
|
367
|
+
total: number;
|
|
368
|
+
type: 'product' | 'booking' | 'custom' | 'membership';
|
|
369
|
+
specialInstructions?: string;
|
|
370
|
+
}
|
|
371
|
+
interface TiquoReceiptBusiness {
|
|
372
|
+
name?: string;
|
|
373
|
+
logo?: string;
|
|
374
|
+
brandName?: string;
|
|
375
|
+
primaryColor?: string;
|
|
376
|
+
vatNumber?: string;
|
|
377
|
+
address?: string;
|
|
378
|
+
city?: string;
|
|
379
|
+
postalCode?: string;
|
|
380
|
+
country?: string;
|
|
381
|
+
email?: string;
|
|
382
|
+
phone?: string;
|
|
383
|
+
sublocationName?: string;
|
|
384
|
+
locationName?: string;
|
|
385
|
+
}
|
|
386
|
+
interface TiquoReceiptCustomer {
|
|
387
|
+
id: string;
|
|
388
|
+
customerNumber: string;
|
|
389
|
+
displayName?: string;
|
|
390
|
+
email?: string;
|
|
391
|
+
}
|
|
392
|
+
interface TiquoReceiptOrder {
|
|
393
|
+
id: string;
|
|
394
|
+
orderNumber: string;
|
|
395
|
+
status: TiquoOrder['status'];
|
|
396
|
+
paymentStatus: TiquoOrder['paymentStatus'];
|
|
397
|
+
currency: string;
|
|
398
|
+
subtotal: number;
|
|
399
|
+
taxTotal: number;
|
|
400
|
+
/** "Tax Inclusive" or "Tax Exclusive" — controls how the receipt should render tax lines. */
|
|
401
|
+
taxSetting?: string;
|
|
402
|
+
discountTotal: number;
|
|
403
|
+
discountName?: string;
|
|
404
|
+
serviceChargeAmount?: number;
|
|
405
|
+
tipAmount?: number;
|
|
406
|
+
total: number;
|
|
407
|
+
refundAmount?: number;
|
|
408
|
+
refundedAt?: number;
|
|
409
|
+
paymentMethod?: string;
|
|
410
|
+
cardBrand?: string;
|
|
411
|
+
cardLast4?: string;
|
|
412
|
+
items: TiquoReceiptItem[];
|
|
413
|
+
createdAt: number;
|
|
414
|
+
completedAt?: number;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* A printable receipt for a single paid/completed order owned by the
|
|
418
|
+
* authenticated customer. Combines order totals, line items, business
|
|
419
|
+
* branding (logo, VAT, address), and the customer's own details so the
|
|
420
|
+
* consumer can render or print the receipt without further API calls.
|
|
421
|
+
*/
|
|
422
|
+
interface TiquoReceipt {
|
|
423
|
+
order: TiquoReceiptOrder;
|
|
424
|
+
business: TiquoReceiptBusiness;
|
|
425
|
+
customer: TiquoReceiptCustomer;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* A booking belonging to the authenticated customer.
|
|
429
|
+
*
|
|
430
|
+
* Note: `draft` bookings (in-progress checkout state) are never returned —
|
|
431
|
+
* they're internal state, not part of the customer's booking history.
|
|
432
|
+
*/
|
|
352
433
|
interface TiquoBooking {
|
|
353
434
|
id: string;
|
|
354
435
|
bookingNumber: string;
|
|
355
|
-
status: '
|
|
436
|
+
status: 'scheduled' | 'confirmed' | 'reminder_sent' | 'waiting_room' | 'waiting_list' | 'checked_in' | 'active' | 'in_progress' | 'completed' | 'cancelled' | 'no_show' | 'rescheduled';
|
|
356
437
|
date: number;
|
|
357
438
|
startTime: string;
|
|
358
439
|
endTime: string;
|
|
359
440
|
duration: number;
|
|
360
441
|
timezone: string;
|
|
361
442
|
attendeeCount: number;
|
|
443
|
+
/**
|
|
444
|
+
* Service title (e.g. "OJAS Listening Room"). Empty string when the
|
|
445
|
+
* underlying service has been deleted — render your own fallback if you
|
|
446
|
+
* need a non-empty display string.
|
|
447
|
+
*/
|
|
362
448
|
serviceName: string;
|
|
363
449
|
serviceId: string;
|
|
364
450
|
sublocationId: string;
|
|
@@ -394,7 +480,7 @@ interface TiquoEnquiry {
|
|
|
394
480
|
updatedAt: string;
|
|
395
481
|
firstResponseAt?: string;
|
|
396
482
|
resolvedAt?: string;
|
|
397
|
-
customerRole: 'primary' | '
|
|
483
|
+
customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
|
|
398
484
|
}
|
|
399
485
|
interface GetEnquiriesOptions {
|
|
400
486
|
limit?: number;
|
|
@@ -464,15 +550,54 @@ declare class TiquoAuth {
|
|
|
464
550
|
*/
|
|
465
551
|
onAuthStateChange(callback: AuthStateChangeCallback): () => void;
|
|
466
552
|
/**
|
|
467
|
-
* Get the authenticated customer's order history
|
|
468
|
-
*
|
|
553
|
+
* Get the authenticated customer's order history.
|
|
554
|
+
*
|
|
555
|
+
* Returns orders across most statuses (draft, processing, completed,
|
|
556
|
+
* cancelled, refunded, open_tab). `lost_cart` (abandoned) and `pending`
|
|
557
|
+
* (unprocessed/awaiting-payment) orders are never exposed — they're
|
|
558
|
+
* internal state, not purchase history.
|
|
559
|
+
*
|
|
560
|
+
* Pass `status` to filter to a single status; pass `cursor` (an order id
|
|
561
|
+
* from a previous `nextCursor`) to paginate. Sorted most recent first.
|
|
469
562
|
*/
|
|
470
563
|
getOrders(options?: GetOrdersOptions): Promise<GetOrdersResult>;
|
|
471
564
|
/**
|
|
472
|
-
* Get the authenticated customer's booking history
|
|
473
|
-
*
|
|
565
|
+
* Get the authenticated customer's booking history.
|
|
566
|
+
*
|
|
567
|
+
* Pass `upcoming: true` to limit to future bookings sorted soonest-first —
|
|
568
|
+
* the common case for rendering "Your upcoming bookings" on a logged-in
|
|
569
|
+
* customer dashboard. Without it, returns all bookings sorted most recent
|
|
570
|
+
* first.
|
|
474
571
|
*/
|
|
475
572
|
getBookings(options?: GetBookingsOptions): Promise<GetBookingsResult>;
|
|
573
|
+
/**
|
|
574
|
+
* Convenience wrapper around `getBookings({ upcoming: true })` for the
|
|
575
|
+
* common "show me my upcoming bookings" case. Results are sorted
|
|
576
|
+
* soonest-first.
|
|
577
|
+
*
|
|
578
|
+
* Only actionable future bookings are returned — `cancelled`, `no_show`,
|
|
579
|
+
* and `rescheduled` bookings are excluded even if their date is in the
|
|
580
|
+
* future, since they're effectively history. Use `getBookings()` without
|
|
581
|
+
* `upcoming: true` if you need those.
|
|
582
|
+
*/
|
|
583
|
+
getUpcomingBookings(options?: Omit<GetBookingsOptions, 'upcoming'>): Promise<GetBookingsResult>;
|
|
584
|
+
/**
|
|
585
|
+
* Get a printable receipt for a single order owned by the authenticated
|
|
586
|
+
* customer. Only resolves for orders that are paid (full or partial),
|
|
587
|
+
* refunded, or completed — drafts and pending orders don't have a receipt
|
|
588
|
+
* yet and will throw `RECEIPT_NOT_AVAILABLE`.
|
|
589
|
+
*
|
|
590
|
+
* The returned payload bundles the order totals & items, the business's
|
|
591
|
+
* receipt branding (logo, VAT number, address), and the customer's own
|
|
592
|
+
* details so the consumer can render or print the receipt without further
|
|
593
|
+
* API calls.
|
|
594
|
+
*
|
|
595
|
+
* Throws `TiquoAuthError` with code:
|
|
596
|
+
* - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
|
|
597
|
+
* it isn't paid/completed yet.
|
|
598
|
+
* - `NOT_AUTHENTICATED` — no valid session.
|
|
599
|
+
*/
|
|
600
|
+
getReceipt(orderId: string): Promise<TiquoReceipt>;
|
|
476
601
|
/**
|
|
477
602
|
* Get the authenticated customer's enquiry history
|
|
478
603
|
* Only returns enquiries for the logged-in customer
|
|
@@ -568,6 +693,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
|
|
|
568
693
|
updateProfile: (updates: ProfileUpdateData) => Promise<ProfileUpdateResult>;
|
|
569
694
|
getOrders: (options?: GetOrdersOptions) => Promise<GetOrdersResult>;
|
|
570
695
|
getBookings: (options?: GetBookingsOptions) => Promise<GetBookingsResult>;
|
|
696
|
+
getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
|
|
697
|
+
getReceipt: (orderId: string) => Promise<TiquoReceipt>;
|
|
571
698
|
getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
|
|
572
699
|
getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
|
|
573
700
|
embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
|
|
@@ -631,4 +758,4 @@ declare class TiquoPhone {
|
|
|
631
758
|
static buildPhone: typeof buildPhone;
|
|
632
759
|
}
|
|
633
760
|
|
|
634
|
-
export { type AuthStateChangeCallback, type CountryPhoneInfo, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type PhoneValidationResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, TiquoPhone, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isDashboardSession, trackCustomerPresence, useTiquoAuth };
|
|
761
|
+
export { type AuthStateChangeCallback, type CountryPhoneInfo, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type PhoneValidationResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, TiquoPhone, type TiquoReceipt, type TiquoReceiptBusiness, type TiquoReceiptCustomer, type TiquoReceiptItem, type TiquoReceiptOrder, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isDashboardSession, trackCustomerPresence, useTiquoAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -325,10 +325,17 @@ interface TiquoOrderItem {
|
|
|
325
325
|
total: number;
|
|
326
326
|
type: 'product' | 'booking' | 'custom';
|
|
327
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* An order belonging to the authenticated customer.
|
|
330
|
+
*
|
|
331
|
+
* Note: `lost_cart` (abandoned) and `pending` (unprocessed/awaiting-payment)
|
|
332
|
+
* orders are never returned — they're internal state, not part of the
|
|
333
|
+
* customer's purchase history.
|
|
334
|
+
*/
|
|
328
335
|
interface TiquoOrder {
|
|
329
336
|
id: string;
|
|
330
337
|
orderNumber: string;
|
|
331
|
-
status: 'draft' | '
|
|
338
|
+
status: 'draft' | 'processing' | 'completed' | 'cancelled' | 'refunded' | 'open_tab';
|
|
332
339
|
paymentStatus: 'pending' | 'paid' | 'partial' | 'refunded' | 'partially_refunded' | 'failed' | 'cancelled';
|
|
333
340
|
total: number;
|
|
334
341
|
subtotal: number;
|
|
@@ -337,7 +344,7 @@ interface TiquoOrder {
|
|
|
337
344
|
items: TiquoOrderItem[];
|
|
338
345
|
createdAt: number;
|
|
339
346
|
completedAt?: number;
|
|
340
|
-
customerRole: 'primary' | 'attendee' | '
|
|
347
|
+
customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
|
|
341
348
|
}
|
|
342
349
|
interface GetOrdersOptions {
|
|
343
350
|
limit?: number;
|
|
@@ -349,16 +356,95 @@ interface GetOrdersResult {
|
|
|
349
356
|
hasMore: boolean;
|
|
350
357
|
nextCursor?: string;
|
|
351
358
|
}
|
|
359
|
+
interface TiquoReceiptItem {
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
quantity: number;
|
|
363
|
+
unitPrice: number;
|
|
364
|
+
subtotal: number;
|
|
365
|
+
tax: number;
|
|
366
|
+
discount: number;
|
|
367
|
+
total: number;
|
|
368
|
+
type: 'product' | 'booking' | 'custom' | 'membership';
|
|
369
|
+
specialInstructions?: string;
|
|
370
|
+
}
|
|
371
|
+
interface TiquoReceiptBusiness {
|
|
372
|
+
name?: string;
|
|
373
|
+
logo?: string;
|
|
374
|
+
brandName?: string;
|
|
375
|
+
primaryColor?: string;
|
|
376
|
+
vatNumber?: string;
|
|
377
|
+
address?: string;
|
|
378
|
+
city?: string;
|
|
379
|
+
postalCode?: string;
|
|
380
|
+
country?: string;
|
|
381
|
+
email?: string;
|
|
382
|
+
phone?: string;
|
|
383
|
+
sublocationName?: string;
|
|
384
|
+
locationName?: string;
|
|
385
|
+
}
|
|
386
|
+
interface TiquoReceiptCustomer {
|
|
387
|
+
id: string;
|
|
388
|
+
customerNumber: string;
|
|
389
|
+
displayName?: string;
|
|
390
|
+
email?: string;
|
|
391
|
+
}
|
|
392
|
+
interface TiquoReceiptOrder {
|
|
393
|
+
id: string;
|
|
394
|
+
orderNumber: string;
|
|
395
|
+
status: TiquoOrder['status'];
|
|
396
|
+
paymentStatus: TiquoOrder['paymentStatus'];
|
|
397
|
+
currency: string;
|
|
398
|
+
subtotal: number;
|
|
399
|
+
taxTotal: number;
|
|
400
|
+
/** "Tax Inclusive" or "Tax Exclusive" — controls how the receipt should render tax lines. */
|
|
401
|
+
taxSetting?: string;
|
|
402
|
+
discountTotal: number;
|
|
403
|
+
discountName?: string;
|
|
404
|
+
serviceChargeAmount?: number;
|
|
405
|
+
tipAmount?: number;
|
|
406
|
+
total: number;
|
|
407
|
+
refundAmount?: number;
|
|
408
|
+
refundedAt?: number;
|
|
409
|
+
paymentMethod?: string;
|
|
410
|
+
cardBrand?: string;
|
|
411
|
+
cardLast4?: string;
|
|
412
|
+
items: TiquoReceiptItem[];
|
|
413
|
+
createdAt: number;
|
|
414
|
+
completedAt?: number;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* A printable receipt for a single paid/completed order owned by the
|
|
418
|
+
* authenticated customer. Combines order totals, line items, business
|
|
419
|
+
* branding (logo, VAT, address), and the customer's own details so the
|
|
420
|
+
* consumer can render or print the receipt without further API calls.
|
|
421
|
+
*/
|
|
422
|
+
interface TiquoReceipt {
|
|
423
|
+
order: TiquoReceiptOrder;
|
|
424
|
+
business: TiquoReceiptBusiness;
|
|
425
|
+
customer: TiquoReceiptCustomer;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* A booking belonging to the authenticated customer.
|
|
429
|
+
*
|
|
430
|
+
* Note: `draft` bookings (in-progress checkout state) are never returned —
|
|
431
|
+
* they're internal state, not part of the customer's booking history.
|
|
432
|
+
*/
|
|
352
433
|
interface TiquoBooking {
|
|
353
434
|
id: string;
|
|
354
435
|
bookingNumber: string;
|
|
355
|
-
status: '
|
|
436
|
+
status: 'scheduled' | 'confirmed' | 'reminder_sent' | 'waiting_room' | 'waiting_list' | 'checked_in' | 'active' | 'in_progress' | 'completed' | 'cancelled' | 'no_show' | 'rescheduled';
|
|
356
437
|
date: number;
|
|
357
438
|
startTime: string;
|
|
358
439
|
endTime: string;
|
|
359
440
|
duration: number;
|
|
360
441
|
timezone: string;
|
|
361
442
|
attendeeCount: number;
|
|
443
|
+
/**
|
|
444
|
+
* Service title (e.g. "OJAS Listening Room"). Empty string when the
|
|
445
|
+
* underlying service has been deleted — render your own fallback if you
|
|
446
|
+
* need a non-empty display string.
|
|
447
|
+
*/
|
|
362
448
|
serviceName: string;
|
|
363
449
|
serviceId: string;
|
|
364
450
|
sublocationId: string;
|
|
@@ -394,7 +480,7 @@ interface TiquoEnquiry {
|
|
|
394
480
|
updatedAt: string;
|
|
395
481
|
firstResponseAt?: string;
|
|
396
482
|
resolvedAt?: string;
|
|
397
|
-
customerRole: 'primary' | '
|
|
483
|
+
customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
|
|
398
484
|
}
|
|
399
485
|
interface GetEnquiriesOptions {
|
|
400
486
|
limit?: number;
|
|
@@ -464,15 +550,54 @@ declare class TiquoAuth {
|
|
|
464
550
|
*/
|
|
465
551
|
onAuthStateChange(callback: AuthStateChangeCallback): () => void;
|
|
466
552
|
/**
|
|
467
|
-
* Get the authenticated customer's order history
|
|
468
|
-
*
|
|
553
|
+
* Get the authenticated customer's order history.
|
|
554
|
+
*
|
|
555
|
+
* Returns orders across most statuses (draft, processing, completed,
|
|
556
|
+
* cancelled, refunded, open_tab). `lost_cart` (abandoned) and `pending`
|
|
557
|
+
* (unprocessed/awaiting-payment) orders are never exposed — they're
|
|
558
|
+
* internal state, not purchase history.
|
|
559
|
+
*
|
|
560
|
+
* Pass `status` to filter to a single status; pass `cursor` (an order id
|
|
561
|
+
* from a previous `nextCursor`) to paginate. Sorted most recent first.
|
|
469
562
|
*/
|
|
470
563
|
getOrders(options?: GetOrdersOptions): Promise<GetOrdersResult>;
|
|
471
564
|
/**
|
|
472
|
-
* Get the authenticated customer's booking history
|
|
473
|
-
*
|
|
565
|
+
* Get the authenticated customer's booking history.
|
|
566
|
+
*
|
|
567
|
+
* Pass `upcoming: true` to limit to future bookings sorted soonest-first —
|
|
568
|
+
* the common case for rendering "Your upcoming bookings" on a logged-in
|
|
569
|
+
* customer dashboard. Without it, returns all bookings sorted most recent
|
|
570
|
+
* first.
|
|
474
571
|
*/
|
|
475
572
|
getBookings(options?: GetBookingsOptions): Promise<GetBookingsResult>;
|
|
573
|
+
/**
|
|
574
|
+
* Convenience wrapper around `getBookings({ upcoming: true })` for the
|
|
575
|
+
* common "show me my upcoming bookings" case. Results are sorted
|
|
576
|
+
* soonest-first.
|
|
577
|
+
*
|
|
578
|
+
* Only actionable future bookings are returned — `cancelled`, `no_show`,
|
|
579
|
+
* and `rescheduled` bookings are excluded even if their date is in the
|
|
580
|
+
* future, since they're effectively history. Use `getBookings()` without
|
|
581
|
+
* `upcoming: true` if you need those.
|
|
582
|
+
*/
|
|
583
|
+
getUpcomingBookings(options?: Omit<GetBookingsOptions, 'upcoming'>): Promise<GetBookingsResult>;
|
|
584
|
+
/**
|
|
585
|
+
* Get a printable receipt for a single order owned by the authenticated
|
|
586
|
+
* customer. Only resolves for orders that are paid (full or partial),
|
|
587
|
+
* refunded, or completed — drafts and pending orders don't have a receipt
|
|
588
|
+
* yet and will throw `RECEIPT_NOT_AVAILABLE`.
|
|
589
|
+
*
|
|
590
|
+
* The returned payload bundles the order totals & items, the business's
|
|
591
|
+
* receipt branding (logo, VAT number, address), and the customer's own
|
|
592
|
+
* details so the consumer can render or print the receipt without further
|
|
593
|
+
* API calls.
|
|
594
|
+
*
|
|
595
|
+
* Throws `TiquoAuthError` with code:
|
|
596
|
+
* - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
|
|
597
|
+
* it isn't paid/completed yet.
|
|
598
|
+
* - `NOT_AUTHENTICATED` — no valid session.
|
|
599
|
+
*/
|
|
600
|
+
getReceipt(orderId: string): Promise<TiquoReceipt>;
|
|
476
601
|
/**
|
|
477
602
|
* Get the authenticated customer's enquiry history
|
|
478
603
|
* Only returns enquiries for the logged-in customer
|
|
@@ -568,6 +693,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
|
|
|
568
693
|
updateProfile: (updates: ProfileUpdateData) => Promise<ProfileUpdateResult>;
|
|
569
694
|
getOrders: (options?: GetOrdersOptions) => Promise<GetOrdersResult>;
|
|
570
695
|
getBookings: (options?: GetBookingsOptions) => Promise<GetBookingsResult>;
|
|
696
|
+
getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
|
|
697
|
+
getReceipt: (orderId: string) => Promise<TiquoReceipt>;
|
|
571
698
|
getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
|
|
572
699
|
getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
|
|
573
700
|
embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
|
|
@@ -631,4 +758,4 @@ declare class TiquoPhone {
|
|
|
631
758
|
static buildPhone: typeof buildPhone;
|
|
632
759
|
}
|
|
633
760
|
|
|
634
|
-
export { type AuthStateChangeCallback, type CountryPhoneInfo, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type PhoneValidationResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, TiquoPhone, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isDashboardSession, trackCustomerPresence, useTiquoAuth };
|
|
761
|
+
export { type AuthStateChangeCallback, type CountryPhoneInfo, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type PhoneValidationResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, TiquoPhone, type TiquoReceipt, type TiquoReceiptBusiness, type TiquoReceiptCustomer, type TiquoReceiptItem, type TiquoReceiptOrder, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isDashboardSession, trackCustomerPresence, useTiquoAuth };
|
package/dist/index.js
CHANGED
|
@@ -919,8 +919,15 @@ var TiquoAuth = class {
|
|
|
919
919
|
};
|
|
920
920
|
}
|
|
921
921
|
/**
|
|
922
|
-
* Get the authenticated customer's order history
|
|
923
|
-
*
|
|
922
|
+
* Get the authenticated customer's order history.
|
|
923
|
+
*
|
|
924
|
+
* Returns orders across most statuses (draft, processing, completed,
|
|
925
|
+
* cancelled, refunded, open_tab). `lost_cart` (abandoned) and `pending`
|
|
926
|
+
* (unprocessed/awaiting-payment) orders are never exposed — they're
|
|
927
|
+
* internal state, not purchase history.
|
|
928
|
+
*
|
|
929
|
+
* Pass `status` to filter to a single status; pass `cursor` (an order id
|
|
930
|
+
* from a previous `nextCursor`) to paginate. Sorted most recent first.
|
|
924
931
|
*/
|
|
925
932
|
async getOrders(options) {
|
|
926
933
|
await this.ensureValidToken();
|
|
@@ -950,8 +957,12 @@ var TiquoAuth = class {
|
|
|
950
957
|
return result.data || { orders: [], hasMore: false };
|
|
951
958
|
}
|
|
952
959
|
/**
|
|
953
|
-
* Get the authenticated customer's booking history
|
|
954
|
-
*
|
|
960
|
+
* Get the authenticated customer's booking history.
|
|
961
|
+
*
|
|
962
|
+
* Pass `upcoming: true` to limit to future bookings sorted soonest-first —
|
|
963
|
+
* the common case for rendering "Your upcoming bookings" on a logged-in
|
|
964
|
+
* customer dashboard. Without it, returns all bookings sorted most recent
|
|
965
|
+
* first.
|
|
955
966
|
*/
|
|
956
967
|
async getBookings(options) {
|
|
957
968
|
await this.ensureValidToken();
|
|
@@ -983,6 +994,55 @@ var TiquoAuth = class {
|
|
|
983
994
|
const result = await response.json();
|
|
984
995
|
return result.data || { bookings: [], hasMore: false };
|
|
985
996
|
}
|
|
997
|
+
/**
|
|
998
|
+
* Convenience wrapper around `getBookings({ upcoming: true })` for the
|
|
999
|
+
* common "show me my upcoming bookings" case. Results are sorted
|
|
1000
|
+
* soonest-first.
|
|
1001
|
+
*
|
|
1002
|
+
* Only actionable future bookings are returned — `cancelled`, `no_show`,
|
|
1003
|
+
* and `rescheduled` bookings are excluded even if their date is in the
|
|
1004
|
+
* future, since they're effectively history. Use `getBookings()` without
|
|
1005
|
+
* `upcoming: true` if you need those.
|
|
1006
|
+
*/
|
|
1007
|
+
async getUpcomingBookings(options) {
|
|
1008
|
+
return this.getBookings({ ...options, upcoming: true });
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Get a printable receipt for a single order owned by the authenticated
|
|
1012
|
+
* customer. Only resolves for orders that are paid (full or partial),
|
|
1013
|
+
* refunded, or completed — drafts and pending orders don't have a receipt
|
|
1014
|
+
* yet and will throw `RECEIPT_NOT_AVAILABLE`.
|
|
1015
|
+
*
|
|
1016
|
+
* The returned payload bundles the order totals & items, the business's
|
|
1017
|
+
* receipt branding (logo, VAT number, address), and the customer's own
|
|
1018
|
+
* details so the consumer can render or print the receipt without further
|
|
1019
|
+
* API calls.
|
|
1020
|
+
*
|
|
1021
|
+
* Throws `TiquoAuthError` with code:
|
|
1022
|
+
* - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
|
|
1023
|
+
* it isn't paid/completed yet.
|
|
1024
|
+
* - `NOT_AUTHENTICATED` — no valid session.
|
|
1025
|
+
*/
|
|
1026
|
+
async getReceipt(orderId) {
|
|
1027
|
+
await this.ensureValidToken();
|
|
1028
|
+
this.log("Fetching receipt for order:", orderId);
|
|
1029
|
+
const url = new URL(`${this.config.apiEndpoint}/api/client/v1/receipt`);
|
|
1030
|
+
url.searchParams.set("orderId", orderId);
|
|
1031
|
+
const response = await fetch(url.toString(), {
|
|
1032
|
+
method: "GET",
|
|
1033
|
+
headers: {
|
|
1034
|
+
"Authorization": `Bearer ${this.accessToken}`
|
|
1035
|
+
},
|
|
1036
|
+
credentials: "include"
|
|
1037
|
+
});
|
|
1038
|
+
if (!response.ok) {
|
|
1039
|
+
const error = await response.json().catch(() => ({ error: "Failed to get receipt" }));
|
|
1040
|
+
const code = response.status === 404 ? "RECEIPT_NOT_AVAILABLE" : "GET_RECEIPT_FAILED";
|
|
1041
|
+
throw new TiquoAuthError(error.error || "Failed to get receipt", code, response.status);
|
|
1042
|
+
}
|
|
1043
|
+
const result = await response.json();
|
|
1044
|
+
return result.data;
|
|
1045
|
+
}
|
|
986
1046
|
/**
|
|
987
1047
|
* Get the authenticated customer's enquiry history
|
|
988
1048
|
* Only returns enquiries for the logged-in customer
|
|
@@ -1582,6 +1642,8 @@ function useTiquoAuth(auth) {
|
|
|
1582
1642
|
updateProfile: (updates) => auth.updateProfile(updates),
|
|
1583
1643
|
getOrders: (options) => auth.getOrders(options),
|
|
1584
1644
|
getBookings: (options) => auth.getBookings(options),
|
|
1645
|
+
getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
|
|
1646
|
+
getReceipt: (orderId) => auth.getReceipt(orderId),
|
|
1585
1647
|
getEnquiries: (options) => auth.getEnquiries(options),
|
|
1586
1648
|
getIframeToken: (flowId) => auth.getIframeToken(flowId),
|
|
1587
1649
|
embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
|
package/dist/index.mjs
CHANGED
|
@@ -883,8 +883,15 @@ var TiquoAuth = class {
|
|
|
883
883
|
};
|
|
884
884
|
}
|
|
885
885
|
/**
|
|
886
|
-
* Get the authenticated customer's order history
|
|
887
|
-
*
|
|
886
|
+
* Get the authenticated customer's order history.
|
|
887
|
+
*
|
|
888
|
+
* Returns orders across most statuses (draft, processing, completed,
|
|
889
|
+
* cancelled, refunded, open_tab). `lost_cart` (abandoned) and `pending`
|
|
890
|
+
* (unprocessed/awaiting-payment) orders are never exposed — they're
|
|
891
|
+
* internal state, not purchase history.
|
|
892
|
+
*
|
|
893
|
+
* Pass `status` to filter to a single status; pass `cursor` (an order id
|
|
894
|
+
* from a previous `nextCursor`) to paginate. Sorted most recent first.
|
|
888
895
|
*/
|
|
889
896
|
async getOrders(options) {
|
|
890
897
|
await this.ensureValidToken();
|
|
@@ -914,8 +921,12 @@ var TiquoAuth = class {
|
|
|
914
921
|
return result.data || { orders: [], hasMore: false };
|
|
915
922
|
}
|
|
916
923
|
/**
|
|
917
|
-
* Get the authenticated customer's booking history
|
|
918
|
-
*
|
|
924
|
+
* Get the authenticated customer's booking history.
|
|
925
|
+
*
|
|
926
|
+
* Pass `upcoming: true` to limit to future bookings sorted soonest-first —
|
|
927
|
+
* the common case for rendering "Your upcoming bookings" on a logged-in
|
|
928
|
+
* customer dashboard. Without it, returns all bookings sorted most recent
|
|
929
|
+
* first.
|
|
919
930
|
*/
|
|
920
931
|
async getBookings(options) {
|
|
921
932
|
await this.ensureValidToken();
|
|
@@ -947,6 +958,55 @@ var TiquoAuth = class {
|
|
|
947
958
|
const result = await response.json();
|
|
948
959
|
return result.data || { bookings: [], hasMore: false };
|
|
949
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* Convenience wrapper around `getBookings({ upcoming: true })` for the
|
|
963
|
+
* common "show me my upcoming bookings" case. Results are sorted
|
|
964
|
+
* soonest-first.
|
|
965
|
+
*
|
|
966
|
+
* Only actionable future bookings are returned — `cancelled`, `no_show`,
|
|
967
|
+
* and `rescheduled` bookings are excluded even if their date is in the
|
|
968
|
+
* future, since they're effectively history. Use `getBookings()` without
|
|
969
|
+
* `upcoming: true` if you need those.
|
|
970
|
+
*/
|
|
971
|
+
async getUpcomingBookings(options) {
|
|
972
|
+
return this.getBookings({ ...options, upcoming: true });
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Get a printable receipt for a single order owned by the authenticated
|
|
976
|
+
* customer. Only resolves for orders that are paid (full or partial),
|
|
977
|
+
* refunded, or completed — drafts and pending orders don't have a receipt
|
|
978
|
+
* yet and will throw `RECEIPT_NOT_AVAILABLE`.
|
|
979
|
+
*
|
|
980
|
+
* The returned payload bundles the order totals & items, the business's
|
|
981
|
+
* receipt branding (logo, VAT number, address), and the customer's own
|
|
982
|
+
* details so the consumer can render or print the receipt without further
|
|
983
|
+
* API calls.
|
|
984
|
+
*
|
|
985
|
+
* Throws `TiquoAuthError` with code:
|
|
986
|
+
* - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
|
|
987
|
+
* it isn't paid/completed yet.
|
|
988
|
+
* - `NOT_AUTHENTICATED` — no valid session.
|
|
989
|
+
*/
|
|
990
|
+
async getReceipt(orderId) {
|
|
991
|
+
await this.ensureValidToken();
|
|
992
|
+
this.log("Fetching receipt for order:", orderId);
|
|
993
|
+
const url = new URL(`${this.config.apiEndpoint}/api/client/v1/receipt`);
|
|
994
|
+
url.searchParams.set("orderId", orderId);
|
|
995
|
+
const response = await fetch(url.toString(), {
|
|
996
|
+
method: "GET",
|
|
997
|
+
headers: {
|
|
998
|
+
"Authorization": `Bearer ${this.accessToken}`
|
|
999
|
+
},
|
|
1000
|
+
credentials: "include"
|
|
1001
|
+
});
|
|
1002
|
+
if (!response.ok) {
|
|
1003
|
+
const error = await response.json().catch(() => ({ error: "Failed to get receipt" }));
|
|
1004
|
+
const code = response.status === 404 ? "RECEIPT_NOT_AVAILABLE" : "GET_RECEIPT_FAILED";
|
|
1005
|
+
throw new TiquoAuthError(error.error || "Failed to get receipt", code, response.status);
|
|
1006
|
+
}
|
|
1007
|
+
const result = await response.json();
|
|
1008
|
+
return result.data;
|
|
1009
|
+
}
|
|
950
1010
|
/**
|
|
951
1011
|
* Get the authenticated customer's enquiry history
|
|
952
1012
|
* Only returns enquiries for the logged-in customer
|
|
@@ -1546,6 +1606,8 @@ function useTiquoAuth(auth) {
|
|
|
1546
1606
|
updateProfile: (updates) => auth.updateProfile(updates),
|
|
1547
1607
|
getOrders: (options) => auth.getOrders(options),
|
|
1548
1608
|
getBookings: (options) => auth.getBookings(options),
|
|
1609
|
+
getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
|
|
1610
|
+
getReceipt: (orderId) => auth.getReceipt(orderId),
|
|
1549
1611
|
getEnquiries: (options) => auth.getEnquiries(options),
|
|
1550
1612
|
getIframeToken: (flowId) => auth.getIframeToken(flowId),
|
|
1551
1613
|
embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
|
package/package.json
CHANGED