@23blocks/sdk 6.6.12 → 6.7.0

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 (2) hide show
  1. package/llms.txt +115 -4
  2. package/package.json +1 -1
package/llms.txt CHANGED
@@ -36,7 +36,7 @@ The SDK is organized as independent npm packages:
36
36
 
37
37
  ```
38
38
  @23blocks/sdk Meta-package re-exporting all blocks + client factory
39
- @23blocks/contracts Core types: Transport, BlockConfig, IdentityCore, PageResult, ListParams
39
+ @23blocks/contracts Core types: Transport, BlockConfig, HealthCheckResponse, IdentityCore, PageResult, ListParams
40
40
  @23blocks/jsonapi-codec JSON:API v1.0 encoder/decoder
41
41
  @23blocks/transport-http HTTP transport implementation (fetch-based)
42
42
  @23blocks/block-* 18 feature blocks (Promise-based, framework-agnostic)
@@ -99,6 +99,19 @@ interface ListParams {
99
99
  }
100
100
  ```
101
101
 
102
+ ### HealthCheckResponse
103
+
104
+ Every block exposes a `health()` method that pings the service's `GET /health` endpoint (plain JSON, not JSON:API):
105
+
106
+ ```typescript
107
+ interface HealthCheckResponse {
108
+ service: string; // e.g. "auth", "crm", "search"
109
+ status: string; // e.g. "ok"
110
+ version: string; // e.g. "v4.4.0"
111
+ timestamp: string; // ISO 8601
112
+ }
113
+ ```
114
+
102
115
  ### EntityStatus
103
116
 
104
117
  ```typescript
@@ -156,6 +169,80 @@ const user = await client.users.updateProfile(userUniqueId, {
156
169
  // Access updated profile: user.profile?.firstName === 'Jane'
157
170
  ```
158
171
 
172
+ ## Stripe Integration (block-sales)
173
+
174
+ ### Identity Types
175
+
176
+ Stripe operations support three identity types for multi-entity billing:
177
+
178
+ ```typescript
179
+ // User (B2C) - default when identityType omitted
180
+ await client.sales.stripe.createCustomer({
181
+ email: 'john@example.com',
182
+ userUniqueId: 'user-uuid',
183
+ });
184
+
185
+ // Company (B2B)
186
+ await client.sales.stripe.createCustomer({
187
+ identityType: 'customer',
188
+ email: 'billing@acme.com',
189
+ companyUniqueId: 'company-uuid',
190
+ });
191
+
192
+ // Entity (AI agent / autonomous system)
193
+ await client.sales.stripe.createCustomer({
194
+ identityType: 'entity',
195
+ entityUniqueId: 'entity-uuid',
196
+ entityType: 'Bot',
197
+ });
198
+ ```
199
+
200
+ ### Checkout Sessions
201
+
202
+ ```typescript
203
+ const session = await client.sales.stripe.createCheckoutSession({
204
+ successUrl: 'https://app.example.com/success',
205
+ cancelUrl: 'https://app.example.com/cancel',
206
+ mode: 'subscription', // 'payment' | 'subscription' | 'setup'
207
+ subscriptionModelCode: 'pro-plan',
208
+ allowPromotionCodes: true, // Enable Stripe promo code input
209
+ couponId: 'WELCOME20', // Pre-apply a coupon
210
+ identityType: 'user',
211
+ });
212
+ // session.url -> redirect user to Stripe checkout
213
+ // session.id -> use to verify later
214
+
215
+ // Verify a completed session
216
+ const verified = await client.sales.stripe.verifySession(session.id);
217
+ ```
218
+
219
+ ### Payment Intents
220
+
221
+ **Note:** `amount` is NOT a parameter. The server derives payment amount from the order's balance.
222
+
223
+ ```typescript
224
+ const intent = await client.sales.stripe.createPaymentIntent({
225
+ orderUniqueId: 'order-uuid', // Required - amount derived from order.balance
226
+ currency: 'usd',
227
+ customerId: 'cus_stripe_id',
228
+ });
229
+ // intent.clientSecret -> use with Stripe.js to confirm payment
230
+ ```
231
+
232
+ ### Purchases (Gateway-Agnostic)
233
+
234
+ Single-call purchase that creates Order + Payment + Subscription:
235
+
236
+ ```typescript
237
+ const purchase = await client.sales.purchases.create({
238
+ subscriptionModelCode: 'free-plan',
239
+ identityType: 'user',
240
+ userUniqueId: 'user-uuid',
241
+ gateway: 'stripe', // or 'mercadopago', or omit for free
242
+ gatewayTransactionId: 'pi_xxx', // Stripe payment intent ID
243
+ });
244
+ ```
245
+
159
246
  ## Common Gotchas
160
247
 
161
248
  1. **No PATCH method.** The 23blocks API only supports PUT for updates. Never use PATCH.
@@ -166,6 +253,8 @@ const user = await client.users.updateProfile(userUniqueId, {
166
253
  6. **`create()` on ApiKeysService returns `ApiKeyWithSecret`.** The secret is only available once at creation time.
167
254
  7. **Service URLs are per-microservice.** Each block connects to its own backend URL.
168
255
  8. **Accessing unconfigured services throws.** If you didn't provide `urls.crm`, accessing `client.crm` throws an error.
256
+ 9. **Stripe `createPaymentIntent` has no `amount` param.** The server derives amount from the order's balance. Pass `orderUniqueId` instead.
257
+ 10. **`purchases.create()` is a single-call shortcut.** Use it for free plan activations or server-confirmed purchases instead of the multi-step register + subscribe + checkout flow.
169
258
 
170
259
  ## Error Handling
171
260
 
@@ -205,6 +294,26 @@ The client provides:
205
294
  - `client.{blockName}` - All other blocks
206
295
  - `client.getAccessToken()`, `client.setTokens()`, `client.clearSession()` - Token utilities
207
296
 
297
+ ## Health Check
298
+
299
+ Every block has a `health()` method to verify service connectivity:
300
+
301
+ ```typescript
302
+ // Via client factory
303
+ const status = await client.authentication.health();
304
+ // { service: "auth", status: "ok", version: "v4.4.0", timestamp: "2026-02-16T23:19:52Z" }
305
+
306
+ // Via standalone block
307
+ const auth = createAuthenticationBlock(transport, config);
308
+ const status = await auth.health();
309
+
310
+ // Check multiple services
311
+ const [authHealth, crmHealth] = await Promise.all([
312
+ client.authentication.health(),
313
+ client.crm.health(),
314
+ ]);
315
+ ```
316
+
208
317
  ## All 18 Blocks and Their Sub-Services
209
318
 
210
319
  ### authentication (block-authentication)
@@ -367,10 +476,12 @@ The client provides:
367
476
  - `orders`, `orderDetails`, `orderTaxes` - Order management
368
477
  - `payments` - Payment processing
369
478
  - `subscriptions`, `subscriptionModels` - Recurring billing
370
- - `entities`, `users`, `customers` - Sales entities
479
+ - `entities`, `users`, `customers` - Sales entities with subscription management
371
480
  - `flexibleOrders` - Custom order workflows
372
- - `stripe`, `mercadopago` - Payment gateway integrations
373
- - `vendorPayments` - Vendor payment management
481
+ - `stripe` - Stripe integration (customers, checkout sessions, payment intents, subscriptions, webhooks, customer portal)
482
+ - `mercadopago` - MercadoPago integration (payment methods, payment intents, PSE bank transfers)
483
+ - `vendorPayments` - Vendor payment management with reporting (payment reports, provider reports)
484
+ - `purchases` - Gateway-agnostic single-call purchases (creates Order + Payment + Subscription in one call)
374
485
 
375
486
  ### wallet (block-wallet)
376
487
  - `wallets` - Digital wallet management
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@23blocks/sdk",
3
- "version": "6.6.12",
3
+ "version": "6.7.0",
4
4
  "description": "23blocks SDK - unified meta-package re-exporting all blocks and utilities",
5
5
  "license": "MIT",
6
6
  "author": "23blocks <hello@23blocks.com>",