waii-sdk-js
Advanced tools
Comparing version 1.24.0 to 1.25.0
@@ -203,2 +203,14 @@ import WaiiHttpClient from "../../../lib/src/WaiiHttpClient"; | ||
}; | ||
type SubmitGenerateQueryRequest = { | ||
query: string; | ||
session_id?: string; | ||
current_schema?: SchemaName; | ||
session_parameters?: Record<string, any>; | ||
}; | ||
type GetObjectRequest = { | ||
uuid: string; | ||
}; | ||
type GetObjectResponse = { | ||
uuid: string; | ||
}; | ||
type ExpandQueryResponse = { | ||
@@ -218,2 +230,4 @@ query: string; | ||
submit(params: RunQueryRequest, signal?: AbortSignal): Promise<RunQueryResponse>; | ||
submitQueryForGeneration(params: SubmitGenerateQueryRequest, signal?: AbortSignal): Promise<GetObjectResponse>; | ||
generateQueryProgress(params: GetObjectRequest, signal?: AbortSignal): Promise<GeneratedQuery>; | ||
getResults(params: GetQueryResultRequest, signal?: AbortSignal): Promise<GetQueryResultResponse>; | ||
@@ -220,0 +234,0 @@ cancel(params: CancelQueryRequest, signal?: AbortSignal): Promise<CancelQueryResponse>; |
@@ -29,2 +29,4 @@ "use strict"; | ||
const EXPAND_QUERY_ENDPOINT = 'expand-query'; | ||
const GET_GENERATED_QUERY_ENDPOINT = 'get-generated-query'; | ||
const SUBMIT_GENERATE_QUERY_ENDPOINT = 'submit-generate-query'; | ||
// This is supported target persona for describe query | ||
@@ -88,2 +90,14 @@ const TARGET_PERSONA_SQL_EXPERT = 'sql_expert'; | ||
; | ||
submitQueryForGeneration(params, signal) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.httpClient.commonFetch(SUBMIT_GENERATE_QUERY_ENDPOINT, params, signal); | ||
}); | ||
} | ||
; | ||
generateQueryProgress(params, signal) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.httpClient.commonFetch(GET_GENERATED_QUERY_ENDPOINT, params, signal); | ||
}); | ||
} | ||
; | ||
getResults(params, signal) { | ||
@@ -90,0 +104,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ApiError_1 = require("./ApiError"); | ||
class WaiiHttpClient { | ||
@@ -67,3 +68,3 @@ constructor(url = 'http://localhost:9859/api/', apiKey = '') { | ||
new Promise((res, rej) => { | ||
timer = setTimeout(() => rej(new Error(`Call timed out after ${this.timeout} ms`)), this.timeout); | ||
timer = setTimeout(() => rej(new ApiError_1.ApiError(`Call timed out after ${this.timeout} ms`, 504)), this.timeout); | ||
}) | ||
@@ -75,3 +76,3 @@ ]); | ||
if (response.status === 401) { | ||
throw new Error("Authentication failed: Incorrect API key."); | ||
throw new ApiError_1.ApiError("Authentication failed: Incorrect API key.", 401); | ||
} | ||
@@ -81,6 +82,6 @@ if (!response.ok) { | ||
let error = JSON.parse(text); | ||
throw new Error(error.detail); | ||
throw new ApiError_1.ApiError(error.detail, response.status); | ||
} | ||
catch (e) { | ||
throw new Error(text); | ||
throw new ApiError_1.ApiError(text, response.status); | ||
} | ||
@@ -93,3 +94,3 @@ } | ||
catch (e) { | ||
throw new Error("Invalid response received."); | ||
throw new ApiError_1.ApiError("Invalid response received.", response.status); | ||
} | ||
@@ -96,0 +97,0 @@ }); |
{ | ||
"name": "waii-sdk-js", | ||
"version": "1.24.0", | ||
"version": "1.25.0", | ||
"description": "Typescript / Javascript SDK for the waii api. SQL generation and much more.", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/waii-sdk.js", |
115794
50
2404