@breadstone/archipel-mcp 0.0.54 → 0.0.56
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 +101 -0
- package/data/guides/ai-realtime-voice.md +85 -473
- package/data/guides/ai-text-generation.md +98 -635
- package/data/guides/health-indicators.md +67 -66
- package/data/guides/index.md +2 -1
- package/data/guides/intelligence-prompts-warm-up.md +81 -312
- package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +122 -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 +15 -10
- package/data/packages/platform-intelligence/api/Class.IntelligenceImageGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +159 -0
- 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.IntelligencePromptPolicyPort.md +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAdapterPort.md +104 -0
- 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.IntelligenceRealtimeMeteringPort.md +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +8 -8
- 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.IntelligenceSpeechGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +14 -16
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +14 -18
- package/data/packages/platform-intelligence/api/Class.IntelligenceTranscriptionGenerator.md +139 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceVideoGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.MiMoIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +122 -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 +140 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +130 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +118 -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 +186 -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 +250 -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 +72 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +54 -26
- 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.IIntelligenceProviderConfiguration.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +54 -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 +23 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +174 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +156 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +110 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +80 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +180 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +155 -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 +130 -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 +197 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +245 -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 +2 -2
- package/data/packages/platform-intelligence/api/index.md +83 -32
- package/data/packages/platform-intelligence/index.md +81 -622
- 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.IntelligenceMediaGenerator.md +0 -118
- 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-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,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` |
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: platform-mapping
|
|
3
|
-
description: Type-safe object-to-object mapping framework with profile-based configuration.
|
|
4
|
-
order: 2
|
|
5
|
-
tags: [mapping, dto, profiles, type-safe]
|
|
6
|
-
package: '@breadstone/archipel-platform-mapping'
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# platform-mapping
|
|
10
|
-
|
|
11
|
-
Type-safe object-to-object mapping framework for transforming domain entities into response DTOs. Extracted from `platform-core` to provide a focused, independently versionable mapping module.
|
|
12
|
-
|
|
13
|
-
**Package:** `@breadstone/archipel-platform-mapping`
|
|
14
|
-
|
|
15
|
-
<InstallTabs />
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import {
|
|
21
|
-
MappingModule,
|
|
22
|
-
MappingService,
|
|
23
|
-
MappingProfileBase,
|
|
24
|
-
MappingKey,
|
|
25
|
-
MappingError,
|
|
26
|
-
MappingNotRegisteredError,
|
|
27
|
-
TypeMappingNotRegisteredError,
|
|
28
|
-
} from '@breadstone/archipel-platform-mapping';
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Defining Mapping Keys
|
|
34
|
-
|
|
35
|
-
Mapping keys are branded constants that provide compile-time safety for source → destination pairs:
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
import { MappingKey } from '@breadstone/archipel-platform-mapping';
|
|
39
|
-
import type { IUserEntity } from './entities';
|
|
40
|
-
import type { UserResponse } from './responses';
|
|
41
|
-
|
|
42
|
-
export const USER_TO_RESPONSE = new MappingKey<IUserEntity, UserResponse>('UserEntity→UserResponse');
|
|
43
|
-
export const USER_TO_SUMMARY = new MappingKey<IUserEntity, UserSummary>('UserEntity→UserSummary');
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Creating a Mapping Profile
|
|
47
|
-
|
|
48
|
-
Profiles group related mappings into cohesive, injectable classes:
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import { Injectable } from '@nestjs/common';
|
|
52
|
-
import { MappingProfileBase, type IMappingBuilder } from '@breadstone/archipel-platform-mapping';
|
|
53
|
-
import { USER_TO_RESPONSE, USER_TO_SUMMARY } from './mapping-keys';
|
|
54
|
-
|
|
55
|
-
@Injectable()
|
|
56
|
-
export class UserMappingProfile extends MappingProfileBase {
|
|
57
|
-
public override configure(builder: IMappingBuilder): void {
|
|
58
|
-
builder.createKeyedMap(USER_TO_RESPONSE, (source) => ({
|
|
59
|
-
id: source.id,
|
|
60
|
-
name: source.userName,
|
|
61
|
-
email: source.email,
|
|
62
|
-
verified: source.isVerified,
|
|
63
|
-
roles: [...source.roles],
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
builder.createKeyedMap(USER_TO_SUMMARY, (source) => ({
|
|
67
|
-
id: source.id,
|
|
68
|
-
displayName: source.userName ?? source.email ?? 'Anonymous',
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Registering Profiles in a Module
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
import { Module } from '@nestjs/common';
|
|
78
|
-
import { MappingModule } from '@breadstone/archipel-platform-mapping';
|
|
79
|
-
import { UserMappingProfile } from './mappers/UserMappingProfile';
|
|
80
|
-
|
|
81
|
-
@Module({
|
|
82
|
-
imports: [MappingModule.withProfiles([UserMappingProfile])],
|
|
83
|
-
})
|
|
84
|
-
export class AppModule {}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Using in a Controller
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
import { Controller, Get, Param } from '@nestjs/common';
|
|
91
|
-
import { MappingService } from '@breadstone/archipel-platform-mapping';
|
|
92
|
-
import { USER_TO_RESPONSE } from './mapping-keys';
|
|
93
|
-
|
|
94
|
-
@Controller('users')
|
|
95
|
-
export class UserController {
|
|
96
|
-
constructor(
|
|
97
|
-
private readonly _userService: UserService,
|
|
98
|
-
private readonly _mappingService: MappingService,
|
|
99
|
-
) {}
|
|
100
|
-
|
|
101
|
-
@Get(':id')
|
|
102
|
-
public async getUser(@Param('id') id: string): Promise<UserResponse> {
|
|
103
|
-
const entity = await this._userService.findById(id);
|
|
104
|
-
return this._mappingService.map(USER_TO_RESPONSE, entity);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Error Classes
|
|
112
|
-
|
|
113
|
-
| Error | Description |
|
|
114
|
-
| ------------------------------ | ----------------------------------------------- |
|
|
115
|
-
| `MappingError` | Base error for all mapping failures |
|
|
116
|
-
| `MappingNotRegisteredError` | Thrown when a mapping key has no registered map |
|
|
117
|
-
| `TypeMappingNotRegisteredError`| Thrown when a type-based mapping is not found |
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## API Reference
|
|
122
|
-
|
|
123
|
-
The auto-generated API reference is published when API docs are generated for this package.
|