@bloque/sdk-accounts 0.0.4 → 0.0.10

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
@@ -5,6 +5,7 @@ Financial accounts and payment methods client for the [Bloque](https://www.bloqu
5
5
  ## Features
6
6
 
7
7
  - **Virtual Cards**: Create virtual cards instantly
8
+ - **Bancolombia Accounts**: Create Bancolombia accounts with reference codes
8
9
  - **TypeScript First**: Built with TypeScript for complete type safety
9
10
  - **Simple API**: Minimal input required - just URN and optional name
10
11
  - **Fully Async**: Promise-based API for modern JavaScript workflows
@@ -46,6 +47,17 @@ console.log('Card created:', card.urn);
46
47
  console.log('Last four digits:', card.lastFour);
47
48
  console.log('Card details URL:', card.detailsUrl);
48
49
  console.log('Status:', card.status);
50
+
51
+ // Create a Bancolombia account
52
+ const bancolombiaAccount = await bloque.accounts.bancolombia.create({
53
+ urn: 'did:bloque:user:123',
54
+ name: 'Main Account', // Optional
55
+ cardUrn: card.urn, // Optional - link with existing card
56
+ });
57
+
58
+ console.log('Bancolombia account created:', bancolombiaAccount.urn);
59
+ console.log('Reference code:', bancolombiaAccount.referenceCode);
60
+ console.log('Status:', bancolombiaAccount.status);
49
61
  ```
50
62
 
51
63
  ## API Reference
@@ -99,6 +111,64 @@ interface CardAccount {
99
111
  }
100
112
  ```
101
113
 
114
+ ### Bancolombia Accounts
115
+
116
+ Create Bancolombia accounts with reference codes for local payments.
117
+
118
+ #### `bancolombia.create(params)`
119
+
120
+ ```typescript
121
+ const account = await bloque.accounts.bancolombia.create({
122
+ urn: 'did:bloque:user:123',
123
+ name: 'Main Account', // Optional
124
+ cardUrn: 'did:bloque:card:456', // Optional - link with existing card
125
+ });
126
+ ```
127
+
128
+ **Parameters**:
129
+
130
+ ```typescript
131
+ interface CreateBancolombiaAccountParams {
132
+ /**
133
+ * URN of the account holder (user or organization)
134
+ * @example "did:bloque:user:123e4567"
135
+ */
136
+ urn: string;
137
+
138
+ /**
139
+ * Display name for the account (optional)
140
+ */
141
+ name?: string;
142
+
143
+ /**
144
+ * URN of an existing card to link with the Bancolombia account (optional)
145
+ * @example "did:bloque:card:123e4567"
146
+ */
147
+ cardUrn?: string;
148
+
149
+ /**
150
+ * Custom metadata to attach to the Bancolombia account (optional)
151
+ */
152
+ metadata?: Record<string, unknown>;
153
+ }
154
+ ```
155
+
156
+ **Returns**:
157
+
158
+ ```typescript
159
+ interface BancolombiaAccount {
160
+ urn: string; // Unique resource name
161
+ id: string; // Account ID
162
+ referenceCode: string; // Reference code for payments
163
+ status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
164
+ ownerUrn: string; // Owner URN
165
+ webhookUrl: string | null; // Webhook URL (if configured)
166
+ metadata?: Record<string, unknown>; // Custom metadata
167
+ createdAt: string; // Creation timestamp (ISO 8601)
168
+ updatedAt: string; // Last update timestamp (ISO 8601)
169
+ }
170
+ ```
171
+
102
172
  ## Complete Examples
103
173
 
104
174
  ### Basic Card Creation
@@ -199,6 +269,81 @@ try {
199
269
  }
200
270
  ```
201
271
 
272
+ ### Basic Bancolombia Account Creation
273
+
274
+ ```typescript
275
+ import { SDK } from '@bloque/sdk';
276
+
277
+ const bloque = new SDK({
278
+ apiKey: process.env.BLOQUE_API_KEY!,
279
+ mode: 'production',
280
+ });
281
+
282
+ // Create a Bancolombia account with just URN
283
+ const account = await bloque.accounts.bancolombia.create({
284
+ urn: 'did:bloque:user:123e4567',
285
+ });
286
+
287
+ console.log('Account created:', account.urn);
288
+ console.log('Reference code:', account.referenceCode);
289
+ console.log('Status:', account.status);
290
+ ```
291
+
292
+ ### Bancolombia Account with Card Link
293
+
294
+ ```typescript
295
+ import { SDK } from '@bloque/sdk';
296
+
297
+ const bloque = new SDK({
298
+ apiKey: process.env.BLOQUE_API_KEY!,
299
+ mode: 'production',
300
+ });
301
+
302
+ const userUrn = 'did:bloque:user:123e4567';
303
+
304
+ // Create a card first
305
+ const card = await bloque.accounts.card.create({
306
+ urn: userUrn,
307
+ name: 'My Card',
308
+ });
309
+
310
+ // Create Bancolombia account and link it to the card
311
+ const account = await bloque.accounts.bancolombia.create({
312
+ urn: userUrn,
313
+ name: 'Main Account',
314
+ cardUrn: card.urn, // Link to existing card
315
+ });
316
+
317
+ console.log('Card URN:', card.urn);
318
+ console.log('Account URN:', account.urn);
319
+ console.log('Reference code for payments:', account.referenceCode);
320
+ ```
321
+
322
+ ### Bancolombia Account with Metadata
323
+
324
+ ```typescript
325
+ import { SDK } from '@bloque/sdk';
326
+
327
+ const bloque = new SDK({
328
+ apiKey: process.env.BLOQUE_API_KEY!,
329
+ mode: 'production',
330
+ });
331
+
332
+ // Create Bancolombia account with custom metadata
333
+ const account = await bloque.accounts.bancolombia.create({
334
+ urn: 'did:bloque:user:123e4567',
335
+ name: 'Business Account',
336
+ metadata: {
337
+ purpose: 'business-payments',
338
+ department: 'sales',
339
+ customField: 'custom-value',
340
+ },
341
+ });
342
+
343
+ console.log('Account created with metadata:', account.metadata);
344
+ console.log('Reference code:', account.referenceCode);
345
+ ```
346
+
202
347
  ## TypeScript Support
203
348
 
204
349
  This package is written in TypeScript and includes complete type definitions:
@@ -207,32 +352,47 @@ This package is written in TypeScript and includes complete type definitions:
207
352
  import type {
208
353
  CardAccount,
209
354
  CreateCardParams,
355
+ BancolombiaAccount,
356
+ CreateBancolombiaAccountParams,
210
357
  } from '@bloque/sdk-accounts';
211
358
 
212
359
  // Type-safe card creation
213
- const params: CreateCardParams = {
360
+ const cardParams: CreateCardParams = {
214
361
  urn: 'did:bloque:user:123e4567',
215
362
  name: 'My Card', // Optional
216
363
  };
217
364
 
218
- const card: CardAccount = await bloque.accounts.card.create(params);
365
+ const card: CardAccount = await bloque.accounts.card.create(cardParams);
219
366
 
220
367
  // TypeScript infers all card properties with full type safety
221
368
  console.log(card.lastFour); // string
222
369
  console.log(card.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
223
370
  console.log(card.cardType); // 'VIRTUAL' | 'PHYSICAL'
371
+
372
+ // Type-safe Bancolombia account creation
373
+ const accountParams: CreateBancolombiaAccountParams = {
374
+ urn: 'did:bloque:user:123e4567',
375
+ name: 'Main Account', // Optional
376
+ cardUrn: card.urn, // Optional
377
+ };
378
+
379
+ const account: BancolombiaAccount = await bloque.accounts.bancolombia.create(accountParams);
380
+
381
+ // TypeScript infers all account properties with full type safety
382
+ console.log(account.referenceCode); // string
383
+ console.log(account.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
224
384
  ```
225
385
 
226
- ## Card Status
386
+ ## Account Status
227
387
 
228
- Cards have a status field indicating their current state:
388
+ Both cards and Bancolombia accounts have a status field indicating their current state:
229
389
 
230
- - `creation_in_progress`: Card is being created
231
- - `creation_failed`: Card creation failed
232
- - `active`: Card is active and ready to use
233
- - `disabled`: Card has been disabled
234
- - `frozen`: Card has been temporarily frozen
235
- - `deleted`: Card has been deleted
390
+ - `creation_in_progress`: Account/card is being created
391
+ - `creation_failed`: Account/card creation failed
392
+ - `active`: Account/card is active and ready to use
393
+ - `disabled`: Account/card has been disabled
394
+ - `frozen`: Account/card has been temporarily frozen
395
+ - `deleted`: Account/card has been deleted
236
396
 
237
397
  ## Requirements
238
398
 
package/dist/index.cjs CHANGED
@@ -25,9 +25,10 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  AccountsClient: ()=>AccountsClient,
28
- CardClient: ()=>CardClient
28
+ CardClient: ()=>CardClient,
29
+ BancolombiaClient: ()=>BancolombiaClient
29
30
  });
30
- class CardClient {
31
+ class BancolombiaClient {
31
32
  httpClient;
32
33
  constructor(httpClient){
33
34
  this.httpClient = httpClient;
@@ -35,31 +36,25 @@ class CardClient {
35
36
  async create(params) {
36
37
  const request = {
37
38
  holder_urn: params.urn,
38
- input: {
39
- create: {
40
- card_type: 'VIRTUAL'
41
- }
42
- },
39
+ input: {},
43
40
  metadata: {
44
41
  source: "sdk-typescript",
45
42
  name: params.name,
43
+ card_urn: params.cardUrn,
46
44
  ...params.metadata
47
45
  }
48
46
  };
49
47
  const response = await this.httpClient.request({
50
48
  method: 'POST',
51
- path: '/api/mediums/card',
49
+ path: '/api/mediums/bancolombia',
52
50
  body: request
53
51
  });
54
52
  const account = response.result.account;
55
53
  return {
56
54
  urn: account.urn,
57
55
  id: account.id,
58
- lastFour: account.details.card_last_four,
59
- productType: account.details.card_product_type,
56
+ referenceCode: account.details.reference_code,
60
57
  status: account.status,
61
- cardType: account.details.card_type,
62
- detailsUrl: account.details.card_url_details,
63
58
  ownerUrn: account.owner_urn,
64
59
  webhookUrl: account.webhook_url,
65
60
  metadata: account.metadata,
@@ -68,7 +63,7 @@ class CardClient {
68
63
  };
69
64
  }
70
65
  }
71
- class BancolombiaClient {
66
+ class CardClient {
72
67
  httpClient;
73
68
  constructor(httpClient){
74
69
  this.httpClient = httpClient;
@@ -76,25 +71,31 @@ class BancolombiaClient {
76
71
  async create(params) {
77
72
  const request = {
78
73
  holder_urn: params.urn,
79
- input: {},
74
+ input: {
75
+ create: {
76
+ card_type: 'VIRTUAL'
77
+ }
78
+ },
80
79
  metadata: {
81
80
  source: "sdk-typescript",
82
81
  name: params.name,
83
- card_urn: params.cardUrn,
84
82
  ...params.metadata
85
83
  }
86
84
  };
87
85
  const response = await this.httpClient.request({
88
86
  method: 'POST',
89
- path: '/api/mediums/bancolombia',
87
+ path: '/api/mediums/card',
90
88
  body: request
91
89
  });
92
90
  const account = response.result.account;
93
91
  return {
94
92
  urn: account.urn,
95
93
  id: account.id,
96
- referenceCode: account.details.reference_code,
94
+ lastFour: account.details.card_last_four,
95
+ productType: account.details.card_product_type,
97
96
  status: account.status,
97
+ cardType: account.details.card_type,
98
+ detailsUrl: account.details.card_url_details,
98
99
  ownerUrn: account.owner_urn,
99
100
  webhookUrl: account.webhook_url,
100
101
  metadata: account.metadata,
@@ -114,9 +115,11 @@ class AccountsClient {
114
115
  }
115
116
  }
116
117
  exports.AccountsClient = __webpack_exports__.AccountsClient;
118
+ exports.BancolombiaClient = __webpack_exports__.BancolombiaClient;
117
119
  exports.CardClient = __webpack_exports__.CardClient;
118
120
  for(var __rspack_i in __webpack_exports__)if (-1 === [
119
121
  "AccountsClient",
122
+ "BancolombiaClient",
120
123
  "CardClient"
121
124
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
122
125
  Object.defineProperty(exports, '__esModule', {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './bancolombia/client';
2
+ export * from './bancolombia/types';
1
3
  export * from './card/client';
2
4
  export * from './card/types';
3
5
  export * from './client';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- class CardClient {
1
+ class BancolombiaClient {
2
2
  httpClient;
3
3
  constructor(httpClient){
4
4
  this.httpClient = httpClient;
@@ -6,31 +6,25 @@ class CardClient {
6
6
  async create(params) {
7
7
  const request = {
8
8
  holder_urn: params.urn,
9
- input: {
10
- create: {
11
- card_type: 'VIRTUAL'
12
- }
13
- },
9
+ input: {},
14
10
  metadata: {
15
11
  source: "sdk-typescript",
16
12
  name: params.name,
13
+ card_urn: params.cardUrn,
17
14
  ...params.metadata
18
15
  }
19
16
  };
20
17
  const response = await this.httpClient.request({
21
18
  method: 'POST',
22
- path: '/api/mediums/card',
19
+ path: '/api/mediums/bancolombia',
23
20
  body: request
24
21
  });
25
22
  const account = response.result.account;
26
23
  return {
27
24
  urn: account.urn,
28
25
  id: account.id,
29
- lastFour: account.details.card_last_four,
30
- productType: account.details.card_product_type,
26
+ referenceCode: account.details.reference_code,
31
27
  status: account.status,
32
- cardType: account.details.card_type,
33
- detailsUrl: account.details.card_url_details,
34
28
  ownerUrn: account.owner_urn,
35
29
  webhookUrl: account.webhook_url,
36
30
  metadata: account.metadata,
@@ -39,7 +33,7 @@ class CardClient {
39
33
  };
40
34
  }
41
35
  }
42
- class BancolombiaClient {
36
+ class CardClient {
43
37
  httpClient;
44
38
  constructor(httpClient){
45
39
  this.httpClient = httpClient;
@@ -47,25 +41,31 @@ class BancolombiaClient {
47
41
  async create(params) {
48
42
  const request = {
49
43
  holder_urn: params.urn,
50
- input: {},
44
+ input: {
45
+ create: {
46
+ card_type: 'VIRTUAL'
47
+ }
48
+ },
51
49
  metadata: {
52
50
  source: "sdk-typescript",
53
51
  name: params.name,
54
- card_urn: params.cardUrn,
55
52
  ...params.metadata
56
53
  }
57
54
  };
58
55
  const response = await this.httpClient.request({
59
56
  method: 'POST',
60
- path: '/api/mediums/bancolombia',
57
+ path: '/api/mediums/card',
61
58
  body: request
62
59
  });
63
60
  const account = response.result.account;
64
61
  return {
65
62
  urn: account.urn,
66
63
  id: account.id,
67
- referenceCode: account.details.reference_code,
64
+ lastFour: account.details.card_last_four,
65
+ productType: account.details.card_product_type,
68
66
  status: account.status,
67
+ cardType: account.details.card_type,
68
+ detailsUrl: account.details.card_url_details,
69
69
  ownerUrn: account.owner_urn,
70
70
  webhookUrl: account.webhook_url,
71
71
  metadata: account.metadata,
@@ -84,4 +84,4 @@ class AccountsClient {
84
84
  this.card = new CardClient(this.httpClient);
85
85
  }
86
86
  }
87
- export { AccountsClient, CardClient };
87
+ export { AccountsClient, BancolombiaClient, CardClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-accounts",
3
- "version": "0.0.4",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bloque",
@@ -36,6 +36,7 @@
36
36
  "node": ">=22"
37
37
  },
38
38
  "scripts": {
39
+ "release": "bun publish",
39
40
  "build": "rslib build",
40
41
  "dev": "rslib build --watch",
41
42
  "clean": "rm -rf node_modules && rm -rf dist",
@@ -43,12 +44,12 @@
43
44
  "typecheck": "tsgo --noEmit"
44
45
  },
45
46
  "dependencies": {
46
- "@bloque/sdk-core": "workspace:*"
47
+ "@bloque/sdk-core": "0.0.2"
47
48
  },
48
49
  "devDependencies": {
49
- "@rslib/core": "catalog:",
50
- "@types/node": "catalog:",
51
- "@typescript/native-preview": "catalog:",
52
- "typescript": "catalog:"
50
+ "@rslib/core": "^0.18.4",
51
+ "@types/node": "^24.10.1",
52
+ "@typescript/native-preview": "latest",
53
+ "typescript": "^5.9.3"
53
54
  }
54
55
  }