wapi-client 0.10.2 → 0.10.6
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/api/base-client.browser.cjs +27 -8
- package/dist/api/base-client.browser.js +28 -9
- package/dist/api/base-client.cjs +27 -8
- package/dist/api/base-client.d.ts +6 -2
- package/dist/api/base-client.js +28 -9
- package/dist/api/http-client.browser.cjs +47 -21
- package/dist/api/http-client.browser.js +47 -21
- package/dist/api/http-client.cjs +47 -21
- package/dist/api/http-client.d.ts +2 -2
- package/dist/api/http-client.js +47 -21
- package/dist/api/index.d.ts +4 -0
- package/dist/api/ws-client.browser.cjs +26 -10
- package/dist/api/ws-client.browser.js +27 -11
- package/dist/api/ws-client.cjs +27 -11
- package/dist/api/ws-client.d.ts +5 -4
- package/dist/api/ws-client.js +28 -12
- package/dist/client.browser.cjs +90 -17
- package/dist/client.browser.js +91 -18
- package/dist/client.cjs +91 -18
- package/dist/client.d.ts +53 -5
- package/dist/client.js +92 -19
- package/dist/fns/list-exports/list-exports.browser.cjs +4 -7
- package/dist/fns/list-exports/list-exports.browser.js +9 -8
- package/dist/fns/list-exports/list-exports.cjs +4 -7
- package/dist/fns/list-exports/list-exports.enums.d.ts +9 -4
- package/dist/fns/list-exports/list-exports.js +9 -8
- package/dist/fns/list-exports/list-exports.schema.input.json +20 -2
- package/dist/fns/update-transfer/update-transfer.browser.cjs +2 -1
- package/dist/fns/update-transfer/update-transfer.browser.js +2 -1
- package/dist/fns/update-transfer/update-transfer.cjs +2 -1
- package/dist/fns/update-transfer/update-transfer.enums.d.ts +6 -0
- package/dist/fns/update-transfer/update-transfer.js +2 -1
- package/dist/fns/update-transfer/update-transfer.schema.input.json +3 -0
- package/dist/index.browser.cjs +3 -0
- package/dist/index.browser.js +3 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.ts +23 -5
- package/dist/index.js +3 -0
- package/dist/lib/errors.browser.cjs +21 -1
- package/dist/lib/errors.browser.js +21 -1
- package/dist/lib/errors.cjs +21 -1
- package/dist/lib/errors.d.ts +180 -109
- package/dist/lib/errors.js +21 -1
- package/dist/lib/utils.browser.cjs +24 -0
- package/dist/lib/utils.browser.js +24 -0
- package/dist/lib/utils.cjs +27 -0
- package/dist/lib/utils.d.ts +6 -0
- package/dist/lib/utils.js +24 -0
- package/dist/lib/validator.browser.cjs +3 -0
- package/dist/lib/validator.browser.js +4 -1
- package/dist/lib/validator.cjs +3 -0
- package/dist/lib/validator.js +4 -1
- package/dist/txs/get-export/get-export.enums.d.ts +2 -1
- package/dist/txs/get-export/get-export.schema.output.json +13 -2
- package/dist/txs/list-export-many/list-export-many.enums.d.ts +5 -5
- package/dist/txs/list-export-many/list-export-many.schema.input.json +5 -4
- package/dist/txs/update-transfer/update-transfer.schema.input.json +0 -4
- package/dist/types/index.d.ts +301 -137
- package/dist/wapi-client-web.iife.js +6 -6
- package/dist/wapi-client.iife.js +6 -6
- package/package.json +1 -1
package/dist/api/ws-client.js
CHANGED
|
@@ -22,7 +22,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
22
22
|
// src/api/ws-client.ts
|
|
23
23
|
import WebSocket from "modern-isomorphic-ws";
|
|
24
24
|
import { debugLog } from "../lib/debug";
|
|
25
|
-
import { AuthenticationError, ERROR_GROUPS } from "../lib/errors";
|
|
25
|
+
import { AuthenticationError, ConfigError, ERROR_GROUPS } from "../lib/errors";
|
|
26
26
|
import { getConnectionParams, wait } from "../lib/utils";
|
|
27
27
|
import { BaseClient } from "./base-client";
|
|
28
28
|
import {
|
|
@@ -31,12 +31,14 @@ import {
|
|
|
31
31
|
} from "./connection/connection.enums";
|
|
32
32
|
import { WapiClientType } from "../index";
|
|
33
33
|
var _a;
|
|
34
|
-
var CLIENT_VERSION = (_a = '0.10.
|
|
35
|
-
function createWsClient(opts) {
|
|
36
|
-
const initialConnection = createConnection(opts
|
|
37
|
-
|
|
34
|
+
var CLIENT_VERSION = (_a = '0.10.6') != null ? _a : "";
|
|
35
|
+
function createWsClient(opts, config) {
|
|
36
|
+
const initialConnection = createConnection(opts, {
|
|
37
|
+
timeout: config == null ? void 0 : config.connectingTimeout
|
|
38
|
+
});
|
|
39
|
+
return new WsClient(initialConnection, opts, config);
|
|
38
40
|
}
|
|
39
|
-
function createConnection(opts) {
|
|
41
|
+
function createConnection(opts, connectionConfig) {
|
|
40
42
|
var _a2;
|
|
41
43
|
const config = Object.assign(
|
|
42
44
|
{
|
|
@@ -85,10 +87,21 @@ function createConnection(opts) {
|
|
|
85
87
|
}
|
|
86
88
|
clean();
|
|
87
89
|
}
|
|
90
|
+
debugLog(
|
|
91
|
+
`createConnection>(message:setting up ws connection${(connectionConfig == null ? void 0 : connectionConfig.timeout) ? " with timeout " + connectionConfig.timeout : ""})`
|
|
92
|
+
);
|
|
93
|
+
const connectingTimeout = (connectionConfig == null ? void 0 : connectionConfig.timeout) ? setTimeout(() => {
|
|
94
|
+
clean(
|
|
95
|
+
new ConfigError("CONNECTION_TIMEOUT", {
|
|
96
|
+
timeout: connectionConfig.timeout
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
}, connectionConfig.timeout) : void 0;
|
|
88
100
|
function clean(err) {
|
|
89
101
|
if (isCleaned) {
|
|
90
102
|
return;
|
|
91
103
|
}
|
|
104
|
+
clearTimeout(connectingTimeout);
|
|
92
105
|
delete ws.onmessage;
|
|
93
106
|
delete ws.onerror;
|
|
94
107
|
delete ws.onclose;
|
|
@@ -110,11 +123,12 @@ function createConnection(opts) {
|
|
|
110
123
|
};
|
|
111
124
|
}
|
|
112
125
|
var WsClient = class extends BaseClient {
|
|
113
|
-
constructor(initial, config) {
|
|
126
|
+
constructor(initial, opts, config) {
|
|
114
127
|
super(initial.ws, WapiClientType.ws, initial.$connect);
|
|
115
128
|
this._tryToReconnect = true;
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
129
|
+
this._opts = opts;
|
|
130
|
+
this._connectionConfig = config;
|
|
131
|
+
this.host = opts.host;
|
|
118
132
|
this.$connect.then((_id) => {
|
|
119
133
|
this.socId = _id;
|
|
120
134
|
return this._ready();
|
|
@@ -173,12 +187,14 @@ var WsClient = class extends BaseClient {
|
|
|
173
187
|
nrOfAttempts != null ? nrOfAttempts : nrOfAttempts = process.env.WAPI_RECONNECT_ATTEMPTS && parseInt(process.env.WAPI_RECONNECT_ATTEMPTS) || 10;
|
|
174
188
|
const maxWaitTime = process.env.WAPI_MAX_RECONNECT_WAIT && parseInt(process.env.WAPI_MAX_RECONNECT_WAIT) || 1e4;
|
|
175
189
|
this.$connect = (() => __async(this, null, function* () {
|
|
176
|
-
var _a2, _b;
|
|
190
|
+
var _a2, _b, _c;
|
|
177
191
|
let _id;
|
|
178
192
|
for (let i = 0; i < nrOfAttempts + 1; i++) {
|
|
179
193
|
try {
|
|
180
194
|
debugLog("Trying to connect, attempt:", i);
|
|
181
|
-
const { ws, $connect } = createConnection(this.
|
|
195
|
+
const { ws, $connect } = createConnection(this._opts, {
|
|
196
|
+
timeout: (_a2 = this._connectionConfig) == null ? void 0 : _a2.reconnectingTimeout
|
|
197
|
+
});
|
|
182
198
|
_id = yield $connect;
|
|
183
199
|
this.socId = _id;
|
|
184
200
|
this._connection = ws;
|
|
@@ -189,7 +205,7 @@ var WsClient = class extends BaseClient {
|
|
|
189
205
|
const outOfAttempts = i > nrOfAttempts - 1;
|
|
190
206
|
if (isAuthError || outOfAttempts) {
|
|
191
207
|
this._setErrored(err);
|
|
192
|
-
(
|
|
208
|
+
(_c = (_b = this.hooks).reconnectError) == null ? void 0 : _c.call(_b, err);
|
|
193
209
|
break;
|
|
194
210
|
}
|
|
195
211
|
yield wait(Math.min(Math.pow(1.5, i) * 1e3, maxWaitTime));
|
package/dist/client.browser.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -18,7 +16,6 @@ var __spreadValues = (a, b) => {
|
|
|
18
16
|
}
|
|
19
17
|
return a;
|
|
20
18
|
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
19
|
var __export = (target, all) => {
|
|
23
20
|
for (var name in all)
|
|
24
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -76,16 +73,13 @@ var Client = class {
|
|
|
76
73
|
this.api = _apiClient;
|
|
77
74
|
this.$connect = _apiClient.$connect;
|
|
78
75
|
if (initialConf) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.setHook(hookName, value);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
76
|
+
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
77
|
+
sendingTimeout: initialConf.sendingTimeout
|
|
78
|
+
}), initialConf.connectingTimeout && {
|
|
79
|
+
connectingTimeout: initialConf.connectingTimeout
|
|
80
|
+
}), initialConf.reconnectingTimeout && {
|
|
81
|
+
reconnectingTimeout: initialConf.reconnectingTimeout
|
|
82
|
+
}), initialConf.hooks && { hooks: initialConf.hooks }));
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
/**
|
|
@@ -135,13 +129,14 @@ var Client = class {
|
|
|
135
129
|
return this;
|
|
136
130
|
}
|
|
137
131
|
/**
|
|
138
|
-
* Overwrite client configuration (default token, hooks)
|
|
132
|
+
* Overwrite client configuration (default token, default timeout, hooks)
|
|
139
133
|
*
|
|
140
134
|
*
|
|
141
135
|
* ```javascript
|
|
142
136
|
*
|
|
143
137
|
* wapiClient.configure({
|
|
144
138
|
* token: 'EURO',
|
|
139
|
+
* timeout: 45000,
|
|
145
140
|
* hooks: {
|
|
146
141
|
* disconnect: () => {}
|
|
147
142
|
* },
|
|
@@ -151,7 +146,33 @@ var Client = class {
|
|
|
151
146
|
* @param {ClientConfig} newConf
|
|
152
147
|
*/
|
|
153
148
|
configure(newConf) {
|
|
149
|
+
if (newConf.token && typeof newConf.token !== "string" && typeof newConf.token !== "number") {
|
|
150
|
+
throw new import_errors.ConfigError("CONFIG_INVALID", {
|
|
151
|
+
field: "token",
|
|
152
|
+
error: `Must be a string|number, '${newConf.token}' provided`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
["sendingTimeout", "connectingTimeout", "reconnectingTimeout"].forEach(
|
|
156
|
+
(t) => {
|
|
157
|
+
if (newConf[t] && typeof newConf[t] !== "number") {
|
|
158
|
+
throw new import_errors.ConfigError("CONFIG_INVALID", {
|
|
159
|
+
field: t,
|
|
160
|
+
error: `Must be a number, '${newConf[t]}' provided`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
const hooks = newConf.hooks;
|
|
166
|
+
delete newConf.hooks;
|
|
154
167
|
this.config = __spreadValues(__spreadValues({}, this.config), newConf);
|
|
168
|
+
if (this.config.sendingTimeout) {
|
|
169
|
+
this.api.sendingTimeout = this.config.sendingTimeout;
|
|
170
|
+
}
|
|
171
|
+
if (hooks) {
|
|
172
|
+
for (const [hookName, value] of Object.entries(hooks)) {
|
|
173
|
+
this.setHook(hookName, value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
155
176
|
return this;
|
|
156
177
|
}
|
|
157
178
|
/**
|
|
@@ -778,6 +799,49 @@ var Client = class {
|
|
|
778
799
|
/**
|
|
779
800
|
*
|
|
780
801
|
*
|
|
802
|
+
* ```javascript
|
|
803
|
+
*
|
|
804
|
+
* // setup
|
|
805
|
+
* await wapiClient.createDeposit(
|
|
806
|
+
* {
|
|
807
|
+
* wallet: 'newWallet',
|
|
808
|
+
* amount: 10,
|
|
809
|
+
* status: 'pending',
|
|
810
|
+
* identifier: 'depositUSD',
|
|
811
|
+
* token: 'USD',
|
|
812
|
+
* },
|
|
813
|
+
* {
|
|
814
|
+
* create_wallet_if_not_exists: true,
|
|
815
|
+
* },
|
|
816
|
+
* );
|
|
817
|
+
* await wapiClient.updateTransfer({
|
|
818
|
+
* transfer: 'depositUSD',
|
|
819
|
+
* status: 'finished',
|
|
820
|
+
* });
|
|
821
|
+
*
|
|
822
|
+
* const result = await wapiClient.exportBalanceHistory(
|
|
823
|
+
* {
|
|
824
|
+
* wallet: 'newWallet',
|
|
825
|
+
* token: 'USD',
|
|
826
|
+
* },
|
|
827
|
+
* {
|
|
828
|
+
* limit: 0,
|
|
829
|
+
* select: [
|
|
830
|
+
* 'transfer_identifier',
|
|
831
|
+
* 'pending_amount',
|
|
832
|
+
* 'finished_amount',
|
|
833
|
+
* 'pending_amount_from',
|
|
834
|
+
* 'pending_amount_to',
|
|
835
|
+
* 'amount',
|
|
836
|
+
* ],
|
|
837
|
+
* offset: 0,
|
|
838
|
+
* order: 'desc',
|
|
839
|
+
* tracking_id: 'mylogId',
|
|
840
|
+
* // transaction_id: Transaction.identifier, // created transaction identifier
|
|
841
|
+
* },
|
|
842
|
+
* );
|
|
843
|
+
*
|
|
844
|
+
* ```
|
|
781
845
|
*
|
|
782
846
|
* @param {ExportBalanceHistoryFnInput} input
|
|
783
847
|
* @param {ExportBalanceHistoryFnOptions} [options]
|
|
@@ -1299,8 +1363,11 @@ var Client = class {
|
|
|
1299
1363
|
* ```javascript
|
|
1300
1364
|
*
|
|
1301
1365
|
* const result = await wapiClient.listExports(
|
|
1302
|
-
* {},
|
|
1303
1366
|
* {
|
|
1367
|
+
* type: 'transfers',
|
|
1368
|
+
* },
|
|
1369
|
+
* {
|
|
1370
|
+
* order_by: 'created_at desc',
|
|
1304
1371
|
* tracking_id: 'myLogId',
|
|
1305
1372
|
* },
|
|
1306
1373
|
* );
|
|
@@ -1741,10 +1808,16 @@ var Client = class {
|
|
|
1741
1808
|
// CLIENTFNDEFS
|
|
1742
1809
|
};
|
|
1743
1810
|
function createClientWithWS(opts, config) {
|
|
1744
|
-
const wsClient = (0, import_api.createWsClient)(opts
|
|
1811
|
+
const wsClient = (0, import_api.createWsClient)(opts, {
|
|
1812
|
+
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
1813
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
1814
|
+
});
|
|
1745
1815
|
return new Client(wsClient, config);
|
|
1746
1816
|
}
|
|
1747
1817
|
function createClientWithHttp(opts, config) {
|
|
1748
|
-
const httpClient = (0, import_api.createHttpClient)(opts
|
|
1818
|
+
const httpClient = (0, import_api.createHttpClient)(opts, {
|
|
1819
|
+
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
1820
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
1821
|
+
});
|
|
1749
1822
|
return new Client(httpClient, config);
|
|
1750
1823
|
}
|
package/dist/client.browser.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
var __async = (__this, __arguments, generator) => {
|
|
21
18
|
return new Promise((resolve, reject) => {
|
|
22
19
|
var fulfilled = (value) => {
|
|
@@ -43,7 +40,7 @@ import {
|
|
|
43
40
|
createHttpClient,
|
|
44
41
|
createWsClient
|
|
45
42
|
} from "./api/index.browser.js";
|
|
46
|
-
import { ValidationError } from "./lib/errors.browser.js";
|
|
43
|
+
import { ConfigError, ValidationError } from "./lib/errors.browser.js";
|
|
47
44
|
import { ClientFunctions } from "./fns/index.browser.js";
|
|
48
45
|
import {
|
|
49
46
|
isImportDataFnOptions,
|
|
@@ -60,16 +57,13 @@ var Client = class {
|
|
|
60
57
|
this.api = _apiClient;
|
|
61
58
|
this.$connect = _apiClient.$connect;
|
|
62
59
|
if (initialConf) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.setHook(hookName, value);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
60
|
+
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
61
|
+
sendingTimeout: initialConf.sendingTimeout
|
|
62
|
+
}), initialConf.connectingTimeout && {
|
|
63
|
+
connectingTimeout: initialConf.connectingTimeout
|
|
64
|
+
}), initialConf.reconnectingTimeout && {
|
|
65
|
+
reconnectingTimeout: initialConf.reconnectingTimeout
|
|
66
|
+
}), initialConf.hooks && { hooks: initialConf.hooks }));
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
/**
|
|
@@ -119,13 +113,14 @@ var Client = class {
|
|
|
119
113
|
return this;
|
|
120
114
|
}
|
|
121
115
|
/**
|
|
122
|
-
* Overwrite client configuration (default token, hooks)
|
|
116
|
+
* Overwrite client configuration (default token, default timeout, hooks)
|
|
123
117
|
*
|
|
124
118
|
*
|
|
125
119
|
* ```javascript
|
|
126
120
|
*
|
|
127
121
|
* wapiClient.configure({
|
|
128
122
|
* token: 'EURO',
|
|
123
|
+
* timeout: 45000,
|
|
129
124
|
* hooks: {
|
|
130
125
|
* disconnect: () => {}
|
|
131
126
|
* },
|
|
@@ -135,7 +130,33 @@ var Client = class {
|
|
|
135
130
|
* @param {ClientConfig} newConf
|
|
136
131
|
*/
|
|
137
132
|
configure(newConf) {
|
|
133
|
+
if (newConf.token && typeof newConf.token !== "string" && typeof newConf.token !== "number") {
|
|
134
|
+
throw new ConfigError("CONFIG_INVALID", {
|
|
135
|
+
field: "token",
|
|
136
|
+
error: `Must be a string|number, '${newConf.token}' provided`
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
["sendingTimeout", "connectingTimeout", "reconnectingTimeout"].forEach(
|
|
140
|
+
(t) => {
|
|
141
|
+
if (newConf[t] && typeof newConf[t] !== "number") {
|
|
142
|
+
throw new ConfigError("CONFIG_INVALID", {
|
|
143
|
+
field: t,
|
|
144
|
+
error: `Must be a number, '${newConf[t]}' provided`
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
const hooks = newConf.hooks;
|
|
150
|
+
delete newConf.hooks;
|
|
138
151
|
this.config = __spreadValues(__spreadValues({}, this.config), newConf);
|
|
152
|
+
if (this.config.sendingTimeout) {
|
|
153
|
+
this.api.sendingTimeout = this.config.sendingTimeout;
|
|
154
|
+
}
|
|
155
|
+
if (hooks) {
|
|
156
|
+
for (const [hookName, value] of Object.entries(hooks)) {
|
|
157
|
+
this.setHook(hookName, value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
139
160
|
return this;
|
|
140
161
|
}
|
|
141
162
|
/**
|
|
@@ -762,6 +783,49 @@ var Client = class {
|
|
|
762
783
|
/**
|
|
763
784
|
*
|
|
764
785
|
*
|
|
786
|
+
* ```javascript
|
|
787
|
+
*
|
|
788
|
+
* // setup
|
|
789
|
+
* await wapiClient.createDeposit(
|
|
790
|
+
* {
|
|
791
|
+
* wallet: 'newWallet',
|
|
792
|
+
* amount: 10,
|
|
793
|
+
* status: 'pending',
|
|
794
|
+
* identifier: 'depositUSD',
|
|
795
|
+
* token: 'USD',
|
|
796
|
+
* },
|
|
797
|
+
* {
|
|
798
|
+
* create_wallet_if_not_exists: true,
|
|
799
|
+
* },
|
|
800
|
+
* );
|
|
801
|
+
* await wapiClient.updateTransfer({
|
|
802
|
+
* transfer: 'depositUSD',
|
|
803
|
+
* status: 'finished',
|
|
804
|
+
* });
|
|
805
|
+
*
|
|
806
|
+
* const result = await wapiClient.exportBalanceHistory(
|
|
807
|
+
* {
|
|
808
|
+
* wallet: 'newWallet',
|
|
809
|
+
* token: 'USD',
|
|
810
|
+
* },
|
|
811
|
+
* {
|
|
812
|
+
* limit: 0,
|
|
813
|
+
* select: [
|
|
814
|
+
* 'transfer_identifier',
|
|
815
|
+
* 'pending_amount',
|
|
816
|
+
* 'finished_amount',
|
|
817
|
+
* 'pending_amount_from',
|
|
818
|
+
* 'pending_amount_to',
|
|
819
|
+
* 'amount',
|
|
820
|
+
* ],
|
|
821
|
+
* offset: 0,
|
|
822
|
+
* order: 'desc',
|
|
823
|
+
* tracking_id: 'mylogId',
|
|
824
|
+
* // transaction_id: Transaction.identifier, // created transaction identifier
|
|
825
|
+
* },
|
|
826
|
+
* );
|
|
827
|
+
*
|
|
828
|
+
* ```
|
|
765
829
|
*
|
|
766
830
|
* @param {ExportBalanceHistoryFnInput} input
|
|
767
831
|
* @param {ExportBalanceHistoryFnOptions} [options]
|
|
@@ -1283,8 +1347,11 @@ var Client = class {
|
|
|
1283
1347
|
* ```javascript
|
|
1284
1348
|
*
|
|
1285
1349
|
* const result = await wapiClient.listExports(
|
|
1286
|
-
* {},
|
|
1287
1350
|
* {
|
|
1351
|
+
* type: 'transfers',
|
|
1352
|
+
* },
|
|
1353
|
+
* {
|
|
1354
|
+
* order_by: 'created_at desc',
|
|
1288
1355
|
* tracking_id: 'myLogId',
|
|
1289
1356
|
* },
|
|
1290
1357
|
* );
|
|
@@ -1725,11 +1792,17 @@ var Client = class {
|
|
|
1725
1792
|
// CLIENTFNDEFS
|
|
1726
1793
|
};
|
|
1727
1794
|
function createClientWithWS(opts, config) {
|
|
1728
|
-
const wsClient = createWsClient(opts
|
|
1795
|
+
const wsClient = createWsClient(opts, {
|
|
1796
|
+
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
1797
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
1798
|
+
});
|
|
1729
1799
|
return new Client(wsClient, config);
|
|
1730
1800
|
}
|
|
1731
1801
|
function createClientWithHttp(opts, config) {
|
|
1732
|
-
const httpClient = createHttpClient(opts
|
|
1802
|
+
const httpClient = createHttpClient(opts, {
|
|
1803
|
+
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
1804
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
1805
|
+
});
|
|
1733
1806
|
return new Client(httpClient, config);
|
|
1734
1807
|
}
|
|
1735
1808
|
export {
|
package/dist/client.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -18,7 +16,6 @@ var __spreadValues = (a, b) => {
|
|
|
18
16
|
}
|
|
19
17
|
return a;
|
|
20
18
|
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
19
|
var __export = (target, all) => {
|
|
23
20
|
for (var name in all)
|
|
24
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -66,7 +63,7 @@ var import_errors = require('./lib/errors.cjs');
|
|
|
66
63
|
var import_fns = require('./fns/index.cjs');
|
|
67
64
|
var import_import_data = require('./fns/import-data/import-data.guards.cjs');
|
|
68
65
|
var _a;
|
|
69
|
-
var CLIENT_VERSION = (_a = '0.10.
|
|
66
|
+
var CLIENT_VERSION = (_a = '0.10.6') != null ? _a : "";
|
|
70
67
|
var Client = class {
|
|
71
68
|
/**
|
|
72
69
|
* @internal
|
|
@@ -76,16 +73,13 @@ var Client = class {
|
|
|
76
73
|
this.api = _apiClient;
|
|
77
74
|
this.$connect = _apiClient.$connect;
|
|
78
75
|
if (initialConf) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.setHook(hookName, value);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
76
|
+
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
77
|
+
sendingTimeout: initialConf.sendingTimeout
|
|
78
|
+
}), initialConf.connectingTimeout && {
|
|
79
|
+
connectingTimeout: initialConf.connectingTimeout
|
|
80
|
+
}), initialConf.reconnectingTimeout && {
|
|
81
|
+
reconnectingTimeout: initialConf.reconnectingTimeout
|
|
82
|
+
}), initialConf.hooks && { hooks: initialConf.hooks }));
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
/**
|
|
@@ -135,13 +129,14 @@ var Client = class {
|
|
|
135
129
|
return this;
|
|
136
130
|
}
|
|
137
131
|
/**
|
|
138
|
-
* Overwrite client configuration (default token, hooks)
|
|
132
|
+
* Overwrite client configuration (default token, default timeout, hooks)
|
|
139
133
|
*
|
|
140
134
|
*
|
|
141
135
|
* ```javascript
|
|
142
136
|
*
|
|
143
137
|
* wapiClient.configure({
|
|
144
138
|
* token: 'EURO',
|
|
139
|
+
* timeout: 45000,
|
|
145
140
|
* hooks: {
|
|
146
141
|
* disconnect: () => {}
|
|
147
142
|
* },
|
|
@@ -151,7 +146,33 @@ var Client = class {
|
|
|
151
146
|
* @param {ClientConfig} newConf
|
|
152
147
|
*/
|
|
153
148
|
configure(newConf) {
|
|
149
|
+
if (newConf.token && typeof newConf.token !== "string" && typeof newConf.token !== "number") {
|
|
150
|
+
throw new import_errors.ConfigError("CONFIG_INVALID", {
|
|
151
|
+
field: "token",
|
|
152
|
+
error: `Must be a string|number, '${newConf.token}' provided`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
["sendingTimeout", "connectingTimeout", "reconnectingTimeout"].forEach(
|
|
156
|
+
(t) => {
|
|
157
|
+
if (newConf[t] && typeof newConf[t] !== "number") {
|
|
158
|
+
throw new import_errors.ConfigError("CONFIG_INVALID", {
|
|
159
|
+
field: t,
|
|
160
|
+
error: `Must be a number, '${newConf[t]}' provided`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
const hooks = newConf.hooks;
|
|
166
|
+
delete newConf.hooks;
|
|
154
167
|
this.config = __spreadValues(__spreadValues({}, this.config), newConf);
|
|
168
|
+
if (this.config.sendingTimeout) {
|
|
169
|
+
this.api.sendingTimeout = this.config.sendingTimeout;
|
|
170
|
+
}
|
|
171
|
+
if (hooks) {
|
|
172
|
+
for (const [hookName, value] of Object.entries(hooks)) {
|
|
173
|
+
this.setHook(hookName, value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
155
176
|
return this;
|
|
156
177
|
}
|
|
157
178
|
/**
|
|
@@ -778,6 +799,49 @@ var Client = class {
|
|
|
778
799
|
/**
|
|
779
800
|
*
|
|
780
801
|
*
|
|
802
|
+
* ```javascript
|
|
803
|
+
*
|
|
804
|
+
* // setup
|
|
805
|
+
* await wapiClient.createDeposit(
|
|
806
|
+
* {
|
|
807
|
+
* wallet: 'newWallet',
|
|
808
|
+
* amount: 10,
|
|
809
|
+
* status: 'pending',
|
|
810
|
+
* identifier: 'depositUSD',
|
|
811
|
+
* token: 'USD',
|
|
812
|
+
* },
|
|
813
|
+
* {
|
|
814
|
+
* create_wallet_if_not_exists: true,
|
|
815
|
+
* },
|
|
816
|
+
* );
|
|
817
|
+
* await wapiClient.updateTransfer({
|
|
818
|
+
* transfer: 'depositUSD',
|
|
819
|
+
* status: 'finished',
|
|
820
|
+
* });
|
|
821
|
+
*
|
|
822
|
+
* const result = await wapiClient.exportBalanceHistory(
|
|
823
|
+
* {
|
|
824
|
+
* wallet: 'newWallet',
|
|
825
|
+
* token: 'USD',
|
|
826
|
+
* },
|
|
827
|
+
* {
|
|
828
|
+
* limit: 0,
|
|
829
|
+
* select: [
|
|
830
|
+
* 'transfer_identifier',
|
|
831
|
+
* 'pending_amount',
|
|
832
|
+
* 'finished_amount',
|
|
833
|
+
* 'pending_amount_from',
|
|
834
|
+
* 'pending_amount_to',
|
|
835
|
+
* 'amount',
|
|
836
|
+
* ],
|
|
837
|
+
* offset: 0,
|
|
838
|
+
* order: 'desc',
|
|
839
|
+
* tracking_id: 'mylogId',
|
|
840
|
+
* // transaction_id: Transaction.identifier, // created transaction identifier
|
|
841
|
+
* },
|
|
842
|
+
* );
|
|
843
|
+
*
|
|
844
|
+
* ```
|
|
781
845
|
*
|
|
782
846
|
* @param {ExportBalanceHistoryFnInput} input
|
|
783
847
|
* @param {ExportBalanceHistoryFnOptions} [options]
|
|
@@ -1299,8 +1363,11 @@ var Client = class {
|
|
|
1299
1363
|
* ```javascript
|
|
1300
1364
|
*
|
|
1301
1365
|
* const result = await wapiClient.listExports(
|
|
1302
|
-
* {},
|
|
1303
1366
|
* {
|
|
1367
|
+
* type: 'transfers',
|
|
1368
|
+
* },
|
|
1369
|
+
* {
|
|
1370
|
+
* order_by: 'created_at desc',
|
|
1304
1371
|
* tracking_id: 'myLogId',
|
|
1305
1372
|
* },
|
|
1306
1373
|
* );
|
|
@@ -1741,11 +1808,17 @@ var Client = class {
|
|
|
1741
1808
|
// CLIENTFNDEFS
|
|
1742
1809
|
};
|
|
1743
1810
|
function createClientWithWS(opts, config) {
|
|
1744
|
-
const wsClient = (0, import_api.createWsClient)(opts
|
|
1811
|
+
const wsClient = (0, import_api.createWsClient)(opts, {
|
|
1812
|
+
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
1813
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
1814
|
+
});
|
|
1745
1815
|
return new Client(wsClient, config);
|
|
1746
1816
|
}
|
|
1747
1817
|
function createClientWithHttp(opts, config) {
|
|
1748
|
-
const httpClient = (0, import_api.createHttpClient)(opts
|
|
1818
|
+
const httpClient = (0, import_api.createHttpClient)(opts, {
|
|
1819
|
+
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
1820
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
1821
|
+
});
|
|
1749
1822
|
return new Client(httpClient, config);
|
|
1750
1823
|
}
|
|
1751
1824
|
// Annotate the CommonJS export names for ESM import in node:
|