Compare commits

...

12 Commits

42 changed files with 2557 additions and 1802 deletions

View File

@ -1,5 +1,52 @@
# Changelog
## 2025-05-04 - 2.3.1 - fix(platformservice)
Update dependency versions and refactor import paths for improved compatibility; add initial DcRouter plan documentation.
- Upgrade @git.zone/tsbuild to ^2.3.2 and @push.rocks/tapbundle to ^6.0.3.
- Upgrade @api.global/typedserver to ^3.0.74 and update related API dependencies (cloudflare, letterxpress).
- Upgrade smartdata to ^5.15.1, add smartdns (^6.2.2), upgrade smartproxy to ^10.0.2, smartrequest to ^2.1.0, smartrule to ^2.0.1, and smartrx to ^3.0.10.
- Upgrade @serve.zone/interfaces to ^5.0.4 and @tsclass/tsclass to ^9.1.0; update mailauth to ^4.8.4.
- Add packageManager field in package.json for PNPM configuration.
- Add readme.plan.md detailing the DcRouter implementation plan.
- Refactor import paths in several TS files (e.g. ts/plugins.ts, ts/mta classes) for consistency.
## 2025-03-15 - 2.3.0 - feat(platformservice)
Add AIBridge module and refactor service file paths for improved module organization
- Added new AIBridge class in ts/aibridge/classes.aibridge.ts.
- Renamed letter service file from ts/letter/letterservice.ts to ts/letter/classes.letterservice.ts and updated its index.
- Updated platformservice.ts to import letter and SMS services from new paths.
- Renamed SMS service file from ts/sms/smsservice.ts to ts/sms/classes.smsservice.ts and updated its index accordingly.
## 2025-03-15 - 2.2.1 - fix(platformservice)
Refactor module structure to update import paths and file organization
- Removed obsolete file 'ts/classes.platformservice.ts' and updated references to use 'ts/platformservice.ts'.
- Updated import paths in PlatformServiceDb, EmailService, and other modules to use new file structure.
- Renamed and moved files in the email, mta, letter, and sms directories to align with new module layout.
- Fixed references to external modules (e.g. '@serve.zone/interfaces', '@push.rocks/*', etc.) to reflect the updated paths.
## 2025-03-15 - 2.2.0 - feat(plugins)
Add smartproxy support by including the @push.rocks/smartproxy dependency and exporting it in the plugins module.
- Added '@push.rocks/smartproxy' dependency version '^4.1.0' to package.json
- Updated ts/plugins.ts to export the smartproxy module alongside other push.rocks modules
## 2025-03-15 - 2.1.0 - feat(MTA)
Update readme with detailed Mail Transfer Agent usage and examples
- Added a comprehensive MTA section with usage examples including SMTP server setup, DKIM signing/verification, SPF/DMARC support, and API integration
- Expanded the conclusion to highlight MTA capabilities alongside email, SMS, letter, and AI services
## 2025-03-15 - 2.0.0 - BREAKING CHANGE(platformservice)
Remove deprecated AIBridge module and update email service to use the MTA connector; update dependency versions and adjust build scripts in package.json.
- Completely remove the aibridge module files (aibridge.classes.aibridge.ts, aibridge.classes.aibridgedb.ts, aibridge.classes.openaibridge.ts, aibridge.paths.ts, aibridge.plugins.ts, and index.ts) as they are no longer needed.
- Switch the email service from using MailgunConnector to the new MTA connector for sending emails.
- Update dependency versions for @serve.zone/interfaces, @tsclass/tsclass, letterxpress, and uuid in package.json.
- Enhance the build script in package.json and add pnpm configuration.
## 2025-03-15 - 1.1.2 - fix(mta)
Expose HttpResponse.statusCode and add explicit generic type annotations in DNSManager cache retrieval

View File

@ -1,7 +1,7 @@
{
"name": "@serve.zone/platformservice",
"private": true,
"version": "1.1.2",
"version": "2.3.1",
"description": "A multifaceted platform service handling mail, SMS, letter delivery, and AI services.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
@ -12,39 +12,42 @@
"test": "(tstest test/)",
"start": "(node --max_old_space_size=250 ./cli.js)",
"startTs": "(node cli.ts.js)",
"build": "(tsbuild tsfolders --allowimplicitany)",
"localPublish": ""
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.17",
"@git.zone/tsbuild": "^2.3.2",
"@git.zone/tsrun": "^1.2.8",
"@git.zone/tstest": "^1.0.88",
"@git.zone/tswatch": "^2.0.1",
"@push.rocks/tapbundle": "^5.0.22"
"@push.rocks/tapbundle": "^6.0.3"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.18.0",
"@api.global/typedrequest": "^3.0.19",
"@api.global/typedserver": "^3.0.27",
"@api.global/typedserver": "^3.0.74",
"@api.global/typedsocket": "^3.0.0",
"@apiclient.xyz/cloudflare": "^6.0.3",
"@apiclient.xyz/letterxpress": "^1.0.17",
"@apiclient.xyz/cloudflare": "^6.4.1",
"@apiclient.xyz/letterxpress": "^1.0.22",
"@push.rocks/projectinfo": "^5.0.1",
"@push.rocks/qenv": "^6.0.5",
"@push.rocks/smartdata": "^5.0.7",
"@push.rocks/smartdata": "^5.15.1",
"@push.rocks/smartdns": "^6.2.2",
"@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartmail": "^1.0.24",
"@push.rocks/smartpath": "^5.0.5",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrequest": "^2.0.21",
"@push.rocks/smartrx": "^3.0.7",
"@push.rocks/smartproxy": "^10.0.2",
"@push.rocks/smartrequest": "^2.1.0",
"@push.rocks/smartrule": "^2.0.1",
"@push.rocks/smartrx": "^3.0.10",
"@push.rocks/smartstate": "^2.0.0",
"@serve.zone/interfaces": "^1.0.47",
"@tsclass/tsclass": "^4.0.52",
"mailauth": "^4.6.5",
"@serve.zone/interfaces": "^5.0.4",
"@tsclass/tsclass": "^9.1.0",
"@types/mailparser": "^3.4.5",
"mailauth": "^4.8.4",
"mailparser": "^3.6.9",
"openai": "^4.29.2",
"uuid": "^9.0.1"
"uuid": "^11.1.0"
},
"keywords": [
"mail service",
@ -67,5 +70,13 @@
"rule management",
"SMTP STARTTLS",
"DNS management"
]
],
"pnpm": {
"onlyBuiltDependencies": [
"esbuild",
"mongodb-memory-server",
"puppeteer"
]
},
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
}

2927
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,81 @@ async function sendLetter() {
sendLetter();
```
### Mail Transfer Agent (MTA)
The platform includes a robust Mail Transfer Agent (MTA) for enterprise-grade email handling with complete control over the email delivery process:
```mermaid
graph TD
API[API Clients] --> ApiManager
SMTP[External SMTP Servers] <--> SMTPServer
subgraph "MTA Service"
MtaService[MTA Service] --> SMTPServer[SMTP Server]
MtaService --> EmailSendJob[Email Send Job]
MtaService --> DnsManager[DNS Manager]
MtaService --> DkimCreator[DKIM Creator]
ApiManager[API Manager] --> MtaService
end
subgraph "External Services"
DnsManager <--> DNS[DNS Servers]
EmailSendJob <--> MXServers[MX Servers]
end
```
The MTA service provides:
- Complete SMTP server for receiving emails
- DKIM signing and verification
- SPF and DMARC support
- DNS record management
- Retry logic with queue processing
- TLS encryption
Here's how to use the MTA service:
```ts
import { MtaService, Email } from '@serve.zone/platformservice';
async function useMtaService() {
// Initialize MTA service
const mtaService = new MtaService(platformService);
await mtaService.start();
// Send an email
const email = new Email({
from: 'sender@yourdomain.com',
to: 'recipient@example.com',
subject: 'Hello World',
text: 'This is a test email',
html: '<p>This is a <b>test</b> email</p>',
attachments: [] // Optional attachments
});
const emailId = await mtaService.send(email);
console.log(`Email queued with ID: ${emailId}`);
// Check email status
const status = mtaService.getEmailStatus(emailId);
console.log(`Email status: ${status.status}`);
// Set up API for external access
const apiManager = new ApiManager(mtaService);
await apiManager.start(3000);
console.log('MTA API running on port 3000');
}
useMtaService();
```
The MTA provides key advantages for applications requiring:
- High-volume email sending
- Compliance with email authentication standards
- Detailed delivery tracking
- Custom email handling logic
- Multi-domain email management
- Complete control over email infrastructure
### Leveraging AI Services
The platform also integrates AI functionalities, allowing for innovative use cases like generating content, analyzing text, or automating responses:
@ -122,5 +197,4 @@ useAiService();
### Conclusion
The `@serve.zone/platformservice` offers a robust set of features for modern application requirements, including but not limited to communication and AI services. By following the examples above, developers can integrate these services into their applications, harnessing the power of email, SMS, letters, and artificial intelligence seamlessly.
undefined
The `@serve.zone/platformservice` offers a robust set of features for modern application requirements, including but not limited to communication and AI services. By following the examples above, developers can integrate these services into their applications, harnessing the power of email, SMS, letters, MTA capabilities, and artificial intelligence seamlessly.

91
readme.plan.md Normal file
View File

@ -0,0 +1,91 @@
# DcRouter Implementation Plan
This document outlines the plan for developing **DcRouter**, a central routing
component for the platform service. DcRouter will provide:
- HTTP/HTTPS reverse proxy with TLS (ACME) support
- TCP/SNI-based proxying
- Mail Transfer Agent (MTA) for inbound/outbound SMTP
- Rule-based routing for web and mail traffic
- DNS-based dynamic routing
- Configuration, persistence, logging, and monitoring
## 1. Read and Summarize Dependencies
We will leverage existing modules; key points from their READMEs:
- **@push.rocks/smartproxy**: high-performance HTTP/HTTPS reverse proxy,
TLS termination, ACME HTTP-01, WebSockets, low-level port forwarding (nftables),
TCP/SNI proxy with dynamic routing and IP filtering.
- **@push.rocks/smartmail**: unified mail data structures and utilities.
- **mailparser**: parse raw SMTP messages into structured objects.
- **mailauth**: SPF/DKIM/DMARC validation and signing (DKIM).
- **@api.global/typedserver** / **typedsocket**: typed HTTP and TCP server abstractions.
- **@push.rocks/smartrule**: rule engine for dynamic decision-making on traffic.
- **@push.rocks/smartdns**: DNS resolution and caching for routing decisions.
- **@push.rocks/smartdata**: persistent key/value or document store for configs.
- **@push.rocks/smartlog** and **@push.rocks/smartrx**: logging and metrics/event tracking.
- **@push.rocks/qenv**: environment-based configuration loading.
- **ts/mta**: built-in MTA implementation (MtaService, SMTPServer, EmailSendJob, DKIMCreator/Verifier, DNSManager, ApiManager, Email class).
## 2. High-Level Architecture
DcRouter will instantiate and coordinate:
1. **HTTP(S) Proxy Layer**
- Use `NetworkProxy` and `Port80Handler` from smartproxy
- Manage virtual hosts, certificates, redirects
2. **TCP/SNI Proxy Layer (SmartProxy)**
- Use `SmartProxy` from `@push.rocks/smartproxy` to:
- Forward TCP connections by port or port ranges to backends (nftables-like port forwarding).
- Route TLS connections based on SNI to different target IPs/ports (SNI bridge).
- Integrate HTTP reverse proxy on select ports via `NetworkProxyBridge`.
- Manage ACME certificates with built-in `Port80Handler` and `CertProvisioner`.
- Apply IP filtering, connection rate limiting, timeouts, and detailed logging.
3. **SMTP/MTA Layer**
- Leverage `MtaService` from `ts/mta`, coordinating subcomponents:
- `SMTPServer` (classes.smtpserver): SMTP listener on ports 25/587 with STARTTLS/TLS
- `Email` and `EmailSendJob`: queue-based outbound sending with retries and rate limiting
- `DKIMCreator` / `DKIMVerifier`: automatic key management, signing, and verification
- `DNSManager`: generate and update DNS records for DKIM/SPF/MTA
- `ApiManager`: certificate provisioning and renewal via typedrequest/typedsocket
- Integrate inbound processing (mailparser, SPF/DKIM validation) and routing rules
4. **Rule Engine**
- Use smartrule to define routing rules for HTTP domains and mail addresses
- Support wildcard matching, priority, and dynamic updates
5. **DNS Integration**
- Use smartdns to resolve backend targets by name, with caching
6. **Persistence & Config**
- Load environment config via qenv
- Store dynamic state (rules, domains, MTA settings) in smartdata
7. **Logging & Metrics**
- Instrument all layers with smartlog and smartrx
8. **Management API / CLI**
- Expose REST/CLI commands via typedserver for: add/remove domains, rules,
view status, reload config, etc.
## 3. Feature Breakdown and Milestones
- [ ] A. Core Router scaffolding (`DcRouter` class)
- [ ] B. HTTP/HTTPS proxy integration
- [ ] C. SmartProxy Integration
- [ ] C1. Define `IPortProxySettings` with `fromPort`, `toPort`, `domainConfigs`, and global port ranges
- [ ] C2. Configure `domainConfigs` to mix port forwarding, SNI routing, and `useNetworkProxy` flags
- [ ] C3. Initialize and start `SmartProxy`, including `Port80Handler` for ACME and `CertProvisioner`
- [ ] C4. Wire SmartProxy events (e.g., certificate issuance, connection logging) into DcRouter
- [ ] C5. Support runtime updates to `domainConfigs` for dynamic routing changes
- [ ] D. MTA Integration (ts/mta)
- [ ] D1. Scaffold integration of `MtaService` into `DcRouter`
- [ ] D2. Configure and start `SMTPServer` with TLS/STARTTLS on ports 25/587
- [ ] D3. Wire inbound email handling via `processIncomingEmail` and rule engine
- [ ] D4. Implement outbound queue processing (`EmailSendJob`), retries, rate limiting
- [ ] D5. Manage DKIM keys and DNS records (`DKIMCreator`, `DNSManager`)
- [ ] D6. Provision and auto-renew certificates (`ApiManager`)
- [ ] E. Rule engine wiring for HTTP and SMTP
- [ ] F. DNS-based dynamic resolution
- [ ] G. Persistence layer for configs and state
- [ ] H. Logging/metrics instrumentation
- [ ] I. CLI and REST API endpoints
- [ ] J. Automated tests for each layer
- [ ] K. Documentation and examples in README
## 4. Next Steps
1. Review and refine this plan.
2. Begin implementation starting with the core scaffolding (A).
3. Iterate through features in milestone order.
_Last updated: 2025-05-04_

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@serve.zone/platformservice',
version: '1.1.2',
version: '2.3.1',
description: 'A multifaceted platform service handling mail, SMS, letter delivery, and AI services.'
}

View File

@ -1,50 +0,0 @@
import * as plugins from './aibridge.plugins.js';
import * as paths from './aibridge.paths.js';
import { AiBridgeDb } from './aibridge.classes.aibridgedb.js';
import { OpenAiBridge } from './aibridge.classes.openaibridge.js';
export class AiBridge {
public projectinfo: plugins.projectinfo.ProjectInfo;
public serverInstance: plugins.loleServiceserver.ServiceServer;
public serviceQenv = new plugins.qenv.Qenv('./', './.nogit');
public aibridgeDb: AiBridgeDb;
public openAiBridge: OpenAiBridge;
public typedrouter = new plugins.typedrequest.TypedRouter();
public async start() {
this.aibridgeDb = new AiBridgeDb(this);
await this.aibridgeDb.start();
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
this.openAiBridge = new OpenAiBridge(this);
await this.openAiBridge.start();
// server
this.serverInstance = new plugins.loleServiceserver.ServiceServer({
serviceDomain: 'aibridge.lossless.one',
serviceName: 'aibridge',
serviceVersion: this.projectinfo.npm.version,
addCustomRoutes: async (serverArg) => {
// any custom route configs go here
},
});
// lets implemenet the actual typedrequest functions
this.typedrouter.addTypedHandler<plugins.lointAiBridge.requests.IReq_Chat>(new plugins.typedrequest.TypedHandler('chat', async reqArg => {
const resultChat = await this.openAiBridge.chat(reqArg.chat.systemMessage, reqArg.chat.messages[reqArg.chat.messages.length - 1].content, reqArg.chat.messages);
return {
chat: reqArg.chat,
latestMessage: resultChat.message.content,
}
}))
await this.serverInstance.start();
this.serverInstance.typedServer.typedrouter.addTypedRouter(this.typedrouter);
}
public async stop() {
await this.serverInstance.stop();
await this.aibridgeDb.stop();
}
}

View File

@ -1,25 +0,0 @@
import * as plugins from './aibridge.plugins.js';
import { AiBridge } from './aibridge.classes.aibridge.js';
export class AiBridgeDb {
public smartdataDb: plugins.smartdata.SmartdataDb;
public aibridgeRef: AiBridge;
constructor(aibridgeRefArg: AiBridge) {
this.aibridgeRef = aibridgeRefArg;
}
public async start() {
this.smartdataDb = new plugins.smartdata.SmartdataDb({
mongoDbUser: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_USER'),
mongoDbName: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_NAME'),
mongoDbPass: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_PASS'),
mongoDbUrl: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_URL'),
});
await this.smartdataDb.init();
}
public async stop() {
await this.smartdataDb.close();
}
}

View File

@ -1,58 +0,0 @@
import { AiBridge } from './aibridge.classes.aibridge.js';
import * as plugins from './aibridge.plugins.js';
import * as paths from './aibridge.paths.js';
export class OpenAiBridge {
public aiBridgeRef: AiBridge;
public openAiApiClient: plugins.openai.default;
constructor(aiBridgeRefArg: AiBridge) {
this.aiBridgeRef = aiBridgeRefArg;
}
public async start() {
const openAiToken = await this.aiBridgeRef.serviceQenv.getEnvVarOnDemand('OPENAI_TOKEN');
this.openAiApiClient = new plugins.openai.default({
apiKey: openAiToken,
dangerouslyAllowBrowser: true,
});
}
public async stop() {}
public async chat(
systemMessage: string,
userMessage: string,
messageHistory: {
role: 'assistant' | 'user';
content: string;
}[]
) {
const result = await this.openAiApiClient.chat.completions.create({
model: 'gpt-4-turbo-preview',
messages: [
{ role: 'system', content: systemMessage },
...messageHistory,
{ role: 'user', content: userMessage },
],
});
return {
message: result.choices[0].message,
};
}
public async audio(messageArg: string) {
const done = plugins.smartpromise.defer();
const result = await this.openAiApiClient.audio.speech.create({
model: 'tts-1-hd',
input: messageArg,
voice: 'nova',
response_format: 'mp3',
speed: 1,
});
const stream = result.body.pipe(plugins.smartfile.fsStream.createWriteStream(plugins.path.join(paths.nogitDir, 'output.mp3')));
stream.on('finish', () => {
done.resolve();
});
return done.promise;
}
}

View File

@ -1,16 +0,0 @@
import * as plugins from './aibridge.plugins.js';
export const packageDir = plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../'
);
export const assetsDir = plugins.path.join(
packageDir,
'./assets/'
);
export const nogitDir = plugins.path.join(
packageDir,
'./.nogit/'
);

View File

@ -1,32 +0,0 @@
// node native
import * as path from 'path';
export { path };
// @losslessone_private scope
import * as loleServiceserver from '@losslessone_private/lole-serviceserver';
import * as lointAiBridge from '@losslessone_private/loint-aibridge';
export { loleServiceserver, lointAiBridge };
// apiglobal scope
import * as typedrequest from '@api.global/typedrequest';
export {
typedrequest,
}
// pushrocks scope
import * as projectinfo from '@push.rocks/projectinfo';
import * as qenv from '@push.rocks/qenv';
import * as smartdata from '@push.rocks/smartdata';
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@push.rocks/smartpromise';
export { projectinfo, qenv, smartdata, smartfile, smartpath, smartpromise };
// thirdparty scope
import * as antrophic from '@anthropic-ai/sdk';
import * as openai from 'openai';
export { antrophic as anthropic, openai };

View File

@ -0,0 +1,3 @@
export class AIBridge {
}

View File

@ -1,17 +0,0 @@
import { AiBridge } from './aibridge.classes.aibridge.js';
export {
AiBridge,
}
let aibridgeInstance: AiBridge;
export const runCli = async () => {
aibridgeInstance = new AiBridge();
await aibridgeInstance.start();
};
export const stop = async () => {
if (aibridgeInstance) {
await aibridgeInstance.stop();
}
};

View File

@ -1,5 +1,5 @@
import * as plugins from './plugins.js';
import { SzPlatformService } from './classes.platformservice.js';
import { SzPlatformService } from './platformservice.js';

View File

@ -0,0 +1,49 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { type IMtaConfig, MtaService } from '../mta/classes.mta.js';
export interface IDcRouterOptions {
portProxyConfig?: plugins.smartproxy.IPortProxySettings;
mtaConfig?: IMtaConfig;
dnsServerConfig?: plugins.smartdns.IDnsServerOptions;
}
/**
* DcRouter can be run on ingress and egress to and from a datacenter site.
*/
export class DcRouter {
private options: IDcRouterOptions;
public smartProxy: plugins.smartproxy.SmartProxy;
public mta: MtaService;
public dnsServer: plugins.smartdns.DnsServer;
constructor(optionsArg: IDcRouterOptions) {
this.options = optionsArg;
if (this.options.portProxyConfig) {
this.smartProxy = new plugins.smartproxy.SmartProxy(this.options.portProxyConfig);
}
if (this.options.mtaConfig) {
this.mta = new MtaService(null, this.options.mtaConfig);
}
}
public async start() {
if (this.smartProxy) {
await this.smartProxy.start();
}
if (this.mta) {
await this.mta.start();
}
}
public async stop() {
if (this.smartProxy) {
await this.smartProxy.stop();
}
if (this.mta) {
await this.mta.stop();
}
}
}
export default DcRouter;

View File

@ -0,0 +1,87 @@
import * as plugins from '../plugins.js';
import { EmailService } from './classes.emailservice.js';
import { logger } from '../logger.js';
export class ApiManager {
public emailRef: EmailService;
public typedRouter = new plugins.typedrequest.TypedRouter();
constructor(emailRefArg: EmailService) {
this.emailRef = emailRefArg;
this.emailRef.typedrouter.addTypedRouter(this.typedRouter);
// Register API endpoints
this.registerApiEndpoints();
}
/**
* Register API endpoints for email functionality
*/
private registerApiEndpoints() {
// Register the SendEmail endpoint
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
new plugins.typedrequest.TypedHandler('sendEmail', async (requestData) => {
const mailToSend = new plugins.smartmail.Smartmail({
body: requestData.body,
from: requestData.from,
subject: requestData.title,
});
if (requestData.attachments) {
for (const attachment of requestData.attachments) {
mailToSend.addAttachment(
await plugins.smartfile.SmartFile.fromString(
attachment.name,
attachment.binaryAttachmentString,
'binary'
)
);
}
}
// Send email through the service which will route to the appropriate connector
const emailId = await this.emailRef.sendEmail(mailToSend, requestData.to, {});
logger.log(
'info',
`sent an email to ${requestData.to} with subject '${mailToSend.getSubject()}'`,
{
eventType: 'sentEmail',
email: {
to: requestData.to,
subject: mailToSend.getSubject(),
},
}
);
return {
responseId: emailId,
};
})
);
// Add endpoint to check email status
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.platformservice.mta.IReq_CheckEmailStatus>(
new plugins.typedrequest.TypedHandler('checkEmailStatus', async (requestData) => {
// If MTA is enabled, use it to check status
if (this.emailRef.mtaConnector) {
const status = await this.emailRef.mtaConnector.checkEmailStatus(requestData.emailId);
return status;
}
// For Mailgun, we don't have a status check implementation currently
return {
status: 'unknown',
details: { message: 'Status tracking not available for current provider' }
};
})
);
// Add statistics endpoint
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.platformservice.mta.IReq_GetEMailStats>(
new plugins.typedrequest.TypedHandler('getEmailStats', async () => {
return this.emailRef.getStats();
})
);
}
}

View File

@ -0,0 +1,169 @@
import * as plugins from '../plugins.js';
import { EmailService } from './classes.emailservice.js';
import { logger } from '../logger.js';
// Import MTA classes
import {
MtaService,
Email as MtaEmail,
type IEmailOptions,
DeliveryStatus,
type IAttachment
} from '../mta/index.js';
export class MtaConnector {
public emailRef: EmailService;
private mtaService: MtaService;
constructor(emailRefArg: EmailService, mtaService?: MtaService) {
this.emailRef = emailRefArg;
this.mtaService = mtaService || this.emailRef.mtaService;
}
/**
* Send an email using the MTA service
* @param smartmail The email to send
* @param toAddresses Recipients (comma-separated or array)
* @param options Additional options
*/
public async sendEmail(
smartmail: plugins.smartmail.Smartmail<>,
toAddresses: string | string[],
options: any = {}
): Promise<string> {
try {
// Process recipients
const toArray = Array.isArray(toAddresses)
? toAddresses
: toAddresses.split(',').map(addr => addr.trim());
// Map SmartMail attachments to MTA attachments
const attachments: IAttachment[] = smartmail.attachments.map(attachment => {
return {
filename: attachment.parsedPath.base,
content: Buffer.from(attachment.contentBuffer),
contentType: (attachment as any)?.getContentType?.() || 'application/octet-stream' // TODO: revisit after smartfile has been updated
};
});
// Create MTA Email
const mtaEmail = new MtaEmail({
from: smartmail.options.from,
to: toArray,
subject: smartmail.getSubject(),
text: smartmail.getBody(false), // Plain text version
html: smartmail.getBody(true), // HTML version
attachments
});
// Send using MTA
const emailId = await this.mtaService.send(mtaEmail);
logger.log('info', `Email sent via MTA to ${toAddresses}`, {
eventType: 'sentEmail',
provider: 'mta',
emailId,
to: toAddresses
});
return emailId;
} catch (error) {
logger.log('error', `Failed to send email via MTA: ${error.message}`, {
eventType: 'emailError',
provider: 'mta',
error: error.message
});
throw error;
}
}
/**
* Retrieve and process an incoming email
* For MTA, this would handle an email already received by the SMTP server
* @param emailData The raw email data or identifier
*/
public async receiveEmail(emailData: string): Promise<plugins.smartmail.Smartmail<>> {
try {
// In a real implementation, this would retrieve an email from the MTA storage
// For now, we can use a simplified approach:
// Parse the email (assuming emailData is a raw email or a file path)
const parsedEmail = await plugins.mailparser.simpleParser(emailData);
// Create a Smartmail from the parsed email
const smartmail = new plugins.smartmail.Smartmail({
from: parsedEmail.from?.text || '',
subject: parsedEmail.subject || '',
body: parsedEmail.html || parsedEmail.text || '',
creationObjectRef: {
From: parsedEmail.from?.text || '',
To: parsedEmail.to?.text || '',
Subject: parsedEmail.subject || ''
}
});
// Add attachments if present
if (parsedEmail.attachments && parsedEmail.attachments.length > 0) {
for (const attachment of parsedEmail.attachments) {
smartmail.addAttachment(
await plugins.smartfile.SmartFile.fromBuffer(
attachment.filename || 'attachment',
attachment.content
)
);
}
}
return smartmail;
} catch (error) {
logger.log('error', `Failed to receive email via MTA: ${error.message}`, {
eventType: 'emailError',
provider: 'mta',
error: error.message
});
throw error;
}
}
/**
* Check the status of a sent email
* @param emailId The email ID to check
*/
public async checkEmailStatus(emailId: string): Promise<{
status: string;
details?: any;
}> {
try {
const status = this.mtaService.getEmailStatus(emailId);
if (!status) {
return {
status: 'unknown',
details: { message: 'Email not found' }
};
}
return {
status: status.status,
details: {
attempts: status.attempts,
lastAttempt: status.lastAttempt,
nextAttempt: status.nextAttempt,
error: status.error?.message
}
};
} catch (error) {
logger.log('error', `Failed to check email status: ${error.message}`, {
eventType: 'emailError',
provider: 'mta',
emailId,
error: error.message
});
return {
status: 'error',
details: { message: error.message }
};
}
}
}

View File

@ -0,0 +1,131 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { MtaConnector } from './classes.connector.mta.js';
import { RuleManager } from './classes.rulemanager.js';
import { ApiManager } from './classes.apimanager.js';
import { logger } from '../logger.js';
import type { SzPlatformService } from '../platformservice.js';
// Import MTA service
import { MtaService, type IMtaConfig } from '../mta/index.js';
export interface IEmailConstructorOptions {
useMta?: boolean;
mtaConfig?: IMtaConfig;
}
/**
* Email service with support for both Mailgun and local MTA
*/
export class EmailService {
public platformServiceRef: SzPlatformService;
// typedrouter
public typedrouter = new plugins.typedrequest.TypedRouter();
// connectors
public mtaConnector: MtaConnector;
public qenv = new plugins.qenv.Qenv('./', '.nogit/');
// MTA service
public mtaService: MtaService;
// services
public apiManager: ApiManager;
public ruleManager: RuleManager;
// configuration
private config: IEmailConstructorOptions;
constructor(platformServiceRefArg: SzPlatformService, options: IEmailConstructorOptions = {}) {
this.platformServiceRef = platformServiceRefArg;
this.platformServiceRef.typedrouter.addTypedRouter(this.typedrouter);
// Set default options
this.config = {
useMta: options.useMta ?? true,
mtaConfig: options.mtaConfig || {}
};
if (this.config.useMta) {
// Initialize MTA service
this.mtaService = new MtaService(platformServiceRefArg, this.config.mtaConfig);
// Initialize MTA connector
this.mtaConnector = new MtaConnector(this);
}
// Initialize API manager and rule manager
this.apiManager = new ApiManager(this);
this.ruleManager = new RuleManager(this);
// Set up MTA SMTP server webhook if using MTA
if (this.config.useMta) {
// The MTA SMTP server will handle incoming emails directly
// through its SMTP protocol. No additional webhook needed.
}
}
/**
* Start the email service
*/
public async start() {
// Initialize rule manager
await this.ruleManager.init();
// Start MTA service if enabled
if (this.config.useMta && this.mtaService) {
await this.mtaService.start();
logger.log('success', 'Started MTA service');
}
logger.log('success', `Started email service`);
}
/**
* Stop the email service
*/
public async stop() {
// Stop MTA service if it's running
if (this.config.useMta && this.mtaService) {
await this.mtaService.stop();
logger.log('info', 'Stopped MTA service');
}
logger.log('info', 'Stopped email service');
}
/**
* Send an email using the configured provider (Mailgun or MTA)
* @param email The email to send
* @param to Recipient(s)
* @param options Additional options
*/
public async sendEmail(
email: plugins.smartmail.Smartmail<>,
to: string | string[],
options: any = {}
): Promise<string> {
// Determine which connector to use
if (this.config.useMta && this.mtaConnector) {
return this.mtaConnector.sendEmail(email, to, options);
} else {
throw new Error('No email provider configured');
}
}
/**
* Get email service statistics
*/
public getStats() {
const stats: any = {
activeProviders: []
};
if (this.config.useMta) {
stats.activeProviders.push('mta');
stats.mta = this.mtaService.getStats();
}
return stats;
}
}

View File

@ -0,0 +1,177 @@
import * as plugins from '../plugins.js';
import { EmailService } from './classes.emailservice.js';
import { logger } from '../logger.js';
export class RuleManager {
public emailRef: EmailService;
public smartruleInstance = new plugins.smartrule.SmartRule<
plugins.smartmail.Smartmail<any>
>();
constructor(emailRefArg: EmailService) {
this.emailRef = emailRefArg;
// Register MTA handler for incoming emails if MTA is enabled
if (this.emailRef.mtaService) {
this.setupMtaIncomingHandler();
}
}
/**
* Set up handler for incoming emails via MTA's SMTP server
*/
private setupMtaIncomingHandler() {
// The original MtaService doesn't have a direct callback for incoming emails,
// but we can modify this approach based on how you prefer to integrate.
// One option would be to extend the MtaService to add an event emitter.
// For now, we'll use a directory watcher as an example
// This would watch the directory where MTA saves incoming emails
const incomingDir = this.emailRef.mtaService['receivedEmailsDir'] || './received';
// Simple file watcher (in real implementation, use proper file watching)
// This is just conceptual - would need modification to work with your specific setup
this.watchIncomingEmails(incomingDir);
}
/**
* Watch directory for incoming emails (conceptual implementation)
*/
private watchIncomingEmails(directory: string) {
console.log(`Watching for incoming emails in: ${directory}`);
// Conceptual - in a real implementation, set up proper file watching
// or modify the MTA to emit events when emails are received
/*
// Example using a file watcher:
const watcher = plugins.fs.watch(directory, async (eventType, filename) => {
if (eventType === 'rename' && filename.endsWith('.eml')) {
const filePath = plugins.path.join(directory, filename);
await this.handleMtaIncomingEmail(filePath);
}
});
*/
}
/**
* Handle incoming email received via MTA
*/
public async handleMtaIncomingEmail(emailPath: string) {
try {
// Process the email file
const fetchedSmartmail = await this.emailRef.mtaConnector.receiveEmail(emailPath);
console.log('=======================');
console.log('Received a mail via MTA:');
console.log(`From: ${fetchedSmartmail.options.creationObjectRef.From}`);
console.log(`To: ${fetchedSmartmail.options.creationObjectRef.To}`);
console.log(`Subject: ${fetchedSmartmail.options.creationObjectRef.Subject}`);
console.log('^^^^^^^^^^^^^^^^^^^^^^^');
logger.log(
'info',
`email from ${fetchedSmartmail.options.creationObjectRef.From} to ${fetchedSmartmail.options.creationObjectRef.To} with subject '${fetchedSmartmail.options.creationObjectRef.Subject}'`,
{
eventType: 'receivedEmail',
provider: 'mta',
email: {
from: fetchedSmartmail.options.creationObjectRef.From,
to: fetchedSmartmail.options.creationObjectRef.To,
subject: fetchedSmartmail.options.creationObjectRef.Subject,
},
}
);
// Process with rules
this.smartruleInstance.makeDecision(fetchedSmartmail);
} catch (error) {
logger.log('error', `Failed to process incoming MTA email: ${error.message}`, {
eventType: 'emailError',
provider: 'mta',
error: error.message
});
}
}
public async init() {
// Setup email rules
await this.createForwards();
}
/**
* creates the default forwards
*/
public async createForwards() {
const forwards: { originalToAddress: string[]; forwardedToAddress: string[] }[] = [];
console.log(`${forwards.length} forward rules configured:`);
for (const forward of forwards) {
console.log(forward);
}
for (const forward of forwards) {
this.smartruleInstance.createRule(
10,
async (smartmailArg) => {
const matched = forward.originalToAddress.reduce<boolean>((prevValue, currentValue) => {
return smartmailArg.options.creationObjectRef.To.includes(currentValue) || prevValue;
}, false);
if (matched) {
console.log('Forward rule matched');
console.log(forward);
return 'apply-continue';
} else {
return 'continue';
}
},
async (smartmailArg: plugins.smartmail.Smartmail<any>) => {
forward.forwardedToAddress.map(async (toArg) => {
const forwardedSmartMail = new plugins.smartmail.Smartmail({
body:
`
<div style="background: #CCC; padding: 10px; border-radius: 3px;">
<div><b>Original Sender:</b></div>
<div>${smartmailArg.options.creationObjectRef.From}</div>
<div><b>Original Recipient:</b></div>
<div>${smartmailArg.options.creationObjectRef.To}</div>
<div><b>Forwarded to:</b></div>
<div>${forward.forwardedToAddress.reduce<string>((pVal, cVal) => {
return `${pVal ? pVal + ', ' : ''}${cVal}`;
}, null)}</div>
<div><b>Subject:</b></div>
<div>${smartmailArg.getSubject()}</div>
<div><b>The original body can be found below.</b></div>
</div>
` + smartmailArg.getBody(),
from: 'forwarder@mail.lossless.one',
subject: `Forwarded mail for '${smartmailArg.options.creationObjectRef.To}'`,
});
for (const attachment of smartmailArg.attachments) {
forwardedSmartMail.addAttachment(attachment);
}
// Use the EmailService's sendEmail method to send with the appropriate provider
await this.emailRef.sendEmail(forwardedSmartMail, toArg);
console.log(`forwarded mail to ${toArg}`);
logger.log(
'info',
`email from ${
smartmailArg.options.creationObjectRef.From
} to ${toArg} with subject '${smartmailArg.getSubject()}'`,
{
eventType: 'forwardedEmail',
email: {
from: smartmailArg.options.creationObjectRef.From,
to: smartmailArg.options.creationObjectRef.To,
forwardedTo: toArg,
subject: smartmailArg.options.creationObjectRef.Subject,
},
}
);
});
}
);
}
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from './email.plugins.js';
import * as plugins from '../plugins.js';
export class TemplateManager {
public smartmailDefault = new plugins.smartmail.Smartmail({

View File

@ -1,51 +0,0 @@
import * as plugins from '../plugins.js';
import { EmailService } from './email.classes.emailservice.js';
import { logger } from '../logger.js';
export class ApiManager {
public emailRef: EmailService;
public typedRouter = new plugins.typedrequest.TypedRouter();
constructor(emailRefArg: EmailService) {
this.emailRef = emailRefArg;
this.emailRef.typedrouter.addTypedRouter(this.typedRouter);
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
new plugins.typedrequest.TypedHandler('sendEmail', async (requestData) => {
const mailToSend = new plugins.smartmail.Smartmail({
body: requestData.body,
from: requestData.from,
subject: requestData.title,
});
if (requestData.attachments) {
for (const attachment of requestData.attachments) {
mailToSend.addAttachment(
await plugins.smartfile.SmartFile.fromString(
attachment.name,
attachment.binaryAttachmentString,
'binary'
)
);
}
}
await this.emailRef.mailgunConnector.sendEmail(mailToSend, requestData.to, {});
logger.log(
'info',
`send an email to ${requestData.to} with subject '${mailToSend.getSubject()}'`,
{
eventType: 'sentEmail',
email: {
to: requestData.to,
subject: mailToSend.getSubject(),
},
}
);
return {
responseId: 'abc', // TODO: generate proper response id
};
})
);
}
}

View File

@ -1,30 +0,0 @@
import * as plugins from './email.plugins.js';
import { EmailService } from './email.classes.emailservice.js';
export class MailgunConnector {
public emailRef: EmailService;
public mailgunAccount: plugins.mailgun.MailgunAccount;
constructor(emailRefArg: EmailService) {
this.emailRef = emailRefArg;
this.mailgunAccount = new plugins.mailgun.MailgunAccount({
apiToken: this.emailRef.qenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'),
region: 'eu',
});
this.mailgunAccount.addSmtpCredentials(
this.emailRef.qenv.getEnvVarOnDemand('MAILGUN_SMTP_CREDENTIALS')
);
}
public async sendEmail(
smartMailArg: plugins.smartmail.Smartmail<any>,
toArg: string,
dataArg: any = {}
) {
this.mailgunAccount.sendSmartMail(smartMailArg, toArg, dataArg);
}
public async receiveEmail(messageUrl: string) {
return await this.mailgunAccount.retrieveSmartMailFromMessageUrl(messageUrl);
}
}

View File

@ -1,53 +0,0 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { MailgunConnector } from './email.classes.connector.mailgun.js';
import { RuleManager } from './email.classes.rulemanager.js';
import { ApiManager } from './email.classes.apimanager.js';
import { logger } from '../logger.js';
import type { SzPlatformService } from '../classes.platformservice.js';
export interface IEmailConstructorOptions {
mailgunApiKey: string;
}
export class EmailService {
public platformServiceRef: SzPlatformService;
// typedrouter
public typedrouter = new plugins.typedrequest.TypedRouter();
// connectors
public mailgunConnector: MailgunConnector;
public qenv = new plugins.qenv.Qenv('./', '.nogit/');
// server
public apiManager = new ApiManager(this);
public ruleManager: RuleManager;
constructor(platformServiceRefArg: SzPlatformService) {
this.platformServiceRef = platformServiceRefArg;
this.platformServiceRef.typedrouter.addTypedRouter(this.typedrouter);
this.mailgunConnector = new MailgunConnector(this);
this.ruleManager = new RuleManager(this);
this.platformServiceRef.typedserver.server.addRoute(
'/mailgun-notify',
new plugins.typedserver.servertools.Handler('POST', async (req, res) => {
console.log('Got a mailgun email notification');
res.status(200);
res.end();
this.ruleManager.handleNotification(req.body);
})
);
}
public async start() {
await this.ruleManager.init();
logger.log('success', `Started email service`);
}
public async stop() {
}
}

View File

@ -1,137 +0,0 @@
import * as plugins from './email.plugins.js';
import { EmailService } from './email.classes.emailservice.js';
import { logger } from './email.logging.js';
export class RuleManager {
public emailRef: EmailService;
public smartruleInstance = new plugins.smartrule.SmartRule<
plugins.smartmail.Smartmail<plugins.mailgun.IMailgunMessage>
>();
constructor(emailRefArg: EmailService) {
this.emailRef = emailRefArg;
}
public async handleNotification(notification: plugins.mailgun.IMailgunNotification) {
console.log(notification['message-url']);
// basic checks here
// none for now
const fetchedSmartmail = await this.emailRef.mailgunConnector.receiveEmail(
notification['message-url']
);
console.log('=======================');
console.log('Received a mail:');
console.log(`From: ${fetchedSmartmail.options.creationObjectRef.From}`);
console.log(`To: ${fetchedSmartmail.options.creationObjectRef.To}`);
console.log(`Subject: ${fetchedSmartmail.options.creationObjectRef.Subject}`);
console.log('^^^^^^^^^^^^^^^^^^^^^^^');
logger.log(
'info',
`email from ${fetchedSmartmail.options.creationObjectRef.From} to ${fetchedSmartmail.options.creationObjectRef.To} with subject '${fetchedSmartmail.options.creationObjectRef.Subject}'`,
{
eventType: 'receivedEmail',
email: {
from: fetchedSmartmail.options.creationObjectRef.From,
to: fetchedSmartmail.options.creationObjectRef.To,
subject: fetchedSmartmail.options.creationObjectRef.Subject,
},
}
);
this.smartruleInstance.makeDecision(fetchedSmartmail);
}
public async init() {
// lets forward stuff
await this.createForwards();
}
/**
* creates the default forwards
*/
public async createForwards() {
const forwards: { originalToAddress: string[]; forwardedToAddress: string[] }[] = [
{
originalToAddress: ['bot@mail.nevermind.group'],
forwardedToAddress: ['phil@metadata.company', 'dominik@metadata.company'],
},
{
originalToAddress: ['legal@mail.lossless.com'],
forwardedToAddress: ['phil@lossless.com'],
},
{
originalToAddress: ['christine.nyamwaro@mail.lossless.com', 'christine@nyamwaro.com'],
forwardedToAddress: ['phil@lossless.com'],
},
];
console.log(`${forwards.length} forward rules configured:`);
for (const forward of forwards) {
console.log(forward);
}
for (const forward of forwards) {
this.smartruleInstance.createRule(
10,
async (smartmailArg) => {
const matched = forward.originalToAddress.reduce<boolean>((prevValue, currentValue) => {
return smartmailArg.options.creationObjectRef.To.includes(currentValue) || prevValue;
}, false);
if (matched) {
console.log('Forward rule matched');
console.log(forward);
return 'apply-continue';
} else {
return 'continue';
}
},
async (smartmailArg: plugins.smartmail.Smartmail<plugins.mailgun.IMailgunMessage>) => {
forward.forwardedToAddress.map(async (toArg) => {
const forwardedSmartMail = new plugins.smartmail.Smartmail({
body:
`
<div style="background: #CCC; padding: 10px; border-radius: 3px;">
<div><b>Original Sender:</b></div>
<div>${smartmailArg.options.creationObjectRef.From}</div>
<div><b>Original Recipient:</b></div>
<div>${smartmailArg.options.creationObjectRef.To}</div>
<div><b>Forwarded to:</b></div>
<div>${forward.forwardedToAddress.reduce<string>((pVal, cVal) => {
return `${pVal ? pVal + ', ' : ''}${cVal}`;
}, null)}</div>
<div><b>Subject:</b></div>
<div>${smartmailArg.getSubject()}</div>
<div><b>The original body can be found below.</b></div>
</div>
` + smartmailArg.getBody(),
from: 'forwarder@mail.lossless.one',
subject: `Forwarded mail for '${smartmailArg.options.creationObjectRef.To}'`,
});
for (const attachment of smartmailArg.attachments) {
forwardedSmartMail.addAttachment(attachment);
}
await this.emailRef.mailgunConnector.sendEmail(forwardedSmartMail, toArg);
console.log(`forwarded mail to ${toArg}`);
logger.log(
'info',
`email from ${
smartmailArg.options.creationObjectRef.From
} to phil@lossless.com with subject '${smartmailArg.getSubject()}'`,
{
eventType: 'forwardedEmail',
email: {
from: smartmailArg.options.creationObjectRef.From,
to: smartmailArg.options.creationObjectRef.To,
forwardedTo: toArg,
subject: smartmailArg.options.creationObjectRef.Subject,
},
}
);
});
}
);
}
}
}

View File

@ -1,4 +1,4 @@
export * from './00_commitinfo_data.js';
import { SzPlatformService } from './classes.platformservice.js';
import { SzPlatformService } from './platformservice.js';
export const runCli = async () => {}

View File

@ -1,4 +1,4 @@
import type { SzPlatformService } from '../classes.platformservice.js';
import type { SzPlatformService } from '../platformservice.js';
import * as plugins from '../plugins.js';
export interface ILetterConstructorOptions {

View File

@ -0,0 +1 @@
export * from './classes.letterservice.js';

View File

@ -1,9 +1,9 @@
import * as plugins from '../plugins.js';
import { Email } from './mta.classes.email.js';
import type { IEmailOptions } from './mta.classes.email.js';
import { DeliveryStatus } from './mta.classes.emailsendjob.js';
import type { MtaService } from './mta.classes.mta.js';
import type { IDnsRecord } from './mta.classes.dnsmanager.js';
import { Email } from './classes.email.js';
import type { IEmailOptions } from './classes.email.js';
import { DeliveryStatus } from './classes.emailsendjob.js';
import type { MtaService } from './classes.mta.js';
import type { IDnsRecord } from './classes.dnsmanager.js';
/**
* Authentication options for API requests

View File

@ -1,8 +1,8 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { Email } from './mta.classes.email.js';
import type { MtaService } from './mta.classes.mta.js';
import { Email } from './classes.email.js';
import type { MtaService } from './classes.mta.js';
const readFile = plugins.util.promisify(plugins.fs.readFile);
const writeFile = plugins.util.promisify(plugins.fs.writeFile);

View File

@ -1,5 +1,5 @@
import * as plugins from '../plugins.js';
import { MtaService } from './mta.classes.mta.js';
import { MtaService } from './classes.mta.js';
class DKIMVerifier {
public mtaRef: MtaService;

View File

@ -1,6 +1,6 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import type { MtaService } from './mta.classes.mta.js';
import type { MtaService } from './classes.mta.js';
/**
* Interface for DNS record information

View File

@ -1,8 +1,8 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { Email } from './mta.classes.email.js';
import { EmailSignJob } from './mta.classes.emailsignjob.js';
import type { MtaService } from './mta.classes.mta.js';
import { Email } from './classes.email.js';
import { EmailSignJob } from './classes.emailsignjob.js';
import type { MtaService } from './classes.mta.js';
// Configuration options for email sending
export interface IEmailSendOptions {

View File

@ -1,5 +1,5 @@
import * as plugins from '../plugins.js';
import type { MtaService } from './mta.classes.mta.js';
import type { MtaService } from './classes.mta.js';
interface Headers {
[key: string]: string;

View File

@ -1,14 +1,14 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { Email } from './mta.classes.email.js';
import { EmailSendJob, DeliveryStatus } from './mta.classes.emailsendjob.js';
import { DKIMCreator } from './mta.classes.dkimcreator.js';
import { DKIMVerifier } from './mta.classes.dkimverifier.js';
import { SMTPServer, type ISmtpServerOptions } from './mta.classes.smtpserver.js';
import { DNSManager } from './mta.classes.dnsmanager.js';
import { ApiManager } from './mta.classes.apimanager.js';
import type { SzPlatformService } from '../classes.platformservice.js';
import { Email } from './classes.email.js';
import { EmailSendJob, DeliveryStatus } from './classes.emailsendjob.js';
import { DKIMCreator } from './classes.dkimcreator.js';
import { DKIMVerifier } from './classes.dkimverifier.js';
import { SMTPServer, type ISmtpServerOptions } from './classes.smtpserver.js';
import { DNSManager } from './classes.dnsmanager.js';
import { ApiManager } from './classes.apimanager.js';
import type { SzPlatformService } from '../platformservice.js';
/**
* Configuration options for the MTA service

View File

@ -1,7 +1,7 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { Email } from './mta.classes.email.js';
import type { MtaService } from './mta.classes.mta.js';
import { Email } from './classes.email.js';
import type { MtaService } from './classes.mta.js';
export interface ISmtpServerOptions {
port: number;

View File

@ -1,8 +1,7 @@
export * from './mta.classes.dkimcreator.js';
export * from './mta.classes.emailsignjob.js';
export * from './mta.classes.dkimverifier.js';
export * from './mta.classes.mta.js';
export * from './mta.classes.smtpserver.js';
export * from './mta.classes.emailsendjob.js';
export * from './mta.classes.mta.js';
export * from './mta.classes.email.js';
export * from './classes.dkimcreator.js';
export * from './classes.emailsignjob.js';
export * from './classes.dkimverifier.js';
export * from './classes.mta.js';
export * from './classes.smtpserver.js';
export * from './classes.emailsendjob.js';
export * from './classes.email.js';

View File

@ -1,10 +1,10 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { PlatformServiceDb } from './classes.platformservicedb.js'
import { EmailService } from './email/email.classes.emailservice.js';
import { SmsService } from './sms/smsservice.js';
import { EmailService } from './email/classes.emailservice.js';
import { SmsService } from './sms/classes.smsservice.js';
import { LetterService } from './letter/classes.letterservice.js';
import { MtaService } from './mta/mta.classes.mta.js';
import { MtaService } from './mta/classes.mta.js';
export class SzPlatformService {
public projectinfo: plugins.projectinfo.ProjectInfo;

View File

@ -41,15 +41,18 @@ export {
import * as projectinfo from '@push.rocks/projectinfo';
import * as qenv from '@push.rocks/qenv';
import * as smartdata from '@push.rocks/smartdata';
import * as smartdns from '@push.rocks/smartdns';
import * as smartfile from '@push.rocks/smartfile';
import * as smartlog from '@push.rocks/smartlog';
import * as smartmail from '@push.rocks/smartmail';
import * as smartpath from '@push.rocks/smartpath';
import * as smartproxy from '@push.rocks/smartproxy';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartrule from '@push.rocks/smartrule';
import * as smartrx from '@push.rocks/smartrx';
export { projectinfo, qenv, smartdata, smartfile, smartlog, smartmail, smartpath, smartpromise, smartrequest, smartrx };
export { projectinfo, qenv, smartdata, smartdns, smartfile, smartlog, smartmail, smartpath, smartproxy, smartpromise, smartrequest, smartrule, smartrx };
// apiclient.xyz scope
import * as letterxpress from '@apiclient.xyz/letterxpress';

View File

@ -1,7 +1,7 @@
import * as plugins from '../plugins.js';
import * as paths from '../paths.js';
import { logger } from '../logger.js';
import type { SzPlatformService } from '../classes.platformservice.js';
import type { SzPlatformService } from '../platformservice.js';
export interface ISmsConstructorOptions {
apiGatewayApiToken: string;

View File

@ -1 +1 @@
export * from './smsservice.js';
export * from './classes.smsservice.js';

View File

@ -1,6 +1,7 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",