@astralibx/email-rule-engine 12.5.2 → 12.6.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 +5 -2
- package/dist/index.cjs +29908 -1994
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.mjs +29899 -2008
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -101,6 +101,11 @@ interface EmailRule {
|
|
|
101
101
|
minGapDays?: number;
|
|
102
102
|
};
|
|
103
103
|
emailType: EmailType;
|
|
104
|
+
schedule?: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
cron: string;
|
|
107
|
+
timezone?: string;
|
|
108
|
+
};
|
|
104
109
|
totalSent: number;
|
|
105
110
|
totalSkipped: number;
|
|
106
111
|
lastRunAt?: Date;
|
|
@@ -128,6 +133,11 @@ interface CreateEmailRuleInput {
|
|
|
128
133
|
minGapDays?: number;
|
|
129
134
|
};
|
|
130
135
|
emailType?: EmailType;
|
|
136
|
+
schedule?: {
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
cron: string;
|
|
139
|
+
timezone?: string;
|
|
140
|
+
};
|
|
131
141
|
}
|
|
132
142
|
interface UpdateEmailRuleInput {
|
|
133
143
|
name?: string;
|
|
@@ -150,6 +160,11 @@ interface UpdateEmailRuleInput {
|
|
|
150
160
|
minGapDays?: number;
|
|
151
161
|
};
|
|
152
162
|
emailType?: EmailType;
|
|
163
|
+
schedule?: {
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
cron: string;
|
|
166
|
+
timezone?: string;
|
|
167
|
+
};
|
|
153
168
|
}
|
|
154
169
|
interface EmailRuleSend {
|
|
155
170
|
_id: string;
|
|
@@ -550,10 +565,16 @@ declare class TemplateService {
|
|
|
550
565
|
errors: string[];
|
|
551
566
|
variables: string[];
|
|
552
567
|
}>;
|
|
568
|
+
clone(sourceId: string, newName?: string): Promise<any>;
|
|
553
569
|
sendTestEmail(id: string, testEmail: string, sampleData: Record<string, unknown>): Promise<{
|
|
554
570
|
success: boolean;
|
|
555
571
|
error?: string;
|
|
556
572
|
}>;
|
|
573
|
+
previewWithRecipient(templateId: string, recipientData: Record<string, unknown>): Promise<{
|
|
574
|
+
html: string;
|
|
575
|
+
text: string;
|
|
576
|
+
subject: string;
|
|
577
|
+
} | null>;
|
|
557
578
|
}
|
|
558
579
|
|
|
559
580
|
declare class RuleService {
|
|
@@ -576,7 +597,13 @@ declare class RuleService {
|
|
|
576
597
|
effectiveLimit: number;
|
|
577
598
|
willProcess: number;
|
|
578
599
|
ruleId: string;
|
|
600
|
+
sample: Array<{
|
|
601
|
+
email: string;
|
|
602
|
+
name?: string;
|
|
603
|
+
[key: string]: unknown;
|
|
604
|
+
}>;
|
|
579
605
|
}>;
|
|
606
|
+
clone(sourceId: string, newName?: string): Promise<any>;
|
|
580
607
|
getRunHistory(limit?: number): Promise<unknown[]>;
|
|
581
608
|
}
|
|
582
609
|
|
|
@@ -692,6 +719,29 @@ declare class RedisLock {
|
|
|
692
719
|
release(): Promise<void>;
|
|
693
720
|
}
|
|
694
721
|
|
|
722
|
+
declare class SchedulerService {
|
|
723
|
+
private queue;
|
|
724
|
+
private worker?;
|
|
725
|
+
private keyPrefix;
|
|
726
|
+
constructor(connection: Redis, keyPrefix?: string);
|
|
727
|
+
syncRule(rule: {
|
|
728
|
+
_id: any;
|
|
729
|
+
schedule?: {
|
|
730
|
+
enabled: boolean;
|
|
731
|
+
cron: string;
|
|
732
|
+
timezone?: string;
|
|
733
|
+
};
|
|
734
|
+
}): Promise<void>;
|
|
735
|
+
removeRule(ruleId: string): Promise<void>;
|
|
736
|
+
startWorker(runFn: (triggeredBy: string) => Promise<any>): void;
|
|
737
|
+
stopWorker(): Promise<void>;
|
|
738
|
+
getScheduledJobs(): Promise<Array<{
|
|
739
|
+
ruleId: string;
|
|
740
|
+
cron: string;
|
|
741
|
+
next: number | null;
|
|
742
|
+
}>>;
|
|
743
|
+
}
|
|
744
|
+
|
|
695
745
|
/**
|
|
696
746
|
* Engine instance with Express routes and programmatic service access.
|
|
697
747
|
*/
|
|
@@ -727,4 +777,4 @@ interface EmailRuleEngine {
|
|
|
727
777
|
*/
|
|
728
778
|
declare function createEmailRuleEngine(config: EmailRuleEngineConfig): EmailRuleEngine;
|
|
729
779
|
|
|
730
|
-
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, RedisLock, type RenderResult, type RuleCondition, RuleNotFoundError, type RuleOperator, type RuleRunStats, RuleRunnerService, RuleService, type RuleTarget, RuleTemplateIncompatibleError, type RunTrigger, 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 };
|
|
780
|
+
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, RedisLock, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,11 @@ interface EmailRule {
|
|
|
101
101
|
minGapDays?: number;
|
|
102
102
|
};
|
|
103
103
|
emailType: EmailType;
|
|
104
|
+
schedule?: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
cron: string;
|
|
107
|
+
timezone?: string;
|
|
108
|
+
};
|
|
104
109
|
totalSent: number;
|
|
105
110
|
totalSkipped: number;
|
|
106
111
|
lastRunAt?: Date;
|
|
@@ -128,6 +133,11 @@ interface CreateEmailRuleInput {
|
|
|
128
133
|
minGapDays?: number;
|
|
129
134
|
};
|
|
130
135
|
emailType?: EmailType;
|
|
136
|
+
schedule?: {
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
cron: string;
|
|
139
|
+
timezone?: string;
|
|
140
|
+
};
|
|
131
141
|
}
|
|
132
142
|
interface UpdateEmailRuleInput {
|
|
133
143
|
name?: string;
|
|
@@ -150,6 +160,11 @@ interface UpdateEmailRuleInput {
|
|
|
150
160
|
minGapDays?: number;
|
|
151
161
|
};
|
|
152
162
|
emailType?: EmailType;
|
|
163
|
+
schedule?: {
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
cron: string;
|
|
166
|
+
timezone?: string;
|
|
167
|
+
};
|
|
153
168
|
}
|
|
154
169
|
interface EmailRuleSend {
|
|
155
170
|
_id: string;
|
|
@@ -550,10 +565,16 @@ declare class TemplateService {
|
|
|
550
565
|
errors: string[];
|
|
551
566
|
variables: string[];
|
|
552
567
|
}>;
|
|
568
|
+
clone(sourceId: string, newName?: string): Promise<any>;
|
|
553
569
|
sendTestEmail(id: string, testEmail: string, sampleData: Record<string, unknown>): Promise<{
|
|
554
570
|
success: boolean;
|
|
555
571
|
error?: string;
|
|
556
572
|
}>;
|
|
573
|
+
previewWithRecipient(templateId: string, recipientData: Record<string, unknown>): Promise<{
|
|
574
|
+
html: string;
|
|
575
|
+
text: string;
|
|
576
|
+
subject: string;
|
|
577
|
+
} | null>;
|
|
557
578
|
}
|
|
558
579
|
|
|
559
580
|
declare class RuleService {
|
|
@@ -576,7 +597,13 @@ declare class RuleService {
|
|
|
576
597
|
effectiveLimit: number;
|
|
577
598
|
willProcess: number;
|
|
578
599
|
ruleId: string;
|
|
600
|
+
sample: Array<{
|
|
601
|
+
email: string;
|
|
602
|
+
name?: string;
|
|
603
|
+
[key: string]: unknown;
|
|
604
|
+
}>;
|
|
579
605
|
}>;
|
|
606
|
+
clone(sourceId: string, newName?: string): Promise<any>;
|
|
580
607
|
getRunHistory(limit?: number): Promise<unknown[]>;
|
|
581
608
|
}
|
|
582
609
|
|
|
@@ -692,6 +719,29 @@ declare class RedisLock {
|
|
|
692
719
|
release(): Promise<void>;
|
|
693
720
|
}
|
|
694
721
|
|
|
722
|
+
declare class SchedulerService {
|
|
723
|
+
private queue;
|
|
724
|
+
private worker?;
|
|
725
|
+
private keyPrefix;
|
|
726
|
+
constructor(connection: Redis, keyPrefix?: string);
|
|
727
|
+
syncRule(rule: {
|
|
728
|
+
_id: any;
|
|
729
|
+
schedule?: {
|
|
730
|
+
enabled: boolean;
|
|
731
|
+
cron: string;
|
|
732
|
+
timezone?: string;
|
|
733
|
+
};
|
|
734
|
+
}): Promise<void>;
|
|
735
|
+
removeRule(ruleId: string): Promise<void>;
|
|
736
|
+
startWorker(runFn: (triggeredBy: string) => Promise<any>): void;
|
|
737
|
+
stopWorker(): Promise<void>;
|
|
738
|
+
getScheduledJobs(): Promise<Array<{
|
|
739
|
+
ruleId: string;
|
|
740
|
+
cron: string;
|
|
741
|
+
next: number | null;
|
|
742
|
+
}>>;
|
|
743
|
+
}
|
|
744
|
+
|
|
695
745
|
/**
|
|
696
746
|
* Engine instance with Express routes and programmatic service access.
|
|
697
747
|
*/
|
|
@@ -727,4 +777,4 @@ interface EmailRuleEngine {
|
|
|
727
777
|
*/
|
|
728
778
|
declare function createEmailRuleEngine(config: EmailRuleEngineConfig): EmailRuleEngine;
|
|
729
779
|
|
|
730
|
-
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, RedisLock, type RenderResult, type RuleCondition, RuleNotFoundError, type RuleOperator, type RuleRunStats, RuleRunnerService, RuleService, type RuleTarget, RuleTemplateIncompatibleError, type RunTrigger, 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 };
|
|
780
|
+
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, RedisLock, 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 };
|