@astralibx/email-account-manager 8.0.0 → 9.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 CHANGED
@@ -102,7 +102,7 @@ All services are also available programmatically via the returned `eam` object.
102
102
  ## Getting Started Guide
103
103
 
104
104
  1. [Configuration](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/configuration.md) — Set up database, Redis, queues, and hooks
105
- 2. [Account Management](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/account-management.md) — Create and manage email accounts
105
+ 2. [Account Management](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/account-management.md) — Create and manage email accounts (see [default values](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/account-management.md#default-values))
106
106
  3. [Warmup System](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/warmup-system.md) — Gradually increase sending volume (**requires daily `advanceDay()` cron**)
107
107
  4. [Health Tracking](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/health-tracking.md) — Monitor account health and auto-disable unhealthy accounts
108
108
  5. [Email Sending](https://github.com/Hariprakash1997/astralib/blob/main/packages/email-account-manager/docs/email-sending.md) — Send emails via SMTP with queue-based processing
package/dist/index.cjs CHANGED
@@ -240,8 +240,7 @@ function createEmailAccountSchema(options) {
240
240
  status: {
241
241
  type: String,
242
242
  enum: Object.values(ACCOUNT_STATUS),
243
- default: ACCOUNT_STATUS.Active,
244
- index: true
243
+ default: ACCOUNT_STATUS.Active
245
244
  },
246
245
  // WARNING: SMTP/IMAP credentials are stored as plaintext in the database.
247
246
  // Consumers MUST encrypt `smtp.pass` and `imap.pass` at the application layer
@@ -275,7 +274,7 @@ function createEmailAccountSchema(options) {
275
274
  },
276
275
  limits: {
277
276
  type: {
278
- dailyMax: { type: Number, required: true, default: 100 }
277
+ dailyMax: { type: Number, required: true, default: 50 }
279
278
  },
280
279
  required: true,
281
280
  _id: false
@@ -288,8 +287,8 @@ function createEmailAccountSchema(options) {
288
287
  thresholds: {
289
288
  type: {
290
289
  minScore: { type: Number, default: 50 },
291
- maxBounceRate: { type: Number, default: 5 },
292
- maxConsecutiveErrors: { type: Number, default: 10 }
290
+ maxBounceRate: { type: Number, default: 0.1 },
291
+ maxConsecutiveErrors: { type: Number, default: 5 }
293
292
  },
294
293
  _id: false
295
294
  }
@@ -355,8 +354,8 @@ function createEmailAccountSchema(options) {
355
354
  function createEmailDailyStatsSchema(options) {
356
355
  const schema = new mongoose.Schema(
357
356
  {
358
- accountId: { type: mongoose.Schema.Types.ObjectId, required: true, index: true },
359
- date: { type: String, required: true, index: true },
357
+ accountId: { type: mongoose.Schema.Types.ObjectId, required: true },
358
+ date: { type: String, required: true },
360
359
  sent: { type: Number, default: 0 },
361
360
  failed: { type: Number, default: 0 },
362
361
  bounced: { type: Number, default: 0 },
@@ -405,8 +404,7 @@ function createEmailIdentifierSchema(options) {
405
404
  status: {
406
405
  type: String,
407
406
  enum: Object.values(IDENTIFIER_STATUS),
408
- default: IDENTIFIER_STATUS.Active,
409
- index: true
407
+ default: IDENTIFIER_STATUS.Active
410
408
  },
411
409
  sentCount: { type: Number, default: 0 },
412
410
  bounceCount: { type: Number, default: 0 },
@@ -487,7 +485,6 @@ function createEmailIdentifierSchema(options) {
487
485
  }
488
486
  );
489
487
  schema.index({ email: 1 }, { unique: true });
490
- schema.index({ status: 1 });
491
488
  return schema;
492
489
  }
493
490
  function createEmailDraftSchema(options) {
@@ -497,12 +494,11 @@ function createEmailDraftSchema(options) {
497
494
  subject: { type: String, required: true },
498
495
  htmlBody: { type: String, required: true },
499
496
  textBody: String,
500
- accountId: { type: mongoose.Schema.Types.ObjectId, required: true, index: true },
497
+ accountId: { type: mongoose.Schema.Types.ObjectId, required: true },
501
498
  status: {
502
499
  type: String,
503
500
  enum: Object.values(DRAFT_STATUS),
504
- default: DRAFT_STATUS.Pending,
505
- index: true
501
+ default: DRAFT_STATUS.Pending
506
502
  },
507
503
  approvedAt: Date,
508
504
  rejectedAt: Date,
@@ -2262,15 +2258,15 @@ function createAccountController(EmailAccount, capacityManager, healthTracker, w
2262
2258
  smtp: input.smtp,
2263
2259
  ...input.imap ? { imap: input.imap } : {},
2264
2260
  ...input.ses ? { ses: input.ses } : {},
2265
- limits: { dailyMax: input.limits?.dailyMax || 450 },
2261
+ limits: { dailyMax: input.limits?.dailyMax ?? 50 },
2266
2262
  health: {
2267
2263
  score: 100,
2268
2264
  consecutiveErrors: 0,
2269
2265
  bounceCount: 0,
2270
2266
  thresholds: {
2271
2267
  minScore: input.health?.thresholds?.minScore ?? healthDefaults?.minScore ?? 50,
2272
- maxBounceRate: input.health?.thresholds?.maxBounceRate ?? healthDefaults?.maxBounceRate ?? 5,
2273
- maxConsecutiveErrors: input.health?.thresholds?.maxConsecutiveErrors ?? healthDefaults?.maxConsecutiveErrors ?? 10
2268
+ maxBounceRate: input.health?.thresholds?.maxBounceRate ?? healthDefaults?.maxBounceRate ?? 0.1,
2269
+ maxConsecutiveErrors: input.health?.thresholds?.maxConsecutiveErrors ?? healthDefaults?.maxConsecutiveErrors ?? 5
2274
2270
  }
2275
2271
  },
2276
2272
  warmup: {