@bloque/sdk-accounts 0.0.23 → 0.0.25

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,10 @@
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 { PolygonClient } from './polygon/polygon-client';
6
+ import type { TransferParams, TransferResult } from './types';
7
+ import { VirtualClient } from './virtual/virtual-client';
6
8
  /**
7
9
  * Accounts client for managing financial accounts and payment methods
8
10
  *
@@ -16,6 +18,8 @@ import { CardClient } from './card/client';
16
18
  export declare class AccountsClient extends BaseClient {
17
19
  readonly bancolombia: BancolombiaClient;
18
20
  readonly card: CardClient;
21
+ readonly polygon: PolygonClient;
22
+ readonly virtual: VirtualClient;
19
23
  constructor(httpClient: HttpClient);
20
24
  /**
21
25
  * 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,PolygonClient:()=>PolygonClient,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 PolygonClient 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",...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",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 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,address:t.details.address,network:t.details.network,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 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;polygon;virtual;constructor(t){super(t),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient),this.polygon=new PolygonClient(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.PolygonClient=__webpack_exports__.PolygonClient,exports.VirtualClient=__webpack_exports__.VirtualClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient","PolygonClient","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,10 @@
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 './polygon/polygon-client';
7
+ export * from './polygon/types';
8
+ export * from './types';
9
+ export * from './virtual/types';
10
+ 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 s=e.toString(),r=`/api/accounts/${t.urn}/movements${s?`?${s}`:""}`;return(await this.httpClient.request({method:"GET",path:r})).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 s 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",...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",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 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,address:t.details.address,network:t.details.network,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 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}},s=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(s.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 n extends t{bancolombia;card;polygon;virtual;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient),this.polygon=new s(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},s=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:s.result.queue_id,status:s.result.status,message:s.result.message}}}export{n as AccountsClient,e as BancolombiaClient,a as CardClient,s as PolygonClient,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' | 'polygon';
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,94 @@ 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
+ * Polygon account input for creation
112
+ */
113
+ export type CreatePolygonAccountInput = Record<string, never>;
114
+ /**
115
+ * @internal
116
+ * Polygon account details from API
117
+ */
118
+ export type PolygonDetails = {
119
+ id: string;
120
+ address: string;
121
+ network: string;
122
+ };
123
+ /**
124
+ * @internal
125
+ * Update account request body
126
+ */
54
127
  export interface UpdateAccountRequest<TInput = unknown> {
55
128
  input?: TInput;
56
129
  metadata?: Record<string, unknown>;
57
130
  status?: AccountStatus;
58
131
  }
132
+ /**
133
+ * @internal
134
+ * Update account response
135
+ */
59
136
  export interface UpdateAccountResponse<TDetails = unknown> {
60
137
  result: {
61
138
  account: Account<TDetails>;
62
139
  };
63
140
  req_id: string;
64
141
  }
142
+ /**
143
+ * @internal
144
+ * Token balance from API
145
+ */
65
146
  export interface TokenBalance {
66
147
  current: string;
67
148
  pending: string;
68
149
  in: string;
69
150
  out: string;
70
151
  }
152
+ /**
153
+ * @internal
154
+ * Account with balance from API
155
+ */
71
156
  export interface AccountWithBalance<TDetails = unknown> extends Account<TDetails> {
72
157
  balance: Record<string, TokenBalance>;
73
158
  }
159
+ /**
160
+ * @internal
161
+ * List accounts response
162
+ */
74
163
  export interface ListAccountsResponse<TDetails = unknown> {
75
164
  accounts: AccountWithBalance<TDetails>[];
76
165
  }
166
+ /**
167
+ * @internal
168
+ * Transaction metadata from API
169
+ */
77
170
  export interface TransactionMetadata {
78
171
  amount?: string;
79
172
  asset_type?: string;
@@ -103,10 +196,18 @@ export interface TransactionMetadata {
103
196
  user_id?: string;
104
197
  [key: string]: unknown;
105
198
  }
199
+ /**
200
+ * @internal
201
+ * Transaction details from API
202
+ */
106
203
  export interface TransactionDetails {
107
204
  metadata: TransactionMetadata;
108
205
  type: string;
109
206
  }
207
+ /**
208
+ * @internal
209
+ * Transaction from API
210
+ */
110
211
  export interface Transaction {
111
212
  amount: string;
112
213
  asset: string;
@@ -118,51 +219,34 @@ export interface Transaction {
118
219
  details: TransactionDetails;
119
220
  created_at: string;
120
221
  }
222
+ /**
223
+ * @internal
224
+ * List movements response
225
+ */
121
226
  export interface ListMovementsResponse {
122
227
  transactions: Transaction[];
123
228
  }
229
+ /**
230
+ * @internal
231
+ * Get balance response
232
+ */
124
233
  export interface GetBalanceResponse {
125
234
  balance: Record<string, TokenBalance>;
126
235
  }
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
- }
236
+ /**
237
+ * @internal
238
+ * Transfer request body
239
+ */
155
240
  export interface TransferRequest {
156
241
  destination_account_urn: string;
157
242
  amount: string;
158
243
  asset: string;
159
244
  metadata?: Record<string, unknown>;
160
245
  }
161
- export interface TransferResult {
162
- queueId: string;
163
- status: 'queued' | 'processing' | 'completed' | 'failed';
164
- message: string;
165
- }
246
+ /**
247
+ * @internal
248
+ * Transfer response from API
249
+ */
166
250
  export interface TransferResponse {
167
251
  result: {
168
252
  queue_id: string;
@@ -171,4 +255,3 @@ export interface TransferResponse {
171
255
  };
172
256
  req_id: string;
173
257
  }
174
- export {};
@@ -0,0 +1,87 @@
1
+ import { BaseClient } from '@bloque/sdk-core';
2
+ import type { CreatePolygonAccountParams, PolygonAccount, UpdatePolygonMetadataParams } from './types';
3
+ export declare class PolygonClient extends BaseClient {
4
+ /**
5
+ * Create a new polygon account
6
+ *
7
+ * Polygon accounts are cryptocurrency wallets on the Polygon network.
8
+ * They're created automatically without requiring additional input.
9
+ *
10
+ * @param params - Polygon account creation parameters
11
+ * @returns Promise resolving to the created polygon account
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const account = await bloque.accounts.polygon.create();
16
+ * ```
17
+ */
18
+ create(params?: CreatePolygonAccountParams): Promise<PolygonAccount>;
19
+ /**
20
+ * Update polygon account metadata
21
+ *
22
+ * @param params - Metadata update parameters
23
+ * @returns Promise resolving to the updated polygon account
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const account = await bloque.accounts.polygon.updateMetadata({
28
+ * urn: 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731',
29
+ * metadata: {
30
+ * updated_by: 'admin',
31
+ * update_reason: 'testing_update'
32
+ * }
33
+ * });
34
+ * ```
35
+ */
36
+ updateMetadata(params: UpdatePolygonMetadataParams): Promise<PolygonAccount>;
37
+ /**
38
+ * Activate a polygon account
39
+ *
40
+ * @param urn - Polygon account URN
41
+ * @returns Promise resolving to the updated polygon account
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const account = await bloque.accounts.polygon.activate(
46
+ * 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731'
47
+ * );
48
+ * ```
49
+ */
50
+ activate(urn: string): Promise<PolygonAccount>;
51
+ /**
52
+ * Freeze a polygon account
53
+ *
54
+ * @param urn - Polygon account URN
55
+ * @returns Promise resolving to the updated polygon account
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const account = await bloque.accounts.polygon.freeze(
60
+ * 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731'
61
+ * );
62
+ * ```
63
+ */
64
+ freeze(urn: string): Promise<PolygonAccount>;
65
+ /**
66
+ * Disable a polygon account
67
+ *
68
+ * @param urn - Polygon account URN
69
+ * @returns Promise resolving to the updated polygon account
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const account = await bloque.accounts.polygon.disable(
74
+ * 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731'
75
+ * );
76
+ * ```
77
+ */
78
+ disable(urn: string): Promise<PolygonAccount>;
79
+ /**
80
+ * Private method to update polygon account status
81
+ */
82
+ private _updateStatus;
83
+ /**
84
+ * Private method to map API response to PolygonAccount
85
+ */
86
+ private _mapAccountResponse;
87
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Parameters for creating a polygon account
3
+ */
4
+ export interface CreatePolygonAccountParams {
5
+ /**
6
+ * URN of the account holder (user or organization)
7
+ *
8
+ * @example "did:bloque:user:123e4567"
9
+ */
10
+ holderUrn?: string;
11
+ /**
12
+ * Ledger account ID to associate with the polygon account
13
+ * If not provided, a new ledger account will be created automatically
14
+ */
15
+ ledgerId?: string;
16
+ /**
17
+ * Webhook URL to receive account events
18
+ */
19
+ webhookUrl?: string;
20
+ /**
21
+ * Custom metadata to attach to the polygon account
22
+ * Must be a Record<string, string> (all values must be strings)
23
+ */
24
+ metadata?: Record<string, string>;
25
+ }
26
+ /**
27
+ * Parameters for updating polygon account metadata
28
+ */
29
+ export interface UpdatePolygonMetadataParams {
30
+ /**
31
+ * URN of the polygon account to update
32
+ *
33
+ * @example "did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731"
34
+ */
35
+ urn: string;
36
+ /**
37
+ * Metadata to update
38
+ * Note: 'source' is a reserved field and cannot be modified
39
+ */
40
+ metadata: Record<string, string> & {
41
+ source?: never;
42
+ };
43
+ }
44
+ /**
45
+ * Polygon account response
46
+ */
47
+ export interface PolygonAccount {
48
+ /**
49
+ * Unique resource name for the polygon account
50
+ */
51
+ urn: string;
52
+ /**
53
+ * Account ID
54
+ */
55
+ id: string;
56
+ /**
57
+ * Polygon wallet address
58
+ */
59
+ address: string;
60
+ /**
61
+ * Network name (always "polygon")
62
+ */
63
+ network: string;
64
+ /**
65
+ * Account status
66
+ */
67
+ status: 'creation_in_progress' | 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_failed';
68
+ /**
69
+ * Owner URN
70
+ */
71
+ ownerUrn: string;
72
+ /**
73
+ * Ledger account ID associated with the polygon account
74
+ */
75
+ ledgerId: string;
76
+ /**
77
+ * Webhook URL (if configured)
78
+ */
79
+ webhookUrl: string | null;
80
+ /**
81
+ * Custom metadata
82
+ */
83
+ metadata?: Record<string, string>;
84
+ /**
85
+ * Creation timestamp
86
+ */
87
+ createdAt: string;
88
+ /**
89
+ * Last update timestamp
90
+ */
91
+ updatedAt: string;
92
+ }
@@ -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.25",
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.25"
40
40
  }
41
41
  }