@skillsmith/core 2.1.0 → 2.1.2
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/dist/.tsbuildinfo +1 -1
- package/dist/src/analysis/types.d.ts +2 -0
- package/dist/src/analysis/types.d.ts.map +1 -1
- package/dist/src/analysis/types.js +13 -1
- package/dist/src/analysis/types.js.map +1 -1
- package/dist/src/analytics/AnalyticsRepository.d.ts +4 -0
- package/dist/src/analytics/AnalyticsRepository.d.ts.map +1 -1
- package/dist/src/analytics/AnalyticsRepository.js +26 -44
- package/dist/src/analytics/AnalyticsRepository.js.map +1 -1
- package/dist/src/analytics/schema.d.ts +1 -1
- package/dist/src/analytics/schema.d.ts.map +1 -1
- package/dist/src/analytics/schema.js +68 -0
- package/dist/src/analytics/schema.js.map +1 -1
- package/dist/src/api/client.d.ts +33 -29
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +15 -10
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/billing/BillingService.d.ts +139 -0
- package/dist/src/billing/BillingService.d.ts.map +1 -0
- package/dist/src/billing/BillingService.js +393 -0
- package/dist/src/billing/BillingService.js.map +1 -0
- package/dist/src/billing/GDPRComplianceService.d.ts +176 -0
- package/dist/src/billing/GDPRComplianceService.d.ts.map +1 -0
- package/dist/src/billing/GDPRComplianceService.js +361 -0
- package/dist/src/billing/GDPRComplianceService.js.map +1 -0
- package/dist/src/billing/StripeClient.d.ts +177 -0
- package/dist/src/billing/StripeClient.d.ts.map +1 -0
- package/dist/src/billing/StripeClient.js +462 -0
- package/dist/src/billing/StripeClient.js.map +1 -0
- package/dist/src/billing/StripeReconciliationJob.d.ts +95 -0
- package/dist/src/billing/StripeReconciliationJob.d.ts.map +1 -0
- package/dist/src/billing/StripeReconciliationJob.js +405 -0
- package/dist/src/billing/StripeReconciliationJob.js.map +1 -0
- package/dist/src/billing/StripeWebhookHandler.d.ts +92 -0
- package/dist/src/billing/StripeWebhookHandler.d.ts.map +1 -0
- package/dist/src/billing/StripeWebhookHandler.js +409 -0
- package/dist/src/billing/StripeWebhookHandler.js.map +1 -0
- package/dist/src/billing/index.d.ts +18 -0
- package/dist/src/billing/index.d.ts.map +1 -0
- package/dist/src/billing/index.js +19 -0
- package/dist/src/billing/index.js.map +1 -0
- package/dist/src/billing/types.d.ts +266 -0
- package/dist/src/billing/types.d.ts.map +1 -0
- package/dist/src/billing/types.js +23 -0
- package/dist/src/billing/types.js.map +1 -0
- package/dist/src/embeddings/hnsw-store.d.ts +568 -0
- package/dist/src/embeddings/hnsw-store.d.ts.map +1 -0
- package/dist/src/embeddings/hnsw-store.js +805 -0
- package/dist/src/embeddings/hnsw-store.js.map +1 -0
- package/dist/src/embeddings/index.d.ts +2 -0
- package/dist/src/embeddings/index.d.ts.map +1 -1
- package/dist/src/embeddings/index.js +2 -0
- package/dist/src/embeddings/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/learning/PatternStore.d.ts +457 -0
- package/dist/src/learning/PatternStore.d.ts.map +1 -0
- package/dist/src/learning/PatternStore.js +893 -0
- package/dist/src/learning/PatternStore.js.map +1 -0
- package/dist/src/learning/ReasoningBankIntegration.d.ts +403 -0
- package/dist/src/learning/ReasoningBankIntegration.d.ts.map +1 -0
- package/dist/src/learning/ReasoningBankIntegration.js +627 -0
- package/dist/src/learning/ReasoningBankIntegration.js.map +1 -0
- package/dist/src/learning/index.d.ts +15 -0
- package/dist/src/learning/index.d.ts.map +1 -0
- package/dist/src/learning/index.js +15 -0
- package/dist/src/learning/index.js.map +1 -0
- package/dist/src/routing/SONARouter.d.ts +154 -0
- package/dist/src/routing/SONARouter.d.ts.map +1 -0
- package/dist/src/routing/SONARouter.js +679 -0
- package/dist/src/routing/SONARouter.js.map +1 -0
- package/dist/src/routing/index.d.ts +9 -0
- package/dist/src/routing/index.d.ts.map +1 -0
- package/dist/src/routing/index.js +10 -0
- package/dist/src/routing/index.js.map +1 -0
- package/dist/src/routing/types.d.ts +331 -0
- package/dist/src/routing/types.d.ts.map +1 -0
- package/dist/src/routing/types.js +203 -0
- package/dist/src/routing/types.js.map +1 -0
- package/dist/src/scripts/__tests__/scan-imported-skills.test.js +5 -0
- package/dist/src/scripts/__tests__/scan-imported-skills.test.js.map +1 -1
- package/dist/src/security/SkillSandbox.d.ts +156 -0
- package/dist/src/security/SkillSandbox.d.ts.map +1 -0
- package/dist/src/security/SkillSandbox.js +303 -0
- package/dist/src/security/SkillSandbox.js.map +1 -0
- package/dist/src/security/index.d.ts +3 -1
- package/dist/src/security/index.d.ts.map +1 -1
- package/dist/src/security/index.js +5 -1
- package/dist/src/security/index.js.map +1 -1
- package/dist/src/security/rate-limiter/presets.d.ts +12 -0
- package/dist/src/security/rate-limiter/presets.d.ts.map +1 -1
- package/dist/src/security/rate-limiter/presets.js +12 -0
- package/dist/src/security/rate-limiter/presets.js.map +1 -1
- package/dist/src/security/sanitization.d.ts +85 -0
- package/dist/src/security/sanitization.d.ts.map +1 -1
- package/dist/src/security/sanitization.js +133 -0
- package/dist/src/security/sanitization.js.map +1 -1
- package/dist/src/security/scanner/SecurityScanner.d.ts +23 -0
- package/dist/src/security/scanner/SecurityScanner.d.ts.map +1 -1
- package/dist/src/security/scanner/SecurityScanner.js +232 -28
- package/dist/src/security/scanner/SecurityScanner.js.map +1 -1
- package/dist/src/security/scanner/patterns.d.ts +13 -0
- package/dist/src/security/scanner/patterns.d.ts.map +1 -1
- package/dist/src/security/scanner/patterns.js +51 -0
- package/dist/src/security/scanner/patterns.js.map +1 -1
- package/dist/src/security/scanner/types.d.ts +13 -1
- package/dist/src/security/scanner/types.d.ts.map +1 -1
- package/dist/src/security/scanner/weights.d.ts.map +1 -1
- package/dist/src/security/scanner/weights.js +1 -0
- package/dist/src/security/scanner/weights.js.map +1 -1
- package/dist/src/session/SessionManager.d.ts +7 -0
- package/dist/src/session/SessionManager.d.ts.map +1 -1
- package/dist/src/session/SessionManager.js +117 -10
- package/dist/src/session/SessionManager.js.map +1 -1
- package/dist/src/sync/SyncEngine.d.ts.map +1 -1
- package/dist/src/sync/SyncEngine.js +52 -32
- package/dist/src/sync/SyncEngine.js.map +1 -1
- package/dist/src/testing/MultiLLMProvider.d.ts +374 -0
- package/dist/src/testing/MultiLLMProvider.d.ts.map +1 -0
- package/dist/src/testing/MultiLLMProvider.js +720 -0
- package/dist/src/testing/MultiLLMProvider.js.map +1 -0
- package/dist/src/testing/index.d.ts +8 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +9 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/types.d.ts +3 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tests/SecurityScanner.test.js +337 -1
- package/dist/tests/SecurityScanner.test.js.map +1 -1
- package/dist/tests/billing/BillingService.test.d.ts +7 -0
- package/dist/tests/billing/BillingService.test.d.ts.map +1 -0
- package/dist/tests/billing/BillingService.test.js +168 -0
- package/dist/tests/billing/BillingService.test.js.map +1 -0
- package/dist/tests/billing/GDPRCompliance.test.d.ts +7 -0
- package/dist/tests/billing/GDPRCompliance.test.d.ts.map +1 -0
- package/dist/tests/billing/GDPRCompliance.test.js +195 -0
- package/dist/tests/billing/GDPRCompliance.test.js.map +1 -0
- package/dist/tests/billing/StripeReconciliation.test.d.ts +7 -0
- package/dist/tests/billing/StripeReconciliation.test.d.ts.map +1 -0
- package/dist/tests/billing/StripeReconciliation.test.js +266 -0
- package/dist/tests/billing/StripeReconciliation.test.js.map +1 -0
- package/dist/tests/billing/stripe-validators.test.d.ts +7 -0
- package/dist/tests/billing/stripe-validators.test.d.ts.map +1 -0
- package/dist/tests/billing/stripe-validators.test.js +107 -0
- package/dist/tests/billing/stripe-validators.test.js.map +1 -0
- package/dist/tests/embeddings/hnsw-store.test.d.ts +7 -0
- package/dist/tests/embeddings/hnsw-store.test.d.ts.map +1 -0
- package/dist/tests/embeddings/hnsw-store.test.js +295 -0
- package/dist/tests/embeddings/hnsw-store.test.js.map +1 -0
- package/dist/tests/integration/neural/e2e-learning.test.d.ts +17 -0
- package/dist/tests/integration/neural/e2e-learning.test.d.ts.map +1 -0
- package/dist/tests/integration/neural/e2e-learning.test.js +238 -0
- package/dist/tests/integration/neural/e2e-learning.test.js.map +1 -0
- package/dist/tests/integration/neural/helpers.d.ts +132 -0
- package/dist/tests/integration/neural/helpers.d.ts.map +1 -0
- package/dist/tests/integration/neural/helpers.js +287 -0
- package/dist/tests/integration/neural/helpers.js.map +1 -0
- package/dist/tests/integration/neural/personalization.test.d.ts +21 -0
- package/dist/tests/integration/neural/personalization.test.d.ts.map +1 -0
- package/dist/tests/integration/neural/personalization.test.js +304 -0
- package/dist/tests/integration/neural/personalization.test.js.map +1 -0
- package/dist/tests/integration/neural/preference-learner.test.d.ts +23 -0
- package/dist/tests/integration/neural/preference-learner.test.d.ts.map +1 -0
- package/dist/tests/integration/neural/preference-learner.test.js +289 -0
- package/dist/tests/integration/neural/preference-learner.test.js.map +1 -0
- package/dist/tests/integration/neural/privacy.test.d.ts +19 -0
- package/dist/tests/integration/neural/privacy.test.d.ts.map +1 -0
- package/dist/tests/integration/neural/privacy.test.js +249 -0
- package/dist/tests/integration/neural/privacy.test.js.map +1 -0
- package/dist/tests/integration/neural/setup.d.ts +175 -0
- package/dist/tests/integration/neural/setup.d.ts.map +1 -0
- package/dist/tests/integration/neural/setup.js +487 -0
- package/dist/tests/integration/neural/setup.js.map +1 -0
- package/dist/tests/integration/neural/signal-collection.test.d.ts +21 -0
- package/dist/tests/integration/neural/signal-collection.test.d.ts.map +1 -0
- package/dist/tests/integration/neural/signal-collection.test.js +232 -0
- package/dist/tests/integration/neural/signal-collection.test.js.map +1 -0
- package/dist/tests/learning/PatternStore.test.d.ts +8 -0
- package/dist/tests/learning/PatternStore.test.d.ts.map +1 -0
- package/dist/tests/learning/PatternStore.test.js +589 -0
- package/dist/tests/learning/PatternStore.test.js.map +1 -0
- package/dist/tests/learning/ReasoningBankIntegration.test.d.ts +8 -0
- package/dist/tests/learning/ReasoningBankIntegration.test.d.ts.map +1 -0
- package/dist/tests/learning/ReasoningBankIntegration.test.js +269 -0
- package/dist/tests/learning/ReasoningBankIntegration.test.js.map +1 -0
- package/dist/tests/routing/SONARouter.test.d.ts +8 -0
- package/dist/tests/routing/SONARouter.test.d.ts.map +1 -0
- package/dist/tests/routing/SONARouter.test.js +400 -0
- package/dist/tests/routing/SONARouter.test.js.map +1 -0
- package/dist/tests/security/ContinuousSecurity.test.js +10 -12
- package/dist/tests/security/ContinuousSecurity.test.js.map +1 -1
- package/dist/tests/security/SkillSandbox.test.d.ts +8 -0
- package/dist/tests/security/SkillSandbox.test.d.ts.map +1 -0
- package/dist/tests/security/SkillSandbox.test.js +321 -0
- package/dist/tests/security/SkillSandbox.test.js.map +1 -0
- package/dist/tests/sync/SyncEngine.test.js +4 -2
- package/dist/tests/sync/SyncEngine.test.js.map +1 -1
- package/dist/tests/testing/MultiLLMProvider.test.d.ts +14 -0
- package/dist/tests/testing/MultiLLMProvider.test.d.ts.map +1 -0
- package/dist/tests/testing/MultiLLMProvider.test.js +438 -0
- package/dist/tests/testing/MultiLLMProvider.test.js.map +1 -0
- package/package.json +16 -3
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-1062: Stripe Client Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides a type-safe wrapper around the Stripe SDK with:
|
|
5
|
+
* - Customer management
|
|
6
|
+
* - Subscription management
|
|
7
|
+
* - Checkout session creation
|
|
8
|
+
* - Customer portal sessions
|
|
9
|
+
* - Invoice retrieval
|
|
10
|
+
* - Webhook signature verification
|
|
11
|
+
*/
|
|
12
|
+
import Stripe from 'stripe';
|
|
13
|
+
import type { BillingPeriod, CreateCheckoutSessionRequest, CreateCheckoutSessionResponse, CreatePortalSessionRequest, CreatePortalSessionResponse, LicenseTier, StripeCheckoutSessionId, StripeCustomerId, StripePriceId, StripeSubscriptionId, SubscriptionStatus } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Stripe client configuration
|
|
16
|
+
*/
|
|
17
|
+
export interface StripeClientConfig {
|
|
18
|
+
/**
|
|
19
|
+
* Stripe secret key (sk_test_xxx or sk_live_xxx)
|
|
20
|
+
*/
|
|
21
|
+
secretKey: string;
|
|
22
|
+
/**
|
|
23
|
+
* Stripe webhook signing secret (whsec_xxx)
|
|
24
|
+
*/
|
|
25
|
+
webhookSecret: string;
|
|
26
|
+
/**
|
|
27
|
+
* Price ID mappings for each tier
|
|
28
|
+
*/
|
|
29
|
+
prices: TierPriceConfigs;
|
|
30
|
+
/**
|
|
31
|
+
* Base URL for success/cancel redirects
|
|
32
|
+
*/
|
|
33
|
+
appUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Price configurations for all tiers
|
|
37
|
+
*/
|
|
38
|
+
export interface TierPriceConfigs {
|
|
39
|
+
individual: {
|
|
40
|
+
monthly: StripePriceId;
|
|
41
|
+
annual: StripePriceId;
|
|
42
|
+
};
|
|
43
|
+
team: {
|
|
44
|
+
monthly: StripePriceId;
|
|
45
|
+
annual: StripePriceId;
|
|
46
|
+
};
|
|
47
|
+
enterprise: {
|
|
48
|
+
monthly: StripePriceId;
|
|
49
|
+
annual: StripePriceId;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stripe API client wrapper
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const client = new StripeClient({
|
|
58
|
+
* secretKey: process.env.STRIPE_SECRET_KEY!,
|
|
59
|
+
* webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
|
|
60
|
+
* prices: {
|
|
61
|
+
* individual: { monthly: 'price_xxx', annual: 'price_yyy' },
|
|
62
|
+
* team: { monthly: 'price_xxx', annual: 'price_yyy' },
|
|
63
|
+
* enterprise: { monthly: 'price_xxx', annual: 'price_yyy' },
|
|
64
|
+
* },
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* const session = await client.createCheckoutSession({
|
|
68
|
+
* tier: 'team',
|
|
69
|
+
* billingPeriod: 'monthly',
|
|
70
|
+
* seatCount: 5,
|
|
71
|
+
* successUrl: 'https://app.example.com/success',
|
|
72
|
+
* cancelUrl: 'https://app.example.com/cancel',
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare class StripeClient {
|
|
77
|
+
private readonly stripe;
|
|
78
|
+
private readonly webhookSecret;
|
|
79
|
+
private readonly prices;
|
|
80
|
+
private readonly appUrl;
|
|
81
|
+
constructor(config: StripeClientConfig);
|
|
82
|
+
/**
|
|
83
|
+
* Create a new Stripe customer
|
|
84
|
+
*/
|
|
85
|
+
createCustomer(params: {
|
|
86
|
+
email: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
metadata?: Record<string, string>;
|
|
89
|
+
}): Promise<StripeCustomerId>;
|
|
90
|
+
/**
|
|
91
|
+
* Get a Stripe customer by ID
|
|
92
|
+
*/
|
|
93
|
+
getCustomer(customerId: StripeCustomerId): Promise<Stripe.Customer | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Update a Stripe customer
|
|
96
|
+
*/
|
|
97
|
+
updateCustomer(customerId: StripeCustomerId, params: {
|
|
98
|
+
email?: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
metadata?: Record<string, string>;
|
|
101
|
+
}): Promise<Stripe.Customer>;
|
|
102
|
+
/**
|
|
103
|
+
* Create a Stripe Checkout session for subscription
|
|
104
|
+
*/
|
|
105
|
+
createCheckoutSession(request: CreateCheckoutSessionRequest): Promise<CreateCheckoutSessionResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Retrieve a checkout session
|
|
108
|
+
*/
|
|
109
|
+
getCheckoutSession(sessionId: StripeCheckoutSessionId): Promise<Stripe.Checkout.Session>;
|
|
110
|
+
/**
|
|
111
|
+
* Get a subscription by ID
|
|
112
|
+
*/
|
|
113
|
+
getSubscription(subscriptionId: StripeSubscriptionId): Promise<Stripe.Subscription | null>;
|
|
114
|
+
/**
|
|
115
|
+
* List subscriptions for a customer
|
|
116
|
+
*/
|
|
117
|
+
listSubscriptions(customerId: StripeCustomerId): Promise<Stripe.Subscription[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Update a subscription (tier change or seat count)
|
|
120
|
+
*/
|
|
121
|
+
updateSubscription(subscriptionId: StripeSubscriptionId, params: {
|
|
122
|
+
tier?: LicenseTier;
|
|
123
|
+
billingPeriod?: BillingPeriod;
|
|
124
|
+
seatCount?: number;
|
|
125
|
+
prorate?: boolean;
|
|
126
|
+
}): Promise<Stripe.Subscription>;
|
|
127
|
+
/**
|
|
128
|
+
* Cancel a subscription
|
|
129
|
+
*/
|
|
130
|
+
cancelSubscription(subscriptionId: StripeSubscriptionId, options?: {
|
|
131
|
+
immediately?: boolean;
|
|
132
|
+
feedback?: string;
|
|
133
|
+
}): Promise<Stripe.Subscription>;
|
|
134
|
+
/**
|
|
135
|
+
* Reactivate a canceled subscription (before period end)
|
|
136
|
+
*/
|
|
137
|
+
reactivateSubscription(subscriptionId: StripeSubscriptionId): Promise<Stripe.Subscription>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a Stripe Customer Portal session
|
|
140
|
+
*/
|
|
141
|
+
createPortalSession(request: CreatePortalSessionRequest): Promise<CreatePortalSessionResponse>;
|
|
142
|
+
/**
|
|
143
|
+
* List invoices for a customer
|
|
144
|
+
*/
|
|
145
|
+
listInvoices(customerId: StripeCustomerId, options?: {
|
|
146
|
+
limit?: number;
|
|
147
|
+
startingAfter?: string;
|
|
148
|
+
}): Promise<{
|
|
149
|
+
invoices: Stripe.Invoice[];
|
|
150
|
+
hasMore: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Get a specific invoice
|
|
154
|
+
*/
|
|
155
|
+
getInvoice(invoiceId: string): Promise<Stripe.Invoice | null>;
|
|
156
|
+
/**
|
|
157
|
+
* Get upcoming invoice (preview of next charge)
|
|
158
|
+
*/
|
|
159
|
+
getUpcomingInvoice(customerId: StripeCustomerId): Promise<Stripe.UpcomingInvoice | null>;
|
|
160
|
+
/**
|
|
161
|
+
* Verify and parse a webhook event
|
|
162
|
+
*/
|
|
163
|
+
verifyWebhookSignature(payload: string, signature: string): Stripe.Event;
|
|
164
|
+
/**
|
|
165
|
+
* Get the price ID for a tier and billing period
|
|
166
|
+
*/
|
|
167
|
+
getPriceId(tier: LicenseTier, billingPeriod: BillingPeriod): StripePriceId | null;
|
|
168
|
+
/**
|
|
169
|
+
* Map Stripe subscription status to our status
|
|
170
|
+
*/
|
|
171
|
+
static mapSubscriptionStatus(stripeStatus: Stripe.Subscription.Status): SubscriptionStatus;
|
|
172
|
+
/**
|
|
173
|
+
* Get the underlying Stripe instance (for advanced operations)
|
|
174
|
+
*/
|
|
175
|
+
getStripeInstance(): Stripe;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=StripeClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeClient.d.ts","sourceRoot":"","sources":["../../../src/billing/StripeClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EACV,aAAa,EACb,4BAA4B,EAC5B,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,WAAW,EACX,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AASnB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAA;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA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jB,CAAC;IAaF;;OAEG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAWnE;;OAEG;IACG,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;IAiB9F;;OAEG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK;IAexE;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI;IAajF;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,kBAAkB;IAuB1F;;OAEG;IACH,iBAAiB,IAAI,MAAM;CAG5B"}
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-1062: Stripe Client Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides a type-safe wrapper around the Stripe SDK with:
|
|
5
|
+
* - Customer management
|
|
6
|
+
* - Subscription management
|
|
7
|
+
* - Checkout session creation
|
|
8
|
+
* - Customer portal sessions
|
|
9
|
+
* - Invoice retrieval
|
|
10
|
+
* - Webhook signature verification
|
|
11
|
+
*/
|
|
12
|
+
import Stripe from 'stripe';
|
|
13
|
+
import { createLogger } from '../utils/logger.js';
|
|
14
|
+
import { BillingError } from './types.js';
|
|
15
|
+
const logger = createLogger('StripeClient');
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// StripeClient Class
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Stripe API client wrapper
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const client = new StripeClient({
|
|
25
|
+
* secretKey: process.env.STRIPE_SECRET_KEY!,
|
|
26
|
+
* webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
|
|
27
|
+
* prices: {
|
|
28
|
+
* individual: { monthly: 'price_xxx', annual: 'price_yyy' },
|
|
29
|
+
* team: { monthly: 'price_xxx', annual: 'price_yyy' },
|
|
30
|
+
* enterprise: { monthly: 'price_xxx', annual: 'price_yyy' },
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const session = await client.createCheckoutSession({
|
|
35
|
+
* tier: 'team',
|
|
36
|
+
* billingPeriod: 'monthly',
|
|
37
|
+
* seatCount: 5,
|
|
38
|
+
* successUrl: 'https://app.example.com/success',
|
|
39
|
+
* cancelUrl: 'https://app.example.com/cancel',
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export class StripeClient {
|
|
44
|
+
stripe;
|
|
45
|
+
webhookSecret;
|
|
46
|
+
prices;
|
|
47
|
+
appUrl;
|
|
48
|
+
constructor(config) {
|
|
49
|
+
this.stripe = new Stripe(config.secretKey, {
|
|
50
|
+
apiVersion: '2023-10-16',
|
|
51
|
+
typescript: true,
|
|
52
|
+
});
|
|
53
|
+
this.webhookSecret = config.webhookSecret;
|
|
54
|
+
this.prices = config.prices;
|
|
55
|
+
this.appUrl = config.appUrl ?? 'https://skillsmith.app';
|
|
56
|
+
logger.info('Stripe client initialized');
|
|
57
|
+
}
|
|
58
|
+
// ==========================================================================
|
|
59
|
+
// Customer Management
|
|
60
|
+
// ==========================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Create a new Stripe customer
|
|
63
|
+
*/
|
|
64
|
+
async createCustomer(params) {
|
|
65
|
+
try {
|
|
66
|
+
const customer = await this.stripe.customers.create({
|
|
67
|
+
email: params.email,
|
|
68
|
+
name: params.name,
|
|
69
|
+
metadata: {
|
|
70
|
+
...params.metadata,
|
|
71
|
+
source: 'skillsmith',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
logger.info('Customer created', { customerId: customer.id });
|
|
75
|
+
return customer.id;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
79
|
+
logger.error('Failed to create customer', undefined, {
|
|
80
|
+
errorDetails: errorMsg,
|
|
81
|
+
email: params.email,
|
|
82
|
+
});
|
|
83
|
+
throw new BillingError('Failed to create customer', 'STRIPE_API_ERROR', {
|
|
84
|
+
originalError: errorMsg,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get a Stripe customer by ID
|
|
90
|
+
*/
|
|
91
|
+
async getCustomer(customerId) {
|
|
92
|
+
try {
|
|
93
|
+
const customer = await this.stripe.customers.retrieve(customerId);
|
|
94
|
+
if (customer.deleted) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return customer;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error instanceof Stripe.errors.StripeError && error.code === 'resource_missing') {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Update a Stripe customer
|
|
108
|
+
*/
|
|
109
|
+
async updateCustomer(customerId, params) {
|
|
110
|
+
return this.stripe.customers.update(customerId, params);
|
|
111
|
+
}
|
|
112
|
+
// ==========================================================================
|
|
113
|
+
// Checkout Session
|
|
114
|
+
// ==========================================================================
|
|
115
|
+
/**
|
|
116
|
+
* Create a Stripe Checkout session for subscription
|
|
117
|
+
*/
|
|
118
|
+
async createCheckoutSession(request) {
|
|
119
|
+
const priceId = this.getPriceId(request.tier, request.billingPeriod);
|
|
120
|
+
if (!priceId) {
|
|
121
|
+
throw new BillingError(`No price configured for tier: ${request.tier}`, 'INVALID_TIER', {
|
|
122
|
+
tier: request.tier,
|
|
123
|
+
billingPeriod: request.billingPeriod,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const lineItems = [
|
|
127
|
+
{
|
|
128
|
+
price: priceId,
|
|
129
|
+
quantity: request.seatCount ?? 1,
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
const sessionParams = {
|
|
133
|
+
mode: 'subscription',
|
|
134
|
+
line_items: lineItems,
|
|
135
|
+
success_url: request.successUrl,
|
|
136
|
+
cancel_url: request.cancelUrl,
|
|
137
|
+
metadata: {
|
|
138
|
+
tier: request.tier,
|
|
139
|
+
billingPeriod: request.billingPeriod,
|
|
140
|
+
seatCount: String(request.seatCount ?? 1),
|
|
141
|
+
...request.metadata,
|
|
142
|
+
},
|
|
143
|
+
subscription_data: {
|
|
144
|
+
metadata: {
|
|
145
|
+
tier: request.tier,
|
|
146
|
+
seatCount: String(request.seatCount ?? 1),
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
// Attach to existing customer or create new
|
|
151
|
+
if (request.customerId) {
|
|
152
|
+
sessionParams.customer = request.customerId;
|
|
153
|
+
}
|
|
154
|
+
else if (request.email) {
|
|
155
|
+
sessionParams.customer_email = request.email;
|
|
156
|
+
}
|
|
157
|
+
// Allow seat quantity changes for team/enterprise
|
|
158
|
+
if (request.tier === 'team' || request.tier === 'enterprise') {
|
|
159
|
+
sessionParams.line_items[0].adjustable_quantity = {
|
|
160
|
+
enabled: true,
|
|
161
|
+
minimum: 1,
|
|
162
|
+
maximum: 1000,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const session = await this.stripe.checkout.sessions.create(sessionParams);
|
|
167
|
+
logger.info('Checkout session created', {
|
|
168
|
+
sessionId: session.id,
|
|
169
|
+
tier: request.tier,
|
|
170
|
+
seatCount: request.seatCount,
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
sessionId: session.id,
|
|
174
|
+
url: session.url,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
179
|
+
logger.error('Failed to create checkout session', undefined, { errorDetails: errorMsg });
|
|
180
|
+
throw new BillingError('Failed to create checkout session', 'STRIPE_API_ERROR', {
|
|
181
|
+
originalError: errorMsg,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Retrieve a checkout session
|
|
187
|
+
*/
|
|
188
|
+
async getCheckoutSession(sessionId) {
|
|
189
|
+
return this.stripe.checkout.sessions.retrieve(sessionId, {
|
|
190
|
+
expand: ['subscription', 'customer'],
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// ==========================================================================
|
|
194
|
+
// Subscription Management
|
|
195
|
+
// ==========================================================================
|
|
196
|
+
/**
|
|
197
|
+
* Get a subscription by ID
|
|
198
|
+
*/
|
|
199
|
+
async getSubscription(subscriptionId) {
|
|
200
|
+
try {
|
|
201
|
+
return await this.stripe.subscriptions.retrieve(subscriptionId);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error instanceof Stripe.errors.StripeError && error.code === 'resource_missing') {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* List subscriptions for a customer
|
|
212
|
+
*/
|
|
213
|
+
async listSubscriptions(customerId) {
|
|
214
|
+
const subscriptions = await this.stripe.subscriptions.list({
|
|
215
|
+
customer: customerId,
|
|
216
|
+
status: 'all',
|
|
217
|
+
expand: ['data.default_payment_method'],
|
|
218
|
+
});
|
|
219
|
+
return subscriptions.data;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Update a subscription (tier change or seat count)
|
|
223
|
+
*/
|
|
224
|
+
async updateSubscription(subscriptionId, params) {
|
|
225
|
+
const subscription = await this.getSubscription(subscriptionId);
|
|
226
|
+
if (!subscription) {
|
|
227
|
+
throw new BillingError('Subscription not found', 'SUBSCRIPTION_NOT_FOUND');
|
|
228
|
+
}
|
|
229
|
+
const updateParams = {
|
|
230
|
+
proration_behavior: params.prorate !== false ? 'create_prorations' : 'none',
|
|
231
|
+
};
|
|
232
|
+
// Update price if tier or billing period changed
|
|
233
|
+
if (params.tier && params.billingPeriod) {
|
|
234
|
+
const newPriceId = this.getPriceId(params.tier, params.billingPeriod);
|
|
235
|
+
if (newPriceId) {
|
|
236
|
+
updateParams.items = [
|
|
237
|
+
{
|
|
238
|
+
id: subscription.items.data[0].id,
|
|
239
|
+
price: newPriceId,
|
|
240
|
+
quantity: params.seatCount ?? subscription.items.data[0].quantity,
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
updateParams.metadata = {
|
|
244
|
+
...subscription.metadata,
|
|
245
|
+
tier: params.tier,
|
|
246
|
+
seatCount: String(params.seatCount ?? subscription.items.data[0].quantity),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else if (params.seatCount !== undefined) {
|
|
251
|
+
// Just update seat count
|
|
252
|
+
updateParams.items = [
|
|
253
|
+
{
|
|
254
|
+
id: subscription.items.data[0].id,
|
|
255
|
+
quantity: params.seatCount,
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
updateParams.metadata = {
|
|
259
|
+
...subscription.metadata,
|
|
260
|
+
seatCount: String(params.seatCount),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
const updated = await this.stripe.subscriptions.update(subscriptionId, updateParams);
|
|
265
|
+
logger.info('Subscription updated', { subscriptionId, params });
|
|
266
|
+
return updated;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
270
|
+
logger.error('Failed to update subscription', undefined, {
|
|
271
|
+
errorDetails: errorMsg,
|
|
272
|
+
subscriptionId,
|
|
273
|
+
});
|
|
274
|
+
throw new BillingError('Failed to update subscription', 'STRIPE_API_ERROR', {
|
|
275
|
+
originalError: errorMsg,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Cancel a subscription
|
|
281
|
+
*/
|
|
282
|
+
async cancelSubscription(subscriptionId, options) {
|
|
283
|
+
try {
|
|
284
|
+
if (options?.immediately) {
|
|
285
|
+
return await this.stripe.subscriptions.cancel(subscriptionId, {
|
|
286
|
+
cancellation_details: {
|
|
287
|
+
comment: options.feedback,
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
// Cancel at period end
|
|
293
|
+
return await this.stripe.subscriptions.update(subscriptionId, {
|
|
294
|
+
cancel_at_period_end: true,
|
|
295
|
+
cancellation_details: {
|
|
296
|
+
comment: options?.feedback,
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
303
|
+
logger.error('Failed to cancel subscription', undefined, {
|
|
304
|
+
errorDetails: errorMsg,
|
|
305
|
+
subscriptionId,
|
|
306
|
+
});
|
|
307
|
+
throw new BillingError('Failed to cancel subscription', 'STRIPE_API_ERROR', {
|
|
308
|
+
originalError: errorMsg,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Reactivate a canceled subscription (before period end)
|
|
314
|
+
*/
|
|
315
|
+
async reactivateSubscription(subscriptionId) {
|
|
316
|
+
return this.stripe.subscriptions.update(subscriptionId, {
|
|
317
|
+
cancel_at_period_end: false,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
// ==========================================================================
|
|
321
|
+
// Customer Portal
|
|
322
|
+
// ==========================================================================
|
|
323
|
+
/**
|
|
324
|
+
* Create a Stripe Customer Portal session
|
|
325
|
+
*/
|
|
326
|
+
async createPortalSession(request) {
|
|
327
|
+
try {
|
|
328
|
+
// Need to get Stripe customer ID from our customer ID
|
|
329
|
+
// This assumes customerId is the Stripe customer ID
|
|
330
|
+
const session = await this.stripe.billingPortal.sessions.create({
|
|
331
|
+
customer: request.customerId,
|
|
332
|
+
return_url: request.returnUrl,
|
|
333
|
+
});
|
|
334
|
+
logger.info('Portal session created', { customerId: request.customerId });
|
|
335
|
+
return {
|
|
336
|
+
url: session.url,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
341
|
+
logger.error('Failed to create portal session', undefined, {
|
|
342
|
+
errorDetails: errorMsg,
|
|
343
|
+
customerId: request.customerId,
|
|
344
|
+
});
|
|
345
|
+
throw new BillingError('Failed to create portal session', 'STRIPE_API_ERROR', {
|
|
346
|
+
originalError: errorMsg,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// ==========================================================================
|
|
351
|
+
// Invoice Management
|
|
352
|
+
// ==========================================================================
|
|
353
|
+
/**
|
|
354
|
+
* List invoices for a customer
|
|
355
|
+
*/
|
|
356
|
+
async listInvoices(customerId, options) {
|
|
357
|
+
const invoices = await this.stripe.invoices.list({
|
|
358
|
+
customer: customerId,
|
|
359
|
+
limit: options?.limit ?? 10,
|
|
360
|
+
starting_after: options?.startingAfter,
|
|
361
|
+
});
|
|
362
|
+
return {
|
|
363
|
+
invoices: invoices.data,
|
|
364
|
+
hasMore: invoices.has_more,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get a specific invoice
|
|
369
|
+
*/
|
|
370
|
+
async getInvoice(invoiceId) {
|
|
371
|
+
try {
|
|
372
|
+
return await this.stripe.invoices.retrieve(invoiceId);
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
if (error instanceof Stripe.errors.StripeError && error.code === 'resource_missing') {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
throw error;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Get upcoming invoice (preview of next charge)
|
|
383
|
+
*/
|
|
384
|
+
async getUpcomingInvoice(customerId) {
|
|
385
|
+
try {
|
|
386
|
+
return await this.stripe.invoices.retrieveUpcoming({
|
|
387
|
+
customer: customerId,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
if (error instanceof Stripe.errors.StripeError && error.code === 'invoice_upcoming_none') {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
// ==========================================================================
|
|
398
|
+
// Webhook Handling
|
|
399
|
+
// ==========================================================================
|
|
400
|
+
/**
|
|
401
|
+
* Verify and parse a webhook event
|
|
402
|
+
*/
|
|
403
|
+
verifyWebhookSignature(payload, signature) {
|
|
404
|
+
try {
|
|
405
|
+
return this.stripe.webhooks.constructEvent(payload, signature, this.webhookSecret);
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
408
|
+
logger.warn('Webhook signature verification failed', {
|
|
409
|
+
error: error instanceof Error ? error.message : String(error),
|
|
410
|
+
});
|
|
411
|
+
throw new BillingError('Invalid webhook signature', 'WEBHOOK_SIGNATURE_INVALID');
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
// ==========================================================================
|
|
415
|
+
// Helper Methods
|
|
416
|
+
// ==========================================================================
|
|
417
|
+
/**
|
|
418
|
+
* Get the price ID for a tier and billing period
|
|
419
|
+
*/
|
|
420
|
+
getPriceId(tier, billingPeriod) {
|
|
421
|
+
if (tier === 'community') {
|
|
422
|
+
return null; // Community tier is free, no Stripe price
|
|
423
|
+
}
|
|
424
|
+
const tierPrices = this.prices[tier];
|
|
425
|
+
if (!tierPrices) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
return tierPrices[billingPeriod];
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Map Stripe subscription status to our status
|
|
432
|
+
*/
|
|
433
|
+
static mapSubscriptionStatus(stripeStatus) {
|
|
434
|
+
switch (stripeStatus) {
|
|
435
|
+
case 'active':
|
|
436
|
+
return 'active';
|
|
437
|
+
case 'past_due':
|
|
438
|
+
return 'past_due';
|
|
439
|
+
case 'canceled':
|
|
440
|
+
return 'canceled';
|
|
441
|
+
case 'trialing':
|
|
442
|
+
return 'trialing';
|
|
443
|
+
case 'paused':
|
|
444
|
+
return 'paused';
|
|
445
|
+
case 'incomplete':
|
|
446
|
+
return 'incomplete';
|
|
447
|
+
case 'incomplete_expired':
|
|
448
|
+
return 'incomplete_expired';
|
|
449
|
+
case 'unpaid':
|
|
450
|
+
return 'unpaid';
|
|
451
|
+
default:
|
|
452
|
+
return 'active';
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Get the underlying Stripe instance (for advanced operations)
|
|
457
|
+
*/
|
|
458
|
+
getStripeInstance() {
|
|
459
|
+
return this.stripe;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=StripeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeClient.js","sourceRoot":"","sources":["../../../src/billing/StripeClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAcjD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AAiD3C,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,YAAY;IACN,MAAM,CAAQ;IACd,aAAa,CAAQ;IACrB,MAAM,CAAkB;IACxB,MAAM,CAAQ;IAE/B,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;YACzC,UAAU,E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