@tiquo/dom-package 1.4.0 → 1.5.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
@@ -328,13 +328,14 @@ interface TiquoOrderItem {
328
328
  /**
329
329
  * An order belonging to the authenticated customer.
330
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.
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.
333
334
  */
334
335
  interface TiquoOrder {
335
336
  id: string;
336
337
  orderNumber: string;
337
- status: 'draft' | 'pending' | 'processing' | 'completed' | 'cancelled' | 'refunded' | 'open_tab';
338
+ status: 'draft' | 'processing' | 'completed' | 'cancelled' | 'refunded' | 'open_tab';
338
339
  paymentStatus: 'pending' | 'paid' | 'partial' | 'refunded' | 'partially_refunded' | 'failed' | 'cancelled';
339
340
  total: number;
340
341
  subtotal: number;
@@ -423,16 +424,27 @@ interface TiquoReceipt {
423
424
  business: TiquoReceiptBusiness;
424
425
  customer: TiquoReceiptCustomer;
425
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
+ */
426
433
  interface TiquoBooking {
427
434
  id: string;
428
435
  bookingNumber: string;
429
- status: 'draft' | 'scheduled' | 'confirmed' | 'reminder_sent' | 'waiting_room' | 'waiting_list' | 'checked_in' | 'active' | 'in_progress' | 'completed' | 'cancelled' | 'no_show' | 'rescheduled';
436
+ status: 'scheduled' | 'confirmed' | 'reminder_sent' | 'waiting_room' | 'waiting_list' | 'checked_in' | 'active' | 'in_progress' | 'completed' | 'cancelled' | 'no_show' | 'rescheduled';
430
437
  date: number;
431
438
  startTime: string;
432
439
  endTime: string;
433
440
  duration: number;
434
441
  timezone: string;
435
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
+ */
436
448
  serviceName: string;
437
449
  serviceId: string;
438
450
  sublocationId: string;
@@ -480,6 +492,80 @@ interface GetEnquiriesResult {
480
492
  hasMore: boolean;
481
493
  nextCursor?: string;
482
494
  }
495
+ type TiquoCompanyRelationship = 'employee' | 'contractor' | 'manager' | 'executive' | 'owner' | 'contact' | 'other';
496
+ /**
497
+ * The authenticated customer's membership in a company. Each company the
498
+ * customer belongs to has its own membership record — a customer can be
499
+ * an admin of one company and a regular employee of another.
500
+ */
501
+ interface TiquoCompanyMembership {
502
+ relationship: TiquoCompanyRelationship;
503
+ title?: string;
504
+ department?: string;
505
+ isPrimaryContact: boolean;
506
+ /** True when this customer can call `getCompanyColleagues(company.id)`. */
507
+ isCompanyAdmin: boolean;
508
+ startDate?: number;
509
+ }
510
+ /**
511
+ * A company the authenticated customer is a member of. Bundles the
512
+ * company's public-ish details with the caller's own role inside it
513
+ * (`membership`). CRM/financial fields are intentionally omitted.
514
+ */
515
+ interface TiquoCompany {
516
+ id: string;
517
+ name: string;
518
+ displayName?: string;
519
+ companyNumber: string;
520
+ description?: string;
521
+ email?: string;
522
+ phone?: string;
523
+ website?: string;
524
+ websites?: string[];
525
+ logo?: string;
526
+ addressLine1?: string;
527
+ addressLine2?: string;
528
+ city?: string;
529
+ state?: string;
530
+ postalCode?: string;
531
+ country?: string;
532
+ industry?: string;
533
+ companySize?: '1-10' | '11-50' | '51-200' | '201-500' | '501-1000' | '1000+';
534
+ status: 'active' | 'inactive' | 'archived';
535
+ type?: 'client' | 'prospect' | 'vendor' | 'partner' | 'other';
536
+ membership: TiquoCompanyMembership;
537
+ }
538
+ interface GetCompaniesResult {
539
+ companies: TiquoCompany[];
540
+ }
541
+ /**
542
+ * A colleague — another customer in the same company. Returned only to
543
+ * Company Admins via `getCompanyColleagues()`. Limited to display-card
544
+ * info; CRM/financial data is never exposed.
545
+ */
546
+ interface TiquoCompanyColleague {
547
+ id: string;
548
+ firstName?: string;
549
+ lastName?: string;
550
+ displayName?: string;
551
+ profilePhoto?: string;
552
+ email?: string;
553
+ phone?: string;
554
+ relationship: TiquoCompanyRelationship;
555
+ title?: string;
556
+ department?: string;
557
+ isPrimaryContact: boolean;
558
+ isCompanyAdmin: boolean;
559
+ /** True when this colleague is the authenticated customer themselves. */
560
+ isSelf: boolean;
561
+ }
562
+ interface GetCompanyColleaguesResult {
563
+ company: {
564
+ id: string;
565
+ name: string;
566
+ };
567
+ colleagues: TiquoCompanyColleague[];
568
+ }
483
569
  type AuthStateChangeCallback = (session: TiquoSession | null) => void;
484
570
  declare class TiquoAuthError extends Error {
485
571
  code: string;
@@ -540,9 +626,10 @@ declare class TiquoAuth {
540
626
  /**
541
627
  * Get the authenticated customer's order history.
542
628
  *
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.
629
+ * Returns orders across most statuses (draft, processing, completed,
630
+ * cancelled, refunded, open_tab). `lost_cart` (abandoned) and `pending`
631
+ * (unprocessed/awaiting-payment) orders are never exposed they're
632
+ * internal state, not purchase history.
546
633
  *
547
634
  * Pass `status` to filter to a single status; pass `cursor` (an order id
548
635
  * from a previous `nextCursor`) to paginate. Sorted most recent first.
@@ -561,6 +648,11 @@ declare class TiquoAuth {
561
648
  * Convenience wrapper around `getBookings({ upcoming: true })` for the
562
649
  * common "show me my upcoming bookings" case. Results are sorted
563
650
  * soonest-first.
651
+ *
652
+ * Only actionable future bookings are returned — `cancelled`, `no_show`,
653
+ * and `rescheduled` bookings are excluded even if their date is in the
654
+ * future, since they're effectively history. Use `getBookings()` without
655
+ * `upcoming: true` if you need those.
564
656
  */
565
657
  getUpcomingBookings(options?: Omit<GetBookingsOptions, 'upcoming'>): Promise<GetBookingsResult>;
566
658
  /**
@@ -585,6 +677,32 @@ declare class TiquoAuth {
585
677
  * Only returns enquiries for the logged-in customer
586
678
  */
587
679
  getEnquiries(options?: GetEnquiriesOptions): Promise<GetEnquiriesResult>;
680
+ /**
681
+ * Get the companies the authenticated customer belongs to.
682
+ *
683
+ * Each entry includes the customer's role inside that company via
684
+ * `membership` — branch on `membership.isCompanyAdmin` to decide whether
685
+ * to render admin features (e.g. a colleagues list).
686
+ *
687
+ * Returns an empty array (not an error) when the customer isn't a
688
+ * member of any company.
689
+ */
690
+ getCompanies(): Promise<GetCompaniesResult>;
691
+ /**
692
+ * Get the colleagues (other customers) inside a company the authenticated
693
+ * customer is a member of.
694
+ *
695
+ * Restricted to Company Admins — if the caller isn't flagged as
696
+ * `isCompanyAdmin` on that company, this throws `TiquoAuthError` with
697
+ * code `NOT_COMPANY_ADMIN` (status 403). Check `membership.isCompanyAdmin`
698
+ * from `getCompanies()` before calling this if you want to render the
699
+ * admin UI conditionally.
700
+ *
701
+ * Each colleague includes basic contact info and their relationship to
702
+ * the company. The authenticated customer is included in the list with
703
+ * `isSelf: true` so the UI can highlight or skip them.
704
+ */
705
+ getCompanyColleagues(companyId: string): Promise<GetCompanyColleaguesResult>;
588
706
  /**
589
707
  * Generate a short-lived token for customer flow iframe authentication
590
708
  */
@@ -678,6 +796,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
678
796
  getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
679
797
  getReceipt: (orderId: string) => Promise<TiquoReceipt>;
680
798
  getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
799
+ getCompanies: () => Promise<GetCompaniesResult>;
800
+ getCompanyColleagues: (companyId: string) => Promise<GetCompanyColleaguesResult>;
681
801
  getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
682
802
  embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
683
803
  width?: string;
@@ -740,4 +860,4 @@ declare class TiquoPhone {
740
860
  static buildPhone: typeof buildPhone;
741
861
  }
742
862
 
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 };
863
+ export { type AuthStateChangeCallback, type CountryPhoneInfo, type GetBookingsOptions, type GetBookingsResult, type GetCompaniesResult, type GetCompanyColleaguesResult, 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 TiquoCompany, type TiquoCompanyColleague, type TiquoCompanyMembership, type TiquoCompanyRelationship, 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
@@ -328,13 +328,14 @@ interface TiquoOrderItem {
328
328
  /**
329
329
  * An order belonging to the authenticated customer.
330
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.
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.
333
334
  */
334
335
  interface TiquoOrder {
335
336
  id: string;
336
337
  orderNumber: string;
337
- status: 'draft' | 'pending' | 'processing' | 'completed' | 'cancelled' | 'refunded' | 'open_tab';
338
+ status: 'draft' | 'processing' | 'completed' | 'cancelled' | 'refunded' | 'open_tab';
338
339
  paymentStatus: 'pending' | 'paid' | 'partial' | 'refunded' | 'partially_refunded' | 'failed' | 'cancelled';
339
340
  total: number;
340
341
  subtotal: number;
@@ -423,16 +424,27 @@ interface TiquoReceipt {
423
424
  business: TiquoReceiptBusiness;
424
425
  customer: TiquoReceiptCustomer;
425
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
+ */
426
433
  interface TiquoBooking {
427
434
  id: string;
428
435
  bookingNumber: string;
429
- status: 'draft' | 'scheduled' | 'confirmed' | 'reminder_sent' | 'waiting_room' | 'waiting_list' | 'checked_in' | 'active' | 'in_progress' | 'completed' | 'cancelled' | 'no_show' | 'rescheduled';
436
+ status: 'scheduled' | 'confirmed' | 'reminder_sent' | 'waiting_room' | 'waiting_list' | 'checked_in' | 'active' | 'in_progress' | 'completed' | 'cancelled' | 'no_show' | 'rescheduled';
430
437
  date: number;
431
438
  startTime: string;
432
439
  endTime: string;
433
440
  duration: number;
434
441
  timezone: string;
435
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
+ */
436
448
  serviceName: string;
437
449
  serviceId: string;
438
450
  sublocationId: string;
@@ -480,6 +492,80 @@ interface GetEnquiriesResult {
480
492
  hasMore: boolean;
481
493
  nextCursor?: string;
482
494
  }
495
+ type TiquoCompanyRelationship = 'employee' | 'contractor' | 'manager' | 'executive' | 'owner' | 'contact' | 'other';
496
+ /**
497
+ * The authenticated customer's membership in a company. Each company the
498
+ * customer belongs to has its own membership record — a customer can be
499
+ * an admin of one company and a regular employee of another.
500
+ */
501
+ interface TiquoCompanyMembership {
502
+ relationship: TiquoCompanyRelationship;
503
+ title?: string;
504
+ department?: string;
505
+ isPrimaryContact: boolean;
506
+ /** True when this customer can call `getCompanyColleagues(company.id)`. */
507
+ isCompanyAdmin: boolean;
508
+ startDate?: number;
509
+ }
510
+ /**
511
+ * A company the authenticated customer is a member of. Bundles the
512
+ * company's public-ish details with the caller's own role inside it
513
+ * (`membership`). CRM/financial fields are intentionally omitted.
514
+ */
515
+ interface TiquoCompany {
516
+ id: string;
517
+ name: string;
518
+ displayName?: string;
519
+ companyNumber: string;
520
+ description?: string;
521
+ email?: string;
522
+ phone?: string;
523
+ website?: string;
524
+ websites?: string[];
525
+ logo?: string;
526
+ addressLine1?: string;
527
+ addressLine2?: string;
528
+ city?: string;
529
+ state?: string;
530
+ postalCode?: string;
531
+ country?: string;
532
+ industry?: string;
533
+ companySize?: '1-10' | '11-50' | '51-200' | '201-500' | '501-1000' | '1000+';
534
+ status: 'active' | 'inactive' | 'archived';
535
+ type?: 'client' | 'prospect' | 'vendor' | 'partner' | 'other';
536
+ membership: TiquoCompanyMembership;
537
+ }
538
+ interface GetCompaniesResult {
539
+ companies: TiquoCompany[];
540
+ }
541
+ /**
542
+ * A colleague — another customer in the same company. Returned only to
543
+ * Company Admins via `getCompanyColleagues()`. Limited to display-card
544
+ * info; CRM/financial data is never exposed.
545
+ */
546
+ interface TiquoCompanyColleague {
547
+ id: string;
548
+ firstName?: string;
549
+ lastName?: string;
550
+ displayName?: string;
551
+ profilePhoto?: string;
552
+ email?: string;
553
+ phone?: string;
554
+ relationship: TiquoCompanyRelationship;
555
+ title?: string;
556
+ department?: string;
557
+ isPrimaryContact: boolean;
558
+ isCompanyAdmin: boolean;
559
+ /** True when this colleague is the authenticated customer themselves. */
560
+ isSelf: boolean;
561
+ }
562
+ interface GetCompanyColleaguesResult {
563
+ company: {
564
+ id: string;
565
+ name: string;
566
+ };
567
+ colleagues: TiquoCompanyColleague[];
568
+ }
483
569
  type AuthStateChangeCallback = (session: TiquoSession | null) => void;
484
570
  declare class TiquoAuthError extends Error {
485
571
  code: string;
@@ -540,9 +626,10 @@ declare class TiquoAuth {
540
626
  /**
541
627
  * Get the authenticated customer's order history.
542
628
  *
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.
629
+ * Returns orders across most statuses (draft, processing, completed,
630
+ * cancelled, refunded, open_tab). `lost_cart` (abandoned) and `pending`
631
+ * (unprocessed/awaiting-payment) orders are never exposed they're
632
+ * internal state, not purchase history.
546
633
  *
547
634
  * Pass `status` to filter to a single status; pass `cursor` (an order id
548
635
  * from a previous `nextCursor`) to paginate. Sorted most recent first.
@@ -561,6 +648,11 @@ declare class TiquoAuth {
561
648
  * Convenience wrapper around `getBookings({ upcoming: true })` for the
562
649
  * common "show me my upcoming bookings" case. Results are sorted
563
650
  * soonest-first.
651
+ *
652
+ * Only actionable future bookings are returned — `cancelled`, `no_show`,
653
+ * and `rescheduled` bookings are excluded even if their date is in the
654
+ * future, since they're effectively history. Use `getBookings()` without
655
+ * `upcoming: true` if you need those.
564
656
  */
565
657
  getUpcomingBookings(options?: Omit<GetBookingsOptions, 'upcoming'>): Promise<GetBookingsResult>;
566
658
  /**
@@ -585,6 +677,32 @@ declare class TiquoAuth {
585
677
  * Only returns enquiries for the logged-in customer
586
678
  */
587
679
  getEnquiries(options?: GetEnquiriesOptions): Promise<GetEnquiriesResult>;
680
+ /**
681
+ * Get the companies the authenticated customer belongs to.
682
+ *
683
+ * Each entry includes the customer's role inside that company via
684
+ * `membership` — branch on `membership.isCompanyAdmin` to decide whether
685
+ * to render admin features (e.g. a colleagues list).
686
+ *
687
+ * Returns an empty array (not an error) when the customer isn't a
688
+ * member of any company.
689
+ */
690
+ getCompanies(): Promise<GetCompaniesResult>;
691
+ /**
692
+ * Get the colleagues (other customers) inside a company the authenticated
693
+ * customer is a member of.
694
+ *
695
+ * Restricted to Company Admins — if the caller isn't flagged as
696
+ * `isCompanyAdmin` on that company, this throws `TiquoAuthError` with
697
+ * code `NOT_COMPANY_ADMIN` (status 403). Check `membership.isCompanyAdmin`
698
+ * from `getCompanies()` before calling this if you want to render the
699
+ * admin UI conditionally.
700
+ *
701
+ * Each colleague includes basic contact info and their relationship to
702
+ * the company. The authenticated customer is included in the list with
703
+ * `isSelf: true` so the UI can highlight or skip them.
704
+ */
705
+ getCompanyColleagues(companyId: string): Promise<GetCompanyColleaguesResult>;
588
706
  /**
589
707
  * Generate a short-lived token for customer flow iframe authentication
590
708
  */
@@ -678,6 +796,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
678
796
  getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
679
797
  getReceipt: (orderId: string) => Promise<TiquoReceipt>;
680
798
  getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
799
+ getCompanies: () => Promise<GetCompaniesResult>;
800
+ getCompanyColleagues: (companyId: string) => Promise<GetCompanyColleaguesResult>;
681
801
  getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
682
802
  embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
683
803
  width?: string;
@@ -740,4 +860,4 @@ declare class TiquoPhone {
740
860
  static buildPhone: typeof buildPhone;
741
861
  }
742
862
 
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 };
863
+ export { type AuthStateChangeCallback, type CountryPhoneInfo, type GetBookingsOptions, type GetBookingsResult, type GetCompaniesResult, type GetCompanyColleaguesResult, 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 TiquoCompany, type TiquoCompanyColleague, type TiquoCompanyMembership, type TiquoCompanyRelationship, 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
@@ -921,9 +921,10 @@ var TiquoAuth = class {
921
921
  /**
922
922
  * Get the authenticated customer's order history.
923
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.
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.
927
928
  *
928
929
  * Pass `status` to filter to a single status; pass `cursor` (an order id
929
930
  * from a previous `nextCursor`) to paginate. Sorted most recent first.
@@ -997,6 +998,11 @@ var TiquoAuth = class {
997
998
  * Convenience wrapper around `getBookings({ upcoming: true })` for the
998
999
  * common "show me my upcoming bookings" case. Results are sorted
999
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.
1000
1006
  */
1001
1007
  async getUpcomingBookings(options) {
1002
1008
  return this.getBookings({ ...options, upcoming: true });
@@ -1068,6 +1074,67 @@ var TiquoAuth = class {
1068
1074
  const result = await response.json();
1069
1075
  return result.data || { enquiries: [], hasMore: false };
1070
1076
  }
1077
+ /**
1078
+ * Get the companies the authenticated customer belongs to.
1079
+ *
1080
+ * Each entry includes the customer's role inside that company via
1081
+ * `membership` — branch on `membership.isCompanyAdmin` to decide whether
1082
+ * to render admin features (e.g. a colleagues list).
1083
+ *
1084
+ * Returns an empty array (not an error) when the customer isn't a
1085
+ * member of any company.
1086
+ */
1087
+ async getCompanies() {
1088
+ await this.ensureValidToken();
1089
+ this.log("Fetching customer companies");
1090
+ const response = await fetch(`${this.config.apiEndpoint}/api/client/v1/companies`, {
1091
+ method: "GET",
1092
+ headers: {
1093
+ "Authorization": `Bearer ${this.accessToken}`
1094
+ },
1095
+ credentials: "include"
1096
+ });
1097
+ if (!response.ok) {
1098
+ const error = await response.json().catch(() => ({ error: "Failed to get companies" }));
1099
+ throw new TiquoAuthError(error.error || "Failed to get companies", "GET_COMPANIES_FAILED", response.status);
1100
+ }
1101
+ const result = await response.json();
1102
+ return result.data || { companies: [] };
1103
+ }
1104
+ /**
1105
+ * Get the colleagues (other customers) inside a company the authenticated
1106
+ * customer is a member of.
1107
+ *
1108
+ * Restricted to Company Admins — if the caller isn't flagged as
1109
+ * `isCompanyAdmin` on that company, this throws `TiquoAuthError` with
1110
+ * code `NOT_COMPANY_ADMIN` (status 403). Check `membership.isCompanyAdmin`
1111
+ * from `getCompanies()` before calling this if you want to render the
1112
+ * admin UI conditionally.
1113
+ *
1114
+ * Each colleague includes basic contact info and their relationship to
1115
+ * the company. The authenticated customer is included in the list with
1116
+ * `isSelf: true` so the UI can highlight or skip them.
1117
+ */
1118
+ async getCompanyColleagues(companyId) {
1119
+ await this.ensureValidToken();
1120
+ this.log("Fetching company colleagues for:", companyId);
1121
+ const url = new URL(`${this.config.apiEndpoint}/api/client/v1/companies/colleagues`);
1122
+ url.searchParams.set("companyId", companyId);
1123
+ const response = await fetch(url.toString(), {
1124
+ method: "GET",
1125
+ headers: {
1126
+ "Authorization": `Bearer ${this.accessToken}`
1127
+ },
1128
+ credentials: "include"
1129
+ });
1130
+ if (!response.ok) {
1131
+ const error = await response.json().catch(() => ({ error: "Failed to get colleagues" }));
1132
+ const code = response.status === 403 ? "NOT_COMPANY_ADMIN" : "GET_COLLEAGUES_FAILED";
1133
+ throw new TiquoAuthError(error.error || "Failed to get colleagues", code, response.status);
1134
+ }
1135
+ const result = await response.json();
1136
+ return result.data;
1137
+ }
1071
1138
  /**
1072
1139
  * Generate a short-lived token for customer flow iframe authentication
1073
1140
  */
@@ -1639,6 +1706,8 @@ function useTiquoAuth(auth) {
1639
1706
  getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
1640
1707
  getReceipt: (orderId) => auth.getReceipt(orderId),
1641
1708
  getEnquiries: (options) => auth.getEnquiries(options),
1709
+ getCompanies: () => auth.getCompanies(),
1710
+ getCompanyColleagues: (companyId) => auth.getCompanyColleagues(companyId),
1642
1711
  getIframeToken: (flowId) => auth.getIframeToken(flowId),
1643
1712
  embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
1644
1713
  onAuthStateChange: (cb) => auth.onAuthStateChange(cb)
package/dist/index.mjs CHANGED
@@ -885,9 +885,10 @@ var TiquoAuth = class {
885
885
  /**
886
886
  * Get the authenticated customer's order history.
887
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.
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.
891
892
  *
892
893
  * Pass `status` to filter to a single status; pass `cursor` (an order id
893
894
  * from a previous `nextCursor`) to paginate. Sorted most recent first.
@@ -961,6 +962,11 @@ var TiquoAuth = class {
961
962
  * Convenience wrapper around `getBookings({ upcoming: true })` for the
962
963
  * common "show me my upcoming bookings" case. Results are sorted
963
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.
964
970
  */
965
971
  async getUpcomingBookings(options) {
966
972
  return this.getBookings({ ...options, upcoming: true });
@@ -1032,6 +1038,67 @@ var TiquoAuth = class {
1032
1038
  const result = await response.json();
1033
1039
  return result.data || { enquiries: [], hasMore: false };
1034
1040
  }
1041
+ /**
1042
+ * Get the companies the authenticated customer belongs to.
1043
+ *
1044
+ * Each entry includes the customer's role inside that company via
1045
+ * `membership` — branch on `membership.isCompanyAdmin` to decide whether
1046
+ * to render admin features (e.g. a colleagues list).
1047
+ *
1048
+ * Returns an empty array (not an error) when the customer isn't a
1049
+ * member of any company.
1050
+ */
1051
+ async getCompanies() {
1052
+ await this.ensureValidToken();
1053
+ this.log("Fetching customer companies");
1054
+ const response = await fetch(`${this.config.apiEndpoint}/api/client/v1/companies`, {
1055
+ method: "GET",
1056
+ headers: {
1057
+ "Authorization": `Bearer ${this.accessToken}`
1058
+ },
1059
+ credentials: "include"
1060
+ });
1061
+ if (!response.ok) {
1062
+ const error = await response.json().catch(() => ({ error: "Failed to get companies" }));
1063
+ throw new TiquoAuthError(error.error || "Failed to get companies", "GET_COMPANIES_FAILED", response.status);
1064
+ }
1065
+ const result = await response.json();
1066
+ return result.data || { companies: [] };
1067
+ }
1068
+ /**
1069
+ * Get the colleagues (other customers) inside a company the authenticated
1070
+ * customer is a member of.
1071
+ *
1072
+ * Restricted to Company Admins — if the caller isn't flagged as
1073
+ * `isCompanyAdmin` on that company, this throws `TiquoAuthError` with
1074
+ * code `NOT_COMPANY_ADMIN` (status 403). Check `membership.isCompanyAdmin`
1075
+ * from `getCompanies()` before calling this if you want to render the
1076
+ * admin UI conditionally.
1077
+ *
1078
+ * Each colleague includes basic contact info and their relationship to
1079
+ * the company. The authenticated customer is included in the list with
1080
+ * `isSelf: true` so the UI can highlight or skip them.
1081
+ */
1082
+ async getCompanyColleagues(companyId) {
1083
+ await this.ensureValidToken();
1084
+ this.log("Fetching company colleagues for:", companyId);
1085
+ const url = new URL(`${this.config.apiEndpoint}/api/client/v1/companies/colleagues`);
1086
+ url.searchParams.set("companyId", companyId);
1087
+ const response = await fetch(url.toString(), {
1088
+ method: "GET",
1089
+ headers: {
1090
+ "Authorization": `Bearer ${this.accessToken}`
1091
+ },
1092
+ credentials: "include"
1093
+ });
1094
+ if (!response.ok) {
1095
+ const error = await response.json().catch(() => ({ error: "Failed to get colleagues" }));
1096
+ const code = response.status === 403 ? "NOT_COMPANY_ADMIN" : "GET_COLLEAGUES_FAILED";
1097
+ throw new TiquoAuthError(error.error || "Failed to get colleagues", code, response.status);
1098
+ }
1099
+ const result = await response.json();
1100
+ return result.data;
1101
+ }
1035
1102
  /**
1036
1103
  * Generate a short-lived token for customer flow iframe authentication
1037
1104
  */
@@ -1603,6 +1670,8 @@ function useTiquoAuth(auth) {
1603
1670
  getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
1604
1671
  getReceipt: (orderId) => auth.getReceipt(orderId),
1605
1672
  getEnquiries: (options) => auth.getEnquiries(options),
1673
+ getCompanies: () => auth.getCompanies(),
1674
+ getCompanyColleagues: (companyId) => auth.getCompanyColleagues(companyId),
1606
1675
  getIframeToken: (flowId) => auth.getIframeToken(flowId),
1607
1676
  embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
1608
1677
  onAuthStateChange: (cb) => auth.onAuthStateChange(cb)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiquo/dom-package",
3
- "version": "1.4.0",
4
- "description": "Tiquo SDK for third-party websites - authentication, customer profiles, orders, bookings, and enquiries",
3
+ "version": "1.5.0",
4
+ "description": "Tiquo SDK for third-party websites - authentication, customer profiles, orders, bookings, enquiries, receipts, and companies",
5
5
  "sideEffects": true,
6
6
  "publishConfig": {
7
7
  "access": "restricted"