/** Shared company data fields returned by the Customer Service API. */ interface CompanyData { id: string; name: string; hostname: string; crm_code: string; token: string; status: string; timezone: string; utc: string; check_bad_password: boolean; limit_bad_password: number; watching: boolean; trial: boolean; support_widget_id: string; createdAt: string; updatedAt: string; } /** Response returned by the Customer Service API when fetching a company. */ interface CompanyResponse { company: CompanyData; } /** Request payload for updating company settings. */ interface UpdateCompanyRequest { check_bad_password?: boolean; limit_bad_password?: number; timezone?: string; utc?: string; } /** Request payload for updating the company support widget identifier. */ interface UpdateSupportWidgetIdRequest { support_widget_id: string; } /** Response returned by the Customer Service API when updating the support widget identifier. */ interface UpdateSupportWidgetIdResponse { company: Pick; } /** Response returned by the Customer Service API when fetching the support widget identifier. */ interface GetSupportWidgetIdResponse { support_widget_id: string; } /** Strong password policy options stored in a company config `value_json`. */ interface StrongPasswordOptions { /** Whether uppercase letters are required. */ uppercase: boolean; /** Whether lowercase letters are required. */ lowercase: boolean; /** Whether numeric digits are required. */ number: boolean; /** Whether symbols are required. */ symbol: boolean; /** Minimum password length. */ minChars: number; } /** Request payload for updating a boolean company config. */ interface UpdateCompanyBooleanConfigRequest { value: boolean; } /** Request payload for updating a string company config. */ interface UpdateCompanyStringConfigRequest { value: string; } /** Request payload for updating a JSON company config. */ interface UpdateCompanyJsonConfigRequest { valueJson: StrongPasswordOptions; } /** Known company config keys that accept a boolean value. */ type CompanyBooleanConfigKey = 'block-anonymous-messages' | 'block-silent-close' | 'mandatory-tag' | 'prevent-tag-edit' | 'inbox-hide-message-enabled' | 'show-deleted-users'; /** Known company config keys that accept a string value. */ type CompanyStringConfigKey = 'proxy_ami' | 'snep_password' | 'snep_ip'; /** Known company config keys that accept a JSON value. */ type CompanyJsonConfigKey = 'strong-password-options'; /** Known company config keys for fetching a single config entry. */ type CompanyConfigKey = CompanyBooleanConfigKey | CompanyStringConfigKey | CompanyJsonConfigKey; /** Response returned by the Customer Service API for a company config entry. */ interface CompanyConfigResponse { id: string; key: string; value: boolean | string | null; value_json: StrongPasswordOptions | null; createdAt: string; updatedAt: string; company_id: string; } /** Response returned by the Customer Service API when fetching or updating strong password options. */ interface StrongPasswordOptionsResponse extends CompanyConfigResponse { key: 'strong-password-options'; value_json: StrongPasswordOptions; } /** Response returned by the Customer Service API when fetching the current company with its configs. */ interface CompanyWithConfigsResponse extends CompanyData { configs: CompanyConfigResponse[]; } /** Queue entry returned by the Customer Service API when listing company queues. */ interface CompanyQueue { name: string; musiconhold: string; announce: string; context: string; timeout: string; ringinuse: string; setinterfacevar: string | null; setqueuevar: string | null; setqueueentryvar: string | null; monitor_format: string | null; membermacro: string | null; membergosub: string | null; queue_youarenext: string; queue_thereare: string; queue_callswaiting: string; queue_quantity1: string | null; queue_quantity2: string | null; queue_holdtime: string | null; queue_minutes: string | null; queue_minute: string | null; queue_seconds: string | null; queue_thankyou: string; queue_callerannounce: string | null; queue_reporthold: string | null; announce_frequency: string; announce_to_first_user: string | null; min_announce_frequency: string | null; announce_round_seconds: string | null; announce_holdtime: string | null; announce_position: string | null; announce_position_limit: string | null; periodic_announce: string | null; periodic_announce_frequency: string | null; relative_periodic_announce: string | null; random_periodic_announce: string | null; retry: string; wrapuptime: string; penaltymemberslimit: string | null; autofill: string | null; monitor_type: string | null; autopause: string | null; autopausedelay: string | null; autopausebusy: string | null; autopauseunavail: string | null; maxlen: string; servicelevel: string; strategy: string; joinempty: string; leavewhenempty: string; reportholdtime: string; memberdelay: string; weight: string; timeoutrestart: string | null; defaultrule: string | null; timeoutpriority: string | null; id: string; alert_mail: string; notify: string; csat: string; csat_survey_audio: string | null; csat_thanks_audio: string | null; announce_audio: string | null; announce_audio_enabled: string; } /** Allowed user profile values in the Customer Service API. */ type UserProfile = 'p_admin' | 'p_manager' | 'p_corporative' | 'p_agent'; /** User bond returned by the Customer Service API. */ interface UserBond { id: string; queue: string; type: 'queue' | 'work_group'; permission: 'superviser' | 'manager' | 'member'; user_id: string; group_id: string | null; company_id: string; group_name: string | null; createdAt: string; updatedAt: string; workgroups_bonds?: WorkGroup; } /** User entity returned by the Customer Service API. */ interface User { id: string; username: string; email: string; profile: UserProfile; language: string; access_token?: string; occupation: string; endpoint: string | null; phone_number: string | null; usercode: number; queues: unknown[] | null; avatar: string | null; type: string; status: 'new' | 'activated' | 'disabled'; redefine_code: number; redefine_expires: string; state: string; pause: Record | null; last_event_time: string | null; oncall: boolean; ringing: boolean | null; callnumber: string | null; timezone: string; utc: string; peer_create: string | null; token_id: string; tech_channel: string | null; bad_password: number; block_status: string; two_auth_mail: boolean; two_auth_otp: boolean; otp_key?: string | null; watching: boolean; trial: boolean; ringing_sound: string | null; createdAt: string; updatedAt: string; company_id: string; password?: string; mobile_access?: boolean; company?: CompanyData; users_bonds?: UserBond[]; } interface GetAllUsersParams { status?: string; includeWorkGroups?: boolean; withoutOpensUsers?: boolean; } interface GetAllUsersResponse { users: User[]; } interface ManagedUser { id: string; username: string; email: string; profile: string; status: string; companyId: string; createdAt: string; updatedAt: string; } type GetManagedUsersResponse = ManagedUser[]; /** Response returned by the Customer Service API when fetching a user by identifier. */ interface GetUserByIdResponse { user: User; } /** Request payload for updating a company user. */ interface UpdateCompanyUserRequest { username?: string; occupation?: string; email?: string; two_auth_mail?: boolean; two_auth_otp?: boolean; mobile_access?: boolean; } /** Request payload for updating the current user's password. */ interface UpdateUserPasswordRequest { password: string; new_password: string; } /** Response returned by the Customer Service API when updating a user password. */ interface UpdateUserPasswordResponse { user: { id: string; password: string; company_id: string; updatedAt: string; }; } /** Response returned by the Customer Service API when updating a company user avatar. */ interface UpdateCompanyUserAvatarResponse { success: boolean; } /** Allowed user status values for listing filters. */ type ListUsersStatus = 'new' | 'activated' | 'disabled'; /** Allowed user profile values for listing filters. */ type ListUsersProfile = UserProfile; /** Allowed user type values for listing filters. */ type ListUsersType = 'user' | 'opens'; /** * Optional associations loaded via `include`. * `logs` is not allowed. Unknown or duplicated values return `400`. */ type ListUsersInclude = 'company' | 'bonds' | 'workgroups'; /** * Query parameters for `GET /users`. * * Company is resolved from the authenticated token first; `companyId` is used only when the token has none. * List filters may be sent as repeated query keys (for example `status[]=new&status[]=activated`). */ interface ListUsersRequest { /** Current page, starting at 1. Defaults to `1`. */ page?: number; /** Page size between 1 and 100. Defaults to `20`. */ pageSize?: number; /** Company UUID used only when the token does not contain `companyId`. */ companyId?: string; /** Case-insensitive search on `username` and `email`. */ search?: string; /** Filters by the `mobile_access` field. */ mobileAccess?: boolean; /** Allowed values: `new`, `activated`, `disabled`. */ status?: ListUsersStatus[]; /** Allowed values: `p_admin`, `p_manager`, `p_corporative`, `p_agent`. */ profile?: ListUsersProfile[]; /** Allowed values: `user`, `opens`. */ type?: ListUsersType; /** Restricts the result to the given user UUIDs. */ ids?: string[]; /** Excludes users; takes precedence when an id is also present in `ids`. */ excludeIds?: string[]; /** Returns users linked to any of the given workgroup UUIDs. */ workgroupIds?: string[]; /** * Associations to load. * `company` → `company`, `bonds` → `users_bonds`, * `workgroups` → `users_bonds` of type `work_group` with nested `workgroups_bonds`. */ include?: ListUsersInclude[]; } /** Paginated response returned by `GET /users`. */ interface ListUsersResponse { /** Users in the current page. */ data: User[]; /** Total number of users matching the filters. */ total: number; /** Whether another page is available. */ hasMore: boolean; } /** A work group entity nested within {@link WorkGroupListResponse} and {@link WorkGroupResponse}. */ interface WorkGroup { id: string; name: string; description: string | null; type: 'default' | 'user'; company_id: string; createdAt: string; updatedAt: string; } /** Response returned by the Customer Service API when fetching the work groups list. */ interface WorkGroupListResponse extends CompanyData { workgroups: WorkGroup[]; } /** A user membership entity nested within {@link WorkGroupResponse}. */ interface WorkGroupMember { id: string; username: string; email: string; profile: UserProfile; status: 'new' | 'activated' | 'disabled'; avatar: string | null; createdAt: string; updatedAt: string; } /** Response returned by the Customer Service API when fetching a single work group. */ interface WorkGroupResponse { id: string; name: string; description: string | null; type: 'default' | 'user'; company_id: string; createdAt: string; updatedAt: string; workgroups_users: WorkGroupMember[]; } /** Response returned by the Customer Service API when fetching members of a work group. */ type WorkGroupMembersResponse = WorkGroupMember[]; /** Visual status literals for an announcement payload. */ type AnnouncementVisualStatus = 'success' | 'alert' | 'warning' | 'custom'; /** Button displayed inside an announcement payload. */ interface AnnouncementButton { /** Button label. */ text: string; /** Target URL opened when the button is clicked. */ url: string; /** Whether the URL should open in a new browser tab. */ new_tab: boolean; } /** Appearance configuration for an announcement. */ interface AnnouncementAppearance { /** * Target DOM selector where the announcement should be anchored. * Defaults to '#announcements' if omitted. */ targetElement?: string; /** * Position of the announcement inside the target element. * - 'top': rendered inside the target element at the very top (prepended). * - 'bottom': rendered inside the target element at the bottom (appended). * Note: The announcement is always rendered INSIDE the target element, not outside. * Defaults to 'top'. */ position?: 'top' | 'bottom'; } /** Payload rendered by the announcement widget. */ interface AnnouncementPayload { /** Main announcement message. */ message: string; /** Visual style applied to the announcement. */ visual_status: AnnouncementVisualStatus; /** Optional action buttons (up to 3). */ buttons?: AnnouncementButton[]; /** Optional appearance configuration for DOM anchoring. */ appearance?: AnnouncementAppearance; } /** URL targeting rule for an announcement. */ interface AnnouncementTargetingRuleUrl { /** Matching strategy. */ operator: 'starts_with' | 'exact_match'; /** URL value to match against the current page URL. */ value: string; } /** Targeting rules used to decide whether an announcement should be shown. */ interface AnnouncementTargetingRules { /** When true, the announcement matches every profile. */ allProfiles?: boolean; /** Profile slugs that should see the announcement. */ profiles?: string[]; /** URL-based targeting rule. */ url?: AnnouncementTargetingRuleUrl; } /** Company linked to an announcement. */ interface AnnouncementCompany { /** Announcement identifier. */ announcementId: string; /** Company identifier. */ companyId: string; } /** Announcement type returned by the API. */ interface AnnouncementType { /** Unique identifier. */ id: string; /** Type slug (e.g. banner, modal). */ type: string; /** Display name. */ name: string; } /** Announcement entity returned by the Customer Service API. */ interface Announcement { /** Unique identifier. */ id: string; /** Display name. */ name: string; /** Identifier of the announcement type. */ typeId: string; /** Whether the announcement is currently active. */ isActive: boolean; /** Whether the announcement is visible to all companies. */ allCompanies: boolean; /** Targeting rules (JSONB). */ targetingRules: AnnouncementTargetingRules; /** Renderable payload. */ payload: AnnouncementPayload; /** Optional expiration ISO date. */ expiresAt?: string | null; /** Creation ISO date. */ createdAt: string; /** Last update ISO date. */ updatedAt: string; /** Linked companies (included on detail endpoints). */ announcement_companies?: AnnouncementCompany[]; /** Linked announcement type (included on list/detail endpoints). */ announcement_type?: AnnouncementType; } /** Query filters for listing announcements through the admin endpoint. */ interface AnnouncementListFilters { /** Page number (defaults to 1). */ page?: number; /** Items per page (defaults to 20, max 100). */ limit?: number; /** Filter by active flag. */ isActive?: boolean; /** Filter by global companies flag. */ allCompanies?: boolean; /** true: only expired; false: only not expired; omitted: no expiration filter. */ expired?: boolean; /** Filter by a linked company UUID. */ companyId?: string; /** Filter by announcement type UUID. */ typeId?: string; /** Filter by targeted profile. */ profile?: string; /** Filter by targeted URL. */ url?: string; } /** Paginated response returned by the announcements admin list endpoint. */ interface AnnouncementListResponse { /** Total matching rows. */ count: number; /** Current page rows. */ rows: Announcement[]; } /** Request payload for creating an announcement. */ interface CreateAnnouncementRequest { /** Display name. */ name: string; /** Identifier of the announcement type. */ typeId: string; /** Whether the announcement should start active (defaults to true). */ isActive?: boolean; /** Whether the announcement is visible to all companies. */ allCompanies: boolean; /** Optional expiration ISO date. */ expiresAt?: string | null; /** Renderable payload. */ payload: AnnouncementPayload; /** Company UUIDs allowed to see the announcement when allCompanies is false. */ companies?: string[]; /** Targeting rules. */ targetingRules?: AnnouncementTargetingRules; } /** Request payload for updating an announcement. */ interface UpdateAnnouncementRequest { /** Display name. */ name: string; /** Identifier of the announcement type. */ typeId: string; /** Whether the announcement is currently active. */ isActive?: boolean; /** Whether the announcement is visible to all companies. */ allCompanies: boolean; /** Optional expiration ISO date. */ expiresAt?: string | null; /** Renderable payload. */ payload: AnnouncementPayload; /** Company UUIDs allowed to see the announcement when allCompanies is false. */ companies?: string[]; /** Targeting rules. */ targetingRules?: AnnouncementTargetingRules; } /** Request payload for toggling an announcement active status. */ interface UpdateAnnouncementStatusRequest { /** New active status. */ isActive: boolean; } /** Query parameters for the active announcements widget endpoint. */ interface ActiveAnnouncementQuery { /** Current page URL used for URL targeting rules. */ url?: string; /** User profile slug used for profile targeting rules. */ profile?: string; } /** Slim announcement payload returned by the active endpoint (widget). */ interface ActiveAnnouncement { /** Unique identifier. */ id: string; /** Announcement type slug. */ type?: string; /** Renderable payload. */ payload: AnnouncementPayload; } /** Request payload for generating a two-factor OTP secret URL. */ interface GenerateTwoFactorOtpRequest { userId: string; } /** Response returned when generating a two-factor OTP secret URL. */ interface GenerateTwoFactorOtpResponse { url: string; } /** Request payload for validating a two-factor OTP code. */ interface ValidateTwoFactorOtpRequest { userId: string; code: string; } /** Response returned when validating a two-factor OTP code. */ interface ValidateTwoFactorOtpResponse { validate: boolean; } export type { ActiveAnnouncement, ActiveAnnouncementQuery, Announcement, AnnouncementAppearance, AnnouncementButton, AnnouncementCompany, AnnouncementListFilters, AnnouncementListResponse, AnnouncementPayload, AnnouncementTargetingRuleUrl, AnnouncementTargetingRules, AnnouncementType, AnnouncementVisualStatus, CompanyBooleanConfigKey, CompanyConfigKey, CompanyConfigResponse, CompanyData, CompanyJsonConfigKey, CompanyQueue, CompanyResponse, CompanyStringConfigKey, CompanyWithConfigsResponse, CreateAnnouncementRequest, GenerateTwoFactorOtpRequest, GenerateTwoFactorOtpResponse, GetAllUsersParams, GetAllUsersResponse, GetManagedUsersResponse, GetSupportWidgetIdResponse, GetUserByIdResponse, ListUsersInclude, ListUsersProfile, ListUsersRequest, ListUsersResponse, ListUsersStatus, ListUsersType, ManagedUser, StrongPasswordOptions, StrongPasswordOptionsResponse, UpdateAnnouncementRequest, UpdateAnnouncementStatusRequest, UpdateCompanyBooleanConfigRequest, UpdateCompanyJsonConfigRequest, UpdateCompanyRequest, UpdateCompanyStringConfigRequest, UpdateCompanyUserAvatarResponse, UpdateCompanyUserRequest, UpdateSupportWidgetIdRequest, UpdateSupportWidgetIdResponse, UpdateUserPasswordRequest, UpdateUserPasswordResponse, User, UserBond, UserProfile, ValidateTwoFactorOtpRequest, ValidateTwoFactorOtpResponse, WorkGroup, WorkGroupListResponse, WorkGroupMember, WorkGroupMembersResponse, WorkGroupResponse };