mirror of
https://github.com/FlipsideCrypto/sdk.git
synced 2026-02-06 10:46:43 +00:00
Add tests
This commit is contained in:
parent
7c0ceb89af
commit
1966ea1391
@ -1,6 +1,7 @@
|
||||
import axios, { AxiosError, AxiosResponse } from "axios";
|
||||
import { ServerError, UnexpectedSDKError, UserError } from "./errors";
|
||||
import {
|
||||
CompassApiClient,
|
||||
CreateQueryRunRpcParams,
|
||||
CreateQueryRunRpcRequestImplementation,
|
||||
CreateQueryRunRpcResponse,
|
||||
@ -25,7 +26,7 @@ import {
|
||||
|
||||
const PARSE_ERROR_MSG = "the api returned an error and there was a fatal client side error parsing that error msg";
|
||||
|
||||
export class Api {
|
||||
export class Api implements CompassApiClient {
|
||||
url: string;
|
||||
#baseUrl: string;
|
||||
#headers: Record<string, string>;
|
||||
|
||||
@ -6,4 +6,5 @@ export const ERROR_TYPES = {
|
||||
query_run_timeout_error: "QUERY_RUN_TIMEOUT_ERROR",
|
||||
query_run_execution_error: "QUERY_RUN_EXECUTION_ERROR",
|
||||
user_error: "USER_ERROR",
|
||||
api_error: "API_ERROR",
|
||||
};
|
||||
|
||||
@ -12,6 +12,7 @@ import {
|
||||
QueryRun,
|
||||
ResultFormat,
|
||||
SqlStatement,
|
||||
CompassApiClient,
|
||||
} from "../../types";
|
||||
import { getElapsedLinearSeconds, linearBackOff } from "../../utils/sleep";
|
||||
import {
|
||||
@ -27,9 +28,9 @@ import { Api } from "../../api";
|
||||
import { DEFAULTS } from "../../defaults";
|
||||
|
||||
export class QueryIntegration {
|
||||
#api: Api;
|
||||
#api: CompassApiClient;
|
||||
|
||||
constructor(api: Api) {
|
||||
constructor(api: CompassApiClient) {
|
||||
this.#api = api;
|
||||
}
|
||||
|
||||
|
||||
@ -2,26 +2,23 @@ import { Flipside } from "../flipside";
|
||||
import { Query, QueryResultSet } from "../types";
|
||||
|
||||
const runIt = async (): Promise<void> => {
|
||||
// Initialize `Flipside` with your API key
|
||||
const flipside = new Flipside(
|
||||
"api-key-here",
|
||||
"https://api.flipsidecrypto.com",
|
||||
);
|
||||
// Initialize `Flipside` with your API key
|
||||
const flipside = new Flipside("api-key-here", "https://api-v2.flipsidecrypto.xyz");
|
||||
|
||||
// Create a query object for the `query.run` function to execute
|
||||
const query: Query = {
|
||||
sql: "select nft_address, mint_price_eth, mint_price_usd from flipside_prod_db.ethereum_core.ez_nft_mints limit 100",
|
||||
ttlMinutes: 10,
|
||||
pageSize: 100,
|
||||
pageNumber: 1
|
||||
};
|
||||
// Create a query object for the `query.run` function to execute
|
||||
const query: Query = {
|
||||
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.core.ez_nft_mints limit 100",
|
||||
ttlMinutes: 10,
|
||||
pageSize: 100,
|
||||
pageNumber: 1,
|
||||
};
|
||||
|
||||
// Send the `Query` to Flipside's query engine and await the results
|
||||
const result: QueryResultSet = await flipside.query.run(query);
|
||||
// Send the `Query` to Flipside's query engine and await the results
|
||||
const result: QueryResultSet = await flipside.query.run(query);
|
||||
|
||||
if (!result || !result.records) throw "null result";
|
||||
if (!result || !result.records) throw "null result";
|
||||
|
||||
console.log(result);
|
||||
console.log(result);
|
||||
};
|
||||
|
||||
runIt();
|
||||
runIt();
|
||||
|
||||
61
js/src/tests/mock-data/cancel-query-run.ts
Normal file
61
js/src/tests/mock-data/cancel-query-run.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import { QueryStatus, RpcError, CancelQueryRunRpcResponse, mapApiQueryStateToStatus } from "../../../src/types";
|
||||
|
||||
export function cancelQueryRunResponse(
|
||||
status: string = "QUERY_STATE_SUCCESS",
|
||||
error: RpcError | null = null
|
||||
): CancelQueryRunRpcResponse {
|
||||
let base: CancelQueryRunRpcResponse = {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
error: null,
|
||||
result: null,
|
||||
};
|
||||
|
||||
const defaultResult = {
|
||||
queryRun: {
|
||||
id: "clg44olzq00cbn60tasvob5l2",
|
||||
sqlStatementId: "clg44oly200c9n60tviq17sng",
|
||||
state: status,
|
||||
path: "2023/04/05/20/clg44olzq00cbn60tasvob5l2",
|
||||
fileCount: 1,
|
||||
lastFileNumber: 1,
|
||||
fileNames: "clg44olzq00cbn60tasvob5l2-consolidated-results.parquet",
|
||||
errorName: null,
|
||||
errorMessage: null,
|
||||
errorData: null,
|
||||
dataSourceQueryId: null,
|
||||
dataSourceSessionId: "17257398387030526",
|
||||
startedAt: "2023-04-05T20:14:55.000Z",
|
||||
queryRunningEndedAt: "2023-04-05T20:15:00.000Z",
|
||||
queryStreamingEndedAt: "2023-04-05T20:15:45.000Z",
|
||||
endedAt: "2023-04-05T20:15:46.000Z",
|
||||
rowCount: 10000,
|
||||
totalSize: 24904891,
|
||||
tags: {
|
||||
sdk_package: "js",
|
||||
sdk_version: "1.0.0",
|
||||
sdk_language: "javascript",
|
||||
},
|
||||
dataSourceId: "clf90gwee0002jvbu63diaa8u",
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
createdAt: "2023-04-05T20:14:55.000Z",
|
||||
updatedAt: "2023-04-05T20:14:55.000Z",
|
||||
archivedAt: "2023-04-05T20:14:55.000Z",
|
||||
},
|
||||
redirectedToQueryRun: null,
|
||||
};
|
||||
|
||||
if (error !== null) {
|
||||
base = {
|
||||
...base,
|
||||
error: error,
|
||||
};
|
||||
}
|
||||
|
||||
base = {
|
||||
...base,
|
||||
result: defaultResult,
|
||||
};
|
||||
|
||||
return base;
|
||||
}
|
||||
151
js/src/tests/mock-data/create-query-run.ts
Normal file
151
js/src/tests/mock-data/create-query-run.ts
Normal file
@ -0,0 +1,151 @@
|
||||
import {
|
||||
QueryRun,
|
||||
RpcError,
|
||||
mapApiQueryStateToStatus,
|
||||
BaseRpcResponse,
|
||||
CreateQueryRunRpcResponse,
|
||||
} from "../../../src/types";
|
||||
|
||||
export function createQueryRunResponse(
|
||||
status: string = "QUERY_STATE_READY",
|
||||
error: RpcError | null = null,
|
||||
resultNull: boolean = false
|
||||
): CreateQueryRunRpcResponse {
|
||||
let defaultResult = {
|
||||
queryRequest: {
|
||||
id: "clg44na8m00iund0uymg1n60i",
|
||||
sqlStatementId: "clg44k7gt00iind0ul763yjf8",
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
tags: {
|
||||
sdk_package: "js",
|
||||
sdk_version: "1.0.2",
|
||||
sdk_language: "javascript",
|
||||
},
|
||||
maxAgeMinutes: 30,
|
||||
resultTTLHours: 720,
|
||||
userSkipCache: false,
|
||||
triggeredQueryRun: false,
|
||||
queryRunId: "clg44k7ij00iknd0u60y2zfyx",
|
||||
createdAt: "2023-04-05T20:13:53.000Z",
|
||||
updatedAt: "2023-04-05T20:13:53.000Z",
|
||||
},
|
||||
queryRun: {
|
||||
id: "clg44k7ij00iknd0u60y2zfyx",
|
||||
sqlStatementId: "clg44k7gt00iind0ul763yjf8",
|
||||
state: status,
|
||||
path: "2023/04/05/20/clg44k7ij00iknd0u60y2zfyx",
|
||||
fileCount: 1,
|
||||
lastFileNumber: 1,
|
||||
fileNames: "clg44k7ij00iknd0u60y2zfyx-consolidated-results.parquet",
|
||||
errorName: null,
|
||||
errorMessage: null,
|
||||
errorData: null,
|
||||
dataSourceQueryId: null,
|
||||
dataSourceSessionId: "17257398387015434",
|
||||
startedAt: "2023-04-05T20:11:30.000Z",
|
||||
queryRunningEndedAt: "2023-04-05T20:11:46.000Z",
|
||||
queryStreamingEndedAt: "2023-04-05T20:13:16.000Z",
|
||||
endedAt: "2023-04-05T20:13:16.000Z",
|
||||
rowCount: 13000,
|
||||
totalSize: 18412529,
|
||||
tags: {
|
||||
sdk_package: "js",
|
||||
sdk_version: "1.0.2",
|
||||
sdk_language: "javascript",
|
||||
},
|
||||
dataSourceId: "clf90gwee0002jvbu63diaa8u",
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
createdAt: "2023-04-05T20:11:29.000Z",
|
||||
updatedAt: "2023-04-05T20:11:29.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
sqlStatement: {
|
||||
id: "clg44k7gt00iind0ul763yjf8",
|
||||
statementHash: "36aa1767e72b9c9be3d9cfabe8992da861571629b45e57a834a44d6f2aeabf5d",
|
||||
sql: "SELECT * FROM ethereum.core.fact_transactions LIMIT 13000",
|
||||
columnMetadata: {
|
||||
types: [
|
||||
"fixed",
|
||||
"timestamp_ntz",
|
||||
"text",
|
||||
"text",
|
||||
"real",
|
||||
"fixed",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"real",
|
||||
"real",
|
||||
"real",
|
||||
"fixed",
|
||||
"real",
|
||||
"real",
|
||||
"text",
|
||||
"text",
|
||||
"object",
|
||||
],
|
||||
columns: [
|
||||
"BLOCK_NUMBER",
|
||||
"BLOCK_TIMESTAMP",
|
||||
"BLOCK_HASH",
|
||||
"TX_HASH",
|
||||
"NONCE",
|
||||
"POSITION",
|
||||
"ORIGIN_FUNCTION_SIGNATURE",
|
||||
"FROM_ADDRESS",
|
||||
"TO_ADDRESS",
|
||||
"ETH_VALUE",
|
||||
"TX_FEE",
|
||||
"GAS_PRICE",
|
||||
"GAS_LIMIT",
|
||||
"GAS_USED",
|
||||
"CUMULATIVE_GAS_USED",
|
||||
"INPUT_DATA",
|
||||
"STATUS",
|
||||
"TX_JSON",
|
||||
],
|
||||
colTypeMap: {
|
||||
NONCE: "real",
|
||||
STATUS: "text",
|
||||
TX_FEE: "real",
|
||||
TX_HASH: "text",
|
||||
TX_JSON: "object",
|
||||
GAS_USED: "real",
|
||||
POSITION: "fixed",
|
||||
ETH_VALUE: "real",
|
||||
GAS_LIMIT: "fixed",
|
||||
GAS_PRICE: "real",
|
||||
BLOCK_HASH: "text",
|
||||
INPUT_DATA: "text",
|
||||
TO_ADDRESS: "text",
|
||||
BLOCK_NUMBER: "fixed",
|
||||
FROM_ADDRESS: "text",
|
||||
BLOCK_TIMESTAMP: "timestamp_ntz",
|
||||
CUMULATIVE_GAS_USED: "real",
|
||||
ORIGIN_FUNCTION_SIGNATURE: "text",
|
||||
},
|
||||
},
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
tags: {
|
||||
sdk_package: "js",
|
||||
sdk_version: "1.0.2",
|
||||
sdk_language: "javascript",
|
||||
},
|
||||
createdAt: "2023-04-05T20:11:29.000Z",
|
||||
updatedAt: "2023-04-05T20:11:29.000Z",
|
||||
},
|
||||
};
|
||||
|
||||
let base: CreateQueryRunRpcResponse = {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
error: null,
|
||||
result: defaultResult,
|
||||
};
|
||||
|
||||
if (error) {
|
||||
base.error = error;
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
319
js/src/tests/mock-data/get-query-results.ts
Normal file
319
js/src/tests/mock-data/get-query-results.ts
Normal file
@ -0,0 +1,319 @@
|
||||
import {
|
||||
QueryStatus,
|
||||
RpcError,
|
||||
GetQueryRunResultsRpcResponse,
|
||||
ResultFormat,
|
||||
mapApiQueryStateToStatus,
|
||||
} from "../../../src/types";
|
||||
|
||||
export function getQueryResultsResponse(
|
||||
status: string = "QUERY_STATE_READY",
|
||||
error: RpcError | null = null
|
||||
): GetQueryRunResultsRpcResponse {
|
||||
let base: GetQueryRunResultsRpcResponse = {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
error: null,
|
||||
result: null,
|
||||
};
|
||||
|
||||
const defaultData = {
|
||||
columnNames: [
|
||||
"block_number",
|
||||
"block_timestamp",
|
||||
"block_hash",
|
||||
"tx_hash",
|
||||
"nonce",
|
||||
"position",
|
||||
"origin_function_signature",
|
||||
"from_address",
|
||||
"to_address",
|
||||
"eth_value",
|
||||
"tx_fee",
|
||||
"gas_price",
|
||||
"gas_limit",
|
||||
"gas_used",
|
||||
"cumulative_gas_used",
|
||||
"input_data",
|
||||
"status",
|
||||
"tx_json",
|
||||
"__row_index",
|
||||
],
|
||||
columnTypes: [
|
||||
"number",
|
||||
"date",
|
||||
"string",
|
||||
"string",
|
||||
"number",
|
||||
"number",
|
||||
"string",
|
||||
"string",
|
||||
"string",
|
||||
"number",
|
||||
"number",
|
||||
"number",
|
||||
"number",
|
||||
"number",
|
||||
"number",
|
||||
"string",
|
||||
"string",
|
||||
"object",
|
||||
"number",
|
||||
],
|
||||
rows: [
|
||||
[
|
||||
15053521,
|
||||
"2022-07-01T01:03:20.000Z",
|
||||
"0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
"0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
5228,
|
||||
142,
|
||||
"0x2e95b6c8",
|
||||
"0x7303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
"0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
0,
|
||||
0.004411543611,
|
||||
40.571141215,
|
||||
167993,
|
||||
108736,
|
||||
11289236,
|
||||
"0x2e95b6c80000000000000000000000002791bfd60d232150bff86b39b7146c0eaaa2ba81000000000000000000000000000000000000000000001d4d3c9f5487881900000000000000000000000000000000000000000000000000000fb6f5c18351004b0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000140000000000000003b6d03400bec54c89a7d9f15c4e7faa8d47adedf374462ede26b9977",
|
||||
"SUCCESS",
|
||||
{
|
||||
block_hash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
block_number: 15053521,
|
||||
chain_id: null,
|
||||
condition: null,
|
||||
creates: null,
|
||||
from: "0x7303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
gas: 167993,
|
||||
gas_price: 40571141215,
|
||||
hash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
input:
|
||||
"0x2e95b6c80000000000000000000000002791bfd60d232150bff86b39b7146c0eaaa2ba81000000000000000000000000000000000000000000001d4d3c9f5487881900000000000000000000000000000000000000000000000000000fb6f5c18351004b0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000140000000000000003b6d03400bec54c89a7d9f15c4e7faa8d47adedf374462ede26b9977",
|
||||
max_fee_per_gas: null,
|
||||
max_priority_fee_per_gas: null,
|
||||
nonce: "0x146c",
|
||||
public_key: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
r: "0x31815cdb89c4d6f65f3aa3437c9c27a6cb32b6af3796f6eb0adbf5fdfc547ac5",
|
||||
receipt: {
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
contractAddress: null,
|
||||
cumulativeGasUsed: "0xac4294",
|
||||
effectiveGasPrice: "0x9723a7c5f",
|
||||
from: "0x7303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
gasUsed: "0x1a8c0",
|
||||
logs: [
|
||||
{
|
||||
address: "0x2791bfd60d232150bff86b39b7146c0eaaa2ba81",
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
data: "0x000000000000000000000000000000000000000000001d4d3c9f548788190000",
|
||||
decoded: {
|
||||
contractName: "ERC20",
|
||||
eventName: "Transfer",
|
||||
inputs: {
|
||||
from: "0x7303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
to: "0x0bec54c89a7d9f15c4e7faa8d47adedf374462ed",
|
||||
value: "138373395600000000000000",
|
||||
},
|
||||
logKey: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc:0",
|
||||
},
|
||||
logIndex: "0x120",
|
||||
removed: false,
|
||||
topics: [
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
"0x0000000000000000000000007303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
"0x0000000000000000000000000bec54c89a7d9f15c4e7faa8d47adedf374462ed",
|
||||
],
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
},
|
||||
{
|
||||
address: "0x2791bfd60d232150bff86b39b7146c0eaaa2ba81",
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
data: "0xffffffffffffffffffffffffffffffffffffffffffff00378d1be533fbc8e7ff",
|
||||
decoded: {
|
||||
contractName: "ERC20",
|
||||
eventName: "Approval",
|
||||
inputs: {
|
||||
owner: "0x7303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
spender: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
value: "115792089237316195423570985008687907853269984665640562831556503289933129639935",
|
||||
},
|
||||
logKey: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc:1",
|
||||
},
|
||||
logIndex: "0x121",
|
||||
removed: false,
|
||||
topics: [
|
||||
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
|
||||
"0x0000000000000000000000007303c623bc32633d4c1320ab46538f5bab0959ea",
|
||||
"0x0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d",
|
||||
],
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
},
|
||||
{
|
||||
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
data: "0x0000000000000000000000000000000000000000000000000fcb2d05613e1c99",
|
||||
decoded: {
|
||||
contractName: "WETH9",
|
||||
eventName: "Transfer",
|
||||
inputs: {
|
||||
from: "0x0bec54c89a7d9f15c4e7faa8d47adedf374462ed",
|
||||
to: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
value: "1138052831970729113",
|
||||
},
|
||||
logKey: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc:2",
|
||||
},
|
||||
logIndex: "0x122",
|
||||
removed: false,
|
||||
topics: [
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
"0x0000000000000000000000000bec54c89a7d9f15c4e7faa8d47adedf374462ed",
|
||||
"0x0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d",
|
||||
],
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
},
|
||||
{
|
||||
address: "0x0bec54c89a7d9f15c4e7faa8d47adedf374462ed",
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
data: "0x000000000000000000000000000000000000000000218db370860b0d203c608e00000000000000000000000000000000000000000000001213f31668c8cc585e",
|
||||
decoded: {
|
||||
eventName: "Sync",
|
||||
inputs: {
|
||||
reserve0: "40563715796736906880639118",
|
||||
reserve1: "333478910672134494302",
|
||||
},
|
||||
logKey: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc:3",
|
||||
},
|
||||
logIndex: "0x123",
|
||||
removed: false,
|
||||
topics: ["0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"],
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
},
|
||||
{
|
||||
address: "0x0bec54c89a7d9f15c4e7faa8d47adedf374462ed",
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
data: "0x000000000000000000000000000000000000000000001d4d3c9f548788190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fcb2d05613e1c99",
|
||||
decoded: {
|
||||
eventName: "Swap",
|
||||
inputs: {
|
||||
amount0In: "138373395600000000000000",
|
||||
amount0Out: "0",
|
||||
amount1In: "0",
|
||||
amount1Out: "1138052831970729113",
|
||||
sender: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
to: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
},
|
||||
logKey: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc:4",
|
||||
},
|
||||
logIndex: "0x124",
|
||||
removed: false,
|
||||
topics: [
|
||||
"0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",
|
||||
"0x0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d",
|
||||
"0x0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d",
|
||||
],
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
},
|
||||
{
|
||||
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
blockHash: "0x30b559cad268f6665ae14a1cdd4f2019d8232309f1412be8c17c38ed08a10178",
|
||||
blockNumber: "0xe5b2d1",
|
||||
data: "0x0000000000000000000000000000000000000000000000000fcb2d05613e1c99",
|
||||
decoded: {
|
||||
contractName: "WETH9",
|
||||
eventName: "Withdrawal",
|
||||
inputs: {
|
||||
src: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
wad: "1138052831970729113",
|
||||
},
|
||||
logKey: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc:5",
|
||||
},
|
||||
logIndex: "0x125",
|
||||
removed: false,
|
||||
topics: [
|
||||
"0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65",
|
||||
"0x0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d",
|
||||
],
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
},
|
||||
],
|
||||
logsBloom:
|
||||
"0x00200800000000000000000080002000000400000000000000100000000000000000000000200000000000000000000002000800080000000000000000200000000000000000000000000008000000600000000000600000000000000000000000000000000000000000000000000000000000000000040000000010000000000000010000001000000000000000004000000000000000080000004000000000060400000000000000000000000000000000000000000000000000000000000001000002000000000000000800000000000000000000001000000002000000000010200000000000000000000000000000000000000000000000000000000000",
|
||||
status: "0x1",
|
||||
to: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
transactionHash: "0x92a993c0901c6ee620ec31e504f0496cdbd6088d6894ffc507e56bcfd80fb0fc",
|
||||
transactionIndex: "0x8e",
|
||||
type: "0x2",
|
||||
},
|
||||
s: "0x2888a1070bac8036df23ee909da8e9547f345b3a6b07c00a4b1d44698c558b4d",
|
||||
standard_v: null,
|
||||
to: "0x1111111254fb6c44bac0bed2854e76f90643097d",
|
||||
transaction_index: 142,
|
||||
v: "0x0",
|
||||
value: 0,
|
||||
},
|
||||
0,
|
||||
],
|
||||
],
|
||||
page: {
|
||||
currentPageNumber: 1,
|
||||
currentPageSize: 1,
|
||||
totalRows: 34000,
|
||||
totalPages: 34000,
|
||||
},
|
||||
sql: "select * from read_parquet('/data/2023/04/05/20/clg44olzq00cbn60tasvob5l2/*') offset 0 limit 1",
|
||||
format: ResultFormat.csv,
|
||||
originalQueryRun: {
|
||||
id: "clg44olzq00cbn60tasvob5l2",
|
||||
sqlStatementId: "clg44oly200c9n60tviq17sng",
|
||||
state: status,
|
||||
path: "2023/04/05/20/clg44olzq00cbn60tasvob5l2",
|
||||
fileCount: 1,
|
||||
lastFileNumber: 1,
|
||||
fileNames: "clg44olzq00cbn60tasvob5l2-consolidated-results.parquet",
|
||||
errorName: null,
|
||||
errorMessage: null,
|
||||
errorData: null,
|
||||
dataSourceQueryId: null,
|
||||
dataSourceSessionId: "17257398387030526",
|
||||
startedAt: "2023-04-05T20:14:55.000Z",
|
||||
queryRunningEndedAt: "2023-04-05T20:15:16.000Z",
|
||||
queryStreamingEndedAt: "2023-04-05T20:17:18.000Z",
|
||||
endedAt: "2023-04-05T20:17:18.000Z",
|
||||
rowCount: 17000,
|
||||
totalSize: 24904891,
|
||||
tags: {
|
||||
sdk_package: "python",
|
||||
sdk_version: "1.0.2",
|
||||
sdk_language: "python",
|
||||
},
|
||||
dataSourceId: "clf90gwee0002jvbu63diaa8u",
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
createdAt: "2023-04-05T20:14:55.000Z",
|
||||
updatedAt: "2023-04-05T20:14:55.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
redirectedToQueryRun: null,
|
||||
};
|
||||
|
||||
if (error) {
|
||||
base.error = error;
|
||||
}
|
||||
|
||||
base.result = defaultData;
|
||||
|
||||
return base;
|
||||
}
|
||||
67
js/src/tests/mock-data/get-query-run.ts
Normal file
67
js/src/tests/mock-data/get-query-run.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import {
|
||||
QueryStatus,
|
||||
RpcError,
|
||||
GetQueryRunRpcResponse,
|
||||
ResultFormat,
|
||||
mapApiQueryStateToStatus,
|
||||
} from "../../../src/types";
|
||||
|
||||
export function getQueryRunResponse(
|
||||
status: string = "QUERY_STATE_READY",
|
||||
error: RpcError | null = null
|
||||
): GetQueryRunRpcResponse {
|
||||
let base: GetQueryRunRpcResponse = {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
error: null,
|
||||
result: null,
|
||||
};
|
||||
|
||||
const defaultResult = {
|
||||
queryRun: {
|
||||
id: "clg44olzq00cbn60tasvob5l2",
|
||||
sqlStatementId: "clg44oly200c9n60tviq17sng",
|
||||
state: status,
|
||||
path: "2023/04/05/20/clg44olzq00cbn60tasvob5l2",
|
||||
fileCount: 1,
|
||||
lastFileNumber: 1,
|
||||
fileNames: "clg44olzq00cbn60tasvob5l2-consolidated-results.parquet",
|
||||
errorName: null,
|
||||
errorMessage: null,
|
||||
errorData: null,
|
||||
dataSourceQueryId: null,
|
||||
dataSourceSessionId: "17257398387030526",
|
||||
startedAt: "2023-04-05T20:14:55.000Z",
|
||||
queryRunningEndedAt: "2023-04-05T20:15:00.000Z",
|
||||
queryStreamingEndedAt: "2023-04-05T20:15:45.000Z",
|
||||
endedAt: "2023-04-05T20:15:46.000Z",
|
||||
rowCount: 10000,
|
||||
totalSize: 24904891,
|
||||
tags: {
|
||||
sdk_package: "python",
|
||||
sdk_version: "1.0.2",
|
||||
sdk_language: "python",
|
||||
},
|
||||
dataSourceId: "clf90gwee0002jvbu63diaa8u",
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
createdAt: "2023-04-05T20:14:55.000Z",
|
||||
updatedAt: "2023-04-05T20:14:55.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
redirectedToQueryRun: null,
|
||||
};
|
||||
|
||||
if (error !== null) {
|
||||
base = {
|
||||
...base,
|
||||
error: error,
|
||||
};
|
||||
}
|
||||
|
||||
base = {
|
||||
...base,
|
||||
result: defaultResult,
|
||||
};
|
||||
|
||||
return base;
|
||||
}
|
||||
86
js/src/tests/mock-data/get-sql-statement.ts
Normal file
86
js/src/tests/mock-data/get-sql-statement.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import { GetSqlStatementResponse } from "../../types";
|
||||
|
||||
export function getSqlStatementResponse(id: string): GetSqlStatementResponse {
|
||||
return {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
error: null,
|
||||
result: {
|
||||
sqlStatement: {
|
||||
id: id,
|
||||
statementHash: "9d9d5d462b0e4aaf18d17283b1ea2ff9bb30a285c0fe066754fed18f34f80388",
|
||||
sql: "SELECT * FROM ethereum.core.fact_transactions LIMIT 100000",
|
||||
columnMetadata: {
|
||||
types: [
|
||||
"fixed",
|
||||
"timestamp_ntz",
|
||||
"text",
|
||||
"text",
|
||||
"real",
|
||||
"fixed",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"real",
|
||||
"real",
|
||||
"real",
|
||||
"fixed",
|
||||
"real",
|
||||
"real",
|
||||
"text",
|
||||
"text",
|
||||
"object",
|
||||
],
|
||||
columns: [
|
||||
"BLOCK_NUMBER",
|
||||
"BLOCK_TIMESTAMP",
|
||||
"BLOCK_HASH",
|
||||
"TX_HASH",
|
||||
"NONCE",
|
||||
"POSITION",
|
||||
"ORIGIN_FUNCTION_SIGNATURE",
|
||||
"FROM_ADDRESS",
|
||||
"TO_ADDRESS",
|
||||
"ETH_VALUE",
|
||||
"TX_FEE",
|
||||
"GAS_PRICE",
|
||||
"GAS_LIMIT",
|
||||
"GAS_USED",
|
||||
"CUMULATIVE_GAS_USED",
|
||||
"INPUT_DATA",
|
||||
"STATUS",
|
||||
"TX_JSON",
|
||||
],
|
||||
colTypeMap: {
|
||||
NONCE: "real",
|
||||
STATUS: "text",
|
||||
TX_FEE: "real",
|
||||
TX_HASH: "text",
|
||||
TX_JSON: "object",
|
||||
GAS_USED: "real",
|
||||
POSITION: "fixed",
|
||||
ETH_VALUE: "real",
|
||||
GAS_LIMIT: "fixed",
|
||||
GAS_PRICE: "real",
|
||||
BLOCK_HASH: "text",
|
||||
INPUT_DATA: "text",
|
||||
TO_ADDRESS: "text",
|
||||
BLOCK_NUMBER: "fixed",
|
||||
FROM_ADDRESS: "text",
|
||||
BLOCK_TIMESTAMP: "timestamp_ntz",
|
||||
CUMULATIVE_GAS_USED: "real",
|
||||
ORIGIN_FUNCTION_SIGNATURE: "text",
|
||||
},
|
||||
},
|
||||
userId: "clf8qd1eb0000jv08kbuw0dy4",
|
||||
tags: {
|
||||
sdk_package: "python",
|
||||
sdk_version: "1.0.2",
|
||||
sdk_language: "python",
|
||||
},
|
||||
createdAt: "2023-04-05T18:53:59.000Z",
|
||||
updatedAt: "2023-04-05T18:53:59.000Z",
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
5
js/src/tests/mock-data/index.ts
Normal file
5
js/src/tests/mock-data/index.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export * from "./cancel-query-run";
|
||||
export * from "./create-query-run";
|
||||
export * from "./get-query-results";
|
||||
export * from "./get-query-run";
|
||||
export * from "./get-sql-statement";
|
||||
@ -1,22 +1,35 @@
|
||||
import {
|
||||
ApiClient,
|
||||
CreateQueryResp,
|
||||
Query,
|
||||
QueryResultResp,
|
||||
CompassApiClient,
|
||||
CreateQueryRunRpcResponse,
|
||||
CreateQueryRunRpcParams,
|
||||
GetQueryRunRpcRequestParams,
|
||||
GetQueryRunRpcResponse,
|
||||
GetQueryRunResultsRpcResponse,
|
||||
GetQueryRunResultsRpcParams,
|
||||
GetSqlStatementResponse,
|
||||
GetSqlStatementParams,
|
||||
CancelQueryRunRpcRequestParams,
|
||||
CancelQueryRunRpcResponse,
|
||||
} from "../../types";
|
||||
|
||||
export type MockApiClientInput = {
|
||||
createQueryResp: CreateQueryResp;
|
||||
getQueryResultResp: QueryResultResp;
|
||||
createQueryResp: CreateQueryRunRpcResponse;
|
||||
getQueryRunResp: GetQueryRunRpcResponse;
|
||||
getQueryRunResultsResp: GetQueryRunResultsRpcResponse;
|
||||
getSqlStatementResp: GetSqlStatementResponse;
|
||||
cancelQueryRunResp: CancelQueryRunRpcResponse;
|
||||
};
|
||||
|
||||
export function getMockApiClient(input: MockApiClientInput): ApiClient {
|
||||
class MockApiClient implements ApiClient {
|
||||
export function getMockApiClient(input: MockApiClientInput): CompassApiClient {
|
||||
class MockApiClient implements CompassApiClient {
|
||||
url: string;
|
||||
#baseUrl: string;
|
||||
#headers: Record<string, string>;
|
||||
|
||||
constructor(baseUrl: string, apiKey: string) {
|
||||
this.#baseUrl = baseUrl;
|
||||
this.url = this.getUrl();
|
||||
this.#headers = {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
@ -24,17 +37,33 @@ export function getMockApiClient(input: MockApiClientInput): ApiClient {
|
||||
};
|
||||
}
|
||||
|
||||
getUrl(path: string): string {
|
||||
return `${this.#baseUrl}/${path}`;
|
||||
getUrl(): string {
|
||||
return `${this.#baseUrl}/json-rpc`;
|
||||
}
|
||||
async createQuery(query: Query): Promise<CreateQueryResp> {
|
||||
return new Promise<CreateQueryResp>((resolve, reject) => {
|
||||
|
||||
async createQuery(params: CreateQueryRunRpcParams): Promise<CreateQueryRunRpcResponse> {
|
||||
return new Promise<CreateQueryRunRpcResponse>((resolve, reject) => {
|
||||
resolve(input.createQueryResp);
|
||||
});
|
||||
}
|
||||
async getQueryResult(queryID: string): Promise<QueryResultResp> {
|
||||
return await new Promise<QueryResultResp>((resolve, reject) => {
|
||||
resolve(input.getQueryResultResp);
|
||||
async getQueryRun(params: GetQueryRunRpcRequestParams): Promise<GetQueryRunRpcResponse> {
|
||||
return await new Promise<GetQueryRunRpcResponse>((resolve, reject) => {
|
||||
resolve(input.getQueryRunResp);
|
||||
});
|
||||
}
|
||||
async getQueryResult(params: GetQueryRunResultsRpcParams): Promise<GetQueryRunResultsRpcResponse> {
|
||||
return await new Promise<GetQueryRunResultsRpcResponse>((resolve, reject) => {
|
||||
resolve(input.getQueryRunResultsResp);
|
||||
});
|
||||
}
|
||||
async getSqlStatement(params: GetSqlStatementParams): Promise<GetSqlStatementResponse> {
|
||||
return await new Promise<GetSqlStatementResponse>((resolve, reject) => {
|
||||
resolve(input.getSqlStatementResp);
|
||||
});
|
||||
}
|
||||
async cancelQueryRun(params: CancelQueryRunRpcRequestParams): Promise<CancelQueryRunRpcResponse> {
|
||||
return await new Promise<CancelQueryRunRpcResponse>((resolve, reject) => {
|
||||
resolve(input.cancelQueryRunResp);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,207 +1,301 @@
|
||||
import { assert, describe, it } from "vitest";
|
||||
import { ERROR_TYPES } from "..";
|
||||
import { ApiError, ERROR_TYPES } from "..";
|
||||
import { QueryIntegration } from "../integrations/query-integration";
|
||||
import {
|
||||
QueryStatus,
|
||||
QueryStatusError,
|
||||
QueryStatusFinished,
|
||||
QueryStatusPending,
|
||||
} from "../types";
|
||||
import { QueryStatus, QueryStatusError, QueryStatusFinished, QueryStatusPending, SqlStatement } from "../types";
|
||||
import { Query } from "../types/query.type";
|
||||
import { getMockApiClient } from "./mocks/api-mocks";
|
||||
|
||||
let createQueryData = {
|
||||
token: "flipside test token",
|
||||
errors: null,
|
||||
};
|
||||
import { createQueryRunResponse } from "./mock-data/create-query-run";
|
||||
import {
|
||||
cancelQueryRunResponse,
|
||||
getQueryResultsResponse,
|
||||
getQueryRunResponse,
|
||||
getSqlStatementResponse,
|
||||
} from "./mock-data";
|
||||
|
||||
let defaultQueryData: Query = {
|
||||
sql: "select 1",
|
||||
ttlMinutes: 1,
|
||||
};
|
||||
|
||||
let createQueries = {
|
||||
userError: {
|
||||
data: createQueryData,
|
||||
statusCode: 400,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
serverError: {
|
||||
data: createQueryData,
|
||||
statusCode: 500,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
rateLimitError: {
|
||||
data: createQueryData,
|
||||
statusCode: 429,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
noError: {
|
||||
data: createQueryData,
|
||||
statusCode: 200,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
};
|
||||
|
||||
function generateQueryResultData(status: QueryStatus) {
|
||||
return {
|
||||
queryId: "test",
|
||||
status,
|
||||
results: [],
|
||||
startedAt: "2022-05-19T00:00:00Z",
|
||||
endedAt: "2022-05-19T00:00:00Z",
|
||||
columnLabels: ["block_id", "tx_id"],
|
||||
columnTypes: ["string", "string"],
|
||||
message: "",
|
||||
errors: "invalid sql",
|
||||
pageNumber: 1,
|
||||
pageSize: 100,
|
||||
};
|
||||
}
|
||||
|
||||
let getQueryResult = {
|
||||
userError: {
|
||||
data: generateQueryResultData(QueryStatusError),
|
||||
statusCode: 400,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
serverError: {
|
||||
data: generateQueryResultData(QueryStatusPending),
|
||||
statusCode: 500,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
noErrorPending: {
|
||||
data: generateQueryResultData(QueryStatusPending),
|
||||
statusCode: 200,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
noErrorFinished: {
|
||||
data: generateQueryResultData(QueryStatusFinished),
|
||||
statusCode: 200,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
sqlExecError: {
|
||||
data: generateQueryResultData(QueryStatusError),
|
||||
statusCode: 200,
|
||||
statusMsg: null,
|
||||
errorMsg: null,
|
||||
},
|
||||
};
|
||||
|
||||
describe("run: server_error", () => {
|
||||
it("#createQuery server error", async () => {
|
||||
describe("getQueryResults", () => {
|
||||
it("with page data", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.serverError,
|
||||
getQueryResultResp: getQueryResult.noErrorPending,
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_SUCCESS"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.error?.errorType, ERROR_TYPES.server_error);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
});
|
||||
|
||||
it("#getQueryResult server error", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.noError,
|
||||
getQueryResultResp: getQueryResult.serverError,
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.error?.errorType, ERROR_TYPES.server_error);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("run: user_error", () => {
|
||||
it("#createQuery user error", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.userError,
|
||||
getQueryResultResp: getQueryResult.noErrorPending,
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.error?.errorType, ERROR_TYPES.user_error);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
});
|
||||
|
||||
it("#getQueryResult user error", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.noError,
|
||||
getQueryResultResp: getQueryResult.userError,
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.error?.errorType, ERROR_TYPES.user_error);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
});
|
||||
|
||||
it("#getQueryResult sql exec error", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.noError,
|
||||
getQueryResultResp: getQueryResult.sqlExecError,
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(
|
||||
result.error?.errorType,
|
||||
ERROR_TYPES.query_run_execution_error
|
||||
);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("run: timeout_error", () => {
|
||||
it("query is pending", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.noError,
|
||||
getQueryResultResp: getQueryResult.noErrorPending,
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api, {
|
||||
ttlMinutes: 1,
|
||||
cached: false,
|
||||
timeoutMinutes: 0.01,
|
||||
retryIntervalSeconds: 0.001,
|
||||
const result = await queryIntegration.getQueryResults({
|
||||
queryRunId: "123",
|
||||
pageNumber: 1,
|
||||
pageSize: 100,
|
||||
pageSize: 1,
|
||||
});
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.error?.errorType, ERROR_TYPES.query_run_timeout_error);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
assert.equal(result.status, QueryStatusFinished);
|
||||
});
|
||||
|
||||
it("query is rate limited", async () => {
|
||||
it("without page data", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueries.rateLimitError,
|
||||
getQueryResultResp: getQueryResult.noErrorPending,
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_SUCCESS"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api, {
|
||||
ttlMinutes: 1,
|
||||
cached: false,
|
||||
timeoutMinutes: 0.01,
|
||||
retryIntervalSeconds: 0.001,
|
||||
pageNumber: 1,
|
||||
pageSize: 100,
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.getQueryResults({
|
||||
queryRunId: "123",
|
||||
});
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(
|
||||
result.error?.errorType,
|
||||
ERROR_TYPES.query_run_rate_limit_error
|
||||
);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
assert.equal(result.status, QueryStatusFinished);
|
||||
});
|
||||
|
||||
it("with filters & sortby", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_SUCCESS"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.getQueryResults({
|
||||
queryRunId: "123",
|
||||
filters: [
|
||||
{
|
||||
column: "test",
|
||||
eq: "test",
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
neq: "test",
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
gt: 5,
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
gte: 5,
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
lt: 5,
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
lte: 5,
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
like: "some value",
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
in: ["some value"],
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
in: [5],
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
notIn: ["some value"],
|
||||
},
|
||||
{
|
||||
column: "test",
|
||||
notIn: [5],
|
||||
},
|
||||
],
|
||||
sortBy: [
|
||||
{
|
||||
column: "test",
|
||||
direction: "asc",
|
||||
},
|
||||
{
|
||||
column: "test2",
|
||||
direction: "desc",
|
||||
},
|
||||
],
|
||||
});
|
||||
assert.equal(result.status, QueryStatusFinished);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQueryRun", () => {
|
||||
it("success", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_SUCCESS"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.getQueryRun({ queryRunId: "123" });
|
||||
assert.equal(result.state, "QUERY_STATE_SUCCESS");
|
||||
});
|
||||
it("streaming", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_STREAMING"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_STREAMING"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_STREAMING"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.getQueryRun({ queryRunId: "123" });
|
||||
assert.equal(result.state, "QUERY_STATE_STREAMING");
|
||||
});
|
||||
it("failed", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_FAILED"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_FAILED"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_FAILED"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.getQueryRun({ queryRunId: "123" });
|
||||
assert.equal(result.state, "QUERY_STATE_FAILED");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSqlStatement", () => {
|
||||
it("success", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_SUCCESS"),
|
||||
getSqlStatementResp: getSqlStatementResponse("123"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.getSqlStatement({ sqlStatementId: "123" });
|
||||
assert.equal(result.id, "123");
|
||||
});
|
||||
});
|
||||
|
||||
describe("cancelQueryRun", () => {
|
||||
it("success", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_CANCELLED"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_CANCELLED"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_CANCELLED"),
|
||||
getSqlStatementResp: getSqlStatementResponse("123"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse("QUERY_STATE_CANCELLED"),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.cancelQueryRun({ queryRunId: "123" });
|
||||
assert.equal(result.state, "QUERY_STATE_CANCELLED");
|
||||
});
|
||||
});
|
||||
|
||||
describe("run", () => {
|
||||
it("run success", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResp: getQueryRunResponse("QUERY_STATE_SUCCESS"),
|
||||
getQueryRunResultsResp: getQueryResultsResponse("QUERY_STATE_SUCCESS"),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.status, QueryStatusFinished);
|
||||
});
|
||||
});
|
||||
|
||||
describe("run: api_error", () => {
|
||||
it("#createQuery ApiError", async () => {
|
||||
const api = getMockApiClient({
|
||||
createQueryResp: createQueryRunResponse("QUERY_STATE_READY", {
|
||||
code: -32164,
|
||||
message: "DataSourceNotFound",
|
||||
data: {},
|
||||
}),
|
||||
getQueryRunResp: getQueryRunResponse(),
|
||||
getQueryRunResultsResp: getQueryResultsResponse(),
|
||||
getSqlStatementResp: getSqlStatementResponse("t"),
|
||||
cancelQueryRunResp: cancelQueryRunResponse(),
|
||||
});
|
||||
|
||||
const queryIntegration = new QueryIntegration(api);
|
||||
const result = await queryIntegration.run(defaultQueryData);
|
||||
assert.equal(result.error instanceof ApiError, true);
|
||||
assert.notEqual(result.error?.message, null);
|
||||
});
|
||||
|
||||
// it("#getQueryResult user error", async () => {
|
||||
// const api = getMockApiClient({
|
||||
// createQueryResp: createQueries.noError,
|
||||
// getQueryResultResp: getQueryResult.userError,
|
||||
// });
|
||||
|
||||
// const queryIntegration = new QueryIntegration(api);
|
||||
// const result = await queryIntegration.run(defaultQueryData);
|
||||
// assert.equal(result.error?.errorType, ERROR_TYPES.user_error);
|
||||
// assert.notEqual(result.error?.message, null);
|
||||
// });
|
||||
|
||||
// it("#getQueryResult sql exec error", async () => {
|
||||
// const api = getMockApiClient({
|
||||
// createQueryResp: createQueries.noError,
|
||||
// getQueryResultResp: getQueryResult.sqlExecError,
|
||||
// });
|
||||
|
||||
// const queryIntegration = new QueryIntegration(api);
|
||||
// const result = await queryIntegration.run(defaultQueryData);
|
||||
// assert.equal(result.error?.errorType, ERROR_TYPES.query_run_execution_error);
|
||||
// assert.notEqual(result.error?.message, null);
|
||||
// });
|
||||
});
|
||||
|
||||
// describe("run: timeout_error", () => {
|
||||
// it("query is pending", async () => {
|
||||
// const api = getMockApiClient({
|
||||
// createQueryResp: createQueries.noError,
|
||||
// getQueryResultResp: getQueryResult.noErrorPending,
|
||||
// });
|
||||
|
||||
// const queryIntegration = new QueryIntegration(api, {
|
||||
// ttlMinutes: 1,
|
||||
// cached: false,
|
||||
// timeoutMinutes: 0.01,
|
||||
// retryIntervalSeconds: 0.001,
|
||||
// pageNumber: 1,
|
||||
// pageSize: 100,
|
||||
// });
|
||||
// const result = await queryIntegration.run(defaultQueryData);
|
||||
// assert.equal(result.error?.errorType, ERROR_TYPES.query_run_timeout_error);
|
||||
// assert.notEqual(result.error?.message, null);
|
||||
// });
|
||||
|
||||
// it("query is rate limited", async () => {
|
||||
// const api = getMockApiClient({
|
||||
// createQueryResp: createQueries.rateLimitError,
|
||||
// getQueryResultResp: getQueryResult.noErrorPending,
|
||||
// });
|
||||
|
||||
// const queryIntegration = new QueryIntegration(api, {
|
||||
// ttlMinutes: 1,
|
||||
// cached: false,
|
||||
// timeoutMinutes: 0.01,
|
||||
// retryIntervalSeconds: 0.001,
|
||||
// pageNumber: 1,
|
||||
// pageSize: 100,
|
||||
// });
|
||||
// const result = await queryIntegration.run(defaultQueryData);
|
||||
// assert.equal(result.error?.errorType, ERROR_TYPES.query_run_rate_limit_error);
|
||||
// assert.notEqual(result.error?.message, null);
|
||||
// });
|
||||
// });
|
||||
|
||||
@ -1,39 +1,15 @@
|
||||
import { assert, describe, it } from "vitest";
|
||||
import { QueryResultSetBuilder } from "../integrations/query-integration/query-result-set-builder-old";
|
||||
import {
|
||||
QueryResultSetBuilderInput,
|
||||
QueryStatus,
|
||||
QueryStatusError,
|
||||
QueryStatusFinished,
|
||||
QueryStatusPending,
|
||||
} from "../types";
|
||||
|
||||
function getQueryResultSetBuilder(status: QueryStatus): QueryResultSetBuilderInput {
|
||||
return {
|
||||
queryResultJson: {
|
||||
queryId: "test",
|
||||
status,
|
||||
results: [
|
||||
[1, "0x-tx-id-0", "0xfrom-address-0", true, 0.5],
|
||||
[2, "0x-tx-id-1", "0xfrom-address-1", false, 0.75],
|
||||
[3, "0x-tx-id-2", "0xfrom-address-2", false, 1.75],
|
||||
[4, "0x-tx-id-3", "0xfrom-address-3", true, 100.001],
|
||||
],
|
||||
startedAt: "2022-05-19T00:00:00Z",
|
||||
endedAt: "2022-05-19T00:01:30Z",
|
||||
columnLabels: ["block_id", "tx_id", "from_address", "succeeded", "amount"],
|
||||
columnTypes: ["number", "string", "string", "boolean", "number"],
|
||||
message: "",
|
||||
errors: null,
|
||||
pageSize: 100,
|
||||
pageNumber: 0,
|
||||
},
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
import { QueryResultSetBuilder } from "../integrations/query-integration/query-result-set-builder";
|
||||
import { QueryStatus, QueryStatusError, QueryStatusFinished, QueryStatusPending } from "../types";
|
||||
import { getQueryResultsResponse, getQueryRunResponse } from "./mock-data";
|
||||
|
||||
describe("runStats", () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
const queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_SUCCESS").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_SUCCESS").result,
|
||||
error: null,
|
||||
});
|
||||
it("runStats startedAt is Date type", async () => {
|
||||
assert.typeOf(queryResultSet.runStats?.startedAt, "Date");
|
||||
});
|
||||
@ -42,17 +18,34 @@ describe("runStats", () => {
|
||||
assert.typeOf(queryResultSet.runStats?.startedAt, "Date");
|
||||
});
|
||||
|
||||
it("runStats recordCount = 4", async () => {
|
||||
assert.equal(queryResultSet.runStats?.recordCount, 4);
|
||||
it("runStats recordCount = 1", async () => {
|
||||
assert.equal(queryResultSet.runStats?.recordCount, 10000);
|
||||
});
|
||||
|
||||
it("runStats elpasedSeconds = 90", async () => {
|
||||
assert.equal(queryResultSet.runStats?.elapsedSeconds, 90);
|
||||
it("runStats elpasedSeconds = 51", async () => {
|
||||
assert.equal(queryResultSet.runStats?.elapsedSeconds, 51);
|
||||
});
|
||||
|
||||
it("runStats queuedSeconds = 0", async () => {
|
||||
assert.equal(queryResultSet.runStats?.queuedSeconds, 0);
|
||||
});
|
||||
|
||||
it("runStats streamingSeconds = 45", async () => {
|
||||
assert.equal(queryResultSet.runStats?.streamingSeconds, 45);
|
||||
});
|
||||
|
||||
it("runStats queryExecSeconds = 5", async () => {
|
||||
assert.equal(queryResultSet.runStats?.queryExecSeconds, 5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("records", () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
const queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_SUCCESS").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_SUCCESS").result,
|
||||
error: null,
|
||||
});
|
||||
|
||||
it("records length = rows length", async () => {
|
||||
assert.equal(queryResultSet.records?.length, queryResultSet.rows?.length);
|
||||
});
|
||||
@ -80,7 +73,7 @@ describe("records", () => {
|
||||
it("record values match row values", () => {
|
||||
let records = queryResultSet?.records;
|
||||
queryResultSet?.rows?.forEach((cells, rowIndex) => {
|
||||
cells.forEach((cellValue, colIndex) => {
|
||||
cells.forEach((cellValue: any, colIndex: number) => {
|
||||
let columns = queryResultSet?.columns;
|
||||
if (!columns) {
|
||||
throw new Error("QueryResultSetBuilder columns cannot be null for tests");
|
||||
@ -100,26 +93,64 @@ describe("records", () => {
|
||||
|
||||
describe("status", () => {
|
||||
it("isFinished", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
const queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_SUCCESS").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_SUCCESS").result,
|
||||
error: null,
|
||||
});
|
||||
|
||||
assert.equal(queryResultSet?.status, QueryStatusFinished);
|
||||
});
|
||||
it("isPending", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusPending));
|
||||
it("isPending: QUERY_STATE_READY", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_READY").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_READY").result,
|
||||
error: null,
|
||||
});
|
||||
assert.equal(queryResultSet?.status, QueryStatusPending);
|
||||
});
|
||||
it("isError", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusError));
|
||||
it("isPending: QUERY_STATE_RUNNING", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_RUNNING").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_RUNNING").result,
|
||||
error: null,
|
||||
});
|
||||
assert.equal(queryResultSet?.status, QueryStatusPending);
|
||||
});
|
||||
it("isPending: QUERY_STATE_STREAMING_RESULTS", async () => {
|
||||
let queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_STREAMING_RESULTS").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_STREAMING_RESULTS").result,
|
||||
error: null,
|
||||
});
|
||||
assert.equal(queryResultSet?.status, QueryStatusPending);
|
||||
});
|
||||
|
||||
it("isError: QUERY_STATE_FAILED", async () => {
|
||||
let queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_FAILED").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_FAILED").result,
|
||||
error: null,
|
||||
});
|
||||
assert.equal(queryResultSet?.status, QueryStatusError);
|
||||
});
|
||||
it("isError: QUERY_STATE_CANCELLED", async () => {
|
||||
let queryResultSet = new QueryResultSetBuilder({
|
||||
getQueryRunResultsRpcResult: getQueryResultsResponse("QUERY_STATE_CANCELED").result,
|
||||
getQueryRunRpcResult: getQueryRunResponse("QUERY_STATE_CANCELED").result,
|
||||
error: null,
|
||||
});
|
||||
assert.equal(queryResultSet?.status, QueryStatusError);
|
||||
});
|
||||
});
|
||||
|
||||
describe("queryID", () => {
|
||||
it("queryId is set", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
assert.notEqual(queryResultSet?.queryId, null);
|
||||
});
|
||||
it("queryId is test", async () => {
|
||||
const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
assert.equal(queryResultSet?.queryId, "test");
|
||||
});
|
||||
});
|
||||
// describe("queryID", () => {
|
||||
// it("queryId is set", async () => {
|
||||
// const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
// assert.notEqual(queryResultSet?.queryId, null);
|
||||
// });
|
||||
// it("queryId is test", async () => {
|
||||
// const queryResultSet = new QueryResultSetBuilder(getQueryResultSetBuilder(QueryStatusFinished));
|
||||
// assert.equal(queryResultSet?.queryId, "test");
|
||||
// });
|
||||
// });
|
||||
|
||||
15
js/src/types/compass/compass-api-client.type.ts
Normal file
15
js/src/types/compass/compass-api-client.type.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { CreateQueryRunRpcParams, CreateQueryRunRpcResponse } from "./create-query-run.type";
|
||||
import { GetQueryRunRpcRequestParams, GetQueryRunRpcResponse } from "./get-query-run.type";
|
||||
import { GetQueryRunResultsRpcParams, GetQueryRunResultsRpcResponse } from "./get-query-run-results.type";
|
||||
import { GetSqlStatementParams, GetSqlStatementResponse } from "./get-sql-statement.type";
|
||||
import { CancelQueryRunRpcRequestParams, CancelQueryRunRpcResponse } from "./cancel-query-run.type";
|
||||
|
||||
export interface CompassApiClient {
|
||||
url: string;
|
||||
getUrl(): string;
|
||||
createQuery(params: CreateQueryRunRpcParams): Promise<CreateQueryRunRpcResponse>;
|
||||
getQueryRun(params: GetQueryRunRpcRequestParams): Promise<GetQueryRunRpcResponse>;
|
||||
getQueryResult(params: GetQueryRunResultsRpcParams): Promise<GetQueryRunResultsRpcResponse>;
|
||||
getSqlStatement(params: GetSqlStatementParams): Promise<GetSqlStatementResponse>;
|
||||
cancelQueryRun(params: CancelQueryRunRpcRequestParams): Promise<CancelQueryRunRpcResponse>;
|
||||
}
|
||||
@ -8,3 +8,4 @@ export { RpcRequest, BaseRpcRequest } from "./rpc-request.type";
|
||||
export { RpcResponse, BaseRpcResponse } from "./rpc-response.type";
|
||||
export { SqlStatement } from "./sql-statement.type";
|
||||
export { Tags } from "./tags.type";
|
||||
export { RpcError } from "./rpc-error.type";
|
||||
|
||||
@ -12,20 +12,20 @@ import {
|
||||
// Request
|
||||
export interface Filter {
|
||||
column: string;
|
||||
eq?: string | null;
|
||||
neq?: string | null;
|
||||
gt?: string | null;
|
||||
gte?: string | null;
|
||||
lt?: string | null;
|
||||
lte?: string | null;
|
||||
like?: string | null;
|
||||
in_?: string[] | null;
|
||||
notIn?: string[] | null;
|
||||
eq?: string | number | null;
|
||||
neq?: string | number | null;
|
||||
gt?: number | null;
|
||||
gte?: number | null;
|
||||
lt?: number | null;
|
||||
lte?: number | null;
|
||||
like?: string | number | null;
|
||||
in?: any[] | null;
|
||||
notIn?: any[] | null;
|
||||
}
|
||||
|
||||
export interface SortBy {
|
||||
column: string;
|
||||
direction: string;
|
||||
direction: "desc" | "asc";
|
||||
}
|
||||
|
||||
export interface GetQueryRunResultsRpcParams {
|
||||
|
||||
@ -5,3 +5,4 @@ export * from "./get-query-run.type";
|
||||
export * from "./get-sql-statement.type";
|
||||
export * from "./query-results.type";
|
||||
export * from "./core";
|
||||
export * from "./compass-api-client.type";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user