@0xsequence/metadata 1.9.20 → 1.9.22
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/0xsequence-metadata.cjs.dev.js +511 -95
- package/dist/0xsequence-metadata.cjs.prod.js +511 -95
- package/dist/0xsequence-metadata.esm.js +487 -96
- package/dist/declarations/src/metadata.gen.d.ts +191 -90
- package/package.json +1 -1
- package/src/metadata.gen.ts +1110 -401
|
@@ -14,11 +14,11 @@ function _extends() {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/* eslint-disable */
|
|
17
|
-
// sequence-metadata v0.4.0
|
|
17
|
+
// sequence-metadata v0.4.0 3ae3122f8b3067b58e097c81c3c6edb3843b2ed8
|
|
18
18
|
// --
|
|
19
|
-
// Code generated by webrpc-gen@v0.
|
|
19
|
+
// Code generated by webrpc-gen@v0.18.4 with typescript@v0.13.0 generator. DO NOT EDIT.
|
|
20
20
|
//
|
|
21
|
-
// webrpc-gen -schema=metadata.ridl -target=typescript@v0.
|
|
21
|
+
// webrpc-gen -schema=metadata.ridl -target=typescript@v0.13.0 -client -out=./clients/metadata.gen.ts
|
|
22
22
|
|
|
23
23
|
// WebRPC description and code-gen version
|
|
24
24
|
const WebRPCVersion = 'v1';
|
|
@@ -27,7 +27,7 @@ const WebRPCVersion = 'v1';
|
|
|
27
27
|
const WebRPCSchemaVersion = 'v0.4.0';
|
|
28
28
|
|
|
29
29
|
// Schema hash generated from your RIDL schema
|
|
30
|
-
const WebRPCSchemaHash = '
|
|
30
|
+
const WebRPCSchemaHash = '3ae3122f8b3067b58e097c81c3c6edb3843b2ed8';
|
|
31
31
|
|
|
32
32
|
//
|
|
33
33
|
// Types
|
|
@@ -69,71 +69,99 @@ class Metadata {
|
|
|
69
69
|
this.hostname = void 0;
|
|
70
70
|
this.fetch = void 0;
|
|
71
71
|
this.path = '/rpc/Metadata/';
|
|
72
|
-
this.ping = headers => {
|
|
73
|
-
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
|
|
72
|
+
this.ping = (headers, signal) => {
|
|
73
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
74
74
|
return buildResponse(res).then(_data => {
|
|
75
75
|
return {
|
|
76
76
|
status: _data.status
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
|
+
}, error => {
|
|
80
|
+
throw WebrpcRequestFailedError.new({
|
|
81
|
+
cause: `fetch(): ${error.message || ''}`
|
|
82
|
+
});
|
|
79
83
|
});
|
|
80
84
|
};
|
|
81
|
-
this.version = headers => {
|
|
82
|
-
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
|
|
85
|
+
this.version = (headers, signal) => {
|
|
86
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
83
87
|
return buildResponse(res).then(_data => {
|
|
84
88
|
return {
|
|
85
89
|
version: _data.version
|
|
86
90
|
};
|
|
87
91
|
});
|
|
92
|
+
}, error => {
|
|
93
|
+
throw WebrpcRequestFailedError.new({
|
|
94
|
+
cause: `fetch(): ${error.message || ''}`
|
|
95
|
+
});
|
|
88
96
|
});
|
|
89
97
|
};
|
|
90
|
-
this.runtimeStatus = headers => {
|
|
91
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
|
|
98
|
+
this.runtimeStatus = (headers, signal) => {
|
|
99
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
92
100
|
return buildResponse(res).then(_data => {
|
|
93
101
|
return {
|
|
94
102
|
status: _data.status
|
|
95
103
|
};
|
|
96
104
|
});
|
|
105
|
+
}, error => {
|
|
106
|
+
throw WebrpcRequestFailedError.new({
|
|
107
|
+
cause: `fetch(): ${error.message || ''}`
|
|
108
|
+
});
|
|
97
109
|
});
|
|
98
110
|
};
|
|
99
|
-
this.getTokenMetadata = (args, headers) => {
|
|
100
|
-
return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
111
|
+
this.getTokenMetadata = (args, headers, signal) => {
|
|
112
|
+
return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
101
113
|
return buildResponse(res).then(_data => {
|
|
102
114
|
return {
|
|
103
115
|
tokenMetadata: _data.tokenMetadata
|
|
104
116
|
};
|
|
105
117
|
});
|
|
118
|
+
}, error => {
|
|
119
|
+
throw WebrpcRequestFailedError.new({
|
|
120
|
+
cause: `fetch(): ${error.message || ''}`
|
|
121
|
+
});
|
|
106
122
|
});
|
|
107
123
|
};
|
|
108
|
-
this.refreshTokenMetadata = (args, headers) => {
|
|
109
|
-
return this.fetch(this.url('RefreshTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
124
|
+
this.refreshTokenMetadata = (args, headers, signal) => {
|
|
125
|
+
return this.fetch(this.url('RefreshTokenMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
110
126
|
return buildResponse(res).then(_data => {
|
|
111
127
|
return {
|
|
112
128
|
taskId: _data.taskId
|
|
113
129
|
};
|
|
114
130
|
});
|
|
131
|
+
}, error => {
|
|
132
|
+
throw WebrpcRequestFailedError.new({
|
|
133
|
+
cause: `fetch(): ${error.message || ''}`
|
|
134
|
+
});
|
|
115
135
|
});
|
|
116
136
|
};
|
|
117
|
-
this.enqueueTokensForRefresh = (args, headers) => {
|
|
118
|
-
return this.fetch(this.url('EnqueueTokensForRefresh'), createHTTPRequest(args, headers)).then(res => {
|
|
137
|
+
this.enqueueTokensForRefresh = (args, headers, signal) => {
|
|
138
|
+
return this.fetch(this.url('EnqueueTokensForRefresh'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
119
139
|
return buildResponse(res).then(_data => {
|
|
120
140
|
return {
|
|
121
141
|
taskId: _data.taskId
|
|
122
142
|
};
|
|
123
143
|
});
|
|
144
|
+
}, error => {
|
|
145
|
+
throw WebrpcRequestFailedError.new({
|
|
146
|
+
cause: `fetch(): ${error.message || ''}`
|
|
147
|
+
});
|
|
124
148
|
});
|
|
125
149
|
};
|
|
126
|
-
this.getTokenRefreshStatus = (args, headers) => {
|
|
127
|
-
return this.fetch(this.url('GetTokenRefreshStatus'), createHTTPRequest(args, headers)).then(res => {
|
|
150
|
+
this.getTokenRefreshStatus = (args, headers, signal) => {
|
|
151
|
+
return this.fetch(this.url('GetTokenRefreshStatus'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
128
152
|
return buildResponse(res).then(_data => {
|
|
129
153
|
return {
|
|
130
154
|
status: _data.status
|
|
131
155
|
};
|
|
132
156
|
});
|
|
157
|
+
}, error => {
|
|
158
|
+
throw WebrpcRequestFailedError.new({
|
|
159
|
+
cause: `fetch(): ${error.message || ''}`
|
|
160
|
+
});
|
|
133
161
|
});
|
|
134
162
|
};
|
|
135
|
-
this.getTokenRefreshResult = (args, headers) => {
|
|
136
|
-
return this.fetch(this.url('GetTokenRefreshResult'), createHTTPRequest(args, headers)).then(res => {
|
|
163
|
+
this.getTokenRefreshResult = (args, headers, signal) => {
|
|
164
|
+
return this.fetch(this.url('GetTokenRefreshResult'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
137
165
|
return buildResponse(res).then(_data => {
|
|
138
166
|
return {
|
|
139
167
|
status: _data.status,
|
|
@@ -141,162 +169,234 @@ class Metadata {
|
|
|
141
169
|
failureReasons: _data.failureReasons
|
|
142
170
|
};
|
|
143
171
|
});
|
|
172
|
+
}, error => {
|
|
173
|
+
throw WebrpcRequestFailedError.new({
|
|
174
|
+
cause: `fetch(): ${error.message || ''}`
|
|
175
|
+
});
|
|
144
176
|
});
|
|
145
177
|
};
|
|
146
|
-
this.cancelRefreshJob = (args, headers) => {
|
|
147
|
-
return this.fetch(this.url('CancelRefreshJob'), createHTTPRequest(args, headers)).then(res => {
|
|
178
|
+
this.cancelRefreshJob = (args, headers, signal) => {
|
|
179
|
+
return this.fetch(this.url('CancelRefreshJob'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
148
180
|
return buildResponse(res).then(_data => {
|
|
149
181
|
return {
|
|
150
182
|
ok: _data.ok
|
|
151
183
|
};
|
|
152
184
|
});
|
|
185
|
+
}, error => {
|
|
186
|
+
throw WebrpcRequestFailedError.new({
|
|
187
|
+
cause: `fetch(): ${error.message || ''}`
|
|
188
|
+
});
|
|
153
189
|
});
|
|
154
190
|
};
|
|
155
|
-
this.getTokenMetadataBatch = (args, headers) => {
|
|
156
|
-
return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers)).then(res => {
|
|
191
|
+
this.getTokenMetadataBatch = (args, headers, signal) => {
|
|
192
|
+
return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
157
193
|
return buildResponse(res).then(_data => {
|
|
158
194
|
return {
|
|
159
195
|
contractTokenMetadata: _data.contractTokenMetadata
|
|
160
196
|
};
|
|
161
197
|
});
|
|
198
|
+
}, error => {
|
|
199
|
+
throw WebrpcRequestFailedError.new({
|
|
200
|
+
cause: `fetch(): ${error.message || ''}`
|
|
201
|
+
});
|
|
162
202
|
});
|
|
163
203
|
};
|
|
164
|
-
this.searchTokenMetadata = (args, headers) => {
|
|
165
|
-
return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
204
|
+
this.searchTokenMetadata = (args, headers, signal) => {
|
|
205
|
+
return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
166
206
|
return buildResponse(res).then(_data => {
|
|
167
207
|
return {
|
|
168
208
|
page: _data.page,
|
|
169
209
|
tokenMetadata: _data.tokenMetadata
|
|
170
210
|
};
|
|
171
211
|
});
|
|
212
|
+
}, error => {
|
|
213
|
+
throw WebrpcRequestFailedError.new({
|
|
214
|
+
cause: `fetch(): ${error.message || ''}`
|
|
215
|
+
});
|
|
172
216
|
});
|
|
173
217
|
};
|
|
174
|
-
this.searchTokenIDs = (args, headers) => {
|
|
175
|
-
return this.fetch(this.url('SearchTokenIDs'), createHTTPRequest(args, headers)).then(res => {
|
|
218
|
+
this.searchTokenIDs = (args, headers, signal) => {
|
|
219
|
+
return this.fetch(this.url('SearchTokenIDs'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
176
220
|
return buildResponse(res).then(_data => {
|
|
177
221
|
return {
|
|
178
222
|
page: _data.page,
|
|
179
223
|
tokenIds: _data.tokenIds
|
|
180
224
|
};
|
|
181
225
|
});
|
|
226
|
+
}, error => {
|
|
227
|
+
throw WebrpcRequestFailedError.new({
|
|
228
|
+
cause: `fetch(): ${error.message || ''}`
|
|
229
|
+
});
|
|
182
230
|
});
|
|
183
231
|
};
|
|
184
|
-
this.tokenCollectionFilters = (args, headers) => {
|
|
185
|
-
return this.fetch(this.url('TokenCollectionFilters'), createHTTPRequest(args, headers)).then(res => {
|
|
232
|
+
this.tokenCollectionFilters = (args, headers, signal) => {
|
|
233
|
+
return this.fetch(this.url('TokenCollectionFilters'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
186
234
|
return buildResponse(res).then(_data => {
|
|
187
235
|
return {
|
|
188
236
|
filters: _data.filters
|
|
189
237
|
};
|
|
190
238
|
});
|
|
239
|
+
}, error => {
|
|
240
|
+
throw WebrpcRequestFailedError.new({
|
|
241
|
+
cause: `fetch(): ${error.message || ''}`
|
|
242
|
+
});
|
|
191
243
|
});
|
|
192
244
|
};
|
|
193
|
-
this.getContractInfo = (args, headers) => {
|
|
194
|
-
return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers)).then(res => {
|
|
245
|
+
this.getContractInfo = (args, headers, signal) => {
|
|
246
|
+
return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
195
247
|
return buildResponse(res).then(_data => {
|
|
196
248
|
return {
|
|
197
249
|
contractInfo: _data.contractInfo
|
|
198
250
|
};
|
|
199
251
|
});
|
|
252
|
+
}, error => {
|
|
253
|
+
throw WebrpcRequestFailedError.new({
|
|
254
|
+
cause: `fetch(): ${error.message || ''}`
|
|
255
|
+
});
|
|
200
256
|
});
|
|
201
257
|
};
|
|
202
|
-
this.getContractInfoBatch = (args, headers) => {
|
|
203
|
-
return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
|
|
258
|
+
this.getContractInfoBatch = (args, headers, signal) => {
|
|
259
|
+
return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
204
260
|
return buildResponse(res).then(_data => {
|
|
205
261
|
return {
|
|
206
262
|
contractInfoMap: _data.contractInfoMap
|
|
207
263
|
};
|
|
208
264
|
});
|
|
265
|
+
}, error => {
|
|
266
|
+
throw WebrpcRequestFailedError.new({
|
|
267
|
+
cause: `fetch(): ${error.message || ''}`
|
|
268
|
+
});
|
|
209
269
|
});
|
|
210
270
|
};
|
|
211
|
-
this.searchContractInfo = (args, headers) => {
|
|
212
|
-
return this.fetch(this.url('SearchContractInfo'), createHTTPRequest(args, headers)).then(res => {
|
|
271
|
+
this.searchContractInfo = (args, headers, signal) => {
|
|
272
|
+
return this.fetch(this.url('SearchContractInfo'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
213
273
|
return buildResponse(res).then(_data => {
|
|
214
274
|
return {
|
|
215
275
|
contractInfoList: _data.contractInfoList
|
|
216
276
|
};
|
|
217
277
|
});
|
|
278
|
+
}, error => {
|
|
279
|
+
throw WebrpcRequestFailedError.new({
|
|
280
|
+
cause: `fetch(): ${error.message || ''}`
|
|
281
|
+
});
|
|
218
282
|
});
|
|
219
283
|
};
|
|
220
|
-
this.searchContractInfoBatch = (args, headers) => {
|
|
221
|
-
return this.fetch(this.url('SearchContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
|
|
284
|
+
this.searchContractInfoBatch = (args, headers, signal) => {
|
|
285
|
+
return this.fetch(this.url('SearchContractInfoBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
222
286
|
return buildResponse(res).then(_data => {
|
|
223
287
|
return {
|
|
224
288
|
contractInfoByChain: _data.contractInfoByChain
|
|
225
289
|
};
|
|
226
290
|
});
|
|
291
|
+
}, error => {
|
|
292
|
+
throw WebrpcRequestFailedError.new({
|
|
293
|
+
cause: `fetch(): ${error.message || ''}`
|
|
294
|
+
});
|
|
227
295
|
});
|
|
228
296
|
};
|
|
229
|
-
this.searchMetadata = (args, headers) => {
|
|
230
|
-
return this.fetch(this.url('SearchMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
297
|
+
this.searchMetadata = (args, headers, signal) => {
|
|
298
|
+
return this.fetch(this.url('SearchMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
231
299
|
return buildResponse(res).then(_data => {
|
|
232
300
|
return {
|
|
233
301
|
tokenMetadata: _data.tokenMetadata,
|
|
234
302
|
contractInfo: _data.contractInfo
|
|
235
303
|
};
|
|
236
304
|
});
|
|
305
|
+
}, error => {
|
|
306
|
+
throw WebrpcRequestFailedError.new({
|
|
307
|
+
cause: `fetch(): ${error.message || ''}`
|
|
308
|
+
});
|
|
237
309
|
});
|
|
238
310
|
};
|
|
239
|
-
this.getNiftyswapTokenQuantity = (args, headers) => {
|
|
240
|
-
return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers)).then(res => {
|
|
311
|
+
this.getNiftyswapTokenQuantity = (args, headers, signal) => {
|
|
312
|
+
return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
241
313
|
return buildResponse(res).then(_data => {
|
|
242
314
|
return {
|
|
243
315
|
quantity: _data.quantity
|
|
244
316
|
};
|
|
245
317
|
});
|
|
318
|
+
}, error => {
|
|
319
|
+
throw WebrpcRequestFailedError.new({
|
|
320
|
+
cause: `fetch(): ${error.message || ''}`
|
|
321
|
+
});
|
|
246
322
|
});
|
|
247
323
|
};
|
|
248
|
-
this.getNiftyswapUnitPrices = (args, headers) => {
|
|
249
|
-
return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers)).then(res => {
|
|
324
|
+
this.getNiftyswapUnitPrices = (args, headers, signal) => {
|
|
325
|
+
return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
250
326
|
return buildResponse(res).then(_data => {
|
|
251
327
|
return {
|
|
252
328
|
prices: _data.prices
|
|
253
329
|
};
|
|
254
330
|
});
|
|
331
|
+
}, error => {
|
|
332
|
+
throw WebrpcRequestFailedError.new({
|
|
333
|
+
cause: `fetch(): ${error.message || ''}`
|
|
334
|
+
});
|
|
255
335
|
});
|
|
256
336
|
};
|
|
257
|
-
this.getNiftyswapUnitPricesWithQuantities = (args, headers) => {
|
|
258
|
-
return this.fetch(this.url('GetNiftyswapUnitPricesWithQuantities'), createHTTPRequest(args, headers)).then(res => {
|
|
337
|
+
this.getNiftyswapUnitPricesWithQuantities = (args, headers, signal) => {
|
|
338
|
+
return this.fetch(this.url('GetNiftyswapUnitPricesWithQuantities'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
259
339
|
return buildResponse(res).then(_data => {
|
|
260
340
|
return {
|
|
261
341
|
prices: _data.prices
|
|
262
342
|
};
|
|
263
343
|
});
|
|
344
|
+
}, error => {
|
|
345
|
+
throw WebrpcRequestFailedError.new({
|
|
346
|
+
cause: `fetch(): ${error.message || ''}`
|
|
347
|
+
});
|
|
264
348
|
});
|
|
265
349
|
};
|
|
266
|
-
this.addContractToMintMonitor = (args, headers) => {
|
|
267
|
-
return this.fetch(this.url('AddContractToMintMonitor'), createHTTPRequest(args, headers)).then(res => {
|
|
350
|
+
this.addContractToMintMonitor = (args, headers, signal) => {
|
|
351
|
+
return this.fetch(this.url('AddContractToMintMonitor'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
268
352
|
return buildResponse(res).then(_data => {
|
|
269
353
|
return {
|
|
270
354
|
ok: _data.ok
|
|
271
355
|
};
|
|
272
356
|
});
|
|
357
|
+
}, error => {
|
|
358
|
+
throw WebrpcRequestFailedError.new({
|
|
359
|
+
cause: `fetch(): ${error.message || ''}`
|
|
360
|
+
});
|
|
273
361
|
});
|
|
274
362
|
};
|
|
275
|
-
this.removeContractFromMintMonitor = (args, headers) => {
|
|
276
|
-
return this.fetch(this.url('RemoveContractFromMintMonitor'), createHTTPRequest(args, headers)).then(res => {
|
|
363
|
+
this.removeContractFromMintMonitor = (args, headers, signal) => {
|
|
364
|
+
return this.fetch(this.url('RemoveContractFromMintMonitor'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
277
365
|
return buildResponse(res).then(_data => {
|
|
278
366
|
return {
|
|
279
367
|
ok: _data.ok
|
|
280
368
|
};
|
|
281
369
|
});
|
|
370
|
+
}, error => {
|
|
371
|
+
throw WebrpcRequestFailedError.new({
|
|
372
|
+
cause: `fetch(): ${error.message || ''}`
|
|
373
|
+
});
|
|
282
374
|
});
|
|
283
375
|
};
|
|
284
|
-
this.mintMonitorJobStatus = (args, headers) => {
|
|
285
|
-
return this.fetch(this.url('MintMonitorJobStatus'), createHTTPRequest(args, headers)).then(res => {
|
|
376
|
+
this.mintMonitorJobStatus = (args, headers, signal) => {
|
|
377
|
+
return this.fetch(this.url('MintMonitorJobStatus'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
286
378
|
return buildResponse(res).then(_data => {
|
|
287
379
|
return {
|
|
288
380
|
task: _data.task
|
|
289
381
|
};
|
|
290
382
|
});
|
|
383
|
+
}, error => {
|
|
384
|
+
throw WebrpcRequestFailedError.new({
|
|
385
|
+
cause: `fetch(): ${error.message || ''}`
|
|
386
|
+
});
|
|
291
387
|
});
|
|
292
388
|
};
|
|
293
|
-
this.mintMonitorTriggerJob = (args, headers) => {
|
|
294
|
-
return this.fetch(this.url('MintMonitorTriggerJob'), createHTTPRequest(args, headers)).then(res => {
|
|
389
|
+
this.mintMonitorTriggerJob = (args, headers, signal) => {
|
|
390
|
+
return this.fetch(this.url('MintMonitorTriggerJob'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
295
391
|
return buildResponse(res).then(_data => {
|
|
296
392
|
return {
|
|
297
393
|
ok: _data.ok
|
|
298
394
|
};
|
|
299
395
|
});
|
|
396
|
+
}, error => {
|
|
397
|
+
throw WebrpcRequestFailedError.new({
|
|
398
|
+
cause: `fetch(): ${error.message || ''}`
|
|
399
|
+
});
|
|
300
400
|
});
|
|
301
401
|
};
|
|
302
402
|
this.hostname = hostname;
|
|
@@ -311,152 +411,216 @@ class Collections {
|
|
|
311
411
|
this.hostname = void 0;
|
|
312
412
|
this.fetch = void 0;
|
|
313
413
|
this.path = '/rpc/Collections/';
|
|
314
|
-
this.createCollection = (args, headers) => {
|
|
315
|
-
return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
414
|
+
this.createCollection = (args, headers, signal) => {
|
|
415
|
+
return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
316
416
|
return buildResponse(res).then(_data => {
|
|
317
417
|
return {
|
|
318
418
|
collection: _data.collection
|
|
319
419
|
};
|
|
320
420
|
});
|
|
421
|
+
}, error => {
|
|
422
|
+
throw WebrpcRequestFailedError.new({
|
|
423
|
+
cause: `fetch(): ${error.message || ''}`
|
|
424
|
+
});
|
|
321
425
|
});
|
|
322
426
|
};
|
|
323
|
-
this.getCollection = (args, headers) => {
|
|
324
|
-
return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
427
|
+
this.getCollection = (args, headers, signal) => {
|
|
428
|
+
return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
325
429
|
return buildResponse(res).then(_data => {
|
|
326
430
|
return {
|
|
327
431
|
collection: _data.collection
|
|
328
432
|
};
|
|
329
433
|
});
|
|
434
|
+
}, error => {
|
|
435
|
+
throw WebrpcRequestFailedError.new({
|
|
436
|
+
cause: `fetch(): ${error.message || ''}`
|
|
437
|
+
});
|
|
330
438
|
});
|
|
331
439
|
};
|
|
332
|
-
this.listCollections = (args, headers) => {
|
|
333
|
-
return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers)).then(res => {
|
|
440
|
+
this.listCollections = (args, headers, signal) => {
|
|
441
|
+
return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
334
442
|
return buildResponse(res).then(_data => {
|
|
335
443
|
return {
|
|
336
444
|
page: _data.page,
|
|
337
445
|
collections: _data.collections
|
|
338
446
|
};
|
|
339
447
|
});
|
|
448
|
+
}, error => {
|
|
449
|
+
throw WebrpcRequestFailedError.new({
|
|
450
|
+
cause: `fetch(): ${error.message || ''}`
|
|
451
|
+
});
|
|
340
452
|
});
|
|
341
453
|
};
|
|
342
|
-
this.updateCollection = (args, headers) => {
|
|
343
|
-
return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
454
|
+
this.updateCollection = (args, headers, signal) => {
|
|
455
|
+
return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
344
456
|
return buildResponse(res).then(_data => {
|
|
345
457
|
return {
|
|
346
458
|
collection: _data.collection
|
|
347
459
|
};
|
|
348
460
|
});
|
|
461
|
+
}, error => {
|
|
462
|
+
throw WebrpcRequestFailedError.new({
|
|
463
|
+
cause: `fetch(): ${error.message || ''}`
|
|
464
|
+
});
|
|
349
465
|
});
|
|
350
466
|
};
|
|
351
|
-
this.deleteCollection = (args, headers) => {
|
|
352
|
-
return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
467
|
+
this.deleteCollection = (args, headers, signal) => {
|
|
468
|
+
return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
353
469
|
return buildResponse(res).then(_data => {
|
|
354
470
|
return {
|
|
355
471
|
status: _data.status
|
|
356
472
|
};
|
|
357
473
|
});
|
|
474
|
+
}, error => {
|
|
475
|
+
throw WebrpcRequestFailedError.new({
|
|
476
|
+
cause: `fetch(): ${error.message || ''}`
|
|
477
|
+
});
|
|
358
478
|
});
|
|
359
479
|
};
|
|
360
|
-
this.publishCollection = (args, headers) => {
|
|
361
|
-
return this.fetch(this.url('PublishCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
480
|
+
this.publishCollection = (args, headers, signal) => {
|
|
481
|
+
return this.fetch(this.url('PublishCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
362
482
|
return buildResponse(res).then(_data => {
|
|
363
483
|
return {
|
|
364
484
|
collection: _data.collection
|
|
365
485
|
};
|
|
366
486
|
});
|
|
487
|
+
}, error => {
|
|
488
|
+
throw WebrpcRequestFailedError.new({
|
|
489
|
+
cause: `fetch(): ${error.message || ''}`
|
|
490
|
+
});
|
|
367
491
|
});
|
|
368
492
|
};
|
|
369
|
-
this.unpublishCollection = (args, headers) => {
|
|
370
|
-
return this.fetch(this.url('UnpublishCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
493
|
+
this.unpublishCollection = (args, headers, signal) => {
|
|
494
|
+
return this.fetch(this.url('UnpublishCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
371
495
|
return buildResponse(res).then(_data => {
|
|
372
496
|
return {
|
|
373
497
|
collection: _data.collection
|
|
374
498
|
};
|
|
375
499
|
});
|
|
500
|
+
}, error => {
|
|
501
|
+
throw WebrpcRequestFailedError.new({
|
|
502
|
+
cause: `fetch(): ${error.message || ''}`
|
|
503
|
+
});
|
|
376
504
|
});
|
|
377
505
|
};
|
|
378
|
-
this.createToken = (args, headers) => {
|
|
379
|
-
return this.fetch(this.url('CreateToken'), createHTTPRequest(args, headers)).then(res => {
|
|
506
|
+
this.createToken = (args, headers, signal) => {
|
|
507
|
+
return this.fetch(this.url('CreateToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
380
508
|
return buildResponse(res).then(_data => {
|
|
381
509
|
return {
|
|
382
510
|
token: _data.token,
|
|
383
511
|
assets: _data.assets
|
|
384
512
|
};
|
|
385
513
|
});
|
|
514
|
+
}, error => {
|
|
515
|
+
throw WebrpcRequestFailedError.new({
|
|
516
|
+
cause: `fetch(): ${error.message || ''}`
|
|
517
|
+
});
|
|
386
518
|
});
|
|
387
519
|
};
|
|
388
|
-
this.getToken = (args, headers) => {
|
|
389
|
-
return this.fetch(this.url('GetToken'), createHTTPRequest(args, headers)).then(res => {
|
|
520
|
+
this.getToken = (args, headers, signal) => {
|
|
521
|
+
return this.fetch(this.url('GetToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
390
522
|
return buildResponse(res).then(_data => {
|
|
391
523
|
return {
|
|
392
524
|
token: _data.token,
|
|
393
525
|
assets: _data.assets
|
|
394
526
|
};
|
|
395
527
|
});
|
|
528
|
+
}, error => {
|
|
529
|
+
throw WebrpcRequestFailedError.new({
|
|
530
|
+
cause: `fetch(): ${error.message || ''}`
|
|
531
|
+
});
|
|
396
532
|
});
|
|
397
533
|
};
|
|
398
|
-
this.listTokens = (args, headers) => {
|
|
399
|
-
return this.fetch(this.url('ListTokens'), createHTTPRequest(args, headers)).then(res => {
|
|
534
|
+
this.listTokens = (args, headers, signal) => {
|
|
535
|
+
return this.fetch(this.url('ListTokens'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
400
536
|
return buildResponse(res).then(_data => {
|
|
401
537
|
return {
|
|
402
538
|
page: _data.page,
|
|
403
539
|
tokens: _data.tokens
|
|
404
540
|
};
|
|
405
541
|
});
|
|
542
|
+
}, error => {
|
|
543
|
+
throw WebrpcRequestFailedError.new({
|
|
544
|
+
cause: `fetch(): ${error.message || ''}`
|
|
545
|
+
});
|
|
406
546
|
});
|
|
407
547
|
};
|
|
408
|
-
this.updateToken = (args, headers) => {
|
|
409
|
-
return this.fetch(this.url('UpdateToken'), createHTTPRequest(args, headers)).then(res => {
|
|
548
|
+
this.updateToken = (args, headers, signal) => {
|
|
549
|
+
return this.fetch(this.url('UpdateToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
410
550
|
return buildResponse(res).then(_data => {
|
|
411
551
|
return {
|
|
412
552
|
token: _data.token
|
|
413
553
|
};
|
|
414
554
|
});
|
|
555
|
+
}, error => {
|
|
556
|
+
throw WebrpcRequestFailedError.new({
|
|
557
|
+
cause: `fetch(): ${error.message || ''}`
|
|
558
|
+
});
|
|
415
559
|
});
|
|
416
560
|
};
|
|
417
|
-
this.deleteToken = (args, headers) => {
|
|
418
|
-
return this.fetch(this.url('DeleteToken'), createHTTPRequest(args, headers)).then(res => {
|
|
561
|
+
this.deleteToken = (args, headers, signal) => {
|
|
562
|
+
return this.fetch(this.url('DeleteToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
419
563
|
return buildResponse(res).then(_data => {
|
|
420
564
|
return {
|
|
421
565
|
status: _data.status
|
|
422
566
|
};
|
|
423
567
|
});
|
|
568
|
+
}, error => {
|
|
569
|
+
throw WebrpcRequestFailedError.new({
|
|
570
|
+
cause: `fetch(): ${error.message || ''}`
|
|
571
|
+
});
|
|
424
572
|
});
|
|
425
573
|
};
|
|
426
|
-
this.createAsset = (args, headers) => {
|
|
427
|
-
return this.fetch(this.url('CreateAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
574
|
+
this.createAsset = (args, headers, signal) => {
|
|
575
|
+
return this.fetch(this.url('CreateAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
428
576
|
return buildResponse(res).then(_data => {
|
|
429
577
|
return {
|
|
430
578
|
asset: _data.asset
|
|
431
579
|
};
|
|
432
580
|
});
|
|
581
|
+
}, error => {
|
|
582
|
+
throw WebrpcRequestFailedError.new({
|
|
583
|
+
cause: `fetch(): ${error.message || ''}`
|
|
584
|
+
});
|
|
433
585
|
});
|
|
434
586
|
};
|
|
435
|
-
this.getAsset = (args, headers) => {
|
|
436
|
-
return this.fetch(this.url('GetAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
587
|
+
this.getAsset = (args, headers, signal) => {
|
|
588
|
+
return this.fetch(this.url('GetAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
437
589
|
return buildResponse(res).then(_data => {
|
|
438
590
|
return {
|
|
439
591
|
asset: _data.asset
|
|
440
592
|
};
|
|
441
593
|
});
|
|
594
|
+
}, error => {
|
|
595
|
+
throw WebrpcRequestFailedError.new({
|
|
596
|
+
cause: `fetch(): ${error.message || ''}`
|
|
597
|
+
});
|
|
442
598
|
});
|
|
443
599
|
};
|
|
444
|
-
this.updateAsset = (args, headers) => {
|
|
445
|
-
return this.fetch(this.url('UpdateAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
600
|
+
this.updateAsset = (args, headers, signal) => {
|
|
601
|
+
return this.fetch(this.url('UpdateAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
446
602
|
return buildResponse(res).then(_data => {
|
|
447
603
|
return {
|
|
448
604
|
asset: _data.asset
|
|
449
605
|
};
|
|
450
606
|
});
|
|
607
|
+
}, error => {
|
|
608
|
+
throw WebrpcRequestFailedError.new({
|
|
609
|
+
cause: `fetch(): ${error.message || ''}`
|
|
610
|
+
});
|
|
451
611
|
});
|
|
452
612
|
};
|
|
453
|
-
this.deleteAsset = (args, headers) => {
|
|
454
|
-
return this.fetch(this.url('DeleteAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
613
|
+
this.deleteAsset = (args, headers, signal) => {
|
|
614
|
+
return this.fetch(this.url('DeleteAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
455
615
|
return buildResponse(res).then(_data => {
|
|
456
616
|
return {
|
|
457
617
|
status: _data.status
|
|
458
618
|
};
|
|
459
619
|
});
|
|
620
|
+
}, error => {
|
|
621
|
+
throw WebrpcRequestFailedError.new({
|
|
622
|
+
cause: `fetch(): ${error.message || ''}`
|
|
623
|
+
});
|
|
460
624
|
});
|
|
461
625
|
};
|
|
462
626
|
this.hostname = hostname;
|
|
@@ -466,13 +630,14 @@ class Collections {
|
|
|
466
630
|
return this.hostname + this.path + name;
|
|
467
631
|
}
|
|
468
632
|
}
|
|
469
|
-
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
633
|
+
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
|
470
634
|
return {
|
|
471
635
|
method: 'POST',
|
|
472
636
|
headers: _extends({}, headers, {
|
|
473
637
|
'Content-Type': 'application/json'
|
|
474
638
|
}),
|
|
475
|
-
body: JSON.stringify(body || {})
|
|
639
|
+
body: JSON.stringify(body || {}),
|
|
640
|
+
signal
|
|
476
641
|
};
|
|
477
642
|
};
|
|
478
643
|
const buildResponse = res => {
|
|
@@ -480,20 +645,246 @@ const buildResponse = res => {
|
|
|
480
645
|
let data;
|
|
481
646
|
try {
|
|
482
647
|
data = JSON.parse(text);
|
|
483
|
-
} catch (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
648
|
+
} catch (error) {
|
|
649
|
+
let message = '';
|
|
650
|
+
if (error instanceof Error) {
|
|
651
|
+
message = error.message;
|
|
652
|
+
}
|
|
653
|
+
throw WebrpcBadResponseError.new({
|
|
654
|
+
status: res.status,
|
|
655
|
+
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
656
|
+
});
|
|
489
657
|
}
|
|
490
658
|
if (!res.ok) {
|
|
491
|
-
|
|
659
|
+
const code = typeof data.code === 'number' ? data.code : 0;
|
|
660
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
492
661
|
}
|
|
493
662
|
return data;
|
|
494
663
|
});
|
|
495
664
|
};
|
|
496
665
|
|
|
666
|
+
//
|
|
667
|
+
// Errors
|
|
668
|
+
//
|
|
669
|
+
|
|
670
|
+
class WebrpcError extends Error {
|
|
671
|
+
constructor(name, code, message, status, cause) {
|
|
672
|
+
super(message);
|
|
673
|
+
this.name = void 0;
|
|
674
|
+
this.code = void 0;
|
|
675
|
+
this.message = void 0;
|
|
676
|
+
this.status = void 0;
|
|
677
|
+
this.cause = void 0;
|
|
678
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
679
|
+
this.msg = void 0;
|
|
680
|
+
this.name = name || 'WebrpcError';
|
|
681
|
+
this.code = typeof code === 'number' ? code : 0;
|
|
682
|
+
this.message = message || `endpoint error ${this.code}`;
|
|
683
|
+
this.msg = this.message;
|
|
684
|
+
this.status = typeof status === 'number' ? status : 0;
|
|
685
|
+
this.cause = cause;
|
|
686
|
+
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
687
|
+
}
|
|
688
|
+
static new(payload) {
|
|
689
|
+
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// Webrpc errors
|
|
694
|
+
|
|
695
|
+
class WebrpcEndpointError extends WebrpcError {
|
|
696
|
+
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) {
|
|
697
|
+
super(name, code, message, status, cause);
|
|
698
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
class WebrpcRequestFailedError extends WebrpcError {
|
|
702
|
+
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) {
|
|
703
|
+
super(name, code, message, status, cause);
|
|
704
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
class WebrpcBadRouteError extends WebrpcError {
|
|
708
|
+
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) {
|
|
709
|
+
super(name, code, message, status, cause);
|
|
710
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
class WebrpcBadMethodError extends WebrpcError {
|
|
714
|
+
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) {
|
|
715
|
+
super(name, code, message, status, cause);
|
|
716
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
class WebrpcBadRequestError extends WebrpcError {
|
|
720
|
+
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) {
|
|
721
|
+
super(name, code, message, status, cause);
|
|
722
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
class WebrpcBadResponseError extends WebrpcError {
|
|
726
|
+
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) {
|
|
727
|
+
super(name, code, message, status, cause);
|
|
728
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
class WebrpcServerPanicError extends WebrpcError {
|
|
732
|
+
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) {
|
|
733
|
+
super(name, code, message, status, cause);
|
|
734
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
class WebrpcInternalErrorError extends WebrpcError {
|
|
738
|
+
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) {
|
|
739
|
+
super(name, code, message, status, cause);
|
|
740
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
class WebrpcClientDisconnectedError extends WebrpcError {
|
|
744
|
+
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) {
|
|
745
|
+
super(name, code, message, status, cause);
|
|
746
|
+
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
class WebrpcStreamLostError extends WebrpcError {
|
|
750
|
+
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) {
|
|
751
|
+
super(name, code, message, status, cause);
|
|
752
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
class WebrpcStreamFinishedError extends WebrpcError {
|
|
756
|
+
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) {
|
|
757
|
+
super(name, code, message, status, cause);
|
|
758
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// Schema errors
|
|
763
|
+
|
|
764
|
+
class UnauthorizedError extends WebrpcError {
|
|
765
|
+
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) {
|
|
766
|
+
super(name, code, message, status, cause);
|
|
767
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
class PermissionDeniedError extends WebrpcError {
|
|
771
|
+
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) {
|
|
772
|
+
super(name, code, message, status, cause);
|
|
773
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
class SessionExpiredError extends WebrpcError {
|
|
777
|
+
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) {
|
|
778
|
+
super(name, code, message, status, cause);
|
|
779
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
class MethodNotFoundError extends WebrpcError {
|
|
783
|
+
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) {
|
|
784
|
+
super(name, code, message, status, cause);
|
|
785
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
class RequestConflictError extends WebrpcError {
|
|
789
|
+
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
|
790
|
+
super(name, code, message, status, cause);
|
|
791
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
class FailError extends WebrpcError {
|
|
795
|
+
constructor(name = 'Fail', code = 1005, message = 'Request Failed', status = 0, cause) {
|
|
796
|
+
super(name, code, message, status, cause);
|
|
797
|
+
Object.setPrototypeOf(this, FailError.prototype);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
class TimeoutError extends WebrpcError {
|
|
801
|
+
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) {
|
|
802
|
+
super(name, code, message, status, cause);
|
|
803
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
class InvalidArgumentError extends WebrpcError {
|
|
807
|
+
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
808
|
+
super(name, code, message, status, cause);
|
|
809
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
class RequiredArgumentError extends WebrpcError {
|
|
813
|
+
constructor(name = 'RequiredArgument', code = 2002, message = 'Required argument missing', status = 0, cause) {
|
|
814
|
+
super(name, code, message, status, cause);
|
|
815
|
+
Object.setPrototypeOf(this, RequiredArgumentError.prototype);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
class NotFoundError extends WebrpcError {
|
|
819
|
+
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) {
|
|
820
|
+
super(name, code, message, status, cause);
|
|
821
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
class ProjectNotFoundError extends WebrpcError {
|
|
825
|
+
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) {
|
|
826
|
+
super(name, code, message, status, cause);
|
|
827
|
+
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
class ChainNotFoundError extends WebrpcError {
|
|
831
|
+
constructor(name = 'ChainNotFound', code = 3003, message = 'Chain not found', status = 0, cause) {
|
|
832
|
+
super(name, code, message, status, cause);
|
|
833
|
+
Object.setPrototypeOf(this, ChainNotFoundError.prototype);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
let errors = /*#__PURE__*/function (errors) {
|
|
837
|
+
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
838
|
+
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
839
|
+
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
840
|
+
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
841
|
+
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
842
|
+
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
843
|
+
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
844
|
+
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
845
|
+
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
|
846
|
+
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
847
|
+
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
848
|
+
errors["Unauthorized"] = "Unauthorized";
|
|
849
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
|
850
|
+
errors["SessionExpired"] = "SessionExpired";
|
|
851
|
+
errors["MethodNotFound"] = "MethodNotFound";
|
|
852
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
853
|
+
errors["Fail"] = "Fail";
|
|
854
|
+
errors["Timeout"] = "Timeout";
|
|
855
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
|
856
|
+
errors["RequiredArgument"] = "RequiredArgument";
|
|
857
|
+
errors["NotFound"] = "NotFound";
|
|
858
|
+
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
859
|
+
errors["ChainNotFound"] = "ChainNotFound";
|
|
860
|
+
return errors;
|
|
861
|
+
}({});
|
|
862
|
+
const webrpcErrorByCode = {
|
|
863
|
+
[0]: WebrpcEndpointError,
|
|
864
|
+
[-1]: WebrpcRequestFailedError,
|
|
865
|
+
[-2]: WebrpcBadRouteError,
|
|
866
|
+
[-3]: WebrpcBadMethodError,
|
|
867
|
+
[-4]: WebrpcBadRequestError,
|
|
868
|
+
[-5]: WebrpcBadResponseError,
|
|
869
|
+
[-6]: WebrpcServerPanicError,
|
|
870
|
+
[-7]: WebrpcInternalErrorError,
|
|
871
|
+
[-8]: WebrpcClientDisconnectedError,
|
|
872
|
+
[-9]: WebrpcStreamLostError,
|
|
873
|
+
[-10]: WebrpcStreamFinishedError,
|
|
874
|
+
[1000]: UnauthorizedError,
|
|
875
|
+
[1001]: PermissionDeniedError,
|
|
876
|
+
[1002]: SessionExpiredError,
|
|
877
|
+
[1003]: MethodNotFoundError,
|
|
878
|
+
[1004]: RequestConflictError,
|
|
879
|
+
[1005]: FailError,
|
|
880
|
+
[2000]: TimeoutError,
|
|
881
|
+
[2001]: InvalidArgumentError,
|
|
882
|
+
[2002]: RequiredArgumentError,
|
|
883
|
+
[3000]: NotFoundError,
|
|
884
|
+
[3002]: ProjectNotFoundError,
|
|
885
|
+
[3003]: ChainNotFoundError
|
|
886
|
+
};
|
|
887
|
+
|
|
497
888
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch;
|
|
498
889
|
class SequenceMetadata extends Metadata {
|
|
499
890
|
constructor(hostname = 'https://metadata.sequence.app', projectAccessKey, jwtAuth) {
|
|
@@ -544,4 +935,4 @@ class SequenceCollections extends Collections {
|
|
|
544
935
|
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
545
936
|
}
|
|
546
937
|
|
|
547
|
-
export { Collections, ContractType, Metadata, PropertyType, SequenceCollections, SequenceMetadata, SwapType, TaskStatus, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
|
|
938
|
+
export { ChainNotFoundError, Collections, ContractType, FailError, InvalidArgumentError, Metadata, MethodNotFoundError, NotFoundError, PermissionDeniedError, ProjectNotFoundError, PropertyType, RequestConflictError, RequiredArgumentError, SequenceCollections, SequenceMetadata, SessionExpiredError, SwapType, TaskStatus, TimeoutError, UnauthorizedError, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion, WebrpcBadMethodError, WebrpcBadRequestError, WebrpcBadResponseError, WebrpcBadRouteError, WebrpcClientDisconnectedError, WebrpcEndpointError, WebrpcError, WebrpcInternalErrorError, WebrpcRequestFailedError, WebrpcServerPanicError, WebrpcStreamFinishedError, WebrpcStreamLostError, errors };
|