Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
feat(web): port utilities, types, and composables
Acho Arnold3dfcecccb256
diff --git a/web/app/composables/useApi.ts b/web/app/composables/useApi.tsnew file mode 100644index 00000000..598146ca--- /dev/null+++ b/web/app/composables/useApi.ts@@ -0,0 +1,33 @@+let authToken: string | null = null;+let apiKey: string | null = null;++export function setAuthHeader(token: string | null) {+ authToken = token;+}++export function setApiKey(key: string | null) {+ apiKey = key;+}++export function useApi() {+ const config = useRuntimeConfig();+ const baseURL = config.public.apiBaseUrl as string;++ const apiFetch = $fetch.create({+ baseURL,+ headers: {+ "X-Client-Version": "web",+ },+ onRequest({ options }) {+ const headers = (options.headers ||= {}) as Record<string, string>;+ if (authToken) {+ headers.Authorization = `Bearer ${authToken}`;+ }+ if (apiKey) {+ headers["x-api-key"] = apiKey;+ }+ },+ });++ return { apiFetch, setAuthHeader, setApiKey };+}diff --git a/web/app/composables/useFilters.ts b/web/app/composables/useFilters.tsnew file mode 100644index 00000000..bcdc1cbc--- /dev/null+++ b/web/app/composables/useFilters.ts@@ -0,0 +1,23 @@+import {+ formatPhoneNumber,+ phoneCountry,+ formatTimestamp,+ formatMoney,+ formatDecimal,+ formatBillingPeriod,+ humanizeTime,+} from "~/utils/filters";+import { capitalize } from "~/utils/capitalize";++export function useFilters() {+ return {+ formatPhoneNumber,+ phoneCountry,+ formatTimestamp,+ formatMoney,+ formatDecimal,+ formatBillingPeriod,+ humanizeTime,+ capitalize,+ };+}diff --git a/web/app/utils/bag.ts b/web/app/utils/bag.tsnew file mode 100644index 00000000..02d9691a--- /dev/null+++ b/web/app/utils/bag.ts@@ -0,0 +1,63 @@+export default class Bag<T> {+ private items = new Map<string, Array<T>>();++ serialize(): Record<string, Array<T>> {+ const result: Record<string, Array<T>> = {};+ this.items.forEach((value: T[], key) => {+ result[key] = value;+ });+ return result;+ }++ static fromObject<T>(items: Record<string, Array<T>>): Bag<T> {+ const result = new Bag<T>();+ Object.keys(items).forEach((key) => {+ result.addMany(key, items[key]);+ });+ return result;+ }++ add(key: string, value: T): this {+ let messages: Array<T> | undefined = this.items.get(key);+ if (messages === undefined) {+ messages = [];+ }++ if (!messages.includes(value)) {+ messages.push(value);+ }++ this.items.set(key, messages);+ return this;+ }++ addMany(key: string, values: Array<T>): this {+ values.forEach((value: T) => {+ this.add(key, value);+ });+ return this;+ }++ has(key: string): boolean {+ return this.items.has(key);+ }++ first(key: string): T | undefined {+ if (this.has(key)) {+ return this.get(key)[0] ?? undefined;+ }+ return undefined;+ }++ get(key: string): Array<T> {+ const result = this.items.get(key);+ if (result === undefined) {+ return [];+ }+ return result;+ }++ size(): number {+ return this.items.size;+ }+}diff --git a/web/app/utils/capitalize.ts b/web/app/utils/capitalize.tsnew file mode 100644index 00000000..78c7b8d7--- /dev/null+++ b/web/app/utils/capitalize.ts@@ -0,0 +1,6 @@+export function capitalize(value: string | null): string {+ if (!value) {+ return "";+ }+ return value.charAt(0).toUpperCase() + value.slice(1);+}diff --git a/web/app/utils/errors.ts b/web/app/utils/errors.tsnew file mode 100644index 00000000..c80b1d95--- /dev/null+++ b/web/app/utils/errors.ts@@ -0,0 +1,47 @@+import Bag from "~/utils/bag";+import { capitalize } from "~/utils/capitalize";++export class ErrorMessages extends Bag<string> {}++const sanitize = (key: string, values: Array<string>): Array<string> => {+ return values.map((value: string) => {+ return capitalize(+ value+ .split(key)+ .join(key.replace("_", " "))+ .split("_")+ .join(" ")+ .split("-")+ .join(" ")+ .split(" char")+ .join(" character")+ .split(" field ")+ .join(" "),+ );+ });+};++interface AxiosLikeError {+ response?: {+ data?: { data?: Record<string, string[]> };+ status?: number;+ };+}++export const getErrorMessages = (error: AxiosLikeError): ErrorMessages => {+ const errors = new ErrorMessages();+ if (+ error === null ||+ typeof error.response?.data?.data !== "object" ||+ error.response?.data?.data === null ||+ error.response?.status !== 422+ ) {+ return errors;+ }++ Object.keys(error.response.data.data).forEach((key: string) => {+ errors.addMany(key, sanitize(key, error.response!.data!.data![key]));+ });++ return errors;+};diff --git a/web/app/utils/filters.ts b/web/app/utils/filters.tsnew file mode 100644index 00000000..abfa8bac--- /dev/null+++ b/web/app/utils/filters.ts@@ -0,0 +1,54 @@+import { intervalToDuration, formatDuration } from "date-fns";+import { parsePhoneNumber, isValidPhoneNumber } from "libphonenumber-js";++export function formatPhoneNumber(value: string): string {+ if (!isValidPhoneNumber(value)) {+ return value;+ }+ const phoneNumber = parsePhoneNumber(value);+ if (phoneNumber) {+ return phoneNumber.formatInternational();+ }+ return value;+}++export function phoneCountry(value: string): string {+ const phoneNumber = parsePhoneNumber(value);+ if (phoneNumber && phoneNumber.country) {+ const regionNames = new Intl.DisplayNames(undefined, { type: "region" });+ return regionNames.of(phoneNumber.country) ?? "Earth";+ }+ return "Earth";+}++export function formatTimestamp(value: string): string {+ return new Date(value).toLocaleString();+}++export function formatMoney(value: string | number): string {+ return new Intl.NumberFormat("en-US", {+ style: "currency",+ currency: "USD",+ }).format(typeof value === "string" ? parseInt(value) : value);+}++export function formatDecimal(value: string | number): string {+ return new Intl.NumberFormat("en-US", {+ style: "decimal",+ }).format(typeof value === "string" ? parseInt(value) : value);+}++export function formatBillingPeriod(value: string): string {+ return new Date(value).toLocaleDateString("en-US", {+ year: "numeric",+ month: "long",+ });+}++export function humanizeTime(value: string): string {+ const durations = intervalToDuration({+ start: new Date(),+ end: new Date(value),+ });+ return formatDuration(durations);+}diff --git a/web/shared/types/api.ts b/web/shared/types/api.tsnew file mode 100644index 00000000..dba3c6ca--- /dev/null+++ b/web/shared/types/api.ts@@ -0,0 +1,831 @@+/* eslint-disable */+/* tslint:disable */+// @ts-nocheck+/*+ * ---------------------------------------------------------------+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##+ * ## ##+ * ## AUTHOR: acacode ##+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##+ * ---------------------------------------------------------------+ */++export enum EntitiesSubscriptionName {+ SubscriptionNameFree = "free",+ SubscriptionNameProMonthly = "pro-monthly",+ SubscriptionNameProYearly = "pro-yearly",+ SubscriptionNameUltraMonthly = "ultra-monthly",+ SubscriptionNameUltraYearly = "ultra-yearly",+ SubscriptionNameProLifetime = "pro-lifetime",+ SubscriptionName20KMonthly = "20k-monthly",+ SubscriptionName100KMonthly = "100k-monthly",+ SubscriptionName50KMonthly = "50k-monthly",+ SubscriptionName200KMonthly = "200k-monthly",+ SubscriptionName20KYearly = "20k-yearly",+}++export enum EntitiesSIM {+ SIM1 = "SIM1",+ SIM2 = "SIM2",+}++export interface EntitiesBillingUsage {+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "2022-01-31T23:59:59+00:00" */+ end_timestamp: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example 465 */+ received_messages: number;+ /** @example 321 */+ sent_messages: number;+ /** @example "2022-01-01T00:00:00+00:00" */+ start_timestamp: string;+ /** @example 0 */+ total_cost: number;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface EntitiesBulkMessage {+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example 25 */+ delivered_count: number;+ /** @example 5 */+ failed_count: number;+ /** @example 30 */+ pending_count: number;+ /** @example "bulk-32343a19-da5e-4b1b-a767-3298a73703cb" */+ request_id: string;+ /** @example 50 */+ scheduled_count: number;+ /** @example 40 */+ sent_count: number;+ /** @example 150 */+ total: number;+}++export interface EntitiesDiscord {+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example "1095780203256627291" */+ incoming_channel_id: string;+ /** @example "Game Server" */+ name: string;+ /** @example "1095778291488653372" */+ server_id: string;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface EntitiesHeartbeat {+ /** @example true */+ charging: boolean;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example "+18005550199" */+ owner: string;+ /** @example "2022-06-05T14:26:01.520828+03:00" */+ timestamp: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+ /** @example "344c10f" */+ version: string;+}++export interface EntitiesMessage {+ /** @example ["https://example.com/image.jpg","https://example.com/video.mp4"] */+ attachments: string[];+ /** @example "+18005550100" */+ contact: string;+ /** @example "This is a sample text message" */+ content: string;+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ delivered_at?: string;+ /** @example false */+ encrypted: boolean;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ expired_at?: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ failed_at?: string;+ /** @example "UNKNOWN" */+ failure_reason?: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ last_attempted_at?: string;+ /** @example 1 */+ max_send_attempts: number;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ order_timestamp: string;+ /** @example "+18005550199" */+ owner: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ received_at?: string;+ /** @example "153554b5-ae44-44a0-8f4f-7bbac5657ad4" */+ request_id?: string;+ /** @example "2022-06-05T14:26:01.520828+03:00" */+ request_received_at: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ scheduled_at?: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ scheduled_send_time?: string;+ /** @example 0 */+ send_attempt_count: number;+ /**+ * SendDuration is the number of nanoseconds from when the request was received until when the mobile phone send the message+ * @example 133414+ */+ send_time?: number;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ sent_at?: string;+ /**+ * SIM is the SIM card to use to send the message+ * * SMS1: use the SIM card in slot 1+ * * SMS2: use the SIM card in slot 2+ * * DEFAULT: used the default communication SIM card+ * @example "DEFAULT"+ */+ sim: EntitiesSIM;+ /** @example "pending" */+ status: string;+ /** @example "mobile-terminated" */+ type: string;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface EntitiesMessageSendSchedule {+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example "Business Hours" */+ name: string;+ /** @example "Europe/Tallinn" */+ timezone: string;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+ windows: EntitiesMessageSendScheduleWindow[];+}++export interface EntitiesMessageSendScheduleWindow {+ /** @example 1 */+ day_of_week: number;+ /** @example 1020 */+ end_minute: number;+ /** @example 540 */+ start_minute: number;+}++export interface EntitiesMessageThread {+ /** @example "indigo" */+ color: string;+ /** @example "+18005550100" */+ contact: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ created_at: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703ca" */+ id: string;+ /** @example false */+ is_archived: boolean;+ /** @example "This is a sample message content" */+ last_message_content: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703ca" */+ last_message_id: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ order_timestamp: string;+ /** @example "+18005550199" */+ owner: string;+ /** @example "PENDING" */+ status: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ updated_at: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface EntitiesPhone {+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....." */+ fcm_token?: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /**+ * MaxSendAttempts determines how many times to retry sending an SMS message+ * @example 2+ */+ max_send_attempts: number;+ /** MessageExpirationSeconds is the duration in seconds after sending a message when it is considered to be expired. */+ message_expiration_seconds: number;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ message_send_schedule_id?: string;+ /** @example 1 */+ messages_per_minute: number;+ /** @example "This phone cannot receive calls. Please send an SMS instead." */+ missed_call_auto_reply?: string;+ /** @example "+18005550199" */+ phone_number: string;+ sim: EntitiesSIM;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface EntitiesPhoneAPIKey {+ /** @example "pk_DGW8NwQp7mxKaSZ72Xq9v6xxxxx" */+ api_key: string;+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example "Business Phone Key" */+ name: string;+ /** @example ["32343a19-da5e-4b1b-a767-3298a73703cb","32343a19-da5e-4b1b-a767-3298a73703cc"] */+ phone_ids: string[];+ /** @example ["+18005550199","+18005550100"] */+ phone_numbers: string[];+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ updated_at: string;+ /** @example "[email protected]" */+ user_email: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface EntitiesUser {+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ active_phone_id?: string;+ /** @example "x-api-key" */+ api_key: string;+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example "[email protected]" */+ email: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ id: string;+ /** @example true */+ notification_heartbeat_enabled: boolean;+ /** @example true */+ notification_message_status_enabled: boolean;+ /** @example true */+ notification_newsletter_enabled: boolean;+ /** @example true */+ notification_webhook_enabled: boolean;+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ subscription_ends_at?: string;+ /** @example "8f9c71b8-b84e-4417-8408-a62274f65a08" */+ subscription_id: string;+ /** @example "free" */+ subscription_name: EntitiesSubscriptionName;+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ subscription_renews_at?: string;+ /** @example "on_trial" */+ subscription_status?: string;+ /** @example "Europe/Helsinki" */+ timezone: string;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+}++export interface EntitiesWebhook {+ /** @example "2022-06-05T14:26:02.302718+03:00" */+ created_at: string;+ /** @example ["message.phone.received"] */+ events: string[];+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ id: string;+ /** @example ["+18005550199","+18005550100"] */+ phone_numbers: string[];+ /** @example "DGW8NwQp7mxKaSZ72Xq9v67SLqSbWQvckzzmK8D6rvd7NywSEkdMJtuxKyEkYnCY" */+ signing_key: string;+ /** @example "2022-06-05T14:26:10.303278+03:00" */+ updated_at: string;+ /** @example "https://example.com" */+ url: string;+ /** @example "WB7DRDWrJZRGbYrv2CKGkqbzvqdC" */+ user_id: string;+}++export interface RequestsDiscordStore {+ incoming_channel_id: string;+ name: string;+ server_id: string;+}++export interface RequestsDiscordUpdate {+ incoming_channel_id: string;+ name: string;+ server_id: string;+}++export interface RequestsHeartbeatStore {+ charging: boolean;+ phone_numbers: string[];+}++export interface RequestsMessageAttachment {+ /**+ * Content is the base64-encoded attachment data+ * @example "base64data..."+ */+ content: string;+ /**+ * ContentType is the MIME type of the attachment+ * @example "image/jpeg"+ */+ content_type: string;+ /**+ * Name is the original filename of the attachment+ * @example "photo.jpg"+ */+ name: string;+}++export interface RequestsMessageBulkSend {+ /** Attachments are optional. When you provide a list of attachments, the message will be sent out as an MMS */+ attachments?: string[];+ /** @example "This is a sample text message" */+ content: string;+ /**+ * Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app+ * @example false+ */+ encrypted?: boolean;+ /** @example "+18005550199" */+ from: string;+ /**+ * RequestID is an optional parameter used to track a request from the client's perspective+ * @example "153554b5-ae44-44a0-8f4f-7bbac5657ad4"+ */+ request_id?: string;+ /** @example ["+18005550100","+18005550100"] */+ to: string[];+}++export interface RequestsMessageCallMissed {+ /** @example "+18005550199" */+ from: string;+ /** @example "SIM1" */+ sim: string;+ /** @example "2022-06-05T14:26:09.527976+03:00" */+ timestamp: string;+ /** @example "+18005550100" */+ to: string;+}++export interface RequestsMessageEvent {+ /**+ * EventName is the type of event+ * * SENT: is emitted when a message is sent by the mobile phone+ * * FAILED: is event is emitted when the message could not be sent by the mobile phone+ * * DELIVERED: is event is emitted when a delivery report has been received by the mobile phone+ * @example "SENT"+ */+ event_name: string;+ /** Reason is the exact error message in case the event is an error */+ reason: string;+ /**+ * Timestamp is the time when the event was emitted, Please send the timestamp in UTC with as much precision as possible+ * @example "2022-06-05T14:26:09.527976+03:00"+ */+ timestamp: string;+}++export interface RequestsMessageReceive {+ /** Attachments is the list of MMS attachments received with the message */+ attachments?: RequestsMessageAttachment[];+ /** @example "This is a sample text message received on a phone" */+ content: string;+ /**+ * Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app+ * @example false+ */+ encrypted: boolean;+ /** @example "+18005550199" */+ from: string;+ /**+ * SIM card that received the message+ * @example "SIM1"+ */+ sim: EntitiesSIM;+ /**+ * Timestamp is the time when the event was emitted, Please send the timestamp in UTC with as much precision as possible+ * @example "2022-06-05T14:26:09.527976+03:00"+ */+ timestamp: string;+ /** @example "+18005550100" */+ to: string;+}++export interface RequestsMessageSend {+ /**+ * Attachments are optional. When you provide a list of attachments, the message will be sent out as an MMS+ * @example ["https://example.com/image.jpg","https://example.com/video.mp4"]+ */+ attachments?: string[];+ /** @example "This is a sample text message" */+ content: string;+ /**+ * Encrypted is an optional parameter used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app+ * @example false+ */+ encrypted?: boolean;+ /** @example "+18005550199" */+ from: string;+ /**+ * RequestID is an optional parameter used to track a request from the client's perspective+ * @example "153554b5-ae44-44a0-8f4f-7bbac5657ad4"+ */+ request_id?: string;+ /**+ * SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.+ * @example "2025-12-19T16:39:57-08:00"+ */+ send_at?: string;+ /** @example "+18005550100" */+ to: string;+}++export interface RequestsMessageSendScheduleStore {+ name: string;+ timezone: string;+ windows: RequestsMessageSendScheduleWindow[];+}++export interface RequestsMessageSendScheduleWindow {+ day_of_week: number;+ end_minute: number;+ start_minute: number;+}++export interface RequestsMessageThreadUpdate {+ /** @example true */+ is_archived: boolean;+}++export interface RequestsPhoneAPIKeyStoreRequest {+ /** @example "My Phone API Key" */+ name: string;+}++export interface RequestsPhoneFCMToken {+ /** @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....." */+ fcm_token: string;+ /** @example "[+18005550199]" */+ phone_number: string;+ /**+ * SIM is the SIM slot of the phone in case the phone has more than 1 SIM slot+ * @example "SIM1"+ */+ sim: string;+}++export interface RequestsPhoneUpsert {+ /** @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....." */+ fcm_token: string;+ /**+ * MaxSendAttempts is the number of attempts when sending an SMS message to handle the case where the phone is offline.+ * @example 2+ */+ max_send_attempts: number;+ /**+ * MessageExpirationSeconds is the duration in seconds after sending a message when it is considered to be expired.+ * @example 12345+ */+ message_expiration_seconds: number;+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ message_send_schedule_id?: string;+ /** @example 1 */+ messages_per_minute: number;+ /** @example "e.g. This phone cannot receive calls. Please send an SMS instead." */+ missed_call_auto_reply: string;+ /** @example "+18005550199" */+ phone_number: string;+ /**+ * SIM is the SIM slot of the phone in case the phone has more than 1 SIM slot+ * @example "SIM1"+ */+ sim: string;+}++export interface RequestsUserNotificationUpdate {+ /** @example true */+ heartbeat_enabled: boolean;+ /** @example true */+ message_status_enabled: boolean;+ /** @example true */+ newsletter_enabled: boolean;+ /** @example true */+ webhook_enabled: boolean;+}++export interface RequestsUserPaymentInvoice {+ /** @example "221B Baker Street, London" */+ address: string;+ /** @example "Los Angeles" */+ city: string;+ /** @example "US" */+ country: string;+ /** @example "Acme Corp" */+ name: string;+ /** @example "Thank you for your business!" */+ notes: string;+ /** @example "CA" */+ state: string;+ /** @example "9800" */+ zip_code: string;+}++export interface RequestsUserUpdate {+ /** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */+ active_phone_id: string;+ /** @example "Europe/Helsinki" */+ timezone: string;+}++export interface RequestsWebhookStore {+ events: string[];+ /** @example ["+18005550100","+18005550100"] */+ phone_numbers: string[];+ signing_key: string;+ url: string;+}++export interface RequestsWebhookUpdate {+ events: string[];+ /** @example ["+18005550100","+18005550100"] */+ phone_numbers: string[];+ signing_key: string;+ url: string;+}++export interface ResponsesBadRequest {+ /** @example "The request body is not a valid JSON string" */+ data: string;+ /** @example "The request isn't properly formed" */+ message: string;+ /** @example "error" */+ status: string;+}++export interface ResponsesBillingUsageResponse {+ data: EntitiesBillingUsage;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesBillingUsagesResponse {+ data: EntitiesBillingUsage[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesBulkMessagesResponse {+ data: EntitiesBulkMessage[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesDiscordResponse {+ data: EntitiesDiscord;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesDiscordsResponse {+ data: EntitiesDiscord[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesHeartbeatResponse {+ data: EntitiesHeartbeat;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesHeartbeatsResponse {+ data: EntitiesHeartbeat[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesInternalServerError {+ /** @example "We ran into an internal error while handling the request." */+ message: string;+ /** @example "error" */+ status: string;+}++export interface ResponsesMessageResponse {+ data: EntitiesMessage;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesMessageSendScheduleResponse {+ data: EntitiesMessageSendSchedule;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesMessageSendSchedulesResponse {+ data: EntitiesMessageSendSchedule[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesMessageThreadsResponse {+ data: EntitiesMessageThread[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesMessagesResponse {+ data: EntitiesMessage[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesNoContent {+ /** @example "action performed successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesNotFound {+ /** @example "cannot find message with ID [32343a19-da5e-4b1b-a767-3298a73703ca]" */+ message: string;+ /** @example "error" */+ status: string;+}++export interface ResponsesOkString {+ data: string;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesPaymentRequired {+ /** @example "You have reached the maximum number of allowed resources. Please upgrade your plan." */+ message: string;+ /** @example "error" */+ status: string;+}++export interface ResponsesPhoneAPIKeyResponse {+ data: EntitiesPhoneAPIKey;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesPhoneAPIKeysResponse {+ data: EntitiesPhoneAPIKey[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesPhoneResponse {+ data: EntitiesPhone;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesPhonesResponse {+ data: EntitiesPhone[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesUnauthorized {+ /** @example "Make sure your API key is set in the [X-API-Key] header in the request" */+ data: string;+ /** @example "You are not authorized to carry out this request." */+ message: string;+ /** @example "error" */+ status: string;+}++export interface ResponsesUnprocessableEntity {+ data: Record<string, string[]>;+ /** @example "validation errors while handling request" */+ message: string;+ /** @example "error" */+ status: string;+}++export interface ResponsesUserResponse {+ data: EntitiesUser;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesUserSubscriptionPaymentsResponse {+ data: {+ attributes: {+ billing_reason: string;+ card_brand: string;+ card_last_four: string;+ created_at: string;+ currency: string;+ currency_rate: string;+ discount_total: number;+ discount_total_formatted: string;+ discount_total_usd: number;+ refunded: boolean;+ refunded_amount: number;+ refunded_amount_formatted: string;+ refunded_amount_usd: number;+ refunded_at: any;+ status: string;+ status_formatted: string;+ subtotal: number;+ subtotal_formatted: string;+ subtotal_usd: number;+ tax: number;+ tax_formatted: string;+ tax_inclusive: boolean;+ tax_usd: number;+ total: number;+ total_formatted: string;+ total_usd: number;+ updated_at: string;+ };+ id: string;+ type: string;+ }[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesWebhookResponse {+ data: EntitiesWebhook;+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}++export interface ResponsesWebhooksResponse {+ data: EntitiesWebhook[];+ /** @example "Request handled successfully" */+ message: string;+ /** @example "success" */+ status: string;+}diff --git a/web/shared/types/billing.ts b/web/shared/types/billing.tsnew file mode 100644index 00000000..0541b2bd--- /dev/null+++ b/web/shared/types/billing.ts@@ -0,0 +1,8 @@+export interface BillingUsage {+ id: string;+ user_id: string;+ period_start: string;+ period_end: string;+ sent_messages: number;+ received_messages: number;+}diff --git a/web/shared/types/heartbeat.ts b/web/shared/types/heartbeat.tsnew file mode 100644index 00000000..0ba29f92--- /dev/null+++ b/web/shared/types/heartbeat.ts@@ -0,0 +1,7 @@+export interface Heartbeat {+ id: string;+ owner: string;+ phone_number: string;+ charging: boolean;+ timestamp: string;+}diff --git a/web/shared/types/message-thread.ts b/web/shared/types/message-thread.tsnew file mode 100644index 00000000..e334bc1f--- /dev/null+++ b/web/shared/types/message-thread.ts@@ -0,0 +1,12 @@+export interface MessageThread {+ color: string;+ contact: string;+ created_at: string;+ id: string;+ last_message_content: string;+ last_message_id: string;+ is_archived: boolean;+ order_timestamp: string;+ owner: string;+ updated_at: string;+}diff --git a/web/shared/types/message.ts b/web/shared/types/message.tsnew file mode 100644index 00000000..0761c623--- /dev/null+++ b/web/shared/types/message.ts@@ -0,0 +1,30 @@+export interface Message {+ contact: string;+ content: string;+ attachments: Array<string> | null;+ created_at: string;+ failure_reason: string;+ id: string;+ last_attempted_at: string | null;+ order_timestamp: string;+ owner: string;+ received_at: string | null;+ request_received_at: string | null;+ send_time: number | null;+ sent_at: string;+ status: string;+ type: string;+ updated_at: string;+}++export interface SearchMessagesRequest {+ owners: string[];+ types: string[];+ statuses: string[];+ query: string;+ sort_by: string;+ token?: string;+ sort_descending: boolean;+ skip: number;+ limit: number;+}diff --git a/web/shared/types/user.ts b/web/shared/types/user.tsnew file mode 100644index 00000000..c2f7c96c--- /dev/null+++ b/web/shared/types/user.ts@@ -0,0 +1,12 @@+export interface User {+ id: string;+ email: string;+ api_key: string;+ active_phone_id: string | null;+ timezone: string;+ subscription_id: string | null;+ subscription_name: string | null;+ subscription_status: string | null;+ notification_message_status_enabled: boolean;+ notification_webhooks_enabled: boolean;+}