@breadstone/archipel-mcp 0.0.54 → 0.0.55
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/data/guides/ai-image-generation.md +96 -0
- package/data/guides/ai-realtime-voice.md +69 -464
- package/data/guides/ai-text-generation.md +95 -626
- package/data/guides/index.md +2 -1
- package/data/guides/intelligence-prompts-warm-up.md +63 -283
- package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgent.md +95 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgentFactory.md +11 -23
- package/data/packages/platform-intelligence/api/Class.IntelligenceEmbeddingGenerator.md +25 -21
- package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +11 -7
- package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +159 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +60 -38
- package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptExecutor.md +6 -6
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAssetUploader.md +21 -15
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderDiagnostics.md +55 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderError.md +14 -4
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderRegistry.md +68 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeError.md +9 -9
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +12 -12
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionPort.md +18 -18
- package/data/packages/platform-intelligence/api/Class.IntelligenceReranker.md +58 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +14 -16
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +10 -14
- package/data/packages/platform-intelligence/api/Class.MiMoIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +102 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokCodeExecutionTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokMcpServerTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokViewImageTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokViewXVideoTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokXSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createIntelligenceJsonSchema.md +31 -0
- package/data/packages/platform-intelligence/api/Function.createIntelligenceTool.md +2 -2
- package/data/packages/platform-intelligence/api/Function.createMimoCustomTool.md +5 -5
- package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.defineIntelligenceTool.md +31 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceAgentConfiguration.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchOptions.md +124 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +102 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadResult.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGeneratedFile.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGenerationStepStartEvent.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationOptions.md +170 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationResult.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageCompletion.md +141 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageGenerationOptions.md +234 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageStream.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelReference.md +34 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelRequestOptions.md +52 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +33 -27
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceObjectStream.md +56 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePrompt.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptDefinition.md +14 -14
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptEffectivePolicy.md +1 -1
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionPolicy.md +1 -1
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionResult.md +15 -27
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderAdapter.md +73 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderConfiguration.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderProbeResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeModuleOptions.md +9 -21
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +11 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +98 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +140 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +94 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +80 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +164 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +139 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTool.md +7 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolCall.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolDefinition.md +91 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionEndEvent.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionStartEvent.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolRegistry.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionResult.md +84 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionStream.md +97 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceUsage.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +229 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceModelMessage.md +43 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligencePromptModelRequirement.md +2 -2
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceSchema.md +70 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceCapability.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceDefaultModels.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceJsonValue.md +22 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptDefinitionConfiguration.md +2 -2
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptGenerationOptions.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderName.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderOptions.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderProbeStatus.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderToolOptions.md +17 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMeteringEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRequestTimeouts.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolChoice.md +21 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolOutput.md +22 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolSet.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTranscriptionStreamPart.md +46 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_API_KEY.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_BASE_URL.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MAX_OUTPUT_TOKENS.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MODEL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_PROVIDER.md +2 -2
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TEMPERATURE.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TOP_P.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.IntelligenceCapabilityNames.md +40 -0
- package/data/packages/platform-intelligence/api/Variable.IntelligenceProviderNames.md +2 -0
- package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-intelligence/api/index.md +78 -30
- package/package.json +1 -1
- package/data/packages/index.md +0 -8
- package/data/packages/platform-analytics/index.md +0 -209
- package/data/packages/platform-authentication/index.md +0 -725
- package/data/packages/platform-blob-storage/index.md +0 -416
- package/data/packages/platform-bootstrap/index.md +0 -162
- package/data/packages/platform-caching/index.md +0 -167
- package/data/packages/platform-configuration/index.md +0 -226
- package/data/packages/platform-core/index.md +0 -504
- package/data/packages/platform-cryptography/index.md +0 -142
- package/data/packages/platform-database/index.md +0 -337
- package/data/packages/platform-documents/index.md +0 -255
- package/data/packages/platform-esigning/index.md +0 -710
- package/data/packages/platform-feature-flags/index.md +0 -103
- package/data/packages/platform-health/index.md +0 -141
- package/data/packages/platform-intelligence/api/Class.IntelligenceStructuredGenerator.md +0 -70
- package/data/packages/platform-intelligence/api/Class.IntelligenceTelemetryRegistry.md +0 -44
- package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +0 -138
- package/data/packages/platform-intelligence/api/Function.createProviderOptions.md +0 -39
- package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGoogleRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGrokRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Function.loadMimoLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadOpenAIRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCompletionUsage.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextCompletion.md +0 -180
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerationOptions.md +0 -144
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerator.md +0 -78
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextStreamingOptions.md +0 -170
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +0 -24
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoaders.md +0 -14
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoader.md +0 -25
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoaders.md +0 -14
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTextStream.md +0 -14
- package/data/packages/platform-intelligence/index.md +0 -627
- package/data/packages/platform-logging/index.md +0 -150
- package/data/packages/platform-mailing/index.md +0 -470
- package/data/packages/platform-mapping/index.md +0 -123
- package/data/packages/platform-mcp/index.md +0 -335
- package/data/packages/platform-openapi/index.md +0 -207
- package/data/packages/platform-payments/index.md +0 -610
- package/data/packages/platform-queue/index.md +0 -192
- package/data/packages/platform-reporting/index.md +0 -233
- package/data/packages/platform-resources/index.md +0 -137
- package/data/packages/platform-telemetry/index.md +0 -262
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: platform-logging
|
|
3
|
-
description: Configurable logging module for NestJS with log-level management, request context propagation, and structured logging.
|
|
4
|
-
order: 6
|
|
5
|
-
tags: [logging, log-level, nestjs, request-context, structured-logging, correlation-id]
|
|
6
|
-
package: '@breadstone/archipel-platform-logging'
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# platform-logging
|
|
10
|
-
|
|
11
|
-
Configurable logging module for NestJS applications with application-wide log-level management, request-scoped context propagation, and structured logging. Wraps the built-in NestJS `Logger` and configures it via the central `ConfigModule`.
|
|
12
|
-
|
|
13
|
-
**Package:** `@breadstone/archipel-platform-logging`
|
|
14
|
-
|
|
15
|
-
<InstallTabs />
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { Module } from '@nestjs/common';
|
|
21
|
-
import { LoggerModule } from '@breadstone/archipel-platform-logging';
|
|
22
|
-
|
|
23
|
-
@Module({
|
|
24
|
-
imports: [LoggerModule],
|
|
25
|
-
})
|
|
26
|
-
export class AppModule {}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The module is `@Global()` — once imported, `Logger` is available for injection across the entire application.
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Using the Logger
|
|
34
|
-
|
|
35
|
-
Inject the standard NestJS `Logger` provided by `LoggerModule`:
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
import { Injectable, Logger } from '@nestjs/common';
|
|
39
|
-
|
|
40
|
-
@Injectable()
|
|
41
|
-
export class PaymentService {
|
|
42
|
-
constructor(private readonly _logger: Logger) {}
|
|
43
|
-
|
|
44
|
-
public async processPayment(orderId: string): Promise<void> {
|
|
45
|
-
this._logger.log(`Processing payment for order ${orderId}`);
|
|
46
|
-
// ...
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Request Context Propagation
|
|
54
|
-
|
|
55
|
-
### RequestIdMiddleware
|
|
56
|
-
|
|
57
|
-
Extracts or generates a unique `x-request-id` per request and stores it in `AsyncLocalStorage` via `RequestContextStore`. Apply it globally:
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import { RequestIdMiddleware } from '@breadstone/archipel-platform-logging';
|
|
61
|
-
|
|
62
|
-
export class AppModule implements NestModule {
|
|
63
|
-
public configure(consumer: MiddlewareConsumer): void {
|
|
64
|
-
consumer.apply(RequestIdMiddleware).forRoutes('*');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
The middleware:
|
|
70
|
-
|
|
71
|
-
1. Reads the `x-request-id` header from the incoming request (if present from an API gateway or load balancer)
|
|
72
|
-
2. Generates a UUID v4 if no header is found
|
|
73
|
-
3. Sets the `x-request-id` header on the response
|
|
74
|
-
4. Wraps the request execution in `RequestContextStore.run()` so the ID is available anywhere in the call stack
|
|
75
|
-
|
|
76
|
-
### RequestContextStore
|
|
77
|
-
|
|
78
|
-
`AsyncLocalStorage`-based per-request context store. Access the current request context from anywhere without passing parameters:
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
import { RequestContextStore, type IRequestContext } from '@breadstone/archipel-platform-logging';
|
|
82
|
-
|
|
83
|
-
// Get current context
|
|
84
|
-
const context: IRequestContext | undefined = RequestContextStore.get();
|
|
85
|
-
const requestId: string | undefined = RequestContextStore.getRequestId();
|
|
86
|
-
|
|
87
|
-
// Run a callback within a context (used internally by middleware)
|
|
88
|
-
RequestContextStore.run({ requestId: 'abc-123', userId: 'user-1' }, () => {
|
|
89
|
-
// context is available in all nested calls
|
|
90
|
-
});
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
#### IRequestContext
|
|
94
|
-
|
|
95
|
-
| Field | Type | Description |
|
|
96
|
-
| ----------- | -------- | --------------------------------- |
|
|
97
|
-
| `requestId` | `string` | Unique request correlation ID |
|
|
98
|
-
| `userId` | `string?`| Optional authenticated user ID |
|
|
99
|
-
|
|
100
|
-
### ContextLogger
|
|
101
|
-
|
|
102
|
-
Structured logger that automatically enriches every log entry with the current request context:
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
import { ContextLogger } from '@breadstone/archipel-platform-logging';
|
|
106
|
-
|
|
107
|
-
@Injectable()
|
|
108
|
-
export class OrderService {
|
|
109
|
-
private readonly _logger = new ContextLogger(OrderService.name);
|
|
110
|
-
|
|
111
|
-
public async placeOrder(dto: CreateOrderDto): Promise<void> {
|
|
112
|
-
this._logger.log('Placing order', { orderId: dto.orderId });
|
|
113
|
-
// Output: { requestId: "abc-123", userId: "user-1", orderId: "...", message: "Placing order" }
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Methods: `log()`, `warn()`, `error()`, `debug()`, `verbose()` — all accept an optional `data` record that is merged with the request context.
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## Environment Variables
|
|
123
|
-
|
|
124
|
-
| Variable | Description | Required | Default |
|
|
125
|
-
| --------------- | -------------------------------------------------------------- | -------- | ------- |
|
|
126
|
-
| `APP_LOG_LEVEL` | Application log level (`'debug'`, `'info'`, `'warn'`, `'error'`) | No | `warn` |
|
|
127
|
-
|
|
128
|
-
> **Startup validation:** The module validates `APP_LOG_LEVEL` at initialization. An unrecognized value triggers a warning and falls back to `warn`.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Peer Dependencies
|
|
133
|
-
|
|
134
|
-
| Package | Required | Notes |
|
|
135
|
-
| --------- | -------- | ---------------------------------------------- |
|
|
136
|
-
| `express` | Yes | Required for `RequestIdMiddleware` types (`Request`, `Response`) |
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## Exports Summary
|
|
141
|
-
|
|
142
|
-
| Export | Type | Description |
|
|
143
|
-
| ----------------------- | ------------- | ------------------------------------------------------------------ |
|
|
144
|
-
| `LoggerModule` | NestJS Module | Global logging module with log-level control |
|
|
145
|
-
| `Logger` | Provider | NestJS Logger configured with `APP_LOG_LEVEL` |
|
|
146
|
-
| `ContextLogger` | Class | Structured logger enriched with request context |
|
|
147
|
-
| `RequestContextStore` | Class | AsyncLocalStorage-based per-request context (requestId, userId) |
|
|
148
|
-
| `RequestIdMiddleware` | Middleware | Extracts/generates `x-request-id` and wraps in context store |
|
|
149
|
-
| `IRequestContext` | Interface | Shape of the per-request context |
|
|
150
|
-
| `REQUEST_ID_HEADER` | Constant | Header name (`'x-request-id'`) |
|
|
@@ -1,470 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: platform-mailing
|
|
3
|
-
description: Multi-strategy email delivery with support for SMTP, Postmark, Resend, SendGrid, and Mailgun.
|
|
4
|
-
order: 7
|
|
5
|
-
tags: [mailing, email, smtp, postmark, resend, sendgrid, mailgun, templates, verification, strategy-pattern, health]
|
|
6
|
-
package: '@breadstone/archipel-platform-mailing'
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# platform-mailing
|
|
10
|
-
|
|
11
|
-
Multi-strategy email delivery system with pluggable transports (SMTP, Postmark, Resend, SendGrid, Mailgun, Log), template engines (file-based, blob-based), and email verification support. Each external provider SDK is an **optional peer dependency** — install only the one you need.
|
|
12
|
-
|
|
13
|
-
**Package:** `@breadstone/archipel-platform-mailing`
|
|
14
|
-
|
|
15
|
-
<InstallTabs />
|
|
16
|
-
|
|
17
|
-
## Architecture
|
|
18
|
-
|
|
19
|
-
```mermaid
|
|
20
|
-
graph TD
|
|
21
|
-
Module["MailModule"]
|
|
22
|
-
MailService["MailService<br/><i>send() / sendTemplate()</i>"]
|
|
23
|
-
Base["DeliveryStrategyBase<br/><i>Abstract send() contract</i>"]
|
|
24
|
-
|
|
25
|
-
SMTP["SmtpDeliveryStrategy<br/><i>Built-in (nodemailer)</i>"]
|
|
26
|
-
Log["LogDeliveryStrategy<br/><i>Built-in (dev)</i>"]
|
|
27
|
-
Postmark["PostmarkDeliveryStrategy<br/><i>postmark</i>"]
|
|
28
|
-
Resend["ResendDeliveryStrategy<br/><i>resend</i>"]
|
|
29
|
-
SendGrid["SendGridDeliveryStrategy<br/><i>@sendgrid/mail</i>"]
|
|
30
|
-
Mailgun["MailgunDeliveryStrategy<br/><i>mailgun.js</i>"]
|
|
31
|
-
|
|
32
|
-
Module --> MailService
|
|
33
|
-
MailService --> Base
|
|
34
|
-
SMTP -->|extends| Base
|
|
35
|
-
Log -->|extends| Base
|
|
36
|
-
Postmark -->|extends| Base
|
|
37
|
-
Resend -->|extends| Base
|
|
38
|
-
SendGrid -->|extends| Base
|
|
39
|
-
Mailgun -->|extends| Base
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Quick Start
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import { Module } from '@nestjs/common';
|
|
48
|
-
import { MailModule } from '@breadstone/archipel-platform-mailing';
|
|
49
|
-
|
|
50
|
-
@Module({
|
|
51
|
-
imports: [MailModule],
|
|
52
|
-
})
|
|
53
|
-
export class AppModule {}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
The module auto-selects delivery and template strategies based on environment variables.
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Environment Variables
|
|
61
|
-
|
|
62
|
-
### Core
|
|
63
|
-
|
|
64
|
-
| Variable | Description | Values | Required |
|
|
65
|
-
| ----------------------------- | ---------------------- | --------------------------------------------------------------------------- | -------- |
|
|
66
|
-
| `MAIL_SENDER_EMAIL` | Default "from" address | `noreply@example.com` | Yes |
|
|
67
|
-
| `MAIL_DELIVERY_STRATEGY` | Transport strategy | `'smtp'` / `'postmark'` / `'resend'` / `'sendgrid'` / `'mailgun'` / `'log'` | Yes |
|
|
68
|
-
| `MAIL_TEMPLATE_STRATEGY` | Template source | `'file'` / `'blob'` | Yes |
|
|
69
|
-
| `MAIL_TEMPLATE_ENGINE_FORMAT` | Template format | `'html'` / `'txt'` | Yes |
|
|
70
|
-
|
|
71
|
-
### SMTP (built-in)
|
|
72
|
-
|
|
73
|
-
| Variable | Description | Default | Required |
|
|
74
|
-
| -------------------- | ---------------- | ----------- | -------- |
|
|
75
|
-
| `MAIL_SMTP_HOST` | SMTP server host | `localhost` | If SMTP |
|
|
76
|
-
| `MAIL_SMTP_PORT` | SMTP server port | `587` | If SMTP |
|
|
77
|
-
| `MAIL_SMTP_SECURE` | Use TLS | `false` | No |
|
|
78
|
-
| `MAIL_SMTP_USER` | Auth username | — | If SMTP |
|
|
79
|
-
| `MAIL_SMTP_PASSWORD` | Auth password | — | If SMTP |
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Delivery Providers
|
|
84
|
-
|
|
85
|
-
### Postmark
|
|
86
|
-
|
|
87
|
-
**Subpath:** `@breadstone/archipel-platform-mailing/postmark`
|
|
88
|
-
**SDK:** `postmark` ≥ 4.0.0
|
|
89
|
-
|
|
90
|
-
| Variable | Description | Required |
|
|
91
|
-
| ----------------------- | ---------------- | -------- |
|
|
92
|
-
| `MAIL_POSTMARK_API_KEY` | Postmark API key | Yes |
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
import { PostmarkDeliveryStrategy, POSTMARK_CONFIG_ENTRIES } from '@breadstone/archipel-platform-mailing/postmark';
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Resend
|
|
99
|
-
|
|
100
|
-
**Subpath:** `@breadstone/archipel-platform-mailing/resend`
|
|
101
|
-
**SDK:** `resend` ≥ 4.0.0
|
|
102
|
-
|
|
103
|
-
| Variable | Description | Required |
|
|
104
|
-
| --------------------- | -------------- | -------- |
|
|
105
|
-
| `MAIL_RESEND_API_KEY` | Resend API key | Yes |
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
import { ResendDeliveryStrategy, RESEND_CONFIG_ENTRIES } from '@breadstone/archipel-platform-mailing/resend';
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### SendGrid
|
|
112
|
-
|
|
113
|
-
**Subpath:** `@breadstone/archipel-platform-mailing/sendgrid`
|
|
114
|
-
**SDK:** `@sendgrid/mail` ≥ 8.0.0
|
|
115
|
-
|
|
116
|
-
| Variable | Description | Required |
|
|
117
|
-
| ----------------------- | ---------------- | -------- |
|
|
118
|
-
| `MAIL_SENDGRID_API_KEY` | SendGrid API key | Yes |
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
import { SendGridDeliveryStrategy, SENDGRID_CONFIG_ENTRIES } from '@breadstone/archipel-platform-mailing/sendgrid';
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Mailgun
|
|
125
|
-
|
|
126
|
-
**Subpath:** `@breadstone/archipel-platform-mailing/mailgun`
|
|
127
|
-
**SDK:** `mailgun.js` ≥ 10.0.0
|
|
128
|
-
|
|
129
|
-
| Variable | Description | Required |
|
|
130
|
-
| ---------------------- | -------------------------------------- | -------- |
|
|
131
|
-
| `MAIL_MAILGUN_API_KEY` | Mailgun API key | Yes |
|
|
132
|
-
| `MAIL_MAILGUN_DOMAIN` | Mailgun domain (e.g. `mg.example.com`) | Yes |
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
import { MailgunDeliveryStrategy, MAILGUN_CONFIG_ENTRIES } from '@breadstone/archipel-platform-mailing/mailgun';
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Log (built-in)
|
|
139
|
-
|
|
140
|
-
Logs emails to the console. No SDK or env vars required — useful for development and testing.
|
|
141
|
-
|
|
142
|
-
### Switching Providers
|
|
143
|
-
|
|
144
|
-
Change a single environment variable — no code change needed:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
# Switch from SMTP to Resend
|
|
148
|
-
MAIL_DELIVERY_STRATEGY=resend
|
|
149
|
-
MAIL_RESEND_API_KEY=re_xxxxxxxxxxxx
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## DeliveryStrategyBase
|
|
155
|
-
|
|
156
|
-
All providers extend this abstract contract:
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
abstract class DeliveryStrategyBase {
|
|
160
|
-
abstract send(
|
|
161
|
-
from: string,
|
|
162
|
-
to: string,
|
|
163
|
-
subject: string,
|
|
164
|
-
content: string,
|
|
165
|
-
isHtml: boolean,
|
|
166
|
-
attachments?: Array<IMailAttachment>,
|
|
167
|
-
): Promise<void>;
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## Attachment Support
|
|
174
|
-
|
|
175
|
-
`MailService.send()` accepts an optional fourth parameter for file attachments:
|
|
176
|
-
|
|
177
|
-
```typescript
|
|
178
|
-
import type { IMailAttachment } from '@breadstone/archipel-platform-mailing';
|
|
179
|
-
|
|
180
|
-
const attachment: IMailAttachment = {
|
|
181
|
-
filename: 'invoice.pdf',
|
|
182
|
-
content: pdfBuffer, // Buffer or string
|
|
183
|
-
contentType: 'application/pdf',
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
await this._mail.send(
|
|
187
|
-
{ to: 'user@example.com', subject: 'Your Invoice' },
|
|
188
|
-
'<p>Please find your invoice attached.</p>',
|
|
189
|
-
true,
|
|
190
|
-
[attachment],
|
|
191
|
-
);
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Validation
|
|
195
|
-
|
|
196
|
-
| Constraint | Detail |
|
|
197
|
-
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
198
|
-
| **MIME types** | PDF, Word (.doc/.docx), Excel (.xls/.xlsx), ZIP, PNG, JPEG, GIF, WebP, plain text, CSV |
|
|
199
|
-
| **Max size** | 25 MB per attachment |
|
|
200
|
-
| **Behavior** | Invalid MIME type or oversized attachments throw immediately — the email is **not** sent |
|
|
201
|
-
|
|
202
|
-
### IMailAttachment Interface
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
interface IMailAttachment {
|
|
206
|
-
readonly filename: string;
|
|
207
|
-
readonly content: Buffer | string;
|
|
208
|
-
readonly contentType: string;
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
---
|
|
213
|
-
|
|
214
|
-
## MailService
|
|
215
|
-
|
|
216
|
-
Core service for sending emails.
|
|
217
|
-
|
|
218
|
-
### Send Plain Email
|
|
219
|
-
|
|
220
|
-
```typescript
|
|
221
|
-
import { MailService } from '@breadstone/archipel-platform-mailing';
|
|
222
|
-
|
|
223
|
-
@Injectable()
|
|
224
|
-
export class NotificationService {
|
|
225
|
-
constructor(private readonly _mail: MailService) {}
|
|
226
|
-
|
|
227
|
-
public async sendWelcome(userEmail: string, userName: string): Promise<void> {
|
|
228
|
-
await this._mail.send(
|
|
229
|
-
{ to: userEmail, subject: `Welcome, ${userName}!` },
|
|
230
|
-
`<h1>Welcome</h1><p>Hey ${userName}, we're glad you're here.</p>`,
|
|
231
|
-
true, // isHtml
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Send Templated Email
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
await this._mail.sendTemplate(
|
|
241
|
-
{ to: userEmail, subject: 'Your Order Confirmation' },
|
|
242
|
-
{
|
|
243
|
-
templateName: 'order-confirmation',
|
|
244
|
-
templateParams: {
|
|
245
|
-
orderNumber: 'ORD-12345',
|
|
246
|
-
total: '€39.97',
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
);
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Custom Sender
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
await this._mail.send(
|
|
256
|
-
{
|
|
257
|
-
from: 'support@example.com', // overrides MAIL_SENDER_EMAIL
|
|
258
|
-
to: 'customer@example.com',
|
|
259
|
-
subject: 'Support Ticket #4567',
|
|
260
|
-
},
|
|
261
|
-
'Your ticket has been received.',
|
|
262
|
-
false, // plain text
|
|
263
|
-
);
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
## Template Strategies
|
|
269
|
-
|
|
270
|
-
### File-Based Templates
|
|
271
|
-
|
|
272
|
-
Load templates from the filesystem:
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
// Set MAIL_TEMPLATE_STRATEGY=file
|
|
276
|
-
// Templates stored as files: assets/templates/welcome.html
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### Blob-Based Templates
|
|
280
|
-
|
|
281
|
-
Load templates from blob storage (e.g., Vercel Blob):
|
|
282
|
-
|
|
283
|
-
```typescript
|
|
284
|
-
// Set MAIL_TEMPLATE_STRATEGY=blob
|
|
285
|
-
// Templates stored in blob storage: templates/welcome.html
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## SmtpConnectionVerifier
|
|
291
|
-
|
|
292
|
-
Verifies SMTP server connectivity. Replaces the deprecated `MailVerificationService`.
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
import { SmtpConnectionVerifier } from '@breadstone/archipel-platform-mailing';
|
|
296
|
-
|
|
297
|
-
@Injectable()
|
|
298
|
-
export class HealthCheckService {
|
|
299
|
-
constructor(private readonly _smtpVerifier: SmtpConnectionVerifier) {}
|
|
300
|
-
|
|
301
|
-
public async checkSmtp(): Promise<boolean> {
|
|
302
|
-
return this._smtpVerifier.verifyConnection();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
public async sendTestEmail(to: string): Promise<boolean> {
|
|
306
|
-
return this._smtpVerifier.sendTestEmail(to);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
## MailVerificationService (Deprecated)
|
|
312
|
-
|
|
313
|
-
::: warning Deprecated
|
|
314
|
-
`MailVerificationService` is deprecated. Use `SmtpConnectionVerifier` instead — it provides `verifyConnection()` for SMTP connectivity checks and `sendTestEmail()` for sending test messages.
|
|
315
|
-
:::
|
|
316
|
-
|
|
317
|
-
```typescript
|
|
318
|
-
import { MailVerificationService } from '@breadstone/archipel-platform-mailing';
|
|
319
|
-
|
|
320
|
-
@Injectable()
|
|
321
|
-
export class RegistrationService {
|
|
322
|
-
constructor(private readonly _mailVerification: MailVerificationService) {}
|
|
323
|
-
|
|
324
|
-
public async sendVerification(email: string): Promise<void> {
|
|
325
|
-
await this._mailVerification.sendVerificationEmail(email);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
---
|
|
331
|
-
|
|
332
|
-
## MailModule.register()
|
|
333
|
-
|
|
334
|
-
The `MailModule` supports a `register()` static method for explicit module configuration:
|
|
335
|
-
|
|
336
|
-
```typescript
|
|
337
|
-
import { MailModule } from '@breadstone/archipel-platform-mailing';
|
|
338
|
-
|
|
339
|
-
@Module({
|
|
340
|
-
imports: [
|
|
341
|
-
MailModule.register({
|
|
342
|
-
configEntries: MY_CUSTOM_CONFIG_ENTRIES, // optional
|
|
343
|
-
isGlobal: true, // optional, default: false
|
|
344
|
-
}),
|
|
345
|
-
],
|
|
346
|
-
})
|
|
347
|
-
export class AppModule {}
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
---
|
|
351
|
-
|
|
352
|
-
## Health Check
|
|
353
|
-
|
|
354
|
-
The `MailHealthIndicator` validates that the required mail configuration values (`MAIL_HOST`, `MAIL_USER`, `MAIL_PORT`) are present and non-empty. Import it from the `/health` subpath:
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
import { MailHealthIndicator } from '@breadstone/archipel-platform-mailing/health';
|
|
358
|
-
import { HealthModule } from '@breadstone/archipel-platform-health';
|
|
359
|
-
|
|
360
|
-
@Module({
|
|
361
|
-
imports: [
|
|
362
|
-
MailModule.register({ /* ... */ }),
|
|
363
|
-
HealthModule.withIndicators([MailHealthIndicator]),
|
|
364
|
-
],
|
|
365
|
-
})
|
|
366
|
-
export class AppModule {}
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
| Key | Check | Dependencies |
|
|
370
|
-
| --- | ----- | ------------ |
|
|
371
|
-
| `mail` | Validates mail host, user, and port config | `ConfigService` |
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## Real-World Example: Transactional Email Pipeline
|
|
376
|
-
|
|
377
|
-
```typescript
|
|
378
|
-
@Injectable()
|
|
379
|
-
export class OrderEmailService {
|
|
380
|
-
constructor(
|
|
381
|
-
private readonly _mail: MailService,
|
|
382
|
-
private readonly _analytics: AnalyticsService,
|
|
383
|
-
) {}
|
|
384
|
-
|
|
385
|
-
public async sendOrderConfirmation(order: IOrder): Promise<void> {
|
|
386
|
-
try {
|
|
387
|
-
await this._mail.sendTemplate(
|
|
388
|
-
{
|
|
389
|
-
to: order.customerEmail,
|
|
390
|
-
subject: `Order ${order.number} Confirmed`,
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
templateName: 'order-confirmation',
|
|
394
|
-
templateParams: {
|
|
395
|
-
customerName: order.customerName,
|
|
396
|
-
orderNumber: order.number,
|
|
397
|
-
total: `€${order.total.toFixed(2)}`,
|
|
398
|
-
deliveryDate: order.estimatedDelivery.toLocaleDateString('de-DE'),
|
|
399
|
-
},
|
|
400
|
-
},
|
|
401
|
-
);
|
|
402
|
-
} catch (error) {
|
|
403
|
-
this._analytics.captureException(error, {
|
|
404
|
-
tags: { module: 'mailing', orderId: order.id },
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
---
|
|
412
|
-
|
|
413
|
-
## Error Handling
|
|
414
|
-
|
|
415
|
-
All delivery strategies throw a `MailDeliveryError` when email sending fails. This domain error class wraps the underlying provider SDK error and exposes structured metadata for error handling and observability.
|
|
416
|
-
|
|
417
|
-
```typescript
|
|
418
|
-
import { MailDeliveryError } from '@breadstone/archipel-platform-mailing';
|
|
419
|
-
|
|
420
|
-
try {
|
|
421
|
-
await this._mail.send(options, content, true);
|
|
422
|
-
} catch (error) {
|
|
423
|
-
if (error instanceof MailDeliveryError) {
|
|
424
|
-
logger.error('Mail delivery failed', {
|
|
425
|
-
provider: error.provider, // 'postmark', 'resend', 'sendgrid', etc.
|
|
426
|
-
code: error.code, // 'MAIL_DELIVERY'
|
|
427
|
-
cause: error.cause, // Original provider SDK error
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
| Property | Type | Description |
|
|
434
|
-
| ---------- | -------- | ---------------------------------------------- |
|
|
435
|
-
| `code` | `string` | Always `'MAIL_DELIVERY'` |
|
|
436
|
-
| `provider` | `string` | Provider that failed (`smtp`, `postmark`, etc.) |
|
|
437
|
-
| `cause` | `unknown`| Original error from the provider SDK |
|
|
438
|
-
|
|
439
|
-
---
|
|
440
|
-
|
|
441
|
-
## Exports Summary
|
|
442
|
-
|
|
443
|
-
### Core (`@breadstone/archipel-platform-mailing`)
|
|
444
|
-
|
|
445
|
-
| Export | Type | Description |
|
|
446
|
-
| --------------------------- | -------------- | ------------------------------- |
|
|
447
|
-
| `MailModule` | NestJS Module | Global mail module |
|
|
448
|
-
| `MailService` | Service | Send emails (plain + templated) |
|
|
449
|
-
| `SmtpConnectionVerifier` | Service | SMTP connectivity verification |
|
|
450
|
-
| `MailVerificationService` | Service | ~~Email verification~~ (deprecated — use `SmtpConnectionVerifier`) |
|
|
451
|
-
| `MailTemplateEngine` | Service | Template variable substitution |
|
|
452
|
-
| `DeliveryStrategyBase` | Abstract class | Base for delivery strategies |
|
|
453
|
-
| `SmtpDeliveryStrategy` | Strategy | SMTP transport (built-in) |
|
|
454
|
-
| `LogDeliveryStrategy` | Strategy | Log-only (built-in) |
|
|
455
|
-
| `ResendDeliveryStrategy` | Strategy | Resend API |
|
|
456
|
-
| `SendGridDeliveryStrategy` | Strategy | SendGrid API |
|
|
457
|
-
| `MailgunDeliveryStrategy` | Strategy | Mailgun API |
|
|
458
|
-
| `FileTemplateFetchStrategy` | Strategy | File-based templates |
|
|
459
|
-
| `BlobTemplateFetchStrategy` | Strategy | Blob-stored templates |
|
|
460
|
-
| `MailHealthIndicator` | Health | Mail readiness check (`/health` subpath) |
|
|
461
|
-
| `MailDeliveryError` | Error class | Domain error for delivery failures |
|
|
462
|
-
|
|
463
|
-
### Provider subpaths
|
|
464
|
-
|
|
465
|
-
| Subpath | Exports |
|
|
466
|
-
| ----------- | ---------------------------------------------------------------------------------------- |
|
|
467
|
-
| `/postmark` | `PostmarkDeliveryStrategy`, `POSTMARK_API_KEY`, `POSTMARK_CONFIG_ENTRIES` |
|
|
468
|
-
| `/resend` | `ResendDeliveryStrategy`, `RESEND_API_KEY`, `RESEND_CONFIG_ENTRIES` |
|
|
469
|
-
| `/sendgrid` | `SendGridDeliveryStrategy`, `SENDGRID_API_KEY`, `SENDGRID_CONFIG_ENTRIES` |
|
|
470
|
-
| `/mailgun` | `MailgunDeliveryStrategy`, `MAILGUN_API_KEY`, `MAILGUN_DOMAIN`, `MAILGUN_CONFIG_ENTRIES` |
|