@tiquo/dom-package 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -325,6 +325,12 @@ 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: abandoned `lost_cart` orders are never returned — they're internal
332
+ * marketing-recovery state, not part of the customer's purchase history.
333
+ */
328
334
  interface TiquoOrder {
329
335
  id: string;
330
336
  orderNumber: string;
@@ -337,7 +343,7 @@ interface TiquoOrder {
337
343
  items: TiquoOrderItem[];
338
344
  createdAt: number;
339
345
  completedAt?: number;
340
- customerRole: 'primary' | 'attendee' | 'recipient' | 'billing' | 'guest' | 'other';
346
+ customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
341
347
  }
342
348
  interface GetOrdersOptions {
343
349
  limit?: number;
@@ -349,6 +355,74 @@ interface GetOrdersResult {
349
355
  hasMore: boolean;
350
356
  nextCursor?: string;
351
357
  }
358
+ interface TiquoReceiptItem {
359
+ id: string;
360
+ name: string;
361
+ quantity: number;
362
+ unitPrice: number;
363
+ subtotal: number;
364
+ tax: number;
365
+ discount: number;
366
+ total: number;
367
+ type: 'product' | 'booking' | 'custom' | 'membership';
368
+ specialInstructions?: string;
369
+ }
370
+ interface TiquoReceiptBusiness {
371
+ name?: string;
372
+ logo?: string;
373
+ brandName?: string;
374
+ primaryColor?: string;
375
+ vatNumber?: string;
376
+ address?: string;
377
+ city?: string;
378
+ postalCode?: string;
379
+ country?: string;
380
+ email?: string;
381
+ phone?: string;
382
+ sublocationName?: string;
383
+ locationName?: string;
384
+ }
385
+ interface TiquoReceiptCustomer {
386
+ id: string;
387
+ customerNumber: string;
388
+ displayName?: string;
389
+ email?: string;
390
+ }
391
+ interface TiquoReceiptOrder {
392
+ id: string;
393
+ orderNumber: string;
394
+ status: TiquoOrder['status'];
395
+ paymentStatus: TiquoOrder['paymentStatus'];
396
+ currency: string;
397
+ subtotal: number;
398
+ taxTotal: number;
399
+ /** "Tax Inclusive" or "Tax Exclusive" — controls how the receipt should render tax lines. */
400
+ taxSetting?: string;
401
+ discountTotal: number;
402
+ discountName?: string;
403
+ serviceChargeAmount?: number;
404
+ tipAmount?: number;
405
+ total: number;
406
+ refundAmount?: number;
407
+ refundedAt?: number;
408
+ paymentMethod?: string;
409
+ cardBrand?: string;
410
+ cardLast4?: string;
411
+ items: TiquoReceiptItem[];
412
+ createdAt: number;
413
+ completedAt?: number;
414
+ }
415
+ /**
416
+ * A printable receipt for a single paid/completed order owned by the
417
+ * authenticated customer. Combines order totals, line items, business
418
+ * branding (logo, VAT, address), and the customer's own details so the
419
+ * consumer can render or print the receipt without further API calls.
420
+ */
421
+ interface TiquoReceipt {
422
+ order: TiquoReceiptOrder;
423
+ business: TiquoReceiptBusiness;
424
+ customer: TiquoReceiptCustomer;
425
+ }
352
426
  interface TiquoBooking {
353
427
  id: string;
354
428
  bookingNumber: string;
@@ -394,7 +468,7 @@ interface TiquoEnquiry {
394
468
  updatedAt: string;
395
469
  firstResponseAt?: string;
396
470
  resolvedAt?: string;
397
- customerRole: 'primary' | 'interested' | 'decision_maker' | 'influencer' | 'referrer' | 'other';
471
+ customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
398
472
  }
399
473
  interface GetEnquiriesOptions {
400
474
  limit?: number;
@@ -464,15 +538,48 @@ declare class TiquoAuth {
464
538
  */
465
539
  onAuthStateChange(callback: AuthStateChangeCallback): () => void;
466
540
  /**
467
- * Get the authenticated customer's order history
468
- * Only returns orders for the logged-in customer
541
+ * Get the authenticated customer's order history.
542
+ *
543
+ * Returns orders across every status (draft, pending, processing, completed,
544
+ * cancelled, refunded, open_tab) — except `lost_cart`, which is internal
545
+ * marketing-recovery state and is never exposed to customers.
546
+ *
547
+ * Pass `status` to filter to a single status; pass `cursor` (an order id
548
+ * from a previous `nextCursor`) to paginate. Sorted most recent first.
469
549
  */
470
550
  getOrders(options?: GetOrdersOptions): Promise<GetOrdersResult>;
471
551
  /**
472
- * Get the authenticated customer's booking history
473
- * Only returns bookings for the logged-in customer
552
+ * Get the authenticated customer's booking history.
553
+ *
554
+ * Pass `upcoming: true` to limit to future bookings sorted soonest-first —
555
+ * the common case for rendering "Your upcoming bookings" on a logged-in
556
+ * customer dashboard. Without it, returns all bookings sorted most recent
557
+ * first.
474
558
  */
475
559
  getBookings(options?: GetBookingsOptions): Promise<GetBookingsResult>;
560
+ /**
561
+ * Convenience wrapper around `getBookings({ upcoming: true })` for the
562
+ * common "show me my upcoming bookings" case. Results are sorted
563
+ * soonest-first.
564
+ */
565
+ getUpcomingBookings(options?: Omit<GetBookingsOptions, 'upcoming'>): Promise<GetBookingsResult>;
566
+ /**
567
+ * Get a printable receipt for a single order owned by the authenticated
568
+ * customer. Only resolves for orders that are paid (full or partial),
569
+ * refunded, or completed — drafts and pending orders don't have a receipt
570
+ * yet and will throw `RECEIPT_NOT_AVAILABLE`.
571
+ *
572
+ * The returned payload bundles the order totals & items, the business's
573
+ * receipt branding (logo, VAT number, address), and the customer's own
574
+ * details so the consumer can render or print the receipt without further
575
+ * API calls.
576
+ *
577
+ * Throws `TiquoAuthError` with code:
578
+ * - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
579
+ * it isn't paid/completed yet.
580
+ * - `NOT_AUTHENTICATED` — no valid session.
581
+ */
582
+ getReceipt(orderId: string): Promise<TiquoReceipt>;
476
583
  /**
477
584
  * Get the authenticated customer's enquiry history
478
585
  * Only returns enquiries for the logged-in customer
@@ -568,6 +675,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
568
675
  updateProfile: (updates: ProfileUpdateData) => Promise<ProfileUpdateResult>;
569
676
  getOrders: (options?: GetOrdersOptions) => Promise<GetOrdersResult>;
570
677
  getBookings: (options?: GetBookingsOptions) => Promise<GetBookingsResult>;
678
+ getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
679
+ getReceipt: (orderId: string) => Promise<TiquoReceipt>;
571
680
  getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
572
681
  getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
573
682
  embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
@@ -631,4 +740,4 @@ declare class TiquoPhone {
631
740
  static buildPhone: typeof buildPhone;
632
741
  }
633
742
 
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 };
743
+ 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,6 +325,12 @@ 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: abandoned `lost_cart` orders are never returned — they're internal
332
+ * marketing-recovery state, not part of the customer's purchase history.
333
+ */
328
334
  interface TiquoOrder {
329
335
  id: string;
330
336
  orderNumber: string;
@@ -337,7 +343,7 @@ interface TiquoOrder {
337
343
  items: TiquoOrderItem[];
338
344
  createdAt: number;
339
345
  completedAt?: number;
340
- customerRole: 'primary' | 'attendee' | 'recipient' | 'billing' | 'guest' | 'other';
346
+ customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
341
347
  }
342
348
  interface GetOrdersOptions {
343
349
  limit?: number;
@@ -349,6 +355,74 @@ interface GetOrdersResult {
349
355
  hasMore: boolean;
350
356
  nextCursor?: string;
351
357
  }
358
+ interface TiquoReceiptItem {
359
+ id: string;
360
+ name: string;
361
+ quantity: number;
362
+ unitPrice: number;
363
+ subtotal: number;
364
+ tax: number;
365
+ discount: number;
366
+ total: number;
367
+ type: 'product' | 'booking' | 'custom' | 'membership';
368
+ specialInstructions?: string;
369
+ }
370
+ interface TiquoReceiptBusiness {
371
+ name?: string;
372
+ logo?: string;
373
+ brandName?: string;
374
+ primaryColor?: string;
375
+ vatNumber?: string;
376
+ address?: string;
377
+ city?: string;
378
+ postalCode?: string;
379
+ country?: string;
380
+ email?: string;
381
+ phone?: string;
382
+ sublocationName?: string;
383
+ locationName?: string;
384
+ }
385
+ interface TiquoReceiptCustomer {
386
+ id: string;
387
+ customerNumber: string;
388
+ displayName?: string;
389
+ email?: string;
390
+ }
391
+ interface TiquoReceiptOrder {
392
+ id: string;
393
+ orderNumber: string;
394
+ status: TiquoOrder['status'];
395
+ paymentStatus: TiquoOrder['paymentStatus'];
396
+ currency: string;
397
+ subtotal: number;
398
+ taxTotal: number;
399
+ /** "Tax Inclusive" or "Tax Exclusive" — controls how the receipt should render tax lines. */
400
+ taxSetting?: string;
401
+ discountTotal: number;
402
+ discountName?: string;
403
+ serviceChargeAmount?: number;
404
+ tipAmount?: number;
405
+ total: number;
406
+ refundAmount?: number;
407
+ refundedAt?: number;
408
+ paymentMethod?: string;
409
+ cardBrand?: string;
410
+ cardLast4?: string;
411
+ items: TiquoReceiptItem[];
412
+ createdAt: number;
413
+ completedAt?: number;
414
+ }
415
+ /**
416
+ * A printable receipt for a single paid/completed order owned by the
417
+ * authenticated customer. Combines order totals, line items, business
418
+ * branding (logo, VAT, address), and the customer's own details so the
419
+ * consumer can render or print the receipt without further API calls.
420
+ */
421
+ interface TiquoReceipt {
422
+ order: TiquoReceiptOrder;
423
+ business: TiquoReceiptBusiness;
424
+ customer: TiquoReceiptCustomer;
425
+ }
352
426
  interface TiquoBooking {
353
427
  id: string;
354
428
  bookingNumber: string;
@@ -394,7 +468,7 @@ interface TiquoEnquiry {
394
468
  updatedAt: string;
395
469
  firstResponseAt?: string;
396
470
  resolvedAt?: string;
397
- customerRole: 'primary' | 'interested' | 'decision_maker' | 'influencer' | 'referrer' | 'other';
471
+ customerRole: 'primary' | 'attendee' | 'billing' | 'referrer' | 'other';
398
472
  }
399
473
  interface GetEnquiriesOptions {
400
474
  limit?: number;
@@ -464,15 +538,48 @@ declare class TiquoAuth {
464
538
  */
465
539
  onAuthStateChange(callback: AuthStateChangeCallback): () => void;
466
540
  /**
467
- * Get the authenticated customer's order history
468
- * Only returns orders for the logged-in customer
541
+ * Get the authenticated customer's order history.
542
+ *
543
+ * Returns orders across every status (draft, pending, processing, completed,
544
+ * cancelled, refunded, open_tab) — except `lost_cart`, which is internal
545
+ * marketing-recovery state and is never exposed to customers.
546
+ *
547
+ * Pass `status` to filter to a single status; pass `cursor` (an order id
548
+ * from a previous `nextCursor`) to paginate. Sorted most recent first.
469
549
  */
470
550
  getOrders(options?: GetOrdersOptions): Promise<GetOrdersResult>;
471
551
  /**
472
- * Get the authenticated customer's booking history
473
- * Only returns bookings for the logged-in customer
552
+ * Get the authenticated customer's booking history.
553
+ *
554
+ * Pass `upcoming: true` to limit to future bookings sorted soonest-first —
555
+ * the common case for rendering "Your upcoming bookings" on a logged-in
556
+ * customer dashboard. Without it, returns all bookings sorted most recent
557
+ * first.
474
558
  */
475
559
  getBookings(options?: GetBookingsOptions): Promise<GetBookingsResult>;
560
+ /**
561
+ * Convenience wrapper around `getBookings({ upcoming: true })` for the
562
+ * common "show me my upcoming bookings" case. Results are sorted
563
+ * soonest-first.
564
+ */
565
+ getUpcomingBookings(options?: Omit<GetBookingsOptions, 'upcoming'>): Promise<GetBookingsResult>;
566
+ /**
567
+ * Get a printable receipt for a single order owned by the authenticated
568
+ * customer. Only resolves for orders that are paid (full or partial),
569
+ * refunded, or completed — drafts and pending orders don't have a receipt
570
+ * yet and will throw `RECEIPT_NOT_AVAILABLE`.
571
+ *
572
+ * The returned payload bundles the order totals & items, the business's
573
+ * receipt branding (logo, VAT number, address), and the customer's own
574
+ * details so the consumer can render or print the receipt without further
575
+ * API calls.
576
+ *
577
+ * Throws `TiquoAuthError` with code:
578
+ * - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
579
+ * it isn't paid/completed yet.
580
+ * - `NOT_AUTHENTICATED` — no valid session.
581
+ */
582
+ getReceipt(orderId: string): Promise<TiquoReceipt>;
476
583
  /**
477
584
  * Get the authenticated customer's enquiry history
478
585
  * Only returns enquiries for the logged-in customer
@@ -568,6 +675,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
568
675
  updateProfile: (updates: ProfileUpdateData) => Promise<ProfileUpdateResult>;
569
676
  getOrders: (options?: GetOrdersOptions) => Promise<GetOrdersResult>;
570
677
  getBookings: (options?: GetBookingsOptions) => Promise<GetBookingsResult>;
678
+ getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
679
+ getReceipt: (orderId: string) => Promise<TiquoReceipt>;
571
680
  getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
572
681
  getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
573
682
  embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
@@ -631,4 +740,4 @@ declare class TiquoPhone {
631
740
  static buildPhone: typeof buildPhone;
632
741
  }
633
742
 
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 };
743
+ 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,14 @@ var TiquoAuth = class {
919
919
  };
920
920
  }
921
921
  /**
922
- * Get the authenticated customer's order history
923
- * Only returns orders for the logged-in customer
922
+ * Get the authenticated customer's order history.
923
+ *
924
+ * Returns orders across every status (draft, pending, processing, completed,
925
+ * cancelled, refunded, open_tab) — except `lost_cart`, which is internal
926
+ * marketing-recovery state and is never exposed to customers.
927
+ *
928
+ * Pass `status` to filter to a single status; pass `cursor` (an order id
929
+ * from a previous `nextCursor`) to paginate. Sorted most recent first.
924
930
  */
925
931
  async getOrders(options) {
926
932
  await this.ensureValidToken();
@@ -950,8 +956,12 @@ var TiquoAuth = class {
950
956
  return result.data || { orders: [], hasMore: false };
951
957
  }
952
958
  /**
953
- * Get the authenticated customer's booking history
954
- * Only returns bookings for the logged-in customer
959
+ * Get the authenticated customer's booking history.
960
+ *
961
+ * Pass `upcoming: true` to limit to future bookings sorted soonest-first —
962
+ * the common case for rendering "Your upcoming bookings" on a logged-in
963
+ * customer dashboard. Without it, returns all bookings sorted most recent
964
+ * first.
955
965
  */
956
966
  async getBookings(options) {
957
967
  await this.ensureValidToken();
@@ -983,6 +993,50 @@ var TiquoAuth = class {
983
993
  const result = await response.json();
984
994
  return result.data || { bookings: [], hasMore: false };
985
995
  }
996
+ /**
997
+ * Convenience wrapper around `getBookings({ upcoming: true })` for the
998
+ * common "show me my upcoming bookings" case. Results are sorted
999
+ * soonest-first.
1000
+ */
1001
+ async getUpcomingBookings(options) {
1002
+ return this.getBookings({ ...options, upcoming: true });
1003
+ }
1004
+ /**
1005
+ * Get a printable receipt for a single order owned by the authenticated
1006
+ * customer. Only resolves for orders that are paid (full or partial),
1007
+ * refunded, or completed — drafts and pending orders don't have a receipt
1008
+ * yet and will throw `RECEIPT_NOT_AVAILABLE`.
1009
+ *
1010
+ * The returned payload bundles the order totals & items, the business's
1011
+ * receipt branding (logo, VAT number, address), and the customer's own
1012
+ * details so the consumer can render or print the receipt without further
1013
+ * API calls.
1014
+ *
1015
+ * Throws `TiquoAuthError` with code:
1016
+ * - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
1017
+ * it isn't paid/completed yet.
1018
+ * - `NOT_AUTHENTICATED` — no valid session.
1019
+ */
1020
+ async getReceipt(orderId) {
1021
+ await this.ensureValidToken();
1022
+ this.log("Fetching receipt for order:", orderId);
1023
+ const url = new URL(`${this.config.apiEndpoint}/api/client/v1/receipt`);
1024
+ url.searchParams.set("orderId", orderId);
1025
+ const response = await fetch(url.toString(), {
1026
+ method: "GET",
1027
+ headers: {
1028
+ "Authorization": `Bearer ${this.accessToken}`
1029
+ },
1030
+ credentials: "include"
1031
+ });
1032
+ if (!response.ok) {
1033
+ const error = await response.json().catch(() => ({ error: "Failed to get receipt" }));
1034
+ const code = response.status === 404 ? "RECEIPT_NOT_AVAILABLE" : "GET_RECEIPT_FAILED";
1035
+ throw new TiquoAuthError(error.error || "Failed to get receipt", code, response.status);
1036
+ }
1037
+ const result = await response.json();
1038
+ return result.data;
1039
+ }
986
1040
  /**
987
1041
  * Get the authenticated customer's enquiry history
988
1042
  * Only returns enquiries for the logged-in customer
@@ -1582,6 +1636,8 @@ function useTiquoAuth(auth) {
1582
1636
  updateProfile: (updates) => auth.updateProfile(updates),
1583
1637
  getOrders: (options) => auth.getOrders(options),
1584
1638
  getBookings: (options) => auth.getBookings(options),
1639
+ getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
1640
+ getReceipt: (orderId) => auth.getReceipt(orderId),
1585
1641
  getEnquiries: (options) => auth.getEnquiries(options),
1586
1642
  getIframeToken: (flowId) => auth.getIframeToken(flowId),
1587
1643
  embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
package/dist/index.mjs CHANGED
@@ -883,8 +883,14 @@ var TiquoAuth = class {
883
883
  };
884
884
  }
885
885
  /**
886
- * Get the authenticated customer's order history
887
- * Only returns orders for the logged-in customer
886
+ * Get the authenticated customer's order history.
887
+ *
888
+ * Returns orders across every status (draft, pending, processing, completed,
889
+ * cancelled, refunded, open_tab) — except `lost_cart`, which is internal
890
+ * marketing-recovery state and is never exposed to customers.
891
+ *
892
+ * Pass `status` to filter to a single status; pass `cursor` (an order id
893
+ * from a previous `nextCursor`) to paginate. Sorted most recent first.
888
894
  */
889
895
  async getOrders(options) {
890
896
  await this.ensureValidToken();
@@ -914,8 +920,12 @@ var TiquoAuth = class {
914
920
  return result.data || { orders: [], hasMore: false };
915
921
  }
916
922
  /**
917
- * Get the authenticated customer's booking history
918
- * Only returns bookings for the logged-in customer
923
+ * Get the authenticated customer's booking history.
924
+ *
925
+ * Pass `upcoming: true` to limit to future bookings sorted soonest-first —
926
+ * the common case for rendering "Your upcoming bookings" on a logged-in
927
+ * customer dashboard. Without it, returns all bookings sorted most recent
928
+ * first.
919
929
  */
920
930
  async getBookings(options) {
921
931
  await this.ensureValidToken();
@@ -947,6 +957,50 @@ var TiquoAuth = class {
947
957
  const result = await response.json();
948
958
  return result.data || { bookings: [], hasMore: false };
949
959
  }
960
+ /**
961
+ * Convenience wrapper around `getBookings({ upcoming: true })` for the
962
+ * common "show me my upcoming bookings" case. Results are sorted
963
+ * soonest-first.
964
+ */
965
+ async getUpcomingBookings(options) {
966
+ return this.getBookings({ ...options, upcoming: true });
967
+ }
968
+ /**
969
+ * Get a printable receipt for a single order owned by the authenticated
970
+ * customer. Only resolves for orders that are paid (full or partial),
971
+ * refunded, or completed — drafts and pending orders don't have a receipt
972
+ * yet and will throw `RECEIPT_NOT_AVAILABLE`.
973
+ *
974
+ * The returned payload bundles the order totals & items, the business's
975
+ * receipt branding (logo, VAT number, address), and the customer's own
976
+ * details so the consumer can render or print the receipt without further
977
+ * API calls.
978
+ *
979
+ * Throws `TiquoAuthError` with code:
980
+ * - `RECEIPT_NOT_AVAILABLE` — order doesn't exist for this customer, or
981
+ * it isn't paid/completed yet.
982
+ * - `NOT_AUTHENTICATED` — no valid session.
983
+ */
984
+ async getReceipt(orderId) {
985
+ await this.ensureValidToken();
986
+ this.log("Fetching receipt for order:", orderId);
987
+ const url = new URL(`${this.config.apiEndpoint}/api/client/v1/receipt`);
988
+ url.searchParams.set("orderId", orderId);
989
+ const response = await fetch(url.toString(), {
990
+ method: "GET",
991
+ headers: {
992
+ "Authorization": `Bearer ${this.accessToken}`
993
+ },
994
+ credentials: "include"
995
+ });
996
+ if (!response.ok) {
997
+ const error = await response.json().catch(() => ({ error: "Failed to get receipt" }));
998
+ const code = response.status === 404 ? "RECEIPT_NOT_AVAILABLE" : "GET_RECEIPT_FAILED";
999
+ throw new TiquoAuthError(error.error || "Failed to get receipt", code, response.status);
1000
+ }
1001
+ const result = await response.json();
1002
+ return result.data;
1003
+ }
950
1004
  /**
951
1005
  * Get the authenticated customer's enquiry history
952
1006
  * Only returns enquiries for the logged-in customer
@@ -1546,6 +1600,8 @@ function useTiquoAuth(auth) {
1546
1600
  updateProfile: (updates) => auth.updateProfile(updates),
1547
1601
  getOrders: (options) => auth.getOrders(options),
1548
1602
  getBookings: (options) => auth.getBookings(options),
1603
+ getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
1604
+ getReceipt: (orderId) => auth.getReceipt(orderId),
1549
1605
  getEnquiries: (options) => auth.getEnquiries(options),
1550
1606
  getIframeToken: (flowId) => auth.getIframeToken(flowId),
1551
1607
  embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiquo/dom-package",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "description": "Tiquo SDK for third-party websites - authentication, customer profiles, orders, bookings, and enquiries",
5
5
  "sideEffects": true,
6
6
  "publishConfig": {