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