@0xsequence/indexer
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -875,13 +875,13 @@ 'use strict'; | ||
const WebrpcHeader = "Webrpc"; | ||
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0"; | ||
const WebrpcHeader = 'Webrpc'; | ||
const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0'; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = "v1"; | ||
const WebRPCVersion = 'v1'; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = "v0.4.0"; | ||
const WebRPCSchemaVersion = 'v0.4.0'; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc"; | ||
const WebRPCSchemaHash = '71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc'; | ||
function VersionFromHeader(headers) { | ||
@@ -891,7 +891,7 @@ const headerValue = headers.get(WebrpcHeader); | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
}; | ||
@@ -902,15 +902,15 @@ } | ||
function parseWebrpcGenVersions(header) { | ||
const versions = header.split(";"); | ||
const versions = header.split(';'); | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
}; | ||
} | ||
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 { | ||
@@ -917,0 +917,0 @@ webrpcGenVersion, |
@@ -875,13 +875,13 @@ 'use strict'; | ||
const WebrpcHeader = "Webrpc"; | ||
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0"; | ||
const WebrpcHeader = 'Webrpc'; | ||
const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0'; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = "v1"; | ||
const WebRPCVersion = 'v1'; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = "v0.4.0"; | ||
const WebRPCSchemaVersion = 'v0.4.0'; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc"; | ||
const WebRPCSchemaHash = '71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc'; | ||
function VersionFromHeader(headers) { | ||
@@ -891,7 +891,7 @@ const headerValue = headers.get(WebrpcHeader); | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
}; | ||
@@ -902,15 +902,15 @@ } | ||
function parseWebrpcGenVersions(header) { | ||
const versions = header.split(";"); | ||
const versions = header.split(';'); | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
}; | ||
} | ||
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 { | ||
@@ -917,0 +917,0 @@ webrpcGenVersion, |
@@ -871,13 +871,13 @@ function _extends() { | ||
const WebrpcHeader = "Webrpc"; | ||
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0"; | ||
const WebrpcHeader = 'Webrpc'; | ||
const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0'; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = "v1"; | ||
const WebRPCVersion = 'v1'; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = "v0.4.0"; | ||
const WebRPCSchemaVersion = 'v0.4.0'; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc"; | ||
const WebRPCSchemaHash = '71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc'; | ||
function VersionFromHeader(headers) { | ||
@@ -887,7 +887,7 @@ const headerValue = headers.get(WebrpcHeader); | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
}; | ||
@@ -898,15 +898,15 @@ } | ||
function parseWebrpcGenVersions(header) { | ||
const versions = header.split(";"); | ||
const versions = header.split(';'); | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
}; | ||
} | ||
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 { | ||
@@ -913,0 +913,0 @@ webrpcGenVersion, |
{ | ||
"name": "@0xsequence/indexer", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "indexer sub-package for Sequence", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexer", |
@@ -8,53 +8,53 @@ /* eslint-disable */ | ||
export const WebrpcHeader = "Webrpc" | ||
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.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0' | ||
// WebRPC description and code-gen version | ||
export const WebRPCVersion = "v1" | ||
export const WebRPCVersion = 'v1' | ||
// Schema version of your RIDL schema | ||
export const WebRPCSchemaVersion = "v0.4.0" | ||
export const WebRPCSchemaVersion = 'v0.4.0' | ||
// Schema hash generated from your RIDL schema | ||
export const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc" | ||
export const WebRPCSchemaHash = '71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc' | ||
type WebrpcGenVersions = { | ||
webrpcGenVersion: string; | ||
codeGenName: string; | ||
codeGenVersion: string; | ||
schemaName: string; | ||
schemaVersion: string; | ||
}; | ||
webrpcGenVersion: string | ||
codeGenName: string | ||
codeGenVersion: string | ||
schemaName: string | ||
schemaVersion: string | ||
} | ||
export function VersionFromHeader(headers: Headers): WebrpcGenVersions { | ||
const headerValue = headers.get(WebrpcHeader); | ||
const headerValue = headers.get(WebrpcHeader) | ||
if (!headerValue) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "", | ||
}; | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
} | ||
} | ||
return parseWebrpcGenVersions(headerValue); | ||
return parseWebrpcGenVersions(headerValue) | ||
} | ||
function parseWebrpcGenVersions(header: string): WebrpcGenVersions { | ||
const versions = header.split(";"); | ||
const versions = header.split(';') | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "", | ||
}; | ||
webrpcGenVersion: '', | ||
codeGenName: '', | ||
codeGenVersion: '', | ||
schemaName: '', | ||
schemaVersion: '' | ||
} | ||
} | ||
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('@') | ||
@@ -66,4 +66,4 @@ return { | ||
schemaName, | ||
schemaVersion, | ||
}; | ||
schemaVersion | ||
} | ||
} | ||
@@ -75,3 +75,2 @@ | ||
export interface ContractInfo { | ||
@@ -110,4 +109,4 @@ chainId: number | ||
audio?: string | ||
properties?: {[key: string]: any} | ||
attributes: Array<{[key: string]: any}> | ||
properties?: { [key: string]: any } | ||
attributes: Array<{ [key: string]: any }> | ||
image_data?: string | ||
@@ -245,3 +244,3 @@ external_url?: string | ||
percent: number | ||
dirs: {[key: string]: string} | ||
dirs: { [key: string]: string } | ||
} | ||
@@ -311,3 +310,3 @@ | ||
txnInfo?: TxnInfo | ||
rawLog?: {[key: string]: any} | ||
rawLog?: { [key: string]: any } | ||
event?: EventDecoded | ||
@@ -413,3 +412,3 @@ } | ||
contractInfo?: ContractInfo | ||
tokenMetadata?: {[key: string]: TokenMetadata} | ||
tokenMetadata?: { [key: string]: TokenMetadata } | ||
} | ||
@@ -540,7 +539,23 @@ | ||
export interface IndexerGateway { | ||
getNativeTokenBalance(args: GetNativeTokenBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetNativeTokenBalanceReturn> | ||
getNativeTokenBalance( | ||
args: GetNativeTokenBalanceArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetNativeTokenBalanceReturn> | ||
getTokenBalances(args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn> | ||
getTokenBalancesSummary(args: GetTokenBalancesSummaryArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesSummaryReturn> | ||
getTokenBalancesDetails(args: GetTokenBalancesDetailsArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesDetailsReturn> | ||
getTokenBalancesByContract(args: GetTokenBalancesByContractArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesByContractReturn> | ||
getTokenBalancesSummary( | ||
args: GetTokenBalancesSummaryArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesSummaryReturn> | ||
getTokenBalancesDetails( | ||
args: GetTokenBalancesDetailsArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesDetailsReturn> | ||
getTokenBalancesByContract( | ||
args: GetTokenBalancesByContractArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesByContractReturn> | ||
getBalanceUpdates(args: GetBalanceUpdatesArgs, headers?: object, signal?: AbortSignal): Promise<GetBalanceUpdatesReturn> | ||
@@ -558,3 +573,3 @@ ping(headers?: object, signal?: AbortSignal): Promise<PingReturn> | ||
export interface GetNativeTokenBalanceReturn { | ||
balances: Array<GatewayNativeTokenBalance> | ||
balances: Array<GatewayNativeTokenBalance> | ||
} | ||
@@ -574,3 +589,3 @@ export interface GetTokenBalancesArgs { | ||
page: Page | ||
balances: Array<GatewayTokenBalance> | ||
balances: Array<GatewayTokenBalance> | ||
} | ||
@@ -586,3 +601,3 @@ export interface GetTokenBalancesSummaryArgs { | ||
page: Page | ||
balances: Array<GatewayTokenBalance> | ||
balances: Array<GatewayTokenBalance> | ||
} | ||
@@ -598,3 +613,3 @@ export interface GetTokenBalancesDetailsArgs { | ||
page: Page | ||
balances: Array<GatewayTokenBalance> | ||
balances: Array<GatewayTokenBalance> | ||
} | ||
@@ -610,3 +625,3 @@ export interface GetTokenBalancesByContractArgs { | ||
page: Page | ||
balances: Array<GatewayTokenBalance> | ||
balances: Array<GatewayTokenBalance> | ||
} | ||
@@ -623,25 +638,20 @@ export interface GetBalanceUpdatesArgs { | ||
page: Page | ||
balances: Array<GatewayTokenBalance> | ||
balances: Array<GatewayTokenBalance> | ||
} | ||
export interface PingArgs { | ||
} | ||
export interface PingArgs {} | ||
export interface PingReturn { | ||
status: boolean | ||
status: boolean | ||
} | ||
export interface VersionArgs { | ||
} | ||
export interface VersionArgs {} | ||
export interface VersionReturn { | ||
version: Version | ||
version: Version | ||
} | ||
export interface RuntimeStatusArgs { | ||
} | ||
export interface RuntimeStatusArgs {} | ||
export interface RuntimeStatusReturn { | ||
status: RuntimeStatus | ||
status: RuntimeStatus | ||
} | ||
// | ||
@@ -663,141 +673,162 @@ // Client | ||
} | ||
getNativeTokenBalance = (args: GetNativeTokenBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetNativeTokenBalanceReturn> => { | ||
return this.fetch( | ||
this.url('GetNativeTokenBalance'), | ||
createHTTPRequest(args, headers, signal)).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balances: <Array<GatewayNativeTokenBalance>>(_data.balances), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
getNativeTokenBalance = ( | ||
args: GetNativeTokenBalanceArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetNativeTokenBalanceReturn> => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balances: <Array<GatewayNativeTokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalances = (args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn> => { | ||
return this.fetch( | ||
this.url('GetTokenBalances'), | ||
createHTTPRequest(args, headers, signal)).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>(_data.page), | ||
balances: <Array<GatewayTokenBalance>>(_data.balances), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<GatewayTokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalancesSummary = (args: GetTokenBalancesSummaryArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesSummaryReturn> => { | ||
return this.fetch( | ||
this.url('GetTokenBalancesSummary'), | ||
createHTTPRequest(args, headers, signal)).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>(_data.page), | ||
balances: <Array<GatewayTokenBalance>>(_data.balances), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
getTokenBalancesSummary = ( | ||
args: GetTokenBalancesSummaryArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesSummaryReturn> => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<GatewayTokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalancesDetails = (args: GetTokenBalancesDetailsArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesDetailsReturn> => { | ||
return this.fetch( | ||
this.url('GetTokenBalancesDetails'), | ||
createHTTPRequest(args, headers, signal)).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>(_data.page), | ||
balances: <Array<GatewayTokenBalance>>(_data.balances), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
getTokenBalancesDetails = ( | ||
args: GetTokenBalancesDetailsArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesDetailsReturn> => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<GatewayTokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalancesByContract = (args: GetTokenBalancesByContractArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesByContractReturn> => { | ||
return this.fetch( | ||
this.url('GetTokenBalancesByContract'), | ||
createHTTPRequest(args, headers, signal)).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>(_data.page), | ||
balances: <Array<GatewayTokenBalance>>(_data.balances), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
getTokenBalancesByContract = ( | ||
args: GetTokenBalancesByContractArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesByContractReturn> => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<GatewayTokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getBalanceUpdates = (args: GetBalanceUpdatesArgs, headers?: object, signal?: AbortSignal): Promise<GetBalanceUpdatesReturn> => { | ||
return this.fetch( | ||
this.url('GetBalanceUpdates'), | ||
createHTTPRequest(args, headers, signal)).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>(_data.page), | ||
balances: <Array<GatewayTokenBalance>>(_data.balances), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<GatewayTokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
ping = (headers?: object, signal?: AbortSignal): Promise<PingReturn> => { | ||
return this.fetch( | ||
this.url('Ping'), | ||
createHTTPRequest({}, headers, signal) | ||
).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: <boolean>(_data.status), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: <boolean>_data.status | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
version = (headers?: object, signal?: AbortSignal): Promise<VersionReturn> => { | ||
return this.fetch( | ||
this.url('Version'), | ||
createHTTPRequest({}, headers, signal) | ||
).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
version: <Version>(_data.version), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
version: <Version>_data.version | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn> => { | ||
return this.fetch( | ||
this.url('RuntimeStatus'), | ||
createHTTPRequest({}, headers, signal) | ||
).then((res) => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: <RuntimeStatus>(_data.status), | ||
} | ||
}) | ||
}, (error) => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
}) | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: <RuntimeStatus>_data.status | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
} | ||
const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { | ||
const reqHeaders: {[key: string]: string} = { ...headers, 'Content-Type': 'application/json' } | ||
const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { | ||
const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' } | ||
reqHeaders[WebrpcHeader] = WebrpcHeaderValue | ||
@@ -818,5 +849,5 @@ | ||
data = JSON.parse(text) | ||
} catch(error) { | ||
} catch (error) { | ||
let message = '' | ||
if (error instanceof Error) { | ||
if (error instanceof Error) { | ||
message = error.message | ||
@@ -826,7 +857,7 @@ } | ||
status: res.status, | ||
cause: `JSON.parse(): ${message}: response text: ${text}`}, | ||
) | ||
cause: `JSON.parse(): ${message}: response text: ${text}` | ||
}) | ||
} | ||
if (!res.ok) { | ||
const code: number = (typeof data.code === 'number') ? data.code : 0 | ||
const code: number = typeof data.code === 'number' ? data.code : 0 | ||
throw (webrpcErrorByCode[code] || WebrpcError).new(data) | ||
@@ -1013,3 +1044,2 @@ } | ||
// Schema errors | ||
@@ -1355,3 +1385,2 @@ | ||
export enum errors { | ||
@@ -1394,3 +1423,3 @@ WebrpcEndpoint = 'WebrpcEndpoint', | ||
NotFound = 'NotFound', | ||
MetadataCallFailed = 'MetadataCallFailed', | ||
MetadataCallFailed = 'MetadataCallFailed' | ||
} | ||
@@ -1435,6 +1464,5 @@ | ||
[3000]: NotFoundError, | ||
[3003]: MetadataCallFailedError, | ||
[3003]: MetadataCallFailedError | ||
} | ||
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response> | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
335745
9470