diff --git a/packages/indexer/src/indexer.gen.ts b/packages/indexer/src/indexer.gen.ts index fe88eab5ba..fc76ddf7be 100644 --- a/packages/indexer/src/indexer.gen.ts +++ b/packages/indexer/src/indexer.gen.ts @@ -1,13 +1,13 @@ /* eslint-disable */ -// sequence-indexer v0.4.0 546b527de7002f409ffa602ad35b5a3abe979088 +// sequence-indexer v0.4.0 9a124af12426495a061fa1cd0f279473bea7b5c0 // -- -// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.24.0 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=indexer.ridl -service=Indexer -target=typescript -client -out=./clients/indexer.gen.ts export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0' +export const WebrpcHeaderValue = 'webrpc@v0.24.0;gen-typescript@v0.16.3;sequence-indexer@v0.4.0' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -16,7 +16,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.4.0' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '546b527de7002f409ffa602ad35b5a3abe979088' +export const WebRPCSchemaHash = '9a124af12426495a061fa1cd0f279473bea7b5c0' type WebrpcGenVersions = { webrpcGenVersion: string @@ -53,16 +53,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -72,14 +72,13 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { export enum ResourceStatus { NOT_AVAILABLE = 'NOT_AVAILABLE', - REFRESHING = 'REFRESHING', + STALE = 'STALE', AVAILABLE = 'AVAILABLE' } export interface ContractInfo { chainId: number address: string - source: string name: string type: string symbol: string @@ -89,6 +88,7 @@ export interface ContractInfo { bytecodeHash: string extensions: ContractInfoExtensions updatedAt: string + notFound: boolean queuedAt?: string status: ResourceStatus } @@ -105,13 +105,10 @@ export interface ContractInfoExtensions { verified: boolean verifiedBy: string featured: boolean - featureIndex: number } export interface TokenMetadata { - contractAddress?: string tokenId: string - source: string name: string description?: string image?: string @@ -389,6 +386,7 @@ export interface OrderbookOrder { export interface OrderbookOrderFilter { isListing?: boolean userAddresses?: Array + orderIds: Array tokenIds: Array excludeUserAddresses?: Array afterBlockNumber: number @@ -540,7 +538,6 @@ export interface MetadataOptions { export interface TokenBalancesFilter { accountAddresses: Array contractStatus?: ContractVerificationStatus - contractTypes?: Array contractWhitelist?: Array contractBlacklist?: Array omitNativeBalances: boolean @@ -623,12 +620,12 @@ export interface Indexer { headers?: object, signal?: AbortSignal ): Promise - subscribeReceipts(args: SubscribeReceiptsArgs, options: WebrpcStreamOptions): Promise - subscribeEvents(args: SubscribeEventsArgs, options: WebrpcStreamOptions): Promise + subscribeReceipts(args: SubscribeReceiptsArgs, options: WebrpcStreamOptions): WebrpcStreamController + subscribeEvents(args: SubscribeEventsArgs, options: WebrpcStreamOptions): WebrpcStreamController subscribeBalanceUpdates( args: SubscribeBalanceUpdatesArgs, options: WebrpcStreamOptions - ): Promise + ): WebrpcStreamController syncBalance(args: SyncBalanceArgs, headers?: object, signal?: AbortSignal): Promise getAllWebhookListeners( args: GetAllWebhookListenersArgs, @@ -1291,9 +1288,21 @@ export class Indexer implements Indexer { ) } - subscribeReceipts = (args: SubscribeReceiptsArgs, options: WebrpcStreamOptions): Promise => { + subscribeReceipts = ( + args: SubscribeReceiptsArgs, + options: WebrpcStreamOptions + ): WebrpcStreamController => { + const abortController = new AbortController() + const abortSignal = abortController.signal + + if (options.signal) { + abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), { + signal: options.signal + }) + } + const _fetch = () => - this.fetch(this.url('SubscribeReceipts'), createHTTPRequest(args, options.headers, options.signal)).then( + this.fetch(this.url('SubscribeReceipts'), createHTTPRequest(args, options.headers, abortSignal)).then( async res => { await sseResponse(res, options, _fetch) }, @@ -1301,11 +1310,25 @@ export class Indexer implements Indexer { options.onError(error, _fetch) } ) - return _fetch() + + const resp = _fetch() + return { + abort: abortController.abort.bind(abortController), + closed: resp + } } - subscribeEvents = (args: SubscribeEventsArgs, options: WebrpcStreamOptions): Promise => { + subscribeEvents = (args: SubscribeEventsArgs, options: WebrpcStreamOptions): WebrpcStreamController => { + const abortController = new AbortController() + const abortSignal = abortController.signal + + if (options.signal) { + abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), { + signal: options.signal + }) + } + const _fetch = () => - this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, options.signal)).then( + this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, abortSignal)).then( async res => { await sseResponse(res, options, _fetch) }, @@ -1313,14 +1336,28 @@ export class Indexer implements Indexer { options.onError(error, _fetch) } ) - return _fetch() + + const resp = _fetch() + return { + abort: abortController.abort.bind(abortController), + closed: resp + } } subscribeBalanceUpdates = ( args: SubscribeBalanceUpdatesArgs, options: WebrpcStreamOptions - ): Promise => { + ): WebrpcStreamController => { + const abortController = new AbortController() + const abortSignal = abortController.signal + + if (options.signal) { + abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), { + signal: options.signal + }) + } + const _fetch = () => - this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest(args, options.headers, options.signal)).then( + this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest(args, options.headers, abortSignal)).then( async res => { await sseResponse(res, options, _fetch) }, @@ -1328,7 +1365,12 @@ export class Indexer implements Indexer { options.onError(error, _fetch) } ) - return _fetch() + + const resp = _fetch() + return { + abort: abortController.abort.bind(abortController), + closed: resp + } } syncBalance = (args: SyncBalanceArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers, signal)).then( @@ -1737,7 +1779,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -1750,7 +1792,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -1763,7 +1805,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -1776,7 +1818,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -1789,7 +1831,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -1802,7 +1844,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -1815,7 +1857,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -1828,7 +1870,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -1841,7 +1883,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -1854,7 +1896,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -1867,7 +1909,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -1882,7 +1924,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -1895,7 +1937,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -1908,7 +1950,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -1921,7 +1963,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -1934,7 +1976,7 @@ export class RequestConflictError extends WebrpcError { constructor( name: string = 'RequestConflict', code: number = 1004, - message: string = 'Conflict with target resource', + message: string = `Conflict with target resource`, status: number = 0, cause?: string ) { @@ -1947,7 +1989,7 @@ export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', code: number = 1005, - message: string = 'Request aborted', + message: string = `Request aborted`, status: number = 0, cause?: string ) { @@ -1960,7 +2002,7 @@ export class GeoblockedError extends WebrpcError { constructor( name: string = 'Geoblocked', code: number = 1006, - message: string = 'Geoblocked region', + message: string = `Geoblocked region`, status: number = 0, cause?: string ) { @@ -1973,7 +2015,7 @@ export class RateLimitedError extends WebrpcError { constructor( name: string = 'RateLimited', code: number = 1007, - message: string = 'Rate-limited. Please slow down.', + message: string = `Rate-limited. Please slow down.`, status: number = 0, cause?: string ) { @@ -1986,7 +2028,7 @@ export class ProjectNotFoundError extends WebrpcError { constructor( name: string = 'ProjectNotFound', code: number = 1100, - message: string = 'Project not found', + message: string = `Project not found`, status: number = 0, cause?: string ) { @@ -1999,7 +2041,7 @@ export class AccessKeyNotFoundError extends WebrpcError { constructor( name: string = 'AccessKeyNotFound', code: number = 1101, - message: string = 'Access key not found', + message: string = `Access key not found`, status: number = 0, cause?: string ) { @@ -2012,7 +2054,7 @@ export class AccessKeyMismatchError extends WebrpcError { constructor( name: string = 'AccessKeyMismatch', code: number = 1102, - message: string = 'Access key mismatch', + message: string = `Access key mismatch`, status: number = 0, cause?: string ) { @@ -2025,7 +2067,7 @@ export class InvalidOriginError extends WebrpcError { constructor( name: string = 'InvalidOrigin', code: number = 1103, - message: string = 'Invalid origin for Access Key', + message: string = `Invalid origin for Access Key`, status: number = 0, cause?: string ) { @@ -2038,7 +2080,7 @@ export class InvalidServiceError extends WebrpcError { constructor( name: string = 'InvalidService', code: number = 1104, - message: string = 'Service not enabled for Access key', + message: string = `Service not enabled for Access key`, status: number = 0, cause?: string ) { @@ -2051,7 +2093,7 @@ export class UnauthorizedUserError extends WebrpcError { constructor( name: string = 'UnauthorizedUser', code: number = 1105, - message: string = 'Unauthorized user', + message: string = `Unauthorized user`, status: number = 0, cause?: string ) { @@ -2064,7 +2106,7 @@ export class QuotaExceededError extends WebrpcError { constructor( name: string = 'QuotaExceeded', code: number = 1200, - message: string = 'Quota exceeded', + message: string = `Quota exceeded`, status: number = 0, cause?: string ) { @@ -2077,7 +2119,7 @@ export class RateLimitError extends WebrpcError { constructor( name: string = 'RateLimit', code: number = 1201, - message: string = 'Rate limit exceeded', + message: string = `Rate limit exceeded`, status: number = 0, cause?: string ) { @@ -2090,7 +2132,7 @@ export class NoDefaultKeyError extends WebrpcError { constructor( name: string = 'NoDefaultKey', code: number = 1300, - message: string = 'No default access key found', + message: string = `No default access key found`, status: number = 0, cause?: string ) { @@ -2103,7 +2145,7 @@ export class MaxAccessKeysError extends WebrpcError { constructor( name: string = 'MaxAccessKeys', code: number = 1301, - message: string = 'Access keys limit reached', + message: string = `Access keys limit reached`, status: number = 0, cause?: string ) { @@ -2116,7 +2158,7 @@ export class AtLeastOneKeyError extends WebrpcError { constructor( name: string = 'AtLeastOneKey', code: number = 1302, - message: string = 'You need at least one Access Key', + message: string = `You need at least one Access Key`, status: number = 0, cause?: string ) { @@ -2129,7 +2171,7 @@ export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', code: number = 1900, - message: string = 'Request timed out', + message: string = `Request timed out`, status: number = 0, cause?: string ) { @@ -2142,7 +2184,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2001, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -2155,7 +2197,7 @@ export class UnavailableError extends WebrpcError { constructor( name: string = 'Unavailable', code: number = 2002, - message: string = 'Unavailable resource', + message: string = `Unavailable resource`, status: number = 0, cause?: string ) { @@ -2168,7 +2210,7 @@ export class QueryFailedError extends WebrpcError { constructor( name: string = 'QueryFailed', code: number = 2003, - message: string = 'Query failed', + message: string = `Query failed`, status: number = 0, cause?: string ) { @@ -2181,7 +2223,7 @@ export class ResourceExhaustedError extends WebrpcError { constructor( name: string = 'ResourceExhausted', code: number = 2004, - message: string = 'Resource exhausted', + message: string = `Resource exhausted`, status: number = 0, cause?: string ) { @@ -2194,7 +2236,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { @@ -2207,7 +2249,7 @@ export class MetadataCallFailedError extends WebrpcError { constructor( name: string = 'MetadataCallFailed', code: number = 3003, - message: string = 'Metadata service call failed', + message: string = `Metadata service call failed`, status: number = 0, cause?: string ) { @@ -2256,7 +2298,47 @@ export enum errors { MetadataCallFailed = 'MetadataCallFailed' } -const webrpcErrorByCode: { [code: number]: any } = { +export enum WebrpcErrorCodes { + WebrpcEndpoint = 0, + WebrpcRequestFailed = -1, + WebrpcBadRoute = -2, + WebrpcBadMethod = -3, + WebrpcBadRequest = -4, + WebrpcBadResponse = -5, + WebrpcServerPanic = -6, + WebrpcInternalError = -7, + WebrpcClientDisconnected = -8, + WebrpcStreamLost = -9, + WebrpcStreamFinished = -10, + Unauthorized = 1000, + PermissionDenied = 1001, + SessionExpired = 1002, + MethodNotFound = 1003, + RequestConflict = 1004, + Aborted = 1005, + Geoblocked = 1006, + RateLimited = 1007, + ProjectNotFound = 1100, + AccessKeyNotFound = 1101, + AccessKeyMismatch = 1102, + InvalidOrigin = 1103, + InvalidService = 1104, + UnauthorizedUser = 1105, + QuotaExceeded = 1200, + RateLimit = 1201, + NoDefaultKey = 1300, + MaxAccessKeys = 1301, + AtLeastOneKey = 1302, + Timeout = 1900, + InvalidArgument = 2001, + Unavailable = 2002, + QueryFailed = 2003, + ResourceExhausted = 2004, + NotFound = 3000, + MetadataCallFailed = 3003 +} + +export const webrpcErrorByCode: { [code: number]: any } = { [0]: WebrpcEndpointError, [-1]: WebrpcRequestFailedError, [-2]: WebrpcBadRouteError, @@ -2304,7 +2386,13 @@ export interface WebrpcStreamOptions extends WebrpcOptions { onOpen?: () => void onClose?: () => void } + export interface WebrpcOptions { headers?: HeadersInit signal?: AbortSignal } + +export interface WebrpcStreamController { + abort: (reason?: any) => void + closed: Promise +} diff --git a/packages/indexer/src/indexergw.gen.ts b/packages/indexer/src/indexergw.gen.ts index 91928e1908..4be18f9307 100644 --- a/packages/indexer/src/indexergw.gen.ts +++ b/packages/indexer/src/indexergw.gen.ts @@ -1,13 +1,13 @@ /* eslint-disable */ -// sequence-indexer v0.4.0 5be4a3e78d9c7e0cc378c675ec01c518e83772e3 +// sequence-indexer v0.4.0 547aa38f8a894ee48678bc9d02ef5f17d2df91ab // -- -// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.24.0 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=indexer.ridl -service=IndexerGateway -target=typescript -client -out=./clients/indexergw.gen.ts export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0' +export const WebrpcHeaderValue = 'webrpc@v0.24.0;gen-typescript@v0.16.3;sequence-indexer@v0.4.0' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -16,7 +16,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.4.0' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '5be4a3e78d9c7e0cc378c675ec01c518e83772e3' +export const WebRPCSchemaHash = '547aa38f8a894ee48678bc9d02ef5f17d2df91ab' type WebrpcGenVersions = { webrpcGenVersion: string @@ -53,16 +53,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -72,14 +72,13 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { export enum ResourceStatus { NOT_AVAILABLE = 'NOT_AVAILABLE', - REFRESHING = 'REFRESHING', + STALE = 'STALE', AVAILABLE = 'AVAILABLE' } export interface ContractInfo { chainId: number address: string - source: string name: string type: string symbol: string @@ -89,6 +88,7 @@ export interface ContractInfo { bytecodeHash: string extensions: ContractInfoExtensions updatedAt: string + notFound: boolean queuedAt?: string status: ResourceStatus } @@ -105,13 +105,10 @@ export interface ContractInfoExtensions { verified: boolean verifiedBy: string featured: boolean - featureIndex: number } export interface TokenMetadata { - contractAddress?: string tokenId: string - source: string name: string description?: string image?: string @@ -389,6 +386,7 @@ export interface OrderbookOrder { export interface OrderbookOrderFilter { isListing?: boolean userAddresses?: Array + orderIds: Array tokenIds: Array excludeUserAddresses?: Array afterBlockNumber: number @@ -540,7 +538,6 @@ export interface MetadataOptions { export interface TokenBalancesFilter { accountAddresses: Array contractStatus?: ContractVerificationStatus - contractTypes?: Array contractWhitelist?: Array contractBlacklist?: Array omitNativeBalances: boolean @@ -607,7 +604,6 @@ export interface IndexerGateway { export interface GetNativeTokenBalanceArgs { chainIds?: Array networks?: Array - testnets?: boolean accountAddress?: string } @@ -617,7 +613,6 @@ export interface GetNativeTokenBalanceReturn { export interface GetTokenBalancesArgs { chainIds?: Array networks?: Array - testnets?: boolean accountAddress?: string contractAddress?: string tokenID?: string @@ -634,7 +629,6 @@ export interface GetTokenBalancesReturn { export interface GetTokenBalancesSummaryArgs { chainIds?: Array networks?: Array - testnets?: boolean filter: TokenBalancesFilter omitMetadata?: boolean page?: Page @@ -648,7 +642,6 @@ export interface GetTokenBalancesSummaryReturn { export interface GetTokenBalancesDetailsArgs { chainIds?: Array networks?: Array - testnets?: boolean filter: TokenBalancesFilter omitMetadata?: boolean page?: Page @@ -662,7 +655,6 @@ export interface GetTokenBalancesDetailsReturn { export interface GetTokenBalancesByContractArgs { chainIds?: Array networks?: Array - testnets?: boolean filter: TokenBalancesByContractFilter omitMetadata?: boolean page?: Page @@ -675,7 +667,6 @@ export interface GetTokenBalancesByContractReturn { export interface GetBalanceUpdatesArgs { chainIds?: Array networks?: Array - testnets?: boolean contractAddress: string lastBlockNumber: number lastBlockHash?: string @@ -949,7 +940,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -962,7 +953,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -975,7 +966,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -988,7 +979,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -1001,7 +992,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -1014,7 +1005,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -1027,7 +1018,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -1040,7 +1031,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -1053,7 +1044,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -1066,7 +1057,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -1079,7 +1070,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -1094,7 +1085,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -1107,7 +1098,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -1120,7 +1111,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -1133,7 +1124,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -1146,7 +1137,7 @@ export class RequestConflictError extends WebrpcError { constructor( name: string = 'RequestConflict', code: number = 1004, - message: string = 'Conflict with target resource', + message: string = `Conflict with target resource`, status: number = 0, cause?: string ) { @@ -1159,7 +1150,7 @@ export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', code: number = 1005, - message: string = 'Request aborted', + message: string = `Request aborted`, status: number = 0, cause?: string ) { @@ -1172,7 +1163,7 @@ export class GeoblockedError extends WebrpcError { constructor( name: string = 'Geoblocked', code: number = 1006, - message: string = 'Geoblocked region', + message: string = `Geoblocked region`, status: number = 0, cause?: string ) { @@ -1185,7 +1176,7 @@ export class RateLimitedError extends WebrpcError { constructor( name: string = 'RateLimited', code: number = 1007, - message: string = 'Rate-limited. Please slow down.', + message: string = `Rate-limited. Please slow down.`, status: number = 0, cause?: string ) { @@ -1198,7 +1189,7 @@ export class ProjectNotFoundError extends WebrpcError { constructor( name: string = 'ProjectNotFound', code: number = 1100, - message: string = 'Project not found', + message: string = `Project not found`, status: number = 0, cause?: string ) { @@ -1211,7 +1202,7 @@ export class AccessKeyNotFoundError extends WebrpcError { constructor( name: string = 'AccessKeyNotFound', code: number = 1101, - message: string = 'Access key not found', + message: string = `Access key not found`, status: number = 0, cause?: string ) { @@ -1224,7 +1215,7 @@ export class AccessKeyMismatchError extends WebrpcError { constructor( name: string = 'AccessKeyMismatch', code: number = 1102, - message: string = 'Access key mismatch', + message: string = `Access key mismatch`, status: number = 0, cause?: string ) { @@ -1237,7 +1228,7 @@ export class InvalidOriginError extends WebrpcError { constructor( name: string = 'InvalidOrigin', code: number = 1103, - message: string = 'Invalid origin for Access Key', + message: string = `Invalid origin for Access Key`, status: number = 0, cause?: string ) { @@ -1250,7 +1241,7 @@ export class InvalidServiceError extends WebrpcError { constructor( name: string = 'InvalidService', code: number = 1104, - message: string = 'Service not enabled for Access key', + message: string = `Service not enabled for Access key`, status: number = 0, cause?: string ) { @@ -1263,7 +1254,7 @@ export class UnauthorizedUserError extends WebrpcError { constructor( name: string = 'UnauthorizedUser', code: number = 1105, - message: string = 'Unauthorized user', + message: string = `Unauthorized user`, status: number = 0, cause?: string ) { @@ -1276,7 +1267,7 @@ export class QuotaExceededError extends WebrpcError { constructor( name: string = 'QuotaExceeded', code: number = 1200, - message: string = 'Quota exceeded', + message: string = `Quota exceeded`, status: number = 0, cause?: string ) { @@ -1289,7 +1280,7 @@ export class RateLimitError extends WebrpcError { constructor( name: string = 'RateLimit', code: number = 1201, - message: string = 'Rate limit exceeded', + message: string = `Rate limit exceeded`, status: number = 0, cause?: string ) { @@ -1302,7 +1293,7 @@ export class NoDefaultKeyError extends WebrpcError { constructor( name: string = 'NoDefaultKey', code: number = 1300, - message: string = 'No default access key found', + message: string = `No default access key found`, status: number = 0, cause?: string ) { @@ -1315,7 +1306,7 @@ export class MaxAccessKeysError extends WebrpcError { constructor( name: string = 'MaxAccessKeys', code: number = 1301, - message: string = 'Access keys limit reached', + message: string = `Access keys limit reached`, status: number = 0, cause?: string ) { @@ -1328,7 +1319,7 @@ export class AtLeastOneKeyError extends WebrpcError { constructor( name: string = 'AtLeastOneKey', code: number = 1302, - message: string = 'You need at least one Access Key', + message: string = `You need at least one Access Key`, status: number = 0, cause?: string ) { @@ -1341,7 +1332,7 @@ export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', code: number = 1900, - message: string = 'Request timed out', + message: string = `Request timed out`, status: number = 0, cause?: string ) { @@ -1354,7 +1345,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2001, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -1367,7 +1358,7 @@ export class UnavailableError extends WebrpcError { constructor( name: string = 'Unavailable', code: number = 2002, - message: string = 'Unavailable resource', + message: string = `Unavailable resource`, status: number = 0, cause?: string ) { @@ -1380,7 +1371,7 @@ export class QueryFailedError extends WebrpcError { constructor( name: string = 'QueryFailed', code: number = 2003, - message: string = 'Query failed', + message: string = `Query failed`, status: number = 0, cause?: string ) { @@ -1393,7 +1384,7 @@ export class ResourceExhaustedError extends WebrpcError { constructor( name: string = 'ResourceExhausted', code: number = 2004, - message: string = 'Resource exhausted', + message: string = `Resource exhausted`, status: number = 0, cause?: string ) { @@ -1406,7 +1397,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { @@ -1419,7 +1410,7 @@ export class MetadataCallFailedError extends WebrpcError { constructor( name: string = 'MetadataCallFailed', code: number = 3003, - message: string = 'Metadata service call failed', + message: string = `Metadata service call failed`, status: number = 0, cause?: string ) { @@ -1468,7 +1459,47 @@ export enum errors { MetadataCallFailed = 'MetadataCallFailed' } -const webrpcErrorByCode: { [code: number]: any } = { +export enum WebrpcErrorCodes { + WebrpcEndpoint = 0, + WebrpcRequestFailed = -1, + WebrpcBadRoute = -2, + WebrpcBadMethod = -3, + WebrpcBadRequest = -4, + WebrpcBadResponse = -5, + WebrpcServerPanic = -6, + WebrpcInternalError = -7, + WebrpcClientDisconnected = -8, + WebrpcStreamLost = -9, + WebrpcStreamFinished = -10, + Unauthorized = 1000, + PermissionDenied = 1001, + SessionExpired = 1002, + MethodNotFound = 1003, + RequestConflict = 1004, + Aborted = 1005, + Geoblocked = 1006, + RateLimited = 1007, + ProjectNotFound = 1100, + AccessKeyNotFound = 1101, + AccessKeyMismatch = 1102, + InvalidOrigin = 1103, + InvalidService = 1104, + UnauthorizedUser = 1105, + QuotaExceeded = 1200, + RateLimit = 1201, + NoDefaultKey = 1300, + MaxAccessKeys = 1301, + AtLeastOneKey = 1302, + Timeout = 1900, + InvalidArgument = 2001, + Unavailable = 2002, + QueryFailed = 2003, + ResourceExhausted = 2004, + NotFound = 3000, + MetadataCallFailed = 3003 +} + +export const webrpcErrorByCode: { [code: number]: any } = { [0]: WebrpcEndpointError, [-1]: WebrpcRequestFailedError, [-2]: WebrpcBadRouteError,