@0xsequence/indexer 3.0.0-beta.8 → 3.0.0
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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +5 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +91 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -47
- package/dist/indexer.gen.d.ts +993 -633
- package/dist/indexer.gen.d.ts.map +1 -1
- package/dist/indexer.gen.js +885 -632
- package/dist/indexergw.gen.d.ts +686 -455
- package/dist/indexergw.gen.d.ts.map +1 -1
- package/dist/indexergw.gen.js +684 -426
- package/eslint.config.js +4 -0
- package/package.json +8 -5
- package/src/index.ts +6 -6
- package/src/indexer.gen.ts +1904 -1487
- package/src/indexergw.gen.ts +1215 -946
- package/tsconfig.json +3 -1
package/dist/indexergw.gen.js
CHANGED
|
@@ -1,67 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable */
|
|
3
|
-
// sequence-indexer v0.4.0
|
|
2
|
+
// sequence-indexer v0.4.0 212120aad9a46e88ead9a2183c5717e9902d8c2b
|
|
4
3
|
// --
|
|
5
|
-
// Code generated by
|
|
4
|
+
// Code generated by Webrpc-gen@v0.31.2 with typescript generator. DO NOT EDIT.
|
|
6
5
|
//
|
|
7
|
-
// webrpc-gen -schema=
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.errors = exports.MetadataCallFailedError = exports.NotFoundError = exports.ResourceExhaustedError = exports.QueryFailedError = void 0;
|
|
11
|
-
exports.VersionFromHeader = VersionFromHeader;
|
|
12
|
-
exports.WebrpcHeader = 'Webrpc';
|
|
13
|
-
exports.WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0';
|
|
14
|
-
// WebRPC description and code-gen version
|
|
15
|
-
exports.WebRPCVersion = 'v1';
|
|
6
|
+
// webrpc-gen -schema=merged.gen.json -service=IndexerGateway -target=typescript -client -out=./clients/indexergw.gen.ts
|
|
7
|
+
// Webrpc description and code-gen version
|
|
8
|
+
export const WebrpcVersion = 'v1';
|
|
16
9
|
// Schema version of your RIDL schema
|
|
17
|
-
|
|
10
|
+
export const WebrpcSchemaVersion = 'v0.4.0';
|
|
18
11
|
// Schema hash generated from your RIDL schema
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
codeGenVersion: '',
|
|
27
|
-
schemaName: '',
|
|
28
|
-
schemaVersion: '',
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return parseWebrpcGenVersions(headerValue);
|
|
32
|
-
}
|
|
33
|
-
function parseWebrpcGenVersions(header) {
|
|
34
|
-
const versions = header.split(';');
|
|
35
|
-
if (versions.length < 3) {
|
|
36
|
-
return {
|
|
37
|
-
webrpcGenVersion: '',
|
|
38
|
-
codeGenName: '',
|
|
39
|
-
codeGenVersion: '',
|
|
40
|
-
schemaName: '',
|
|
41
|
-
schemaVersion: '',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const [_, webrpcGenVersion] = versions[0].split('@');
|
|
45
|
-
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
46
|
-
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
47
|
-
return {
|
|
48
|
-
webrpcGenVersion: webrpcGenVersion,
|
|
49
|
-
codeGenName: codeGenName,
|
|
50
|
-
codeGenVersion: codeGenVersion,
|
|
51
|
-
schemaName: schemaName,
|
|
52
|
-
schemaVersion: schemaVersion,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//
|
|
56
|
-
// Types
|
|
57
|
-
//
|
|
58
|
-
var ResourceStatus;
|
|
59
|
-
(function (ResourceStatus) {
|
|
60
|
-
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
61
|
-
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
62
|
-
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
63
|
-
})(ResourceStatus || (exports.ResourceStatus = ResourceStatus = {}));
|
|
64
|
-
var ContractType;
|
|
12
|
+
export const WebrpcSchemaHash = '212120aad9a46e88ead9a2183c5717e9902d8c2b';
|
|
13
|
+
export var BackupMode;
|
|
14
|
+
(function (BackupMode) {
|
|
15
|
+
BackupMode["INCREMENTAL"] = "INCREMENTAL";
|
|
16
|
+
BackupMode["COMPLETE"] = "COMPLETE";
|
|
17
|
+
})(BackupMode || (BackupMode = {}));
|
|
18
|
+
export var ContractType;
|
|
65
19
|
(function (ContractType) {
|
|
66
20
|
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
67
21
|
ContractType["NATIVE"] = "NATIVE";
|
|
@@ -73,58 +27,71 @@ var ContractType;
|
|
|
73
27
|
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
|
|
74
28
|
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
|
|
75
29
|
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE";
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
30
|
+
ContractType["ERC6909"] = "ERC6909";
|
|
31
|
+
})(ContractType || (ContractType = {}));
|
|
32
|
+
export var ContractVerificationStatus;
|
|
33
|
+
(function (ContractVerificationStatus) {
|
|
34
|
+
ContractVerificationStatus["VERIFIED"] = "VERIFIED";
|
|
35
|
+
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED";
|
|
36
|
+
ContractVerificationStatus["ALL"] = "ALL";
|
|
37
|
+
})(ContractVerificationStatus || (ContractVerificationStatus = {}));
|
|
38
|
+
export var EventLogDataType;
|
|
84
39
|
(function (EventLogDataType) {
|
|
85
40
|
EventLogDataType["EVENT"] = "EVENT";
|
|
86
41
|
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
|
|
87
42
|
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER";
|
|
88
43
|
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
|
|
89
|
-
})(EventLogDataType || (
|
|
90
|
-
var
|
|
44
|
+
})(EventLogDataType || (EventLogDataType = {}));
|
|
45
|
+
export var EventLogType;
|
|
46
|
+
(function (EventLogType) {
|
|
47
|
+
EventLogType["UNKNOWN"] = "UNKNOWN";
|
|
48
|
+
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
|
|
49
|
+
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
|
|
50
|
+
})(EventLogType || (EventLogType = {}));
|
|
51
|
+
export var NetworkType;
|
|
52
|
+
(function (NetworkType) {
|
|
53
|
+
NetworkType["MAINNETS"] = "MAINNETS";
|
|
54
|
+
NetworkType["TESTNETS"] = "TESTNETS";
|
|
55
|
+
NetworkType["ALL"] = "ALL";
|
|
56
|
+
})(NetworkType || (NetworkType = {}));
|
|
57
|
+
export var OrderStatus;
|
|
91
58
|
(function (OrderStatus) {
|
|
92
59
|
OrderStatus["OPEN"] = "OPEN";
|
|
93
60
|
OrderStatus["CLOSED"] = "CLOSED";
|
|
94
61
|
OrderStatus["CANCELLED"] = "CANCELLED";
|
|
95
|
-
})(OrderStatus || (
|
|
96
|
-
var
|
|
97
|
-
(function (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
})(
|
|
102
|
-
var
|
|
62
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
63
|
+
export var ResourceStatus;
|
|
64
|
+
(function (ResourceStatus) {
|
|
65
|
+
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
66
|
+
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
67
|
+
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
68
|
+
})(ResourceStatus || (ResourceStatus = {}));
|
|
69
|
+
export var SortOrder;
|
|
70
|
+
(function (SortOrder) {
|
|
71
|
+
SortOrder["DESC"] = "DESC";
|
|
72
|
+
SortOrder["ASC"] = "ASC";
|
|
73
|
+
})(SortOrder || (SortOrder = {}));
|
|
74
|
+
export var TransactionStatus;
|
|
103
75
|
(function (TransactionStatus) {
|
|
104
76
|
TransactionStatus["FAILED"] = "FAILED";
|
|
105
77
|
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
106
|
-
})(TransactionStatus || (
|
|
107
|
-
var TransactionType;
|
|
78
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
79
|
+
export var TransactionType;
|
|
108
80
|
(function (TransactionType) {
|
|
109
81
|
TransactionType["LegacyTxnType"] = "LegacyTxnType";
|
|
110
82
|
TransactionType["AccessListTxnType"] = "AccessListTxnType";
|
|
111
83
|
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType";
|
|
112
|
-
})(TransactionType || (
|
|
113
|
-
var
|
|
114
|
-
(function (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
(function (ContractVerificationStatus) {
|
|
120
|
-
ContractVerificationStatus["VERIFIED"] = "VERIFIED";
|
|
121
|
-
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED";
|
|
122
|
-
ContractVerificationStatus["ALL"] = "ALL";
|
|
123
|
-
})(ContractVerificationStatus || (exports.ContractVerificationStatus = ContractVerificationStatus = {}));
|
|
84
|
+
})(TransactionType || (TransactionType = {}));
|
|
85
|
+
export var TxnTransferType;
|
|
86
|
+
(function (TxnTransferType) {
|
|
87
|
+
TxnTransferType["UNKNOWN"] = "UNKNOWN";
|
|
88
|
+
TxnTransferType["SEND"] = "SEND";
|
|
89
|
+
TxnTransferType["RECEIVE"] = "RECEIVE";
|
|
90
|
+
})(TxnTransferType || (TxnTransferType = {}));
|
|
124
91
|
//
|
|
125
92
|
// Client
|
|
126
93
|
//
|
|
127
|
-
class IndexerGateway {
|
|
94
|
+
export class IndexerGateway {
|
|
128
95
|
hostname;
|
|
129
96
|
fetch;
|
|
130
97
|
path = '/rpc/IndexerGateway/';
|
|
@@ -135,138 +102,157 @@ class IndexerGateway {
|
|
|
135
102
|
url(name) {
|
|
136
103
|
return this.hostname + this.path + name;
|
|
137
104
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
105
|
+
queryKey = {
|
|
106
|
+
getBalanceUpdates: (req) => ['IndexerGateway', 'getBalanceUpdates', req],
|
|
107
|
+
getChains: (req) => ['IndexerGateway', 'getChains', req],
|
|
108
|
+
getNativeTokenBalance: (req) => ['IndexerGateway', 'getNativeTokenBalance', req],
|
|
109
|
+
getTokenBalances: (req) => ['IndexerGateway', 'getTokenBalances', req],
|
|
110
|
+
getTokenBalancesByContract: (req) => ['IndexerGateway', 'getTokenBalancesByContract', req],
|
|
111
|
+
getTokenBalancesDetails: (req) => ['IndexerGateway', 'getTokenBalancesDetails', req],
|
|
112
|
+
getTokenBalancesSummary: (req) => ['IndexerGateway', 'getTokenBalancesSummary', req],
|
|
113
|
+
getTokenPrice: (req) => ['IndexerGateway', 'getTokenPrice', req],
|
|
114
|
+
getTokenPrices: (req) => ['IndexerGateway', 'getTokenPrices', req],
|
|
115
|
+
getTransactionHistory: (req) => ['IndexerGateway', 'getTransactionHistory', req],
|
|
116
|
+
ping: () => ['IndexerGateway', 'ping'],
|
|
117
|
+
runtimeStatus: () => ['IndexerGateway', 'runtimeStatus'],
|
|
118
|
+
version: () => ['IndexerGateway', 'version']
|
|
119
|
+
};
|
|
120
|
+
getBalanceUpdates = (req, headers, signal) => {
|
|
121
|
+
return this.fetch(this.url('GetBalanceUpdates'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
122
|
+
return buildResponse(res).then(_data => {
|
|
123
|
+
return JsonDecode(_data, 'GetBalanceUpdatesResponse');
|
|
144
124
|
});
|
|
145
|
-
},
|
|
146
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
125
|
+
}, error => {
|
|
126
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
147
127
|
});
|
|
148
128
|
};
|
|
149
|
-
|
|
150
|
-
return this.fetch(this.url('
|
|
151
|
-
return buildResponse(res).then(
|
|
152
|
-
return
|
|
153
|
-
page: _data.page,
|
|
154
|
-
balances: _data.balances,
|
|
155
|
-
};
|
|
129
|
+
getChains = (req, headers, signal) => {
|
|
130
|
+
return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
131
|
+
return buildResponse(res).then(_data => {
|
|
132
|
+
return JsonDecode(_data, 'GetChainsResponse');
|
|
156
133
|
});
|
|
157
|
-
},
|
|
158
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
134
|
+
}, error => {
|
|
135
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
159
136
|
});
|
|
160
137
|
};
|
|
161
|
-
|
|
162
|
-
return this.fetch(this.url('
|
|
163
|
-
return buildResponse(res).then(
|
|
164
|
-
return
|
|
165
|
-
page: _data.page,
|
|
166
|
-
nativeBalances: _data.nativeBalances,
|
|
167
|
-
balances: _data.balances,
|
|
168
|
-
};
|
|
138
|
+
getNativeTokenBalance = (req, headers, signal) => {
|
|
139
|
+
return this.fetch(this.url('GetNativeTokenBalance'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
140
|
+
return buildResponse(res).then(_data => {
|
|
141
|
+
return JsonDecode(_data, 'GetNativeTokenBalanceResponse');
|
|
169
142
|
});
|
|
170
|
-
},
|
|
171
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
143
|
+
}, error => {
|
|
144
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
172
145
|
});
|
|
173
146
|
};
|
|
174
|
-
|
|
175
|
-
return this.fetch(this.url('
|
|
176
|
-
return buildResponse(res).then(
|
|
177
|
-
return
|
|
178
|
-
page: _data.page,
|
|
179
|
-
nativeBalances: _data.nativeBalances,
|
|
180
|
-
balances: _data.balances,
|
|
181
|
-
};
|
|
147
|
+
getTokenBalances = (req, headers, signal) => {
|
|
148
|
+
return this.fetch(this.url('GetTokenBalances'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
149
|
+
return buildResponse(res).then(_data => {
|
|
150
|
+
return JsonDecode(_data, 'GetTokenBalancesResponse');
|
|
182
151
|
});
|
|
183
|
-
},
|
|
184
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
152
|
+
}, error => {
|
|
153
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
185
154
|
});
|
|
186
155
|
};
|
|
187
|
-
getTokenBalancesByContract = (
|
|
188
|
-
return this.fetch(this.url('GetTokenBalancesByContract'),
|
|
189
|
-
return buildResponse(res).then(
|
|
190
|
-
return
|
|
191
|
-
page: _data.page,
|
|
192
|
-
balances: _data.balances,
|
|
193
|
-
};
|
|
156
|
+
getTokenBalancesByContract = (req, headers, signal) => {
|
|
157
|
+
return this.fetch(this.url('GetTokenBalancesByContract'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
158
|
+
return buildResponse(res).then(_data => {
|
|
159
|
+
return JsonDecode(_data, 'GetTokenBalancesByContractResponse');
|
|
194
160
|
});
|
|
195
|
-
},
|
|
196
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
161
|
+
}, error => {
|
|
162
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
197
163
|
});
|
|
198
164
|
};
|
|
199
|
-
|
|
200
|
-
return this.fetch(this.url('
|
|
201
|
-
return buildResponse(res).then(
|
|
202
|
-
return
|
|
203
|
-
page: _data.page,
|
|
204
|
-
balances: _data.balances,
|
|
205
|
-
};
|
|
165
|
+
getTokenBalancesDetails = (req, headers, signal) => {
|
|
166
|
+
return this.fetch(this.url('GetTokenBalancesDetails'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
167
|
+
return buildResponse(res).then(_data => {
|
|
168
|
+
return JsonDecode(_data, 'GetTokenBalancesDetailsResponse');
|
|
206
169
|
});
|
|
207
|
-
},
|
|
208
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
170
|
+
}, error => {
|
|
171
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
209
172
|
});
|
|
210
173
|
};
|
|
211
|
-
|
|
212
|
-
return this.fetch(this.url('
|
|
213
|
-
return buildResponse(res).then(
|
|
214
|
-
return
|
|
215
|
-
status: _data.status,
|
|
216
|
-
};
|
|
174
|
+
getTokenBalancesSummary = (req, headers, signal) => {
|
|
175
|
+
return this.fetch(this.url('GetTokenBalancesSummary'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
176
|
+
return buildResponse(res).then(_data => {
|
|
177
|
+
return JsonDecode(_data, 'GetTokenBalancesSummaryResponse');
|
|
217
178
|
});
|
|
218
|
-
},
|
|
219
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
179
|
+
}, error => {
|
|
180
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
220
181
|
});
|
|
221
182
|
};
|
|
222
|
-
|
|
223
|
-
return this.fetch(this.url('
|
|
224
|
-
return buildResponse(res).then(
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
|
|
183
|
+
getTokenPrice = (req, headers, signal) => {
|
|
184
|
+
return this.fetch(this.url('GetTokenPrice'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
185
|
+
return buildResponse(res).then(_data => {
|
|
186
|
+
return JsonDecode(_data, 'GetTokenPriceResponse');
|
|
187
|
+
});
|
|
188
|
+
}, error => {
|
|
189
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
getTokenPrices = (req, headers, signal) => {
|
|
193
|
+
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
194
|
+
return buildResponse(res).then(_data => {
|
|
195
|
+
return JsonDecode(_data, 'GetTokenPricesResponse');
|
|
228
196
|
});
|
|
229
|
-
},
|
|
230
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
197
|
+
}, error => {
|
|
198
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
getTransactionHistory = (req, headers, signal) => {
|
|
202
|
+
return this.fetch(this.url('GetTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
203
|
+
return buildResponse(res).then(_data => {
|
|
204
|
+
return JsonDecode(_data, 'GetTransactionHistoryResponse');
|
|
205
|
+
});
|
|
206
|
+
}, error => {
|
|
207
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
ping = (headers, signal) => {
|
|
211
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
212
|
+
return buildResponse(res).then(_data => {
|
|
213
|
+
return JsonDecode(_data, 'PingResponse');
|
|
214
|
+
});
|
|
215
|
+
}, error => {
|
|
216
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
231
217
|
});
|
|
232
218
|
};
|
|
233
219
|
runtimeStatus = (headers, signal) => {
|
|
234
|
-
return this.fetch(this.url('RuntimeStatus'),
|
|
235
|
-
return buildResponse(res).then(
|
|
236
|
-
return
|
|
237
|
-
status: _data.status,
|
|
238
|
-
};
|
|
220
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
221
|
+
return buildResponse(res).then(_data => {
|
|
222
|
+
return JsonDecode(_data, 'RuntimeStatusResponse');
|
|
239
223
|
});
|
|
240
|
-
},
|
|
241
|
-
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message
|
|
224
|
+
}, error => {
|
|
225
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
version = (headers, signal) => {
|
|
229
|
+
return this.fetch(this.url('Version'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
230
|
+
return buildResponse(res).then(_data => {
|
|
231
|
+
return JsonDecode(_data, 'VersionResponse');
|
|
232
|
+
});
|
|
233
|
+
}, error => {
|
|
234
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
242
235
|
});
|
|
243
236
|
};
|
|
244
237
|
}
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
method: 'POST',
|
|
251
|
-
headers: reqHeaders,
|
|
252
|
-
body: JSON.stringify(body || {}),
|
|
253
|
-
signal,
|
|
238
|
+
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
239
|
+
const reqHeaders = {
|
|
240
|
+
...headers,
|
|
241
|
+
'Content-Type': 'application/json',
|
|
242
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
254
243
|
};
|
|
244
|
+
return { method: 'POST', headers: reqHeaders, body, signal };
|
|
255
245
|
};
|
|
256
246
|
const buildResponse = (res) => {
|
|
257
|
-
return res.text().then(
|
|
247
|
+
return res.text().then(text => {
|
|
258
248
|
let data;
|
|
259
249
|
try {
|
|
260
250
|
data = JSON.parse(text);
|
|
261
251
|
}
|
|
262
252
|
catch (error) {
|
|
263
|
-
let message = '';
|
|
264
|
-
if (error instanceof Error) {
|
|
265
|
-
message = error.message;
|
|
266
|
-
}
|
|
267
253
|
throw WebrpcBadResponseError.new({
|
|
268
254
|
status: res.status,
|
|
269
|
-
cause: `JSON.parse(): ${message}: response text: ${text}
|
|
255
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
270
256
|
});
|
|
271
257
|
}
|
|
272
258
|
if (!res.ok) {
|
|
@@ -276,294 +262,486 @@ const buildResponse = (res) => {
|
|
|
276
262
|
return data;
|
|
277
263
|
});
|
|
278
264
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
265
|
+
export const JsonEncode = (obj) => {
|
|
266
|
+
return JSON.stringify(obj);
|
|
267
|
+
};
|
|
268
|
+
export const JsonDecode = (data, _typ = '') => {
|
|
269
|
+
let parsed = data;
|
|
270
|
+
if (typeof data === 'string') {
|
|
271
|
+
try {
|
|
272
|
+
parsed = JSON.parse(data);
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${err.message}` });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return parsed;
|
|
279
|
+
};
|
|
280
|
+
export class WebrpcError extends Error {
|
|
284
281
|
code;
|
|
285
|
-
message;
|
|
286
282
|
status;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
this.msg = this.message;
|
|
296
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
297
|
-
this.cause = cause;
|
|
283
|
+
constructor(error = {}) {
|
|
284
|
+
super(error.message);
|
|
285
|
+
this.name = error.name || 'WebrpcEndpointError';
|
|
286
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
287
|
+
this.message = error.message || `endpoint error`;
|
|
288
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
289
|
+
if (error.cause !== undefined)
|
|
290
|
+
this.cause = error.cause;
|
|
298
291
|
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
299
292
|
}
|
|
300
293
|
static new(payload) {
|
|
301
|
-
return new this(
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
294
|
+
return new this({ message: payload.message, code: payload.code, status: payload.status, cause: payload.cause });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
export class WebrpcEndpointError extends WebrpcError {
|
|
298
|
+
constructor(error = {}) {
|
|
299
|
+
super(error);
|
|
300
|
+
this.name = error.name || 'WebrpcEndpoint';
|
|
301
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
302
|
+
this.message = error.message || `endpoint error`;
|
|
303
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
304
|
+
if (error.cause !== undefined)
|
|
305
|
+
this.cause = error.cause;
|
|
309
306
|
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
310
307
|
}
|
|
311
308
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
309
|
+
export class WebrpcRequestFailedError extends WebrpcError {
|
|
310
|
+
constructor(error = {}) {
|
|
311
|
+
super(error);
|
|
312
|
+
this.name = error.name || 'WebrpcRequestFailed';
|
|
313
|
+
this.code = typeof error.code === 'number' ? error.code : -1;
|
|
314
|
+
this.message = error.message || `request failed`;
|
|
315
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
316
|
+
if (error.cause !== undefined)
|
|
317
|
+
this.cause = error.cause;
|
|
316
318
|
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
export class WebrpcBadRouteError extends WebrpcError {
|
|
322
|
+
constructor(error = {}) {
|
|
323
|
+
super(error);
|
|
324
|
+
this.name = error.name || 'WebrpcBadRoute';
|
|
325
|
+
this.code = typeof error.code === 'number' ? error.code : -2;
|
|
326
|
+
this.message = error.message || `bad route`;
|
|
327
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
328
|
+
if (error.cause !== undefined)
|
|
329
|
+
this.cause = error.cause;
|
|
323
330
|
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
324
331
|
}
|
|
325
332
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
export class WebrpcBadMethodError extends WebrpcError {
|
|
334
|
+
constructor(error = {}) {
|
|
335
|
+
super(error);
|
|
336
|
+
this.name = error.name || 'WebrpcBadMethod';
|
|
337
|
+
this.code = typeof error.code === 'number' ? error.code : -3;
|
|
338
|
+
this.message = error.message || `bad method`;
|
|
339
|
+
this.status = typeof error.status === 'number' ? error.status : 405;
|
|
340
|
+
if (error.cause !== undefined)
|
|
341
|
+
this.cause = error.cause;
|
|
330
342
|
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
331
343
|
}
|
|
332
344
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
345
|
+
export class WebrpcBadRequestError extends WebrpcError {
|
|
346
|
+
constructor(error = {}) {
|
|
347
|
+
super(error);
|
|
348
|
+
this.name = error.name || 'WebrpcBadRequest';
|
|
349
|
+
this.code = typeof error.code === 'number' ? error.code : -4;
|
|
350
|
+
this.message = error.message || `bad request`;
|
|
351
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
352
|
+
if (error.cause !== undefined)
|
|
353
|
+
this.cause = error.cause;
|
|
337
354
|
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
357
|
+
export class WebrpcBadResponseError extends WebrpcError {
|
|
358
|
+
constructor(error = {}) {
|
|
359
|
+
super(error);
|
|
360
|
+
this.name = error.name || 'WebrpcBadResponse';
|
|
361
|
+
this.code = typeof error.code === 'number' ? error.code : -5;
|
|
362
|
+
this.message = error.message || `bad response`;
|
|
363
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
364
|
+
if (error.cause !== undefined)
|
|
365
|
+
this.cause = error.cause;
|
|
344
366
|
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
345
367
|
}
|
|
346
368
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
369
|
+
export class WebrpcServerPanicError extends WebrpcError {
|
|
370
|
+
constructor(error = {}) {
|
|
371
|
+
super(error);
|
|
372
|
+
this.name = error.name || 'WebrpcServerPanic';
|
|
373
|
+
this.code = typeof error.code === 'number' ? error.code : -6;
|
|
374
|
+
this.message = error.message || `server panic`;
|
|
375
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
376
|
+
if (error.cause !== undefined)
|
|
377
|
+
this.cause = error.cause;
|
|
351
378
|
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
352
379
|
}
|
|
353
380
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
381
|
+
export class WebrpcInternalErrorError extends WebrpcError {
|
|
382
|
+
constructor(error = {}) {
|
|
383
|
+
super(error);
|
|
384
|
+
this.name = error.name || 'WebrpcInternalError';
|
|
385
|
+
this.code = typeof error.code === 'number' ? error.code : -7;
|
|
386
|
+
this.message = error.message || `internal error`;
|
|
387
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
388
|
+
if (error.cause !== undefined)
|
|
389
|
+
this.cause = error.cause;
|
|
358
390
|
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
359
391
|
}
|
|
360
392
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
393
|
+
export class WebrpcClientAbortedError extends WebrpcError {
|
|
394
|
+
constructor(error = {}) {
|
|
395
|
+
super(error);
|
|
396
|
+
this.name = error.name || 'WebrpcClientAborted';
|
|
397
|
+
this.code = typeof error.code === 'number' ? error.code : -8;
|
|
398
|
+
this.message = error.message || `request aborted by client`;
|
|
399
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
400
|
+
if (error.cause !== undefined)
|
|
401
|
+
this.cause = error.cause;
|
|
402
|
+
Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
export class WebrpcStreamLostError extends WebrpcError {
|
|
406
|
+
constructor(error = {}) {
|
|
407
|
+
super(error);
|
|
408
|
+
this.name = error.name || 'WebrpcStreamLost';
|
|
409
|
+
this.code = typeof error.code === 'number' ? error.code : -9;
|
|
410
|
+
this.message = error.message || `stream lost`;
|
|
411
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
412
|
+
if (error.cause !== undefined)
|
|
413
|
+
this.cause = error.cause;
|
|
372
414
|
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
373
415
|
}
|
|
374
416
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
417
|
+
export class WebrpcStreamFinishedError extends WebrpcError {
|
|
418
|
+
constructor(error = {}) {
|
|
419
|
+
super(error);
|
|
420
|
+
this.name = error.name || 'WebrpcStreamFinished';
|
|
421
|
+
this.code = typeof error.code === 'number' ? error.code : -10;
|
|
422
|
+
this.message = error.message || `stream finished`;
|
|
423
|
+
this.status = typeof error.status === 'number' ? error.status : 200;
|
|
424
|
+
if (error.cause !== undefined)
|
|
425
|
+
this.cause = error.cause;
|
|
379
426
|
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
380
427
|
}
|
|
381
428
|
}
|
|
382
|
-
|
|
429
|
+
//
|
|
383
430
|
// Schema errors
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
431
|
+
//
|
|
432
|
+
export class AbortedError extends WebrpcError {
|
|
433
|
+
constructor(error = {}) {
|
|
434
|
+
super(error);
|
|
435
|
+
this.name = error.name || 'Aborted';
|
|
436
|
+
this.code = typeof error.code === 'number' ? error.code : 1005;
|
|
437
|
+
this.message = error.message || `Request aborted`;
|
|
438
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
439
|
+
if (error.cause !== undefined)
|
|
440
|
+
this.cause = error.cause;
|
|
441
|
+
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
388
442
|
}
|
|
389
443
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
444
|
+
export class AccessKeyMismatchError extends WebrpcError {
|
|
445
|
+
constructor(error = {}) {
|
|
446
|
+
super(error);
|
|
447
|
+
this.name = error.name || 'AccessKeyMismatch';
|
|
448
|
+
this.code = typeof error.code === 'number' ? error.code : 1102;
|
|
449
|
+
this.message = error.message || `Access key mismatch`;
|
|
450
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
451
|
+
if (error.cause !== undefined)
|
|
452
|
+
this.cause = error.cause;
|
|
453
|
+
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
395
454
|
}
|
|
396
455
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
456
|
+
export class AccessKeyNotFoundError extends WebrpcError {
|
|
457
|
+
constructor(error = {}) {
|
|
458
|
+
super(error);
|
|
459
|
+
this.name = error.name || 'AccessKeyNotFound';
|
|
460
|
+
this.code = typeof error.code === 'number' ? error.code : 1101;
|
|
461
|
+
this.message = error.message || `Access key not found`;
|
|
462
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
463
|
+
if (error.cause !== undefined)
|
|
464
|
+
this.cause = error.cause;
|
|
465
|
+
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
402
466
|
}
|
|
403
467
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
468
|
+
export class AtLeastOneKeyError extends WebrpcError {
|
|
469
|
+
constructor(error = {}) {
|
|
470
|
+
super(error);
|
|
471
|
+
this.name = error.name || 'AtLeastOneKey';
|
|
472
|
+
this.code = typeof error.code === 'number' ? error.code : 1302;
|
|
473
|
+
this.message = error.message || `You need at least one Access Key`;
|
|
474
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
475
|
+
if (error.cause !== undefined)
|
|
476
|
+
this.cause = error.cause;
|
|
477
|
+
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
409
478
|
}
|
|
410
479
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
480
|
+
export class GeoblockedError extends WebrpcError {
|
|
481
|
+
constructor(error = {}) {
|
|
482
|
+
super(error);
|
|
483
|
+
this.name = error.name || 'Geoblocked';
|
|
484
|
+
this.code = typeof error.code === 'number' ? error.code : 1006;
|
|
485
|
+
this.message = error.message || `Geoblocked region`;
|
|
486
|
+
this.status = typeof error.status === 'number' ? error.status : 451;
|
|
487
|
+
if (error.cause !== undefined)
|
|
488
|
+
this.cause = error.cause;
|
|
489
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
416
490
|
}
|
|
417
491
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
492
|
+
export class InvalidArgumentError extends WebrpcError {
|
|
493
|
+
constructor(error = {}) {
|
|
494
|
+
super(error);
|
|
495
|
+
this.name = error.name || 'InvalidArgument';
|
|
496
|
+
this.code = typeof error.code === 'number' ? error.code : 2001;
|
|
497
|
+
this.message = error.message || `Invalid argument`;
|
|
498
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
499
|
+
if (error.cause !== undefined)
|
|
500
|
+
this.cause = error.cause;
|
|
501
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
423
502
|
}
|
|
424
503
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
504
|
+
export class InvalidOriginError extends WebrpcError {
|
|
505
|
+
constructor(error = {}) {
|
|
506
|
+
super(error);
|
|
507
|
+
this.name = error.name || 'InvalidOrigin';
|
|
508
|
+
this.code = typeof error.code === 'number' ? error.code : 1103;
|
|
509
|
+
this.message = error.message || `Invalid origin for Access Key`;
|
|
510
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
511
|
+
if (error.cause !== undefined)
|
|
512
|
+
this.cause = error.cause;
|
|
513
|
+
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
430
514
|
}
|
|
431
515
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
516
|
+
export class InvalidServiceError extends WebrpcError {
|
|
517
|
+
constructor(error = {}) {
|
|
518
|
+
super(error);
|
|
519
|
+
this.name = error.name || 'InvalidService';
|
|
520
|
+
this.code = typeof error.code === 'number' ? error.code : 1104;
|
|
521
|
+
this.message = error.message || `Service not enabled for Access key`;
|
|
522
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
523
|
+
if (error.cause !== undefined)
|
|
524
|
+
this.cause = error.cause;
|
|
525
|
+
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
437
526
|
}
|
|
438
527
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
528
|
+
export class MaxAccessKeysError extends WebrpcError {
|
|
529
|
+
constructor(error = {}) {
|
|
530
|
+
super(error);
|
|
531
|
+
this.name = error.name || 'MaxAccessKeys';
|
|
532
|
+
this.code = typeof error.code === 'number' ? error.code : 1301;
|
|
533
|
+
this.message = error.message || `Access keys limit reached`;
|
|
534
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
535
|
+
if (error.cause !== undefined)
|
|
536
|
+
this.cause = error.cause;
|
|
537
|
+
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
444
538
|
}
|
|
445
539
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
540
|
+
export class MetadataCallFailedError extends WebrpcError {
|
|
541
|
+
constructor(error = {}) {
|
|
542
|
+
super(error);
|
|
543
|
+
this.name = error.name || 'MetadataCallFailed';
|
|
544
|
+
this.code = typeof error.code === 'number' ? error.code : 3003;
|
|
545
|
+
this.message = error.message || `Metadata service call failed`;
|
|
546
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
547
|
+
if (error.cause !== undefined)
|
|
548
|
+
this.cause = error.cause;
|
|
549
|
+
Object.setPrototypeOf(this, MetadataCallFailedError.prototype);
|
|
451
550
|
}
|
|
452
551
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
552
|
+
export class MethodNotFoundError extends WebrpcError {
|
|
553
|
+
constructor(error = {}) {
|
|
554
|
+
super(error);
|
|
555
|
+
this.name = error.name || 'MethodNotFound';
|
|
556
|
+
this.code = typeof error.code === 'number' ? error.code : 1003;
|
|
557
|
+
this.message = error.message || `Method not found`;
|
|
558
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
559
|
+
if (error.cause !== undefined)
|
|
560
|
+
this.cause = error.cause;
|
|
561
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
458
562
|
}
|
|
459
563
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
564
|
+
export class NoDefaultKeyError extends WebrpcError {
|
|
565
|
+
constructor(error = {}) {
|
|
566
|
+
super(error);
|
|
567
|
+
this.name = error.name || 'NoDefaultKey';
|
|
568
|
+
this.code = typeof error.code === 'number' ? error.code : 1300;
|
|
569
|
+
this.message = error.message || `No default access key found`;
|
|
570
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
571
|
+
if (error.cause !== undefined)
|
|
572
|
+
this.cause = error.cause;
|
|
573
|
+
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
465
574
|
}
|
|
466
575
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
576
|
+
export class NotFoundError extends WebrpcError {
|
|
577
|
+
constructor(error = {}) {
|
|
578
|
+
super(error);
|
|
579
|
+
this.name = error.name || 'NotFound';
|
|
580
|
+
this.code = typeof error.code === 'number' ? error.code : 3000;
|
|
581
|
+
this.message = error.message || `Resource not found`;
|
|
582
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
583
|
+
if (error.cause !== undefined)
|
|
584
|
+
this.cause = error.cause;
|
|
585
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
472
586
|
}
|
|
473
587
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
588
|
+
export class PermissionDeniedError extends WebrpcError {
|
|
589
|
+
constructor(error = {}) {
|
|
590
|
+
super(error);
|
|
591
|
+
this.name = error.name || 'PermissionDenied';
|
|
592
|
+
this.code = typeof error.code === 'number' ? error.code : 1001;
|
|
593
|
+
this.message = error.message || `Permission denied`;
|
|
594
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
595
|
+
if (error.cause !== undefined)
|
|
596
|
+
this.cause = error.cause;
|
|
597
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
479
598
|
}
|
|
480
599
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
600
|
+
export class ProjectNotFoundError extends WebrpcError {
|
|
601
|
+
constructor(error = {}) {
|
|
602
|
+
super(error);
|
|
603
|
+
this.name = error.name || 'ProjectNotFound';
|
|
604
|
+
this.code = typeof error.code === 'number' ? error.code : 1100;
|
|
605
|
+
this.message = error.message || `Project not found`;
|
|
606
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
607
|
+
if (error.cause !== undefined)
|
|
608
|
+
this.cause = error.cause;
|
|
609
|
+
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
486
610
|
}
|
|
487
611
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
612
|
+
export class QueryFailedError extends WebrpcError {
|
|
613
|
+
constructor(error = {}) {
|
|
614
|
+
super(error);
|
|
615
|
+
this.name = error.name || 'QueryFailed';
|
|
616
|
+
this.code = typeof error.code === 'number' ? error.code : 2003;
|
|
617
|
+
this.message = error.message || `Query failed`;
|
|
618
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
619
|
+
if (error.cause !== undefined)
|
|
620
|
+
this.cause = error.cause;
|
|
621
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
493
622
|
}
|
|
494
623
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
624
|
+
export class QuotaExceededError extends WebrpcError {
|
|
625
|
+
constructor(error = {}) {
|
|
626
|
+
super(error);
|
|
627
|
+
this.name = error.name || 'QuotaExceeded';
|
|
628
|
+
this.code = typeof error.code === 'number' ? error.code : 1200;
|
|
629
|
+
this.message = error.message || `Quota exceeded`;
|
|
630
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
631
|
+
if (error.cause !== undefined)
|
|
632
|
+
this.cause = error.cause;
|
|
633
|
+
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
500
634
|
}
|
|
501
635
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
636
|
+
export class RateLimitError extends WebrpcError {
|
|
637
|
+
constructor(error = {}) {
|
|
638
|
+
super(error);
|
|
639
|
+
this.name = error.name || 'RateLimit';
|
|
640
|
+
this.code = typeof error.code === 'number' ? error.code : 1201;
|
|
641
|
+
this.message = error.message || `Rate limit exceeded`;
|
|
642
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
643
|
+
if (error.cause !== undefined)
|
|
644
|
+
this.cause = error.cause;
|
|
645
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
507
646
|
}
|
|
508
647
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
648
|
+
export class RateLimitedError extends WebrpcError {
|
|
649
|
+
constructor(error = {}) {
|
|
650
|
+
super(error);
|
|
651
|
+
this.name = error.name || 'RateLimited';
|
|
652
|
+
this.code = typeof error.code === 'number' ? error.code : 1007;
|
|
653
|
+
this.message = error.message || `Rate-limited. Please slow down.`;
|
|
654
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
655
|
+
if (error.cause !== undefined)
|
|
656
|
+
this.cause = error.cause;
|
|
657
|
+
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
514
658
|
}
|
|
515
659
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
660
|
+
export class RequestConflictError extends WebrpcError {
|
|
661
|
+
constructor(error = {}) {
|
|
662
|
+
super(error);
|
|
663
|
+
this.name = error.name || 'RequestConflict';
|
|
664
|
+
this.code = typeof error.code === 'number' ? error.code : 1004;
|
|
665
|
+
this.message = error.message || `Conflict with target resource`;
|
|
666
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
667
|
+
if (error.cause !== undefined)
|
|
668
|
+
this.cause = error.cause;
|
|
669
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
521
670
|
}
|
|
522
671
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
672
|
+
export class ResourceExhaustedError extends WebrpcError {
|
|
673
|
+
constructor(error = {}) {
|
|
674
|
+
super(error);
|
|
675
|
+
this.name = error.name || 'ResourceExhausted';
|
|
676
|
+
this.code = typeof error.code === 'number' ? error.code : 2004;
|
|
677
|
+
this.message = error.message || `Resource exhausted`;
|
|
678
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
679
|
+
if (error.cause !== undefined)
|
|
680
|
+
this.cause = error.cause;
|
|
681
|
+
Object.setPrototypeOf(this, ResourceExhaustedError.prototype);
|
|
528
682
|
}
|
|
529
683
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
684
|
+
export class SessionExpiredError extends WebrpcError {
|
|
685
|
+
constructor(error = {}) {
|
|
686
|
+
super(error);
|
|
687
|
+
this.name = error.name || 'SessionExpired';
|
|
688
|
+
this.code = typeof error.code === 'number' ? error.code : 1002;
|
|
689
|
+
this.message = error.message || `Session expired`;
|
|
690
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
691
|
+
if (error.cause !== undefined)
|
|
692
|
+
this.cause = error.cause;
|
|
693
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
535
694
|
}
|
|
536
695
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
696
|
+
export class TimeoutError extends WebrpcError {
|
|
697
|
+
constructor(error = {}) {
|
|
698
|
+
super(error);
|
|
699
|
+
this.name = error.name || 'Timeout';
|
|
700
|
+
this.code = typeof error.code === 'number' ? error.code : 1900;
|
|
701
|
+
this.message = error.message || `Request timed out`;
|
|
702
|
+
this.status = typeof error.status === 'number' ? error.status : 408;
|
|
703
|
+
if (error.cause !== undefined)
|
|
704
|
+
this.cause = error.cause;
|
|
705
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
542
706
|
}
|
|
543
707
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
708
|
+
export class UnauthorizedError extends WebrpcError {
|
|
709
|
+
constructor(error = {}) {
|
|
710
|
+
super(error);
|
|
711
|
+
this.name = error.name || 'Unauthorized';
|
|
712
|
+
this.code = typeof error.code === 'number' ? error.code : 1000;
|
|
713
|
+
this.message = error.message || `Unauthorized access`;
|
|
714
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
715
|
+
if (error.cause !== undefined)
|
|
716
|
+
this.cause = error.cause;
|
|
717
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
549
718
|
}
|
|
550
719
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
720
|
+
export class UnauthorizedUserError extends WebrpcError {
|
|
721
|
+
constructor(error = {}) {
|
|
722
|
+
super(error);
|
|
723
|
+
this.name = error.name || 'UnauthorizedUser';
|
|
724
|
+
this.code = typeof error.code === 'number' ? error.code : 1105;
|
|
725
|
+
this.message = error.message || `Unauthorized user`;
|
|
726
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
727
|
+
if (error.cause !== undefined)
|
|
728
|
+
this.cause = error.cause;
|
|
729
|
+
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
556
730
|
}
|
|
557
731
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
732
|
+
export class UnavailableError extends WebrpcError {
|
|
733
|
+
constructor(error = {}) {
|
|
734
|
+
super(error);
|
|
735
|
+
this.name = error.name || 'Unavailable';
|
|
736
|
+
this.code = typeof error.code === 'number' ? error.code : 2002;
|
|
737
|
+
this.message = error.message || `Unavailable resource`;
|
|
738
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
739
|
+
if (error.cause !== undefined)
|
|
740
|
+
this.cause = error.cause;
|
|
741
|
+
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
563
742
|
}
|
|
564
743
|
}
|
|
565
|
-
|
|
566
|
-
var errors;
|
|
744
|
+
export var errors;
|
|
567
745
|
(function (errors) {
|
|
568
746
|
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
569
747
|
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
@@ -573,37 +751,77 @@ var errors;
|
|
|
573
751
|
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
574
752
|
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
575
753
|
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
576
|
-
errors["
|
|
754
|
+
errors["WebrpcClientAborted"] = "WebrpcClientAborted";
|
|
577
755
|
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
578
756
|
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
579
|
-
errors["Unauthorized"] = "Unauthorized";
|
|
580
|
-
errors["PermissionDenied"] = "PermissionDenied";
|
|
581
|
-
errors["SessionExpired"] = "SessionExpired";
|
|
582
|
-
errors["MethodNotFound"] = "MethodNotFound";
|
|
583
|
-
errors["RequestConflict"] = "RequestConflict";
|
|
584
757
|
errors["Aborted"] = "Aborted";
|
|
585
|
-
errors["Geoblocked"] = "Geoblocked";
|
|
586
|
-
errors["RateLimited"] = "RateLimited";
|
|
587
|
-
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
588
|
-
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
589
758
|
errors["AccessKeyMismatch"] = "AccessKeyMismatch";
|
|
759
|
+
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
760
|
+
errors["AtLeastOneKey"] = "AtLeastOneKey";
|
|
761
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
762
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
|
590
763
|
errors["InvalidOrigin"] = "InvalidOrigin";
|
|
591
764
|
errors["InvalidService"] = "InvalidService";
|
|
592
|
-
errors["
|
|
765
|
+
errors["MaxAccessKeys"] = "MaxAccessKeys";
|
|
766
|
+
errors["MetadataCallFailed"] = "MetadataCallFailed";
|
|
767
|
+
errors["MethodNotFound"] = "MethodNotFound";
|
|
768
|
+
errors["NoDefaultKey"] = "NoDefaultKey";
|
|
769
|
+
errors["NotFound"] = "NotFound";
|
|
770
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
|
771
|
+
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
772
|
+
errors["QueryFailed"] = "QueryFailed";
|
|
593
773
|
errors["QuotaExceeded"] = "QuotaExceeded";
|
|
594
774
|
errors["RateLimit"] = "RateLimit";
|
|
595
|
-
errors["
|
|
596
|
-
errors["
|
|
597
|
-
errors["
|
|
775
|
+
errors["RateLimited"] = "RateLimited";
|
|
776
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
777
|
+
errors["ResourceExhausted"] = "ResourceExhausted";
|
|
778
|
+
errors["SessionExpired"] = "SessionExpired";
|
|
598
779
|
errors["Timeout"] = "Timeout";
|
|
599
|
-
errors["
|
|
780
|
+
errors["Unauthorized"] = "Unauthorized";
|
|
781
|
+
errors["UnauthorizedUser"] = "UnauthorizedUser";
|
|
600
782
|
errors["Unavailable"] = "Unavailable";
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
783
|
+
})(errors || (errors = {}));
|
|
784
|
+
export var WebrpcErrorCodes;
|
|
785
|
+
(function (WebrpcErrorCodes) {
|
|
786
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
|
787
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
|
788
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
|
789
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
|
790
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
|
791
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
792
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
793
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
794
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
|
|
795
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
796
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
797
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Aborted"] = 1005] = "Aborted";
|
|
798
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyMismatch"] = 1102] = "AccessKeyMismatch";
|
|
799
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyNotFound"] = 1101] = "AccessKeyNotFound";
|
|
800
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AtLeastOneKey"] = 1302] = "AtLeastOneKey";
|
|
801
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
|
|
802
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
|
|
803
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidOrigin"] = 1103] = "InvalidOrigin";
|
|
804
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidService"] = 1104] = "InvalidService";
|
|
805
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MaxAccessKeys"] = 1301] = "MaxAccessKeys";
|
|
806
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MetadataCallFailed"] = 3003] = "MetadataCallFailed";
|
|
807
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
|
808
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NoDefaultKey"] = 1300] = "NoDefaultKey";
|
|
809
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 3000] = "NotFound";
|
|
810
|
+
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
|
811
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 1100] = "ProjectNotFound";
|
|
812
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QueryFailed"] = 2003] = "QueryFailed";
|
|
813
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QuotaExceeded"] = 1200] = "QuotaExceeded";
|
|
814
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RateLimit"] = 1201] = "RateLimit";
|
|
815
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 1007] = "RateLimited";
|
|
816
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
|
817
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ResourceExhausted"] = 2004] = "ResourceExhausted";
|
|
818
|
+
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
|
819
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 1900] = "Timeout";
|
|
820
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
821
|
+
WebrpcErrorCodes[WebrpcErrorCodes["UnauthorizedUser"] = 1105] = "UnauthorizedUser";
|
|
822
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unavailable"] = 2002] = "Unavailable";
|
|
823
|
+
})(WebrpcErrorCodes || (WebrpcErrorCodes = {}));
|
|
824
|
+
export const webrpcErrorByCode = {
|
|
607
825
|
[0]: WebrpcEndpointError,
|
|
608
826
|
[-1]: WebrpcRequestFailedError,
|
|
609
827
|
[-2]: WebrpcBadRouteError,
|
|
@@ -612,33 +830,73 @@ const webrpcErrorByCode = {
|
|
|
612
830
|
[-5]: WebrpcBadResponseError,
|
|
613
831
|
[-6]: WebrpcServerPanicError,
|
|
614
832
|
[-7]: WebrpcInternalErrorError,
|
|
615
|
-
[-8]:
|
|
833
|
+
[-8]: WebrpcClientAbortedError,
|
|
616
834
|
[-9]: WebrpcStreamLostError,
|
|
617
835
|
[-10]: WebrpcStreamFinishedError,
|
|
618
|
-
[1000]: UnauthorizedError,
|
|
619
|
-
[1001]: PermissionDeniedError,
|
|
620
|
-
[1002]: SessionExpiredError,
|
|
621
|
-
[1003]: MethodNotFoundError,
|
|
622
|
-
[1004]: RequestConflictError,
|
|
623
836
|
[1005]: AbortedError,
|
|
624
|
-
[1006]: GeoblockedError,
|
|
625
|
-
[1007]: RateLimitedError,
|
|
626
|
-
[1100]: ProjectNotFoundError,
|
|
627
|
-
[1101]: AccessKeyNotFoundError,
|
|
628
837
|
[1102]: AccessKeyMismatchError,
|
|
838
|
+
[1101]: AccessKeyNotFoundError,
|
|
839
|
+
[1302]: AtLeastOneKeyError,
|
|
840
|
+
[1006]: GeoblockedError,
|
|
841
|
+
[2001]: InvalidArgumentError,
|
|
629
842
|
[1103]: InvalidOriginError,
|
|
630
843
|
[1104]: InvalidServiceError,
|
|
631
|
-
[1105]: UnauthorizedUserError,
|
|
632
|
-
[1200]: QuotaExceededError,
|
|
633
|
-
[1201]: RateLimitError,
|
|
634
|
-
[1300]: NoDefaultKeyError,
|
|
635
844
|
[1301]: MaxAccessKeysError,
|
|
636
|
-
[
|
|
637
|
-
[
|
|
638
|
-
[
|
|
639
|
-
[
|
|
845
|
+
[3003]: MetadataCallFailedError,
|
|
846
|
+
[1003]: MethodNotFoundError,
|
|
847
|
+
[1300]: NoDefaultKeyError,
|
|
848
|
+
[3000]: NotFoundError,
|
|
849
|
+
[1001]: PermissionDeniedError,
|
|
850
|
+
[1100]: ProjectNotFoundError,
|
|
640
851
|
[2003]: QueryFailedError,
|
|
852
|
+
[1200]: QuotaExceededError,
|
|
853
|
+
[1201]: RateLimitError,
|
|
854
|
+
[1007]: RateLimitedError,
|
|
855
|
+
[1004]: RequestConflictError,
|
|
641
856
|
[2004]: ResourceExhaustedError,
|
|
642
|
-
[
|
|
643
|
-
[
|
|
857
|
+
[1002]: SessionExpiredError,
|
|
858
|
+
[1900]: TimeoutError,
|
|
859
|
+
[1000]: UnauthorizedError,
|
|
860
|
+
[1105]: UnauthorizedUserError,
|
|
861
|
+
[2002]: UnavailableError
|
|
644
862
|
};
|
|
863
|
+
//
|
|
864
|
+
// Webrpc
|
|
865
|
+
//
|
|
866
|
+
export const WebrpcHeader = 'Webrpc';
|
|
867
|
+
export const WebrpcHeaderValue = 'webrpc@v0.31.2;gen-typescript@v0.23.1;sequence-indexer@v0.4.0';
|
|
868
|
+
export function VersionFromHeader(headers) {
|
|
869
|
+
const headerValue = headers.get(WebrpcHeader);
|
|
870
|
+
if (!headerValue) {
|
|
871
|
+
return {
|
|
872
|
+
WebrpcGenVersion: '',
|
|
873
|
+
codeGenName: '',
|
|
874
|
+
codeGenVersion: '',
|
|
875
|
+
schemaName: '',
|
|
876
|
+
schemaVersion: ''
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
return parseWebrpcGenVersions(headerValue);
|
|
880
|
+
}
|
|
881
|
+
function parseWebrpcGenVersions(header) {
|
|
882
|
+
const versions = header.split(';');
|
|
883
|
+
if (versions.length < 3) {
|
|
884
|
+
return {
|
|
885
|
+
WebrpcGenVersion: '',
|
|
886
|
+
codeGenName: '',
|
|
887
|
+
codeGenVersion: '',
|
|
888
|
+
schemaName: '',
|
|
889
|
+
schemaVersion: ''
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
const [_, WebrpcGenVersion] = versions[0].split('@');
|
|
893
|
+
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
894
|
+
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
895
|
+
return {
|
|
896
|
+
WebrpcGenVersion: WebrpcGenVersion ?? '',
|
|
897
|
+
codeGenName: codeGenName ?? '',
|
|
898
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
899
|
+
schemaName: schemaName ?? '',
|
|
900
|
+
schemaVersion: schemaVersion ?? ''
|
|
901
|
+
};
|
|
902
|
+
}
|