@chainstream-io/sdk 0.1.9 → 0.1.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/README.md +2 -2
- package/dist/esm/index.js +74 -73
- package/dist/esm/openapi/apis/BlockchainApi.js +44 -61
- package/dist/esm/openapi/apis/DefiSolanaMoonshotApi.js +50 -67
- package/dist/esm/openapi/apis/DefiSolanaPumpfunApi.js +25 -38
- package/dist/esm/openapi/apis/DexApi.js +176 -205
- package/dist/esm/openapi/apis/DexPoolApi.js +28 -41
- package/dist/esm/openapi/apis/EndpointApi.js +175 -212
- package/dist/esm/openapi/apis/IpfsApi.js +25 -38
- package/dist/esm/openapi/apis/JobsApi.js +48 -65
- package/dist/esm/openapi/apis/RankingApi.js +249 -278
- package/dist/esm/openapi/apis/RedPacketApi.js +253 -294
- package/dist/esm/openapi/apis/TokenApi.js +1056 -1145
- package/dist/esm/openapi/apis/TradeApi.js +208 -233
- package/dist/esm/openapi/apis/TransactionApi.js +29 -42
- package/dist/esm/openapi/apis/WalletApi.js +123 -148
- package/dist/esm/openapi/apis/WatchlistApi.js +28 -41
- package/dist/esm/openapi/runtime.js +118 -119
- package/dist/esm/stream/stream.js +34 -36
- package/dist/index.js +96 -99
- package/dist/openapi/apis/BlockchainApi.js +48 -69
- package/dist/openapi/apis/DefiSolanaMoonshotApi.js +53 -74
- package/dist/openapi/apis/DefiSolanaPumpfunApi.js +28 -45
- package/dist/openapi/apis/DexApi.js +184 -217
- package/dist/openapi/apis/DexPoolApi.js +32 -49
- package/dist/openapi/apis/EndpointApi.js +179 -220
- package/dist/openapi/apis/IpfsApi.js +27 -44
- package/dist/openapi/apis/JobsApi.js +51 -72
- package/dist/openapi/apis/RankingApi.js +273 -306
- package/dist/openapi/apis/RedPacketApi.js +260 -305
- package/dist/openapi/apis/TokenApi.js +1089 -1182
- package/dist/openapi/apis/TradeApi.js +227 -256
- package/dist/openapi/apis/TransactionApi.js +32 -49
- package/dist/openapi/apis/WalletApi.js +130 -159
- package/dist/openapi/apis/WatchlistApi.js +32 -49
- package/dist/openapi/apis/index.js +15 -31
- package/dist/openapi/index.js +3 -19
- package/dist/openapi/models/BlockchainDTO.js +5 -12
- package/dist/openapi/models/BlockchainLatestBlockDTO.js +5 -12
- package/dist/openapi/models/BooleanResultDTO.js +5 -12
- package/dist/openapi/models/CalculatePnlInput.js +5 -12
- package/dist/openapi/models/Candle.js +8 -15
- package/dist/openapi/models/ClaimRedPacketInput.js +5 -12
- package/dist/openapi/models/CreateEndpointInput.js +5 -12
- package/dist/openapi/models/CreateRedPacketInput.js +5 -12
- package/dist/openapi/models/CreateRedPacketReply.js +5 -12
- package/dist/openapi/models/CreateTokenInput.js +6 -14
- package/dist/openapi/models/CreateTokenReply.js +5 -12
- package/dist/openapi/models/DexDTO.js +5 -12
- package/dist/openapi/models/DexPage.js +8 -15
- package/dist/openapi/models/DexPoolDTO.js +5 -12
- package/dist/openapi/models/EndpointListResponse.js +8 -15
- package/dist/openapi/models/EndpointOperationResponse.js +5 -12
- package/dist/openapi/models/EndpointResponse.js +5 -12
- package/dist/openapi/models/EndpointSecretResponse.js +5 -12
- package/dist/openapi/models/FilterCondition.js +6 -14
- package/dist/openapi/models/GainersAndLosersDTO.js +5 -12
- package/dist/openapi/models/GainersAndLosersPage.js +8 -15
- package/dist/openapi/models/JobDTO.js +5 -12
- package/dist/openapi/models/JobStreamingDTO.js +5 -12
- package/dist/openapi/models/Link.js +6 -14
- package/dist/openapi/models/MoonshotCreateTokenInput.js +10 -18
- package/dist/openapi/models/MoonshotCreateTokenReply.js +5 -12
- package/dist/openapi/models/MoonshotSubmitCreateToken200Response.js +5 -12
- package/dist/openapi/models/MoonshotSubmitCreateTokenInput.js +5 -12
- package/dist/openapi/models/PumpCreateTokenInput.js +7 -15
- package/dist/openapi/models/PumpCreateTokenReply.js +5 -12
- package/dist/openapi/models/QuoteResponse.js +5 -12
- package/dist/openapi/models/RedPacketClaimDTO.js +6 -14
- package/dist/openapi/models/RedPacketClaimsPage.js +8 -15
- package/dist/openapi/models/RedPacketDTO.js +6 -14
- package/dist/openapi/models/RedPacketReply.js +5 -12
- package/dist/openapi/models/RedPacketSendTxInput.js +5 -12
- package/dist/openapi/models/RedPacketSendTxResponse.js +5 -12
- package/dist/openapi/models/RedPacketsPage.js +8 -15
- package/dist/openapi/models/Resolution.js +9 -17
- package/dist/openapi/models/SendTxInput.js +6 -14
- package/dist/openapi/models/SendTxResponse.js +5 -12
- package/dist/openapi/models/SwapInput.js +7 -15
- package/dist/openapi/models/SwapReply.js +5 -12
- package/dist/openapi/models/SwapRouteInput.js +7 -15
- package/dist/openapi/models/SwapRouteResponse.js +8 -15
- package/dist/openapi/models/Token.js +23 -30
- package/dist/openapi/models/TokenCreationDTO.js +6 -14
- package/dist/openapi/models/TokenCreationPage.js +8 -15
- package/dist/openapi/models/TokenCreatorsDTO.js +5 -12
- package/dist/openapi/models/TokenExtraDTO.js +5 -12
- package/dist/openapi/models/TokenHolder.js +5 -12
- package/dist/openapi/models/TokenHolderPage.js +8 -15
- package/dist/openapi/models/TokenListPage.js +8 -15
- package/dist/openapi/models/TokenMarketData.js +5 -12
- package/dist/openapi/models/TokenMetadata.js +14 -21
- package/dist/openapi/models/TokenPage.js +8 -15
- package/dist/openapi/models/TokenPriceDTO.js +5 -12
- package/dist/openapi/models/TokenPricePage.js +8 -15
- package/dist/openapi/models/TokenSocialMediasDTO.js +5 -12
- package/dist/openapi/models/TokenStat.js +5 -12
- package/dist/openapi/models/TopTradersDTO.js +5 -12
- package/dist/openapi/models/TopTradersPage.js +8 -15
- package/dist/openapi/models/TradeDetailDTO.js +5 -12
- package/dist/openapi/models/TradeEvent.js +8 -15
- package/dist/openapi/models/TradePage.js +8 -15
- package/dist/openapi/models/TradeType.js +9 -17
- package/dist/openapi/models/UpdateEndpointInput.js +5 -12
- package/dist/openapi/models/WalletBalanceDetailDTO.js +5 -12
- package/dist/openapi/models/WalletBalancesDTO.js +8 -15
- package/dist/openapi/models/WalletPnlDTO.js +5 -12
- package/dist/openapi/models/index.js +70 -86
- package/dist/openapi/runtime.js +136 -153
- package/dist/stream/index.js +3 -19
- package/dist/stream/stream.fields.js +5 -11
- package/dist/stream/stream.js +39 -45
- package/dist/stream/stream.model.js +10 -13
- package/package.json +1 -1
|
@@ -1,88 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/* tslint:disable */
|
|
18
2
|
/* eslint-disable */
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
3
|
+
export * from './BlockchainDTO';
|
|
4
|
+
export * from './BlockchainLatestBlockDTO';
|
|
5
|
+
export * from './BooleanResultDTO';
|
|
6
|
+
export * from './CalculatePnlInput';
|
|
7
|
+
export * from './Candle';
|
|
8
|
+
export * from './ClaimRedPacketInput';
|
|
9
|
+
export * from './CreateEndpointInput';
|
|
10
|
+
export * from './CreateRedPacketInput';
|
|
11
|
+
export * from './CreateRedPacketReply';
|
|
12
|
+
export * from './CreateTokenInput';
|
|
13
|
+
export * from './CreateTokenReply';
|
|
14
|
+
export * from './DexDTO';
|
|
15
|
+
export * from './DexPage';
|
|
16
|
+
export * from './DexPoolDTO';
|
|
17
|
+
export * from './EndpointListResponse';
|
|
18
|
+
export * from './EndpointOperationResponse';
|
|
19
|
+
export * from './EndpointResponse';
|
|
20
|
+
export * from './EndpointSecretResponse';
|
|
21
|
+
export * from './FilterCondition';
|
|
22
|
+
export * from './GainersAndLosersDTO';
|
|
23
|
+
export * from './GainersAndLosersPage';
|
|
24
|
+
export * from './JobDTO';
|
|
25
|
+
export * from './JobStreamingDTO';
|
|
26
|
+
export * from './Link';
|
|
27
|
+
export * from './MoonshotCreateTokenInput';
|
|
28
|
+
export * from './MoonshotCreateTokenReply';
|
|
29
|
+
export * from './MoonshotSubmitCreateToken200Response';
|
|
30
|
+
export * from './MoonshotSubmitCreateTokenInput';
|
|
31
|
+
export * from './PumpCreateTokenInput';
|
|
32
|
+
export * from './PumpCreateTokenReply';
|
|
33
|
+
export * from './QuoteResponse';
|
|
34
|
+
export * from './RedPacketClaimDTO';
|
|
35
|
+
export * from './RedPacketClaimsPage';
|
|
36
|
+
export * from './RedPacketDTO';
|
|
37
|
+
export * from './RedPacketReply';
|
|
38
|
+
export * from './RedPacketSendTxInput';
|
|
39
|
+
export * from './RedPacketSendTxResponse';
|
|
40
|
+
export * from './RedPacketsPage';
|
|
41
|
+
export * from './Resolution';
|
|
42
|
+
export * from './SendTxInput';
|
|
43
|
+
export * from './SendTxResponse';
|
|
44
|
+
export * from './SwapInput';
|
|
45
|
+
export * from './SwapReply';
|
|
46
|
+
export * from './SwapRouteInput';
|
|
47
|
+
export * from './SwapRouteResponse';
|
|
48
|
+
export * from './Token';
|
|
49
|
+
export * from './TokenCreationDTO';
|
|
50
|
+
export * from './TokenCreationPage';
|
|
51
|
+
export * from './TokenCreatorsDTO';
|
|
52
|
+
export * from './TokenExtraDTO';
|
|
53
|
+
export * from './TokenHolder';
|
|
54
|
+
export * from './TokenHolderPage';
|
|
55
|
+
export * from './TokenListPage';
|
|
56
|
+
export * from './TokenMarketData';
|
|
57
|
+
export * from './TokenMetadata';
|
|
58
|
+
export * from './TokenPage';
|
|
59
|
+
export * from './TokenPriceDTO';
|
|
60
|
+
export * from './TokenPricePage';
|
|
61
|
+
export * from './TokenSocialMediasDTO';
|
|
62
|
+
export * from './TokenStat';
|
|
63
|
+
export * from './TopTradersDTO';
|
|
64
|
+
export * from './TopTradersPage';
|
|
65
|
+
export * from './TradeDetailDTO';
|
|
66
|
+
export * from './TradeEvent';
|
|
67
|
+
export * from './TradePage';
|
|
68
|
+
export * from './TradeType';
|
|
69
|
+
export * from './UpdateEndpointInput';
|
|
70
|
+
export * from './WalletBalanceDetailDTO';
|
|
71
|
+
export * from './WalletBalancesDTO';
|
|
72
|
+
export * from './WalletPnlDTO';
|
package/dist/openapi/runtime.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* tslint:disable */
|
|
3
2
|
/* eslint-disable */
|
|
4
3
|
/**
|
|
@@ -12,23 +11,9 @@
|
|
|
12
11
|
* https://openapi-generator.tech
|
|
13
12
|
* Do not edit the class manually.
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.DefaultConfig = exports.Configuration = exports.BASE_PATH = void 0;
|
|
26
|
-
exports.querystring = querystring;
|
|
27
|
-
exports.exists = exists;
|
|
28
|
-
exports.mapValues = mapValues;
|
|
29
|
-
exports.canConsumeForm = canConsumeForm;
|
|
30
|
-
exports.BASE_PATH = "https://api-dex.chainstream.io".replace(/\/+$/, "");
|
|
31
|
-
class Configuration {
|
|
14
|
+
export const BASE_PATH = "https://api-dex.chainstream.io".replace(/\/+$/, "");
|
|
15
|
+
export class Configuration {
|
|
16
|
+
configuration;
|
|
32
17
|
constructor(configuration = {}) {
|
|
33
18
|
this.configuration = configuration;
|
|
34
19
|
}
|
|
@@ -36,7 +21,7 @@ class Configuration {
|
|
|
36
21
|
this.configuration = configuration;
|
|
37
22
|
}
|
|
38
23
|
get basePath() {
|
|
39
|
-
return this.configuration.basePath != null ? this.configuration.basePath :
|
|
24
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
40
25
|
}
|
|
41
26
|
get fetchApi() {
|
|
42
27
|
return this.configuration.fetchApi;
|
|
@@ -63,7 +48,7 @@ class Configuration {
|
|
|
63
48
|
get accessToken() {
|
|
64
49
|
const accessToken = this.configuration.accessToken;
|
|
65
50
|
if (accessToken) {
|
|
66
|
-
return typeof accessToken === 'function' ? accessToken : () =>
|
|
51
|
+
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
|
|
67
52
|
}
|
|
68
53
|
return undefined;
|
|
69
54
|
}
|
|
@@ -74,58 +59,16 @@ class Configuration {
|
|
|
74
59
|
return this.configuration.credentials;
|
|
75
60
|
}
|
|
76
61
|
}
|
|
77
|
-
|
|
78
|
-
exports.DefaultConfig = new Configuration();
|
|
62
|
+
export const DefaultConfig = new Configuration();
|
|
79
63
|
/**
|
|
80
64
|
* This is the base class for all generated API classes.
|
|
81
65
|
*/
|
|
82
|
-
class BaseAPI {
|
|
83
|
-
|
|
66
|
+
export class BaseAPI {
|
|
67
|
+
configuration;
|
|
68
|
+
static jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
69
|
+
middleware;
|
|
70
|
+
constructor(configuration = DefaultConfig) {
|
|
84
71
|
this.configuration = configuration;
|
|
85
|
-
this.fetchApi = (url, init) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
let fetchParams = { url, init };
|
|
87
|
-
for (const middleware of this.middleware) {
|
|
88
|
-
if (middleware.pre) {
|
|
89
|
-
fetchParams = (yield middleware.pre(Object.assign({ fetch: this.fetchApi }, fetchParams))) || fetchParams;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
let response = undefined;
|
|
93
|
-
try {
|
|
94
|
-
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
95
|
-
}
|
|
96
|
-
catch (e) {
|
|
97
|
-
for (const middleware of this.middleware) {
|
|
98
|
-
if (middleware.onError) {
|
|
99
|
-
response = (yield middleware.onError({
|
|
100
|
-
fetch: this.fetchApi,
|
|
101
|
-
url: fetchParams.url,
|
|
102
|
-
init: fetchParams.init,
|
|
103
|
-
error: e,
|
|
104
|
-
response: response ? response.clone() : undefined,
|
|
105
|
-
})) || response;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (response === undefined) {
|
|
109
|
-
if (e instanceof Error) {
|
|
110
|
-
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
throw e;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (const middleware of this.middleware) {
|
|
118
|
-
if (middleware.post) {
|
|
119
|
-
response = (yield middleware.post({
|
|
120
|
-
fetch: this.fetchApi,
|
|
121
|
-
url: fetchParams.url,
|
|
122
|
-
init: fetchParams.init,
|
|
123
|
-
response: response.clone(),
|
|
124
|
-
})) || response;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return response;
|
|
128
|
-
});
|
|
129
72
|
this.middleware = configuration.middleware;
|
|
130
73
|
}
|
|
131
74
|
withMiddleware(...middlewares) {
|
|
@@ -157,56 +100,105 @@ class BaseAPI {
|
|
|
157
100
|
}
|
|
158
101
|
return BaseAPI.jsonRegex.test(mime);
|
|
159
102
|
}
|
|
160
|
-
request(context, initOverrides) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({
|
|
103
|
+
async request(context, initOverrides) {
|
|
104
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
105
|
+
const response = await this.fetchApi(url, init);
|
|
106
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
throw new ResponseError(response, 'Response returned an error code');
|
|
110
|
+
}
|
|
111
|
+
async createFetchParams(context, initOverrides) {
|
|
112
|
+
let url = this.configuration.basePath + context.path;
|
|
113
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
114
|
+
// only add the querystring to the URL if there are query parameters.
|
|
115
|
+
// this is done to avoid urls ending with a "?" character which buggy webservers
|
|
116
|
+
// do not handle correctly sometimes.
|
|
117
|
+
url += '?' + this.configuration.queryParamsStringify(context.query);
|
|
118
|
+
}
|
|
119
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
120
|
+
Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
|
|
121
|
+
const initOverrideFn = typeof initOverrides === "function"
|
|
122
|
+
? initOverrides
|
|
123
|
+
: async () => initOverrides;
|
|
124
|
+
const initParams = {
|
|
125
|
+
method: context.method,
|
|
126
|
+
headers,
|
|
127
|
+
body: context.body,
|
|
128
|
+
credentials: this.configuration.credentials,
|
|
129
|
+
};
|
|
130
|
+
const overriddenInit = {
|
|
131
|
+
...initParams,
|
|
132
|
+
...(await initOverrideFn({
|
|
191
133
|
init: initParams,
|
|
192
134
|
context,
|
|
193
|
-
}))
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
135
|
+
}))
|
|
136
|
+
};
|
|
137
|
+
let body;
|
|
138
|
+
if (isFormData(overriddenInit.body)
|
|
139
|
+
|| (overriddenInit.body instanceof URLSearchParams)
|
|
140
|
+
|| isBlob(overriddenInit.body)) {
|
|
141
|
+
body = overriddenInit.body;
|
|
142
|
+
}
|
|
143
|
+
else if (this.isJsonMime(headers['Content-Type'])) {
|
|
144
|
+
body = JSON.stringify(overriddenInit.body);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
body = overriddenInit.body;
|
|
148
|
+
}
|
|
149
|
+
const init = {
|
|
150
|
+
...overriddenInit,
|
|
151
|
+
body
|
|
152
|
+
};
|
|
153
|
+
return { url, init };
|
|
154
|
+
}
|
|
155
|
+
fetchApi = async (url, init) => {
|
|
156
|
+
let fetchParams = { url, init };
|
|
157
|
+
for (const middleware of this.middleware) {
|
|
158
|
+
if (middleware.pre) {
|
|
159
|
+
fetchParams = await middleware.pre({
|
|
160
|
+
fetch: this.fetchApi,
|
|
161
|
+
...fetchParams,
|
|
162
|
+
}) || fetchParams;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
let response = undefined;
|
|
166
|
+
try {
|
|
167
|
+
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
for (const middleware of this.middleware) {
|
|
171
|
+
if (middleware.onError) {
|
|
172
|
+
response = await middleware.onError({
|
|
173
|
+
fetch: this.fetchApi,
|
|
174
|
+
url: fetchParams.url,
|
|
175
|
+
init: fetchParams.init,
|
|
176
|
+
error: e,
|
|
177
|
+
response: response ? response.clone() : undefined,
|
|
178
|
+
}) || response;
|
|
179
|
+
}
|
|
199
180
|
}
|
|
200
|
-
|
|
201
|
-
|
|
181
|
+
if (response === undefined) {
|
|
182
|
+
if (e instanceof Error) {
|
|
183
|
+
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
throw e;
|
|
187
|
+
}
|
|
202
188
|
}
|
|
203
|
-
|
|
204
|
-
|
|
189
|
+
}
|
|
190
|
+
for (const middleware of this.middleware) {
|
|
191
|
+
if (middleware.post) {
|
|
192
|
+
response = await middleware.post({
|
|
193
|
+
fetch: this.fetchApi,
|
|
194
|
+
url: fetchParams.url,
|
|
195
|
+
init: fetchParams.init,
|
|
196
|
+
response: response.clone(),
|
|
197
|
+
}) || response;
|
|
205
198
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
199
|
+
}
|
|
200
|
+
return response;
|
|
201
|
+
};
|
|
210
202
|
/**
|
|
211
203
|
* Create a shallow clone of `this` by constructing a new instance
|
|
212
204
|
* and then shallow cloning data members.
|
|
@@ -218,8 +210,6 @@ class BaseAPI {
|
|
|
218
210
|
return next;
|
|
219
211
|
}
|
|
220
212
|
}
|
|
221
|
-
exports.BaseAPI = BaseAPI;
|
|
222
|
-
BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
223
213
|
;
|
|
224
214
|
function isBlob(value) {
|
|
225
215
|
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
@@ -227,37 +217,37 @@ function isBlob(value) {
|
|
|
227
217
|
function isFormData(value) {
|
|
228
218
|
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
229
219
|
}
|
|
230
|
-
class ResponseError extends Error {
|
|
220
|
+
export class ResponseError extends Error {
|
|
221
|
+
response;
|
|
222
|
+
name = "ResponseError";
|
|
231
223
|
constructor(response, msg) {
|
|
232
224
|
super(msg);
|
|
233
225
|
this.response = response;
|
|
234
|
-
this.name = "ResponseError";
|
|
235
226
|
}
|
|
236
227
|
}
|
|
237
|
-
|
|
238
|
-
|
|
228
|
+
export class FetchError extends Error {
|
|
229
|
+
cause;
|
|
230
|
+
name = "FetchError";
|
|
239
231
|
constructor(cause, msg) {
|
|
240
232
|
super(msg);
|
|
241
233
|
this.cause = cause;
|
|
242
|
-
this.name = "FetchError";
|
|
243
234
|
}
|
|
244
235
|
}
|
|
245
|
-
|
|
246
|
-
|
|
236
|
+
export class RequiredError extends Error {
|
|
237
|
+
field;
|
|
238
|
+
name = "RequiredError";
|
|
247
239
|
constructor(field, msg) {
|
|
248
240
|
super(msg);
|
|
249
241
|
this.field = field;
|
|
250
|
-
this.name = "RequiredError";
|
|
251
242
|
}
|
|
252
243
|
}
|
|
253
|
-
|
|
254
|
-
exports.COLLECTION_FORMATS = {
|
|
244
|
+
export const COLLECTION_FORMATS = {
|
|
255
245
|
csv: ",",
|
|
256
246
|
ssv: " ",
|
|
257
247
|
tsv: "\t",
|
|
258
248
|
pipes: "|",
|
|
259
249
|
};
|
|
260
|
-
function querystring(params, prefix = '') {
|
|
250
|
+
export function querystring(params, prefix = '') {
|
|
261
251
|
return Object.keys(params)
|
|
262
252
|
.map(key => querystringSingleKey(key, params[key], prefix))
|
|
263
253
|
.filter(part => part.length > 0)
|
|
@@ -282,18 +272,18 @@ function querystringSingleKey(key, value, keyPrefix = '') {
|
|
|
282
272
|
}
|
|
283
273
|
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
284
274
|
}
|
|
285
|
-
function exists(json, key) {
|
|
275
|
+
export function exists(json, key) {
|
|
286
276
|
const value = json[key];
|
|
287
277
|
return value !== null && value !== undefined;
|
|
288
278
|
}
|
|
289
|
-
function mapValues(data, fn) {
|
|
279
|
+
export function mapValues(data, fn) {
|
|
290
280
|
const result = {};
|
|
291
281
|
for (const key of Object.keys(data)) {
|
|
292
282
|
result[key] = fn(data[key]);
|
|
293
283
|
}
|
|
294
284
|
return result;
|
|
295
285
|
}
|
|
296
|
-
function canConsumeForm(consumes) {
|
|
286
|
+
export function canConsumeForm(consumes) {
|
|
297
287
|
for (const consume of consumes) {
|
|
298
288
|
if ('multipart/form-data' === consume.contentType) {
|
|
299
289
|
return true;
|
|
@@ -301,50 +291,43 @@ function canConsumeForm(consumes) {
|
|
|
301
291
|
}
|
|
302
292
|
return false;
|
|
303
293
|
}
|
|
304
|
-
class JSONApiResponse {
|
|
294
|
+
export class JSONApiResponse {
|
|
295
|
+
raw;
|
|
296
|
+
transformer;
|
|
305
297
|
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
306
298
|
this.raw = raw;
|
|
307
299
|
this.transformer = transformer;
|
|
308
300
|
}
|
|
309
|
-
value() {
|
|
310
|
-
return
|
|
311
|
-
return this.transformer(yield this.raw.json());
|
|
312
|
-
});
|
|
301
|
+
async value() {
|
|
302
|
+
return this.transformer(await this.raw.json());
|
|
313
303
|
}
|
|
314
304
|
}
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
export class VoidApiResponse {
|
|
306
|
+
raw;
|
|
317
307
|
constructor(raw) {
|
|
318
308
|
this.raw = raw;
|
|
319
309
|
}
|
|
320
|
-
value() {
|
|
321
|
-
return
|
|
322
|
-
return undefined;
|
|
323
|
-
});
|
|
310
|
+
async value() {
|
|
311
|
+
return undefined;
|
|
324
312
|
}
|
|
325
313
|
}
|
|
326
|
-
|
|
327
|
-
|
|
314
|
+
export class BlobApiResponse {
|
|
315
|
+
raw;
|
|
328
316
|
constructor(raw) {
|
|
329
317
|
this.raw = raw;
|
|
330
318
|
}
|
|
331
|
-
value() {
|
|
332
|
-
return
|
|
333
|
-
return yield this.raw.blob();
|
|
334
|
-
});
|
|
319
|
+
async value() {
|
|
320
|
+
return await this.raw.blob();
|
|
335
321
|
}
|
|
336
322
|
;
|
|
337
323
|
}
|
|
338
|
-
|
|
339
|
-
|
|
324
|
+
export class TextApiResponse {
|
|
325
|
+
raw;
|
|
340
326
|
constructor(raw) {
|
|
341
327
|
this.raw = raw;
|
|
342
328
|
}
|
|
343
|
-
value() {
|
|
344
|
-
return
|
|
345
|
-
return yield this.raw.text();
|
|
346
|
-
});
|
|
329
|
+
async value() {
|
|
330
|
+
return await this.raw.text();
|
|
347
331
|
}
|
|
348
332
|
;
|
|
349
333
|
}
|
|
350
|
-
exports.TextApiResponse = TextApiResponse;
|
package/dist/stream/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./stream"), exports);
|
|
18
|
-
__exportStar(require("./stream.fields"), exports);
|
|
19
|
-
__exportStar(require("./stream.model"), exports);
|
|
1
|
+
export * from './stream';
|
|
2
|
+
export * from './stream.fields';
|
|
3
|
+
export * from './stream.model';
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Field mappings for CEL filter expressions
|
|
4
3
|
* Maps human-readable field names to short field names used in the API
|
|
5
4
|
* Organized by subscription method to handle field name conflicts
|
|
6
5
|
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.CEL_FIELD_MAPPINGS = void 0;
|
|
9
|
-
exports.getFieldMappings = getFieldMappings;
|
|
10
|
-
exports.replaceFilterFields = replaceFilterFields;
|
|
11
|
-
exports.getAvailableFields = getAvailableFields;
|
|
12
6
|
/**
|
|
13
7
|
* Field mappings organized by subscription method
|
|
14
8
|
* Each method can have its own field mappings to handle conflicts
|
|
15
9
|
*/
|
|
16
|
-
|
|
10
|
+
export const CEL_FIELD_MAPPINGS = {
|
|
17
11
|
// Wallet balance subscription fields
|
|
18
12
|
"subscribeWalletBalance": {
|
|
19
13
|
"walletAddress": "a",
|
|
@@ -206,8 +200,8 @@ exports.CEL_FIELD_MAPPINGS = {
|
|
|
206
200
|
* @param methodName - The name of the subscription method
|
|
207
201
|
* @returns Field mapping object for the method, or empty object if not found
|
|
208
202
|
*/
|
|
209
|
-
function getFieldMappings(methodName) {
|
|
210
|
-
return
|
|
203
|
+
export function getFieldMappings(methodName) {
|
|
204
|
+
return CEL_FIELD_MAPPINGS[methodName] || {};
|
|
211
205
|
}
|
|
212
206
|
/**
|
|
213
207
|
* Replace long field names with short field names in a filter expression
|
|
@@ -216,7 +210,7 @@ function getFieldMappings(methodName) {
|
|
|
216
210
|
* @param methodName - The name of the subscription method
|
|
217
211
|
* @returns Filter expression with short field names and meta. prefix
|
|
218
212
|
*/
|
|
219
|
-
function replaceFilterFields(filter, methodName) {
|
|
213
|
+
export function replaceFilterFields(filter, methodName) {
|
|
220
214
|
if (!filter) {
|
|
221
215
|
return filter;
|
|
222
216
|
}
|
|
@@ -242,7 +236,7 @@ function replaceFilterFields(filter, methodName) {
|
|
|
242
236
|
* @param methodName - The name of the subscription method
|
|
243
237
|
* @returns Array of available field names
|
|
244
238
|
*/
|
|
245
|
-
function getAvailableFields(methodName) {
|
|
239
|
+
export function getAvailableFields(methodName) {
|
|
246
240
|
const mappings = getFieldMappings(methodName);
|
|
247
241
|
return Object.keys(mappings);
|
|
248
242
|
}
|