@tiquo/dom-package 1.4.1 → 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
@@ -492,6 +492,80 @@ interface GetEnquiriesResult {
492
492
  hasMore: boolean;
493
493
  nextCursor?: string;
494
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
+ }
495
569
  type AuthStateChangeCallback = (session: TiquoSession | null) => void;
496
570
  declare class TiquoAuthError extends Error {
497
571
  code: string;
@@ -603,6 +677,32 @@ declare class TiquoAuth {
603
677
  * Only returns enquiries for the logged-in customer
604
678
  */
605
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>;
606
706
  /**
607
707
  * Generate a short-lived token for customer flow iframe authentication
608
708
  */
@@ -696,6 +796,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
696
796
  getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
697
797
  getReceipt: (orderId: string) => Promise<TiquoReceipt>;
698
798
  getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
799
+ getCompanies: () => Promise<GetCompaniesResult>;
800
+ getCompanyColleagues: (companyId: string) => Promise<GetCompanyColleaguesResult>;
699
801
  getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
700
802
  embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
701
803
  width?: string;
@@ -758,4 +860,4 @@ declare class TiquoPhone {
758
860
  static buildPhone: typeof buildPhone;
759
861
  }
760
862
 
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 };
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
@@ -492,6 +492,80 @@ interface GetEnquiriesResult {
492
492
  hasMore: boolean;
493
493
  nextCursor?: string;
494
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
+ }
495
569
  type AuthStateChangeCallback = (session: TiquoSession | null) => void;
496
570
  declare class TiquoAuthError extends Error {
497
571
  code: string;
@@ -603,6 +677,32 @@ declare class TiquoAuth {
603
677
  * Only returns enquiries for the logged-in customer
604
678
  */
605
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>;
606
706
  /**
607
707
  * Generate a short-lived token for customer flow iframe authentication
608
708
  */
@@ -696,6 +796,8 @@ declare function useTiquoAuth(auth: TiquoAuth): {
696
796
  getUpcomingBookings: (options?: Omit<GetBookingsOptions, "upcoming">) => Promise<GetBookingsResult>;
697
797
  getReceipt: (orderId: string) => Promise<TiquoReceipt>;
698
798
  getEnquiries: (options?: GetEnquiriesOptions) => Promise<GetEnquiriesResult>;
799
+ getCompanies: () => Promise<GetCompaniesResult>;
800
+ getCompanyColleagues: (companyId: string) => Promise<GetCompanyColleaguesResult>;
699
801
  getIframeToken: (flowId?: string) => Promise<IframeTokenResult>;
700
802
  embedCustomerFlow: (flowUrl: string, container: HTMLElement | string, options?: {
701
803
  width?: string;
@@ -758,4 +860,4 @@ declare class TiquoPhone {
758
860
  static buildPhone: typeof buildPhone;
759
861
  }
760
862
 
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 };
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
@@ -1074,6 +1074,67 @@ var TiquoAuth = class {
1074
1074
  const result = await response.json();
1075
1075
  return result.data || { enquiries: [], hasMore: false };
1076
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
+ }
1077
1138
  /**
1078
1139
  * Generate a short-lived token for customer flow iframe authentication
1079
1140
  */
@@ -1645,6 +1706,8 @@ function useTiquoAuth(auth) {
1645
1706
  getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
1646
1707
  getReceipt: (orderId) => auth.getReceipt(orderId),
1647
1708
  getEnquiries: (options) => auth.getEnquiries(options),
1709
+ getCompanies: () => auth.getCompanies(),
1710
+ getCompanyColleagues: (companyId) => auth.getCompanyColleagues(companyId),
1648
1711
  getIframeToken: (flowId) => auth.getIframeToken(flowId),
1649
1712
  embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
1650
1713
  onAuthStateChange: (cb) => auth.onAuthStateChange(cb)
package/dist/index.mjs CHANGED
@@ -1038,6 +1038,67 @@ var TiquoAuth = class {
1038
1038
  const result = await response.json();
1039
1039
  return result.data || { enquiries: [], hasMore: false };
1040
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
+ }
1041
1102
  /**
1042
1103
  * Generate a short-lived token for customer flow iframe authentication
1043
1104
  */
@@ -1609,6 +1670,8 @@ function useTiquoAuth(auth) {
1609
1670
  getUpcomingBookings: (options) => auth.getUpcomingBookings(options),
1610
1671
  getReceipt: (orderId) => auth.getReceipt(orderId),
1611
1672
  getEnquiries: (options) => auth.getEnquiries(options),
1673
+ getCompanies: () => auth.getCompanies(),
1674
+ getCompanyColleagues: (companyId) => auth.getCompanyColleagues(companyId),
1612
1675
  getIframeToken: (flowId) => auth.getIframeToken(flowId),
1613
1676
  embedCustomerFlow: auth.embedCustomerFlow.bind(auth),
1614
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.1",
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"