@astralibx/email-rule-engine 12.7.2 → 12.9.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 +3 -0
- package/dist/index.cjs +2293 -29775
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +91 -12
- package/dist/index.d.ts +91 -12
- package/dist/index.mjs +2285 -29749
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,50 @@ import { LogAdapter, AlxError } from '@astralibx/core';
|
|
|
5
5
|
export { LogAdapter, RedisLock } from '@astralibx/core';
|
|
6
6
|
import { Router } from 'express';
|
|
7
7
|
|
|
8
|
+
type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'objectId' | 'array' | 'object';
|
|
9
|
+
interface FieldDefinition {
|
|
10
|
+
name: string;
|
|
11
|
+
type: FieldType;
|
|
12
|
+
label?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
enumValues?: string[];
|
|
15
|
+
fields?: FieldDefinition[];
|
|
16
|
+
}
|
|
17
|
+
interface JoinDefinition {
|
|
18
|
+
from: string;
|
|
19
|
+
localField: string;
|
|
20
|
+
foreignField: string;
|
|
21
|
+
as: string;
|
|
22
|
+
}
|
|
23
|
+
interface CollectionSchema {
|
|
24
|
+
name: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
identifierField?: string;
|
|
28
|
+
fields: FieldDefinition[];
|
|
29
|
+
joins?: JoinDefinition[];
|
|
30
|
+
}
|
|
31
|
+
interface FlattenedField {
|
|
32
|
+
path: string;
|
|
33
|
+
type: FieldType;
|
|
34
|
+
label?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
enumValues?: string[];
|
|
37
|
+
isArray?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const FIELD_TYPE: {
|
|
41
|
+
readonly String: "string";
|
|
42
|
+
readonly Number: "number";
|
|
43
|
+
readonly Boolean: "boolean";
|
|
44
|
+
readonly Date: "date";
|
|
45
|
+
readonly ObjectId: "objectId";
|
|
46
|
+
readonly Array: "array";
|
|
47
|
+
readonly Object: "object";
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
declare const TYPE_OPERATORS: Record<FieldType, string[]>;
|
|
51
|
+
|
|
8
52
|
declare const TEMPLATE_CATEGORY: {
|
|
9
53
|
readonly Onboarding: "onboarding";
|
|
10
54
|
readonly Engagement: "engagement";
|
|
@@ -84,6 +128,7 @@ interface QueryTarget {
|
|
|
84
128
|
role: string;
|
|
85
129
|
platform: string;
|
|
86
130
|
conditions: RuleCondition[];
|
|
131
|
+
collection?: string;
|
|
87
132
|
}
|
|
88
133
|
interface ListTarget {
|
|
89
134
|
mode: 'list';
|
|
@@ -279,8 +324,11 @@ interface EmailRuleEngineConfig {
|
|
|
279
324
|
connection: Redis;
|
|
280
325
|
keyPrefix?: string;
|
|
281
326
|
};
|
|
327
|
+
collections?: CollectionSchema[];
|
|
282
328
|
adapters: {
|
|
283
|
-
queryUsers: (target: RuleTarget, limit: number
|
|
329
|
+
queryUsers: (target: RuleTarget, limit: number, context?: {
|
|
330
|
+
collectionSchema?: CollectionSchema;
|
|
331
|
+
}) => Promise<Record<string, unknown>[]>;
|
|
284
332
|
resolveData: (user: Record<string, unknown>) => Record<string, unknown>;
|
|
285
333
|
sendEmail: (params: SendEmailParams) => Promise<void>;
|
|
286
334
|
selectAgent: (identifierId: string, context?: {
|
|
@@ -332,6 +380,7 @@ interface EmailRuleEngineConfig {
|
|
|
332
380
|
runId: string;
|
|
333
381
|
subjectIndex: number;
|
|
334
382
|
bodyIndex: number;
|
|
383
|
+
preheaderIndex?: number;
|
|
335
384
|
failureReason?: string;
|
|
336
385
|
}) => void;
|
|
337
386
|
onRuleComplete?: (info: {
|
|
@@ -450,9 +499,9 @@ declare function createEmailRuleSchema(platformValues?: string[], audienceValues
|
|
|
450
499
|
|
|
451
500
|
interface IEmailRuleSend {
|
|
452
501
|
ruleId: Types.ObjectId;
|
|
453
|
-
userId:
|
|
454
|
-
emailIdentifierId?:
|
|
455
|
-
messageId?:
|
|
502
|
+
userId: string;
|
|
503
|
+
emailIdentifierId?: string;
|
|
504
|
+
messageId?: string;
|
|
456
505
|
sentAt: Date;
|
|
457
506
|
status?: string;
|
|
458
507
|
accountId?: string;
|
|
@@ -465,9 +514,9 @@ interface IEmailRuleSend {
|
|
|
465
514
|
}
|
|
466
515
|
type EmailRuleSendDocument = HydratedDocument<IEmailRuleSend>;
|
|
467
516
|
interface EmailRuleSendStatics {
|
|
468
|
-
findLatestForUser(ruleId: string | Types.ObjectId, userId: string
|
|
469
|
-
findRecentByUserIds(userIds:
|
|
470
|
-
logSend(ruleId: string | Types.ObjectId, userId: string
|
|
517
|
+
findLatestForUser(ruleId: string | Types.ObjectId, userId: string): Promise<EmailRuleSendDocument | null>;
|
|
518
|
+
findRecentByUserIds(userIds: string[], sinceDays: number): Promise<EmailRuleSendDocument[]>;
|
|
519
|
+
logSend(ruleId: string | Types.ObjectId, userId: string, emailIdentifierId?: string, messageId?: string, extra?: {
|
|
471
520
|
status?: string;
|
|
472
521
|
accountId?: string;
|
|
473
522
|
senderName?: string;
|
|
@@ -563,14 +612,20 @@ declare function createEmailThrottleConfigSchema(collectionPrefix?: string): Sch
|
|
|
563
612
|
declare class TemplateService {
|
|
564
613
|
private EmailTemplate;
|
|
565
614
|
private config;
|
|
615
|
+
private EmailRule?;
|
|
566
616
|
private renderService;
|
|
567
|
-
constructor(EmailTemplate: EmailTemplateModel, config: EmailRuleEngineConfig);
|
|
617
|
+
constructor(EmailTemplate: EmailTemplateModel, config: EmailRuleEngineConfig, EmailRule?: EmailRuleModel | undefined);
|
|
568
618
|
list(filters?: {
|
|
569
619
|
category?: string;
|
|
570
620
|
audience?: string;
|
|
571
621
|
platform?: string;
|
|
572
622
|
isActive?: boolean;
|
|
573
|
-
|
|
623
|
+
page?: number;
|
|
624
|
+
limit?: number;
|
|
625
|
+
}): Promise<{
|
|
626
|
+
templates: EmailTemplateDocument[];
|
|
627
|
+
total: number;
|
|
628
|
+
}>;
|
|
574
629
|
getById(id: string): Promise<EmailTemplateDocument | null>;
|
|
575
630
|
getBySlug(slug: string): Promise<EmailTemplateDocument | null>;
|
|
576
631
|
create(input: CreateEmailTemplateInput): Promise<EmailTemplateDocument>;
|
|
@@ -611,7 +666,13 @@ declare class RuleService {
|
|
|
611
666
|
private EmailRuleRunLog;
|
|
612
667
|
private config;
|
|
613
668
|
constructor(EmailRule: EmailRuleModel, EmailTemplate: EmailTemplateModel, EmailRuleRunLog: EmailRuleRunLogModel, config: EmailRuleEngineConfig);
|
|
614
|
-
list(
|
|
669
|
+
list(opts?: {
|
|
670
|
+
page?: number;
|
|
671
|
+
limit?: number;
|
|
672
|
+
}): Promise<{
|
|
673
|
+
rules: EmailRuleDocument[];
|
|
674
|
+
total: number;
|
|
675
|
+
}>;
|
|
615
676
|
getById(id: string): Promise<EmailRuleDocument | null>;
|
|
616
677
|
create(input: CreateEmailRuleInput): Promise<EmailRuleDocument>;
|
|
617
678
|
update(id: string, input: UpdateEmailRuleInput): Promise<EmailRuleDocument | null>;
|
|
@@ -632,7 +693,15 @@ declare class RuleService {
|
|
|
632
693
|
}>;
|
|
633
694
|
}>;
|
|
634
695
|
clone(sourceId: string, newName?: string): Promise<any>;
|
|
635
|
-
getRunHistory(limit?: number
|
|
696
|
+
getRunHistory(limit?: number, opts?: {
|
|
697
|
+
page?: number;
|
|
698
|
+
from?: string;
|
|
699
|
+
to?: string;
|
|
700
|
+
}): Promise<unknown[]>;
|
|
701
|
+
getRunHistoryCount(opts?: {
|
|
702
|
+
from?: string;
|
|
703
|
+
to?: string;
|
|
704
|
+
}): Promise<number>;
|
|
636
705
|
}
|
|
637
706
|
|
|
638
707
|
interface UserThrottle {
|
|
@@ -669,6 +738,7 @@ declare class RuleRunnerService {
|
|
|
669
738
|
}>;
|
|
670
739
|
trigger(triggeredBy?: RunTrigger): {
|
|
671
740
|
runId: string;
|
|
741
|
+
started: boolean;
|
|
672
742
|
};
|
|
673
743
|
buildThrottleMap(recentSends: any[]): Map<string, UserThrottle>;
|
|
674
744
|
}
|
|
@@ -706,6 +776,15 @@ declare class DuplicateSlugError extends AlxEmailError {
|
|
|
706
776
|
|
|
707
777
|
declare function validateConfig(raw: unknown): void;
|
|
708
778
|
|
|
779
|
+
interface ConditionValidationError {
|
|
780
|
+
index: number;
|
|
781
|
+
field: string;
|
|
782
|
+
message: string;
|
|
783
|
+
}
|
|
784
|
+
declare function validateConditions(conditions: RuleCondition[], collectionName: string | undefined, collections: CollectionSchema[]): ConditionValidationError[];
|
|
785
|
+
|
|
786
|
+
declare function flattenFields(fields: FieldDefinition[], prefix?: string, parentIsArray?: boolean): FlattenedField[];
|
|
787
|
+
|
|
709
788
|
interface RenderResult {
|
|
710
789
|
html: string;
|
|
711
790
|
text: string;
|
|
@@ -794,4 +873,4 @@ interface EmailRuleEngine {
|
|
|
794
873
|
*/
|
|
795
874
|
declare function createEmailRuleEngine(config: EmailRuleEngineConfig): EmailRuleEngine;
|
|
796
875
|
|
|
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 };
|
|
876
|
+
export { type AgentSelection, AlxEmailError, type BeforeSendParams, type BeforeSendResult, type CollectionSchema, type CompiledTemplate, type ConditionValidationError, 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, FIELD_TYPE, type FieldDefinition, type FieldType, type FlattenedField, type IEmailRule, type IEmailRuleRunLog, type IEmailRuleSend, type IEmailTemplate, type IEmailThrottleConfig, type JoinDefinition, 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_OPERATORS, type TargetMode, type TemplateAudience, type TemplateCategory, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, type ThrottleWindow, type UpdateEmailRuleInput, type UpdateEmailTemplateInput, type UpdateEmailThrottleConfigInput, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, flattenFields, validateConditions, validateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,50 @@ import { LogAdapter, AlxError } from '@astralibx/core';
|
|
|
5
5
|
export { LogAdapter, RedisLock } from '@astralibx/core';
|
|
6
6
|
import { Router } from 'express';
|
|
7
7
|
|
|
8
|
+
type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'objectId' | 'array' | 'object';
|
|
9
|
+
interface FieldDefinition {
|
|
10
|
+
name: string;
|
|
11
|
+
type: FieldType;
|
|
12
|
+
label?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
enumValues?: string[];
|
|
15
|
+
fields?: FieldDefinition[];
|
|
16
|
+
}
|
|
17
|
+
interface JoinDefinition {
|
|
18
|
+
from: string;
|
|
19
|
+
localField: string;
|
|
20
|
+
foreignField: string;
|
|
21
|
+
as: string;
|
|
22
|
+
}
|
|
23
|
+
interface CollectionSchema {
|
|
24
|
+
name: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
identifierField?: string;
|
|
28
|
+
fields: FieldDefinition[];
|
|
29
|
+
joins?: JoinDefinition[];
|
|
30
|
+
}
|
|
31
|
+
interface FlattenedField {
|
|
32
|
+
path: string;
|
|
33
|
+
type: FieldType;
|
|
34
|
+
label?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
enumValues?: string[];
|
|
37
|
+
isArray?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const FIELD_TYPE: {
|
|
41
|
+
readonly String: "string";
|
|
42
|
+
readonly Number: "number";
|
|
43
|
+
readonly Boolean: "boolean";
|
|
44
|
+
readonly Date: "date";
|
|
45
|
+
readonly ObjectId: "objectId";
|
|
46
|
+
readonly Array: "array";
|
|
47
|
+
readonly Object: "object";
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
declare const TYPE_OPERATORS: Record<FieldType, string[]>;
|
|
51
|
+
|
|
8
52
|
declare const TEMPLATE_CATEGORY: {
|
|
9
53
|
readonly Onboarding: "onboarding";
|
|
10
54
|
readonly Engagement: "engagement";
|
|
@@ -84,6 +128,7 @@ interface QueryTarget {
|
|
|
84
128
|
role: string;
|
|
85
129
|
platform: string;
|
|
86
130
|
conditions: RuleCondition[];
|
|
131
|
+
collection?: string;
|
|
87
132
|
}
|
|
88
133
|
interface ListTarget {
|
|
89
134
|
mode: 'list';
|
|
@@ -279,8 +324,11 @@ interface EmailRuleEngineConfig {
|
|
|
279
324
|
connection: Redis;
|
|
280
325
|
keyPrefix?: string;
|
|
281
326
|
};
|
|
327
|
+
collections?: CollectionSchema[];
|
|
282
328
|
adapters: {
|
|
283
|
-
queryUsers: (target: RuleTarget, limit: number
|
|
329
|
+
queryUsers: (target: RuleTarget, limit: number, context?: {
|
|
330
|
+
collectionSchema?: CollectionSchema;
|
|
331
|
+
}) => Promise<Record<string, unknown>[]>;
|
|
284
332
|
resolveData: (user: Record<string, unknown>) => Record<string, unknown>;
|
|
285
333
|
sendEmail: (params: SendEmailParams) => Promise<void>;
|
|
286
334
|
selectAgent: (identifierId: string, context?: {
|
|
@@ -332,6 +380,7 @@ interface EmailRuleEngineConfig {
|
|
|
332
380
|
runId: string;
|
|
333
381
|
subjectIndex: number;
|
|
334
382
|
bodyIndex: number;
|
|
383
|
+
preheaderIndex?: number;
|
|
335
384
|
failureReason?: string;
|
|
336
385
|
}) => void;
|
|
337
386
|
onRuleComplete?: (info: {
|
|
@@ -450,9 +499,9 @@ declare function createEmailRuleSchema(platformValues?: string[], audienceValues
|
|
|
450
499
|
|
|
451
500
|
interface IEmailRuleSend {
|
|
452
501
|
ruleId: Types.ObjectId;
|
|
453
|
-
userId:
|
|
454
|
-
emailIdentifierId?:
|
|
455
|
-
messageId?:
|
|
502
|
+
userId: string;
|
|
503
|
+
emailIdentifierId?: string;
|
|
504
|
+
messageId?: string;
|
|
456
505
|
sentAt: Date;
|
|
457
506
|
status?: string;
|
|
458
507
|
accountId?: string;
|
|
@@ -465,9 +514,9 @@ interface IEmailRuleSend {
|
|
|
465
514
|
}
|
|
466
515
|
type EmailRuleSendDocument = HydratedDocument<IEmailRuleSend>;
|
|
467
516
|
interface EmailRuleSendStatics {
|
|
468
|
-
findLatestForUser(ruleId: string | Types.ObjectId, userId: string
|
|
469
|
-
findRecentByUserIds(userIds:
|
|
470
|
-
logSend(ruleId: string | Types.ObjectId, userId: string
|
|
517
|
+
findLatestForUser(ruleId: string | Types.ObjectId, userId: string): Promise<EmailRuleSendDocument | null>;
|
|
518
|
+
findRecentByUserIds(userIds: string[], sinceDays: number): Promise<EmailRuleSendDocument[]>;
|
|
519
|
+
logSend(ruleId: string | Types.ObjectId, userId: string, emailIdentifierId?: string, messageId?: string, extra?: {
|
|
471
520
|
status?: string;
|
|
472
521
|
accountId?: string;
|
|
473
522
|
senderName?: string;
|
|
@@ -563,14 +612,20 @@ declare function createEmailThrottleConfigSchema(collectionPrefix?: string): Sch
|
|
|
563
612
|
declare class TemplateService {
|
|
564
613
|
private EmailTemplate;
|
|
565
614
|
private config;
|
|
615
|
+
private EmailRule?;
|
|
566
616
|
private renderService;
|
|
567
|
-
constructor(EmailTemplate: EmailTemplateModel, config: EmailRuleEngineConfig);
|
|
617
|
+
constructor(EmailTemplate: EmailTemplateModel, config: EmailRuleEngineConfig, EmailRule?: EmailRuleModel | undefined);
|
|
568
618
|
list(filters?: {
|
|
569
619
|
category?: string;
|
|
570
620
|
audience?: string;
|
|
571
621
|
platform?: string;
|
|
572
622
|
isActive?: boolean;
|
|
573
|
-
|
|
623
|
+
page?: number;
|
|
624
|
+
limit?: number;
|
|
625
|
+
}): Promise<{
|
|
626
|
+
templates: EmailTemplateDocument[];
|
|
627
|
+
total: number;
|
|
628
|
+
}>;
|
|
574
629
|
getById(id: string): Promise<EmailTemplateDocument | null>;
|
|
575
630
|
getBySlug(slug: string): Promise<EmailTemplateDocument | null>;
|
|
576
631
|
create(input: CreateEmailTemplateInput): Promise<EmailTemplateDocument>;
|
|
@@ -611,7 +666,13 @@ declare class RuleService {
|
|
|
611
666
|
private EmailRuleRunLog;
|
|
612
667
|
private config;
|
|
613
668
|
constructor(EmailRule: EmailRuleModel, EmailTemplate: EmailTemplateModel, EmailRuleRunLog: EmailRuleRunLogModel, config: EmailRuleEngineConfig);
|
|
614
|
-
list(
|
|
669
|
+
list(opts?: {
|
|
670
|
+
page?: number;
|
|
671
|
+
limit?: number;
|
|
672
|
+
}): Promise<{
|
|
673
|
+
rules: EmailRuleDocument[];
|
|
674
|
+
total: number;
|
|
675
|
+
}>;
|
|
615
676
|
getById(id: string): Promise<EmailRuleDocument | null>;
|
|
616
677
|
create(input: CreateEmailRuleInput): Promise<EmailRuleDocument>;
|
|
617
678
|
update(id: string, input: UpdateEmailRuleInput): Promise<EmailRuleDocument | null>;
|
|
@@ -632,7 +693,15 @@ declare class RuleService {
|
|
|
632
693
|
}>;
|
|
633
694
|
}>;
|
|
634
695
|
clone(sourceId: string, newName?: string): Promise<any>;
|
|
635
|
-
getRunHistory(limit?: number
|
|
696
|
+
getRunHistory(limit?: number, opts?: {
|
|
697
|
+
page?: number;
|
|
698
|
+
from?: string;
|
|
699
|
+
to?: string;
|
|
700
|
+
}): Promise<unknown[]>;
|
|
701
|
+
getRunHistoryCount(opts?: {
|
|
702
|
+
from?: string;
|
|
703
|
+
to?: string;
|
|
704
|
+
}): Promise<number>;
|
|
636
705
|
}
|
|
637
706
|
|
|
638
707
|
interface UserThrottle {
|
|
@@ -669,6 +738,7 @@ declare class RuleRunnerService {
|
|
|
669
738
|
}>;
|
|
670
739
|
trigger(triggeredBy?: RunTrigger): {
|
|
671
740
|
runId: string;
|
|
741
|
+
started: boolean;
|
|
672
742
|
};
|
|
673
743
|
buildThrottleMap(recentSends: any[]): Map<string, UserThrottle>;
|
|
674
744
|
}
|
|
@@ -706,6 +776,15 @@ declare class DuplicateSlugError extends AlxEmailError {
|
|
|
706
776
|
|
|
707
777
|
declare function validateConfig(raw: unknown): void;
|
|
708
778
|
|
|
779
|
+
interface ConditionValidationError {
|
|
780
|
+
index: number;
|
|
781
|
+
field: string;
|
|
782
|
+
message: string;
|
|
783
|
+
}
|
|
784
|
+
declare function validateConditions(conditions: RuleCondition[], collectionName: string | undefined, collections: CollectionSchema[]): ConditionValidationError[];
|
|
785
|
+
|
|
786
|
+
declare function flattenFields(fields: FieldDefinition[], prefix?: string, parentIsArray?: boolean): FlattenedField[];
|
|
787
|
+
|
|
709
788
|
interface RenderResult {
|
|
710
789
|
html: string;
|
|
711
790
|
text: string;
|
|
@@ -794,4 +873,4 @@ interface EmailRuleEngine {
|
|
|
794
873
|
*/
|
|
795
874
|
declare function createEmailRuleEngine(config: EmailRuleEngineConfig): EmailRuleEngine;
|
|
796
875
|
|
|
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 };
|
|
876
|
+
export { type AgentSelection, AlxEmailError, type BeforeSendParams, type BeforeSendResult, type CollectionSchema, type CompiledTemplate, type ConditionValidationError, 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, FIELD_TYPE, type FieldDefinition, type FieldType, type FlattenedField, type IEmailRule, type IEmailRuleRunLog, type IEmailRuleSend, type IEmailTemplate, type IEmailThrottleConfig, type JoinDefinition, 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_OPERATORS, type TargetMode, type TemplateAudience, type TemplateCategory, TemplateNotFoundError, TemplateRenderService, TemplateService, TemplateSyntaxError, type ThrottleWindow, type UpdateEmailRuleInput, type UpdateEmailTemplateInput, type UpdateEmailThrottleConfigInput, createEmailRuleEngine, createEmailRuleRunLogSchema, createEmailRuleSchema, createEmailRuleSendSchema, createEmailTemplateSchema, createEmailThrottleConfigSchema, flattenFields, validateConditions, validateConfig };
|