arcanajs 4.0.0 → 5.0.1
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/529.js +2 -0
- package/dist/529.js.map +1 -0
- package/dist/630.js +3 -0
- package/dist/630.js.LICENSE.txt +14 -0
- package/dist/630.js.map +1 -0
- package/dist/arcanajs.auth.js +3 -0
- package/dist/arcanajs.auth.js.LICENSE.txt +14 -0
- package/dist/arcanajs.auth.js.map +1 -0
- package/dist/arcanajs.js +1 -1
- package/dist/arcanajs.js.map +1 -1
- package/dist/arcanajs.mail.js +2 -0
- package/dist/arcanajs.mail.js.map +1 -0
- package/dist/arcanajs.validator.js +2 -0
- package/dist/arcanajs.validator.js.map +1 -0
- package/dist/arcanox.js +1 -1
- package/dist/arcanox.js.map +1 -1
- package/dist/cli/commands/dependency.d.ts +1 -0
- package/dist/cli/commands/make/Controller.d.ts +3 -0
- package/dist/cli/commands/make/Factory.d.ts +2 -0
- package/dist/cli/commands/make/Middleware.d.ts +1 -0
- package/dist/cli/commands/make/Migration.d.ts +2 -0
- package/dist/cli/commands/make/Model.d.ts +2 -0
- package/dist/cli/commands/make/Provider.d.ts +1 -0
- package/dist/cli/commands/make/Request.d.ts +1 -0
- package/dist/cli/commands/make/Seeder.d.ts +2 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.LICENSE.txt +14 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/toPascalCase.d.ts +1 -0
- package/dist/cli/utils/writeFile.d.ts +1 -0
- package/dist/lib/arcanox/Model.d.ts +7 -0
- package/dist/lib/arcanox/providers/DatabaseProvider.d.ts +9 -4
- package/dist/lib/arcanox/schema/Schema.d.ts +11 -0
- package/dist/lib/arcanox/types.d.ts +4 -2
- package/dist/lib/auth/AuthProvider.d.ts +10 -0
- package/dist/lib/auth/JWTService.d.ts +11 -0
- package/dist/lib/auth/SessionManager.d.ts +4 -0
- package/dist/lib/auth/middleware/AuthMiddleware.d.ts +5 -0
- package/dist/lib/auth/middleware/AuthenticatedMiddleware.d.ts +5 -0
- package/dist/lib/auth/middleware/GuestMiddleware.d.ts +5 -0
- package/dist/lib/auth/middleware/RoleMiddleware.d.ts +7 -0
- package/dist/lib/auth/types/AuthConfig.d.ts +24 -0
- package/dist/lib/auth/types/JWTPayload.d.ts +10 -0
- package/dist/lib/auth/types/index.d.ts +2 -0
- package/dist/lib/auth/utils/PasswordHasher.d.ts +16 -0
- package/dist/lib/auth/utils/TokenBlacklist.d.ts +9 -0
- package/dist/lib/index.arcanox.d.ts +16 -2
- package/dist/lib/index.auth.d.ts +11 -0
- package/dist/lib/index.client.d.ts +2 -0
- package/dist/lib/index.mail.d.ts +8 -0
- package/dist/lib/index.server.d.ts +4 -6
- package/dist/lib/index.validator.d.ts +6 -0
- package/dist/lib/mail/MailProvider.d.ts +10 -0
- package/dist/lib/mail/MailService.d.ts +57 -0
- package/dist/lib/mail/Mailable.d.ts +106 -0
- package/dist/lib/mail/index.d.ts +6 -0
- package/dist/lib/mail/queue/MailQueue.d.ts +51 -0
- package/dist/lib/mail/queue/index.d.ts +1 -0
- package/dist/lib/mail/types/MailConfig.d.ts +146 -0
- package/dist/lib/mail/types/index.d.ts +1 -0
- package/dist/lib/mail/utils/TemplateRenderer.d.ts +34 -0
- package/dist/lib/mail/utils/index.d.ts +1 -0
- package/dist/lib/server/ArcanaJSServer.d.ts +14 -41
- package/dist/lib/server/Container.d.ts +8 -0
- package/dist/lib/server/DynamicRouter.d.ts +1 -1
- package/dist/lib/server/Router.d.ts +23 -33
- package/dist/lib/server/support/ServiceProvider.d.ts +4 -0
- package/dist/lib/validation/Validator.d.ts +55 -0
- package/dist/types/express.d.ts +45 -0
- package/dist/types/global.d.ts +103 -0
- package/package.json +71 -15
- package/dist/lib/arcanox/index.d.ts +0 -13
- package/dist/lib/server/validation/Validator.d.ts +0 -12
- /package/dist/lib/{server/validation → validation}/ValidationException.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toPascalCase: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const writeFile: (dir: string, fileName: string, content: string) => Promise<void>;
|
|
@@ -16,6 +16,9 @@ export interface RelationConfig {
|
|
|
16
16
|
pivotTable?: string;
|
|
17
17
|
}
|
|
18
18
|
import { Macroable } from "./support/Macroable";
|
|
19
|
+
declare global {
|
|
20
|
+
var ArcanaDatabaseAdapter: DatabaseAdapter | undefined;
|
|
21
|
+
}
|
|
19
22
|
/**
|
|
20
23
|
* Base Model class - Arcanox ORM
|
|
21
24
|
*/
|
|
@@ -43,6 +46,10 @@ export declare class Model<T = any> extends Macroable {
|
|
|
43
46
|
* Set the database adapter
|
|
44
47
|
*/
|
|
45
48
|
static setAdapter(adapter: DatabaseAdapter): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get the database adapter
|
|
51
|
+
*/
|
|
52
|
+
protected static getAdapter(): DatabaseAdapter;
|
|
46
53
|
/**
|
|
47
54
|
* Get the table name
|
|
48
55
|
*/
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ServiceProvider } from "../../server/support/ServiceProvider";
|
|
2
|
+
/**
|
|
3
|
+
* Database Service Provider
|
|
4
|
+
*
|
|
5
|
+
* Registers and bootstraps the database system
|
|
6
|
+
*/
|
|
7
|
+
export declare class DatabaseProvider extends ServiceProvider {
|
|
8
|
+
register(): Promise<void>;
|
|
9
|
+
shutdown(): Promise<void>;
|
|
5
10
|
}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { DatabaseAdapter } from "../types";
|
|
2
2
|
import { Blueprint } from "./Blueprint";
|
|
3
|
+
/**
|
|
4
|
+
* Schema - ArcnanJS schema builder
|
|
5
|
+
* Provides fluent interface for creating and modifying database tables
|
|
6
|
+
*/
|
|
7
|
+
declare global {
|
|
8
|
+
var ArcanaDatabaseAdapter: DatabaseAdapter | undefined;
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* Schema - ArcnanJS schema builder
|
|
5
12
|
* Provides fluent interface for creating and modifying database tables
|
|
6
13
|
*/
|
|
7
14
|
export declare class Schema {
|
|
8
15
|
private static adapter;
|
|
16
|
+
/**
|
|
17
|
+
* Get the database adapter
|
|
18
|
+
*/
|
|
19
|
+
private static getAdapter;
|
|
9
20
|
/**
|
|
10
21
|
* Set the database adapter
|
|
11
22
|
*/
|
|
@@ -27,12 +27,14 @@ export interface DatabaseAdapter {
|
|
|
27
27
|
}
|
|
28
28
|
export interface DatabaseConfig {
|
|
29
29
|
type: "postgres" | "mysql" | "mongodb";
|
|
30
|
-
host
|
|
31
|
-
port
|
|
30
|
+
host?: string;
|
|
31
|
+
port?: number;
|
|
32
32
|
database: string;
|
|
33
33
|
username?: string;
|
|
34
34
|
password?: string;
|
|
35
35
|
ssl?: boolean;
|
|
36
|
+
url?: string;
|
|
37
|
+
uri?: string;
|
|
36
38
|
pool?: {
|
|
37
39
|
min?: number;
|
|
38
40
|
max?: number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceProvider } from "../server/support/ServiceProvider";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication Service Provider
|
|
4
|
+
*
|
|
5
|
+
* Registers and bootstraps the authentication system
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthProvider extends ServiceProvider {
|
|
8
|
+
register(): Promise<void>;
|
|
9
|
+
boot(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import jwt from "jsonwebtoken";
|
|
2
|
+
import { AuthConfig, JWTPayload } from "./types";
|
|
3
|
+
export declare class JWTService {
|
|
4
|
+
private static config;
|
|
5
|
+
static init(config: AuthConfig["jwt"]): void;
|
|
6
|
+
static generateToken(payload: JWTPayload, options?: jwt.SignOptions): string;
|
|
7
|
+
static generateRefreshToken(payload: JWTPayload): string;
|
|
8
|
+
static verifyToken(token: string): Promise<JWTPayload>;
|
|
9
|
+
static revokeToken(token: string): Promise<void>;
|
|
10
|
+
static refreshAccessToken(refreshToken: string): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuthConfig } from "./types";
|
|
2
|
+
export declare class SessionManager {
|
|
3
|
+
static createMiddleware(config: AuthConfig["session"]): import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
4
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
|
+
import { Middleware } from "../../server/http/Middleware";
|
|
3
|
+
export declare class RoleMiddleware implements Middleware {
|
|
4
|
+
private roles;
|
|
5
|
+
constructor(...roles: string[]);
|
|
6
|
+
handle(req: Request, res: Response, next: NextFunction): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface AuthConfig {
|
|
2
|
+
jwt: {
|
|
3
|
+
secret: string;
|
|
4
|
+
accessTokenExpiry?: string | number;
|
|
5
|
+
refreshTokenExpiry?: string | number;
|
|
6
|
+
algorithm?: "HS256" | "RS256";
|
|
7
|
+
};
|
|
8
|
+
session: {
|
|
9
|
+
secret: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
maxAge?: number;
|
|
12
|
+
secure?: boolean;
|
|
13
|
+
redis?: {
|
|
14
|
+
host: string;
|
|
15
|
+
port: number;
|
|
16
|
+
password?: string;
|
|
17
|
+
db?: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
tokenBlacklist?: {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
storage: "memory" | "redis";
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class PasswordHasher {
|
|
2
|
+
private static readonly SALT_ROUNDS;
|
|
3
|
+
/**
|
|
4
|
+
* Hash a password.
|
|
5
|
+
* @param password The password to hash.
|
|
6
|
+
* @returns The hashed password.
|
|
7
|
+
*/
|
|
8
|
+
static hash(password: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Verify a password against a hash.
|
|
11
|
+
* @param password The plain text password.
|
|
12
|
+
* @param hash The hashed password.
|
|
13
|
+
* @returns True if the password matches the hash.
|
|
14
|
+
*/
|
|
15
|
+
static verify(password: string, hash: string): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthConfig } from "../types";
|
|
2
|
+
export declare class TokenBlacklist {
|
|
3
|
+
private static redisClient;
|
|
4
|
+
private static memoryStore;
|
|
5
|
+
private static config;
|
|
6
|
+
static init(config: AuthConfig["tokenBlacklist"], redisConfig?: AuthConfig["session"]["redis"]): Promise<void>;
|
|
7
|
+
static add(token: string, expiresInSeconds: number): Promise<void>;
|
|
8
|
+
static isRevoked(token: string): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { MongoAdapter } from "./arcanox/adapters/MongoAdapter";
|
|
4
|
+
export { MySQLAdapter } from "./arcanox/adapters/MySQLAdapter";
|
|
5
|
+
export { PostgresAdapter } from "./arcanox/adapters/PostgresAdapter";
|
|
6
|
+
export { Model } from "./arcanox/Model";
|
|
7
|
+
export { QueryBuilder } from "./arcanox/QueryBuilder";
|
|
8
|
+
export { BelongsTo } from "./arcanox/relations/BelongsTo";
|
|
9
|
+
export { BelongsToMany } from "./arcanox/relations/BelongsToMany";
|
|
10
|
+
export { HasMany } from "./arcanox/relations/HasMany";
|
|
11
|
+
export { HasOne } from "./arcanox/relations/HasOne";
|
|
12
|
+
export { Relation } from "./arcanox/relations/Relation";
|
|
13
|
+
export { Macroable } from "./arcanox/support/Macroable";
|
|
14
|
+
export type { ColumnDefinition, Connection, DatabaseAdapter, DatabaseConfig, JoinClause, OrderByClause, SelectOptions, WhereClause, } from "./arcanox/types";
|
|
3
15
|
export { Blueprint, Migration, MigrationRunner, Schema, } from "./arcanox/schema";
|
|
4
16
|
export type { MigrationStatus } from "./arcanox/schema";
|
|
5
17
|
export { Factory } from "./arcanox/factory";
|
|
6
18
|
export { Seeder } from "./arcanox/seeder";
|
|
19
|
+
export * from "./arcanox/extensions/MongoExtensions";
|
|
20
|
+
export { DatabaseProvider } from "./arcanox/providers/DatabaseProvider";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { AuthProvider } from "./auth/AuthProvider";
|
|
4
|
+
export { JWTService } from "./auth/JWTService";
|
|
5
|
+
export { AuthenticatedMiddleware } from "./auth/middleware/AuthenticatedMiddleware";
|
|
6
|
+
export { AuthMiddleware } from "./auth/middleware/AuthMiddleware";
|
|
7
|
+
export { GuestMiddleware } from "./auth/middleware/GuestMiddleware";
|
|
8
|
+
export { RoleMiddleware } from "./auth/middleware/RoleMiddleware";
|
|
9
|
+
export { SessionManager } from "./auth/SessionManager";
|
|
10
|
+
export type { AuthConfig, JWTPayload } from "./auth/types";
|
|
11
|
+
export { PasswordHasher } from "./auth/utils/PasswordHasher";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { Mailable } from "./mail/Mailable";
|
|
4
|
+
export { MailProvider } from "./mail/MailProvider";
|
|
5
|
+
export { MailService } from "./mail/MailService";
|
|
6
|
+
export { MailQueue } from "./mail/queue/MailQueue";
|
|
7
|
+
export type { MailAttachment, MailConfig, MailDriver, MailFromConfig, MailgunConfig, MailMessage, MailQueueConfig, MailTemplateConfig, SendGridConfig, SESConfig, SMTPConfig, } from "./mail/types";
|
|
8
|
+
export { TemplateRenderer } from "./mail/utils/TemplateRenderer";
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
1
3
|
import { Express } from "express";
|
|
2
4
|
import ArcanaJSServer, { ArcanaJSConfig } from "./server/ArcanaJSServer";
|
|
3
5
|
export { default as ArcanaJSServer } from "./server/ArcanaJSServer";
|
|
4
6
|
export { Container } from "./server/Container";
|
|
5
7
|
export { Express, NextFunction, Request, Response } from "express";
|
|
6
|
-
export { FormRequest } from "./server/http/FormRequest";
|
|
7
|
-
export { JsonResource } from "./server/http/JsonResource";
|
|
8
|
-
export type { Middleware } from "./server/http/Middleware";
|
|
9
8
|
export { default as Route } from "./server/Router";
|
|
9
|
+
export type { Middleware } from "./server/http/Middleware";
|
|
10
10
|
export { ServiceProvider } from "./server/support/ServiceProvider";
|
|
11
|
-
export { ValidationException } from "./server/validation/ValidationException";
|
|
12
|
-
export { Validator } from "./server/validation/Validator";
|
|
13
11
|
/**
|
|
14
12
|
* Create an ArcanaJS server with the given Express app
|
|
15
13
|
*
|
|
@@ -25,7 +23,7 @@ export { Validator } from "./server/validation/Validator";
|
|
|
25
23
|
* const app = express();
|
|
26
24
|
* const server = createArcanaServer(app, {
|
|
27
25
|
* port: 3000,
|
|
28
|
-
* viewsDir: 'src/views',
|
|
26
|
+
* viewsDir: 'src/resources/views',
|
|
29
27
|
* });
|
|
30
28
|
*
|
|
31
29
|
* server.start();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { FormRequest } from "./server/http/FormRequest";
|
|
4
|
+
export { JsonResource } from "./server/http/JsonResource";
|
|
5
|
+
export { ValidationException } from "./validation/ValidationException";
|
|
6
|
+
export { Validator } from "./validation/Validator";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceProvider } from "../server/support/ServiceProvider";
|
|
2
|
+
/**
|
|
3
|
+
* Mail Service Provider
|
|
4
|
+
*
|
|
5
|
+
* Registers and bootstraps the mail system
|
|
6
|
+
*/
|
|
7
|
+
export declare class MailProvider extends ServiceProvider {
|
|
8
|
+
register(): Promise<void>;
|
|
9
|
+
boot(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Mailable } from "./Mailable";
|
|
2
|
+
import { MailConfig, MailMessage } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Core mail service for sending emails
|
|
5
|
+
*/
|
|
6
|
+
export declare class MailService {
|
|
7
|
+
private static config?;
|
|
8
|
+
private static transporter?;
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the mail service
|
|
11
|
+
*/
|
|
12
|
+
static init(config: MailConfig): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Create nodemailer transporter based on configuration
|
|
15
|
+
*/
|
|
16
|
+
private static createTransporter;
|
|
17
|
+
/**
|
|
18
|
+
* Create SMTP transporter
|
|
19
|
+
*/
|
|
20
|
+
private static createSMTPTransporter;
|
|
21
|
+
/**
|
|
22
|
+
* Create SendGrid transporter
|
|
23
|
+
*/
|
|
24
|
+
private static createSendGridTransporter;
|
|
25
|
+
/**
|
|
26
|
+
* Create Mailgun transporter
|
|
27
|
+
*/
|
|
28
|
+
private static createMailgunTransporter;
|
|
29
|
+
/**
|
|
30
|
+
* Create AWS SES transporter
|
|
31
|
+
*/
|
|
32
|
+
private static createSESTransporter;
|
|
33
|
+
/**
|
|
34
|
+
* Create log-only transporter (for testing)
|
|
35
|
+
*/
|
|
36
|
+
private static createLogTransporter;
|
|
37
|
+
/**
|
|
38
|
+
* Send an email immediately
|
|
39
|
+
*/
|
|
40
|
+
static send(mailable: Mailable | MailMessage): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Queue an email for async sending
|
|
43
|
+
*/
|
|
44
|
+
static queue(mailable: Mailable): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Send a raw email message
|
|
47
|
+
*/
|
|
48
|
+
static sendRaw(message: MailMessage): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Get the mail configuration
|
|
51
|
+
*/
|
|
52
|
+
static getConfig(): MailConfig | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Verify transporter connection
|
|
55
|
+
*/
|
|
56
|
+
static verify(): Promise<boolean>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { MailAttachment, MailMessage } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for creating email messages
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* class WelcomeEmail extends Mailable {
|
|
8
|
+
* constructor(private user: User) {
|
|
9
|
+
* super();
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* build() {
|
|
13
|
+
* return this
|
|
14
|
+
* .to(this.user.email)
|
|
15
|
+
* .subject('Welcome to ArcanaJS!')
|
|
16
|
+
* .view('emails/welcome', { name: this.user.name });
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // Send the email
|
|
21
|
+
* await new WelcomeEmail(user).send();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class Mailable {
|
|
25
|
+
protected message: Partial<MailMessage>;
|
|
26
|
+
protected viewName?: string;
|
|
27
|
+
protected viewData?: Record<string, any>;
|
|
28
|
+
/**
|
|
29
|
+
* Build the email message
|
|
30
|
+
* Must be implemented by subclasses
|
|
31
|
+
*/
|
|
32
|
+
abstract build(): this;
|
|
33
|
+
/**
|
|
34
|
+
* Set the recipient(s)
|
|
35
|
+
*/
|
|
36
|
+
to(address: string | string[], name?: string): this;
|
|
37
|
+
/**
|
|
38
|
+
* Set the sender
|
|
39
|
+
*/
|
|
40
|
+
from(address: string, name?: string): this;
|
|
41
|
+
/**
|
|
42
|
+
* Set the email subject
|
|
43
|
+
*/
|
|
44
|
+
subject(subject: string): this;
|
|
45
|
+
/**
|
|
46
|
+
* Set the email view template
|
|
47
|
+
*/
|
|
48
|
+
view(template: string, data?: Record<string, any>): this;
|
|
49
|
+
/**
|
|
50
|
+
* Set HTML content directly
|
|
51
|
+
*/
|
|
52
|
+
html(content: string): this;
|
|
53
|
+
/**
|
|
54
|
+
* Set plain text content
|
|
55
|
+
*/
|
|
56
|
+
text(content: string): this;
|
|
57
|
+
/**
|
|
58
|
+
* Add CC recipient(s)
|
|
59
|
+
*/
|
|
60
|
+
cc(address: string | string[]): this;
|
|
61
|
+
/**
|
|
62
|
+
* Add BCC recipient(s)
|
|
63
|
+
*/
|
|
64
|
+
bcc(address: string | string[]): this;
|
|
65
|
+
/**
|
|
66
|
+
* Set reply-to address
|
|
67
|
+
*/
|
|
68
|
+
replyTo(address: string): this;
|
|
69
|
+
/**
|
|
70
|
+
* Add an attachment
|
|
71
|
+
*/
|
|
72
|
+
attach(attachment: MailAttachment): this;
|
|
73
|
+
/**
|
|
74
|
+
* Attach a file from path
|
|
75
|
+
*/
|
|
76
|
+
attachFromPath(path: string, filename?: string): this;
|
|
77
|
+
/**
|
|
78
|
+
* Attach data as a file
|
|
79
|
+
*/
|
|
80
|
+
attachData(content: string | Buffer, filename: string, contentType?: string): this;
|
|
81
|
+
/**
|
|
82
|
+
* Set email priority
|
|
83
|
+
*/
|
|
84
|
+
priority(level: "high" | "normal" | "low"): this;
|
|
85
|
+
/**
|
|
86
|
+
* Add custom headers
|
|
87
|
+
*/
|
|
88
|
+
withHeaders(headers: Record<string, string>): this;
|
|
89
|
+
/**
|
|
90
|
+
* Get the built message
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
getMessage(): {
|
|
94
|
+
message: Partial<MailMessage>;
|
|
95
|
+
viewName?: string;
|
|
96
|
+
viewData?: Record<string, any>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Send the email immediately
|
|
100
|
+
*/
|
|
101
|
+
send(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Queue the email for async sending
|
|
104
|
+
*/
|
|
105
|
+
queue(): Promise<void>;
|
|
106
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Mailable } from "../Mailable";
|
|
2
|
+
import { MailQueueConfig } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Mail queue for async email processing
|
|
5
|
+
*/
|
|
6
|
+
export declare class MailQueue {
|
|
7
|
+
private static config?;
|
|
8
|
+
private static queue;
|
|
9
|
+
private static processing;
|
|
10
|
+
private static redisClient?;
|
|
11
|
+
/**
|
|
12
|
+
* Initialize the mail queue
|
|
13
|
+
*/
|
|
14
|
+
static init(config: MailQueueConfig): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize Redis connection
|
|
17
|
+
*/
|
|
18
|
+
private static initRedis;
|
|
19
|
+
/**
|
|
20
|
+
* Add a job to the queue
|
|
21
|
+
*/
|
|
22
|
+
static add(mailable: Mailable): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Start processing the queue
|
|
25
|
+
*/
|
|
26
|
+
private static startProcessing;
|
|
27
|
+
/**
|
|
28
|
+
* Process next job in queue
|
|
29
|
+
*/
|
|
30
|
+
private static processNext;
|
|
31
|
+
/**
|
|
32
|
+
* Handle failed job
|
|
33
|
+
*/
|
|
34
|
+
private static handleFailedJob;
|
|
35
|
+
/**
|
|
36
|
+
* Store failed job for manual review
|
|
37
|
+
*/
|
|
38
|
+
private static storeFailedJob;
|
|
39
|
+
/**
|
|
40
|
+
* Generate unique job ID
|
|
41
|
+
*/
|
|
42
|
+
private static generateId;
|
|
43
|
+
/**
|
|
44
|
+
* Get queue size
|
|
45
|
+
*/
|
|
46
|
+
static size(): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* Clear the queue
|
|
49
|
+
*/
|
|
50
|
+
static clear(): Promise<void>;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MailQueue";
|