UNPKG

alepha

Version:

Easy-to-use modern TypeScript framework for building many kind of applications.

133 lines 3.61 kB
import { AlephaError, InstantiableClass, KIND, Primitive } from "alepha"; import { FileSystemProvider } from "alepha/system"; //#region ../../src/sms/providers/SmsProvider.d.ts /** * SMS provider interface. * * All methods are asynchronous and return promises. */ declare abstract class SmsProvider { /** * Send an SMS. * * @return Promise that resolves when the SMS is sent. */ abstract send(options: SmsSendOptions): Promise<void>; } type SmsSendOptions = { to: string | string[]; message: string; }; //#endregion //#region ../../src/sms/errors/SmsError.d.ts declare class SmsError extends AlephaError { constructor(message: string, cause?: Error); } //#endregion //#region ../../src/sms/primitives/$sms.d.ts declare const $sms: { (options?: SmsPrimitiveOptions): SmsPrimitive; [KIND]: typeof SmsPrimitive; }; interface SmsPrimitiveOptions { name?: string; provider?: InstantiableClass<SmsProvider> | "memory"; } /** * SMS primitive for sending SMS messages through various providers. * * Usage: * ```typescript * class MyService { * private readonly welcomeSms = $sms({ name: "welcome" }); * * async sendWelcome(phoneNumber: string, userName: string) { * await this.welcomeSms.send({ * to: phoneNumber, * message: `Hello ${userName}! Welcome to our service.` * }); * } * } * ``` */ declare class SmsPrimitive extends Primitive<SmsPrimitiveOptions> { protected readonly provider: SmsProvider; get name(): string; /** * Send an SMS using the configured provider. */ send(options: SmsSendOptions): Promise<void>; protected $provider(): SmsProvider; } //#endregion //#region ../../src/sms/providers/LocalSmsProvider.d.ts interface LocalSmsProviderOptions { /** * Directory to save SMS files. * @default "node_modules/.alepha/sms" (relative to project root) */ directory?: string; } declare class LocalSmsProvider implements SmsProvider { protected readonly log: import("alepha/logger").Logger; protected readonly fs: FileSystemProvider; protected readonly directory: string; constructor(options?: LocalSmsProviderOptions); send(options: SmsSendOptions): Promise<void>; createSmsJson(options: { to: string; message: string; }): { to: string; message: string; sentAt: string; }; } //#endregion //#region ../../src/sms/providers/MemorySmsProvider.d.ts interface SmsRecord { to: string; message: string; sentAt: Date; } declare class MemorySmsProvider implements SmsProvider { protected readonly log: import("alepha/logger").Logger; records: SmsRecord[]; send(options: SmsSendOptions): Promise<void>; /** * Get the last SMS sent (for testing purposes). */ get last(): SmsRecord | undefined; } //#endregion //#region ../../src/sms/index.d.ts declare module "alepha" { interface Hooks { "sms:sending": { to: string | string[]; template: string; variables: Record<string, unknown>; provider: SmsProvider; abort(): void; }; "sms:sent": { to: string | string[]; template: string; provider: SmsProvider; }; } } /** * SMS delivery with multiple provider support. * * **Features:** * - Send SMS with templates * - Multiple recipients * - Provider abstraction * * @module alepha.sms */ declare const AlephaSms: import("alepha").Service<import("alepha").Module>; //#endregion export { $sms, AlephaSms, LocalSmsProvider, LocalSmsProviderOptions, MemorySmsProvider, SmsError, SmsPrimitive, SmsPrimitiveOptions, SmsProvider, SmsRecord, SmsSendOptions }; //# sourceMappingURL=index.d.ts.map