@bloque/sdk-accounts 0.0.23 → 0.0.24

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.
@@ -1,8 +1,9 @@
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';
4
- import { BancolombiaClient } from './bancolombia/client';
5
- import { CardClient } from './card/client';
3
+ import { BancolombiaClient } from './bancolombia/bancolombia-client';
4
+ import { CardClient } from './card/card-client';
5
+ import type { TransferParams, TransferResult } from './types';
6
+ import { VirtualClient } from './virtual/virtual-client';
6
7
  /**
7
8
  * Accounts client for managing financial accounts and payment methods
8
9
  *
@@ -16,6 +17,7 @@ import { CardClient } from './card/client';
16
17
  export declare class AccountsClient extends BaseClient {
17
18
  readonly bancolombia: BancolombiaClient;
18
19
  readonly card: CardClient;
20
+ readonly virtual: VirtualClient;
19
21
  constructor(httpClient: HttpClient);
20
22
  /**
21
23
  * Transfer funds between accounts
@@ -10,12 +10,11 @@ export declare class BancolombiaClient extends BaseClient {
10
10
  * @example
11
11
  * ```typescript
12
12
  * const account = await bloque.accounts.bancolombia.create({
13
- * urn: 'did:bloque:user:123',
14
13
  * name: 'Main Account'
15
14
  * });
16
15
  * ```
17
16
  */
18
- create(params: CreateBancolombiaAccountParams): Promise<BancolombiaAccount>;
17
+ create(params?: CreateBancolombiaAccountParams): Promise<BancolombiaAccount>;
19
18
  /**
20
19
  * Update Bancolombia account metadata
21
20
  *
@@ -4,7 +4,7 @@ export interface CreateBancolombiaAccountParams {
4
4
  *
5
5
  * @example "did:bloque:user:123e4567"
6
6
  */
7
- urn: string;
7
+ holderUrn?: string;
8
8
  /**
9
9
  * Display name for the card
10
10
  */
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from '@bloque/sdk-core';
2
- import type { TokenBalance } from '../api-types';
2
+ import type { TokenBalance } from '../internal/wire-types';
3
3
  import type { CardAccount, CardMovement, CreateCardParams, GetBalanceParams, ListCardParams, ListMovementsParams, UpdateCardMetadataParams } from './types';
4
4
  export declare class CardClient extends BaseClient {
5
5
  /**
@@ -11,12 +11,11 @@ export declare class CardClient extends BaseClient {
11
11
  * @example
12
12
  * ```typescript
13
13
  * const card = await bloque.accounts.card.create({
14
- * urn: 'did:bloque:user:123',
15
14
  * name: 'My Card',
16
15
  * });
17
16
  * ```
18
17
  */
19
- create(params: CreateCardParams): Promise<CardAccount>;
18
+ create(params?: CreateCardParams): Promise<CardAccount>;
20
19
  /**
21
20
  * List card accounts for a holder
22
21
  *
@@ -25,9 +24,7 @@ export declare class CardClient extends BaseClient {
25
24
  *
26
25
  * @example
27
26
  * ```typescript
28
- * const cards = await bloque.accounts.card.list({
29
- * holderUrn: 'did:bloque:bloque-whatsapp:573023348486',
30
- * });
27
+ * const cards = await bloque.accounts.card.list();
31
28
  * ```
32
29
  */
33
30
  list(params?: ListCardParams): Promise<CardAccount[]>;
@@ -1,11 +1,12 @@
1
- import type { CardType, SupportedAsset, TokenBalance, Transaction } from '../api-types';
1
+ import type { CardType, TokenBalance, Transaction } from '../internal/wire-types';
2
+ import type { SupportedAsset } from '../types';
2
3
  export interface ListCardParams {
3
4
  /**
4
- * URN of the account holder to filter by
5
+ * URN of the account holder (user or organization)
5
6
  *
6
- * @example "did:bloque:bloque-whatsapp:573023348486"
7
+ * @example "did:bloque:user:123e4567"
7
8
  */
8
- holderUrn: string;
9
+ holderUrn?: string;
9
10
  }
10
11
  export interface ListMovementsParams {
11
12
  /**
@@ -67,7 +68,7 @@ export interface CreateCardParams {
67
68
  *
68
69
  * @example "did:bloque:user:123e4567"
69
70
  */
70
- urn: string;
71
+ holderUrn?: string;
71
72
  /**
72
73
  * Display name for the card
73
74
  */
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 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});
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=(t,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{CardClient:()=>CardClient,VirtualClient:()=>VirtualClient,AccountsClient:()=>AccountsClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.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 CardClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.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.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 VirtualClient extends sdk_core_namespaceObject.BaseClient{async create(t){let e={first_name:t.firstName,last_name:t.lastName},a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:e,metadata:{source:"sdk-typescript",...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(r.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 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,firstName:t.details.first_name,lastName:t.details.last_name,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 AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;virtual;constructor(t){super(t),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient),this.virtual=new VirtualClient(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}}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,exports.VirtualClient=__webpack_exports__.VirtualClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient","VirtualClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- export * from './bancolombia/client';
1
+ export * from './accounts-client';
2
+ export * from './bancolombia/bancolombia-client';
2
3
  export * from './bancolombia/types';
3
- export * from './card/client';
4
+ export * from './card/card-client';
4
5
  export * from './card/types';
5
- export * from './client';
6
+ export * from './types';
7
+ export * from './virtual/types';
8
+ export * from './virtual/virtual-client';
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 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};
1
+ import{BaseClient as t}from"@bloque/sdk-core";class e extends t{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.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?.holderUrn||this.httpClient.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.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{async create(t){let e={first_name:t.firstName,last_name:t.lastName},a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:e,metadata:{source:"sdk-typescript",...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(r.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 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,firstName:t.details.first_name,lastName:t.details.last_name,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 s extends t{bancolombia;card;virtual;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient),this.virtual=new r(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{s as AccountsClient,e as BancolombiaClient,a as CardClient,r as VirtualClient};
@@ -1,8 +1,22 @@
1
+ /**
2
+ * @internal
3
+ * Wire types for API communication (snake_case format)
4
+ * These types represent the raw API request/response format
5
+ * and should not be used directly by SDK consumers.
6
+ */
7
+ /**
8
+ * @internal
9
+ * Account status from API
10
+ */
1
11
  export type AccountStatus = 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
2
- interface Account<TDetails = unknown> {
12
+ /**
13
+ * @internal
14
+ * Raw account from API
15
+ */
16
+ export interface Account<TDetails = unknown> {
3
17
  id: string;
4
18
  urn: string;
5
- medium: 'bancolombia' | 'card';
19
+ medium: 'bancolombia' | 'card' | 'virtual';
6
20
  details: TDetails;
7
21
  ledger_account_id: string;
8
22
  status: AccountStatus;
@@ -12,7 +26,15 @@ interface Account<TDetails = unknown> {
12
26
  webhook_url: string | null;
13
27
  metadata?: Record<string, unknown>;
14
28
  }
29
+ /**
30
+ * @internal
31
+ * Card type enum
32
+ */
15
33
  export type CardType = 'VIRTUAL' | 'PHYSICAL';
34
+ /**
35
+ * @internal
36
+ * Create account request body
37
+ */
16
38
  export interface CreateAccountRequest<TInput = unknown> {
17
39
  holder_urn: string;
18
40
  ledger_account_id?: string;
@@ -20,17 +42,29 @@ export interface CreateAccountRequest<TInput = unknown> {
20
42
  metadata?: Record<string, unknown>;
21
43
  webhook_url?: string;
22
44
  }
45
+ /**
46
+ * @internal
47
+ * Card account input for creation
48
+ */
23
49
  export type CreateCardAccountInput = {
24
50
  create: {
25
51
  card_type: CardType;
26
52
  };
27
53
  };
54
+ /**
55
+ * @internal
56
+ * Create account response
57
+ */
28
58
  export interface CreateAccountResponse<TDetails = unknown> {
29
59
  result: {
30
60
  account: Account<TDetails>;
31
61
  };
32
62
  req_id: string;
33
63
  }
64
+ /**
65
+ * @internal
66
+ * Card details from API
67
+ */
34
68
  export type CardDetails = {
35
69
  id: string;
36
70
  email: string;
@@ -45,35 +79,80 @@ export type CardDetails = {
45
79
  card_type: CardType;
46
80
  user_id: string;
47
81
  };
82
+ /**
83
+ * @internal
84
+ * Bancolombia details from API
85
+ */
48
86
  export type BancolombiaDetails = {
49
87
  id: string;
50
88
  reference_code: string;
51
89
  payment_agreement_code: string;
52
90
  network: string[];
53
91
  };
92
+ /**
93
+ * @internal
94
+ * Virtual account input for creation
95
+ */
96
+ export type CreateVirtualAccountInput = {
97
+ first_name: string;
98
+ last_name: string;
99
+ };
100
+ /**
101
+ * @internal
102
+ * Virtual account details from API
103
+ */
104
+ export type VirtualDetails = {
105
+ id: string;
106
+ first_name: string;
107
+ last_name: string;
108
+ };
109
+ /**
110
+ * @internal
111
+ * Update account request body
112
+ */
54
113
  export interface UpdateAccountRequest<TInput = unknown> {
55
114
  input?: TInput;
56
115
  metadata?: Record<string, unknown>;
57
116
  status?: AccountStatus;
58
117
  }
118
+ /**
119
+ * @internal
120
+ * Update account response
121
+ */
59
122
  export interface UpdateAccountResponse<TDetails = unknown> {
60
123
  result: {
61
124
  account: Account<TDetails>;
62
125
  };
63
126
  req_id: string;
64
127
  }
128
+ /**
129
+ * @internal
130
+ * Token balance from API
131
+ */
65
132
  export interface TokenBalance {
66
133
  current: string;
67
134
  pending: string;
68
135
  in: string;
69
136
  out: string;
70
137
  }
138
+ /**
139
+ * @internal
140
+ * Account with balance from API
141
+ */
71
142
  export interface AccountWithBalance<TDetails = unknown> extends Account<TDetails> {
72
143
  balance: Record<string, TokenBalance>;
73
144
  }
145
+ /**
146
+ * @internal
147
+ * List accounts response
148
+ */
74
149
  export interface ListAccountsResponse<TDetails = unknown> {
75
150
  accounts: AccountWithBalance<TDetails>[];
76
151
  }
152
+ /**
153
+ * @internal
154
+ * Transaction metadata from API
155
+ */
77
156
  export interface TransactionMetadata {
78
157
  amount?: string;
79
158
  asset_type?: string;
@@ -103,10 +182,18 @@ export interface TransactionMetadata {
103
182
  user_id?: string;
104
183
  [key: string]: unknown;
105
184
  }
185
+ /**
186
+ * @internal
187
+ * Transaction details from API
188
+ */
106
189
  export interface TransactionDetails {
107
190
  metadata: TransactionMetadata;
108
191
  type: string;
109
192
  }
193
+ /**
194
+ * @internal
195
+ * Transaction from API
196
+ */
110
197
  export interface Transaction {
111
198
  amount: string;
112
199
  asset: string;
@@ -118,51 +205,34 @@ export interface Transaction {
118
205
  details: TransactionDetails;
119
206
  created_at: string;
120
207
  }
208
+ /**
209
+ * @internal
210
+ * List movements response
211
+ */
121
212
  export interface ListMovementsResponse {
122
213
  transactions: Transaction[];
123
214
  }
215
+ /**
216
+ * @internal
217
+ * Get balance response
218
+ */
124
219
  export interface GetBalanceResponse {
125
220
  balance: Record<string, TokenBalance>;
126
221
  }
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
- }
222
+ /**
223
+ * @internal
224
+ * Transfer request body
225
+ */
155
226
  export interface TransferRequest {
156
227
  destination_account_urn: string;
157
228
  amount: string;
158
229
  asset: string;
159
230
  metadata?: Record<string, unknown>;
160
231
  }
161
- export interface TransferResult {
162
- queueId: string;
163
- status: 'queued' | 'processing' | 'completed' | 'failed';
164
- message: string;
165
- }
232
+ /**
233
+ * @internal
234
+ * Transfer response from API
235
+ */
166
236
  export interface TransferResponse {
167
237
  result: {
168
238
  queue_id: string;
@@ -171,4 +241,3 @@ export interface TransferResponse {
171
241
  };
172
242
  req_id: string;
173
243
  }
174
- export {};
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Public types for @bloque/sdk-accounts
3
+ */
4
+ /**
5
+ * Supported asset types for transfers and movements
6
+ */
7
+ export type SupportedAsset = 'DUSD/6' | 'KSM/12';
8
+ /**
9
+ * Parameters for transferring funds between accounts
10
+ */
11
+ export interface TransferParams {
12
+ /**
13
+ * URN of the source account
14
+ * @example "did:bloque:account:card:usr-123:crd-456"
15
+ */
16
+ sourceUrn: string;
17
+ /**
18
+ * URN of the destination account
19
+ * @example "did:bloque:account:virtual:acc-67890"
20
+ */
21
+ destinationUrn: string;
22
+ /**
23
+ * Amount to transfer (as string to preserve precision)
24
+ * @example "1000000000000"
25
+ */
26
+ amount: string;
27
+ /**
28
+ * Asset to transfer
29
+ * @example "DUSD/6"
30
+ */
31
+ asset: SupportedAsset;
32
+ /**
33
+ * Optional metadata for the transfer
34
+ * @example { reference: "payment-123", note: "Monthly subscription" }
35
+ */
36
+ metadata?: Record<string, unknown>;
37
+ }
38
+ /**
39
+ * Result of a transfer operation
40
+ */
41
+ export interface TransferResult {
42
+ /** Unique identifier for the queued transfer */
43
+ queueId: string;
44
+ /** Current status of the transfer */
45
+ status: 'queued' | 'processing' | 'completed' | 'failed';
46
+ /** Human-readable message about the transfer status */
47
+ message: string;
48
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Parameters for creating a virtual account
3
+ */
4
+ export interface CreateVirtualAccountParams {
5
+ /**
6
+ * URN of the account holder (user or organization)
7
+ *
8
+ * @example "did:bloque:user:123e4567"
9
+ */
10
+ holderUrn?: string;
11
+ /**
12
+ * Account holder's first name
13
+ *
14
+ * @example "John"
15
+ */
16
+ firstName: string;
17
+ /**
18
+ * Account holder's last name
19
+ *
20
+ * @example "Doe"
21
+ */
22
+ lastName: string;
23
+ /**
24
+ * Ledger account ID to associate with the virtual account
25
+ * If not provided, a new ledger account will be created automatically
26
+ */
27
+ ledgerId?: string;
28
+ /**
29
+ * Webhook URL to receive account events
30
+ */
31
+ webhookUrl?: string;
32
+ /**
33
+ * Custom metadata to attach to the virtual account
34
+ * Must be a Record<string, string> (all values must be strings)
35
+ */
36
+ metadata?: Record<string, string>;
37
+ }
38
+ /**
39
+ * Parameters for updating virtual account metadata
40
+ */
41
+ export interface UpdateVirtualMetadataParams {
42
+ /**
43
+ * URN of the virtual account to update
44
+ *
45
+ * @example "did:bloque:mediums:virtual:account:123e4567"
46
+ */
47
+ urn: string;
48
+ /**
49
+ * Metadata to update
50
+ * Note: 'source' is a reserved field and cannot be modified
51
+ */
52
+ metadata: Record<string, string> & {
53
+ source?: never;
54
+ };
55
+ }
56
+ /**
57
+ * Virtual account response
58
+ */
59
+ export interface VirtualAccount {
60
+ /**
61
+ * Unique resource name for the virtual account
62
+ */
63
+ urn: string;
64
+ /**
65
+ * Account ID
66
+ */
67
+ id: string;
68
+ /**
69
+ * Account holder's first name
70
+ */
71
+ firstName: string;
72
+ /**
73
+ * Account holder's last name
74
+ */
75
+ lastName: string;
76
+ /**
77
+ * Account status
78
+ */
79
+ status: 'creation_in_progress' | 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_failed';
80
+ /**
81
+ * Owner URN
82
+ */
83
+ ownerUrn: string;
84
+ /**
85
+ * Ledger account ID associated with the virtual account
86
+ */
87
+ ledgerId: string;
88
+ /**
89
+ * Webhook URL (if configured)
90
+ */
91
+ webhookUrl: string | null;
92
+ /**
93
+ * Custom metadata
94
+ */
95
+ metadata?: Record<string, string>;
96
+ /**
97
+ * Creation timestamp
98
+ */
99
+ createdAt: string;
100
+ /**
101
+ * Last update timestamp
102
+ */
103
+ updatedAt: string;
104
+ }
@@ -0,0 +1,90 @@
1
+ import { BaseClient } from '@bloque/sdk-core';
2
+ import type { CreateVirtualAccountParams, UpdateVirtualMetadataParams, VirtualAccount } from './types';
3
+ export declare class VirtualClient extends BaseClient {
4
+ /**
5
+ * Create a new virtual account
6
+ *
7
+ * Virtual accounts are simple testing accounts requiring only basic personal information.
8
+ * They're useful for development and testing purposes.
9
+ *
10
+ * @param params - Virtual account creation parameters
11
+ * @returns Promise resolving to the created virtual account
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const account = await bloque.accounts.virtual.create({
16
+ * firstName: 'John',
17
+ * lastName: 'Doe'
18
+ * });
19
+ * ```
20
+ */
21
+ create(params: CreateVirtualAccountParams): Promise<VirtualAccount>;
22
+ /**
23
+ * Update virtual account metadata
24
+ *
25
+ * @param params - Metadata update parameters
26
+ * @returns Promise resolving to the updated virtual account
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const account = await bloque.accounts.virtual.updateMetadata({
31
+ * urn: 'did:bloque:mediums:virtual:account:123',
32
+ * metadata: {
33
+ * updated_by: 'admin',
34
+ * update_reason: 'testing_update'
35
+ * }
36
+ * });
37
+ * ```
38
+ */
39
+ updateMetadata(params: UpdateVirtualMetadataParams): Promise<VirtualAccount>;
40
+ /**
41
+ * Activate a virtual account
42
+ *
43
+ * @param urn - Virtual account URN
44
+ * @returns Promise resolving to the updated virtual account
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const account = await bloque.accounts.virtual.activate(
49
+ * 'did:bloque:mediums:virtual:account:123'
50
+ * );
51
+ * ```
52
+ */
53
+ activate(urn: string): Promise<VirtualAccount>;
54
+ /**
55
+ * Freeze a virtual account
56
+ *
57
+ * @param urn - Virtual account URN
58
+ * @returns Promise resolving to the updated virtual account
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const account = await bloque.accounts.virtual.freeze(
63
+ * 'did:bloque:mediums:virtual:account:123'
64
+ * );
65
+ * ```
66
+ */
67
+ freeze(urn: string): Promise<VirtualAccount>;
68
+ /**
69
+ * Disable a virtual account
70
+ *
71
+ * @param urn - Virtual account URN
72
+ * @returns Promise resolving to the updated virtual account
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const account = await bloque.accounts.virtual.disable(
77
+ * 'did:bloque:mediums:virtual:account:123'
78
+ * );
79
+ * ```
80
+ */
81
+ disable(urn: string): Promise<VirtualAccount>;
82
+ /**
83
+ * Private method to update virtual account status
84
+ */
85
+ private _updateStatus;
86
+ /**
87
+ * Private method to map API response to VirtualAccount
88
+ */
89
+ private _mapAccountResponse;
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-accounts",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
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.23"
39
+ "@bloque/sdk-core": "0.0.24"
40
40
  }
41
41
  }