@breadstone/archipel-mcp 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/guides/ai-image-generation.md +96 -0
- package/data/guides/ai-realtime-voice.md +69 -464
- package/data/guides/ai-text-generation.md +95 -622
- package/data/guides/index.md +3 -1
- package/data/guides/intelligence-prompts-warm-up.md +138 -0
- package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.DefaultIntelligencePromptPolicyAdapter.md +54 -0
- package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgent.md +95 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgentFactory.md +11 -23
- package/data/packages/platform-intelligence/api/Class.IntelligenceEmbeddingGenerator.md +25 -21
- package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +11 -7
- package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +159 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +60 -38
- package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptExecutor.md +88 -0
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptPolicyPort.md +48 -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 +2 -2
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +12 -12
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionPort.md +18 -18
- package/data/packages/platform-intelligence/api/Class.IntelligenceReranker.md +58 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +14 -16
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +10 -14
- package/data/packages/platform-intelligence/api/Class.MiMoIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +102 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokCodeExecutionTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokMcpServerTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokViewImageTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokViewXVideoTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokXSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createIntelligenceJsonSchema.md +31 -0
- package/data/packages/platform-intelligence/api/Function.createIntelligenceTool.md +2 -2
- package/data/packages/platform-intelligence/api/Function.createMimoCustomTool.md +5 -5
- package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.defineIntelligenceTool.md +31 -0
- package/data/packages/platform-intelligence/api/Function.intelligencePrompt.md +31 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceAgentConfiguration.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchOptions.md +124 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +102 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadResult.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGeneratedFile.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGenerationStepStartEvent.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationOptions.md +170 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationResult.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageCompletion.md +141 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageGenerationOptions.md +234 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageStream.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelReference.md +34 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelRequestOptions.md +52 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +43 -25
- 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 +145 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptEffectivePolicy.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionContext.md +20 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionPolicy.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionResult.md +127 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptInvocation.md +49 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptPolicyRequest.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptRenderContext.md +26 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderAdapter.md +73 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderConfiguration.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderProbeResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeAudioFormat.md +3 -3
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeCloseEvent.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeModuleOptions.md +9 -21
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionConfiguration.md +11 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +11 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeToolDefinition.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeTranscriptionConfiguration.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeTurnDetectionConfiguration.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +98 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +140 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +94 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +80 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +164 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +139 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTool.md +7 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolCall.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolDefinition.md +91 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionEndEvent.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionStartEvent.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolRegistry.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionResult.md +84 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionStream.md +97 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceUsage.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +229 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceModelMessage.md +43 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligencePromptModelRequirement.md +25 -0
- 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.IntelligencePromptCapability.md +20 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptDefinitionConfiguration.md +29 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptGenerationOptions.md +16 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptLatency.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptMode.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptQuality.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptReasoning.md +14 -0
- 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.IntelligenceRealtimeClientEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMetadataValue.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMeteringEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeServerEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeStatus.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRequestTimeouts.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolChoice.md +21 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolOutput.md +22 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolSet.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTranscriptionStreamPart.md +46 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_API_KEY.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_BASE_URL.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MAX_OUTPUT_TOKENS.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MODEL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_PROVIDER.md +2 -2
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TEMPERATURE.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TOP_P.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.IntelligenceCapabilityNames.md +40 -0
- package/data/packages/platform-intelligence/api/Variable.IntelligenceProviderNames.md +2 -0
- package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-intelligence/api/index.md +98 -30
- package/package.json +1 -1
- package/data/packages/index.md +0 -8
- package/data/packages/platform-analytics/index.md +0 -209
- package/data/packages/platform-authentication/index.md +0 -725
- package/data/packages/platform-blob-storage/index.md +0 -416
- package/data/packages/platform-bootstrap/index.md +0 -162
- package/data/packages/platform-caching/index.md +0 -167
- package/data/packages/platform-configuration/index.md +0 -226
- package/data/packages/platform-core/index.md +0 -504
- package/data/packages/platform-cryptography/index.md +0 -142
- package/data/packages/platform-database/index.md +0 -337
- package/data/packages/platform-documents/index.md +0 -255
- package/data/packages/platform-esigning/index.md +0 -710
- package/data/packages/platform-feature-flags/index.md +0 -103
- package/data/packages/platform-health/index.md +0 -141
- package/data/packages/platform-intelligence/api/Class.IntelligenceStructuredGenerator.md +0 -70
- package/data/packages/platform-intelligence/api/Class.IntelligenceTelemetryRegistry.md +0 -44
- package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +0 -138
- package/data/packages/platform-intelligence/api/Function.createProviderOptions.md +0 -39
- package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGoogleRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGrokRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Function.loadMimoLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadOpenAIRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCompletionUsage.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextCompletion.md +0 -168
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerationOptions.md +0 -144
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerator.md +0 -78
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextStreamingOptions.md +0 -170
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +0 -24
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoaders.md +0 -14
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoader.md +0 -25
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoaders.md +0 -14
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTextStream.md +0 -14
- package/data/packages/platform-intelligence/index.md +0 -549
- 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,610 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: platform-payments
|
|
3
|
-
description: Provider-agnostic payment infrastructure with support for Stripe, Paddle, LemonSqueezy, and Mollie.
|
|
4
|
-
order: 4
|
|
5
|
-
tags: [payments, stripe, paddle, lemonsqueezy, mollie, feature-gating, quotas, guards, interceptors, ports-and-adapters, health]
|
|
6
|
-
package: '@breadstone/archipel-platform-payments'
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# platform-payments
|
|
10
|
-
|
|
11
|
-
Provider-agnostic payment infrastructure for NestJS. Exposes a unified `PaymentClientPort` abstraction with four ready-made implementations (Stripe, Paddle, LemonSqueezy, Mollie), a feature-gating guard, and a usage-tracking interceptor. Feature access checks are fully decoupled via the `FeatureAccessPort`.
|
|
12
|
-
|
|
13
|
-
**Package:** `@breadstone/archipel-platform-payments`
|
|
14
|
-
|
|
15
|
-
<InstallTabs />
|
|
16
|
-
|
|
17
|
-
## Architecture
|
|
18
|
-
|
|
19
|
-
```mermaid
|
|
20
|
-
graph TD
|
|
21
|
-
Core["@breadstone/archipel-platform-payments<br/><i>Port, models, guard, interceptor, module</i>"]
|
|
22
|
-
Stripe["@breadstone/archipel-platform-payments/stripe<br/><i>StripeClient</i>"]
|
|
23
|
-
Paddle["@breadstone/archipel-platform-payments/paddle<br/><i>PaddleClient</i>"]
|
|
24
|
-
Lemon["@breadstone/archipel-platform-payments/lemonsqueezy<br/><i>LemonSqueezyClient</i>"]
|
|
25
|
-
Mollie["@breadstone/archipel-platform-payments/mollie<br/><i>MollieClient</i>"]
|
|
26
|
-
|
|
27
|
-
Stripe -->|implements| Core
|
|
28
|
-
Paddle -->|implements| Core
|
|
29
|
-
Lemon -->|implements| Core
|
|
30
|
-
Mollie -->|implements| Core
|
|
31
|
-
|
|
32
|
-
Stripe -.-|requires| S["stripe"]
|
|
33
|
-
Paddle -.-|requires| P["@paddle/paddle-node-sdk"]
|
|
34
|
-
Lemon -.-|requires| L["@lemonsqueezy/lemonsqueezy.js"]
|
|
35
|
-
Mollie -.-|requires| M["@mollie/api-client"]
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Each provider SDK is an **optional peer dependency**. Install only the one you need.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Quick Start
|
|
43
|
-
|
|
44
|
-
### 1. Install the provider SDK
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
# Pick one:
|
|
48
|
-
yarn add stripe
|
|
49
|
-
yarn add @paddle/paddle-node-sdk
|
|
50
|
-
yarn add @lemonsqueezy/lemonsqueezy.js
|
|
51
|
-
yarn add @mollie/api-client
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### 2. Register the module
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
import { Module } from '@nestjs/common';
|
|
58
|
-
import { PaymentModule } from '@breadstone/archipel-platform-payments';
|
|
59
|
-
import { StripeClient, STRIPE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/stripe';
|
|
60
|
-
|
|
61
|
-
@Module({
|
|
62
|
-
imports: [
|
|
63
|
-
PaymentModule.register({
|
|
64
|
-
paymentClient: StripeClient,
|
|
65
|
-
configEntries: STRIPE_CONFIG_ENTRIES,
|
|
66
|
-
featureAccess: PrismaFeatureAccessAdapter, // optional
|
|
67
|
-
isGlobal: false,
|
|
68
|
-
}),
|
|
69
|
-
],
|
|
70
|
-
})
|
|
71
|
-
export class AppModule {}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Switching providers
|
|
75
|
-
|
|
76
|
-
Replace the imports — no other code change needed:
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
import { PaddleClient, PADDLE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/paddle';
|
|
80
|
-
|
|
81
|
-
PaymentModule.register({
|
|
82
|
-
paymentClient: PaddleClient,
|
|
83
|
-
configEntries: PADDLE_CONFIG_ENTRIES,
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Module Configuration
|
|
90
|
-
|
|
91
|
-
### IPaymentModuleOptions
|
|
92
|
-
|
|
93
|
-
| Property | Type | Required | Default | Description |
|
|
94
|
-
| --------------- | ----------------------------------------------------- | -------- | ------- | --------------------------------------------- |
|
|
95
|
-
| `paymentClient` | `Type<PaymentClientPort>` | **Yes** | — | Provider implementation (e.g. `StripeClient`) |
|
|
96
|
-
| `configEntries` | `ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>` | No | `[]` | Provider-specific config entries |
|
|
97
|
-
| `featureAccess` | `Type<FeatureAccessPort>` | No | — | Feature quota checking and usage recording |
|
|
98
|
-
| `isGlobal` | `boolean` | No | `false` | Register as a global module |
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Payment Providers
|
|
103
|
-
|
|
104
|
-
### Stripe
|
|
105
|
-
|
|
106
|
-
**Subpath:** `@breadstone/archipel-platform-payments/stripe`
|
|
107
|
-
**SDK:** `stripe` ≥ 22.0.0
|
|
108
|
-
|
|
109
|
-
| Variable | Description | Required |
|
|
110
|
-
| ----------------------- | ----------------------------- | -------- |
|
|
111
|
-
| `STRIPE_API_KEY` | Stripe secret API key | Yes |
|
|
112
|
-
| `STRIPE_WEBHOOK_SECRET` | Stripe webhook signing secret | Yes |
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
import { StripeClient, STRIPE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/stripe';
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Paddle
|
|
119
|
-
|
|
120
|
-
**Subpath:** `@breadstone/archipel-platform-payments/paddle`
|
|
121
|
-
**SDK:** `@paddle/paddle-node-sdk` ≥ 3.0.0
|
|
122
|
-
|
|
123
|
-
| Variable | Description | Required | Default |
|
|
124
|
-
| ----------------------- | ------------------------- | -------- | ------------ |
|
|
125
|
-
| `PADDLE_API_KEY` | Paddle API key | Yes | — |
|
|
126
|
-
| `PADDLE_WEBHOOK_SECRET` | Paddle webhook secret key | Yes | — |
|
|
127
|
-
| `PADDLE_ENVIRONMENT` | `production` or `sandbox` | No | `production` |
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
import { PaddleClient, PADDLE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/paddle';
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### LemonSqueezy
|
|
134
|
-
|
|
135
|
-
**Subpath:** `@breadstone/archipel-platform-payments/lemonsqueezy`
|
|
136
|
-
**SDK:** `@lemonsqueezy/lemonsqueezy.js` ≥ 4.0.0
|
|
137
|
-
|
|
138
|
-
| Variable | Description | Required |
|
|
139
|
-
| ----------------------------- | ----------------------------------- | -------- |
|
|
140
|
-
| `LEMONSQUEEZY_API_KEY` | LemonSqueezy API key | Yes |
|
|
141
|
-
| `LEMONSQUEEZY_WEBHOOK_SECRET` | LemonSqueezy webhook signing secret | Yes |
|
|
142
|
-
| `LEMONSQUEEZY_STORE_ID` | LemonSqueezy store ID | Yes |
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { LemonSqueezyClient, LEMONSQUEEZY_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/lemonsqueezy';
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Mollie
|
|
149
|
-
|
|
150
|
-
**Subpath:** `@breadstone/archipel-platform-payments/mollie`
|
|
151
|
-
**SDK:** `@mollie/api-client` ≥ 4.0.0
|
|
152
|
-
|
|
153
|
-
| Variable | Description | Required |
|
|
154
|
-
| ----------------------- | -------------------------------------- | -------- |
|
|
155
|
-
| `MOLLIE_API_KEY` | Mollie API key | Yes |
|
|
156
|
-
| `MOLLIE_WEBHOOK_SECRET` | Mollie webhook secret for verification | Yes |
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
import { MollieClient, MOLLIE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/mollie';
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
::: info Mollie Limitations
|
|
163
|
-
Mollie does not have a native price catalog API. `fetchPrices()` returns an empty array — maintain prices in your local database. `fetchSubscription()` expects the format `"customerId:subscriptionId"`.
|
|
164
|
-
:::
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
## PaymentClientPort
|
|
169
|
-
|
|
170
|
-
All providers implement this abstract contract. Inject `PaymentClientPort` in services to stay provider-agnostic:
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
abstract class PaymentClientPort {
|
|
174
|
-
abstract fetchPrices(productId: string): Promise<INormalizedPrice[]>;
|
|
175
|
-
abstract createCheckoutSession(
|
|
176
|
-
priceId: string,
|
|
177
|
-
successUrl: string,
|
|
178
|
-
cancelUrl: string,
|
|
179
|
-
userId?: string,
|
|
180
|
-
): Promise<INormalizedCheckoutSession>;
|
|
181
|
-
abstract fetchSubscription(subscriptionId: string): Promise<INormalizedSubscription | null>;
|
|
182
|
-
abstract constructWebhookEvent(
|
|
183
|
-
payload: string | Buffer,
|
|
184
|
-
signature: string,
|
|
185
|
-
): Promise<INormalizedWebhookEvent> | INormalizedWebhookEvent;
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Usage in services
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
import { PaymentClientPort } from '@breadstone/archipel-platform-payments';
|
|
193
|
-
|
|
194
|
-
@Injectable()
|
|
195
|
-
export class CheckoutService {
|
|
196
|
-
constructor(private readonly _paymentClient: PaymentClientPort) {}
|
|
197
|
-
|
|
198
|
-
public async createCheckout(priceId: string, userId: string): Promise<string | null> {
|
|
199
|
-
const session = await this._paymentClient.createCheckoutSession(
|
|
200
|
-
priceId,
|
|
201
|
-
'https://app.example.com/success',
|
|
202
|
-
'https://app.example.com/cancel',
|
|
203
|
-
userId,
|
|
204
|
-
);
|
|
205
|
-
return session.url;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Prices
|
|
211
|
-
|
|
212
|
-
```typescript
|
|
213
|
-
const prices = await this._paymentClient.fetchPrices('prod_ABC123');
|
|
214
|
-
// → INormalizedPrice[]
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
> **Error handling:** `fetchPrices` **throws** on API or network errors instead of returning an empty array. Errors are logged with structured metadata before being re-thrown. Wrap calls in `try/catch` if you need fallback behavior.
|
|
218
|
-
|
|
219
|
-
### Subscriptions
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
const subscription = await this._paymentClient.fetchSubscription('sub_ABC123');
|
|
223
|
-
// → INormalizedSubscription | null
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Webhook Events
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
const event = await this._paymentClient.constructWebhookEvent(rawBody, signature);
|
|
230
|
-
// → INormalizedWebhookEvent
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
## Normalized Types
|
|
236
|
-
|
|
237
|
-
All providers map their native API responses into these shared interfaces.
|
|
238
|
-
|
|
239
|
-
### INormalizedPrice
|
|
240
|
-
|
|
241
|
-
| Field | Type | Description |
|
|
242
|
-
| --------------- | -------------------------------------------------- | ------------------------------- |
|
|
243
|
-
| `id` | `string` | Price identifier |
|
|
244
|
-
| `productId` | `string` | Associated product identifier |
|
|
245
|
-
| `amount` | `number` | Price amount (in smallest unit) |
|
|
246
|
-
| `currency` | `string` | ISO 4217 currency code |
|
|
247
|
-
| `interval` | `'week' \| 'month' \| 'quarter' \| 'year' \| null` | Billing interval |
|
|
248
|
-
| `intervalCount` | `number` | Number of intervals per cycle |
|
|
249
|
-
| `active` | `boolean` | Whether the price is active |
|
|
250
|
-
|
|
251
|
-
### INormalizedCheckoutSession
|
|
252
|
-
|
|
253
|
-
| Field | Type | Description |
|
|
254
|
-
| ------------------- | --------------------------------------------- | ------------------------ |
|
|
255
|
-
| `id` | `string` | Session identifier |
|
|
256
|
-
| `url` | `string \| null` | Checkout URL to redirect |
|
|
257
|
-
| `subscriptionId` | `string \| null` | Created subscription ID |
|
|
258
|
-
| `customerId` | `string \| null` | Customer identifier |
|
|
259
|
-
| `clientReferenceId` | `string \| null` | Client-supplied ref |
|
|
260
|
-
| `paymentStatus` | `'paid' \| 'unpaid' \| 'no_payment_required'` | Payment status |
|
|
261
|
-
|
|
262
|
-
### INormalizedSubscription
|
|
263
|
-
|
|
264
|
-
| Field | Type | Description |
|
|
265
|
-
| -------------------- | -------------------- | --------------------------------- |
|
|
266
|
-
| `id` | `string` | Subscription identifier |
|
|
267
|
-
| `customerId` | `string` | Customer identifier |
|
|
268
|
-
| `status` | `SubscriptionStatus` | Current status |
|
|
269
|
-
| `priceId` | `string` | Associated price identifier |
|
|
270
|
-
| `currentPeriodStart` | `Date` | Start of current billing period |
|
|
271
|
-
| `currentPeriodEnd` | `Date` | End of current billing period |
|
|
272
|
-
| `cancelAtPeriodEnd` | `boolean` | Whether cancellation is scheduled |
|
|
273
|
-
| `trialStart` | `Date \| null` | Trial start date |
|
|
274
|
-
| `trialEnd` | `Date \| null` | Trial end date |
|
|
275
|
-
|
|
276
|
-
### SubscriptionStatus
|
|
277
|
-
|
|
278
|
-
```typescript
|
|
279
|
-
type SubscriptionStatus =
|
|
280
|
-
| 'active'
|
|
281
|
-
| 'canceled'
|
|
282
|
-
| 'incomplete'
|
|
283
|
-
| 'incompleteExpired'
|
|
284
|
-
| 'pastDue'
|
|
285
|
-
| 'trialing'
|
|
286
|
-
| 'unpaid'
|
|
287
|
-
| 'paused';
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### INormalizedWebhookEvent
|
|
291
|
-
|
|
292
|
-
| Field | Type | Description |
|
|
293
|
-
| ------ | --------------------------- | ------------------------------- |
|
|
294
|
-
| `type` | `string` (see values below) | Normalized event type |
|
|
295
|
-
| `data` | `object` | Event payload (see shape below) |
|
|
296
|
-
|
|
297
|
-
**Event types:** `checkout.session.completed`, `subscription.updated`, `subscription.deleted`, `invoice.payment_failed`, `invoice.payment_succeeded`, `unknown`
|
|
298
|
-
|
|
299
|
-
**Data shape:**
|
|
300
|
-
|
|
301
|
-
```typescript
|
|
302
|
-
{
|
|
303
|
-
checkoutSession?: INormalizedCheckoutSession;
|
|
304
|
-
subscription?: INormalizedSubscription;
|
|
305
|
-
invoice?: {
|
|
306
|
-
id: string;
|
|
307
|
-
subscriptionId: string | null;
|
|
308
|
-
status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void';
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
---
|
|
314
|
-
|
|
315
|
-
## FeatureAccessPort
|
|
316
|
-
|
|
317
|
-
Abstract port for checking feature quotas and recording usage. This enables feature-gating with any billing system and optional request-scoped tenancy context.
|
|
318
|
-
|
|
319
|
-
```typescript
|
|
320
|
-
abstract class FeatureAccessPort {
|
|
321
|
-
abstract checkAccess(
|
|
322
|
-
userId: string,
|
|
323
|
-
featureKey: string,
|
|
324
|
-
context?: IFeatureAccessContext,
|
|
325
|
-
): Promise<IFeatureAccessResult>;
|
|
326
|
-
|
|
327
|
-
abstract recordUsage(userId: string, featureKey: string, context?: IFeatureAccessContext): Promise<void>;
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
`FeatureGuard` and `FeatureUsageInterceptor` create `IFeatureAccessContext` from the authenticated request subject. The guard resolves `request.user.id`, converts numeric ids to strings, forwards `request.user.tenantId` when present, and includes the original subject for adapters that need additional claims.
|
|
332
|
-
|
|
333
|
-
### IFeatureAccessContext
|
|
334
|
-
|
|
335
|
-
| Field | Type | Description |
|
|
336
|
-
| ---------- | -------------------- | ---------------------------------------------------------- |
|
|
337
|
-
| `userId` | `string` | Authenticated user identifier resolved from `request.user` |
|
|
338
|
-
| `tenantId` | `string \| number` | Optional tenant identifier from the authenticated subject |
|
|
339
|
-
| `subject` | `unknown` | Original authenticated subject from the request |
|
|
340
|
-
|
|
341
|
-
### IFeatureAccessResult
|
|
342
|
-
|
|
343
|
-
| Field | Type | Description |
|
|
344
|
-
| ----------- | --------- | ---------------------------------------- |
|
|
345
|
-
| `allowed` | `boolean` | Whether the user can use the feature |
|
|
346
|
-
| `used` | `number` | Current usage count in the active period |
|
|
347
|
-
| `limit` | `number` | Maximum allowed (`-1` = unlimited) |
|
|
348
|
-
| `remaining` | `number` | Remaining quota (`-1` = unlimited) |
|
|
349
|
-
| `resetAt` | `Date` | When the usage period resets |
|
|
350
|
-
|
|
351
|
-
### Real-World Adapter: Prisma + Subscription
|
|
352
|
-
|
|
353
|
-
```typescript
|
|
354
|
-
@Injectable()
|
|
355
|
-
export class PrismaFeatureAccessAdapter extends FeatureAccessPort {
|
|
356
|
-
private readonly _prisma: PrismaService;
|
|
357
|
-
|
|
358
|
-
constructor(prisma: PrismaService) {
|
|
359
|
-
super();
|
|
360
|
-
this._prisma = prisma;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
public async checkAccess(
|
|
364
|
-
userId: string,
|
|
365
|
-
featureKey: string,
|
|
366
|
-
context?: IFeatureAccessContext,
|
|
367
|
-
): Promise<IFeatureAccessResult> {
|
|
368
|
-
const subscription = await this._prisma.subscription.findFirst({
|
|
369
|
-
where: { userId, tenantId: context?.tenantId, status: 'active' },
|
|
370
|
-
include: { plan: { include: { features: true } } },
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
const feature = subscription?.plan.features.find((f) => f.key === featureKey);
|
|
374
|
-
if (!feature) {
|
|
375
|
-
return { allowed: false, used: 0, limit: 0, remaining: 0, resetAt: new Date() };
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const periodStart = this.getCurrentPeriodStart(subscription.currentPeriodStart);
|
|
379
|
-
const usage = await this._prisma.featureUsage.count({
|
|
380
|
-
where: {
|
|
381
|
-
userId,
|
|
382
|
-
tenantId: context?.tenantId,
|
|
383
|
-
featureKey,
|
|
384
|
-
createdAt: { gte: periodStart },
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
const limit = feature.limit;
|
|
389
|
-
const remaining = limit === -1 ? -1 : Math.max(0, limit - usage);
|
|
390
|
-
|
|
391
|
-
return {
|
|
392
|
-
allowed: limit === -1 || usage < limit,
|
|
393
|
-
used: usage,
|
|
394
|
-
limit,
|
|
395
|
-
remaining,
|
|
396
|
-
resetAt: subscription.currentPeriodEnd,
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
public async recordUsage(userId: string, featureKey: string, context?: IFeatureAccessContext): Promise<void> {
|
|
401
|
-
const access = await this.checkAccess(userId, featureKey, context);
|
|
402
|
-
if (!access.allowed) {
|
|
403
|
-
throw new Error(`Feature quota exceeded for ${featureKey}`);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
await this._prisma.featureUsage.create({
|
|
407
|
-
data: { userId, tenantId: context?.tenantId, featureKey },
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
private getCurrentPeriodStart(periodStart: Date): Date {
|
|
412
|
-
return periodStart;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
---
|
|
418
|
-
|
|
419
|
-
## Feature Gating
|
|
420
|
-
|
|
421
|
-
### @RequiresFeature Decorator
|
|
422
|
-
|
|
423
|
-
Mark controller endpoints with a feature key:
|
|
424
|
-
|
|
425
|
-
```typescript
|
|
426
|
-
import { RequiresFeature } from '@breadstone/archipel-platform-payments';
|
|
427
|
-
|
|
428
|
-
@Controller('recipes')
|
|
429
|
-
export class RecipeController {
|
|
430
|
-
@Post()
|
|
431
|
-
@RequiresFeature('RECIPE_CREATION')
|
|
432
|
-
public async createRecipe(@Body() body: CreateRecipeDto): Promise<RecipeResponse> {
|
|
433
|
-
// Only executed if user has quota for RECIPE_CREATION
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
### FeatureGuard
|
|
439
|
-
|
|
440
|
-
Checks the `@RequiresFeature` metadata against `FeatureAccessPort.checkAccess()`. Metadata is resolved from route handlers first and controller classes second. Apply the guard globally or per-controller:
|
|
441
|
-
|
|
442
|
-
```typescript
|
|
443
|
-
// Global registration
|
|
444
|
-
app.useGlobalGuards(app.get(FeatureGuard));
|
|
445
|
-
|
|
446
|
-
// Per-controller
|
|
447
|
-
@Controller('recipes')
|
|
448
|
-
@UseGuards(JwtAuthGuard, FeatureGuard)
|
|
449
|
-
export class RecipeController {
|
|
450
|
-
/* ... */
|
|
451
|
-
}
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
The guard passes `IFeatureAccessContext` into the access port and attaches the `IFeatureAccessResult` to the request as `request.featureAccess`, enabling downstream access to quota information.
|
|
455
|
-
|
|
456
|
-
### FeatureUsageInterceptor
|
|
457
|
-
|
|
458
|
-
Records feature usage after successful request completion:
|
|
459
|
-
|
|
460
|
-
```typescript
|
|
461
|
-
@Controller('recipes')
|
|
462
|
-
@UseGuards(JwtAuthGuard, FeatureGuard)
|
|
463
|
-
@UseInterceptors(FeatureUsageInterceptor)
|
|
464
|
-
export class RecipeController {
|
|
465
|
-
@Post()
|
|
466
|
-
@RequiresFeature('RECIPE_CREATION')
|
|
467
|
-
public async createRecipe(@Body() body: CreateRecipeDto): Promise<RecipeResponse> {
|
|
468
|
-
// After successful response, FeatureUsageInterceptor calls
|
|
469
|
-
// FeatureAccessPort.recordUsage(userId, 'RECIPE_CREATION', context)
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
---
|
|
475
|
-
|
|
476
|
-
## End-to-End Example: Feature-Gated API with Stripe
|
|
477
|
-
|
|
478
|
-
```typescript
|
|
479
|
-
// 1. Define feature keys
|
|
480
|
-
export const FEATURES = {
|
|
481
|
-
RECIPE_CREATION: 'RECIPE_CREATION',
|
|
482
|
-
AI_SUGGESTIONS: 'AI_SUGGESTIONS',
|
|
483
|
-
EXPORT_PDF: 'EXPORT_PDF',
|
|
484
|
-
} as const;
|
|
485
|
-
|
|
486
|
-
// 2. Implement the adapter
|
|
487
|
-
@Injectable()
|
|
488
|
-
export class AppFeatureAccessAdapter extends FeatureAccessPort {
|
|
489
|
-
// ... (see Real-World Adapter above)
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// 3. Register with Stripe
|
|
493
|
-
import { StripeClient, STRIPE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-payments/stripe';
|
|
494
|
-
|
|
495
|
-
@Module({
|
|
496
|
-
imports: [
|
|
497
|
-
PaymentModule.register({
|
|
498
|
-
paymentClient: StripeClient,
|
|
499
|
-
configEntries: STRIPE_CONFIG_ENTRIES,
|
|
500
|
-
featureAccess: AppFeatureAccessAdapter,
|
|
501
|
-
}),
|
|
502
|
-
],
|
|
503
|
-
})
|
|
504
|
-
export class AppModule {}
|
|
505
|
-
|
|
506
|
-
// 4. Use in controllers
|
|
507
|
-
@Controller('recipes')
|
|
508
|
-
@UseGuards(JwtAuthGuard, FeatureGuard)
|
|
509
|
-
@UseInterceptors(FeatureUsageInterceptor)
|
|
510
|
-
export class RecipeController {
|
|
511
|
-
constructor(private readonly _paymentClient: PaymentClientPort) {}
|
|
512
|
-
|
|
513
|
-
@Post()
|
|
514
|
-
@RequiresFeature(FEATURES.RECIPE_CREATION)
|
|
515
|
-
public async create(@Body() body: CreateRecipeDto): Promise<RecipeResponse> {
|
|
516
|
-
return this._recipeService.create(body);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
@Post(':id/ai-suggestions')
|
|
520
|
-
@RequiresFeature(FEATURES.AI_SUGGESTIONS)
|
|
521
|
-
public async suggest(@Param('id') id: string): Promise<SuggestionResponse> {
|
|
522
|
-
return this._aiService.suggest(id);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
---
|
|
528
|
-
|
|
529
|
-
## Error Handling
|
|
530
|
-
|
|
531
|
-
All payment clients throw a `PaymentError` when provider operations fail (checkout session creation, webhook signature verification, price fetching, etc.). This domain error wraps the underlying SDK error and exposes structured metadata:
|
|
532
|
-
|
|
533
|
-
```typescript
|
|
534
|
-
import { PaymentError } from '@breadstone/archipel-platform-payments';
|
|
535
|
-
|
|
536
|
-
try {
|
|
537
|
-
await this._paymentClient.createCheckoutSession(priceId, successUrl, cancelUrl, userId);
|
|
538
|
-
} catch (error) {
|
|
539
|
-
if (error instanceof PaymentError) {
|
|
540
|
-
logger.error('Payment operation failed', {
|
|
541
|
-
provider: error.provider, // 'stripe', 'paddle', 'mollie', 'lemonsqueezy'
|
|
542
|
-
code: error.code, // 'PAYMENT'
|
|
543
|
-
cause: error.cause, // Original provider SDK error
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
```
|
|
548
|
-
|
|
549
|
-
| Property | Type | Description |
|
|
550
|
-
| ---------- | -------- | -------------------------------------------------- |
|
|
551
|
-
| `code` | `string` | Always `'PAYMENT'` |
|
|
552
|
-
| `provider` | `string` | Provider that failed (`stripe`, `paddle`, etc.) |
|
|
553
|
-
| `cause` | `unknown`| Original error from the provider SDK |
|
|
554
|
-
|
|
555
|
-
---
|
|
556
|
-
|
|
557
|
-
## Health Check
|
|
558
|
-
|
|
559
|
-
The `PaymentHealthIndicator` verifies that a `PaymentClientPort` is injected. If no payment client is registered, it reports `disabled: true`. Import it from the `/health` subpath:
|
|
560
|
-
|
|
561
|
-
```typescript
|
|
562
|
-
import { PaymentHealthIndicator } from '@breadstone/archipel-platform-payments/health';
|
|
563
|
-
import { HealthModule } from '@breadstone/archipel-platform-health';
|
|
564
|
-
|
|
565
|
-
@Module({
|
|
566
|
-
imports: [
|
|
567
|
-
PaymentModule.register({ /* ... */ }),
|
|
568
|
-
HealthModule.withIndicators([PaymentHealthIndicator]),
|
|
569
|
-
],
|
|
570
|
-
})
|
|
571
|
-
export class AppModule {}
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
| Key | Check | Dependencies |
|
|
575
|
-
| --- | ----- | ------------ |
|
|
576
|
-
| `payment` | `up` if `PaymentClientPort` injected, else `disabled` | `@Optional() PaymentClientPort` |
|
|
577
|
-
|
|
578
|
-
---
|
|
579
|
-
|
|
580
|
-
## Exports Summary
|
|
581
|
-
|
|
582
|
-
### Core (`@breadstone/archipel-platform-payments`)
|
|
583
|
-
|
|
584
|
-
| Export | Type | Description |
|
|
585
|
-
| ---------------------------- | ------------- | ----------------------------------- |
|
|
586
|
-
| `PaymentModule` | NestJS Module | Main module with `register()` |
|
|
587
|
-
| `PaymentClientPort` | Abstract Port | Provider-agnostic payment contract |
|
|
588
|
-
| `FeatureAccessPort` | Abstract Port | Feature quota checking |
|
|
589
|
-
| `IFeatureAccessContext` | Interface | Request-scoped access context |
|
|
590
|
-
| `IFeatureAccessResult` | Interface | Quota check result |
|
|
591
|
-
| `FeatureGuard` | Guard | Enforces `@RequiresFeature` |
|
|
592
|
-
| `FeatureUsageInterceptor` | Interceptor | Records feature usage |
|
|
593
|
-
| `RequiresFeature` | Decorator | Marks feature-gated endpoints |
|
|
594
|
-
| `FEATURE_KEY_METADATA` | Constant | Metadata key for feature decorators |
|
|
595
|
-
| `INormalizedPrice` | Interface | Normalized price |
|
|
596
|
-
| `INormalizedCheckoutSession` | Interface | Normalized checkout session |
|
|
597
|
-
| `INormalizedSubscription` | Interface | Normalized subscription |
|
|
598
|
-
| `INormalizedWebhookEvent` | Interface | Normalized webhook event |
|
|
599
|
-
| `SubscriptionStatus` | Type Alias | Subscription status union |
|
|
600
|
-
| `PaymentError` | Error class | Domain error for payment failures |
|
|
601
|
-
| `PaymentHealthIndicator` | Health | Payment readiness check (`/health` subpath) |
|
|
602
|
-
|
|
603
|
-
### Provider subpaths
|
|
604
|
-
|
|
605
|
-
| Subpath | Exports |
|
|
606
|
-
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
607
|
-
| `/stripe` | `StripeClient`, `STRIPE_API_KEY`, `STRIPE_WEBHOOK_SECRET`, `STRIPE_CONFIG_ENTRIES` |
|
|
608
|
-
| `/paddle` | `PaddleClient`, `PADDLE_API_KEY`, `PADDLE_WEBHOOK_SECRET`, `PADDLE_ENVIRONMENT`, `PADDLE_CONFIG_ENTRIES` |
|
|
609
|
-
| `/lemonsqueezy` | `LemonSqueezyClient`, `LEMONSQUEEZY_API_KEY`, `LEMONSQUEEZY_WEBHOOK_SECRET`, `LEMONSQUEEZY_STORE_ID`, `LEMONSQUEEZY_CONFIG_ENTRIES` |
|
|
610
|
-
| `/mollie` | `MollieClient`, `MOLLIE_API_KEY`, `MOLLIE_WEBHOOK_SECRET`, `MOLLIE_CONFIG_ENTRIES` |
|