@stacksjs/sms
Version:
The Stacks SMS integration. Painlessly create & manage your inboxes, templates, and send sms.
98 lines (96 loc) • 3.28 kB
TypeScript
import type { SmsDriver, SmsMessage, SmsOptions, SmsProvider, SmsSendResult, SmsStatusUpdate, SmsVerificationDriver, VerificationCheckRequest, VerificationRequest, VerificationResult } from '@stacksjs/types';
/**
* Configure the SMS system
*/
export declare function configure(config: Partial<SmsOptions>): void;
/**
* Get the default SMS driver based on configuration
*/
export declare function getDriver(provider?: SmsProvider): SmsDriver;
/**
* Get the verification driver
*/
export declare function getVerificationDriver(provider?: SmsProvider): SmsVerificationDriver;
/**
* Send an SMS message
*/
export declare function send(message: SmsMessage): Promise<SmsSendResult>;
/**
* Send multiple SMS messages
*/
export declare function sendBulk(messages: SmsMessage[]): Promise<SmsSendResult[]>;
/**
* Get message status
*/
export declare function getStatus(messageId: string): Promise<SmsStatusUpdate | null>;
/**
* Verify a phone number format and carrier
*/
export declare function verifyNumber(phoneNumber: string): Promise<{ valid: boolean, carrier?: string, type?: string }>;
/**
* Get account balance
*/
export declare function getBalance(): Promise<{ balance: number, currency: string } | null>;
/**
* Start a phone verification (send OTP)
*/
export declare function startVerification(request: VerificationRequest): Promise<VerificationResult>;
/**
* Check a verification code
*/
export declare function checkVerification(request: VerificationCheckRequest): Promise<VerificationResult>;
/**
* Cancel a pending verification
*/
export declare function cancelVerification(verificationId: string): Promise<boolean>;
/**
* Create a new SMS builder
*/
export declare function sms(): SmsBuilder;
/**
* Send an SMS using a template
*/
export declare function sendTemplate(to: string | string[], templateName: string, variables?: Record<string, string>): Promise<SmsSendResult>;
/**
* Format a phone number to E.164 format
*/
export declare function formatE164(phoneNumber: string, defaultCountryCode?: string): string;
/**
* Check if a phone number appears valid
*/
export declare function isValidPhoneNumber(phoneNumber: string): boolean;
/**
* Initialize the SMS system (loads config)
*/
export declare function init(): Promise<void>;
/**
* Check if SMS is enabled in config
*/
export declare function isEnabled(): boolean;
/**
* Get the current SMS configuration
*/
export declare function getConfig(): Partial<SmsOptions>;
/**
* Send an SMS message (alias)
*/
export declare const sendSms: unknown;
// =============================================================================
// SMS Facade Object
// =============================================================================
export declare const SMS: {
};
// =============================================================================
// SMS Builder (Fluent API)
// =============================================================================
export declare class SmsBuilder {
to(phoneNumber: string | string[]): this;
body(text: string): this;
text(text: string): this;
from(sender: string): this;
media(urls: string | string[]): this;
callback(url: string): this;
via(provider: SmsProvider): this;
send(): Promise<SmsSendResult>;
}
export default SMS;