@breadstone/archipel-mcp 0.0.20 → 0.0.21

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.
Files changed (69) hide show
  1. package/data/guides/ai-text-generation.md +10 -0
  2. package/data/guides/analytics-and-error-tracking.md +6 -0
  3. package/data/guides/cryptography-and-otp.md +18 -0
  4. package/data/guides/document-generation.md +26 -0
  5. package/data/guides/email-delivery.md +23 -0
  6. package/data/guides/email-templates.md +298 -0
  7. package/data/guides/esigning-integration.md +1 -1
  8. package/data/guides/index.md +1 -0
  9. package/data/guides/mcp-server.md +9 -0
  10. package/data/guides/payments-and-feature-gating.md +18 -0
  11. package/data/guides/telemetry-and-observability.md +7 -1
  12. package/data/packages/platform-analytics/api/Class.AppInsightsAnalyticsClient.md +55 -6
  13. package/data/packages/platform-analytics/api/Class.DatadogAnalyticsClient.md +32 -6
  14. package/data/packages/platform-analytics/api/Class.SentryAnalyticsClient.md +55 -6
  15. package/data/packages/platform-analytics/index.md +13 -0
  16. package/data/packages/platform-core/api/Class.EventHub.md +7 -7
  17. package/data/packages/platform-core/api/Class.HealthOrchestrator.md +1 -1
  18. package/data/packages/platform-core/api/Class.SseHub.md +29 -6
  19. package/data/packages/platform-core/index.md +2 -1
  20. package/data/packages/platform-cryptography/api/Class.CryptoService.md +3 -3
  21. package/data/packages/platform-cryptography/index.md +10 -0
  22. package/data/packages/platform-documents/api/Class.DocumentEngine.md +4 -4
  23. package/data/packages/platform-documents/api/Class.DocumentError.md +61 -0
  24. package/data/packages/platform-documents/api/Class.DocumentRenderError.md +53 -0
  25. package/data/packages/platform-documents/api/Class.DocumentValidationError.md +52 -0
  26. package/data/packages/platform-documents/api/Class.ImageProcessingError.md +53 -0
  27. package/data/packages/platform-documents/api/Class.SharpImageProcessor.md +5 -5
  28. package/data/packages/platform-documents/api/index.md +4 -0
  29. package/data/packages/platform-documents/index.md +27 -0
  30. package/data/packages/platform-esigning/api/Class.EsigningClientPort.md +1 -1
  31. package/data/packages/platform-esigning/api/Class.InternalEsigningProvider.md +8 -8
  32. package/data/packages/platform-esigning/index.md +2 -0
  33. package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistry.md +3 -3
  34. package/data/packages/platform-intelligence/api/Class.IntelligenceConfigurationError.md +50 -0
  35. package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +27 -4
  36. package/data/packages/platform-intelligence/api/Class.IntelligenceValidationError.md +50 -0
  37. package/data/packages/platform-intelligence/api/Function.loadProviderFactory.md +1 -1
  38. package/data/packages/platform-intelligence/api/index.md +2 -0
  39. package/data/packages/platform-intelligence/index.md +32 -0
  40. package/data/packages/platform-logging/api/Class.LoggerModule.md +1 -1
  41. package/data/packages/platform-logging/index.md +2 -0
  42. package/data/packages/platform-mailing/api/Class.MailDeliveryError.md +65 -0
  43. package/data/packages/platform-mailing/api/Class.MailgunDeliveryStrategy.md +3 -3
  44. package/data/packages/platform-mailing/api/Class.PostmarkDeliveryStrategy.md +3 -3
  45. package/data/packages/platform-mailing/api/Class.ResendDeliveryStrategy.md +3 -3
  46. package/data/packages/platform-mailing/api/Class.SendGridDeliveryStrategy.md +3 -3
  47. package/data/packages/platform-mailing/api/Class.SmtpDeliveryStrategy.md +3 -3
  48. package/data/packages/platform-mailing/api/index.md +1 -0
  49. package/data/packages/platform-mailing/index.md +29 -0
  50. package/data/packages/platform-mcp/api/Class.McpServerService.md +8 -8
  51. package/data/packages/platform-mcp/index.md +11 -0
  52. package/data/packages/platform-openapi/api/Class.SwaggerTheme.md +2 -2
  53. package/data/packages/platform-openapi/index.md +1 -1
  54. package/data/packages/platform-payments/api/Class.LemonSqueezyClient.md +6 -6
  55. package/data/packages/platform-payments/api/Class.MollieClient.md +6 -6
  56. package/data/packages/platform-payments/api/Class.PaddleClient.md +6 -6
  57. package/data/packages/platform-payments/api/Class.PaymentError.md +65 -0
  58. package/data/packages/platform-payments/api/Class.StripeClient.md +6 -6
  59. package/data/packages/platform-payments/api/index.md +1 -0
  60. package/data/packages/platform-payments/index.md +29 -0
  61. package/data/packages/platform-reporting/api/Class.ReportingContributorRegistry.md +1 -1
  62. package/data/packages/platform-reporting/index.md +3 -1
  63. package/data/packages/platform-telemetry/api/Class.MetricsService.md +29 -3
  64. package/data/packages/platform-telemetry/api/Class.OtelSdkHolder.md +3 -2
  65. package/data/packages/platform-telemetry/api/Class.TelemetryLoggerService.md +6 -6
  66. package/data/packages/platform-telemetry/api/Class.TelemetryRuleEngine.md +3 -3
  67. package/data/packages/platform-telemetry/api/index.md +1 -1
  68. package/data/packages/platform-telemetry/index.md +3 -1
  69. package/package.json +1 -1
@@ -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.
@@ -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 |
@@ -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-core 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-core`. 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-core';
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
 
@@ -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
@@ -171,7 +171,13 @@ This prevents noisy endpoints (health checks, readiness probes) from overwhelmin
171
171
 
172
172
  ## Graceful Shutdown
173
173
 
174
- The module registers a shutdown hook that flushes all pending telemetry data before the process exits. This ensures you don't lose metrics or traces during deployments or scaling events.
174
+ The module registers a shutdown hook that flushes all pending telemetry data before the process exits. The SDK shutdown is capped at **5 seconds** to prevent the process from hanging if the OTEL collector is unreachable.
175
+
176
+ ### Lifecycle Details
177
+
178
+ - **`MetricsService`** creates metric instruments eagerly via `OnModuleInit` (not lazily on first use).
179
+ - **`OtelSdkHolder`** enforces a write-once guard — calling `setSdk()` twice logs a warning instead of overwriting.
180
+ - **`TelemetryRuleEngine`** logs rule evaluation failures as warnings instead of silently swallowing errors. This ensures you don't lose metrics or traces during deployments or scaling events.
175
181
 
176
182
  ---
177
183
 
@@ -14,6 +14,11 @@ Uses the `applicationinsights` SDK for error tracking and analytics.
14
14
 
15
15
  - [`AnalyticsClientPort`](Class.AnalyticsClientPort)
16
16
 
17
+ ## Implements
18
+
19
+ - `OnModuleInit`
20
+ - `OnModuleDestroy`
21
+
17
22
  ## Constructors
18
23
 
19
24
  ### Constructor
@@ -22,7 +27,7 @@ Uses the `applicationinsights` SDK for error tracking and analytics.
22
27
  new AppInsightsAnalyticsClient(configService): AppInsightsAnalyticsClient;
23
28
  ```
24
29
 
25
- Defined in: [application-insights/AppInsightsAnalyticsClient.ts:32](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L32)
30
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:33](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L33)
26
31
 
27
32
  #### Parameters
28
33
 
@@ -46,7 +51,7 @@ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:32](https://gith
46
51
  addBreadcrumb(breadcrumb): void;
47
52
  ```
48
53
 
49
- Defined in: [application-insights/AppInsightsAnalyticsClient.ts:81](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L81)
54
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:100](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L100)
50
55
 
51
56
  Add a breadcrumb entry to the analytics trail.
52
57
 
@@ -72,7 +77,7 @@ Add a breadcrumb entry to the analytics trail.
72
77
  captureException(error, context?): void;
73
78
  ```
74
79
 
75
- Defined in: [application-insights/AppInsightsAnalyticsClient.ts:49](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L49)
80
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:68](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L68)
76
81
 
77
82
  Capture an exception with optional context.
78
83
 
@@ -102,7 +107,7 @@ captureMessage(
102
107
  context?): void;
103
108
  ```
104
109
 
105
- Defined in: [application-insights/AppInsightsAnalyticsClient.ts:57](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L57)
110
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:76](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L76)
106
111
 
107
112
  Capture a message with a specific severity level.
108
113
 
@@ -130,7 +135,7 @@ Capture a message with a specific severity level.
130
135
  clearUser(): void;
131
136
  ```
132
137
 
133
- Defined in: [application-insights/AppInsightsAnalyticsClient.ts:75](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L75)
138
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:94](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L94)
134
139
 
135
140
  Clear the current user context.
136
141
 
@@ -144,13 +149,57 @@ Clear the current user context.
144
149
 
145
150
  ***
146
151
 
152
+ ### onModuleDestroy()
153
+
154
+ ```ts
155
+ onModuleDestroy(): Promise<void>;
156
+ ```
157
+
158
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:62](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L62)
159
+
160
+ Flushes pending Application Insights telemetry before shutdown.
161
+
162
+ #### Returns
163
+
164
+ `Promise`\<`void`\>
165
+
166
+ #### Implementation of
167
+
168
+ ```ts
169
+ OnModuleDestroy.onModuleDestroy
170
+ ```
171
+
172
+ ***
173
+
174
+ ### onModuleInit()
175
+
176
+ ```ts
177
+ onModuleInit(): void;
178
+ ```
179
+
180
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:47](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L47)
181
+
182
+ Initializes the Application Insights SDK.
183
+
184
+ #### Returns
185
+
186
+ `void`
187
+
188
+ #### Implementation of
189
+
190
+ ```ts
191
+ OnModuleInit.onModuleInit
192
+ ```
193
+
194
+ ***
195
+
147
196
  ### setUser()
148
197
 
149
198
  ```ts
150
199
  setUser(user): void;
151
200
  ```
152
201
 
153
- Defined in: [application-insights/AppInsightsAnalyticsClient.ts:66](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L66)
202
+ Defined in: [application-insights/AppInsightsAnalyticsClient.ts:85](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-analytics/src/application-insights/AppInsightsAnalyticsClient.ts#L85)
154
203
 
155
204
  Set the current user context for subsequent events.
156
205