@bloque/sdk 0.0.1 → 0.0.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/README.md CHANGED
@@ -1,46 +1,56 @@
1
- # Bloque Payments SDK
1
+ # Bloque SDK
2
2
 
3
- The official TypeScript/JavaScript SDK for integrating [Bloque](https://www.bloque.app) payments into your applications.
3
+ The official TypeScript/JavaScript SDK for integrating [Bloque](https://www.bloque.app) into your applications.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - **TypeScript First**: Built with TypeScript for complete type safety
8
- - **Simple API**: Intuitive interface for creating and managing checkouts
9
- - **Multiple Payment Methods**: Support for cards, PSE, and cash payments
8
+ - **Simple API**: Intuitive interface for managing organizations
10
9
  - **Fully Async**: Promise-based API for modern JavaScript workflows
11
10
  - **Lightweight**: Minimal dependencies for optimal bundle size
11
+ - **Modular**: Import only what you need with tree-shakeable exports
12
12
 
13
13
  ## Installation
14
14
 
15
15
  ```bash
16
- bun add @bloque/payments
16
+ bun add @bloque/sdk
17
17
  ```
18
18
 
19
19
  ## Quick Start
20
20
 
21
21
  ```typescript
22
- import { Bloque, type PaymentSubmitPayload } from '@bloque/payments';
22
+ import { SDK } from '@bloque/sdk';
23
+ import type { CreateOrgParams } from '@bloque/sdk/orgs';
23
24
 
24
25
  // Initialize the SDK (server-side only)
25
- const bloque = new Bloque({
26
+ const bloque = new SDK({
26
27
  apiKey: process.env.BLOQUE_API_KEY!,
27
- server: 'production', // or 'sandbox' for testing
28
+ mode: 'production', // or 'sandbox' for testing
28
29
  });
29
30
 
30
- app.post('/api/payments', async (req, res) => {
31
- try {
32
- const payload: PaymentSubmitPayload = req.body;
33
-
34
- // Create payment using SDK
35
- const payment = await bloque.payments.create({
36
- payment: payload,
37
- });
31
+ // Create an organization
32
+ async function createOrganization() {
33
+ const params: CreateOrgParams = {
34
+ org_type: 'business',
35
+ profile: {
36
+ legal_name: 'Acme Corporation',
37
+ tax_id: '123456789',
38
+ incorporation_date: '2020-01-01',
39
+ business_type: 'llc',
40
+ incorporation_country_code: 'US',
41
+ incorporation_state: 'CA',
42
+ address_line1: '123 Main St',
43
+ postal_code: '12345',
44
+ city: 'San Francisco',
45
+ },
46
+ metadata: {
47
+ source: 'api',
48
+ },
49
+ };
38
50
 
39
- res.json({ success: true, payment });
40
- } catch (error) {
41
- res.status(500).json({ success: false, error: error.message });
42
- }
43
- });
51
+ const organization = await bloque.orgs.create(params);
52
+ console.log('Organization created:', organization);
53
+ }
44
54
  ```
45
55
 
46
56
  ## Configuration
@@ -48,366 +58,236 @@ app.post('/api/payments', async (req, res) => {
48
58
  ### Initialize the SDK
49
59
 
50
60
  ```typescript
51
- import { Bloque } from '@bloque/payments';
61
+ import { SDK } from '@bloque/sdk';
62
+ import type { BloqueConfig } from '@bloque/sdk';
52
63
 
53
- const bloque = new Bloque({
64
+ const bloque = new SDK({
54
65
  apiKey: 'your-api-key-here', // Required: Your Bloque API key
55
- server: 'sandbox', // Required: 'sandbox' or 'production'
66
+ mode: 'sandbox', // Required: 'sandbox' or 'production'
56
67
  });
57
68
  ```
58
69
 
59
- ### Environment Options
70
+ ### Configuration Options
60
71
 
61
- - **`sandbox`**: For testing and development
62
- - **`production`**: For live payments
72
+ - **`apiKey`** (string, required): Your Bloque API key
73
+ - **`mode`** ('sandbox' | 'production', required): Environment mode
74
+ - `sandbox`: For testing and development
75
+ - `production`: For live operations
63
76
 
64
77
  ## API Reference
65
78
 
66
- ### Payments
79
+ ### Organizations
67
80
 
68
- The payments resource allows you to create payments for existing checkout sessions.
81
+ The organizations resource allows you to create and manage organizations in the Bloque platform.
69
82
 
70
- #### Create a Payment
83
+ #### Create an Organization
71
84
 
72
85
  ```typescript
73
- const payment = await bloque.payments.create({
74
- checkoutId: string; // Required: Checkout ID from an existing checkout
75
- payment: {
76
- type: 'card' | 'pse' | 'cash',
77
- data: {
78
- // Payment method specific data
79
- }
80
- }
81
- });
86
+ const organization = await bloque.orgs.create(params);
82
87
  ```
83
88
 
84
- **Payment Types**:
85
-
86
- **Card Payment**:
87
- ```typescript
88
- {
89
- type: 'card',
90
- data: {
91
- cardNumber: string; // 16-digit card number
92
- cardholderName: string; // Name on the card
93
- expiryMonth: string; // MM format
94
- expiryYear: string; // YY or YYYY format
95
- cvv: string; // 3-4 digit CVV
96
- email?: string; // Optional customer email
97
- }
98
- }
99
- ```
100
-
101
- **PSE Payment** (Colombian online banking):
102
- ```typescript
103
- {
104
- type: 'pse',
105
- data: {
106
- personType: 'natural' | 'juridica'; // Person type
107
- documentType: string; // Document type (e.g., 'CC', 'NIT')
108
- documentNumber: string; // Document number
109
- bankCode: string; // Bank code
110
- email: string; // Customer email
111
- }
112
- }
113
- ```
89
+ **Parameters**:
114
90
 
115
- **Cash Payment**:
116
91
  ```typescript
117
- {
118
- type: 'cash',
119
- data: {
120
- email: string; // Customer email
121
- documentType: string; // Document type
122
- documentNumber: string; // Document number
123
- fullName: string; // Full name
124
- }
92
+ interface CreateOrgParams {
93
+ org_type: 'business' | 'individual'; // Organization type
94
+ profile: OrgProfile; // Organization profile details
95
+ metadata?: Record<string, unknown>; // Optional custom metadata
125
96
  }
126
- ```
127
97
 
128
- **Payment Response**:
129
- ```typescript
130
- {
131
- id: string; // Payment ID
132
- object: 'payment'; // Object type
133
- status: 'pending' | 'processing' | 'completed' | 'failed';
134
- checkout: Checkout; // Associated checkout
135
- payment_method: 'card' | 'pse' | 'cash';
136
- amount: number; // Payment amount
137
- currency: string; // Currency
138
- created_at: string; // Creation timestamp
139
- updated_at: string; // Last update timestamp
98
+ interface OrgProfile {
99
+ legal_name: string; // Legal name of the organization
100
+ tax_id: string; // Tax ID number
101
+ incorporation_date: string; // Date of incorporation (YYYY-MM-DD)
102
+ business_type: string; // Type of business (e.g., 'llc', 'corporation')
103
+ incorporation_country_code: string; // Country code (ISO 3166-1 alpha-2)
104
+ incorporation_state?: string; // State/province (optional)
105
+ address_line1: string; // Primary address line
106
+ address_line2?: string; // Secondary address line (optional)
107
+ postal_code: string; // Postal/ZIP code
108
+ city: string; // City
109
+ logo_url?: string; // Logo URL (optional)
110
+ places?: Place[]; // Additional places/locations (optional)
140
111
  }
141
- ```
142
-
143
- ### Checkout
144
-
145
- The checkout resource allows you to create payment sessions.
146
-
147
- #### Create a Checkout
148
112
 
149
- ```typescript
150
- const checkout = await bloque.checkout.create({
151
- name: string; // Required: Name of the checkout
152
- description?: string; // Optional: Description
153
- image_url?: string; // Optional: Product/checkout image URL
154
- items: CheckoutItem[]; // Required: Items to be purchased
155
- success_url: string; // Required: Redirect URL after success
156
- cancel_url: string; // Required: Redirect URL after cancellation
157
- metadata?: Record<string, string | number | boolean>; // Optional: Custom metadata
158
- expires_at?: string; // Optional: Expiration date (ISO 8601)
159
- });
160
- ```
161
-
162
- **Checkout Item**:
163
- ```typescript
164
- {
165
- name: string; // Item name
166
- amount: number; // Price in smallest currency unit (e.g., cents)
167
- quantity: number; // Quantity
168
- image_url?: string; // Item image URL
113
+ interface Place {
114
+ country_code: string; // Country code
115
+ state: string; // State/province
116
+ address_line1: string; // Address line 1
117
+ postal_code: string; // Postal code
118
+ city: string; // City
119
+ is_primary: boolean; // Whether this is the primary place
169
120
  }
170
121
  ```
171
122
 
172
- #### Checkout Response
123
+ **Response**:
173
124
 
174
125
  ```typescript
175
- {
176
- id: string; // Unique checkout identifier
177
- object: 'checkout'; // Object type
178
- url: string; // Public payment URL for the customer
179
- status: string; // Current checkout status
180
- amount_total: number; // Total amount
181
- amount_subtotal: number; // Subtotal amount
182
- currency: 'USD'; // Currency
183
- items: CheckoutItem[]; // Items in the checkout
184
- metadata?: Metadata; // Custom metadata
185
- created_at: string; // Creation timestamp (ISO 8601)
186
- updated_at: string; // Last update timestamp (ISO 8601)
187
- expires_at: string; // Expiration timestamp (ISO 8601)
126
+ interface Organization {
127
+ urn: string; // Unique resource name
128
+ org_type: 'business' | 'individual'; // Organization type
129
+ profile: OrgProfile; // Organization profile
130
+ metadata?: Record<string, unknown>; // Custom metadata
131
+ status: OrgStatus; // Organization status
188
132
  }
189
- ```
190
-
191
- #### Retrieve a Checkout
192
-
193
- Retrieve the details of an existing checkout by its ID.
194
133
 
195
- ```typescript
196
- const checkout = await bloque.checkout.retrieve('checkout_id_here');
134
+ type OrgStatus =
135
+ | 'awaiting_compliance_verification'
136
+ | 'active'
137
+ | 'suspended'
138
+ | 'closed';
197
139
  ```
198
140
 
199
- **Parameters**:
200
- - `checkoutId` (string): The ID of the checkout to retrieve
201
-
202
- **Returns**: A `Checkout` object with all the checkout details.
203
-
204
- #### Cancel a Checkout
205
-
206
- Cancel an existing checkout that hasn't been completed yet.
207
-
208
- ```typescript
209
- const checkout = await bloque.checkout.cancel('checkout_id_here');
210
- ```
211
-
212
- **Parameters**:
213
- - `checkoutId` (string): The ID of the checkout to cancel
214
-
215
- **Returns**: A `Checkout` object with updated status reflecting the cancellation.
216
-
217
141
  ## Examples
218
142
 
219
- ### Processing Payments
143
+ ### Creating a Business Organization
220
144
 
221
145
  ```typescript
222
- import { Bloque, type PaymentSubmitPayload } from '@bloque/payments';
146
+ import { SDK } from '@bloque/sdk';
147
+ import type { CreateOrgParams } from '@bloque/sdk/orgs';
223
148
 
224
149
  // Initialize SDK with your API key
225
- const bloque = new Bloque({
150
+ const bloque = new SDK({
226
151
  apiKey: process.env.BLOQUE_API_KEY!,
227
- server: 'production',
152
+ mode: 'production',
228
153
  });
229
154
 
230
- // API endpoint handler
231
- app.post('/api/payments', async (req, res) => {
232
- try {
233
- // Receive payment data from frontend
234
- const payload: PaymentSubmitPayload = req.body;
235
-
236
- // Create payment using SDK
237
- const payment = await bloque.payments.create({
238
- payment: payload,
239
- });
155
+ // Create a business organization
156
+ const params: CreateOrgParams = {
157
+ org_type: 'business',
158
+ profile: {
159
+ legal_name: 'Acme Corporation',
160
+ tax_id: '12-3456789',
161
+ incorporation_date: '2020-01-15',
162
+ business_type: 'llc',
163
+ incorporation_country_code: 'US',
164
+ incorporation_state: 'CA',
165
+ address_line1: '123 Market Street',
166
+ address_line2: 'Suite 400',
167
+ postal_code: '94103',
168
+ city: 'San Francisco',
169
+ logo_url: 'https://example.com/logo.png',
170
+ },
171
+ metadata: {
172
+ source: 'web_app',
173
+ campaign: 'q1_2024',
174
+ },
175
+ };
240
176
 
241
- res.json({ success: true, payment });
242
- } catch (error) {
243
- res.status(500).json({ success: false, error: error.message });
244
- }
245
- });
177
+ try {
178
+ const organization = await bloque.orgs.create(params);
179
+ console.log('Organization created:', organization.urn);
180
+ console.log('Status:', organization.status);
181
+ } catch (error) {
182
+ console.error('Failed to create organization:', error);
183
+ }
246
184
  ```
247
185
 
248
- ### Payment Methods Examples
249
-
250
- #### Card Payment
186
+ ### Creating an Individual Organization
251
187
 
252
188
  ```typescript
253
- // Receive payload from frontend
254
- const cardPayment: PaymentSubmitPayload = req.body;
255
- // Example payload:
256
- // {
257
- // type: 'card',
258
- // data: {
259
- // cardNumber: '4111111111111111',
260
- // cardholderName: 'John Doe',
261
- // expiryMonth: '12',
262
- // expiryYear: '2025',
263
- // cvv: '123',
264
- // email: 'john@example.com'
265
- // }
266
- // }
267
-
268
- const payment = await bloque.payments.create({
269
- payment: cardPayment,
270
- });
271
- ```
272
-
273
- #### PSE Payment (Colombian online banking)
189
+ import { SDK } from '@bloque/sdk';
190
+ import type { CreateOrgParams } from '@bloque/sdk/orgs';
274
191
 
275
- ```typescript
276
- // Receive payload from frontend
277
- const psePayment: PaymentSubmitPayload = req.body;
278
- // Example payload:
279
- // {
280
- // type: 'pse',
281
- // data: {
282
- // personType: 'natural',
283
- // documentType: 'CC',
284
- // documentNumber: '1234567890',
285
- // bankCode: '1022',
286
- // email: 'maria@example.com'
287
- // }
288
- // }
289
-
290
- const payment = await bloque.payments.create({
291
- payment: psePayment,
192
+ const bloque = new SDK({
193
+ apiKey: process.env.BLOQUE_API_KEY!,
194
+ mode: 'sandbox',
292
195
  });
293
- ```
294
196
 
295
- #### Cash Payment
197
+ const params: CreateOrgParams = {
198
+ org_type: 'individual',
199
+ profile: {
200
+ legal_name: 'John Doe',
201
+ tax_id: '123-45-6789',
202
+ incorporation_date: '1990-05-20',
203
+ business_type: 'sole_proprietorship',
204
+ incorporation_country_code: 'US',
205
+ address_line1: '456 Oak Avenue',
206
+ postal_code: '10001',
207
+ city: 'New York',
208
+ },
209
+ };
296
210
 
297
- ```typescript
298
- // Receive payload from frontend
299
- const cashPayment: PaymentSubmitPayload = req.body;
300
- // Example payload:
301
- // {
302
- // type: 'cash',
303
- // data: {
304
- // email: 'carlos@example.com',
305
- // documentType: 'CC',
306
- // documentNumber: '9876543210',
307
- // fullName: 'Carlos García'
308
- // }
309
- // }
310
-
311
- const payment = await bloque.payments.create({
312
- payment: cashPayment,
313
- });
211
+ const organization = await bloque.orgs.create(params);
212
+ console.log('Individual organization created:', organization);
314
213
  ```
315
214
 
316
- ### Type-Safe Payment Creation
317
-
318
- The `PaymentSubmitPayload` type is a discriminated union that provides automatic type narrowing:
215
+ ### Organization with Multiple Locations
319
216
 
320
217
  ```typescript
321
- // Backend API handler
322
- async function handlePayment(payload: PaymentSubmitPayload) {
323
- // TypeScript automatically narrows the type based on the 'type' field
324
- switch (payload.type) {
325
- case 'card':
326
- // payload.data is CardPaymentFormData
327
- console.log('Processing card ending in:', payload.data.cardNumber.slice(-4));
328
- break;
329
-
330
- case 'pse':
331
- // payload.data is PSEPaymentFormData
332
- console.log('Processing PSE for bank:', payload.data.bankCode);
333
- break;
334
-
335
- case 'cash':
336
- // payload.data is CashPaymentFormData
337
- console.log('Processing cash payment for:', payload.data.fullName);
338
- break;
339
- }
218
+ import { SDK } from '@bloque/sdk';
219
+ import type { CreateOrgParams } from '@bloque/sdk/orgs';
340
220
 
341
- // Create payment using SDK
342
- return await bloque.payments.create({
343
- payment: payload,
344
- });
345
- }
346
- ```
221
+ const bloque = new SDK({
222
+ apiKey: process.env.BLOQUE_API_KEY!,
223
+ mode: 'production',
224
+ });
347
225
 
348
- ### Basic Checkout with Single Item
226
+ const params: CreateOrgParams = {
227
+ org_type: 'business',
228
+ profile: {
229
+ legal_name: 'Global Tech Solutions Inc.',
230
+ tax_id: '98-7654321',
231
+ incorporation_date: '2018-03-10',
232
+ business_type: 'corporation',
233
+ incorporation_country_code: 'US',
234
+ incorporation_state: 'DE',
235
+ address_line1: '789 Corporate Blvd',
236
+ postal_code: '19801',
237
+ city: 'Wilmington',
238
+ places: [
239
+ {
240
+ country_code: 'US',
241
+ state: 'CA',
242
+ address_line1: '100 Silicon Valley Drive',
243
+ postal_code: '94025',
244
+ city: 'Menlo Park',
245
+ is_primary: true,
246
+ },
247
+ {
248
+ country_code: 'US',
249
+ state: 'NY',
250
+ address_line1: '250 Broadway',
251
+ postal_code: '10007',
252
+ city: 'New York',
253
+ is_primary: false,
254
+ },
255
+ ],
256
+ },
257
+ };
349
258
 
350
- ```typescript
351
- const checkout = await bloque.checkout.create({
352
- name: 'E-book Purchase',
353
- description: 'Learn TypeScript in 30 Days',
354
- items: [
355
- {
356
- name: 'TypeScript E-book',
357
- amount: 19_99,
358
- quantity: 1,
359
- },
360
- ],
361
- success_url: 'https://yourapp.com/success',
362
- cancel_url: 'https://yourapp.com/cancel',
363
- });
259
+ const organization = await bloque.orgs.create(params);
260
+ console.log('Multi-location organization created');
364
261
  ```
365
262
 
366
- ### Checkout with Multiple Items
263
+ ### Using in an API Endpoint
367
264
 
368
265
  ```typescript
369
- const checkout = await bloque.checkout.create({
370
- name: 'Shopping Cart',
371
- description: 'Your selected items',
372
- items: [
373
- {
374
- name: 'Wireless Mouse',
375
- amount: 25_00,
376
- quantity: 1,
377
- image_url: 'https://example.com/mouse.jpg',
378
- },
379
- {
380
- name: 'USB Cable',
381
- amount: 10_00,
382
- quantity: 2,
383
- image_url: 'https://example.com/cable.jpg',
384
- },
385
- ],
386
- success_url: 'https://yourapp.com/success',
387
- cancel_url: 'https://yourapp.com/cancel',
266
+ import { SDK } from '@bloque/sdk';
267
+ import type { CreateOrgParams } from '@bloque/sdk/orgs';
268
+
269
+ const bloque = new SDK({
270
+ apiKey: process.env.BLOQUE_API_KEY!,
271
+ mode: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',
388
272
  });
389
- ```
390
273
 
391
- ### Checkout with Metadata and Expiration
274
+ app.post('/api/organizations', async (req, res) => {
275
+ try {
276
+ const params: CreateOrgParams = req.body;
392
277
 
393
- ```typescript
394
- const checkout = await bloque.checkout.create({
395
- name: 'Limited Time Offer',
396
- items: [
397
- {
398
- name: 'Premium Course',
399
- amount: 99_00,
400
- quantity: 1,
401
- },
402
- ],
403
- success_url: 'https://yourapp.com/success',
404
- cancel_url: 'https://yourapp.com/cancel',
405
- metadata: {
406
- user_id: '12345',
407
- campaign: 'summer_sale',
408
- discount_applied: true,
409
- },
410
- expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), // 24 hours
278
+ const organization = await bloque.orgs.create(params);
279
+
280
+ res.json({
281
+ success: true,
282
+ organization,
283
+ });
284
+ } catch (error) {
285
+ console.error('Organization creation failed:', error);
286
+ res.status(500).json({
287
+ success: false,
288
+ error: error instanceof Error ? error.message : 'Unknown error',
289
+ });
290
+ }
411
291
  });
412
292
  ```
413
293
 
@@ -417,15 +297,34 @@ const checkout = await bloque.checkout.create({
417
297
  The SDK uses standard JavaScript errors. Always wrap API calls in try-catch blocks:
418
298
 
419
299
  ```typescript
300
+ import { SDK } from '@bloque/sdk';
301
+
302
+ const bloque = new SDK({
303
+ apiKey: process.env.BLOQUE_API_KEY!,
304
+ mode: 'production',
305
+ });
306
+
420
307
  try {
421
- const checkout = await bloque.checkout.create({
422
- name: 'Product',
423
- items: [{ name: 'Item', amount: 1000, quantity: 1 }],
424
- success_url: 'https://yourapp.com/success',
425
- cancel_url: 'https://yourapp.com/cancel',
308
+ const organization = await bloque.orgs.create({
309
+ org_type: 'business',
310
+ profile: {
311
+ legal_name: 'Acme Corp',
312
+ tax_id: '123456789',
313
+ incorporation_date: '2020-01-01',
314
+ business_type: 'llc',
315
+ incorporation_country_code: 'US',
316
+ address_line1: '123 Main St',
317
+ postal_code: '12345',
318
+ city: 'San Francisco',
319
+ },
426
320
  });
321
+ console.log('Success:', organization);
427
322
  } catch (error) {
428
- console.error('Failed to create checkout:', error);
323
+ if (error instanceof Error) {
324
+ console.error('Failed to create organization:', error.message);
325
+ } else {
326
+ console.error('Unknown error:', error);
327
+ }
429
328
  }
430
329
  ```
431
330
 
@@ -434,61 +333,70 @@ try {
434
333
  This SDK is written in TypeScript and includes complete type definitions. You'll get full autocomplete and type checking when using TypeScript or modern editors like VS Code:
435
334
 
436
335
  ```typescript
336
+ import { SDK } from '@bloque/sdk';
437
337
  import type {
438
- // Payment types
439
- PaymentSubmitPayload,
440
- PaymentResponse,
441
- CreatePaymentParams,
442
- // Checkout types
443
- Checkout,
444
- CheckoutStatus,
445
- CheckoutItem,
446
- CheckoutParams,
447
- } from '@bloque/payments';
448
-
449
- const item: CheckoutItem = {
450
- name: 'Product',
451
- amount: 5000,
452
- quantity: 1,
338
+ BloqueConfig,
339
+ CreateOrgParams,
340
+ Organization,
341
+ OrgProfile,
342
+ OrgStatus,
343
+ OrgType,
344
+ Place,
345
+ } from '@bloque/sdk/orgs';
346
+
347
+ // Type-safe configuration
348
+ const config: BloqueConfig = {
349
+ apiKey: 'your-api-key',
350
+ mode: 'sandbox',
453
351
  };
454
352
 
455
- // Type-safe payment data
456
- const cardPayment: PaymentSubmitPayload = {
457
- type: 'card',
458
- data: {
459
- cardNumber: '4111111111111111',
460
- cardholderName: 'John Doe',
461
- expiryMonth: '12',
462
- expiryYear: '2025',
463
- cvv: '123',
353
+ const bloque = new SDK(config);
354
+
355
+ // Type-safe organization profile
356
+ const profile: OrgProfile = {
357
+ legal_name: 'Tech Startup Inc.',
358
+ tax_id: '12-3456789',
359
+ incorporation_date: '2023-01-15',
360
+ business_type: 'llc',
361
+ incorporation_country_code: 'US',
362
+ incorporation_state: 'CA',
363
+ address_line1: '456 Innovation Dr',
364
+ postal_code: '94025',
365
+ city: 'Menlo Park',
366
+ };
367
+
368
+ // Type-safe organization creation
369
+ const params: CreateOrgParams = {
370
+ org_type: 'business',
371
+ profile,
372
+ metadata: {
373
+ vertical: 'fintech',
374
+ employees: 50,
464
375
  },
465
376
  };
377
+
378
+ // TypeScript infers the return type as Organization
379
+ const org = await bloque.orgs.create(params);
466
380
  ```
467
381
 
468
- **Discriminated Union Types**:
382
+ **Available Types**:
469
383
 
470
- The SDK uses TypeScript discriminated unions for payment types, which enables automatic type narrowing:
384
+ The SDK exports all necessary types for type-safe development:
471
385
 
472
386
  ```typescript
473
- // Backend API handler
474
- async function handlePaymentFromFrontend(payment: PaymentSubmitPayload) {
475
- switch (payment.type) {
476
- case 'card':
477
- // TypeScript knows payment.data is CardPaymentFormData
478
- console.log('Card payment for:', payment.data.cardholderName);
479
- break;
480
- case 'pse':
481
- // TypeScript knows payment.data is PSEPaymentFormData
482
- console.log('PSE payment, bank:', payment.data.bankCode);
483
- break;
484
- case 'cash':
485
- // TypeScript knows payment.data is CashPaymentFormData
486
- console.log('Cash payment for:', payment.data.fullName);
487
- break;
488
- }
387
+ // Main SDK types
388
+ import type { SDK, BloqueConfig } from '@bloque/sdk';
489
389
 
490
- return await bloque.payments.create({ payment });
491
- }
390
+ // Organization types
391
+ import type {
392
+ Organization,
393
+ CreateOrgParams,
394
+ CreateOrgResponse,
395
+ OrgProfile,
396
+ OrgType,
397
+ OrgStatus,
398
+ Place,
399
+ } from '@bloque/sdk/orgs';
492
400
  ```
493
401
 
494
402
  ## Development
@@ -526,8 +434,16 @@ bun run check
526
434
  ## Links
527
435
 
528
436
  - [Homepage](https://www.bloque.app)
529
- - [GitHub Repository](git+https://github.com/bloque-app/bloque-payments.git)
530
- - [Issue Tracker](git+https://github.com/bloque-app/bloque-payments.git/issues)
437
+ - [GitHub Repository](https://github.com/bloque-app/sdk)
438
+ - [Issue Tracker](https://github.com/bloque-app/sdk/issues)
439
+
440
+ ## Package Structure
441
+
442
+ This monorepo contains the following packages:
443
+
444
+ - **`@bloque/sdk`**: Main SDK package
445
+ - **`@bloque/sdk-core`**: Core utilities and HTTP client
446
+ - **`@bloque/sdk-orgs`**: Organizations API client
531
447
 
532
448
  ## License
533
449
 
@@ -0,0 +1,7 @@
1
+ import { type BloqueConfig } from '@bloque/sdk-core';
2
+ import { OrgsClient } from '@bloque/sdk-orgs';
3
+ export declare class SDK {
4
+ private readonly httpClient;
5
+ readonly orgs: OrgsClient;
6
+ constructor(config: BloqueConfig);
7
+ }
package/dist/index.cjs CHANGED
@@ -24,12 +24,21 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- sum: ()=>sum
27
+ SDK: ()=>SDK
28
28
  });
29
- const sum = (a, b)=>a + b;
30
- exports.sum = __webpack_exports__.sum;
29
+ const sdk_core_namespaceObject = require("@bloque/sdk-core");
30
+ const sdk_orgs_namespaceObject = require("@bloque/sdk-orgs");
31
+ class SDK {
32
+ httpClient;
33
+ orgs;
34
+ constructor(config){
35
+ this.httpClient = new sdk_core_namespaceObject.HttpClient(config);
36
+ this.orgs = new sdk_orgs_namespaceObject.OrgsClient(this.httpClient);
37
+ }
38
+ }
39
+ exports.SDK = __webpack_exports__.SDK;
31
40
  for(var __rspack_i in __webpack_exports__)if (-1 === [
32
- "sum"
41
+ "SDK"
33
42
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
34
43
  Object.defineProperty(exports, '__esModule', {
35
44
  value: true
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare const sum: (a: number, b: number) => number;
1
+ export { SDK } from './bloque';
2
+ export type { BloqueConfig } from '@bloque/sdk-core';
package/dist/index.js CHANGED
@@ -1,2 +1,11 @@
1
- const sum = (a, b)=>a + b;
2
- export { sum };
1
+ import { HttpClient } from "@bloque/sdk-core";
2
+ import { OrgsClient } from "@bloque/sdk-orgs";
3
+ class SDK {
4
+ httpClient;
5
+ orgs;
6
+ constructor(config){
7
+ this.httpClient = new HttpClient(config);
8
+ this.orgs = new OrgsClient(this.httpClient);
9
+ }
10
+ }
11
+ export { SDK };
package/dist/orgs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export type { CreateOrgParams, CreateOrgResponse, Organization, OrgProfile, OrgStatus, OrgType, Place, } from '@bloque/sdk-orgs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Official Bloque SDK",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -24,6 +24,11 @@
24
24
  "types": "./dist/index.d.ts",
25
25
  "import": "./dist/index.js",
26
26
  "require": "./dist/index.cjs"
27
+ },
28
+ "./orgs": {
29
+ "types": "./dist/orgs.d.ts",
30
+ "import": "./dist/orgs.js",
31
+ "require": "./dist/orgs.cjs"
27
32
  }
28
33
  },
29
34
  "main": "./dist/index.cjs",
@@ -42,7 +47,8 @@
42
47
  "typecheck": "tsgo --noEmit"
43
48
  },
44
49
  "dependencies": {
45
- "@bloque/sdk-core": "workspace:*"
50
+ "@bloque/sdk-core": "workspace:*",
51
+ "@bloque/sdk-orgs": "workspace:*"
46
52
  },
47
53
  "devDependencies": {
48
54
  "@rslib/core": "catalog:",