@astralibx/email-account-manager 2.0.2 → 4.0.0
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/README.md +10 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,15 @@ app.use('/webhooks/ses', eam.webhookRoutes.ses);
|
|
|
52
52
|
// Unsubscribe pages (public)
|
|
53
53
|
app.use('/unsubscribe', eam.unsubscribeRoutes);
|
|
54
54
|
|
|
55
|
+
// Create an account with metadata
|
|
56
|
+
await eam.accounts.create({
|
|
57
|
+
email: 'outreach@yourdomain.com',
|
|
58
|
+
senderName: 'Your Company',
|
|
59
|
+
provider: 'gmail',
|
|
60
|
+
smtp: { host: 'smtp.gmail.com', port: 587, user: 'outreach@yourdomain.com', pass: 'app-password' },
|
|
61
|
+
metadata: { sender_names: ['Sales', 'Support'], contact_number: '+1-555-0100' },
|
|
62
|
+
});
|
|
63
|
+
|
|
55
64
|
// Send an email programmatically
|
|
56
65
|
const result = await eam.smtp.send({
|
|
57
66
|
to: 'recipient@example.com',
|
|
@@ -66,7 +75,7 @@ app.listen(3000);
|
|
|
66
75
|
|
|
67
76
|
## Features
|
|
68
77
|
|
|
69
|
-
- **Multi-account management** -- Gmail and AWS SES providers with credential storage and
|
|
78
|
+
- **Multi-account management** -- Gmail and AWS SES providers with credential storage, status tracking, and freeform metadata. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/account-management.md)
|
|
70
79
|
- **Health tracking** -- Automatic scoring (+1/-5/-10) with auto-disable on threshold breach. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/health-tracking.md)
|
|
71
80
|
- **Account warmup** -- Phased volume ramp-up with configurable schedules stored per-account. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/warmup-system.md)
|
|
72
81
|
- **Capacity-based rotation** -- Health-weighted account selection with daily limit enforcement. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/capacity-selection.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -392,6 +392,7 @@ interface EmailAccount {
|
|
|
392
392
|
limits: AccountLimits;
|
|
393
393
|
health: AccountHealthData;
|
|
394
394
|
warmup: AccountWarmupData;
|
|
395
|
+
metadata?: Record<string, unknown>;
|
|
395
396
|
totalEmailsSent: number;
|
|
396
397
|
lastSuccessfulSendAt?: Date;
|
|
397
398
|
createdAt: Date;
|
|
@@ -408,6 +409,7 @@ interface CreateEmailAccountInput {
|
|
|
408
409
|
warmup?: {
|
|
409
410
|
schedule?: WarmupPhase[];
|
|
410
411
|
};
|
|
412
|
+
metadata?: Record<string, unknown>;
|
|
411
413
|
health?: {
|
|
412
414
|
thresholds?: Partial<HealthThresholds>;
|
|
413
415
|
};
|
|
@@ -420,6 +422,7 @@ interface UpdateEmailAccountInput {
|
|
|
420
422
|
ses?: Partial<SesConfig>;
|
|
421
423
|
limits?: Partial<AccountLimits>;
|
|
422
424
|
warmup?: Partial<AccountWarmupData>;
|
|
425
|
+
metadata?: Record<string, unknown>;
|
|
423
426
|
health?: {
|
|
424
427
|
thresholds?: Partial<HealthThresholds>;
|
|
425
428
|
};
|
|
@@ -484,6 +487,7 @@ interface IEmailAccount {
|
|
|
484
487
|
currentDay: number;
|
|
485
488
|
schedule: WarmupPhase[];
|
|
486
489
|
};
|
|
490
|
+
metadata?: Record<string, unknown>;
|
|
487
491
|
totalEmailsSent: number;
|
|
488
492
|
lastSuccessfulSendAt?: Date;
|
|
489
493
|
lastImapCheckAt?: Date;
|
package/dist/index.d.ts
CHANGED
|
@@ -392,6 +392,7 @@ interface EmailAccount {
|
|
|
392
392
|
limits: AccountLimits;
|
|
393
393
|
health: AccountHealthData;
|
|
394
394
|
warmup: AccountWarmupData;
|
|
395
|
+
metadata?: Record<string, unknown>;
|
|
395
396
|
totalEmailsSent: number;
|
|
396
397
|
lastSuccessfulSendAt?: Date;
|
|
397
398
|
createdAt: Date;
|
|
@@ -408,6 +409,7 @@ interface CreateEmailAccountInput {
|
|
|
408
409
|
warmup?: {
|
|
409
410
|
schedule?: WarmupPhase[];
|
|
410
411
|
};
|
|
412
|
+
metadata?: Record<string, unknown>;
|
|
411
413
|
health?: {
|
|
412
414
|
thresholds?: Partial<HealthThresholds>;
|
|
413
415
|
};
|
|
@@ -420,6 +422,7 @@ interface UpdateEmailAccountInput {
|
|
|
420
422
|
ses?: Partial<SesConfig>;
|
|
421
423
|
limits?: Partial<AccountLimits>;
|
|
422
424
|
warmup?: Partial<AccountWarmupData>;
|
|
425
|
+
metadata?: Record<string, unknown>;
|
|
423
426
|
health?: {
|
|
424
427
|
thresholds?: Partial<HealthThresholds>;
|
|
425
428
|
};
|
|
@@ -484,6 +487,7 @@ interface IEmailAccount {
|
|
|
484
487
|
currentDay: number;
|
|
485
488
|
schedule: WarmupPhase[];
|
|
486
489
|
};
|
|
490
|
+
metadata?: Record<string, unknown>;
|
|
487
491
|
totalEmailsSent: number;
|
|
488
492
|
lastSuccessfulSendAt?: Date;
|
|
489
493
|
lastImapCheckAt?: Date;
|
package/dist/index.js
CHANGED
|
@@ -314,6 +314,10 @@ function createEmailAccountSchema(options) {
|
|
|
314
314
|
required: true,
|
|
315
315
|
_id: false
|
|
316
316
|
},
|
|
317
|
+
metadata: {
|
|
318
|
+
type: mongoose.Schema.Types.Mixed,
|
|
319
|
+
default: {}
|
|
320
|
+
},
|
|
317
321
|
totalEmailsSent: { type: Number, default: 0 },
|
|
318
322
|
lastSuccessfulSendAt: Date,
|
|
319
323
|
lastImapCheckAt: Date
|
|
@@ -2206,6 +2210,16 @@ function createApprovalProcessor(EmailDraft, smtpService, queueService, logger)
|
|
|
2206
2210
|
}
|
|
2207
2211
|
|
|
2208
2212
|
// src/controllers/account.controller.ts
|
|
2213
|
+
var MAX_METADATA_SIZE = 64e3;
|
|
2214
|
+
function sanitizeMetadata(raw) {
|
|
2215
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};
|
|
2216
|
+
const json2 = JSON.stringify(raw);
|
|
2217
|
+
if (json2.length > MAX_METADATA_SIZE) {
|
|
2218
|
+
throw new Error(`metadata exceeds ${MAX_METADATA_SIZE} byte limit`);
|
|
2219
|
+
}
|
|
2220
|
+
const { __proto__: _a, constructor: _b, prototype: _c, ...safe } = raw;
|
|
2221
|
+
return safe;
|
|
2222
|
+
}
|
|
2209
2223
|
function createAccountController(EmailAccount, capacityManager, healthTracker, warmupManager, smtpService, imapBounceChecker, config) {
|
|
2210
2224
|
return {
|
|
2211
2225
|
async list(req, res) {
|
|
@@ -2266,6 +2280,7 @@ function createAccountController(EmailAccount, capacityManager, healthTracker, w
|
|
|
2266
2280
|
schedule: input.warmup?.schedule || warmupDefaults || []
|
|
2267
2281
|
},
|
|
2268
2282
|
status: "warmup",
|
|
2283
|
+
...input.metadata !== void 0 ? { metadata: sanitizeMetadata(input.metadata) } : {},
|
|
2269
2284
|
totalEmailsSent: 0
|
|
2270
2285
|
};
|
|
2271
2286
|
const account = await EmailAccount.create(accountData);
|
|
@@ -2300,6 +2315,7 @@ function createAccountController(EmailAccount, capacityManager, healthTracker, w
|
|
|
2300
2315
|
}
|
|
2301
2316
|
}
|
|
2302
2317
|
if (input.limits?.dailyMax !== void 0) updates["limits.dailyMax"] = input.limits.dailyMax;
|
|
2318
|
+
if (input.metadata !== void 0) updates.metadata = sanitizeMetadata(input.metadata);
|
|
2303
2319
|
const account = await EmailAccount.findByIdAndUpdate(
|
|
2304
2320
|
req.params.id,
|
|
2305
2321
|
{ $set: updates },
|