@bloque/sdk-accounts 0.0.34 → 0.0.36
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/dist/accounts-client.d.ts +36 -12
- package/dist/bancolombia/bancolombia-client.d.ts +6 -0
- package/dist/card/card-client.d.ts +29 -6
- package/dist/card/types.d.ts +21 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/wire-types.d.ts +12 -3
- package/dist/polygon/polygon-client.d.ts +6 -0
- package/dist/types.d.ts +26 -5
- package/dist/us/us-client.d.ts +6 -0
- package/dist/virtual/virtual-client.d.ts +6 -0
- package/package.json +2 -2
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
2
|
import { BaseClient } from '@bloque/sdk-core';
|
|
3
3
|
import { BancolombiaClient } from './bancolombia/bancolombia-client';
|
|
4
|
+
import type { BancolombiaAccount } from './bancolombia/types';
|
|
4
5
|
import { CardClient } from './card/card-client';
|
|
5
|
-
import type { ListMovementsParams } from './card/types';
|
|
6
|
+
import type { CardAccount, ListMovementsParams } from './card/types';
|
|
6
7
|
import { PolygonClient } from './polygon/polygon-client';
|
|
7
|
-
import type {
|
|
8
|
+
import type { PolygonAccount } from './polygon/types';
|
|
9
|
+
import type { BatchTransferParams, BatchTransferResult, ListAccountsParams, ListAccountsResult, ListMovementsResult, TokenBalance, TransferParams, TransferResult } from './types';
|
|
10
|
+
import type { UsAccount } from './us/types';
|
|
8
11
|
import { UsClient } from './us/us-client';
|
|
12
|
+
import type { VirtualAccount } from './virtual/types';
|
|
9
13
|
import { VirtualClient } from './virtual/virtual-client';
|
|
14
|
+
/**
|
|
15
|
+
* Union of all medium-specific mapped account types.
|
|
16
|
+
* Returned by `AccountsClient.get()` and used in `AccountsClient.list()`.
|
|
17
|
+
*/
|
|
18
|
+
export type MappedAccount = CardAccount | VirtualAccount | PolygonAccount | BancolombiaAccount | UsAccount;
|
|
10
19
|
/**
|
|
11
20
|
* Accounts client for managing financial accounts and payment methods
|
|
12
21
|
*
|
|
@@ -60,7 +69,7 @@ export declare class AccountsClient extends BaseClient {
|
|
|
60
69
|
* console.log(account.status, account.balance);
|
|
61
70
|
* ```
|
|
62
71
|
*/
|
|
63
|
-
get(urn: string): Promise<
|
|
72
|
+
get(urn: string): Promise<MappedAccount>;
|
|
64
73
|
/**
|
|
65
74
|
* List accounts
|
|
66
75
|
*
|
|
@@ -142,19 +151,21 @@ export declare class AccountsClient extends BaseClient {
|
|
|
142
151
|
* List account movements/transactions
|
|
143
152
|
*
|
|
144
153
|
* Retrieves transaction history for a specific account using its URN.
|
|
154
|
+
* Returns a paged result with data, pageSize, hasMore, and optional next token.
|
|
145
155
|
*
|
|
146
156
|
* @param params - Movement list parameters
|
|
147
|
-
* @returns Promise resolving to
|
|
157
|
+
* @returns Promise resolving to paged movements result
|
|
148
158
|
*
|
|
149
159
|
* @example
|
|
150
160
|
* ```typescript
|
|
151
161
|
* // Basic usage
|
|
152
|
-
* const
|
|
162
|
+
* const { data, pageSize, hasMore, next } = await bloque.accounts.movements({
|
|
153
163
|
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
164
|
+
* asset: 'DUSD/6',
|
|
154
165
|
* });
|
|
155
166
|
*
|
|
156
167
|
* // With filters
|
|
157
|
-
* const
|
|
168
|
+
* const result = await bloque.accounts.movements({
|
|
158
169
|
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
159
170
|
* asset: 'DUSD/6',
|
|
160
171
|
* limit: 50,
|
|
@@ -162,17 +173,30 @@ export declare class AccountsClient extends BaseClient {
|
|
|
162
173
|
* after: '2025-01-01T00:00:00Z',
|
|
163
174
|
* });
|
|
164
175
|
*
|
|
165
|
-
* //
|
|
166
|
-
*
|
|
176
|
+
* // Next page
|
|
177
|
+
* if (result.hasMore && result.next) {
|
|
178
|
+
* const nextPage = await bloque.accounts.movements({
|
|
179
|
+
* urn: params.urn,
|
|
180
|
+
* asset: params.asset,
|
|
181
|
+
* next: result.next,
|
|
182
|
+
* });
|
|
183
|
+
* }
|
|
184
|
+
*
|
|
185
|
+
* // Filter by pocket (main = confirmed, pending = pending movements)
|
|
186
|
+
* const confirmed = await bloque.accounts.movements({
|
|
167
187
|
* urn: 'did:bloque:account:virtual:acc-123',
|
|
168
|
-
*
|
|
188
|
+
* asset: 'KSM/12',
|
|
189
|
+
* pocket: 'main',
|
|
169
190
|
* });
|
|
170
191
|
* ```
|
|
171
192
|
*/
|
|
172
|
-
movements(params: ListMovementsParams): Promise<
|
|
193
|
+
movements(params: ListMovementsParams): Promise<ListMovementsResult>;
|
|
173
194
|
/**
|
|
174
|
-
*
|
|
195
|
+
* Dispatches the wire account to the correct per-medium mapper.
|
|
196
|
+
* Returns a properly typed account (CardAccount, VirtualAccount, etc.)
|
|
197
|
+
* instead of a generic Account with raw details.
|
|
198
|
+
*
|
|
175
199
|
* @internal
|
|
176
200
|
*/
|
|
177
|
-
private
|
|
201
|
+
private _mapByMedium;
|
|
178
202
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { AccountWithBalance, BancolombiaDetails } from '../internal/wire-types';
|
|
2
3
|
import type { CreateAccountOptions } from '../types';
|
|
3
4
|
import type { BancolombiaAccount, CreateBancolombiaAccountParams, ListBancolombiaAccountsParams, ListBancolombiaAccountsResult, UpdateBancolombiaMetadataParams } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Maps a wire Bancolombia account to the SDK BancolombiaAccount type.
|
|
7
|
+
* Exported so AccountsClient.get() can dispatch by medium.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapBancolombiaAccountFromWire(account: AccountWithBalance<BancolombiaDetails>): BancolombiaAccount;
|
|
4
10
|
export declare class BancolombiaClient extends BaseClient {
|
|
5
11
|
/**
|
|
6
12
|
* List Bancolombia accounts
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
-
import type { TokenBalance } from '../internal/wire-types';
|
|
2
|
+
import type { AccountWithBalance, CardDetails, TokenBalance } from '../internal/wire-types';
|
|
3
3
|
import type { CreateAccountOptions } from '../types';
|
|
4
|
-
import type { CardAccount,
|
|
4
|
+
import type { CardAccount, CreateCardParams, GetBalanceParams, ListCardAccountsParams, ListCardAccountsResult, ListMovementsPagedResult, ListMovementsParams, UpdateCardMetadataParams } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Maps a wire card account to the SDK CardAccount type.
|
|
7
|
+
* Exported so AccountsClient.get() can dispatch by medium.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapCardAccountFromWire(account: AccountWithBalance<CardDetails>): CardAccount;
|
|
5
10
|
export declare class CardClient extends BaseClient {
|
|
6
11
|
/**
|
|
7
12
|
* Create a new card account
|
|
@@ -56,28 +61,46 @@ export declare class CardClient extends BaseClient {
|
|
|
56
61
|
/**
|
|
57
62
|
* List card account movements/transactions
|
|
58
63
|
*
|
|
64
|
+
* Returns a paged result with data, pageSize, hasMore, and optional next token.
|
|
65
|
+
*
|
|
59
66
|
* @param params - Movement list parameters
|
|
60
|
-
* @returns Promise resolving to
|
|
67
|
+
* @returns Promise resolving to paged card movements result
|
|
61
68
|
*
|
|
62
69
|
* @example
|
|
63
70
|
* ```typescript
|
|
64
71
|
* // Basic usage
|
|
65
|
-
* const
|
|
72
|
+
* const { data, pageSize, hasMore, next } = await bloque.accounts.card.movements({
|
|
66
73
|
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
67
74
|
* asset: 'DUSD/6',
|
|
68
75
|
* });
|
|
69
76
|
*
|
|
70
77
|
* // With pagination and filters
|
|
71
|
-
* const
|
|
78
|
+
* const result = await bloque.accounts.card.movements({
|
|
72
79
|
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
73
80
|
* asset: 'DUSD/6',
|
|
74
81
|
* limit: 50,
|
|
75
82
|
* direction: 'in',
|
|
76
83
|
* after: '2025-01-01T00:00:00Z',
|
|
77
84
|
* });
|
|
85
|
+
*
|
|
86
|
+
* // Next page
|
|
87
|
+
* if (result.hasMore && result.next) {
|
|
88
|
+
* const nextPage = await bloque.accounts.card.movements({
|
|
89
|
+
* urn: params.urn,
|
|
90
|
+
* asset: params.asset,
|
|
91
|
+
* next: result.next,
|
|
92
|
+
* });
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* // Filter by pocket (main = confirmed, pending = pending movements)
|
|
96
|
+
* const confirmed = await bloque.accounts.card.movements({
|
|
97
|
+
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
98
|
+
* asset: 'DUSD/6',
|
|
99
|
+
* pocket: 'main',
|
|
100
|
+
* });
|
|
78
101
|
* ```
|
|
79
102
|
*/
|
|
80
|
-
movements(params: ListMovementsParams): Promise<
|
|
103
|
+
movements(params: ListMovementsParams): Promise<ListMovementsPagedResult>;
|
|
81
104
|
/**
|
|
82
105
|
* Get card account balance
|
|
83
106
|
*
|
package/dist/card/types.d.ts
CHANGED
|
@@ -70,6 +70,27 @@ export interface ListMovementsParams {
|
|
|
70
70
|
* See API docs: GET /api/accounts/{urn}/movements
|
|
71
71
|
*/
|
|
72
72
|
collapsed_view?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Filter by pocket: 'main' for confirmed movements, 'pending' for pending movements
|
|
75
|
+
*/
|
|
76
|
+
pocket?: 'main' | 'pending';
|
|
77
|
+
/**
|
|
78
|
+
* Pagination token for fetching the next page (from previous response's next)
|
|
79
|
+
*/
|
|
80
|
+
next?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Paged result for list movements (wire/snake_case from API)
|
|
84
|
+
*/
|
|
85
|
+
export interface ListMovementsPagedResult {
|
|
86
|
+
/** Array of movements */
|
|
87
|
+
data: CardMovement[];
|
|
88
|
+
/** Number of results in this page */
|
|
89
|
+
pageSize: number;
|
|
90
|
+
/** Whether more results are available */
|
|
91
|
+
hasMore: boolean;
|
|
92
|
+
/** Pagination token for the next page (if hasMore is true) */
|
|
93
|
+
next?: string;
|
|
73
94
|
}
|
|
74
95
|
export interface CardMovement extends Transaction {
|
|
75
96
|
}
|
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=(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,UsClient:()=>UsClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,balance:"balance"in t&&t.balance?t.balance:void 0}}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","card"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).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),void 0!==t.collapsed_view&&e.set("collapsed_view",String(t.collapsed_view));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 list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,balance:"balance"in t&&t.balance?t.balance:void 0}}}class UsClient extends sdk_core_namespaceObject.BaseClient{async getTosLink(t){let e=new URLSearchParams({redirect_uri:t.redirectUri});return{url:(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${e.toString()}`})).result.url}}async create(t,e){let a={street_line_1:t.address.streetLine1,street_line_2:t.address.streetLine2,city:t.address.city,state:t.address.state,postal_code:t.address.postalCode,country:t.address.country},r={type:t.type,first_name:t.firstName,middle_name:t.middleName,last_name:t.lastName,email:t.email,phone:t.phone,address:a,birth_date:t.birthDate,tax_identification_number:t.taxIdentificationNumber,gov_id_country:t.govIdCountry,gov_id_image_front:t.govIdImageFront,signed_agreement_id:t.signedAgreementId},s={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:r,metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},n=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:s}),i=this._mapAccountResponse(n.result.account);return e?.waitLedger?this._waitForActiveStatus(i.urn,e.timeout||6e4):i}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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,balance:t.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 activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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 list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t,e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,balance:"balance"in t&&t.balance?t.balance:void 0}}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;polygon;us;virtual;constructor(t){super(t),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient),this.polygon=new PolygonClient(this.httpClient),this.us=new UsClient(this.httpClient),this.virtual=new VirtualClient(this.httpClient)}async balance(t){if(!t?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t}/balance`})).balance}async get(t){if(!t?.trim())throw Error("Account URN is required");let e=await this.httpClient.request({method:"GET",path:`/api/accounts/${t}`});return this._mapAccountResponse(e.account)}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;e&&a.append("holder_urn",e);let r=a.toString(),s=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:s})).accounts.map(t=>this._mapAccountResponse(t))}}async transfer(t){let e=t.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(e))throw Error(`Invalid asset type "${e}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);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}}async batchTransfer(t){if(!t.operations||0===t.operations.length)throw Error("At least one operation is required");if(!t.reference)throw Error("Batch reference is required");for(let e of t.operations)if(!(0,sdk_core_namespaceObject.isSupportedAsset)(e.asset))throw Error(`Invalid asset type "${e.asset}" in operation "${e.reference}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let e={operations:t.operations.map(t=>({from_account_urn:t.fromUrn,to_account_urn:t.toUrn,reference:t.reference,amount:t.amount,asset:t.asset,metadata:t.metadata})),reference:t.reference,metadata:t.metadata,webhook_url:t.webhookUrl},a=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:e});return{chunks:a.result.chunks.map(t=>({queueId:t.queue_id,status:t.status,message:t.message})),totalOperations:a.result.total_operations,totalChunks:a.result.total_chunks}}async movements(t){if(!t.urn)throw Error("Account URN is required");let e=t.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(e))throw Error(`Invalid asset type "${e}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=new URLSearchParams;a.set("asset",e),void 0!==t.limit&&a.set("limit",t.limit.toString()),t.before&&a.set("before",t.before),t.after&&a.set("after",t.after),t.reference&&a.set("reference",t.reference),t.direction&&a.set("direction",t.direction),void 0!==t.collapsed_view&&a.set("collapsed_view",String(t.collapsed_view)),console.log("queryParams: ",a.toString());let r=`/api/accounts/${t.urn}/movements?${a.toString()}`;return(await this.httpClient.request({method:"GET",path:r})).transactions.map(t=>({amount:t.amount,asset:t.asset,fromAccountId:t.from_account_id,toAccountId:t.to_account_id,direction:t.direction,reference:t.reference,status:t.status,railName:t.rail_name,details:t.details,createdAt:t.created_at}))}_mapAccountResponse(t){return{id:t.id,urn:t.urn,medium:t.medium,details:t.details,ledgerId:t.ledger_account_id,status:t.status,ownerUrn:t.owner_urn,createdAt:t.created_at,updatedAt:t.updated_at,webhookUrl:t.webhook_url,metadata:t.metadata,balance:t.balance}}}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.UsClient=__webpack_exports__.UsClient,exports.VirtualClient=__webpack_exports__.VirtualClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient","PolygonClient","UsClient","VirtualClient"].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__,{BancolombiaClient:()=>BancolombiaClient,PolygonClient:()=>PolygonClient,AccountsClient:()=>AccountsClient,UsClient:()=>UsClient,mapUsAccountFromWire:()=>mapUsAccountFromWire,CardClient:()=>CardClient,mapCardAccountFromWire:()=>mapCardAccountFromWire,mapPolygonAccountFromWire:()=>mapPolygonAccountFromWire,mapBancolombiaAccountFromWire:()=>mapBancolombiaAccountFromWire,mapVirtualAccountFromWire:()=>mapVirtualAccountFromWire,VirtualClient:()=>VirtualClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function mapBancolombiaAccountFromWire(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,balance:"balance"in t&&t.balance?t.balance:void 0}}class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 mapBancolombiaAccountFromWire(t)}}function mapCardAccountFromWire(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,balance:t.balance}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","card"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).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),void 0!==t.collapsed_view&&e.set("collapsed_view",String(t.collapsed_view)),t.pocket&&e.set("pocket",t.pocket),t.next&&e.set("next",t.next);let r=e.toString(),n=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`,s=await this.httpClient.request({method:"GET",path:n});return{data:s.data,pageSize:s.page_size,hasMore:s.has_more,next:s.next}}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 mapCardAccountFromWire(t)}}function mapPolygonAccountFromWire(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,balance:"balance"in t&&t.balance?t.balance:void 0}}class PolygonClient extends sdk_core_namespaceObject.BaseClient{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 mapPolygonAccountFromWire(t)}}function mapUsAccountFromWire(t){return{urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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,balance:t.balance}}class UsClient extends sdk_core_namespaceObject.BaseClient{async getTosLink(t){let e=new URLSearchParams({redirect_uri:t.redirectUri});return{url:(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${e.toString()}`})).result.url}}async create(t,e){let a={street_line_1:t.address.streetLine1,street_line_2:t.address.streetLine2,city:t.address.city,state:t.address.state,postal_code:t.address.postalCode,country:t.address.country},r={type:t.type,first_name:t.firstName,middle_name:t.middleName,last_name:t.lastName,email:t.email,phone:t.phone,address:a,birth_date:t.birthDate,tax_identification_number:t.taxIdentificationNumber,gov_id_country:t.govIdCountry,gov_id_image_front:t.govIdImageFront,signed_agreement_id:t.signedAgreementId},n={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:r,metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},s=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:n}),o=this._mapAccountResponse(s.result.account);return e?.waitLedger?this._waitForActiveStatus(o.urn,e.timeout||6e4):o}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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,balance:t.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 activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 mapUsAccountFromWire(t)}}function mapVirtualAccountFromWire(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,balance:"balance"in t&&t.balance?t.balance:void 0}}class VirtualClient extends sdk_core_namespaceObject.BaseClient{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t,e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 mapVirtualAccountFromWire(t)}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;polygon;us;virtual;constructor(t){super(t),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient),this.polygon=new PolygonClient(this.httpClient),this.us=new UsClient(this.httpClient),this.virtual=new VirtualClient(this.httpClient)}async balance(t){if(!t?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t}/balance`})).balance}async get(t){if(!t?.trim())throw Error("Account URN is required");let e=await this.httpClient.request({method:"GET",path:`/api/accounts/${t}`});return this._mapByMedium(e.account)}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;e&&a.append("holder_urn",e);let r=a.toString(),n=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(t=>this._mapByMedium(t))}}async transfer(t){let e=t.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(e))throw Error(`Invalid asset type "${e}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);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}}async batchTransfer(t){if(!t.operations||0===t.operations.length)throw Error("At least one operation is required");if(!t.reference)throw Error("Batch reference is required");for(let e of t.operations)if(!(0,sdk_core_namespaceObject.isSupportedAsset)(e.asset))throw Error(`Invalid asset type "${e.asset}" in operation "${e.reference}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let e={operations:t.operations.map(t=>({from_account_urn:t.fromUrn,to_account_urn:t.toUrn,reference:t.reference,amount:t.amount,asset:t.asset,metadata:t.metadata})),reference:t.reference,metadata:t.metadata,webhook_url:t.webhookUrl},a=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:e});return{chunks:a.result.chunks.map(t=>({queueId:t.queue_id,status:t.status,message:t.message})),totalOperations:a.result.total_operations,totalChunks:a.result.total_chunks}}async movements(t){if(!t.urn)throw Error("Account URN is required");let e=t.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(e))throw Error(`Invalid asset type "${e}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=new URLSearchParams;a.set("asset",e),void 0!==t.limit&&a.set("limit",t.limit.toString()),t.before&&a.set("before",t.before),t.after&&a.set("after",t.after),t.reference&&a.set("reference",t.reference),t.direction&&a.set("direction",t.direction),void 0!==t.collapsed_view&&a.set("collapsed_view",String(t.collapsed_view)),t.pocket&&a.set("pocket",t.pocket),t.next&&a.set("next",t.next);let r=`/api/accounts/${t.urn}/movements?${a.toString()}`,n=await this.httpClient.request({method:"GET",path:r});return{data:n.data.map(t=>({amount:t.amount,asset:t.asset,fromAccountId:t.from_account_id,toAccountId:t.to_account_id,direction:t.direction,type:t.type,reference:t.reference,status:t.status,railName:t.rail_name,details:t.details,createdAt:t.created_at})),pageSize:n.page_size,hasMore:n.has_more,next:n.next}}_mapByMedium(t){switch(t.medium){case"card":return mapCardAccountFromWire(t);case"virtual":return mapVirtualAccountFromWire(t);case"polygon":return mapPolygonAccountFromWire(t);case"bancolombia":return mapBancolombiaAccountFromWire(t);case"us-account":return mapUsAccountFromWire(t);default:throw Error(`Unknown account medium: ${t.medium}`)}}}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.UsClient=__webpack_exports__.UsClient,exports.VirtualClient=__webpack_exports__.VirtualClient,exports.mapBancolombiaAccountFromWire=__webpack_exports__.mapBancolombiaAccountFromWire,exports.mapCardAccountFromWire=__webpack_exports__.mapCardAccountFromWire,exports.mapPolygonAccountFromWire=__webpack_exports__.mapPolygonAccountFromWire,exports.mapUsAccountFromWire=__webpack_exports__.mapUsAccountFromWire,exports.mapVirtualAccountFromWire=__webpack_exports__.mapVirtualAccountFromWire,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient","PolygonClient","UsClient","VirtualClient","mapBancolombiaAccountFromWire","mapCardAccountFromWire","mapPolygonAccountFromWire","mapUsAccountFromWire","mapVirtualAccountFromWire"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BaseClient as t,SUPPORTED_ASSETS as e,isSupportedAsset as a}from"@bloque/sdk-core";class r extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,balance:"balance"in t&&t.balance?t.balance:void 0}}}class s extends t{async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","card"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).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),void 0!==t.collapsed_view&&e.set("collapsed_view",String(t.collapsed_view));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 n extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,balance:"balance"in t&&t.balance?t.balance:void 0}}}class i extends t{async getTosLink(t){let e=new URLSearchParams({redirect_uri:t.redirectUri});return{url:(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${e.toString()}`})).result.url}}async create(t,e){let a={street_line_1:t.address.streetLine1,street_line_2:t.address.streetLine2,city:t.address.city,state:t.address.state,postal_code:t.address.postalCode,country:t.address.country},r={type:t.type,first_name:t.firstName,middle_name:t.middleName,last_name:t.lastName,email:t.email,phone:t.phone,address:a,birth_date:t.birthDate,tax_identification_number:t.taxIdentificationNumber,gov_id_country:t.govIdCountry,gov_id_image_front:t.govIdImageFront,signed_agreement_id:t.signedAgreementId},s={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:r,metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},n=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:s}),i=this._mapAccountResponse(n.result.account);return e?.waitLedger?this._waitForActiveStatus(i.urn,e.timeout||6e4):i}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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,balance:t.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 activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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 o extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t,e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a}),s=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(s.urn,e.timeout||6e4):s}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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,balance:"balance"in t&&t.balance?t.balance:void 0}}}class u extends t{bancolombia;card;polygon;us;virtual;constructor(t){super(t),this.bancolombia=new r(this.httpClient),this.card=new s(this.httpClient),this.polygon=new n(this.httpClient),this.us=new i(this.httpClient),this.virtual=new o(this.httpClient)}async balance(t){if(!t?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t}/balance`})).balance}async get(t){if(!t?.trim())throw Error("Account URN is required");let e=await this.httpClient.request({method:"GET",path:`/api/accounts/${t}`});return this._mapAccountResponse(e.account)}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;e&&a.append("holder_urn",e);let r=a.toString(),s=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:s})).accounts.map(t=>this._mapAccountResponse(t))}}async transfer(t){let r=t.asset||"DUSD/6";if(!a(r))throw Error(`Invalid asset type "${r}". Supported assets: ${e.join(", ")}`);let s={destination_account_urn:t.destinationUrn,amount:t.amount,asset:r,metadata:t.metadata},n=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:s});return{queueId:n.result.queue_id,status:n.result.status,message:n.result.message}}async batchTransfer(t){if(!t.operations||0===t.operations.length)throw Error("At least one operation is required");if(!t.reference)throw Error("Batch reference is required");for(let r of t.operations)if(!a(r.asset))throw Error(`Invalid asset type "${r.asset}" in operation "${r.reference}". Supported assets: ${e.join(", ")}`);let r={operations:t.operations.map(t=>({from_account_urn:t.fromUrn,to_account_urn:t.toUrn,reference:t.reference,amount:t.amount,asset:t.asset,metadata:t.metadata})),reference:t.reference,metadata:t.metadata,webhook_url:t.webhookUrl},s=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:r});return{chunks:s.result.chunks.map(t=>({queueId:t.queue_id,status:t.status,message:t.message})),totalOperations:s.result.total_operations,totalChunks:s.result.total_chunks}}async movements(t){if(!t.urn)throw Error("Account URN is required");let r=t.asset||"DUSD/6";if(!a(r))throw Error(`Invalid asset type "${r}". Supported assets: ${e.join(", ")}`);let s=new URLSearchParams;s.set("asset",r),void 0!==t.limit&&s.set("limit",t.limit.toString()),t.before&&s.set("before",t.before),t.after&&s.set("after",t.after),t.reference&&s.set("reference",t.reference),t.direction&&s.set("direction",t.direction),void 0!==t.collapsed_view&&s.set("collapsed_view",String(t.collapsed_view)),console.log("queryParams: ",s.toString());let n=`/api/accounts/${t.urn}/movements?${s.toString()}`;return(await this.httpClient.request({method:"GET",path:n})).transactions.map(t=>({amount:t.amount,asset:t.asset,fromAccountId:t.from_account_id,toAccountId:t.to_account_id,direction:t.direction,reference:t.reference,status:t.status,railName:t.rail_name,details:t.details,createdAt:t.created_at}))}_mapAccountResponse(t){return{id:t.id,urn:t.urn,medium:t.medium,details:t.details,ledgerId:t.ledger_account_id,status:t.status,ownerUrn:t.owner_urn,createdAt:t.created_at,updatedAt:t.updated_at,webhookUrl:t.webhook_url,metadata:t.metadata,balance:t.balance}}}export{u as AccountsClient,r as BancolombiaClient,s as CardClient,n as PolygonClient,i as UsClient,o as VirtualClient};
|
|
1
|
+
import{BaseClient as t,SUPPORTED_ASSETS as e,isSupportedAsset as a}from"@bloque/sdk-core";function r(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,balance:"balance"in t&&t.balance?t.balance:void 0}}class n extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 r(t)}}function s(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,balance:t.balance}}class i extends t{async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","card"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).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),void 0!==t.collapsed_view&&e.set("collapsed_view",String(t.collapsed_view)),t.pocket&&e.set("pocket",t.pocket),t.next&&e.set("next",t.next);let r=e.toString(),n=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`,s=await this.httpClient.request({method:"GET",path:n});return{data:s.data,pageSize:s.page_size,hasMore:s.has_more,next:s.next}}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 s(t)}}function o(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,balance:"balance"in t&&t.balance?t.balance:void 0}}class u extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 o(t)}}function c(t){return{urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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,balance:t.balance}}class d extends t{async getTosLink(t){let e=new URLSearchParams({redirect_uri:t.redirectUri});return{url:(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${e.toString()}`})).result.url}}async create(t,e){let a={street_line_1:t.address.streetLine1,street_line_2:t.address.streetLine2,city:t.address.city,state:t.address.state,postal_code:t.address.postalCode,country:t.address.country},r={type:t.type,first_name:t.firstName,middle_name:t.middleName,last_name:t.lastName,email:t.email,phone:t.phone,address:a,birth_date:t.birthDate,tax_identification_number:t.taxIdentificationNumber,gov_id_country:t.govIdCountry,gov_id_image_front:t.govIdImageFront,signed_agreement_id:t.signedAgreementId},n={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:r,metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},s=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:n}),i=this._mapAccountResponse(s.result.account);return e?.waitLedger?this._waitForActiveStatus(i.urn,e.timeout||6e4):i}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,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,balance:t.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 activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 c(t)}}function l(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,balance:"balance"in t&&t.balance?t.balance:void 0}}class p extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t,e){let a={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}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}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 l(t)}}class h extends t{bancolombia;card;polygon;us;virtual;constructor(t){super(t),this.bancolombia=new n(this.httpClient),this.card=new i(this.httpClient),this.polygon=new u(this.httpClient),this.us=new d(this.httpClient),this.virtual=new p(this.httpClient)}async balance(t){if(!t?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t}/balance`})).balance}async get(t){if(!t?.trim())throw Error("Account URN is required");let e=await this.httpClient.request({method:"GET",path:`/api/accounts/${t}`});return this._mapByMedium(e.account)}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;e&&a.append("holder_urn",e);let r=a.toString(),n=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(t=>this._mapByMedium(t))}}async transfer(t){let r=t.asset||"DUSD/6";if(!a(r))throw Error(`Invalid asset type "${r}". Supported assets: ${e.join(", ")}`);let n={destination_account_urn:t.destinationUrn,amount:t.amount,asset:r,metadata:t.metadata},s=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:n});return{queueId:s.result.queue_id,status:s.result.status,message:s.result.message}}async batchTransfer(t){if(!t.operations||0===t.operations.length)throw Error("At least one operation is required");if(!t.reference)throw Error("Batch reference is required");for(let r of t.operations)if(!a(r.asset))throw Error(`Invalid asset type "${r.asset}" in operation "${r.reference}". Supported assets: ${e.join(", ")}`);let r={operations:t.operations.map(t=>({from_account_urn:t.fromUrn,to_account_urn:t.toUrn,reference:t.reference,amount:t.amount,asset:t.asset,metadata:t.metadata})),reference:t.reference,metadata:t.metadata,webhook_url:t.webhookUrl},n=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:r});return{chunks:n.result.chunks.map(t=>({queueId:t.queue_id,status:t.status,message:t.message})),totalOperations:n.result.total_operations,totalChunks:n.result.total_chunks}}async movements(t){if(!t.urn)throw Error("Account URN is required");let r=t.asset||"DUSD/6";if(!a(r))throw Error(`Invalid asset type "${r}". Supported assets: ${e.join(", ")}`);let n=new URLSearchParams;n.set("asset",r),void 0!==t.limit&&n.set("limit",t.limit.toString()),t.before&&n.set("before",t.before),t.after&&n.set("after",t.after),t.reference&&n.set("reference",t.reference),t.direction&&n.set("direction",t.direction),void 0!==t.collapsed_view&&n.set("collapsed_view",String(t.collapsed_view)),t.pocket&&n.set("pocket",t.pocket),t.next&&n.set("next",t.next);let s=`/api/accounts/${t.urn}/movements?${n.toString()}`,i=await this.httpClient.request({method:"GET",path:s});return{data:i.data.map(t=>({amount:t.amount,asset:t.asset,fromAccountId:t.from_account_id,toAccountId:t.to_account_id,direction:t.direction,type:t.type,reference:t.reference,status:t.status,railName:t.rail_name,details:t.details,createdAt:t.created_at})),pageSize:i.page_size,hasMore:i.has_more,next:i.next}}_mapByMedium(t){switch(t.medium){case"card":return s(t);case"virtual":return l(t);case"polygon":return o(t);case"bancolombia":return r(t);case"us-account":return c(t);default:throw Error(`Unknown account medium: ${t.medium}`)}}}export{h as AccountsClient,n as BancolombiaClient,i as CardClient,u as PolygonClient,d as UsClient,p as VirtualClient,r as mapBancolombiaAccountFromWire,s as mapCardAccountFromWire,o as mapPolygonAccountFromWire,c as mapUsAccountFromWire,l as mapVirtualAccountFromWire};
|
|
@@ -278,6 +278,11 @@ export declare enum TransactionStatus {
|
|
|
278
278
|
FAILED = "failed",
|
|
279
279
|
IGNORED = "ignored"
|
|
280
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* @internal
|
|
283
|
+
* Transaction type from API
|
|
284
|
+
*/
|
|
285
|
+
export type TransactionType = 'deposit' | 'withdraw' | 'transfer';
|
|
281
286
|
/**
|
|
282
287
|
* @internal
|
|
283
288
|
* Transaction from API
|
|
@@ -287,7 +292,8 @@ export interface Transaction {
|
|
|
287
292
|
asset: string;
|
|
288
293
|
from_account_id: string;
|
|
289
294
|
to_account_id: string;
|
|
290
|
-
direction: 'in' | 'out'
|
|
295
|
+
direction: 'in' | 'out';
|
|
296
|
+
type: TransactionType;
|
|
291
297
|
reference: string;
|
|
292
298
|
rail_name: string;
|
|
293
299
|
status: TransactionStatus;
|
|
@@ -296,10 +302,13 @@ export interface Transaction {
|
|
|
296
302
|
}
|
|
297
303
|
/**
|
|
298
304
|
* @internal
|
|
299
|
-
* List movements response
|
|
305
|
+
* List movements response (paged)
|
|
300
306
|
*/
|
|
301
307
|
export interface ListMovementsResponse {
|
|
302
|
-
|
|
308
|
+
data: Transaction[];
|
|
309
|
+
page_size: number;
|
|
310
|
+
has_more: boolean;
|
|
311
|
+
next?: string;
|
|
303
312
|
}
|
|
304
313
|
/**
|
|
305
314
|
* @internal
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { AccountWithBalance, PolygonDetails } from '../internal/wire-types';
|
|
2
3
|
import type { CreateAccountOptions } from '../types';
|
|
3
4
|
import type { CreatePolygonAccountParams, ListPolygonAccountsParams, ListPolygonAccountsResult, PolygonAccount, UpdatePolygonMetadataParams } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Maps a wire polygon account to the SDK PolygonAccount type.
|
|
7
|
+
* Exported so AccountsClient.get() can dispatch by medium.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapPolygonAccountFromWire(account: AccountWithBalance<PolygonDetails>): PolygonAccount;
|
|
4
10
|
export declare class PolygonClient extends BaseClient {
|
|
5
11
|
/**
|
|
6
12
|
* List polygon accounts
|
package/dist/types.d.ts
CHANGED
|
@@ -210,12 +210,18 @@ export interface ListAccountsParams {
|
|
|
210
210
|
medium?: AccountMedium;
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
|
-
* Result of listing accounts
|
|
213
|
+
* Result of listing accounts.
|
|
214
|
+
* Each account is mapped to its medium-specific type
|
|
215
|
+
* (CardAccount, VirtualAccount, PolygonAccount, BancolombiaAccount, or UsAccount).
|
|
214
216
|
*/
|
|
215
217
|
export interface ListAccountsResult {
|
|
216
|
-
/** Array of accounts */
|
|
217
|
-
accounts:
|
|
218
|
+
/** Array of medium-specific mapped accounts */
|
|
219
|
+
accounts: Array<import('./card/types').CardAccount | import('./virtual/types').VirtualAccount | import('./polygon/types').PolygonAccount | import('./bancolombia/types').BancolombiaAccount | import('./us/types').UsAccount>;
|
|
218
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Transaction type (deposit, withdraw, transfer)
|
|
223
|
+
*/
|
|
224
|
+
export type MovementType = 'deposit' | 'withdraw' | 'transfer';
|
|
219
225
|
/**
|
|
220
226
|
* Transaction details metadata
|
|
221
227
|
*/
|
|
@@ -229,7 +235,7 @@ export interface MovementDetails {
|
|
|
229
235
|
* Account movement/transaction
|
|
230
236
|
*/
|
|
231
237
|
export interface Movement {
|
|
232
|
-
/**
|
|
238
|
+
/** Settlement status of the movement */
|
|
233
239
|
status: TransactionStatus;
|
|
234
240
|
/** Transaction amount */
|
|
235
241
|
amount: string;
|
|
@@ -240,7 +246,9 @@ export interface Movement {
|
|
|
240
246
|
/** Destination account ID */
|
|
241
247
|
toAccountId: string;
|
|
242
248
|
/** Transaction direction */
|
|
243
|
-
direction: 'in' | 'out'
|
|
249
|
+
direction: 'in' | 'out';
|
|
250
|
+
/** Transaction type (deposit, withdraw, transfer) */
|
|
251
|
+
type: MovementType;
|
|
244
252
|
/** Transaction reference */
|
|
245
253
|
reference: string;
|
|
246
254
|
/** Rail/network name */
|
|
@@ -250,3 +258,16 @@ export interface Movement {
|
|
|
250
258
|
/** Creation timestamp */
|
|
251
259
|
createdAt: string;
|
|
252
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Paged result for list movements
|
|
263
|
+
*/
|
|
264
|
+
export interface ListMovementsResult {
|
|
265
|
+
/** Array of movements */
|
|
266
|
+
data: Movement[];
|
|
267
|
+
/** Number of results in this page */
|
|
268
|
+
pageSize: number;
|
|
269
|
+
/** Whether more results are available */
|
|
270
|
+
hasMore: boolean;
|
|
271
|
+
/** Pagination token for the next page (if hasMore is true) */
|
|
272
|
+
next?: string;
|
|
273
|
+
}
|
package/dist/us/us-client.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { AccountWithBalance, UsDetails } from '../internal/wire-types';
|
|
2
3
|
import type { CreateAccountOptions } from '../types';
|
|
3
4
|
import type { CreateUsAccountParams, GetTosLinkParams, ListUsAccountsParams, ListUsAccountsResult, TosLinkResult, UpdateUsMetadataParams, UsAccount } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Maps a wire US account to the SDK UsAccount type.
|
|
7
|
+
* Exported so AccountsClient.get() can dispatch by medium.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapUsAccountFromWire(account: AccountWithBalance<UsDetails>): UsAccount;
|
|
4
10
|
export declare class UsClient extends BaseClient {
|
|
5
11
|
/**
|
|
6
12
|
* Get Terms of Service acceptance link
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { AccountWithBalance, VirtualDetails } from '../internal/wire-types';
|
|
2
3
|
import type { CreateAccountOptions } from '../types';
|
|
3
4
|
import type { CreateVirtualAccountParams, ListVirtualAccountsParams, ListVirtualAccountsResult, UpdateVirtualMetadataParams, VirtualAccount } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Maps a wire virtual account to the SDK VirtualAccount type.
|
|
7
|
+
* Exported so AccountsClient.get() can dispatch by medium.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapVirtualAccountFromWire(account: AccountWithBalance<VirtualDetails>): VirtualAccount;
|
|
4
10
|
export declare class VirtualClient extends BaseClient {
|
|
5
11
|
/**
|
|
6
12
|
* List virtual accounts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-accounts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
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.
|
|
39
|
+
"@bloque/sdk-core": "0.0.36"
|
|
40
40
|
}
|
|
41
41
|
}
|