@astralibx/email-rule-engine 12.7.1 → 12.7.2
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/index.cjs +43 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.mjs +42 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -55,6 +55,17 @@ declare const EMAIL_SEND_STATUS: {
|
|
|
55
55
|
readonly Throttled: "throttled";
|
|
56
56
|
};
|
|
57
57
|
type EmailSendStatus = (typeof EMAIL_SEND_STATUS)[keyof typeof EMAIL_SEND_STATUS];
|
|
58
|
+
declare const TARGET_MODE: {
|
|
59
|
+
readonly Query: "query";
|
|
60
|
+
readonly List: "list";
|
|
61
|
+
};
|
|
62
|
+
type TargetMode = (typeof TARGET_MODE)[keyof typeof TARGET_MODE];
|
|
63
|
+
declare const RUN_LOG_STATUS: {
|
|
64
|
+
readonly Completed: "completed";
|
|
65
|
+
readonly Cancelled: "cancelled";
|
|
66
|
+
readonly Failed: "failed";
|
|
67
|
+
};
|
|
68
|
+
type RunLogStatus = (typeof RUN_LOG_STATUS)[keyof typeof RUN_LOG_STATUS];
|
|
58
69
|
|
|
59
70
|
interface RuleCondition {
|
|
60
71
|
field: string;
|
|
@@ -202,6 +213,11 @@ interface SendEmailParams {
|
|
|
202
213
|
textBody: string;
|
|
203
214
|
ruleId: string;
|
|
204
215
|
autoApprove: boolean;
|
|
216
|
+
attachments?: Array<{
|
|
217
|
+
filename: string;
|
|
218
|
+
url: string;
|
|
219
|
+
contentType: string;
|
|
220
|
+
}>;
|
|
205
221
|
}
|
|
206
222
|
interface AgentSelection {
|
|
207
223
|
accountId: string;
|
|
@@ -272,7 +288,11 @@ interface EmailRuleEngineConfig {
|
|
|
272
288
|
templateId: string;
|
|
273
289
|
}) => Promise<AgentSelection | null>;
|
|
274
290
|
findIdentifier: (email: string) => Promise<RecipientIdentifier | null>;
|
|
275
|
-
sendTestEmail?: (to: string, subject: string, html: string, text: string
|
|
291
|
+
sendTestEmail?: (to: string, subject: string, html: string, text: string, attachments?: Array<{
|
|
292
|
+
filename: string;
|
|
293
|
+
url: string;
|
|
294
|
+
contentType: string;
|
|
295
|
+
}>) => Promise<void>;
|
|
276
296
|
};
|
|
277
297
|
platforms?: string[];
|
|
278
298
|
audiences?: string[];
|
|
@@ -331,6 +351,11 @@ interface EmailRuleEngineConfig {
|
|
|
331
351
|
};
|
|
332
352
|
}
|
|
333
353
|
|
|
354
|
+
interface EmailAttachment {
|
|
355
|
+
filename: string;
|
|
356
|
+
url: string;
|
|
357
|
+
contentType: string;
|
|
358
|
+
}
|
|
334
359
|
interface EmailTemplate {
|
|
335
360
|
_id: string;
|
|
336
361
|
name: string;
|
|
@@ -347,6 +372,7 @@ interface EmailTemplate {
|
|
|
347
372
|
variables: string[];
|
|
348
373
|
version: number;
|
|
349
374
|
isActive: boolean;
|
|
375
|
+
attachments?: EmailAttachment[];
|
|
350
376
|
createdAt: Date;
|
|
351
377
|
updatedAt: Date;
|
|
352
378
|
}
|
|
@@ -363,6 +389,7 @@ interface CreateEmailTemplateInput {
|
|
|
363
389
|
preheaders?: string[];
|
|
364
390
|
fields?: Record<string, string>;
|
|
365
391
|
variables?: string[];
|
|
392
|
+
attachments?: EmailAttachment[];
|
|
366
393
|
}
|
|
367
394
|
interface UpdateEmailTemplateInput {
|
|
368
395
|
name?: string;
|
|
@@ -376,6 +403,7 @@ interface UpdateEmailTemplateInput {
|
|
|
376
403
|
preheaders?: string[];
|
|
377
404
|
fields?: Record<string, string>;
|
|
378
405
|
variables?: string[];
|
|
406
|
+
attachments?: EmailAttachment[];
|
|
379
407
|
isActive?: boolean;
|
|
380
408
|
}
|
|
381
409
|
|
|
@@ -766,4 +794,4 @@ interface EmailRuleEngine {
|
|
|
766
794
|
*/
|
|
767
795
|
declare function createEmailRuleEngine(config: EmailRuleEngineConfig): EmailRuleEngine;
|
|
768
796
|
|
|
769
|
-
export { type AgentSelection, AlxEmailError, type BeforeSendParams, type BeforeSendResult, type CompiledTemplate, ConfigValidationError, type CreateEmailRuleInput, type CreateEmailTemplateInput, DuplicateSlugError, EMAIL_SEND_STATUS, EMAIL_TYPE, type EmailRule, type EmailRuleDocument, type EmailRuleEngine, type EmailRuleEngineConfig, type EmailRuleModel, type EmailRuleRunLog, type EmailRuleRunLogDocument, type EmailRuleRunLogModel, type EmailRuleRunLogStatics, type EmailRuleSend, type EmailRuleSendDocument, type EmailRuleSendModel, type EmailRuleSendStatics, type EmailRuleStatics, type EmailSendStatus, type EmailTemplate, type EmailTemplateDocument, type EmailTemplateModel, type EmailTemplateStatics, type EmailThrottleConfig, type EmailThrottleConfigDocument, type EmailThrottleConfigModel, type EmailThrottleConfigStatics, type EmailType, type IEmailRule, type IEmailRuleRunLog, type IEmailRuleSend, type IEmailTemplate, type IEmailThrottleConfig, type ListTarget, LockAcquisitionError, type PerRuleStats, type QueryTarget, RULE_OPERATOR, RUN_TRIGGER, type RecipientIdentifier, type RenderResult, type RuleCondition, RuleNotFoundError, type RuleOperator, type RuleRunStats, RuleRunnerService, RuleService, type RuleTarget, RuleTemplateIncompatibleError, type RunTrigger, SchedulerService, type SendEmailParams, TEMPLATE_AUDIENCE, TEMPLATE_CATEGORY, THROTTLE_WINDOW, type TemplateAudience, type TemplateCategory, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, type ThrottleWindow, type UpdateEmailRuleInput, type UpdateEmailTemplateInput, type UpdateEmailThrottleConfigInput, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, validateConfig };
|
|
797
|
+
export { type AgentSelection, AlxEmailError, type BeforeSendParams, type BeforeSendResult, type CompiledTemplate, ConfigValidationError, type CreateEmailRuleInput, type CreateEmailTemplateInput, DuplicateSlugError, EMAIL_SEND_STATUS, EMAIL_TYPE, type EmailAttachment, type EmailRule, type EmailRuleDocument, type EmailRuleEngine, type EmailRuleEngineConfig, type EmailRuleModel, type EmailRuleRunLog, type EmailRuleRunLogDocument, type EmailRuleRunLogModel, type EmailRuleRunLogStatics, type EmailRuleSend, type EmailRuleSendDocument, type EmailRuleSendModel, type EmailRuleSendStatics, type EmailRuleStatics, type EmailSendStatus, type EmailTemplate, type EmailTemplateDocument, type EmailTemplateModel, type EmailTemplateStatics, type EmailThrottleConfig, type EmailThrottleConfigDocument, type EmailThrottleConfigModel, type EmailThrottleConfigStatics, type EmailType, type IEmailRule, type IEmailRuleRunLog, type IEmailRuleSend, type IEmailTemplate, type IEmailThrottleConfig, type ListTarget, LockAcquisitionError, type PerRuleStats, type QueryTarget, RULE_OPERATOR, RUN_LOG_STATUS, RUN_TRIGGER, type RecipientIdentifier, type RenderResult, type RuleCondition, RuleNotFoundError, type RuleOperator, type RuleRunStats, RuleRunnerService, RuleService, type RuleTarget, RuleTemplateIncompatibleError, type RunLogStatus, type RunTrigger, SchedulerService, type SendEmailParams, TARGET_MODE, TEMPLATE_AUDIENCE, TEMPLATE_CATEGORY, THROTTLE_WINDOW, type TargetMode, type TemplateAudience, type TemplateCategory, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, type ThrottleWindow, type UpdateEmailRuleInput, type UpdateEmailTemplateInput, type UpdateEmailThrottleConfigInput, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, validateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,17 @@ declare const EMAIL_SEND_STATUS: {
|
|
|
55
55
|
readonly Throttled: "throttled";
|
|
56
56
|
};
|
|
57
57
|
type EmailSendStatus = (typeof EMAIL_SEND_STATUS)[keyof typeof EMAIL_SEND_STATUS];
|
|
58
|
+
declare const TARGET_MODE: {
|
|
59
|
+
readonly Query: "query";
|
|
60
|
+
readonly List: "list";
|
|
61
|
+
};
|
|
62
|
+
type TargetMode = (typeof TARGET_MODE)[keyof typeof TARGET_MODE];
|
|
63
|
+
declare const RUN_LOG_STATUS: {
|
|
64
|
+
readonly Completed: "completed";
|
|
65
|
+
readonly Cancelled: "cancelled";
|
|
66
|
+
readonly Failed: "failed";
|
|
67
|
+
};
|
|
68
|
+
type RunLogStatus = (typeof RUN_LOG_STATUS)[keyof typeof RUN_LOG_STATUS];
|
|
58
69
|
|
|
59
70
|
interface RuleCondition {
|
|
60
71
|
field: string;
|
|
@@ -202,6 +213,11 @@ interface SendEmailParams {
|
|
|
202
213
|
textBody: string;
|
|
203
214
|
ruleId: string;
|
|
204
215
|
autoApprove: boolean;
|
|
216
|
+
attachments?: Array<{
|
|
217
|
+
filename: string;
|
|
218
|
+
url: string;
|
|
219
|
+
contentType: string;
|
|
220
|
+
}>;
|
|
205
221
|
}
|
|
206
222
|
interface AgentSelection {
|
|
207
223
|
accountId: string;
|
|
@@ -272,7 +288,11 @@ interface EmailRuleEngineConfig {
|
|
|
272
288
|
templateId: string;
|
|
273
289
|
}) => Promise<AgentSelection | null>;
|
|
274
290
|
findIdentifier: (email: string) => Promise<RecipientIdentifier | null>;
|
|
275
|
-
sendTestEmail?: (to: string, subject: string, html: string, text: string
|
|
291
|
+
sendTestEmail?: (to: string, subject: string, html: string, text: string, attachments?: Array<{
|
|
292
|
+
filename: string;
|
|
293
|
+
url: string;
|
|
294
|
+
contentType: string;
|
|
295
|
+
}>) => Promise<void>;
|
|
276
296
|
};
|
|
277
297
|
platforms?: string[];
|
|
278
298
|
audiences?: string[];
|
|
@@ -331,6 +351,11 @@ interface EmailRuleEngineConfig {
|
|
|
331
351
|
};
|
|
332
352
|
}
|
|
333
353
|
|
|
354
|
+
interface EmailAttachment {
|
|
355
|
+
filename: string;
|
|
356
|
+
url: string;
|
|
357
|
+
contentType: string;
|
|
358
|
+
}
|
|
334
359
|
interface EmailTemplate {
|
|
335
360
|
_id: string;
|
|
336
361
|
name: string;
|
|
@@ -347,6 +372,7 @@ interface EmailTemplate {
|
|
|
347
372
|
variables: string[];
|
|
348
373
|
version: number;
|
|
349
374
|
isActive: boolean;
|
|
375
|
+
attachments?: EmailAttachment[];
|
|
350
376
|
createdAt: Date;
|
|
351
377
|
updatedAt: Date;
|
|
352
378
|
}
|
|
@@ -363,6 +389,7 @@ interface CreateEmailTemplateInput {
|
|
|
363
389
|
preheaders?: string[];
|
|
364
390
|
fields?: Record<string, string>;
|
|
365
391
|
variables?: string[];
|
|
392
|
+
attachments?: EmailAttachment[];
|
|
366
393
|
}
|
|
367
394
|
interface UpdateEmailTemplateInput {
|
|
368
395
|
name?: string;
|
|
@@ -376,6 +403,7 @@ interface UpdateEmailTemplateInput {
|
|
|
376
403
|
preheaders?: string[];
|
|
377
404
|
fields?: Record<string, string>;
|
|
378
405
|
variables?: string[];
|
|
406
|
+
attachments?: EmailAttachment[];
|
|
379
407
|
isActive?: boolean;
|
|
380
408
|
}
|
|
381
409
|
|
|
@@ -766,4 +794,4 @@ interface EmailRuleEngine {
|
|
|
766
794
|
*/
|
|
767
795
|
declare function createEmailRuleEngine(config: EmailRuleEngineConfig): EmailRuleEngine;
|
|
768
796
|
|
|
769
|
-
export { type AgentSelection, AlxEmailError, type BeforeSendParams, type BeforeSendResult, type CompiledTemplate, ConfigValidationError, type CreateEmailRuleInput, type CreateEmailTemplateInput, DuplicateSlugError, EMAIL_SEND_STATUS, EMAIL_TYPE, type EmailRule, type EmailRuleDocument, type EmailRuleEngine, type EmailRuleEngineConfig, type EmailRuleModel, type EmailRuleRunLog, type EmailRuleRunLogDocument, type EmailRuleRunLogModel, type EmailRuleRunLogStatics, type EmailRuleSend, type EmailRuleSendDocument, type EmailRuleSendModel, type EmailRuleSendStatics, type EmailRuleStatics, type EmailSendStatus, type EmailTemplate, type EmailTemplateDocument, type EmailTemplateModel, type EmailTemplateStatics, type EmailThrottleConfig, type EmailThrottleConfigDocument, type EmailThrottleConfigModel, type EmailThrottleConfigStatics, type EmailType, type IEmailRule, type IEmailRuleRunLog, type IEmailRuleSend, type IEmailTemplate, type IEmailThrottleConfig, type ListTarget, LockAcquisitionError, type PerRuleStats, type QueryTarget, RULE_OPERATOR, RUN_TRIGGER, type RecipientIdentifier, type RenderResult, type RuleCondition, RuleNotFoundError, type RuleOperator, type RuleRunStats, RuleRunnerService, RuleService, type RuleTarget, RuleTemplateIncompatibleError, type RunTrigger, SchedulerService, type SendEmailParams, TEMPLATE_AUDIENCE, TEMPLATE_CATEGORY, THROTTLE_WINDOW, type TemplateAudience, type TemplateCategory, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, type ThrottleWindow, type UpdateEmailRuleInput, type UpdateEmailTemplateInput, type UpdateEmailThrottleConfigInput, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, validateConfig };
|
|
797
|
+
export { type AgentSelection, AlxEmailError, type BeforeSendParams, type BeforeSendResult, type CompiledTemplate, ConfigValidationError, type CreateEmailRuleInput, type CreateEmailTemplateInput, DuplicateSlugError, EMAIL_SEND_STATUS, EMAIL_TYPE, type EmailAttachment, type EmailRule, type EmailRuleDocument, type EmailRuleEngine, type EmailRuleEngineConfig, type EmailRuleModel, type EmailRuleRunLog, type EmailRuleRunLogDocument, type EmailRuleRunLogModel, type EmailRuleRunLogStatics, type EmailRuleSend, type EmailRuleSendDocument, type EmailRuleSendModel, type EmailRuleSendStatics, type EmailRuleStatics, type EmailSendStatus, type EmailTemplate, type EmailTemplateDocument, type EmailTemplateModel, type EmailTemplateStatics, type EmailThrottleConfig, type EmailThrottleConfigDocument, type EmailThrottleConfigModel, type EmailThrottleConfigStatics, type EmailType, type IEmailRule, type IEmailRuleRunLog, type IEmailRuleSend, type IEmailTemplate, type IEmailThrottleConfig, type ListTarget, LockAcquisitionError, type PerRuleStats, type QueryTarget, RULE_OPERATOR, RUN_LOG_STATUS, RUN_TRIGGER, type RecipientIdentifier, type RenderResult, type RuleCondition, RuleNotFoundError, type RuleOperator, type RuleRunStats, RuleRunnerService, RuleService, type RuleTarget, RuleTemplateIncompatibleError, type RunLogStatus, type RunTrigger, SchedulerService, type SendEmailParams, TARGET_MODE, TEMPLATE_AUDIENCE, TEMPLATE_CATEGORY, THROTTLE_WINDOW, type TargetMode, type TemplateAudience, type TemplateCategory, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, type ThrottleWindow, type UpdateEmailRuleInput, type UpdateEmailTemplateInput, type UpdateEmailThrottleConfigInput, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, validateConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -10387,13 +10387,22 @@ var EMAIL_SEND_STATUS = {
|
|
|
10387
10387
|
Invalid: "invalid",
|
|
10388
10388
|
Throttled: "throttled"
|
|
10389
10389
|
};
|
|
10390
|
+
var TARGET_MODE = {
|
|
10391
|
+
Query: "query",
|
|
10392
|
+
List: "list"
|
|
10393
|
+
};
|
|
10394
|
+
var RUN_LOG_STATUS = {
|
|
10395
|
+
Completed: "completed",
|
|
10396
|
+
Cancelled: "cancelled",
|
|
10397
|
+
Failed: "failed"
|
|
10398
|
+
};
|
|
10390
10399
|
|
|
10391
10400
|
// src/schemas/template.schema.ts
|
|
10392
10401
|
function createEmailTemplateSchema(platformValues, audienceValues, categoryValues, collectionPrefix) {
|
|
10393
10402
|
const schema = new Schema(
|
|
10394
10403
|
{
|
|
10395
10404
|
name: { type: String, required: true },
|
|
10396
|
-
slug: { type: String, required: true, unique: true },
|
|
10405
|
+
slug: { type: String, required: true, unique: true, maxlength: 200 },
|
|
10397
10406
|
description: String,
|
|
10398
10407
|
category: { type: String, enum: categoryValues || Object.values(TEMPLATE_CATEGORY), required: true },
|
|
10399
10408
|
audience: { type: String, enum: audienceValues || Object.values(TEMPLATE_AUDIENCE), required: true },
|
|
@@ -10418,6 +10427,15 @@ function createEmailTemplateSchema(platformValues, audienceValues, categoryValue
|
|
|
10418
10427
|
}
|
|
10419
10428
|
},
|
|
10420
10429
|
variables: [{ type: String }],
|
|
10430
|
+
attachments: {
|
|
10431
|
+
type: [{
|
|
10432
|
+
_id: false,
|
|
10433
|
+
filename: { type: String, required: true },
|
|
10434
|
+
url: { type: String, required: true },
|
|
10435
|
+
contentType: { type: String, required: true }
|
|
10436
|
+
}],
|
|
10437
|
+
default: []
|
|
10438
|
+
},
|
|
10421
10439
|
version: { type: Number, default: 1 },
|
|
10422
10440
|
isActive: { type: Boolean, default: true }
|
|
10423
10441
|
},
|
|
@@ -10454,6 +10472,7 @@ function createEmailTemplateSchema(platformValues, audienceValues, categoryValue
|
|
|
10454
10472
|
preheaders: input.preheaders || [],
|
|
10455
10473
|
fields: input.fields || {},
|
|
10456
10474
|
variables: input.variables || [],
|
|
10475
|
+
attachments: input.attachments || [],
|
|
10457
10476
|
version: 1,
|
|
10458
10477
|
isActive: true
|
|
10459
10478
|
});
|
|
@@ -10472,7 +10491,7 @@ function createEmailRuleSchema(platformValues, audienceValues, collectionPrefix)
|
|
|
10472
10491
|
value: { type: Schema.Types.Mixed }
|
|
10473
10492
|
}, { _id: false });
|
|
10474
10493
|
const RuleTargetSchema = new Schema({
|
|
10475
|
-
mode: { type: String, enum:
|
|
10494
|
+
mode: { type: String, enum: Object.values(TARGET_MODE), required: true },
|
|
10476
10495
|
role: { type: String, enum: audienceValues || Object.values(TEMPLATE_AUDIENCE) },
|
|
10477
10496
|
platform: {
|
|
10478
10497
|
type: String,
|
|
@@ -10636,7 +10655,7 @@ function createEmailRuleRunLogSchema(collectionPrefix) {
|
|
|
10636
10655
|
{
|
|
10637
10656
|
runId: { type: String, index: true },
|
|
10638
10657
|
runAt: { type: Date, required: true, default: () => /* @__PURE__ */ new Date() },
|
|
10639
|
-
status: { type: String, enum:
|
|
10658
|
+
status: { type: String, enum: Object.values(RUN_LOG_STATUS), default: RUN_LOG_STATUS.Completed },
|
|
10640
10659
|
triggeredBy: { type: String, enum: Object.values(RUN_TRIGGER), required: true },
|
|
10641
10660
|
duration: { type: Number, required: true },
|
|
10642
10661
|
rulesProcessed: { type: Number, required: true },
|
|
@@ -10931,6 +10950,9 @@ var DuplicateSlugError = class extends AlxEmailError {
|
|
|
10931
10950
|
};
|
|
10932
10951
|
|
|
10933
10952
|
// src/services/template.service.ts
|
|
10953
|
+
function stripScriptTags(text) {
|
|
10954
|
+
return text.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
|
|
10955
|
+
}
|
|
10934
10956
|
var UPDATEABLE_FIELDS = /* @__PURE__ */ new Set([
|
|
10935
10957
|
"name",
|
|
10936
10958
|
"description",
|
|
@@ -10943,7 +10965,8 @@ var UPDATEABLE_FIELDS = /* @__PURE__ */ new Set([
|
|
|
10943
10965
|
"preheaders",
|
|
10944
10966
|
"variables",
|
|
10945
10967
|
"isActive",
|
|
10946
|
-
"fields"
|
|
10968
|
+
"fields",
|
|
10969
|
+
"attachments"
|
|
10947
10970
|
]);
|
|
10948
10971
|
function slugify(name) {
|
|
10949
10972
|
return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -10974,7 +10997,8 @@ var TemplateService = class {
|
|
|
10974
10997
|
if (existing) {
|
|
10975
10998
|
throw new DuplicateSlugError(slug);
|
|
10976
10999
|
}
|
|
10977
|
-
const
|
|
11000
|
+
const subjects = input.subjects.map((s) => stripScriptTags(s));
|
|
11001
|
+
const bodies = input.bodies.map((b) => stripScriptTags(b));
|
|
10978
11002
|
if (subjects.length === 0) throw new TemplateSyntaxError("At least one subject is required", ["At least one subject is required"]);
|
|
10979
11003
|
if (bodies.length === 0) throw new TemplateSyntaxError("At least one body is required", ["At least one body is required"]);
|
|
10980
11004
|
for (const b of bodies) {
|
|
@@ -10996,6 +11020,12 @@ var TemplateService = class {
|
|
|
10996
11020
|
async update(id, input) {
|
|
10997
11021
|
const template = await this.EmailTemplate.findById(id);
|
|
10998
11022
|
if (!template) return null;
|
|
11023
|
+
if (input.subjects) {
|
|
11024
|
+
input.subjects = input.subjects.map((s) => stripScriptTags(s));
|
|
11025
|
+
}
|
|
11026
|
+
if (input.bodies) {
|
|
11027
|
+
input.bodies = input.bodies.map((b) => stripScriptTags(b));
|
|
11028
|
+
}
|
|
10999
11029
|
if (input.subjects && input.subjects.length === 0) {
|
|
11000
11030
|
throw new TemplateSyntaxError("At least one subject is required", ["At least one subject is required"]);
|
|
11001
11031
|
}
|
|
@@ -11104,7 +11134,8 @@ var TemplateService = class {
|
|
|
11104
11134
|
testEmail,
|
|
11105
11135
|
`[TEST] ${rendered.subject}`,
|
|
11106
11136
|
rendered.html,
|
|
11107
|
-
rendered.text
|
|
11137
|
+
rendered.text,
|
|
11138
|
+
template.attachments || []
|
|
11108
11139
|
);
|
|
11109
11140
|
return { success: true };
|
|
11110
11141
|
} catch (error) {
|
|
@@ -11675,7 +11706,8 @@ var RuleRunnerService = class {
|
|
|
11675
11706
|
htmlBody: finalHtml,
|
|
11676
11707
|
textBody: finalText,
|
|
11677
11708
|
ruleId,
|
|
11678
|
-
autoApprove: rule.autoApprove ?? true
|
|
11709
|
+
autoApprove: rule.autoApprove ?? true,
|
|
11710
|
+
attachments: template.attachments || []
|
|
11679
11711
|
});
|
|
11680
11712
|
await this.EmailRuleSend.logSend(
|
|
11681
11713
|
ruleId,
|
|
@@ -11890,7 +11922,8 @@ var RuleRunnerService = class {
|
|
|
11890
11922
|
htmlBody: finalHtml,
|
|
11891
11923
|
textBody: finalText,
|
|
11892
11924
|
ruleId,
|
|
11893
|
-
autoApprove: rule.autoApprove ?? true
|
|
11925
|
+
autoApprove: rule.autoApprove ?? true,
|
|
11926
|
+
attachments: template.attachments || []
|
|
11894
11927
|
});
|
|
11895
11928
|
await this.EmailRuleSend.logSend(
|
|
11896
11929
|
ruleId,
|
|
@@ -30136,6 +30169,6 @@ function createEmailRuleEngine(config) {
|
|
|
30136
30169
|
};
|
|
30137
30170
|
}
|
|
30138
30171
|
|
|
30139
|
-
export { AlxEmailError, ConfigValidationError, DuplicateSlugError, EMAIL_SEND_STATUS, EMAIL_TYPE, LockAcquisitionError, RULE_OPERATOR, RUN_TRIGGER, RuleNotFoundError, RuleRunnerService, RuleService, RuleTemplateIncompatibleError, SchedulerService, TEMPLATE_AUDIENCE, TEMPLATE_CATEGORY, THROTTLE_WINDOW, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, validateConfig };
|
|
30172
|
+
export { AlxEmailError, ConfigValidationError, DuplicateSlugError, EMAIL_SEND_STATUS, EMAIL_TYPE, LockAcquisitionError, RULE_OPERATOR, RUN_LOG_STATUS, RUN_TRIGGER, RuleNotFoundError, RuleRunnerService, RuleService, RuleTemplateIncompatibleError, SchedulerService, TARGET_MODE, TEMPLATE_AUDIENCE, TEMPLATE_CATEGORY, THROTTLE_WINDOW, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, validateConfig };
|
|
30140
30173
|
//# sourceMappingURL=index.mjs.map
|
|
30141
30174
|
//# sourceMappingURL=index.mjs.map
|