@bloque/sdk-accounts 0.0.22 → 0.0.23

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,811 +1,5 @@
1
- # @bloque/sdk-accounts
1
+ # `@bloque/sdk-accounts`
2
2
 
3
- Financial accounts and payment methods client for the [Bloque](https://www.bloque.app) platform.
3
+ ⚠️ **Warning**: This package is intended for internal use. Its release cycle does not follow SemVer, which means we might release breaking changes (change APIs, remove functionality) without any prior warning.
4
4
 
5
- ## Features
6
-
7
- - **Virtual Cards**: Create virtual cards instantly
8
- - **Bancolombia Accounts**: Create Bancolombia accounts with reference codes
9
- - **TypeScript First**: Built with TypeScript for complete type safety
10
- - **Simple API**: Minimal input required - just URN and optional name
11
- - **Fully Async**: Promise-based API for modern JavaScript workflows
12
- - **Secure**: PCI-compliant card details URL
13
-
14
- > **📌 Important:** All account operations require connecting to a user session first using `bloque.connect(urn)`. This ensures proper authentication and authorization for user-specific operations. See the [Usage](#usage) section for details.
15
-
16
- ## Installation
17
-
18
- This package is included in the main `@bloque/sdk` package. You typically don't need to install it separately.
19
-
20
- ```bash
21
- bun add @bloque/sdk
22
- ```
23
-
24
- If you need to use this package standalone:
25
-
26
- ```bash
27
- bun add @bloque/sdk-accounts @bloque/sdk-core
28
- ```
29
-
30
- ## Usage
31
-
32
- ### With the Main SDK (Recommended)
33
-
34
- ```typescript
35
- import { SDK } from '@bloque/sdk';
36
-
37
- const bloque = new SDK({
38
- origin: 'your-origin', // Required: your origin identifier
39
- auth: {
40
- type: 'apiKey',
41
- apiKey: process.env.BLOQUE_API_KEY!,
42
- },
43
- mode: 'production',
44
- });
45
-
46
- // Connect to user session first
47
- const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
48
-
49
- // Create a virtual card through the session
50
- const card = await userSession.accounts.card.create({
51
- urn: 'did:bloque:your-origin:user-alias',
52
- name: 'My Virtual Card', // Optional
53
- ledgerId: 'ledger_123', // Optional - associate with ledger account
54
- });
55
-
56
- console.log('Card created:', card.urn);
57
- console.log('Last four digits:', card.lastFour);
58
- console.log('Card details URL:', card.detailsUrl);
59
- console.log('Ledger ID:', card.ledgerId);
60
- console.log('Status:', card.status);
61
-
62
- // Create a Bancolombia account through the session
63
- const bancolombiaAccount = await userSession.accounts.bancolombia.create({
64
- urn: 'did:bloque:your-origin:user-alias',
65
- name: 'Main Account', // Optional
66
- ledgerId: 'ledger_123', // Optional - associate with ledger account
67
- });
68
-
69
- console.log('Bancolombia account created:', bancolombiaAccount.urn);
70
- console.log('Reference code:', bancolombiaAccount.referenceCode);
71
- console.log('Ledger ID:', bancolombiaAccount.ledgerId);
72
- console.log('Status:', bancolombiaAccount.status);
73
- ```
74
-
75
- ## API Reference
76
-
77
- ### Card Accounts
78
-
79
- Create virtual cards instantly.
80
-
81
- #### `card.create(params)`
82
-
83
- ```typescript
84
- const card = await bloque.accounts.card.create({
85
- urn: 'did:bloque:user:123',
86
- name: 'My Virtual Card', // Optional
87
- ledgerId: 'ledger_123', // Optional
88
- });
89
- ```
90
-
91
- **Parameters**:
92
-
93
- ```typescript
94
- interface CreateCardParams {
95
- /**
96
- * URN of the account holder (user or organization)
97
- * @example "did:bloque:user:123e4567"
98
- */
99
- urn: string;
100
-
101
- /**
102
- * Display name for the card (optional)
103
- */
104
- name?: string;
105
-
106
- /**
107
- * Ledger account ID to associate with the card (optional)
108
- */
109
- ledgerId?: string;
110
-
111
- /**
112
- * Webhook URL to receive card events (optional)
113
- */
114
- webhookUrl?: string;
115
-
116
- /**
117
- * Custom metadata to associate with the card (optional)
118
- */
119
- metadata?: Record<string, unknown>;
120
- }
121
- ```
122
-
123
- **Returns**:
124
-
125
- ```typescript
126
- interface CardAccount {
127
- urn: string; // Unique resource name
128
- id: string; // Card account ID
129
- lastFour: string; // Last four digits
130
- productType: 'CREDIT' | 'DEBIT'; // Card product type
131
- status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
132
- cardType: 'VIRTUAL' | 'PHYSICAL'; // Card type
133
- detailsUrl: string; // PCI-compliant URL to view card details
134
- ownerUrn: string; // Owner URN
135
- ledgerId: string; // Ledger account ID
136
- webhookUrl: string | null; // Webhook URL (if configured)
137
- metadata?: Record<string, unknown>; // Custom metadata
138
- createdAt: string; // Creation timestamp (ISO 8601)
139
- updatedAt: string; // Last update timestamp (ISO 8601)
140
- }
141
- ```
142
-
143
- #### `card.updateMetadata(params)`
144
-
145
- Update the metadata of an existing card account.
146
-
147
- ```typescript
148
- const card = await bloque.accounts.card.updateMetadata({
149
- urn: 'did:bloque:mediums:card:account:123',
150
- metadata: {
151
- updated_by: 'admin',
152
- update_reason: 'customer_request',
153
- },
154
- });
155
- ```
156
-
157
- **Parameters**:
158
-
159
- ```typescript
160
- interface UpdateCardMetadataParams {
161
- /**
162
- * URN of the card account to update
163
- * @example "did:bloque:mediums:card:account:123e4567"
164
- */
165
- urn: string;
166
-
167
- /**
168
- * Metadata to update (name and source are reserved fields and cannot be modified)
169
- */
170
- metadata: Record<string, unknown> & {
171
- name?: never;
172
- source?: never;
173
- };
174
- }
175
- ```
176
-
177
- **Returns**: `CardAccount`
178
-
179
- #### `card.updateName(urn, name)`
180
-
181
- Update the name of a card account.
182
-
183
- ```typescript
184
- const card = await bloque.accounts.card.updateName(
185
- 'did:bloque:mediums:card:account:123',
186
- 'My Business Card'
187
- );
188
- ```
189
-
190
- **Parameters**:
191
- - `urn: string` - Card account URN
192
- - `name: string` - New name for the card
193
-
194
- **Returns**: `CardAccount`
195
-
196
- #### `card.activate(urn)`
197
-
198
- Activate a card account.
199
-
200
- ```typescript
201
- const card = await bloque.accounts.card.activate(
202
- 'did:bloque:mediums:card:account:123'
203
- );
204
- ```
205
-
206
- **Parameters**: `urn: string` - Card account URN
207
-
208
- **Returns**: `CardAccount`
209
-
210
- #### `card.freeze(urn)`
211
-
212
- Freeze a card account.
213
-
214
- ```typescript
215
- const card = await bloque.accounts.card.freeze(
216
- 'did:bloque:mediums:card:account:123'
217
- );
218
- ```
219
-
220
- **Parameters**: `urn: string` - Card account URN
221
-
222
- **Returns**: `CardAccount`
223
-
224
- #### `card.disable(urn)`
225
-
226
- Disable a card account.
227
-
228
- ```typescript
229
- const card = await bloque.accounts.card.disable(
230
- 'did:bloque:mediums:card:account:123'
231
- );
232
- ```
233
-
234
- **Parameters**: `urn: string` - Card account URN
235
-
236
- **Returns**: `CardAccount`
237
-
238
- ### Bancolombia Accounts
239
-
240
- Create Bancolombia accounts with reference codes for local payments.
241
-
242
- #### `bancolombia.create(params)`
243
-
244
- ```typescript
245
- const account = await bloque.accounts.bancolombia.create({
246
- urn: 'did:bloque:user:123',
247
- name: 'Main Account', // Optional
248
- ledgerId: 'ledger_123', // Optional
249
- });
250
- ```
251
-
252
- **Parameters**:
253
-
254
- ```typescript
255
- interface CreateBancolombiaAccountParams {
256
- /**
257
- * URN of the account holder (user or organization)
258
- * @example "did:bloque:user:123e4567"
259
- */
260
- urn: string;
261
-
262
- /**
263
- * Display name for the account (optional)
264
- */
265
- name?: string;
266
-
267
- /**
268
- * Ledger account ID to associate with the Bancolombia account (optional)
269
- */
270
- ledgerId?: string;
271
-
272
- /**
273
- * Webhook URL to receive account events (optional)
274
- */
275
- webhookUrl?: string;
276
-
277
- /**
278
- * Custom metadata to attach to the Bancolombia account (optional)
279
- */
280
- metadata?: Record<string, unknown>;
281
- }
282
- ```
283
-
284
- **Returns**:
285
-
286
- ```typescript
287
- interface BancolombiaAccount {
288
- urn: string; // Unique resource name
289
- id: string; // Account ID
290
- referenceCode: string; // Reference code for payments
291
- status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
292
- ownerUrn: string; // Owner URN
293
- ledgerId: string; // Ledger account ID
294
- webhookUrl: string | null; // Webhook URL (if configured)
295
- metadata?: Record<string, unknown>; // Custom metadata
296
- createdAt: string; // Creation timestamp (ISO 8601)
297
- updatedAt: string; // Last update timestamp (ISO 8601)
298
- }
299
- ```
300
-
301
- #### `bancolombia.updateMetadata(params)`
302
-
303
- Update the metadata of an existing Bancolombia account.
304
-
305
- ```typescript
306
- const account = await bloque.accounts.bancolombia.updateMetadata({
307
- urn: 'did:bloque:mediums:bancolombia:account:123',
308
- metadata: {
309
- updated_by: 'admin',
310
- update_reason: 'customer_request',
311
- },
312
- });
313
- ```
314
-
315
- **Parameters**:
316
-
317
- ```typescript
318
- interface UpdateBancolombiaMetadataParams {
319
- /**
320
- * URN of the Bancolombia account to update
321
- * @example "did:bloque:mediums:bancolombia:account:123e4567"
322
- */
323
- urn: string;
324
-
325
- /**
326
- * Metadata to update (name and source are reserved fields and cannot be modified)
327
- */
328
- metadata: Record<string, unknown> & {
329
- name?: never;
330
- source?: never;
331
- };
332
- }
333
- ```
334
-
335
- **Returns**: `BancolombiaAccount`
336
-
337
- #### `bancolombia.updateName(urn, name)`
338
-
339
- Update the name of a Bancolombia account.
340
-
341
- ```typescript
342
- const account = await bloque.accounts.bancolombia.updateName(
343
- 'did:bloque:mediums:bancolombia:account:123',
344
- 'Main Business Account'
345
- );
346
- ```
347
-
348
- **Parameters**:
349
- - `urn: string` - Bancolombia account URN
350
- - `name: string` - New name for the account
351
-
352
- **Returns**: `BancolombiaAccount`
353
-
354
- #### `bancolombia.activate(urn)`
355
-
356
- Activate a Bancolombia account.
357
-
358
- ```typescript
359
- const account = await bloque.accounts.bancolombia.activate(
360
- 'did:bloque:mediums:bancolombia:account:123'
361
- );
362
- ```
363
-
364
- **Parameters**: `urn: string` - Bancolombia account URN
365
-
366
- **Returns**: `BancolombiaAccount`
367
-
368
- #### `bancolombia.freeze(urn)`
369
-
370
- Freeze a Bancolombia account.
371
-
372
- ```typescript
373
- const account = await bloque.accounts.bancolombia.freeze(
374
- 'did:bloque:mediums:bancolombia:account:123'
375
- );
376
- ```
377
-
378
- **Parameters**: `urn: string` - Bancolombia account URN
379
-
380
- **Returns**: `BancolombiaAccount`
381
-
382
- #### `bancolombia.disable(urn)`
383
-
384
- Disable a Bancolombia account.
385
-
386
- ```typescript
387
- const account = await bloque.accounts.bancolombia.disable(
388
- 'did:bloque:mediums:bancolombia:account:123'
389
- );
390
- ```
391
-
392
- **Parameters**: `urn: string` - Bancolombia account URN
393
-
394
- **Returns**: `BancolombiaAccount`
395
-
396
- ## Complete Examples
397
-
398
- ### Basic Card Creation
399
-
400
- ```typescript
401
- import { SDK } from '@bloque/sdk';
402
-
403
- const bloque = new SDK({
404
- origin: 'your-origin',
405
- auth: {
406
- type: 'apiKey',
407
- apiKey: process.env.BLOQUE_API_KEY!,
408
- },
409
- mode: 'production',
410
- });
411
-
412
- // Connect to user session
413
- const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
414
-
415
- // Create a virtual card with just URN
416
- const card = await userSession.accounts.card.create({
417
- urn: 'did:bloque:your-origin:user-alias',
418
- });
419
-
420
- console.log('Card created:', card.urn);
421
- console.log('Last four:', card.lastFour);
422
- console.log('Status:', card.status);
423
- ```
424
-
425
- ### Card Creation with Name
426
-
427
- ```typescript
428
- import { SDK } from '@bloque/sdk';
429
-
430
- const bloque = new SDK({
431
- apiKey: process.env.BLOQUE_API_KEY!,
432
- mode: 'production',
433
- });
434
-
435
- // Create a named virtual card
436
- const card = await bloque.accounts.card.create({
437
- urn: 'did:bloque:user:123e4567',
438
- name: 'My Business Card',
439
- });
440
-
441
- console.log('Card name:', card.metadata?.name);
442
- console.log('Card details URL:', card.detailsUrl);
443
- ```
444
-
445
- ### Creating Multiple Cards
446
-
447
- ```typescript
448
- import { SDK } from '@bloque/sdk';
449
-
450
- const bloque = new SDK({
451
- apiKey: process.env.BLOQUE_API_KEY!,
452
- mode: 'production',
453
- });
454
-
455
- const userUrn = 'did:bloque:user:123e4567';
456
-
457
- // Create multiple cards for the same user
458
- const personalCard = await bloque.accounts.card.create({
459
- urn: userUrn,
460
- name: 'Personal Card',
461
- });
462
-
463
- const businessCard = await bloque.accounts.card.create({
464
- urn: userUrn,
465
- name: 'Business Card',
466
- });
467
-
468
- console.log('Personal card:', personalCard.lastFour);
469
- console.log('Business card:', businessCard.lastFour);
470
- ```
471
-
472
- ### Updating Card Metadata
473
-
474
- ```typescript
475
- import { SDK } from '@bloque/sdk';
476
-
477
- const bloque = new SDK({
478
- apiKey: process.env.BLOQUE_API_KEY!,
479
- mode: 'production',
480
- });
481
-
482
- // Create a card first
483
- const card = await bloque.accounts.card.create({
484
- urn: 'did:bloque:user:123e4567',
485
- name: 'My Card',
486
- });
487
-
488
- // Update the card metadata
489
- const updatedCard = await bloque.accounts.card.updateMetadata({
490
- urn: card.urn,
491
- metadata: {
492
- updated_by: 'admin',
493
- update_reason: 'customer_request',
494
- custom_field: 'custom_value',
495
- },
496
- });
497
-
498
- console.log('Card metadata updated:', updatedCard.metadata);
499
- ```
500
-
501
- ### Updating Card Name
502
-
503
- ```typescript
504
- import { SDK } from '@bloque/sdk';
505
-
506
- const bloque = new SDK({
507
- apiKey: process.env.BLOQUE_API_KEY!,
508
- mode: 'production',
509
- });
510
-
511
- // Update the card name
512
- const updatedCard = await bloque.accounts.card.updateName(
513
- 'did:bloque:mediums:card:account:123',
514
- 'My Personal Card'
515
- );
516
-
517
- console.log('Card name updated:', updatedCard.metadata?.name); // 'My Personal Card'
518
- ```
519
-
520
- ### Updating Card Status
521
-
522
- ```typescript
523
- import { SDK } from '@bloque/sdk';
524
-
525
- const bloque = new SDK({
526
- apiKey: process.env.BLOQUE_API_KEY!,
527
- mode: 'production',
528
- });
529
-
530
- // Freeze a card
531
- const frozenCard = await bloque.accounts.card.freeze(
532
- 'did:bloque:mediums:card:account:123'
533
- );
534
-
535
- console.log('Card status:', frozenCard.status); // 'frozen'
536
-
537
- // Reactivate the card
538
- const activeCard = await bloque.accounts.card.activate(
539
- 'did:bloque:mediums:card:account:123'
540
- );
541
-
542
- console.log('Card status:', activeCard.status); // 'active'
543
-
544
- // Disable a card
545
- const disabledCard = await bloque.accounts.card.disable(
546
- 'did:bloque:mediums:card:account:123'
547
- );
548
-
549
- console.log('Card status:', disabledCard.status); // 'disabled'
550
- ```
551
-
552
- ### Error Handling
553
-
554
- ```typescript
555
- import { SDK } from '@bloque/sdk';
556
-
557
- const bloque = new SDK({
558
- apiKey: process.env.BLOQUE_API_KEY!,
559
- mode: 'production',
560
- });
561
-
562
- try {
563
- const card = await bloque.accounts.card.create({
564
- urn: 'did:bloque:user:123e4567',
565
- name: 'My Card',
566
- });
567
-
568
- console.log('Card created successfully:', card.urn);
569
-
570
- // Check if card is ready to use
571
- if (card.status === 'active') {
572
- console.log('Card is active and ready to use!');
573
- } else if (card.status === 'creation_in_progress') {
574
- console.log('Card is being created...');
575
- }
576
- } catch (error) {
577
- if (error instanceof Error) {
578
- console.error('Failed to create card:', error.message);
579
- }
580
- }
581
- ```
582
-
583
- ### Basic Bancolombia Account Creation
584
-
585
- ```typescript
586
- import { SDK } from '@bloque/sdk';
587
-
588
- const bloque = new SDK({
589
- apiKey: process.env.BLOQUE_API_KEY!,
590
- mode: 'production',
591
- });
592
-
593
- // Create a Bancolombia account with just URN
594
- const account = await bloque.accounts.bancolombia.create({
595
- urn: 'did:bloque:user:123e4567',
596
- });
597
-
598
- console.log('Account created:', account.urn);
599
- console.log('Reference code:', account.referenceCode);
600
- console.log('Status:', account.status);
601
- ```
602
-
603
- ### Bancolombia Account with Ledger Association
604
-
605
- ```typescript
606
- import { SDK } from '@bloque/sdk';
607
-
608
- const bloque = new SDK({
609
- apiKey: process.env.BLOQUE_API_KEY!,
610
- mode: 'production',
611
- });
612
-
613
- const userUrn = 'did:bloque:user:123e4567';
614
- const ledgerId = 'ledger_abc123';
615
-
616
- // Create a card associated with a ledger
617
- const card = await bloque.accounts.card.create({
618
- urn: userUrn,
619
- name: 'My Card',
620
- ledgerId: ledgerId,
621
- });
622
-
623
- // Create Bancolombia account with the same ledger
624
- const account = await bloque.accounts.bancolombia.create({
625
- urn: userUrn,
626
- name: 'Main Account',
627
- ledgerId: ledgerId,
628
- });
629
-
630
- console.log('Card URN:', card.urn);
631
- console.log('Card Ledger ID:', card.ledgerId);
632
- console.log('Account URN:', account.urn);
633
- console.log('Account Ledger ID:', account.ledgerId);
634
- console.log('Reference code for payments:', account.referenceCode);
635
- ```
636
-
637
- ### Bancolombia Account with Metadata
638
-
639
- ```typescript
640
- import { SDK } from '@bloque/sdk';
641
-
642
- const bloque = new SDK({
643
- apiKey: process.env.BLOQUE_API_KEY!,
644
- mode: 'production',
645
- });
646
-
647
- // Create Bancolombia account with custom metadata
648
- const account = await bloque.accounts.bancolombia.create({
649
- urn: 'did:bloque:user:123e4567',
650
- name: 'Business Account',
651
- metadata: {
652
- purpose: 'business-payments',
653
- department: 'sales',
654
- customField: 'custom-value',
655
- },
656
- });
657
-
658
- console.log('Account created with metadata:', account.metadata);
659
- console.log('Reference code:', account.referenceCode);
660
- ```
661
-
662
- ### Updating Bancolombia Account Metadata
663
-
664
- ```typescript
665
- import { SDK } from '@bloque/sdk';
666
-
667
- const bloque = new SDK({
668
- apiKey: process.env.BLOQUE_API_KEY!,
669
- mode: 'production',
670
- });
671
-
672
- // Create a Bancolombia account first
673
- const account = await bloque.accounts.bancolombia.create({
674
- urn: 'did:bloque:user:123e4567',
675
- name: 'Main Account',
676
- });
677
-
678
- // Update the account metadata
679
- const updatedAccount = await bloque.accounts.bancolombia.updateMetadata({
680
- urn: account.urn,
681
- metadata: {
682
- updated_by: 'admin',
683
- update_reason: 'customer_request',
684
- department: 'finance',
685
- },
686
- });
687
-
688
- console.log('Account metadata updated:', updatedAccount.metadata);
689
- ```
690
-
691
- ### Updating Bancolombia Account Name
692
-
693
- ```typescript
694
- import { SDK } from '@bloque/sdk';
695
-
696
- const bloque = new SDK({
697
- apiKey: process.env.BLOQUE_API_KEY!,
698
- mode: 'production',
699
- });
700
-
701
- // Update the account name
702
- const updatedAccount = await bloque.accounts.bancolombia.updateName(
703
- 'did:bloque:mediums:bancolombia:account:123',
704
- 'Main Business Account'
705
- );
706
-
707
- console.log('Account name updated:', updatedAccount.metadata?.name); // 'Main Business Account'
708
- ```
709
-
710
- ### Updating Bancolombia Account Status
711
-
712
- ```typescript
713
- import { SDK } from '@bloque/sdk';
714
-
715
- const bloque = new SDK({
716
- apiKey: process.env.BLOQUE_API_KEY!,
717
- mode: 'production',
718
- });
719
-
720
- // Freeze a Bancolombia account
721
- const frozenAccount = await bloque.accounts.bancolombia.freeze(
722
- 'did:bloque:mediums:bancolombia:account:123'
723
- );
724
-
725
- console.log('Account status:', frozenAccount.status); // 'frozen'
726
-
727
- // Reactivate the account
728
- const activeAccount = await bloque.accounts.bancolombia.activate(
729
- 'did:bloque:mediums:bancolombia:account:123'
730
- );
731
-
732
- console.log('Account status:', activeAccount.status); // 'active'
733
-
734
- // Disable an account
735
- const disabledAccount = await bloque.accounts.bancolombia.disable(
736
- 'did:bloque:mediums:bancolombia:account:123'
737
- );
738
-
739
- console.log('Account status:', disabledAccount.status); // 'disabled'
740
- ```
741
-
742
- ## TypeScript Support
743
-
744
- This package is written in TypeScript and includes complete type definitions:
745
-
746
- ```typescript
747
- import type {
748
- CardAccount,
749
- CreateCardParams,
750
- UpdateCardMetadataParams,
751
- BancolombiaAccount,
752
- CreateBancolombiaAccountParams,
753
- UpdateBancolombiaMetadataParams,
754
- } from '@bloque/sdk-accounts';
755
-
756
- // Type-safe card creation
757
- const cardParams: CreateCardParams = {
758
- urn: 'did:bloque:user:123e4567',
759
- name: 'My Card', // Optional
760
- };
761
-
762
- const card: CardAccount = await bloque.accounts.card.create(cardParams);
763
-
764
- // TypeScript infers all card properties with full type safety
765
- console.log(card.lastFour); // string
766
- console.log(card.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
767
- console.log(card.cardType); // 'VIRTUAL' | 'PHYSICAL'
768
-
769
- // Type-safe Bancolombia account creation
770
- const accountParams: CreateBancolombiaAccountParams = {
771
- urn: 'did:bloque:user:123e4567',
772
- name: 'Main Account', // Optional
773
- ledgerId: 'ledger_123', // Optional
774
- };
775
-
776
- const account: BancolombiaAccount = await bloque.accounts.bancolombia.create(accountParams);
777
-
778
- // TypeScript infers all account properties with full type safety
779
- console.log(account.referenceCode); // string
780
- console.log(account.ledgerId); // string
781
- console.log(account.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
782
- ```
783
-
784
- ## Account Status
785
-
786
- Both cards and Bancolombia accounts have a status field indicating their current state:
787
-
788
- - `creation_in_progress`: Account/card is being created
789
- - `creation_failed`: Account/card creation failed
790
- - `active`: Account/card is active and ready to use
791
- - `disabled`: Account/card has been disabled
792
- - `frozen`: Account/card has been temporarily frozen
793
- - `deleted`: Account/card has been deleted
794
-
795
- ## Requirements
796
-
797
- - Node.js 22.x or higher / Bun 1.x or higher
798
- - TypeScript 5.x or higher (for TypeScript projects)
799
-
800
- ## Links
801
-
802
- - [Homepage](https://www.bloque.app)
803
- - [Main SDK Documentation](../sdk/README.md)
804
- - [GitHub Repository](https://github.com/bloque-app/sdk)
805
- - [Issue Tracker](https://github.com/bloque-app/sdk/issues)
806
-
807
- ## License
808
-
809
- [MIT](../../LICENSE)
810
-
811
- Copyright (c) 2025-present Bloque Copilot Inc.
5
+ For documentation, please refer to the [main SDK documentation](../sdk/README.md).
@@ -62,4 +62,113 @@ export interface UpdateAccountResponse<TDetails = unknown> {
62
62
  };
63
63
  req_id: string;
64
64
  }
65
+ export interface TokenBalance {
66
+ current: string;
67
+ pending: string;
68
+ in: string;
69
+ out: string;
70
+ }
71
+ export interface AccountWithBalance<TDetails = unknown> extends Account<TDetails> {
72
+ balance: Record<string, TokenBalance>;
73
+ }
74
+ export interface ListAccountsResponse<TDetails = unknown> {
75
+ accounts: AccountWithBalance<TDetails>[];
76
+ }
77
+ export interface TransactionMetadata {
78
+ amount?: string;
79
+ asset_type?: string;
80
+ card_id?: string;
81
+ card_last_four?: string;
82
+ card_product_type?: string;
83
+ card_provider?: string;
84
+ currency?: string;
85
+ installments?: string;
86
+ local_amount?: string;
87
+ local_currency?: string;
88
+ local_to_usd_rate?: string;
89
+ merchant_address?: string;
90
+ merchant_city?: string;
91
+ merchant_country?: string;
92
+ merchant_id?: string;
93
+ merchant_mcc?: string;
94
+ merchant_name?: string;
95
+ merchant_terminal_id?: string;
96
+ operation_type?: string;
97
+ original_transaction_id?: string;
98
+ selected_asset?: string;
99
+ transaction_id?: string;
100
+ transaction_type?: string;
101
+ type?: string;
102
+ usd_amount?: string;
103
+ user_id?: string;
104
+ [key: string]: unknown;
105
+ }
106
+ export interface TransactionDetails {
107
+ metadata: TransactionMetadata;
108
+ type: string;
109
+ }
110
+ export interface Transaction {
111
+ amount: string;
112
+ asset: string;
113
+ from_account_id: string;
114
+ to_account_id: string;
115
+ direction: 'in' | 'out';
116
+ reference: string;
117
+ rail_name: string;
118
+ details: TransactionDetails;
119
+ created_at: string;
120
+ }
121
+ export interface ListMovementsResponse {
122
+ transactions: Transaction[];
123
+ }
124
+ export interface GetBalanceResponse {
125
+ balance: Record<string, TokenBalance>;
126
+ }
127
+ export type SupportedAsset = 'DUSD/6' | 'KSM/12';
128
+ export interface TransferParams {
129
+ /**
130
+ * URN of the source account
131
+ * @example "did:bloque:account:card:usr-123:crd-456"
132
+ */
133
+ sourceUrn: string;
134
+ /**
135
+ * URN of the destination account
136
+ * @example "did:bloque:account:virtual:acc-67890"
137
+ */
138
+ destinationUrn: string;
139
+ /**
140
+ * Amount to transfer
141
+ * @example "1000000000000"
142
+ */
143
+ amount: string;
144
+ /**
145
+ * Asset to transfer
146
+ * @example "USD"
147
+ */
148
+ asset: SupportedAsset;
149
+ /**
150
+ * Optional metadata for the transfer
151
+ * @example { reference: "payment-123", note: "Monthly subscription" }
152
+ */
153
+ metadata?: Record<string, unknown>;
154
+ }
155
+ export interface TransferRequest {
156
+ destination_account_urn: string;
157
+ amount: string;
158
+ asset: string;
159
+ metadata?: Record<string, unknown>;
160
+ }
161
+ export interface TransferResult {
162
+ queueId: string;
163
+ status: 'queued' | 'processing' | 'completed' | 'failed';
164
+ message: string;
165
+ }
166
+ export interface TransferResponse {
167
+ result: {
168
+ queue_id: string;
169
+ status: 'queued' | 'processing' | 'completed' | 'failed';
170
+ message: string;
171
+ };
172
+ req_id: string;
173
+ }
65
174
  export {};
@@ -1,5 +1,6 @@
1
1
  import { BaseClient } from '@bloque/sdk-core';
2
- import type { CardAccount, CreateCardParams, UpdateCardMetadataParams } from './types';
2
+ import type { TokenBalance } from '../api-types';
3
+ import type { CardAccount, CardMovement, CreateCardParams, GetBalanceParams, ListCardParams, ListMovementsParams, UpdateCardMetadataParams } from './types';
3
4
  export declare class CardClient extends BaseClient {
4
5
  /**
5
6
  * Create a new card account
@@ -16,6 +17,59 @@ export declare class CardClient extends BaseClient {
16
17
  * ```
17
18
  */
18
19
  create(params: CreateCardParams): Promise<CardAccount>;
20
+ /**
21
+ * List card accounts for a holder
22
+ *
23
+ * @param params - List parameters
24
+ * @returns Promise resolving to array of card accounts with balances
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const cards = await bloque.accounts.card.list({
29
+ * holderUrn: 'did:bloque:bloque-whatsapp:573023348486',
30
+ * });
31
+ * ```
32
+ */
33
+ list(params?: ListCardParams): Promise<CardAccount[]>;
34
+ /**
35
+ * List card account movements/transactions
36
+ *
37
+ * @param params - Movement list parameters
38
+ * @returns Promise resolving to array of card movements
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Basic usage
43
+ * const movements = await bloque.accounts.card.movements({
44
+ * urn: 'did:bloque:account:card:usr-123:crd-456',
45
+ * asset: 'DUSD/6',
46
+ * });
47
+ *
48
+ * // With pagination and filters
49
+ * const recentMovements = await bloque.accounts.card.movements({
50
+ * urn: 'did:bloque:account:card:usr-123:crd-456',
51
+ * asset: 'DUSD/6',
52
+ * limit: 50,
53
+ * direction: 'in',
54
+ * after: '2025-01-01T00:00:00Z',
55
+ * });
56
+ * ```
57
+ */
58
+ movements(params: ListMovementsParams): Promise<CardMovement[]>;
59
+ /**
60
+ * Get card account balance
61
+ *
62
+ * @param params - Balance query parameters
63
+ * @returns Promise resolving to token balances
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const balances = await bloque.accounts.card.balance({
68
+ * urn: 'did:bloque:account:card:usr-123:crd-456',
69
+ * });
70
+ * ```
71
+ */
72
+ balance(params: GetBalanceParams): Promise<Record<string, TokenBalance>>;
19
73
  /**
20
74
  * Update card account metadata
21
75
  *
@@ -1,4 +1,66 @@
1
- import type { CardType } from '../api-types';
1
+ import type { CardType, SupportedAsset, TokenBalance, Transaction } from '../api-types';
2
+ export interface ListCardParams {
3
+ /**
4
+ * URN of the account holder to filter by
5
+ *
6
+ * @example "did:bloque:bloque-whatsapp:573023348486"
7
+ */
8
+ holderUrn: string;
9
+ }
10
+ export interface ListMovementsParams {
11
+ /**
12
+ * URN of the card account
13
+ *
14
+ * @example "did:bloque:account:card:usr-123:crd-456"
15
+ */
16
+ urn: string;
17
+ /**
18
+ * Asset to filter transactions by
19
+ *
20
+ * @example "USD" (defaults to "USD" if "USD" is provided)
21
+ */
22
+ asset?: SupportedAsset;
23
+ /**
24
+ * Maximum number of transactions to return
25
+ *
26
+ * @example 50
27
+ */
28
+ limit?: number;
29
+ /**
30
+ * Filter transactions before this date (ISO 8601)
31
+ *
32
+ * @example "2025-01-01T00:00:00Z"
33
+ */
34
+ before?: string;
35
+ /**
36
+ * Filter transactions after this date (ISO 8601)
37
+ *
38
+ * @example "2025-01-01T00:00:00Z"
39
+ */
40
+ after?: string;
41
+ /**
42
+ * Filter by transaction reference
43
+ *
44
+ * @example "0xbff43fa587e0efa275f8b643d95881713c0f0ee13682d049cc452f607241b752"
45
+ */
46
+ reference?: string;
47
+ /**
48
+ * Filter by transaction direction
49
+ * - 'in' for incoming funds (deposits, transfers received)
50
+ * - 'out' for outgoing funds (withdrawals, transfers sent)
51
+ */
52
+ direction?: 'in' | 'out';
53
+ }
54
+ export interface CardMovement extends Transaction {
55
+ }
56
+ export interface GetBalanceParams {
57
+ /**
58
+ * URN of the card account
59
+ *
60
+ * @example "did:bloque:account:card:usr-123:crd-456"
61
+ */
62
+ urn: string;
63
+ }
2
64
  export interface CreateCardParams {
3
65
  /**
4
66
  * URN of the account holder (user or organization)
@@ -91,4 +153,8 @@ export interface CardAccount {
91
153
  * Last update timestamp
92
154
  */
93
155
  updatedAt: string;
156
+ /**
157
+ * Token balances (only included in list responses)
158
+ */
159
+ balance?: Record<string, TokenBalance>;
94
160
  }
package/dist/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { HttpClient } from '@bloque/sdk-core';
2
2
  import { BaseClient } from '@bloque/sdk-core';
3
+ import type { TransferParams, TransferResult } from './api-types';
3
4
  import { BancolombiaClient } from './bancolombia/client';
4
5
  import { CardClient } from './card/client';
5
6
  /**
@@ -16,4 +17,25 @@ export declare class AccountsClient extends BaseClient {
16
17
  readonly bancolombia: BancolombiaClient;
17
18
  readonly card: CardClient;
18
19
  constructor(httpClient: HttpClient);
20
+ /**
21
+ * Transfer funds between accounts
22
+ *
23
+ * @param params - Transfer parameters
24
+ * @returns Promise resolving to transfer result
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const transfer = await bloque.accounts.transfer({
29
+ * sourceUrn: 'did:bloque:account:card:usr-123:crd-456',
30
+ * destinationUrn: 'did:bloque:account:virtual:acc-67890',
31
+ * amount: '1000000000000',
32
+ * asset: 'KSM/12',
33
+ * metadata: {
34
+ * reference: 'payment-123',
35
+ * note: 'Monthly subscription'
36
+ * }
37
+ * });
38
+ * ```
39
+ */
40
+ transfer(params: TransferParams): Promise<TransferResult>;
19
41
  }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{AccountsClient:()=>AccountsClient,CardClient:()=>CardClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={holder_urn:e.urn,webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:t});return this._mapAccountResponse(a.result.account)}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return{urn:e.urn,id:e.id,referenceCode:e.details.reference_code,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={holder_urn:e.urn,webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:t});return this._mapAccountResponse(a.result.account)}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return{urn:e.urn,id:e.id,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;constructor(e){super(e),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient)}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{AccountsClient:()=>AccountsClient,CardClient:()=>CardClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={holder_urn:e.urn,webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:t});return this._mapAccountResponse(a.result.account)}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return{urn:e.urn,id:e.id,referenceCode:e.details.reference_code,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={holder_urn:e.urn,webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:t});return this._mapAccountResponse(a.result.account)}async list(e){let t=new URLSearchParams({holder_urn:e?.holderUrn||this.httpClient.config.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${t.toString()}`})).accounts.map(e=>({urn:e.urn,id:e.id,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}))}async movements(e){let t=new URLSearchParams,a=e.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");t.set("asset",a),void 0!==e.limit&&t.set("limit",e.limit.toString()),e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.reference&&t.set("reference",e.reference),e.direction&&t.set("direction",e.direction);let r=t.toString(),s=`/api/accounts/${e.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(e){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e.urn}/balance`})).balance}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return{urn:e.urn,id:e.id,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;constructor(e){super(e),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient)}async transfer(e){let t=e.asset||"DUSD/6";if("DUSD/6"!==t&&"KSM/12"!==t)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:e.destinationUrn,amount:e.amount,asset:t,metadata:e.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${e.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{BaseClient as t}from"@bloque/sdk-core";class e extends t{async create(t){let e={holder_urn:t.urn,webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class a extends t{async create(t){let e={holder_urn:t.urn,webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class s extends t{bancolombia;card;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient)}}export{s as AccountsClient,e as BancolombiaClient,a as CardClient};
1
+ import{BaseClient as t}from"@bloque/sdk-core";class e extends t{async create(t){let e={holder_urn:t.urn,webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class a extends t{async create(t){let e={holder_urn:t.urn,webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async list(t){let e=new URLSearchParams({holder_urn:t?.holderUrn||this.httpClient.config.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${e.toString()}`})).accounts.map(t=>({urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}))}async movements(t){let e=new URLSearchParams,a=t.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");e.set("asset",a),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction);let r=e.toString(),s=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class r extends t{bancolombia;card;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient)}async transfer(t){let e=t.asset||"DUSD/6";if("DUSD/6"!==e&&"KSM/12"!==e)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:t.destinationUrn,amount:t.amount,asset:e,metadata:t.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}export{r as AccountsClient,e as BancolombiaClient,a as CardClient};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-accounts",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bloque",
@@ -36,6 +36,6 @@
36
36
  "node": ">=22"
37
37
  },
38
38
  "dependencies": {
39
- "@bloque/sdk-core": "0.0.22"
39
+ "@bloque/sdk-core": "0.0.23"
40
40
  }
41
41
  }