@breadstone/archipel-mcp 0.0.20 → 0.0.22
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-text-generation.md +10 -0
- package/data/guides/analytics-and-error-tracking.md +6 -0
- package/data/guides/cryptography-and-otp.md +20 -2
- package/data/guides/database-setup.md +4 -3
- package/data/guides/document-generation.md +26 -0
- package/data/guides/email-delivery.md +23 -0
- package/data/guides/email-templates.md +298 -0
- package/data/guides/esigning-integration.md +1 -1
- package/data/guides/getting-started.md +6 -6
- package/data/guides/index.md +1 -0
- package/data/guides/mcp-server.md +9 -0
- package/data/guides/payments-and-feature-gating.md +18 -0
- package/data/guides/resource-management.md +9 -9
- package/data/guides/telemetry-and-observability.md +7 -1
- package/data/packages/platform-analytics/api/Class.AppInsightsAnalyticsClient.md +55 -6
- package/data/packages/platform-analytics/api/Class.DatadogAnalyticsClient.md +32 -6
- package/data/packages/platform-analytics/api/Class.SentryAnalyticsClient.md +55 -6
- package/data/packages/platform-analytics/index.md +13 -0
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_PROVIDER_OPTIONS.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.AZURE_BLOB_PROVIDER_OPTIONS.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.BLOB_PROVIDER.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.VERCEL_BLOB_PROVIDER_OPTIONS.md +1 -1
- package/data/packages/platform-core/api/Class.ErrorTemplateService.md +1 -1
- package/data/packages/platform-core/api/Class.EventHub.md +7 -7
- package/data/packages/platform-core/api/Class.HostService.md +1 -1
- package/data/packages/platform-core/api/Class.SseHub.md +29 -6
- package/data/packages/platform-core/api/Variable.ID_GENERATOR_TOKEN.md +1 -1
- package/data/packages/platform-core/api/index.md +0 -27
- package/data/packages/platform-core/index.md +8 -4
- package/data/packages/platform-cryptography/api/Class.BcryptService.md +4 -4
- package/data/packages/platform-cryptography/api/Class.CryptoService.md +3 -3
- package/data/packages/platform-cryptography/api/Class.OtpService.md +6 -6
- package/data/packages/platform-cryptography/api/Variable.BCRYPT_OPTIONS.md +2 -2
- package/data/packages/platform-cryptography/api/Variable.MAX_BCRYPT_PASSWORD_BYTES.md +1 -1
- package/data/packages/platform-cryptography/api/Variable.MIN_BCRYPT_ROUNDS.md +1 -1
- package/data/packages/platform-cryptography/api/Variable.OTP_OPTIONS.md +2 -2
- package/data/packages/platform-cryptography/api/Variable.OTP_SERVICE_TOKEN.md +2 -2
- package/data/packages/platform-cryptography/api/Variable.TOTP_EPOCH_TOLERANCE.md +1 -1
- package/data/packages/platform-cryptography/api/index.md +3 -3
- package/data/packages/platform-cryptography/index.md +10 -0
- package/data/packages/platform-documents/api/Class.BaseDocumentRenderer.md +32 -1
- package/data/packages/platform-documents/api/Class.DocumentEngine.md +4 -4
- package/data/packages/platform-documents/api/Class.DocumentError.md +61 -0
- package/data/packages/platform-documents/api/Class.DocumentModule.md +2 -2
- package/data/packages/platform-documents/api/Class.DocumentRenderError.md +53 -0
- package/data/packages/platform-documents/api/Class.DocumentValidationError.md +52 -0
- package/data/packages/platform-documents/api/Class.DocxDocumentRenderer2.md +333 -0
- package/data/packages/platform-documents/api/Class.ImageProcessingError.md +53 -0
- package/data/packages/platform-documents/api/Class.PdfDocumentRenderer.md +355 -0
- package/data/packages/platform-documents/api/Class.SharpImageProcessor.md +5 -5
- package/data/packages/platform-documents/api/Interface.IDocumentModuleOptions.md +31 -5
- package/data/packages/platform-documents/api/Variable.DOCUMENT_MODULE_OPTIONS.md +1 -1
- package/data/packages/platform-documents/api/Variable.DOCUMENT_PARSER_TOKEN.md +1 -1
- package/data/packages/platform-documents/api/Variable.DOCUMENT_RENDERER_TOKEN.md +1 -1
- package/data/packages/platform-documents/api/Variable.IMAGE_PROCESSOR_TOKEN.md +1 -1
- package/data/packages/platform-documents/api/index.md +6 -0
- package/data/packages/platform-documents/index.md +27 -0
- package/data/packages/platform-esigning/api/Class.EsigningClientPort.md +2 -2
- package/data/packages/platform-esigning/api/Class.InternalEsigningProvider.md +8 -8
- package/data/packages/platform-esigning/index.md +2 -0
- package/data/packages/platform-health/index.md +128 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistry.md +3 -3
- package/data/packages/platform-intelligence/api/Class.IntelligenceConfigurationError.md +50 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +27 -4
- package/data/packages/platform-intelligence/api/Class.IntelligenceValidationError.md +50 -0
- package/data/packages/platform-intelligence/api/Function.loadProviderFactory.md +1 -1
- package/data/packages/platform-intelligence/api/index.md +2 -0
- package/data/packages/platform-intelligence/index.md +32 -0
- package/data/packages/platform-logging/api/Class.LoggerModule.md +1 -1
- package/data/packages/platform-logging/index.md +2 -0
- package/data/packages/platform-mailing/api/Class.DeliveryStrategyBase.md +0 -1
- package/data/packages/platform-mailing/api/Class.MailDeliveryError.md +65 -0
- package/data/packages/platform-mailing/api/Class.MailModule.md +1 -1
- package/data/packages/platform-mailing/api/Class.MailgunDeliveryStrategy.md +3 -3
- package/data/packages/platform-mailing/api/Class.PostmarkDeliveryStrategy.md +3 -3
- package/data/packages/platform-mailing/api/Class.ResendDeliveryStrategy.md +3 -3
- package/data/packages/platform-mailing/api/Class.SendGridDeliveryStrategy.md +3 -3
- package/data/packages/platform-mailing/api/Class.SmtpDeliveryStrategy.md +3 -3
- package/data/packages/platform-mailing/api/Class.TemplateFetchStrategyBase.md +0 -5
- package/data/packages/platform-mailing/api/Variable.SMTP_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-mailing/api/Variable.SMTP_HOST.md +14 -0
- package/data/packages/platform-mailing/api/Variable.SMTP_PASSWORD.md +14 -0
- package/data/packages/platform-mailing/api/Variable.SMTP_PORT.md +14 -0
- package/data/packages/platform-mailing/api/Variable.SMTP_SECURE.md +14 -0
- package/data/packages/platform-mailing/api/Variable.SMTP_USER.md +14 -0
- package/data/packages/platform-mailing/api/index.md +7 -3
- package/data/packages/platform-mailing/index.md +29 -0
- package/data/packages/platform-mapping/index.md +121 -0
- package/data/packages/platform-mcp/api/Class.McpServerService.md +8 -8
- package/data/packages/platform-mcp/api/Variable.MCP_MODULE_OPTIONS.md +1 -1
- package/data/packages/platform-mcp/index.md +11 -0
- package/data/packages/platform-openapi/api/Class.SwaggerMultiDocumentService.md +4 -4
- package/data/packages/platform-openapi/api/Class.SwaggerTheme.md +2 -2
- package/data/packages/platform-openapi/index.md +1 -1
- package/data/packages/platform-payments/api/Class.LemonSqueezyClient.md +6 -6
- package/data/packages/platform-payments/api/Class.MollieClient.md +6 -6
- package/data/packages/platform-payments/api/Class.PaddleClient.md +6 -6
- package/data/packages/platform-payments/api/Class.PaymentError.md +65 -0
- package/data/packages/platform-payments/api/Class.StripeClient.md +6 -6
- package/data/packages/platform-payments/api/index.md +1 -0
- package/data/packages/platform-payments/index.md +29 -0
- package/data/packages/platform-reporting/api/Class.ReportingContributorRegistry.md +1 -1
- package/data/packages/platform-reporting/index.md +3 -1
- package/data/packages/platform-resources/index.md +135 -0
- package/data/packages/platform-telemetry/api/Class.MetricsService.md +29 -3
- package/data/packages/platform-telemetry/api/Class.OtelSdkHolder.md +3 -2
- package/data/packages/platform-telemetry/api/Class.TelemetryLoggerService.md +6 -6
- package/data/packages/platform-telemetry/api/Class.TelemetryRuleEngine.md +3 -3
- package/data/packages/platform-telemetry/api/Variable.TELEMETRY_ENABLED.md +1 -1
- package/data/packages/platform-telemetry/api/Variable.TELEMETRY_FACADE.md +1 -1
- package/data/packages/platform-telemetry/api/Variable.TELEMETRY_OPTIONS.md +1 -1
- package/data/packages/platform-telemetry/api/index.md +1 -1
- package/data/packages/platform-telemetry/index.md +3 -1
- package/{src/knowledge/configPattern.js → data/patterns/config-pattern.md} +44 -47
- package/{src/knowledge/dtoPattern.js → data/patterns/dto-pattern.md} +58 -61
- package/{src/knowledge/errorHandlingPattern.js → data/patterns/error-handling-pattern.md} +35 -38
- package/{src/knowledge/guardPattern.js → data/patterns/guard-pattern.md} +35 -38
- package/{src/knowledge/mappingPattern.js → data/patterns/mapping-pattern.md} +43 -144
- package/data/patterns/module-pattern.md +182 -0
- package/data/patterns/query-pattern.md +137 -0
- package/data/patterns/repository-pattern.md +208 -0
- package/{src/knowledge/testingPattern.js → data/patterns/testing-pattern.md} +37 -40
- package/package.json +1 -1
- package/src/PatternsLoader.d.ts +12 -0
- package/src/PatternsLoader.js +65 -0
- package/src/generators/mappingPatternGenerator.d.ts +5 -0
- package/src/generators/mappingPatternGenerator.js +107 -0
- package/src/generators/modulePatternGenerator.d.ts +5 -0
- package/src/generators/modulePatternGenerator.js +107 -0
- package/src/generators/queryPatternGenerator.d.ts +4 -0
- package/src/generators/queryPatternGenerator.js +83 -0
- package/src/generators/repositoryPatternGenerator.d.ts +5 -0
- package/src/generators/repositoryPatternGenerator.js +165 -0
- package/src/main.js +15 -9
- package/src/models/IPatternDoc.d.ts +15 -0
- package/src/models/IPatternDoc.js +3 -0
- package/src/tools/registerGetConfigPatternTool.d.ts +2 -1
- package/src/tools/registerGetConfigPatternTool.js +4 -3
- package/src/tools/registerGetDtoPatternTool.d.ts +2 -1
- package/src/tools/registerGetDtoPatternTool.js +4 -3
- package/src/tools/registerGetErrorHandlingPatternTool.d.ts +2 -1
- package/src/tools/registerGetErrorHandlingPatternTool.js +4 -3
- package/src/tools/registerGetGuardPatternTool.d.ts +2 -1
- package/src/tools/registerGetGuardPatternTool.js +4 -3
- package/src/tools/registerGetMappingPatternTool.d.ts +2 -1
- package/src/tools/registerGetMappingPatternTool.js +5 -4
- package/src/tools/registerGetModulePatternTool.d.ts +2 -1
- package/src/tools/registerGetModulePatternTool.js +5 -4
- package/src/tools/registerGetQueryPatternTool.d.ts +2 -1
- package/src/tools/registerGetQueryPatternTool.js +5 -4
- package/src/tools/registerGetRepositoryPatternTool.d.ts +2 -1
- package/src/tools/registerGetRepositoryPatternTool.js +5 -4
- package/src/tools/registerGetTestingPatternTool.d.ts +2 -1
- package/src/tools/registerGetTestingPatternTool.js +4 -3
- package/data/packages/platform-core/api/Class.BlobResourceStrategy.md +0 -195
- package/data/packages/platform-core/api/Class.EmbeddedResourceStrategy.md +0 -215
- package/data/packages/platform-core/api/Class.FileResourceStrategy.md +0 -192
- package/data/packages/platform-core/api/Class.HealthModule.md +0 -42
- package/data/packages/platform-core/api/Class.HealthOrchestrator.md +0 -64
- package/data/packages/platform-core/api/Class.MappingBuilder.md +0 -110
- package/data/packages/platform-core/api/Class.MappingModule.md +0 -46
- package/data/packages/platform-core/api/Class.MappingNotRegisteredError.md +0 -56
- package/data/packages/platform-core/api/Class.MappingProfileBase.md +0 -52
- package/data/packages/platform-core/api/Class.MappingService.md +0 -284
- package/data/packages/platform-core/api/Class.ResourceManager.md +0 -565
- package/data/packages/platform-core/api/Class.ResourceModule.md +0 -46
- package/data/packages/platform-core/api/Class.TypeMappingNotRegisteredError.md +0 -57
- package/data/packages/platform-core/api/Function.createMappingKey.md +0 -39
- package/data/packages/platform-core/api/Interface.IBlobResourceStrategyConfig.md +0 -28
- package/data/packages/platform-core/api/Interface.IBlobServiceAdapter.md +0 -40
- package/data/packages/platform-core/api/Interface.IFileResourceStrategyConfig.md +0 -72
- package/data/packages/platform-core/api/Interface.IHealthCheckResult.md +0 -46
- package/data/packages/platform-core/api/Interface.IHealthIndicator.md +0 -41
- package/data/packages/platform-core/api/Interface.IMappingBuilder.md +0 -76
- package/data/packages/platform-core/api/Interface.IMappingKey.md +0 -58
- package/data/packages/platform-core/api/Interface.IMappingProfile.md +0 -32
- package/data/packages/platform-core/api/Interface.IResourceManagerConfig.md +0 -89
- package/data/packages/platform-core/api/Interface.IResourceMetadata.md +0 -94
- package/data/packages/platform-core/api/Interface.IResourceResult.md +0 -34
- package/data/packages/platform-core/api/Interface.IResourceStrategy.md +0 -134
- package/data/packages/platform-core/api/Variable.HEALTH_INDICATORS_TOKEN.md +0 -14
- package/data/packages/platform-mailing/api/Class.BlobTemplateFetchStrategy.md +0 -60
- package/data/packages/platform-mailing/api/Class.FileTemplateFetchStrategy.md +0 -58
- package/data/packages/platform-mailing/api/Class.LogDeliveryStrategy.md +0 -71
- package/src/knowledge/configPattern.d.ts +0 -5
- package/src/knowledge/dtoPattern.d.ts +0 -5
- package/src/knowledge/errorHandlingPattern.d.ts +0 -5
- package/src/knowledge/guardPattern.d.ts +0 -5
- package/src/knowledge/mappingPattern.d.ts +0 -6
- package/src/knowledge/modulePattern.d.ts +0 -6
- package/src/knowledge/modulePattern.js +0 -283
- package/src/knowledge/queryPattern.d.ts +0 -6
- package/src/knowledge/queryPattern.js +0 -215
- package/src/knowledge/repositoryPattern.d.ts +0 -6
- package/src/knowledge/repositoryPattern.js +0 -367
- package/src/knowledge/testingPattern.d.ts +0 -5
|
@@ -299,6 +299,8 @@ export class ChatOrchestrator {
|
|
|
299
299
|
|
|
300
300
|
Capabilities are resolved by priority (lowest number first). If multiple capabilities can handle the same intent, the one with the highest priority (lowest value) wins.
|
|
301
301
|
|
|
302
|
+
> **Capacity limit:** The registry enforces a maximum of **500** registered capabilities. Attempts to exceed this limit are logged as warnings and silently ignored.
|
|
303
|
+
|
|
302
304
|
---
|
|
303
305
|
|
|
304
306
|
## Inspecting Configuration
|
|
@@ -317,6 +319,14 @@ console.log(config.model); // 'gpt-4o-mini'
|
|
|
317
319
|
|
|
318
320
|
`IntelligenceTextGenerator` wraps all provider errors in `IntelligenceProviderError`, which includes `provider`, `model`, and `retryable` metadata. The generator automatically retries retryable failures (e.g. transient network errors) with exponential backoff before giving up.
|
|
319
321
|
|
|
322
|
+
Two additional error classes handle configuration and validation failures:
|
|
323
|
+
|
|
324
|
+
| Error class | Code | When thrown |
|
|
325
|
+
| ---------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
|
|
326
|
+
| `IntelligenceProviderError` | `INTELLIGENCE_PROVIDER` | Provider SDK failures during text generation |
|
|
327
|
+
| `IntelligenceValidationError` | `INTELLIGENCE_VALIDATION` | Invalid generation parameters (temperature, topP, maxOutputTokens) |
|
|
328
|
+
| `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing SDK package |
|
|
329
|
+
|
|
320
330
|
### Timeout & Retry Defaults
|
|
321
331
|
|
|
322
332
|
| Setting | Default | Description |
|
|
@@ -174,6 +174,12 @@ this._analytics.addBreadcrumb({
|
|
|
174
174
|
|
|
175
175
|
---
|
|
176
176
|
|
|
177
|
+
## Lifecycle
|
|
178
|
+
|
|
179
|
+
All built-in analytics clients (Sentry, Application Insights, Datadog) implement `OnModuleInit` and `OnModuleDestroy`. SDK initialization happens at module startup, and pending events are flushed with a 5-second timeout on shutdown. No manual cleanup is needed.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
177
183
|
## Development Tips
|
|
178
184
|
|
|
179
185
|
- Use the **Noop** provider during local development and testing to avoid sending events to production analytics.
|
|
@@ -105,7 +105,7 @@ The prefix is required and must be a non-empty string. Use short, descriptive pr
|
|
|
105
105
|
|
|
106
106
|
```typescript
|
|
107
107
|
import { Module } from '@nestjs/common';
|
|
108
|
-
import { OtpService, OTP_SERVICE_TOKEN } from '@breadstone/archipel-platform-cryptography';
|
|
108
|
+
import { OtpService, OTP_SERVICE_TOKEN } from '@breadstone/archipel-platform-cryptography/otp';
|
|
109
109
|
|
|
110
110
|
@Module({
|
|
111
111
|
providers: [
|
|
@@ -125,7 +125,7 @@ Generate a secret and a QR code URI for the user's authenticator app:
|
|
|
125
125
|
|
|
126
126
|
```typescript
|
|
127
127
|
import { Inject, Injectable } from '@nestjs/common';
|
|
128
|
-
import { OTP_SERVICE_TOKEN, type IOtpService } from '@breadstone/archipel-platform-cryptography';
|
|
128
|
+
import { OTP_SERVICE_TOKEN, type IOtpService } from '@breadstone/archipel-platform-cryptography/otp';
|
|
129
129
|
|
|
130
130
|
@Injectable()
|
|
131
131
|
export class MfaService {
|
|
@@ -228,6 +228,24 @@ export class AuthService {
|
|
|
228
228
|
|
|
229
229
|
---
|
|
230
230
|
|
|
231
|
+
## Error Handling
|
|
232
|
+
|
|
233
|
+
`CryptoService` throws a `CryptoValidationError` for invalid inputs such as empty UUID prefixes:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { CryptoValidationError } from '@breadstone/archipel-platform-cryptography';
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
crypto.getRandomGuid('');
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (error instanceof CryptoValidationError) {
|
|
242
|
+
// error.code → 'CRYPTO_VALIDATION'
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
231
249
|
## Security Best Practices
|
|
232
250
|
|
|
233
251
|
| Practice | Why |
|
|
@@ -362,7 +362,7 @@ const result = await this._db.transactionCallback(async (tx) => {
|
|
|
362
362
|
|
|
363
363
|
## Health Checks
|
|
364
364
|
|
|
365
|
-
`DatabaseModule` automatically registers a `DatabaseHealthIndicator` with the health orchestrator from `platform-
|
|
365
|
+
`DatabaseModule` automatically registers a `DatabaseHealthIndicator` with the health orchestrator from `platform-health`. Once your application exposes a `/health` endpoint, database connectivity is checked via a `SELECT 1` ping. No additional configuration is needed.
|
|
366
366
|
|
|
367
367
|
If the health check fails, the indicator reports `database: down` with the error details.
|
|
368
368
|
|
|
@@ -484,7 +484,7 @@ export class UserService {
|
|
|
484
484
|
// src/users/UserController.ts
|
|
485
485
|
import { Controller, Get, Param, NotFoundException } from '@nestjs/common';
|
|
486
486
|
import { UserService } from './UserService';
|
|
487
|
-
import { MappingService } from '@breadstone/archipel-platform-
|
|
487
|
+
import { MappingService } from '@breadstone/archipel-platform-mapping';
|
|
488
488
|
import { USER_TO_RESPONSE } from './mapping-keys';
|
|
489
489
|
|
|
490
490
|
@Controller('users')
|
|
@@ -514,7 +514,8 @@ And the root module wiring everything together:
|
|
|
514
514
|
```typescript
|
|
515
515
|
// src/app.module.ts
|
|
516
516
|
import { Module } from '@nestjs/common';
|
|
517
|
-
import { ConfigModule
|
|
517
|
+
import { ConfigModule } from '@breadstone/archipel-platform-configuration';
|
|
518
|
+
import { MappingModule } from '@breadstone/archipel-platform-mapping';
|
|
518
519
|
import { DatabaseModule, PLATFORM_DATABASE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-database';
|
|
519
520
|
import { UserModule } from './users/UserModule';
|
|
520
521
|
|
|
@@ -168,6 +168,32 @@ This logs each step of the rendering process: template loading, placeholder pars
|
|
|
168
168
|
|
|
169
169
|
---
|
|
170
170
|
|
|
171
|
+
## Error Handling
|
|
172
|
+
|
|
173
|
+
The document library throws typed domain errors for different failure scenarios:
|
|
174
|
+
|
|
175
|
+
| Error class | When thrown |
|
|
176
|
+
| -------------------------- | ------------------------------------------------- |
|
|
177
|
+
| `DocumentRenderError` | Template rendering failures (DOCX, PDF) |
|
|
178
|
+
| `DocumentValidationError` | Invalid templates, missing placeholders |
|
|
179
|
+
| `ImageProcessingError` | Image resize/conversion failures |
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { DocumentRenderError } from '@breadstone/archipel-platform-documents';
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const result = await this._engine.render(template, data);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error instanceof DocumentRenderError) {
|
|
188
|
+
// Handle render failure
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
All errors extend `DocumentError` — catch the base class for a blanket handler.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
171
197
|
## Next Steps
|
|
172
198
|
|
|
173
199
|
- See the [Blob Storage](/guides/blob-storage) guide for storing generated documents
|
|
@@ -207,6 +207,28 @@ await this._mailService.send(
|
|
|
207
207
|
|
|
208
208
|
---
|
|
209
209
|
|
|
210
|
+
## Error Handling
|
|
211
|
+
|
|
212
|
+
All delivery strategies throw a `MailDeliveryError` when email sending fails. The error wraps the underlying provider error and identifies which provider failed:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { MailDeliveryError } from '@breadstone/archipel-platform-mailing';
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
await this._mail.send(options, content, true);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
if (error instanceof MailDeliveryError) {
|
|
221
|
+
// error.provider → 'postmark', 'smtp', 'resend', 'sendgrid', 'mailgun'
|
|
222
|
+
// error.code → 'MAIL_DELIVERY'
|
|
223
|
+
// error.cause → Original provider SDK error
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Map `MailDeliveryError` to an appropriate HTTP response in your global exception filter. The `provider` property helps with targeted alerting and retry decisions.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
210
232
|
## Security
|
|
211
233
|
|
|
212
234
|
`MailService` applies automatic sanitization to the email subject to prevent SMTP header injection attacks. Any carriage-return (`\r`) or line-feed (`\n`) characters found in the subject string are replaced with a space before the message is handed to the delivery strategy. This protection runs transparently on every `send` call.
|
|
@@ -229,5 +251,6 @@ await this._mailService.send(
|
|
|
229
251
|
|
|
230
252
|
## Next Steps
|
|
231
253
|
|
|
254
|
+
- See the [Email Templates](/guides/email-templates) guide for creating, registering, and overriding email templates with ResourceManager
|
|
232
255
|
- See the [Authentication & Authorization](/guides/authentication-and-authorization) guide for integrating email verification into the login flow
|
|
233
256
|
- Browse the [platform-mailing API reference](/packages/platform-mailing/api/) for complete method signatures
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Email Templates
|
|
3
|
+
description: Create, register, and override email templates using the ResourceManager from platform-resources and the template engine from platform-mailing.
|
|
4
|
+
order: 8
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Email Templates
|
|
8
|
+
|
|
9
|
+
This guide explains how to create email templates for `platform-mailing` and register them with `ResourceManager` from `platform-resources`. It covers the template syntax, the built-in template names, how to provide your own HTML/TXT files, and how to override library defaults.
|
|
10
|
+
|
|
11
|
+
> **Prerequisite:** You should be familiar with [Email Delivery](/guides/email-delivery) for general mail setup and [Resource Management](/guides/resource-management) for how `ResourceManager` strategies work.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## How It Works
|
|
16
|
+
|
|
17
|
+
`platform-mailing` does **not** ship ready-made template files. It defines a list of known template **names** and loads the actual content through `ResourceManager` at startup.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌──────────────┐ ┌─────────────────────────┐ ┌──────────────────┐
|
|
21
|
+
│ MailService │────▶│ MailTemplateEngine │────▶│ ResourceManager │
|
|
22
|
+
│ sendTemplate()│ │ compileTemplate() │ │ tryLoadAsync() │
|
|
23
|
+
└──────────────┘ └─────────────────────────┘ └──────────────────┘
|
|
24
|
+
│ │
|
|
25
|
+
▼ ▼
|
|
26
|
+
ContentTemplateEngine FileResourceStrategy
|
|
27
|
+
(variable interpolation) BlobResourceStrategy
|
|
28
|
+
EmbeddedResourceStrategy
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
1. `MailService.sendTemplate()` passes the template name and context variables to `MailTemplateEngine`.
|
|
32
|
+
2. `MailTemplateEngine` looks up the pre-loaded template content by name and format (`.html` or `.txt`).
|
|
33
|
+
3. `ContentTemplateEngine` from `platform-core` interpolates `{{placeholders}}` with the provided context.
|
|
34
|
+
4. The compiled string is handed to the configured delivery strategy (SMTP, Resend, Postmark, etc.).
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Built-In Template Names
|
|
39
|
+
|
|
40
|
+
`FileTemplateFetchStrategy` expects these template names. For each name, both `.html` and `.txt` variants are loaded (if available):
|
|
41
|
+
|
|
42
|
+
| Template Name | Purpose |
|
|
43
|
+
| ------------------------ | ------------------------------------------------- |
|
|
44
|
+
| `AuthRegister` | Welcome email sent after user registration |
|
|
45
|
+
| `AuthVerify` | Email address verification with token/link |
|
|
46
|
+
| `AuthForgotPassword` | Password reset email with token/link |
|
|
47
|
+
| `AppointmentInvitation` | Invitation to an appointment or event |
|
|
48
|
+
| `AppointmentUpdate` | Notification about an appointment change |
|
|
49
|
+
|
|
50
|
+
The strategy loads `AuthRegister.html`, `AuthRegister.txt`, `AuthVerify.html`, etc. Missing variants are silently skipped — you can provide only `.html` if you don't need plain-text fallbacks.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Creating Template Files
|
|
55
|
+
|
|
56
|
+
### Template Syntax
|
|
57
|
+
|
|
58
|
+
Templates use a Handlebars-style syntax powered by `ContentTemplateEngine`:
|
|
59
|
+
|
|
60
|
+
| Syntax | Description |
|
|
61
|
+
| ---------------------------------------------- | --------------------------------- |
|
|
62
|
+
| `{{variableName}}` | Simple variable substitution |
|
|
63
|
+
| `{{#if condition}}...{{/if}}` | Conditional block |
|
|
64
|
+
| `{{#if condition}}...{{else}}...{{/if}}` | Conditional with else |
|
|
65
|
+
| `{{#unless condition}}...{{/unless}}` | Negative conditional |
|
|
66
|
+
| `{{#each items}}...{{/each}}` | Loop over array |
|
|
67
|
+
| `{{#with object}}...{{/with}}` | Context switching |
|
|
68
|
+
| `{{@index}}`, `{{@first}}`, `{{@last}}` | Loop metadata inside `#each` |
|
|
69
|
+
| `{{nested.property}}` | Dot notation for nested values |
|
|
70
|
+
|
|
71
|
+
### Example: `AuthVerify.html`
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<!DOCTYPE html>
|
|
75
|
+
<html>
|
|
76
|
+
<head>
|
|
77
|
+
<meta charset="utf-8" />
|
|
78
|
+
<title>Verify your email</title>
|
|
79
|
+
</head>
|
|
80
|
+
<body>
|
|
81
|
+
<h1>Hello, {{userName}}!</h1>
|
|
82
|
+
<p>Please verify your email address by clicking the link below:</p>
|
|
83
|
+
<p>
|
|
84
|
+
<a href="{{verificationUrl}}">Verify Email</a>
|
|
85
|
+
</p>
|
|
86
|
+
{{#if expiresInHours}}
|
|
87
|
+
<p>This link expires in {{expiresInHours}} hours.</p>
|
|
88
|
+
{{/if}}
|
|
89
|
+
<p>If you did not create an account, you can safely ignore this email.</p>
|
|
90
|
+
</body>
|
|
91
|
+
</html>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Example: `AuthVerify.txt`
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
Hello, {{userName}}!
|
|
98
|
+
|
|
99
|
+
Please verify your email address by visiting the following link:
|
|
100
|
+
|
|
101
|
+
{{verificationUrl}}
|
|
102
|
+
|
|
103
|
+
{{#if expiresInHours}}This link expires in {{expiresInHours}} hours.{{/if}}
|
|
104
|
+
|
|
105
|
+
If you did not create an account, you can safely ignore this email.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Security
|
|
109
|
+
|
|
110
|
+
When the format is `html`, `MailTemplateEngine` automatically **escapes all context values** (`&`, `<`, `>`, `"`, `'`) before interpolation to prevent XSS in email clients. Plain-text templates (`txt`) are not escaped.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Registering Templates with ResourceManager
|
|
115
|
+
|
|
116
|
+
### File-Based Templates (Recommended)
|
|
117
|
+
|
|
118
|
+
Place your template files in your application's assets directory and register the path with `ResourceModule`:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
my-app/
|
|
122
|
+
├── src/
|
|
123
|
+
│ ├── assets/
|
|
124
|
+
│ │ ├── AuthRegister.html
|
|
125
|
+
│ │ ├── AuthRegister.txt
|
|
126
|
+
│ │ ├── AuthVerify.html
|
|
127
|
+
│ │ ├── AuthVerify.txt
|
|
128
|
+
│ │ ├── AuthForgotPassword.html
|
|
129
|
+
│ │ ├── AppointmentInvitation.html
|
|
130
|
+
│ │ └── AppointmentUpdate.html
|
|
131
|
+
│ └── app.module.ts
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { Module } from '@nestjs/common';
|
|
136
|
+
import { join } from 'node:path';
|
|
137
|
+
import { ResourceModule, FileResourceStrategy } from '@breadstone/archipel-platform-resources';
|
|
138
|
+
import { MailModule } from '@breadstone/archipel-platform-mailing';
|
|
139
|
+
|
|
140
|
+
@Module({
|
|
141
|
+
imports: [
|
|
142
|
+
ResourceModule.forRoot({
|
|
143
|
+
strategies: [
|
|
144
|
+
new FileResourceStrategy({
|
|
145
|
+
basePaths: [
|
|
146
|
+
join(__dirname, 'assets'),
|
|
147
|
+
],
|
|
148
|
+
includeSubfolders: true,
|
|
149
|
+
}),
|
|
150
|
+
],
|
|
151
|
+
}),
|
|
152
|
+
MailModule,
|
|
153
|
+
],
|
|
154
|
+
})
|
|
155
|
+
export class AppModule {}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Set the environment variable to use the file strategy:
|
|
159
|
+
|
|
160
|
+
```env
|
|
161
|
+
MAIL_TEMPLATE_STRATEGY=file
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Blob-Based Templates
|
|
165
|
+
|
|
166
|
+
For templates managed via a CMS or shared across multiple services, use `BlobTemplateFetchStrategy`. Upload a manifest file (`templates/templates.json`) and the template files to your blob storage:
|
|
167
|
+
|
|
168
|
+
**`templates/templates.json`**
|
|
169
|
+
```json
|
|
170
|
+
[
|
|
171
|
+
"templates/AuthRegister.html",
|
|
172
|
+
"templates/AuthRegister.txt",
|
|
173
|
+
"templates/AuthVerify.html",
|
|
174
|
+
"templates/AuthVerify.txt",
|
|
175
|
+
"templates/AuthForgotPassword.html"
|
|
176
|
+
]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Set the environment variable:
|
|
180
|
+
|
|
181
|
+
```env
|
|
182
|
+
MAIL_TEMPLATE_STRATEGY=blob
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The `BlobTemplateFetchStrategy` downloads the manifest, then fetches each listed file from blob storage via `BlobService` from `platform-blob-storage`.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Overriding Library Templates
|
|
190
|
+
|
|
191
|
+
If a library ships default template files in its `assets/` folder, you can override them by listing your application's assets directory **before** the library path:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
ResourceModule.forRoot({
|
|
195
|
+
strategies: [
|
|
196
|
+
new FileResourceStrategy({
|
|
197
|
+
basePaths: [
|
|
198
|
+
join(__dirname, 'assets'), // ← Your overrides (checked first)
|
|
199
|
+
join(__dirname, '..', 'node_modules', '@breadstone', 'archipel-platform-mailing', 'assets'),
|
|
200
|
+
],
|
|
201
|
+
includeSubfolders: true,
|
|
202
|
+
}),
|
|
203
|
+
],
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
`ResourceManager` tries strategies and base paths in order — the first match wins. By placing your directory first, any file you provide takes precedence.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Sending a Templated Email
|
|
212
|
+
|
|
213
|
+
Once templates are registered, use `MailService.sendTemplate()`:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { Injectable } from '@nestjs/common';
|
|
217
|
+
import { MailService } from '@breadstone/archipel-platform-mailing';
|
|
218
|
+
|
|
219
|
+
@Injectable()
|
|
220
|
+
export class RegistrationService {
|
|
221
|
+
private readonly _mailService: MailService;
|
|
222
|
+
|
|
223
|
+
constructor(mailService: MailService) {
|
|
224
|
+
this._mailService = mailService;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
public async sendWelcomeEmail(email: string, userName: string): Promise<void> {
|
|
228
|
+
await this._mailService.sendTemplate(
|
|
229
|
+
{
|
|
230
|
+
to: email,
|
|
231
|
+
subject: 'Welcome to our platform',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
templateName: 'AuthRegister',
|
|
235
|
+
templateParams: {
|
|
236
|
+
userName,
|
|
237
|
+
dashboardUrl: 'https://yourapp.com/dashboard',
|
|
238
|
+
year: new Date().getFullYear(),
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The `templateName` must match one of the registered template file names (without extension). The `templateParams` object is passed to the template engine for variable substitution.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Template Format Selection
|
|
251
|
+
|
|
252
|
+
The environment variable `MAIL_TEMPLATE_ENGINE_FORMAT` controls which variant is used:
|
|
253
|
+
|
|
254
|
+
| Value | Behavior |
|
|
255
|
+
| ------ | ------------------------------------------- |
|
|
256
|
+
| `html` | Sends HTML email using `TemplateName.html` |
|
|
257
|
+
| `txt` | Sends plain-text email using `TemplateName.txt` |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Debugging
|
|
262
|
+
|
|
263
|
+
If a template is not found at runtime, `MailTemplateEngine.compileTemplate()` throws with the message:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
Template with key 'AuthVerify' not found.
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
To diagnose, enable `debug: true` in `ResourceModule.forRoot()`. This logs every available resource at startup so you can verify that your template files are discovered:
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
[FileResourceStrategy] Available resources:
|
|
273
|
+
- AuthVerify.html (text/html, 1.2 KB) → /app/dist/assets/AuthVerify.html
|
|
274
|
+
- AuthVerify.txt (text/plain, 320 B) → /app/dist/assets/AuthVerify.txt
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Also check that `MAIL_TEMPLATE_STRATEGY` is set correctly (`file` or `blob`).
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Checklist
|
|
282
|
+
|
|
283
|
+
- [ ] Template files created for all required template names (`.html` and/or `.txt`)
|
|
284
|
+
- [ ] `ResourceModule.forRoot()` registered with base paths including your template directory
|
|
285
|
+
- [ ] `MAIL_TEMPLATE_STRATEGY` set to `file` or `blob`
|
|
286
|
+
- [ ] `MAIL_TEMPLATE_ENGINE_FORMAT` set to `html` or `txt`
|
|
287
|
+
- [ ] Placeholders in templates match the keys passed in `templateParams`
|
|
288
|
+
- [ ] App-level overrides listed **before** library asset paths in `basePaths`
|
|
289
|
+
- [ ] `debug: true` used during development to verify template availability
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Next Steps
|
|
294
|
+
|
|
295
|
+
- See the [Email Delivery](/guides/email-delivery) guide for provider setup, attachments, and verification flows
|
|
296
|
+
- See the [Resource Management](/guides/resource-management) guide for advanced strategies (blob, caching, custom strategies)
|
|
297
|
+
- See the [Document Generation](/guides/document-generation) guide for PDF/DOCX template rendering
|
|
298
|
+
- Browse the [platform-mailing API reference](/packages/platform-mailing/api/) for complete method signatures
|
|
@@ -27,7 +27,7 @@ yarn add @breadstone/archipel-platform-esigning
|
|
|
27
27
|
| **DocuSign** | Industry-standard e-signature platform |
|
|
28
28
|
| **Adobe Sign** | Adobe Acrobat Sign integration |
|
|
29
29
|
| **Dropbox Sign** | Dropbox (formerly HelloSign) integration |
|
|
30
|
-
| **Internal** | Custom/self-managed signing
|
|
30
|
+
| **Internal** | Custom/self-managed signing (max 10,000 in-memory requests) |
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
@@ -17,10 +17,10 @@ This guide walks you through adding Archipel packages to a NestJS application. B
|
|
|
17
17
|
|
|
18
18
|
## Install the Foundation
|
|
19
19
|
|
|
20
|
-
Every Archipel application starts with `platform-core` and `platform-
|
|
20
|
+
Every Archipel application starts with `platform-core`, `platform-configuration`, and `platform-mapping`. Core provides templates, events, and cryptographic utilities. Mapping provides the object-to-object mapping system. Configuration provides the type-safe config system that all other packages depend on.
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
yarn add @breadstone/archipel-platform-core @breadstone/archipel-platform-configuration
|
|
23
|
+
yarn add @breadstone/archipel-platform-core @breadstone/archipel-platform-configuration @breadstone/archipel-platform-mapping
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Set Up Configuration
|
|
@@ -85,7 +85,7 @@ The `MappingModule` provides a centralized service for transforming domain entit
|
|
|
85
85
|
```typescript
|
|
86
86
|
import { Module } from '@nestjs/common';
|
|
87
87
|
import { ConfigModule } from '@breadstone/archipel-platform-configuration';
|
|
88
|
-
import { MappingModule } from '@breadstone/archipel-platform-
|
|
88
|
+
import { MappingModule } from '@breadstone/archipel-platform-mapping';
|
|
89
89
|
import { APP_CONFIG_ENTRIES } from './env';
|
|
90
90
|
import { UserMappingProfile } from './mapping/UserMappingProfile';
|
|
91
91
|
|
|
@@ -100,7 +100,7 @@ You define mapping profiles that register transformations:
|
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
102
|
import { Injectable } from '@nestjs/common';
|
|
103
|
-
import { MappingProfileBase, type MappingRegistry } from '@breadstone/archipel-platform-
|
|
103
|
+
import { MappingProfileBase, type MappingRegistry } from '@breadstone/archipel-platform-mapping';
|
|
104
104
|
import { USER_TO_RESPONSE } from './mapping-keys';
|
|
105
105
|
|
|
106
106
|
@Injectable()
|
|
@@ -135,7 +135,7 @@ Register the module:
|
|
|
135
135
|
// src/app.module.ts
|
|
136
136
|
import { Module } from '@nestjs/common';
|
|
137
137
|
import { ConfigModule } from '@breadstone/archipel-platform-configuration';
|
|
138
|
-
import { MappingModule } from '@breadstone/archipel-platform-
|
|
138
|
+
import { MappingModule } from '@breadstone/archipel-platform-mapping';
|
|
139
139
|
import { DatabaseModule } from '@breadstone/archipel-platform-database';
|
|
140
140
|
import { APP_CONFIG_ENTRIES } from './env';
|
|
141
141
|
|
|
@@ -286,7 +286,7 @@ Pass your adapter classes to `AuthModule.register()`:
|
|
|
286
286
|
// src/app.module.ts
|
|
287
287
|
import { Module } from '@nestjs/common';
|
|
288
288
|
import { ConfigModule } from '@breadstone/archipel-platform-configuration';
|
|
289
|
-
import { MappingModule } from '@breadstone/archipel-platform-
|
|
289
|
+
import { MappingModule } from '@breadstone/archipel-platform-mapping';
|
|
290
290
|
import { DatabaseModule } from '@breadstone/archipel-platform-database';
|
|
291
291
|
import { AuthModule } from '@breadstone/archipel-platform-authentication';
|
|
292
292
|
import { APP_CONFIG_ENTRIES } from './env';
|
package/data/guides/index.md
CHANGED
|
@@ -42,6 +42,7 @@ Practical guides for working with Archipel packages in your NestJS application.
|
|
|
42
42
|
| Guide | What you'll learn |
|
|
43
43
|
| ---------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
44
44
|
| [Email Delivery](./email-delivery) | Multi-provider email sending, template engines, and verification flows. |
|
|
45
|
+
| [Email Templates](./email-templates) | Create, register, and override email templates with ResourceManager. |
|
|
45
46
|
| [Payments & Feature Gating](./payments-and-feature-gating) | Payment provider integration, webhook handling, and feature-based access control. |
|
|
46
47
|
|
|
47
48
|
## Operations & Observability
|
|
@@ -216,6 +216,15 @@ export class GuideResources {
|
|
|
216
216
|
|
|
217
217
|
---
|
|
218
218
|
|
|
219
|
+
## Operational Limits
|
|
220
|
+
|
|
221
|
+
| Limit | Value | Description |
|
|
222
|
+
| -------------------- | ---------- | ------------------------------------------------------------------------ |
|
|
223
|
+
| **Max transports** | 1,000 | `McpServerService` tracks up to 1,000 concurrent transports |
|
|
224
|
+
| **Shutdown timeout** | 5 seconds | Transports and server are closed with a 5-second timeout on shutdown |
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
219
228
|
## Next Steps
|
|
220
229
|
|
|
221
230
|
- Browse the [platform-mcp API reference](/packages/platform-mcp/api/) for complete decorator options
|
|
@@ -252,6 +252,24 @@ try {
|
|
|
252
252
|
|
|
253
253
|
All client implementations log errors with structured metadata before re-throwing.
|
|
254
254
|
|
|
255
|
+
All payment clients throw `PaymentError` — a domain error that wraps the underlying SDK error:
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { PaymentError } from '@breadstone/archipel-platform-payments';
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
await this._paymentClient.createCheckoutSession(params);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (error instanceof PaymentError) {
|
|
264
|
+
// error.provider → 'stripe', 'paddle', 'mollie', 'lemonsqueezy'
|
|
265
|
+
// error.code → 'PAYMENT'
|
|
266
|
+
// error.cause → Original provider SDK error
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Map `PaymentError` to an HTTP response in your global exception filter. The `provider` property enables provider-specific alerting.
|
|
272
|
+
|
|
255
273
|
---
|
|
256
274
|
|
|
257
275
|
## Next Steps
|
|
@@ -6,16 +6,16 @@ order: 17
|
|
|
6
6
|
|
|
7
7
|
# Resource Management
|
|
8
8
|
|
|
9
|
-
This guide covers working with `ResourceManager` from `platform-
|
|
9
|
+
This guide covers working with `ResourceManager` from `platform-resources`: registering file strategies, loading resources at runtime, and using the built-in caching layer. If your application ships email templates, HTML pages, CSS/JS assets, or any other file-based content, this is how you make it available to services.
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
`ResourceManager` is part of `platform-
|
|
15
|
+
`ResourceManager` is part of `platform-resources`.
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
yarn add @breadstone/archipel-platform-
|
|
18
|
+
yarn add @breadstone/archipel-platform-resources
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
---
|
|
@@ -47,7 +47,7 @@ If the file exists on disk, it's served immediately. If not, blob storage is che
|
|
|
47
47
|
```typescript
|
|
48
48
|
import { Module } from '@nestjs/common';
|
|
49
49
|
import { join } from 'node:path';
|
|
50
|
-
import { ResourceModule, FileResourceStrategy, EmbeddedResourceStrategy } from '@breadstone/archipel-platform-
|
|
50
|
+
import { ResourceModule, FileResourceStrategy, EmbeddedResourceStrategy } from '@breadstone/archipel-platform-resources';
|
|
51
51
|
|
|
52
52
|
@Module({
|
|
53
53
|
imports: [
|
|
@@ -56,7 +56,7 @@ import { ResourceModule, FileResourceStrategy, EmbeddedResourceStrategy } from '
|
|
|
56
56
|
new FileResourceStrategy({
|
|
57
57
|
basePaths: [
|
|
58
58
|
join(__dirname, 'assets'),
|
|
59
|
-
join(__dirname, '..', 'node_modules', '@breadstone', 'archipel-platform-
|
|
59
|
+
join(__dirname, '..', 'node_modules', '@breadstone', 'archipel-platform-resources', 'assets'),
|
|
60
60
|
join(__dirname, '..', 'node_modules', '@breadstone', 'archipel-platform-openapi', 'assets'),
|
|
61
61
|
join(__dirname, '..', 'node_modules', '@breadstone', 'archipel-platform-mailing', 'assets'),
|
|
62
62
|
],
|
|
@@ -90,7 +90,7 @@ Inject `ResourceManager` and call its load methods. Every method has a `try*` va
|
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
import { Injectable } from '@nestjs/common';
|
|
93
|
-
import { ResourceManager } from '@breadstone/archipel-platform-
|
|
93
|
+
import { ResourceManager } from '@breadstone/archipel-platform-resources';
|
|
94
94
|
|
|
95
95
|
@Injectable()
|
|
96
96
|
export class InvoiceService {
|
|
@@ -172,7 +172,7 @@ The key you pass to `load()` is the **filename** (e.g. `'invoice-template.html'`
|
|
|
172
172
|
Loads from cloud blob storage via a minimal `IBlobServiceAdapter` interface. This is **async-only** — calling `load()` (sync) will throw.
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
|
-
import { BlobResourceStrategy, IBlobServiceAdapter } from '@breadstone/archipel-platform-
|
|
175
|
+
import { BlobResourceStrategy, IBlobServiceAdapter } from '@breadstone/archipel-platform-resources';
|
|
176
176
|
|
|
177
177
|
const blobAdapter: IBlobServiceAdapter = {
|
|
178
178
|
async downloadFile(key: string) {
|
|
@@ -247,7 +247,7 @@ const js = this._resourceManager.loadAsString('swagger.js');
|
|
|
247
247
|
|
|
248
248
|
### Application Index Page
|
|
249
249
|
|
|
250
|
-
`platform-core`'s `HostService` loads `index.html` as a template for the root route:
|
|
250
|
+
`platform-core`'s `HostService` loads `index.html` as a template for the root route (the `ResourceManager` itself comes from `platform-resources`):
|
|
251
251
|
|
|
252
252
|
```typescript
|
|
253
253
|
const html = await this._resourceManager.loadAsStringAsync('index.html');
|
|
@@ -300,7 +300,7 @@ Enable `debug: true` in the module config to have `ResourceManager` call `whatDo
|
|
|
300
300
|
Implement `IResourceStrategy` to support a new source (e.g. a database, S3 directly, or a remote API):
|
|
301
301
|
|
|
302
302
|
```typescript
|
|
303
|
-
import { IResourceStrategy, IResourceResult } from '@breadstone/archipel-platform-
|
|
303
|
+
import { IResourceStrategy, IResourceResult } from '@breadstone/archipel-platform-resources';
|
|
304
304
|
|
|
305
305
|
export class DatabaseResourceStrategy implements IResourceStrategy {
|
|
306
306
|
public get name(): string {
|