wapi-client 0.10.4 → 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +47 -17
- package/dist/client.browser.js +48 -18
- package/dist/client.cjs +48 -18
- package/dist/client.d.ts +10 -5
- package/dist/client.js +49 -19
- package/dist/fns/create-access-token/create-access-token.browser.cjs +6 -1
- package/dist/fns/create-access-token/create-access-token.browser.js +6 -1
- package/dist/fns/create-access-token/create-access-token.cjs +6 -1
- package/dist/fns/create-access-token/create-access-token.enums.d.ts +1 -1
- package/dist/fns/create-access-token/create-access-token.js +6 -1
- package/dist/fns/create-access-token/create-access-token.schema.input.json +13 -1
- package/dist/fns/get-balance-history/get-balance-history.browser.cjs +2 -1
- package/dist/fns/get-balance-history/get-balance-history.browser.js +2 -1
- package/dist/fns/get-balance-history/get-balance-history.cjs +2 -1
- package/dist/fns/get-balance-history/get-balance-history.enums.d.ts +5 -1
- package/dist/fns/get-balance-history/get-balance-history.js +2 -1
- package/dist/fns/get-balance-history/get-balance-history.schema.input.json +5 -0
- 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/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/create-access-token/create-access-token.enums.d.ts +1 -1
- package/dist/txs/create-access-token/create-access-token.schema.input.json +8 -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/get-token/get-token.enums.d.ts +5 -1
- package/dist/txs/get-token/get-token.schema.output.json +3 -0
- 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/types/index.d.ts +264 -141
- 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.10') != 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
|
/**
|
|
@@ -1342,8 +1363,11 @@ var Client = class {
|
|
|
1342
1363
|
* ```javascript
|
|
1343
1364
|
*
|
|
1344
1365
|
* const result = await wapiClient.listExports(
|
|
1345
|
-
* {},
|
|
1346
1366
|
* {
|
|
1367
|
+
* type: 'transfers',
|
|
1368
|
+
* },
|
|
1369
|
+
* {
|
|
1370
|
+
* order_by: 'created_at desc',
|
|
1347
1371
|
* tracking_id: 'myLogId',
|
|
1348
1372
|
* },
|
|
1349
1373
|
* );
|
|
@@ -1784,10 +1808,16 @@ var Client = class {
|
|
|
1784
1808
|
// CLIENTFNDEFS
|
|
1785
1809
|
};
|
|
1786
1810
|
function createClientWithWS(opts, config) {
|
|
1787
|
-
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
|
+
});
|
|
1788
1815
|
return new Client(wsClient, config);
|
|
1789
1816
|
}
|
|
1790
1817
|
function createClientWithHttp(opts, config) {
|
|
1791
|
-
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
|
+
});
|
|
1792
1822
|
return new Client(httpClient, config);
|
|
1793
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
|
/**
|
|
@@ -1326,8 +1347,11 @@ var Client = class {
|
|
|
1326
1347
|
* ```javascript
|
|
1327
1348
|
*
|
|
1328
1349
|
* const result = await wapiClient.listExports(
|
|
1329
|
-
* {},
|
|
1330
1350
|
* {
|
|
1351
|
+
* type: 'transfers',
|
|
1352
|
+
* },
|
|
1353
|
+
* {
|
|
1354
|
+
* order_by: 'created_at desc',
|
|
1331
1355
|
* tracking_id: 'myLogId',
|
|
1332
1356
|
* },
|
|
1333
1357
|
* );
|
|
@@ -1768,11 +1792,17 @@ var Client = class {
|
|
|
1768
1792
|
// CLIENTFNDEFS
|
|
1769
1793
|
};
|
|
1770
1794
|
function createClientWithWS(opts, config) {
|
|
1771
|
-
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
|
+
});
|
|
1772
1799
|
return new Client(wsClient, config);
|
|
1773
1800
|
}
|
|
1774
1801
|
function createClientWithHttp(opts, config) {
|
|
1775
|
-
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
|
+
});
|
|
1776
1806
|
return new Client(httpClient, config);
|
|
1777
1807
|
}
|
|
1778
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.10') != 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
|
/**
|
|
@@ -1342,8 +1363,11 @@ var Client = class {
|
|
|
1342
1363
|
* ```javascript
|
|
1343
1364
|
*
|
|
1344
1365
|
* const result = await wapiClient.listExports(
|
|
1345
|
-
* {},
|
|
1346
1366
|
* {
|
|
1367
|
+
* type: 'transfers',
|
|
1368
|
+
* },
|
|
1369
|
+
* {
|
|
1370
|
+
* order_by: 'created_at desc',
|
|
1347
1371
|
* tracking_id: 'myLogId',
|
|
1348
1372
|
* },
|
|
1349
1373
|
* );
|
|
@@ -1784,11 +1808,17 @@ var Client = class {
|
|
|
1784
1808
|
// CLIENTFNDEFS
|
|
1785
1809
|
};
|
|
1786
1810
|
function createClientWithWS(opts, config) {
|
|
1787
|
-
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
|
+
});
|
|
1788
1815
|
return new Client(wsClient, config);
|
|
1789
1816
|
}
|
|
1790
1817
|
function createClientWithHttp(opts, config) {
|
|
1791
|
-
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
|
+
});
|
|
1792
1822
|
return new Client(httpClient, config);
|
|
1793
1823
|
}
|
|
1794
1824
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WapiConnectionOptions, WapiHttpConnectionOptions, WsClient, HttpClient } from './api';
|
|
1
|
+
import { WapiConnectionOptions, WapiHttpConnectionOptions, WsClient, HttpClient, ConnectionConfig } from './api';
|
|
2
2
|
import { ClientHooks, ISocketId } from './api/base-client';
|
|
3
3
|
import { AggregateQueryBuilder, UpdateQueryBuilder, ReverseQueryBuilder, QueryBuilder } from './lib/query-builder';
|
|
4
4
|
import { StreamPromise } from './lib/stream-promise';
|
|
@@ -59,9 +59,10 @@ import { UpdateTransferGroupsFnFields, UpdateTransferGroupsFnMetadataFields, Upd
|
|
|
59
59
|
import { UpdateTransfersFnInput, UpdateTransfersFnOutput, UpdateTransfersFnOptions, UpdateTransfersFnUpdateFields } from './fns/update-transfers/update-transfers.enums';
|
|
60
60
|
import { UpdateTransfersFnFields, UpdateTransfersFnMetadataFields, UpdateTransfersFnStringFields, UpdateTransfersFnResultFields } from './fns/update-transfers/update-transfers';
|
|
61
61
|
import { UpdateWalletFnInput, UpdateWalletFnOutput, UpdateWalletFnOptions } from './fns/update-wallet/update-wallet.enums';
|
|
62
|
-
export interface ClientConfig {
|
|
62
|
+
export interface ClientConfig extends ConnectionConfig {
|
|
63
63
|
token?: number | string;
|
|
64
64
|
hooks?: ClientHooks;
|
|
65
|
+
sendingTimeout?: number;
|
|
65
66
|
}
|
|
66
67
|
export declare class Client {
|
|
67
68
|
/**
|
|
@@ -112,13 +113,14 @@ export declare class Client {
|
|
|
112
113
|
*/
|
|
113
114
|
setHook(hookName: keyof ClientHooks, value: (input?: unknown) => boolean | void): this;
|
|
114
115
|
/**
|
|
115
|
-
* Overwrite client configuration (default token, hooks)
|
|
116
|
+
* Overwrite client configuration (default token, default timeout, hooks)
|
|
116
117
|
*
|
|
117
118
|
*
|
|
118
119
|
* ```javascript
|
|
119
120
|
*
|
|
120
121
|
* wapiClient.configure({
|
|
121
122
|
* token: 'EURO',
|
|
123
|
+
* timeout: 45000,
|
|
122
124
|
* hooks: {
|
|
123
125
|
* disconnect: () => {}
|
|
124
126
|
* },
|
|
@@ -136,7 +138,7 @@ export declare class Client {
|
|
|
136
138
|
*
|
|
137
139
|
* ```
|
|
138
140
|
*/
|
|
139
|
-
getConfig(key: '
|
|
141
|
+
getConfig(key: keyof Omit<ClientConfig, 'hooks'>): number | string | undefined;
|
|
140
142
|
/**
|
|
141
143
|
*
|
|
142
144
|
* Aggregate Transfers using either a simple filter or queryBuilder
|
|
@@ -1625,8 +1627,11 @@ export declare class Client {
|
|
|
1625
1627
|
* ```javascript
|
|
1626
1628
|
*
|
|
1627
1629
|
* const result = await wapiClient.listExports(
|
|
1628
|
-
* {},
|
|
1629
1630
|
* {
|
|
1631
|
+
* type: 'transfers',
|
|
1632
|
+
* },
|
|
1633
|
+
* {
|
|
1634
|
+
* order_by: 'created_at desc',
|
|
1630
1635
|
* tracking_id: 'myLogId',
|
|
1631
1636
|
* },
|
|
1632
1637
|
* );
|
package/dist/client.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,14 +40,14 @@ import {
|
|
|
43
40
|
createHttpClient,
|
|
44
41
|
createWsClient
|
|
45
42
|
} from "./api";
|
|
46
|
-
import { ValidationError } from "./lib/errors";
|
|
43
|
+
import { ConfigError, ValidationError } from "./lib/errors";
|
|
47
44
|
import { ClientFunctions } from "./fns";
|
|
48
45
|
import {
|
|
49
46
|
isImportDataFnOptions,
|
|
50
47
|
isImportDataFnInput
|
|
51
48
|
} from "./fns/import-data/import-data.guards";
|
|
52
49
|
var _a;
|
|
53
|
-
var CLIENT_VERSION = (_a = '0.10.
|
|
50
|
+
var CLIENT_VERSION = (_a = '0.10.10') != null ? _a : "";
|
|
54
51
|
var Client = class {
|
|
55
52
|
/**
|
|
56
53
|
* @internal
|
|
@@ -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
|
/**
|
|
@@ -1326,8 +1347,11 @@ var Client = class {
|
|
|
1326
1347
|
* ```javascript
|
|
1327
1348
|
*
|
|
1328
1349
|
* const result = await wapiClient.listExports(
|
|
1329
|
-
* {},
|
|
1330
1350
|
* {
|
|
1351
|
+
* type: 'transfers',
|
|
1352
|
+
* },
|
|
1353
|
+
* {
|
|
1354
|
+
* order_by: 'created_at desc',
|
|
1331
1355
|
* tracking_id: 'myLogId',
|
|
1332
1356
|
* },
|
|
1333
1357
|
* );
|
|
@@ -1768,11 +1792,17 @@ var Client = class {
|
|
|
1768
1792
|
// CLIENTFNDEFS
|
|
1769
1793
|
};
|
|
1770
1794
|
function createClientWithWS(opts, config) {
|
|
1771
|
-
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
|
+
});
|
|
1772
1799
|
return new Client(wsClient, config);
|
|
1773
1800
|
}
|
|
1774
1801
|
function createClientWithHttp(opts, config) {
|
|
1775
|
-
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
|
+
});
|
|
1776
1806
|
return new Client(httpClient, config);
|
|
1777
1807
|
}
|
|
1778
1808
|
export {
|
|
@@ -28,11 +28,16 @@ var import_validator = require('../../lib/validator.cjs');
|
|
|
28
28
|
var clientFnToTxMap = new Map(
|
|
29
29
|
Object.entries({
|
|
30
30
|
aggregateTransfers: "aggregateTransferMany",
|
|
31
|
+
exportTokens: "exportTokenMany",
|
|
32
|
+
exportTransferGroups: "exportTransferGroupMany",
|
|
33
|
+
exportTransfers: "exportTransferMany",
|
|
34
|
+
exportWallets: "exportWalletMany",
|
|
31
35
|
findBalances: "findBalanceMany",
|
|
32
36
|
findTokens: "findTokenMany",
|
|
33
37
|
findTransferGroups: "findTransferGroupMany",
|
|
34
38
|
findTransfers: "findTransferMany",
|
|
35
|
-
findWallets: "findWalletMany"
|
|
39
|
+
findWallets: "findWalletMany",
|
|
40
|
+
listExports: "listExportMany"
|
|
36
41
|
})
|
|
37
42
|
);
|
|
38
43
|
var validate = (0, import_validator.getValidator)(import_validator.SchemaNames.CreateAccessTokenFnInput);
|