wapi-client 0.15.8 → 0.16.0-beta.1
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 +62 -41
- package/dist/api/base-client.browser.js +62 -41
- package/dist/api/base-client.cjs +62 -41
- package/dist/api/base-client.js +62 -41
- package/dist/api/http-client.browser.cjs +13 -13
- package/dist/api/http-client.browser.js +14 -14
- package/dist/api/http-client.cjs +13 -13
- package/dist/api/http-client.js +14 -14
- package/dist/api/ws-client.browser.cjs +2 -2
- package/dist/api/ws-client.browser.js +2 -2
- package/dist/api/ws-client.cjs +2 -2
- package/dist/api/ws-client.js +2 -2
- package/dist/client-options.schema.zod.browser.cjs +12 -17
- package/dist/client-options.schema.zod.browser.js +12 -17
- package/dist/client-options.schema.zod.cjs +15 -21
- package/dist/client-options.schema.zod.js +12 -17
- package/dist/client.browser.cjs +19 -5
- package/dist/client.browser.js +19 -5
- package/dist/client.cjs +19 -5
- package/dist/client.js +19 -5
- package/dist/lib/env.browser.cjs +1 -1
- package/dist/lib/env.browser.js +1 -1
- package/dist/lib/env.cjs +1 -1
- package/dist/lib/env.js +1 -1
- package/dist/lib/errors.browser.cjs +5 -0
- package/dist/lib/errors.browser.js +5 -0
- package/dist/lib/errors.cjs +5 -0
- package/dist/lib/errors.js +5 -0
- package/dist/lib/utils.browser.cjs +10 -4
- package/dist/lib/utils.browser.js +10 -4
- package/dist/lib/utils.cjs +11 -4
- package/dist/lib/utils.js +10 -4
- package/dist/types/wapi-client.d.ts +79 -52
- package/dist/wapi-client-web.iife.js +7 -7
- package/dist/wapi-client.browser.cjs +4 -6
- package/dist/wapi-client.browser.js +5 -10
- package/dist/wapi-client.cjs +4 -6
- package/dist/wapi-client.iife.js +7 -7
- package/dist/wapi-client.js +5 -10
- package/package.json +2 -2
|
@@ -657,17 +657,22 @@ function createConnection(opts, connectionConfig) {
|
|
|
657
657
|
(0, import_debug.debugLog)(`http_createConnection>message(body:$0)`, body);
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function getHeaders(id) {
|
|
661
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
662
|
+
"content-type": "application/json"
|
|
663
|
+
}, id ? { [REQ_HEADER_ID]: id } : {}), (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}), "jwt" in opts ? {
|
|
664
|
+
Authorization: `Bearer ${opts.jwt}`
|
|
665
|
+
} : {}), "apikey" in opts ? {
|
|
666
|
+
Authorization: `Basic ${(0, import_utils.getBasicAuth)(opts)}`
|
|
667
|
+
} : {});
|
|
668
|
+
}
|
|
669
|
+
function send(body) {
|
|
661
670
|
return __async(this, null, function* () {
|
|
662
671
|
const jsonBody = JSON.parse(body);
|
|
663
672
|
const res = yield (0, import_cross_fetch.default)(`${url}/api`, {
|
|
664
673
|
keepalive: true,
|
|
665
674
|
method: "POST",
|
|
666
|
-
headers:
|
|
667
|
-
Authorization: `Bearer ${jwt}`,
|
|
668
|
-
"content-type": "application/json",
|
|
669
|
-
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
670
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
675
|
+
headers: getHeaders(jsonBody == null ? void 0 : jsonBody.id),
|
|
671
676
|
body
|
|
672
677
|
});
|
|
673
678
|
const responseBody = yield res.json();
|
|
@@ -693,11 +698,7 @@ function createConnection(opts, connectionConfig) {
|
|
|
693
698
|
}, connectionConfig.timeout) : void 0;
|
|
694
699
|
(0, import_cross_fetch.default)(`${url}/api`, {
|
|
695
700
|
method: "POST",
|
|
696
|
-
headers:
|
|
697
|
-
Authorization: `Bearer ${opts.jwt}`,
|
|
698
|
-
"content-type": "application/json",
|
|
699
|
-
[REQ_HEADER_ID]: connectId
|
|
700
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
701
|
+
headers: getHeaders(connectId),
|
|
701
702
|
body: JSON.stringify({
|
|
702
703
|
jsonrpc: import_jsonrpc_enums.JSONRPC.version,
|
|
703
704
|
method: "authenticationCheck",
|
|
@@ -727,7 +728,6 @@ var HttpClient = class extends import_base_client.BaseClient {
|
|
|
727
728
|
var _a;
|
|
728
729
|
super(connection, import_wapi_client.WapiClientType.https, connection.$connect);
|
|
729
730
|
this.host = opts.host;
|
|
730
|
-
this.jwt = opts.jwt;
|
|
731
731
|
(_a = this.$connect) == null ? void 0 : _a.then(() => {
|
|
732
732
|
this._ready();
|
|
733
733
|
}).catch((err) => {
|
|
@@ -736,7 +736,7 @@ var HttpClient = class extends import_base_client.BaseClient {
|
|
|
736
736
|
}
|
|
737
737
|
_send(input) {
|
|
738
738
|
(0, import_debug.debugLog)("send()", input);
|
|
739
|
-
this._connection.send(JSON.stringify(input)
|
|
739
|
+
this._connection.send(JSON.stringify(input));
|
|
740
740
|
}
|
|
741
741
|
_ready() {
|
|
742
742
|
this._setConnected(true);
|
|
@@ -625,7 +625,7 @@ import {
|
|
|
625
625
|
import { BaseClient } from "./base-client.browser.js";
|
|
626
626
|
import { WapiClientType } from "../wapi-client.browser.js";
|
|
627
627
|
import { ConfigError } from "../lib/errors.browser.js";
|
|
628
|
-
import { getRandomHex } from "../lib/utils.browser.js";
|
|
628
|
+
import { getBasicAuth, getRandomHex } from "../lib/utils.browser.js";
|
|
629
629
|
function createHttpClient(opts, config) {
|
|
630
630
|
const initialConnection = createConnection(opts, {
|
|
631
631
|
timeout: config == null ? void 0 : config.connectingTimeout,
|
|
@@ -647,17 +647,22 @@ function createConnection(opts, connectionConfig) {
|
|
|
647
647
|
debugLog(`http_createConnection>message(body:$0)`, body);
|
|
648
648
|
});
|
|
649
649
|
}
|
|
650
|
-
function
|
|
650
|
+
function getHeaders(id) {
|
|
651
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
652
|
+
"content-type": "application/json"
|
|
653
|
+
}, id ? { [REQ_HEADER_ID]: id } : {}), (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}), "jwt" in opts ? {
|
|
654
|
+
Authorization: `Bearer ${opts.jwt}`
|
|
655
|
+
} : {}), "apikey" in opts ? {
|
|
656
|
+
Authorization: `Basic ${getBasicAuth(opts)}`
|
|
657
|
+
} : {});
|
|
658
|
+
}
|
|
659
|
+
function send(body) {
|
|
651
660
|
return __async(this, null, function* () {
|
|
652
661
|
const jsonBody = JSON.parse(body);
|
|
653
662
|
const res = yield (0, import_cross_fetch.default)(`${url}/api`, {
|
|
654
663
|
keepalive: true,
|
|
655
664
|
method: "POST",
|
|
656
|
-
headers:
|
|
657
|
-
Authorization: `Bearer ${jwt}`,
|
|
658
|
-
"content-type": "application/json",
|
|
659
|
-
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
660
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
665
|
+
headers: getHeaders(jsonBody == null ? void 0 : jsonBody.id),
|
|
661
666
|
body
|
|
662
667
|
});
|
|
663
668
|
const responseBody = yield res.json();
|
|
@@ -683,11 +688,7 @@ function createConnection(opts, connectionConfig) {
|
|
|
683
688
|
}, connectionConfig.timeout) : void 0;
|
|
684
689
|
(0, import_cross_fetch.default)(`${url}/api`, {
|
|
685
690
|
method: "POST",
|
|
686
|
-
headers:
|
|
687
|
-
Authorization: `Bearer ${opts.jwt}`,
|
|
688
|
-
"content-type": "application/json",
|
|
689
|
-
[REQ_HEADER_ID]: connectId
|
|
690
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
691
|
+
headers: getHeaders(connectId),
|
|
691
692
|
body: JSON.stringify({
|
|
692
693
|
jsonrpc: JSONRPC.version,
|
|
693
694
|
method: "authenticationCheck",
|
|
@@ -717,7 +718,6 @@ var HttpClient = class extends BaseClient {
|
|
|
717
718
|
var _a;
|
|
718
719
|
super(connection, WapiClientType.https, connection.$connect);
|
|
719
720
|
this.host = opts.host;
|
|
720
|
-
this.jwt = opts.jwt;
|
|
721
721
|
(_a = this.$connect) == null ? void 0 : _a.then(() => {
|
|
722
722
|
this._ready();
|
|
723
723
|
}).catch((err) => {
|
|
@@ -726,7 +726,7 @@ var HttpClient = class extends BaseClient {
|
|
|
726
726
|
}
|
|
727
727
|
_send(input) {
|
|
728
728
|
debugLog("send()", input);
|
|
729
|
-
this._connection.send(JSON.stringify(input)
|
|
729
|
+
this._connection.send(JSON.stringify(input));
|
|
730
730
|
}
|
|
731
731
|
_ready() {
|
|
732
732
|
this._setConnected(true);
|
package/dist/api/http-client.cjs
CHANGED
|
@@ -99,17 +99,22 @@ function createConnection(opts, connectionConfig) {
|
|
|
99
99
|
(0, import_debug.debugLog)(`http_createConnection>message(body:$0)`, body);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function getHeaders(id) {
|
|
103
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
104
|
+
"content-type": "application/json"
|
|
105
|
+
}, id ? { [REQ_HEADER_ID]: id } : {}), (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}), "jwt" in opts ? {
|
|
106
|
+
Authorization: `Bearer ${opts.jwt}`
|
|
107
|
+
} : {}), "apikey" in opts ? {
|
|
108
|
+
Authorization: `Basic ${(0, import_utils.getBasicAuth)(opts)}`
|
|
109
|
+
} : {});
|
|
110
|
+
}
|
|
111
|
+
function send(body) {
|
|
103
112
|
return __async(this, null, function* () {
|
|
104
113
|
const jsonBody = JSON.parse(body);
|
|
105
114
|
const res = yield (0, import_cross_fetch.default)(`${url}/api`, {
|
|
106
115
|
keepalive: true,
|
|
107
116
|
method: "POST",
|
|
108
|
-
headers:
|
|
109
|
-
Authorization: `Bearer ${jwt}`,
|
|
110
|
-
"content-type": "application/json",
|
|
111
|
-
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
112
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
117
|
+
headers: getHeaders(jsonBody == null ? void 0 : jsonBody.id),
|
|
113
118
|
body
|
|
114
119
|
});
|
|
115
120
|
const responseBody = yield res.json();
|
|
@@ -135,11 +140,7 @@ function createConnection(opts, connectionConfig) {
|
|
|
135
140
|
}, connectionConfig.timeout) : void 0;
|
|
136
141
|
(0, import_cross_fetch.default)(`${url}/api`, {
|
|
137
142
|
method: "POST",
|
|
138
|
-
headers:
|
|
139
|
-
Authorization: `Bearer ${opts.jwt}`,
|
|
140
|
-
"content-type": "application/json",
|
|
141
|
-
[REQ_HEADER_ID]: connectId
|
|
142
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
143
|
+
headers: getHeaders(connectId),
|
|
143
144
|
body: JSON.stringify({
|
|
144
145
|
jsonrpc: import_jsonrpc_enums.JSONRPC.version,
|
|
145
146
|
method: "authenticationCheck",
|
|
@@ -169,7 +170,6 @@ var HttpClient = class extends import_base_client.BaseClient {
|
|
|
169
170
|
var _a;
|
|
170
171
|
super(connection, import_wapi_client.WapiClientType.https, connection.$connect);
|
|
171
172
|
this.host = opts.host;
|
|
172
|
-
this.jwt = opts.jwt;
|
|
173
173
|
(_a = this.$connect) == null ? void 0 : _a.then(() => {
|
|
174
174
|
this._ready();
|
|
175
175
|
}).catch((err) => {
|
|
@@ -178,7 +178,7 @@ var HttpClient = class extends import_base_client.BaseClient {
|
|
|
178
178
|
}
|
|
179
179
|
_send(input) {
|
|
180
180
|
(0, import_debug.debugLog)("send()", input);
|
|
181
|
-
this._connection.send(JSON.stringify(input)
|
|
181
|
+
this._connection.send(JSON.stringify(input));
|
|
182
182
|
}
|
|
183
183
|
_ready() {
|
|
184
184
|
this._setConnected(true);
|
package/dist/api/http-client.js
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
import { BaseClient } from "./base-client.js";
|
|
48
48
|
import { WapiClientType } from "../wapi-client.js";
|
|
49
49
|
import { ConfigError } from "../lib/errors.js";
|
|
50
|
-
import { getRandomHex } from "../lib/utils.js";
|
|
50
|
+
import { getBasicAuth, getRandomHex } from "../lib/utils.js";
|
|
51
51
|
function createHttpClient(opts, config) {
|
|
52
52
|
const initialConnection = createConnection(opts, {
|
|
53
53
|
timeout: config == null ? void 0 : config.connectingTimeout,
|
|
@@ -69,17 +69,22 @@ function createConnection(opts, connectionConfig) {
|
|
|
69
69
|
debugLog(`http_createConnection>message(body:$0)`, body);
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function getHeaders(id) {
|
|
73
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
74
|
+
"content-type": "application/json"
|
|
75
|
+
}, id ? { [REQ_HEADER_ID]: id } : {}), (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}), "jwt" in opts ? {
|
|
76
|
+
Authorization: `Bearer ${opts.jwt}`
|
|
77
|
+
} : {}), "apikey" in opts ? {
|
|
78
|
+
Authorization: `Basic ${getBasicAuth(opts)}`
|
|
79
|
+
} : {});
|
|
80
|
+
}
|
|
81
|
+
function send(body) {
|
|
73
82
|
return __async(this, null, function* () {
|
|
74
83
|
const jsonBody = JSON.parse(body);
|
|
75
84
|
const res = yield fetch(`${url}/api`, {
|
|
76
85
|
keepalive: true,
|
|
77
86
|
method: "POST",
|
|
78
|
-
headers:
|
|
79
|
-
Authorization: `Bearer ${jwt}`,
|
|
80
|
-
"content-type": "application/json",
|
|
81
|
-
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
82
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
87
|
+
headers: getHeaders(jsonBody == null ? void 0 : jsonBody.id),
|
|
83
88
|
body
|
|
84
89
|
});
|
|
85
90
|
const responseBody = yield res.json();
|
|
@@ -105,11 +110,7 @@ function createConnection(opts, connectionConfig) {
|
|
|
105
110
|
}, connectionConfig.timeout) : void 0;
|
|
106
111
|
fetch(`${url}/api`, {
|
|
107
112
|
method: "POST",
|
|
108
|
-
headers:
|
|
109
|
-
Authorization: `Bearer ${opts.jwt}`,
|
|
110
|
-
"content-type": "application/json",
|
|
111
|
-
[REQ_HEADER_ID]: connectId
|
|
112
|
-
}, (connectionConfig == null ? void 0 : connectionConfig.connectionName) ? { [REQ_CONN_NAME]: connectionConfig == null ? void 0 : connectionConfig.connectionName } : {}),
|
|
113
|
+
headers: getHeaders(connectId),
|
|
113
114
|
body: JSON.stringify({
|
|
114
115
|
jsonrpc: JSONRPC.version,
|
|
115
116
|
method: "authenticationCheck",
|
|
@@ -139,7 +140,6 @@ var HttpClient = class extends BaseClient {
|
|
|
139
140
|
var _a;
|
|
140
141
|
super(connection, WapiClientType.https, connection.$connect);
|
|
141
142
|
this.host = opts.host;
|
|
142
|
-
this.jwt = opts.jwt;
|
|
143
143
|
(_a = this.$connect) == null ? void 0 : _a.then(() => {
|
|
144
144
|
this._ready();
|
|
145
145
|
}).catch((err) => {
|
|
@@ -148,7 +148,7 @@ var HttpClient = class extends BaseClient {
|
|
|
148
148
|
}
|
|
149
149
|
_send(input) {
|
|
150
150
|
debugLog("send()", input);
|
|
151
|
-
this._connection.send(JSON.stringify(input)
|
|
151
|
+
this._connection.send(JSON.stringify(input));
|
|
152
152
|
}
|
|
153
153
|
_ready() {
|
|
154
154
|
this._setConnected(true);
|
|
@@ -73,7 +73,8 @@ var import_wapi_client = require("../wapi-client.browser.cjs");
|
|
|
73
73
|
var import_env = require("../lib/env.browser.cjs");
|
|
74
74
|
function createWsClient(opts, config) {
|
|
75
75
|
const initialConnection = createConnection(opts, {
|
|
76
|
-
timeout: config == null ? void 0 : config.connectingTimeout
|
|
76
|
+
timeout: config == null ? void 0 : config.connectingTimeout,
|
|
77
|
+
connectionName: config == null ? void 0 : config.connectionName
|
|
77
78
|
});
|
|
78
79
|
return new WsClient(initialConnection, opts, config);
|
|
79
80
|
}
|
|
@@ -170,7 +171,6 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
170
171
|
constructor(initial, opts, config) {
|
|
171
172
|
var _a;
|
|
172
173
|
super(initial.ws, import_wapi_client.WapiClientType.ws, initial.$connect);
|
|
173
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
174
|
__publicField(this, "_pingTimeout");
|
|
175
175
|
__publicField(this, "_opts");
|
|
176
176
|
__publicField(this, "_connectionConfig");
|
|
@@ -56,7 +56,8 @@ import { WapiClientType } from "../wapi-client.browser.js";
|
|
|
56
56
|
import { CLIENT_VERSION, getEnvConfig } from "../lib/env.browser.js";
|
|
57
57
|
function createWsClient(opts, config) {
|
|
58
58
|
const initialConnection = createConnection(opts, {
|
|
59
|
-
timeout: config == null ? void 0 : config.connectingTimeout
|
|
59
|
+
timeout: config == null ? void 0 : config.connectingTimeout,
|
|
60
|
+
connectionName: config == null ? void 0 : config.connectionName
|
|
60
61
|
});
|
|
61
62
|
return new WsClient(initialConnection, opts, config);
|
|
62
63
|
}
|
|
@@ -153,7 +154,6 @@ var WsClient = class extends BaseClient {
|
|
|
153
154
|
constructor(initial, opts, config) {
|
|
154
155
|
var _a;
|
|
155
156
|
super(initial.ws, WapiClientType.ws, initial.$connect);
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
157
|
__publicField(this, "_pingTimeout");
|
|
158
158
|
__publicField(this, "_opts");
|
|
159
159
|
__publicField(this, "_connectionConfig");
|
package/dist/api/ws-client.cjs
CHANGED
|
@@ -79,7 +79,8 @@ var import_wapi_client = require("../wapi-client.cjs");
|
|
|
79
79
|
var import_env = require("../lib/env.cjs");
|
|
80
80
|
function createWsClient(opts, config) {
|
|
81
81
|
const initialConnection = createConnection(opts, {
|
|
82
|
-
timeout: config == null ? void 0 : config.connectingTimeout
|
|
82
|
+
timeout: config == null ? void 0 : config.connectingTimeout,
|
|
83
|
+
connectionName: config == null ? void 0 : config.connectionName
|
|
83
84
|
});
|
|
84
85
|
return new WsClient(initialConnection, opts, config);
|
|
85
86
|
}
|
|
@@ -176,7 +177,6 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
176
177
|
constructor(initial, opts, config) {
|
|
177
178
|
var _a;
|
|
178
179
|
super(initial.ws, import_wapi_client.WapiClientType.ws, initial.$connect);
|
|
179
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
180
180
|
__publicField(this, "_pingTimeout");
|
|
181
181
|
__publicField(this, "_opts");
|
|
182
182
|
__publicField(this, "_connectionConfig");
|
package/dist/api/ws-client.js
CHANGED
|
@@ -54,7 +54,8 @@ import { WapiClientType } from "../wapi-client.js";
|
|
|
54
54
|
import { CLIENT_VERSION, getEnvConfig } from "../lib/env.js";
|
|
55
55
|
function createWsClient(opts, config) {
|
|
56
56
|
const initialConnection = createConnection(opts, {
|
|
57
|
-
timeout: config == null ? void 0 : config.connectingTimeout
|
|
57
|
+
timeout: config == null ? void 0 : config.connectingTimeout,
|
|
58
|
+
connectionName: config == null ? void 0 : config.connectionName
|
|
58
59
|
});
|
|
59
60
|
return new WsClient(initialConnection, opts, config);
|
|
60
61
|
}
|
|
@@ -151,7 +152,6 @@ var WsClient = class extends BaseClient {
|
|
|
151
152
|
constructor(initial, opts, config) {
|
|
152
153
|
var _a;
|
|
153
154
|
super(initial.ws, WapiClientType.ws, initial.$connect);
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
155
|
__publicField(this, "_pingTimeout");
|
|
156
156
|
__publicField(this, "_opts");
|
|
157
157
|
__publicField(this, "_connectionConfig");
|
|
@@ -22,32 +22,27 @@ var client_options_schema_zod_exports = {};
|
|
|
22
22
|
__export(client_options_schema_zod_exports, {
|
|
23
23
|
clientOptionsSchema: () => clientOptionsSchema,
|
|
24
24
|
clientTypeSchema: () => clientTypeSchema,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
wsConnectionSchema: () => wsConnectionSchema
|
|
25
|
+
connectionSchema: () => connectionSchema,
|
|
26
|
+
credsConnectionSchema: () => credsConnectionSchema,
|
|
27
|
+
jwtConnectionSchema: () => jwtConnectionSchema
|
|
29
28
|
});
|
|
30
29
|
module.exports = __toCommonJS(client_options_schema_zod_exports);
|
|
31
30
|
var import_zod = require("./lib/zod.browser.cjs");
|
|
32
31
|
var clientTypeSchema = import_zod.z.enum(["ws", "https"]);
|
|
33
|
-
var
|
|
32
|
+
var credsConnectionSchema = import_zod.z.looseObject({
|
|
34
33
|
host: import_zod.z.string().describe("URL of the API"),
|
|
35
34
|
apikey: import_zod.z.string().describe("API key for the client"),
|
|
36
35
|
apisecret: import_zod.z.string().describe("API secret for the client")
|
|
37
36
|
});
|
|
38
|
-
var
|
|
39
|
-
client: import_zod.z.literal("ws"),
|
|
40
|
-
connection: wsConnectionSchema
|
|
41
|
-
});
|
|
42
|
-
var httpsConnectionSchema = import_zod.z.looseObject({
|
|
37
|
+
var jwtConnectionSchema = import_zod.z.looseObject({
|
|
43
38
|
host: import_zod.z.string().describe("URL of the API"),
|
|
44
39
|
jwt: import_zod.z.string().describe("Auth token for calling api")
|
|
45
40
|
});
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
var clientOptionsSchema = import_zod.z.discriminatedUnion("client", [
|
|
51
|
-
wsClientOptionsSchema,
|
|
52
|
-
httpsClientOptionsSchema
|
|
41
|
+
var connectionSchema = import_zod.z.union([
|
|
42
|
+
jwtConnectionSchema,
|
|
43
|
+
credsConnectionSchema
|
|
53
44
|
]);
|
|
45
|
+
var clientOptionsSchema = import_zod.z.object({
|
|
46
|
+
client: clientTypeSchema,
|
|
47
|
+
connection: connectionSchema
|
|
48
|
+
});
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
// src/client-options.schema.zod.ts
|
|
2
2
|
import { z } from "./lib/zod.browser.js";
|
|
3
3
|
var clientTypeSchema = z.enum(["ws", "https"]);
|
|
4
|
-
var
|
|
4
|
+
var credsConnectionSchema = z.looseObject({
|
|
5
5
|
host: z.string().describe("URL of the API"),
|
|
6
6
|
apikey: z.string().describe("API key for the client"),
|
|
7
7
|
apisecret: z.string().describe("API secret for the client")
|
|
8
8
|
});
|
|
9
|
-
var
|
|
10
|
-
client: z.literal("ws"),
|
|
11
|
-
connection: wsConnectionSchema
|
|
12
|
-
});
|
|
13
|
-
var httpsConnectionSchema = z.looseObject({
|
|
9
|
+
var jwtConnectionSchema = z.looseObject({
|
|
14
10
|
host: z.string().describe("URL of the API"),
|
|
15
11
|
jwt: z.string().describe("Auth token for calling api")
|
|
16
12
|
});
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
var clientOptionsSchema = z.discriminatedUnion("client", [
|
|
22
|
-
wsClientOptionsSchema,
|
|
23
|
-
httpsClientOptionsSchema
|
|
13
|
+
var connectionSchema = z.union([
|
|
14
|
+
jwtConnectionSchema,
|
|
15
|
+
credsConnectionSchema
|
|
24
16
|
]);
|
|
17
|
+
var clientOptionsSchema = z.object({
|
|
18
|
+
client: clientTypeSchema,
|
|
19
|
+
connection: connectionSchema
|
|
20
|
+
});
|
|
25
21
|
export {
|
|
26
22
|
clientOptionsSchema,
|
|
27
23
|
clientTypeSchema,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
wsConnectionSchema
|
|
24
|
+
connectionSchema,
|
|
25
|
+
credsConnectionSchema,
|
|
26
|
+
jwtConnectionSchema
|
|
32
27
|
};
|
|
@@ -22,41 +22,35 @@ var client_options_schema_zod_exports = {};
|
|
|
22
22
|
__export(client_options_schema_zod_exports, {
|
|
23
23
|
clientOptionsSchema: () => clientOptionsSchema,
|
|
24
24
|
clientTypeSchema: () => clientTypeSchema,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
wsConnectionSchema: () => wsConnectionSchema
|
|
25
|
+
connectionSchema: () => connectionSchema,
|
|
26
|
+
credsConnectionSchema: () => credsConnectionSchema,
|
|
27
|
+
jwtConnectionSchema: () => jwtConnectionSchema
|
|
29
28
|
});
|
|
30
29
|
module.exports = __toCommonJS(client_options_schema_zod_exports);
|
|
31
30
|
var import_zod = require("./lib/zod.cjs");
|
|
32
31
|
var clientTypeSchema = import_zod.z.enum(["ws", "https"]);
|
|
33
|
-
var
|
|
32
|
+
var credsConnectionSchema = import_zod.z.looseObject({
|
|
34
33
|
host: import_zod.z.string().describe("URL of the API"),
|
|
35
34
|
apikey: import_zod.z.string().describe("API key for the client"),
|
|
36
35
|
apisecret: import_zod.z.string().describe("API secret for the client")
|
|
37
36
|
});
|
|
38
|
-
var
|
|
39
|
-
client: import_zod.z.literal("ws"),
|
|
40
|
-
connection: wsConnectionSchema
|
|
41
|
-
});
|
|
42
|
-
var httpsConnectionSchema = import_zod.z.looseObject({
|
|
37
|
+
var jwtConnectionSchema = import_zod.z.looseObject({
|
|
43
38
|
host: import_zod.z.string().describe("URL of the API"),
|
|
44
39
|
jwt: import_zod.z.string().describe("Auth token for calling api")
|
|
45
40
|
});
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
var clientOptionsSchema = import_zod.z.discriminatedUnion("client", [
|
|
51
|
-
wsClientOptionsSchema,
|
|
52
|
-
httpsClientOptionsSchema
|
|
41
|
+
var connectionSchema = import_zod.z.union([
|
|
42
|
+
jwtConnectionSchema,
|
|
43
|
+
credsConnectionSchema
|
|
53
44
|
]);
|
|
45
|
+
var clientOptionsSchema = import_zod.z.object({
|
|
46
|
+
client: clientTypeSchema,
|
|
47
|
+
connection: connectionSchema
|
|
48
|
+
});
|
|
54
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
50
|
0 && (module.exports = {
|
|
56
51
|
clientOptionsSchema,
|
|
57
52
|
clientTypeSchema,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
wsConnectionSchema
|
|
53
|
+
connectionSchema,
|
|
54
|
+
credsConnectionSchema,
|
|
55
|
+
jwtConnectionSchema
|
|
62
56
|
});
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
// src/client-options.schema.zod.ts
|
|
2
2
|
import { z } from "./lib/zod.js";
|
|
3
3
|
var clientTypeSchema = z.enum(["ws", "https"]);
|
|
4
|
-
var
|
|
4
|
+
var credsConnectionSchema = z.looseObject({
|
|
5
5
|
host: z.string().describe("URL of the API"),
|
|
6
6
|
apikey: z.string().describe("API key for the client"),
|
|
7
7
|
apisecret: z.string().describe("API secret for the client")
|
|
8
8
|
});
|
|
9
|
-
var
|
|
10
|
-
client: z.literal("ws"),
|
|
11
|
-
connection: wsConnectionSchema
|
|
12
|
-
});
|
|
13
|
-
var httpsConnectionSchema = z.looseObject({
|
|
9
|
+
var jwtConnectionSchema = z.looseObject({
|
|
14
10
|
host: z.string().describe("URL of the API"),
|
|
15
11
|
jwt: z.string().describe("Auth token for calling api")
|
|
16
12
|
});
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
var clientOptionsSchema = z.discriminatedUnion("client", [
|
|
22
|
-
wsClientOptionsSchema,
|
|
23
|
-
httpsClientOptionsSchema
|
|
13
|
+
var connectionSchema = z.union([
|
|
14
|
+
jwtConnectionSchema,
|
|
15
|
+
credsConnectionSchema
|
|
24
16
|
]);
|
|
17
|
+
var clientOptionsSchema = z.object({
|
|
18
|
+
client: clientTypeSchema,
|
|
19
|
+
connection: connectionSchema
|
|
20
|
+
});
|
|
25
21
|
export {
|
|
26
22
|
clientOptionsSchema,
|
|
27
23
|
clientTypeSchema,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
wsConnectionSchema
|
|
24
|
+
connectionSchema,
|
|
25
|
+
credsConnectionSchema,
|
|
26
|
+
jwtConnectionSchema
|
|
32
27
|
};
|
package/dist/client.browser.cjs
CHANGED
|
@@ -123,7 +123,7 @@ var Client = class {
|
|
|
123
123
|
this.api = _apiClient;
|
|
124
124
|
this.$connect = _apiClient.$connect;
|
|
125
125
|
if (initialConf) {
|
|
126
|
-
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
126
|
+
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
127
127
|
sendingTimeout: initialConf.sendingTimeout
|
|
128
128
|
}), initialConf.connectingTimeout && {
|
|
129
129
|
connectingTimeout: initialConf.connectingTimeout
|
|
@@ -133,6 +133,8 @@ var Client = class {
|
|
|
133
133
|
connectionName: initialConf.connectionName
|
|
134
134
|
}), initialConf.httpSkipInitialAuthConnection && {
|
|
135
135
|
httpSkipInitialAuthConnection: initialConf.httpSkipInitialAuthConnection
|
|
136
|
+
}), initialConf.requestTimeout && {
|
|
137
|
+
requestTimeout: initialConf.requestTimeout
|
|
136
138
|
}));
|
|
137
139
|
}
|
|
138
140
|
}
|
|
@@ -190,7 +192,10 @@ var Client = class {
|
|
|
190
192
|
*
|
|
191
193
|
* wapiClient.configure({
|
|
192
194
|
* token: 'EURO',
|
|
193
|
-
*
|
|
195
|
+
* connectingTimeout: 45000,
|
|
196
|
+
* reconnectingTimeout: 45000,
|
|
197
|
+
* sendingTimeout: 10000,
|
|
198
|
+
* requestTimeout: 120000,
|
|
194
199
|
* hooks: {
|
|
195
200
|
* disconnect: () => {}
|
|
196
201
|
* },
|
|
@@ -206,7 +211,12 @@ var Client = class {
|
|
|
206
211
|
error: `Must be a string|number, '${newConf.token}' provided`
|
|
207
212
|
});
|
|
208
213
|
}
|
|
209
|
-
[
|
|
214
|
+
[
|
|
215
|
+
"sendingTimeout",
|
|
216
|
+
"connectingTimeout",
|
|
217
|
+
"reconnectingTimeout",
|
|
218
|
+
"requestTimeout"
|
|
219
|
+
].forEach((t) => {
|
|
210
220
|
if (newConf[t] && typeof newConf[t] !== "number") {
|
|
211
221
|
throw new import_errors.ConfigError("CONFIG_INVALID", {
|
|
212
222
|
field: t,
|
|
@@ -217,9 +227,12 @@ var Client = class {
|
|
|
217
227
|
const hooks = newConf.hooks;
|
|
218
228
|
delete newConf.hooks;
|
|
219
229
|
this.config = __spreadValues(__spreadValues({}, this.config), newConf);
|
|
220
|
-
if (this.config
|
|
230
|
+
if ("sendingTimeout" in this.config) {
|
|
221
231
|
this.api.sendingTimeout = this.config.sendingTimeout;
|
|
222
232
|
}
|
|
233
|
+
if ("requestTimeout" in this.config) {
|
|
234
|
+
this.api.requestTimeout = this.config.requestTimeout;
|
|
235
|
+
}
|
|
223
236
|
if (hooks) {
|
|
224
237
|
for (const [hookName, value] of Object.entries(hooks)) {
|
|
225
238
|
this.setHook(hookName, value);
|
|
@@ -2182,7 +2195,8 @@ var Client = class {
|
|
|
2182
2195
|
function createClientWithWS(opts, config) {
|
|
2183
2196
|
const wsClient = (0, import_api.createWsClient)(opts, {
|
|
2184
2197
|
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
2185
|
-
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
2198
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout,
|
|
2199
|
+
connectionName: config == null ? void 0 : config.connectionName
|
|
2186
2200
|
});
|
|
2187
2201
|
return new Client(wsClient, config);
|
|
2188
2202
|
}
|
package/dist/client.browser.js
CHANGED
|
@@ -103,7 +103,7 @@ var Client = class {
|
|
|
103
103
|
this.api = _apiClient;
|
|
104
104
|
this.$connect = _apiClient.$connect;
|
|
105
105
|
if (initialConf) {
|
|
106
|
-
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
106
|
+
this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
|
|
107
107
|
sendingTimeout: initialConf.sendingTimeout
|
|
108
108
|
}), initialConf.connectingTimeout && {
|
|
109
109
|
connectingTimeout: initialConf.connectingTimeout
|
|
@@ -113,6 +113,8 @@ var Client = class {
|
|
|
113
113
|
connectionName: initialConf.connectionName
|
|
114
114
|
}), initialConf.httpSkipInitialAuthConnection && {
|
|
115
115
|
httpSkipInitialAuthConnection: initialConf.httpSkipInitialAuthConnection
|
|
116
|
+
}), initialConf.requestTimeout && {
|
|
117
|
+
requestTimeout: initialConf.requestTimeout
|
|
116
118
|
}));
|
|
117
119
|
}
|
|
118
120
|
}
|
|
@@ -170,7 +172,10 @@ var Client = class {
|
|
|
170
172
|
*
|
|
171
173
|
* wapiClient.configure({
|
|
172
174
|
* token: 'EURO',
|
|
173
|
-
*
|
|
175
|
+
* connectingTimeout: 45000,
|
|
176
|
+
* reconnectingTimeout: 45000,
|
|
177
|
+
* sendingTimeout: 10000,
|
|
178
|
+
* requestTimeout: 120000,
|
|
174
179
|
* hooks: {
|
|
175
180
|
* disconnect: () => {}
|
|
176
181
|
* },
|
|
@@ -186,7 +191,12 @@ var Client = class {
|
|
|
186
191
|
error: `Must be a string|number, '${newConf.token}' provided`
|
|
187
192
|
});
|
|
188
193
|
}
|
|
189
|
-
[
|
|
194
|
+
[
|
|
195
|
+
"sendingTimeout",
|
|
196
|
+
"connectingTimeout",
|
|
197
|
+
"reconnectingTimeout",
|
|
198
|
+
"requestTimeout"
|
|
199
|
+
].forEach((t) => {
|
|
190
200
|
if (newConf[t] && typeof newConf[t] !== "number") {
|
|
191
201
|
throw new ConfigError("CONFIG_INVALID", {
|
|
192
202
|
field: t,
|
|
@@ -197,9 +207,12 @@ var Client = class {
|
|
|
197
207
|
const hooks = newConf.hooks;
|
|
198
208
|
delete newConf.hooks;
|
|
199
209
|
this.config = __spreadValues(__spreadValues({}, this.config), newConf);
|
|
200
|
-
if (this.config
|
|
210
|
+
if ("sendingTimeout" in this.config) {
|
|
201
211
|
this.api.sendingTimeout = this.config.sendingTimeout;
|
|
202
212
|
}
|
|
213
|
+
if ("requestTimeout" in this.config) {
|
|
214
|
+
this.api.requestTimeout = this.config.requestTimeout;
|
|
215
|
+
}
|
|
203
216
|
if (hooks) {
|
|
204
217
|
for (const [hookName, value] of Object.entries(hooks)) {
|
|
205
218
|
this.setHook(hookName, value);
|
|
@@ -2162,7 +2175,8 @@ var Client = class {
|
|
|
2162
2175
|
function createClientWithWS(opts, config) {
|
|
2163
2176
|
const wsClient = createWsClient(opts, {
|
|
2164
2177
|
connectingTimeout: config == null ? void 0 : config.connectingTimeout,
|
|
2165
|
-
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
|
|
2178
|
+
reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout,
|
|
2179
|
+
connectionName: config == null ? void 0 : config.connectionName
|
|
2166
2180
|
});
|
|
2167
2181
|
return new Client(wsClient, config);
|
|
2168
2182
|
}
|