changemaker.lite/api/dist/modules/email-templates/email-templates.service.d.ts

266 lines
7.5 KiB
TypeScript

import { Prisma } from '@prisma/client';
import type { ListEmailTemplatesDto, CreateEmailTemplateDto, UpdateEmailTemplateDto, RollbackToVersionDto, ValidateTemplateDto, SendTestEmailDto } from './email-templates.schemas';
interface EmailTemplatesListResponse {
templates: any[];
pagination: {
page: number;
limit: number;
total: number;
totalPages: number;
};
}
interface ValidationResult {
valid: boolean;
errors: string[];
warnings?: string[];
extractedVariables?: string[];
}
export declare class EmailTemplatesService {
/**
* List email templates with pagination, search, and filters
*/
list(params: ListEmailTemplatesDto): Promise<EmailTemplatesListResponse>;
/**
* Get a single email template by ID
*/
getById(id: string): Promise<{
_count: {
versions: number;
testLogs: number;
};
createdBy: {
id: string;
email: string;
name: string | null;
};
variables: {
type: import(".prisma/client").$Enums.EmailTemplateVariableType;
id: string;
videoId: number | null;
key: string;
description: string | null;
sortOrder: number;
label: string;
templateId: string;
isRequired: boolean;
isConditional: boolean;
sampleValue: string | null;
}[];
updatedBy: {
id: string;
email: string;
name: string | null;
} | null;
} & {
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
category: import(".prisma/client").$Enums.EmailTemplateCategory;
key: string;
isActive: boolean;
description: string | null;
subjectLine: string;
htmlContent: string;
textContent: string;
isSystem: boolean;
createdByUserId: string;
updatedByUserId: string | null;
}>;
/**
* Get template by key
*/
getByKey(key: string): Promise<({
variables: {
type: import(".prisma/client").$Enums.EmailTemplateVariableType;
id: string;
videoId: number | null;
key: string;
description: string | null;
sortOrder: number;
label: string;
templateId: string;
isRequired: boolean;
isConditional: boolean;
sampleValue: string | null;
}[];
} & {
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
category: import(".prisma/client").$Enums.EmailTemplateCategory;
key: string;
isActive: boolean;
description: string | null;
subjectLine: string;
htmlContent: string;
textContent: string;
isSystem: boolean;
createdByUserId: string;
updatedByUserId: string | null;
}) | null>;
/**
* Create a new email template
*/
create(data: CreateEmailTemplateDto, userId: string): Promise<{
variables: {
type: import(".prisma/client").$Enums.EmailTemplateVariableType;
id: string;
videoId: number | null;
key: string;
description: string | null;
sortOrder: number;
label: string;
templateId: string;
isRequired: boolean;
isConditional: boolean;
sampleValue: string | null;
}[];
} & {
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
category: import(".prisma/client").$Enums.EmailTemplateCategory;
key: string;
isActive: boolean;
description: string | null;
subjectLine: string;
htmlContent: string;
textContent: string;
isSystem: boolean;
createdByUserId: string;
updatedByUserId: string | null;
}>;
/**
* Update an email template
*/
update(id: string, data: UpdateEmailTemplateDto, userId: string): Promise<{
variables: {
type: import(".prisma/client").$Enums.EmailTemplateVariableType;
id: string;
videoId: number | null;
key: string;
description: string | null;
sortOrder: number;
label: string;
templateId: string;
isRequired: boolean;
isConditional: boolean;
sampleValue: string | null;
}[];
} & {
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
category: import(".prisma/client").$Enums.EmailTemplateCategory;
key: string;
isActive: boolean;
description: string | null;
subjectLine: string;
htmlContent: string;
textContent: string;
isSystem: boolean;
createdByUserId: string;
updatedByUserId: string | null;
}>;
/**
* Delete an email template
*/
delete(id: string): Promise<void>;
/**
* Get version history for a template
*/
getVersions(templateId: string): Promise<({
createdBy: {
id: string;
email: string;
name: string | null;
};
} & {
id: string;
createdAt: Date;
subjectLine: string;
htmlContent: string;
textContent: string;
createdByUserId: string;
versionNumber: number;
changeNotes: string | null;
templateId: string;
})[]>;
/**
* Get a specific version
*/
getVersion(templateId: string, versionNumber: number): Promise<{
createdBy: {
id: string;
email: string;
name: string | null;
};
} & {
id: string;
createdAt: Date;
subjectLine: string;
htmlContent: string;
textContent: string;
createdByUserId: string;
versionNumber: number;
changeNotes: string | null;
templateId: string;
}>;
/**
* Rollback to a previous version
*/
rollbackToVersion(templateId: string, data: RollbackToVersionDto, userId: string): Promise<{
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
category: import(".prisma/client").$Enums.EmailTemplateCategory;
key: string;
isActive: boolean;
description: string | null;
subjectLine: string;
htmlContent: string;
textContent: string;
isSystem: boolean;
createdByUserId: string;
updatedByUserId: string | null;
}>;
/**
* Validate template syntax
*/
validateTemplate(data: ValidateTemplateDto): ValidationResult;
/**
* Send test email
*/
sendTestEmail(templateId: string, data: SendTestEmailDto, userId: string): Promise<{
success: boolean;
messageId: string | undefined;
}>;
/**
* Get test logs for a template
*/
getTestLogs(templateId: string, limit?: number): Promise<({
sentBy: {
id: string;
email: string;
name: string | null;
};
} & {
id: string;
success: boolean;
messageId: string | null;
recipientEmail: string;
sentAt: Date;
templateId: string;
testData: Prisma.JsonValue;
errorMessage: string | null;
sentByUserId: string;
})[]>;
}
export declare const emailTemplatesService: EmailTemplatesService;
export {};
//# sourceMappingURL=email-templates.service.d.ts.map