New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

waii-sdk-js

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

waii-sdk-js - npm Package Compare versions

Comparing version 1.12.5 to 1.12.6

dist/clients/chart/src/Chart.d.ts

5

dist/clients/database/src/Database.d.ts

@@ -11,2 +11,6 @@ import WaiiHttpClient from "../../../lib/src/WaiiHttpClient";

}
declare enum DBContentFilterActionType {
visibility = "visibility",
sample_values = "sample_values"
}
type DBContentFilter = {

@@ -17,2 +21,3 @@ filter_scope?: DBContentFilterScope;

pattern?: string;
filter_action_type?: DBContentFilterActionType;
};

@@ -19,0 +24,0 @@ type DBConnection = {

@@ -30,2 +30,8 @@ "use strict";

;
var DBContentFilterActionType;
(function (DBContentFilterActionType) {
DBContentFilterActionType["visibility"] = "visibility";
DBContentFilterActionType["sample_values"] = "sample_values";
})(DBContentFilterActionType || (DBContentFilterActionType = {}));
;
class Database {

@@ -32,0 +38,0 @@ constructor(httpClient) {

17

dist/clients/query/src/Query.d.ts

@@ -54,3 +54,17 @@ import WaiiHttpClient from "../../../lib/src/WaiiHttpClient";

timestamp_ms?: number;
debug_info?: {
[a: string]: any;
};
};
type Query_ = {
uuid: string;
ask: string;
query: string;
detailed_steps?: string[];
};
type SimilarQueryResponse = {
qid?: number;
equivalent?: boolean;
query?: Query_;
};
type RunQueryRequest = {

@@ -142,4 +156,5 @@ query: string;

generateQuestion(params: GenerateQuestionRequest, signal?: AbortSignal): Promise<GenerateQuestionResponse>;
getSimilarQuery(params: GenerateQuestionRequest, signal?: AbortSignal): Promise<SimilarQueryResponse>;
}
export default Query;
export { GetQueryResultRequest, GetQueryResultResponse, GeneratedQuery, QueryGenerationRequest, RunQueryRequest, RunQueryResponse, LikeQueryRequest, LikeQueryResponse, DescribeQueryRequest, DescribeQueryResponse, CancelQueryRequest, CancelQueryResponse, Tweak, AutoCompleteRequest, AutoCompleteResponse, DiffQueryRequest, DiffQueryResponse, QueryPerformanceRequest, QueryPerformanceResponse, GenerateQuestionRequest, GeneratedQuestion, GenerateQuestionResponse };
export { GetQueryResultRequest, GetQueryResultResponse, GeneratedQuery, QueryGenerationRequest, RunQueryRequest, RunQueryResponse, LikeQueryRequest, LikeQueryResponse, DescribeQueryRequest, DescribeQueryResponse, CancelQueryRequest, CancelQueryResponse, Tweak, AutoCompleteRequest, AutoCompleteResponse, DiffQueryRequest, DiffQueryResponse, QueryPerformanceRequest, QueryPerformanceResponse, GenerateQuestionRequest, GeneratedQuestion, GenerateQuestionResponse, SimilarQueryResponse };

@@ -24,2 +24,3 @@ "use strict";

const GENERATE_QUESTION_ENDPOINT = 'generate-questions';
const GET_SIMILAR_QUERY_ENDPOINT = 'get-similar-query';
class Query {

@@ -100,4 +101,9 @@ constructor(httpClient) {

;
getSimilarQuery(params, signal) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpClient.commonFetch(GET_SIMILAR_QUERY_ENDPOINT, params, signal);
});
}
}
;
exports.default = Query;

2

dist/clients/semantic-context/src/SemanticContext.d.ts

@@ -10,3 +10,3 @@ import WaiiHttpClient from "../../../lib/src/WaiiHttpClient";

summarization_prompt?: string;
constructor(scope: string | undefined, statement: string, labels?: string[], always_include?: boolean, lookup_summaries?: string[], summarization_prompt?: string, id?: string);
constructor(scope: string | undefined, statement: string, labels?: string[], always_include?: boolean, lookup_summaries?: string[], summarization_prompt?: string);
}

@@ -13,0 +13,0 @@ type ModifySemanticContextRequest = {

@@ -17,3 +17,4 @@ "use strict";

class SemanticStatement {
constructor(scope = '*', statement, labels = [], always_include = true, lookup_summaries = [], summarization_prompt = '', id = '') {
constructor(scope = '*', statement, labels = [], always_include = true, lookup_summaries = [], summarization_prompt = '') {
this.id = (0, uuid_1.v4)();
this.scope = scope;

@@ -25,8 +26,2 @@ this.statement = statement;

this.summarization_prompt = summarization_prompt;
if (!id || id.length === 0) {
this.id = (0, uuid_1.v4)();
}
else {
this.id = id;
}
}

@@ -33,0 +28,0 @@ }

{
"name": "waii-sdk-js",
"version": "1.12.5",
"version": "1.12.6",
"description": "Typescript / Javascript SDK for the waii api. SQL generation and much more.",

@@ -5,0 +5,0 @@ "main": "dist/src/waii-sdk.js",

@@ -1,33 +0,8 @@

# WAII SDK Documentation for TypeScript and JavaScript
# Waii TypeScript/JavaScript SDK
Welcome to the SDK documentation for WAII (World's most powerful SQL/AI API). This documentation provides detailed information on how to use the SDK to interact with the WAII system. The SDK allows enables developers to generate, explain, describe, modify, transcode and run SQL queries from text input, as well as manage a semantic layer, handle database connections, perform semantic search, and access the history of generated queries.
Welcome to the SDK documentation for Waii - the worlds most powerful SQL API built on LLM agents. This documentation provides detailed information on how to use the SDK to interact with the system.
## Table of Contents
The SDK allows enables developers to generate, explain, describe, modify, transcode, optimize and run SQL queries from text input, as well as manage the semantic layer, handle database connections, perform semantic search, and access the history of generated queries. You can also generate visualizations from the SQL you are working with.
1. [Getting Started](#getting-started)
2. [SQL Query Module](#query-module)
- [Query Generation and Update](#query-generation)
- [Running a Query](#running-a-query)
- [Liking a Query](#liking-a-query)
- [Submitting a Query](#submitting-a-query)
- [Getting Query Results](#getting-query-results)
- [Cancelling a Query](#cancelling-a-query)
- [Describing a Query](#describing-a-query)
- [Autocompleting a Query](#autocomplete-a-query)
- [Showing the difference between two queries](#diffing-a-query)
- [Analyzing the performance of a query](#performance-query)
- [Generate questions from database schema](#generate-questions)
3. [Semantic Context Module](#semantic-context-module)
- [Modifying the Semantic Context](#modifying-the-semantic-context)
- [Getting the Semantic Context](#getting-the-semantic-context)
4. [Database Module](#database-module)
- [Modify Database Connections](#modify-database-connections)
- [Get Database Connections](#get-database-connections)
- [Get Default Connection](#get-default-connection)
- [Activate Connection](#activate-connection)
- [Get Catalogs](#get-catalogs)
- [Update Schema Descriptions](#update-schema-description)
- [Update Table Description](#update-table-description)
5. [History Module](#history-module)
- [Get Generated Query History](#get-generated-query-history)
Whether you are looking to build a conversational client, analtyics tooling or database infrastructure, you have come to the right place. Waii makes it much easier to integrate advanced AI capabilities into your data-centric applications. Happy coding!

@@ -56,3 +31,2 @@ ## Getting Started <a name="getting-started"></a>

If it's the first time you're using the system you have to add a database connection. This can be done ahead of time / outside the sdk (using the UI for instance).

@@ -92,692 +66,1 @@

```
## SQL Query Module <a name="query-module"></a>
The Query module provides functions to generate, run, and manage SQL queries.
### Query Generation and Update <a name="query-generation"></a>
This function allows you to generate or refine/update a query based on the provided request parameters.
```typescript
async function generate(params: QueryGenerationRequest, signal?: AbortSignal): Promise<GeneratedQuery>;
```
#### Parameters:
- `params` (required): An object containing the query generation request parameters.
- `search_context` (optional): An array of `SearchContext` objects that specify the database, schema, and table names to consider during query generation. The system will automatically pick the needed objects, if this field is ommitted all the objects in the database will be considered (that's the common case).
- `tweak_history` (optional): An array of `Tweak` objects that provide additional information for query generation. This is to interactively update a query. The Tweaks are the previous asks and response queries and these will be refined with the new ask.
- `ask` (optional): A string containing the english language statement for the query generation. Can we a question or a description of the requested result.
- `uuid` (optional): A unique identifier for the query.
- `dialect` (optional): The dialect of the query: Snowflake, or PostgreSQL.
- `parent_uuid` (optional): The parent query's unique identifier. This is for interactive sessions and refers to the UUID from the previous interaction.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `GeneratedQuery` object containing the details of the generated SQL query.
The `GeneratedQuery` object represents the details of a generated query and contains the following fields:
- `uuid` (optional): A string representing the unique identifier of the generated query. This can be later used for liking the query. Please refer to documentation of "Liking a Query".
- `liked` (optional): A boolean value indicating whether the query has been liked/favorited by the user. This is always false when the query is generated, but can be set via the "like" API.
- `tables` (optional): An array of `TableName` objects representing the tables used in the generated query (this is a subset of the search_context). Each `TableName` object may contain the following fields:
- `table_name` (required): The name of the table.
- `schema_name` (optional): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `semantic_context` (optional): An array of `SemanticStatement` objects representing the semantic context of the generated query. Each `SemanticStatement` object may contain the following fields:
- `id` (optional): A string representing the unique identifier of the semantic statement.
- `scope` (required): A string representing the scope of the semantic statement. This is either a database, schema, table or column name. The semantic statement will be considered whenever that object is involved in a query.
- `statement` (required): A string representing the semantic statement itself (e.g.: Describes the price of an item, final price is computed as 'price - discount'). This helps understand why a query was built a certain way.
- `labels` (optional): An array of strings representing the labels associated with the semantic statement.
- `query` (optional): A string representing the generated SQL query.
- `detailed_steps` (optional): An array of strings providing detailed steps or actions performed by the generated SQL query. This is the textual "explain plan".
- `what_changed` (optional): A string representing what changed in the query. This will be set when a generated query is refined with additional asks.
- `compilation_errors` (optional): An array of `CompilationError` objects representing any compilation errors that occurred during query generation. Each `CompilationError` object may contain the following fields:
- `message` (required): A string representing the compilation error message.
- `line` (optional): An array of numbers representing the line numbers where the compilation error occurred.
- `is_new` (optional): A boolean value indicating whether the generated query is new.
- `timestamp_ms` (optional): A number representing the timestamp (in milliseconds) when the query was generated.
- `confidence_score` (optional): returns logprob confidence score based on the tokens from generated queries.
- `llm_usage_stats`: token consumption during the query generation.
- `token_total`: total token usage (prompt + completed), this doesn't include cached tokens. So if you see the total_total = 0, the query is fetched from the cache.
- `elapsed_time_ms`: total elapsed time (in milli-seconds) between RPC request/response.
Please note that some fields in the `GeneratedQuery` object may be optional, and their presence depends on the details of the specific generated query.
### Running a Query <a name="running-a-query"></a>
This function allows you to run a given query.
```typescript
async function run(params: RunQueryRequest, signal?: AbortSignal): Promise<GetQueryResultResponse>;
```
#### Parameters:
- `params` (required): An object containing the run query request parameters.
- `query` (required): The query string to be executed.
- `session_id` (optional): The session ID for the query execution. We will use the same connection for specific sessionIds, thus it's possible to use stateful statements as well (e.g: use schema, create temproary table, etc)
- `current_schema`: The SchemaName object to use as context when running the query. Each `SchemaName` object may contain the following fields:
- `schema_name` (required): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `GetQueryResultResponse` object containing the query result details.
The `GetQueryResultResponse` object represents the result of a query execution and contains the following fields:
- `rows` (optional): An array of objects representing the rows of the query result. Each object corresponds to a row, and its properties represent the column values.
- `more_rows` (optional): A number indicating the number of additional rows available for the query result. If the query result exceeds the maximum returned rows, this field indicates the number of remaining rows that can be fetched.
- `column_definitions` (optional): An array of `Column` objects representing the column definitions of the query result. Each `Column` object may contain the following fields:
- `name` (required): A string representing the name of the column.
- `type` (required): A string representing the data type of the column.
- `comment` (optional): A string representing any comment or description associated with the column.
- `sample_values` (optional): An array of `ColumnSampleValues` objects representing sample values for the column. Each `ColumnSampleValues` object may contain the following fields:
- `values` (optional): An array of objects representing sample values for the column, along with their respective counts. Each object may have `value` (string) and `count` (number) properties.
- `query_uuid` (optional): A string representing the unique identifier of the query associated with the result.
Please note that some fields in the `GetQueryResultResponse` object may be optional, and their presence depends on the specific result of the executed query.
### Liking a Query <a name="liking-a-query"></a>
This function allows you to like or favorite a specific query. This helps finding queries in the query history, but also tells the system when queries are correct to learn from them.
```typescript
async function like(params: LikeQueryRequest, signal?: AbortSignal): Promise<LikeQueryResponse>;
```
#### Parameters:
- `params` (required): An object containing the like query request parameters.
- `query_uuid` (required): The unique identifier of the query to be liked or disliked.
- `liked` (required): A boolean value indicating whether to like (true) or dislike (false) the query.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `LikeQueryResponse` object confirming the success of the operation. The `LikeQueryResponse` object has no fields, and is just a placeholder. If the query doesn't fail, the state is updated to mark the requested query as a favorite.
### Submitting a Query for Execution <a name="submitting-a-query"></a>
This function allows you to submit a query for processing. This is the same as "Running a Query" except that this function is async. It returns an id that can be used later to retrieve a query response.
```typescript
async function submit(params: RunQueryRequest, signal?: AbortSignal): Promise<RunQueryResponse>;
```
#### Parameters:
- `params` (required): An object containing the submit query request parameters.
- `query` (required): The query string to be submitted.
- `session_id` (optional): The session ID for the query execution.
- `current_schema`: The SchemaName object to use as context when running the query. Each `SchemaName` object may contain the following fields:
- `schema_name` (required): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `signal` (optional): An AbortSignal object for aborting the request.
### Returns:
A Promise resolving to a `RunQueryResponse` object containing the query ID.
The `RunQueryResponse` object represents the response of the "run query" operation and contains the following field:
- `query_id` (optional): A string representing the unique identifier of the executed query. This id is to be used in the "Get Query Results" call.
- `error_details` (optional): An object containing the error details if the query failed. The object may contain the following error code:
- `0` (optional): Compilation failed, but no extra information is available.
- `1` (optional): Found a table that can’t be mapped to any of the schemas within the database. A list of table also present which can’t be mapped to any of the present schema.
- `2` (optional): Found unqualified tables that can’t be mapped to any single schema.
- `3` (optional): Found that more than one schema contain all the unqualified tables. Schema selection is required.
- `detected_schemas`: An array of string representing the schemas which are qualified for the query. Schema selection is required.
### Getting Query Results <a name="getting-query-results"></a>
This function allows you to get the results of a previously submitted query.
```typescript
async function getResults(params: GetQueryResultRequest, signal?: AbortSignal): Promise<GetQueryResultResponse>;
```
#### Parameters:
- `params` (required): An object containing the get query results request parameters.
- `query_id` (required): The unique identifier of the query.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `GetQueryResultResponse` object containing the query result data. For a description of this object please refer to the documentation of "Running a query".
### Cancelling a Query <a name="cancelling-a-query"></a>
This function allows you to cancel a running query.
```typescript
async function cancel(params: CancelQueryRequest, signal?: AbortSignal): Promise<CancelQueryResponse>;
```
#### Parameters:
- `params` (required): An object containing the cancel query request parameters.
- `query_id` (required): The unique identifier of the query to be canceled. This is the response of the "Submit Query" api.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `CancelQueryResponse` object confirming the successful cancellation.
### Describing a Query <a name="describing-a-query"></a>
This function allows you to describe a query, providing a summary and detailed steps.
```typescript
async function describe(params: DescribeQueryRequest, signal?: AbortSignal): Promise<DescribeQueryResponse>;
```
#### Parameters:
- `params` (required): An object containing the describe query request parameters.
- `search_context` (optional): An array of `SearchContext` objects that specify the database, schema, and table names related to the query. This is optional, when provided the query processing engine will only consider objects in the search context. If ommitted, all objects in the database will be considered.
- `current_schema` (optional): The current schema name for the query. An optional hint to the system that the query is using a particular schema.
- `query` (optional): The query string to be described.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `DescribeQueryResponse object containing the query description details.
The DescribeQueryResponse object contains the following fields:
- `summary` (optional): A string representing a summary of the query's purpose or objective.
- `detailed_steps` (optional): An array of strings providing detailed steps or actions performed by the query.
- `tables` (optional): An array of TableName objects representing the tables involved in the query. Each TableName object may contain the following fields:
- `table_name` (required): The name of the table.
- `schema_name` (optional): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
Please note that some fields in the DescribeQueryResponse object may be optional, and their presence depends on the information available for the query or the provided search_context.
### Autocompleting a Query <a name="autocomplete-a-query"></a>
This function allows you to complete a partial query.
```typescript
async function autoComplete(params: AutoCompleteRequest, signal?: AbortSignal): Promise<AutoCompleteResponse>;
```
#### Parameters:
- `params` (required): An object containing the auto-complete query request parameters.
- `search_context` (optional): An array of `SearchContext` objects that specify the database, schema, and table names related to the query. This is optional, when provided the query processing engine will only consider objects in the search context. If ommitted, all objects in the database will be considered.
- `text` (optional): A string containing the partial or incomplete query.
- `cursor_offset` (optional): The offset in the `text` string where the completion is desired.
- `dialect` (optional): The query dialect to use `Snowflake` or `PostgreSQL`
- `max_output_tokens` (optional): Maximum number of tokens to generate.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `AutoCompleteResponse object containing the query description details.
The AutoCompleteResponse object contains the following fields:
- `text` (optional): The additional text to complete the query (to be inserted at the cursor_offset given)
Please note that some fields in the AutoCompleteResponse object may be optional, and their presence depends on the information available for the query or the provided search_context.
### Showing the difference between two queries <a name="diffing-a-query"></a>
This function allows you to diff two queries, providing a summary and detailed differences.
```typescript
async function diff(params: DiffQueryRequest, signal?: AbortSignal): Promise<DiffQueryResponse>;
```
#### Parameters:
- `params` (required): An object containing the diff query request parameters.
- `search_context` (optional): An array of `SearchContext` objects that specify the database, schema, and table names related to the queries. This is optional, when provided the query processing engine will only consider objects in the search context. If ommitted, all objects in the database will be considered.
- `current_schema` (optional): The current schema name for the query. An optional hint to the system that the query is using a particular schema.
- `query` (optional): Query string B to be diffed.
- `previous_query` (optional): Query string A to be diffed.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `DiffQueryResponse object containing the query description details.
The DiffQueryResponse object contains the following fields:
- `summary` (optional): A string representing a summary of the query's purpose or objective.
- `detailed_steps` (optional): An array of strings providing detailed steps or actions performed by the query.
- `tables` (optional): An array of TableName objects representing the tables involved in the query. Each TableName object may contain the following fields:
- `table_name` (required): The name of the table.
- `schema_name` (optional): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `what_changed`: A description of the differences between the two queries.
Please note that some fields in the DiffQueryResponse object may be optional, and their presence depends on the information available for the query or the provided search_context.
### Analyzing the performance of a query <a name="performance-query"></a>
This function allows you to get a summary of the runtime of a query as well as recommendations of how to make the query run faster.
```typescript
async function analyzePeformance(params: QueryPerformanceRequest, signal?: AbortSignal): Promise<QueryPerformanceResponse>;
```
#### Parameters:
- `params` (required): An object containing the performance request parameters.
- `query_id` (optional): The uuid of the query. Can be retrieved from a query submit call, snowflake's history, or the waii query history.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
- A Promise resolving to a `QueryPerformance` object containing the performance description details.
The QueryPerfromanceResponse object contains the following fields:
- `summary`: A string array summarizing the runtime of the query.
- `recommendations`: An array of strings providing recommendations of how to improve the runtime.
- `query_text`: The sql of the query.
### Generate questions from database schema
This function allows you to generate questions from the database schema.
```typescript
async function generateQuestion(params: GenerateQuestionRequest, signal?: AbortSignal): Promise<GenerateQuestionResponse>;
```
#### Parameters
- `schema_name` (required): The name of the schema to generate questions from.
- `n_questions` (optional): The number of questions to generate. Default is 10
- `complexity` (optional): The complexity of the questions to generate. Default is "medium". Possible values are "easy", "medium", "hard".
#### Returns
- A list of questions generated from the schema.
- Each question (`GeneratedQuestion`) contains the question text, the complexity of the question, and the tables involved in the question.
#### Example
```typescript
WAII.Query.generateQuestion({
schema_name: <schema_name like My_Schema>,
n_questions: <n_questions>,
complexity: "hard"
}).then((result) => {
for (let i = 0; !(result.questions) || i < result.questions.length; i++) {
// ...
}
})
```
## Semantic Context Module <a name="semantic-context-module"></a>
The Semantic Context module provides functions to modify and retrieve the semantic context.
### Modifying the Semantic Context <a name="modifying-the-semantic-context"></a>
This function allows you to modify the semantic context by adding or deleting semantic statements.
```typescript
async function modifySemanticContext(params: ModifySemanticContextRequest, signal?: AbortSignal): Promise<ModifySemanticContextResponse>;
```
#### Parameters:
- `params` (required): An object containing the modify semantic context request parameters.
- `updated` (optional): An array of `SemanticStatement` objects representing the updated semantic statements.
- `deleted` (optional): An array of strings representing the IDs of the semantic statements to be deleted.
- `validate_before_save` (optional): A boolean value indicating whether to validate the changes before saving.
- `user_id` (optional): The ID of the user performing the modification.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `ModifySemanticContextResponse` object containing the updated and deleted semantic statements.
The `ModifySemanticContextResponse` object represents the response of the "modify semantic context" operation and contains the following fields:
- `updated` (optional): An array of `SemanticStatement` objects representing the semantic statements that have been updated as a result of the operation. Each `SemanticStatement` object may contain the following fields:
- `id` (optional): A string representing the unique identifier of the semantic statement.
- `scope` (required): A string representing the scope of the semantic statement.
- `statement` (required): A string representing the semantic statement itself.
- `labels` (optional): An array of strings representing the labels associated with the semantic statement.
- `deleted` (optional): An array of strings representing the IDs of the semantic statements that have been deleted as a result of the operation.
Please note that the `updated` and `deleted` fields in the `ModifySemanticContextResponse` object may be optional, depending on the changes made during the "modify semantic context" operation.
### Getting the Semantic Context <a name="getting-the-semantic-context"></a>
This function allows you to retrieve the current semantic context.
```typescript
async function getSemanticContext(params: GetSemanticContextRequest, signal?: AbortSignal): Promise<GetSemanticContextResponse>;
```
#### Parameters:
- `params` (optional): An object containing the get semantic context request parameters.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `GetSemanticContextResponse` object containing the semantic statements.
The `GetSemanticContextResponse` object represents the response of the "get semantic context" operation and contains the following field:
- `semantic_context` (optional): An array of `SemanticStatement` objects representing the semantic statements retrieved from the server. Each `SemanticStatement` object may contain the following fields:
- `id` (optional): A string representing the unique identifier of the semantic statement.
- `scope` (required): A string representing the scope of the semantic statement.
- `statement` (required): A string representing the semantic statement itself.
- `labels` (optional): An array of strings representing the labels associated with the semantic statement.
Please note that the `semantic_context` field in the `GetSemanticContextResponse` object may be optional.
## Database Module <a name="database-module"></a>
The Database module provides functions to manage database connections and access schema and table information.
### Modify Database Connections <a name="modify-database-connections"></a>
This function allows you to modify existing database connections or add new ones.
```typescript
async function modifyConnections(params: ModifyDBConnectionRequest, signal?: AbortSignal): Promise<ModifyDBConnectionResponse>;
```
#### Parameters:
- `params` (required): An object containing the modify database connection request parameters.
- `updated` (optional): An array of `DBConnection` objects representing the updated database connections.
- `removed` (optional): An array of strings representing the keys of the database connections to be removed.
- `validate_before_save` (optional): A boolean value indicating whether to validate the changes before saving.
- `user_id` (optional): The ID of the user performing the modification.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `ModifyDBConnectionResponse` object containing the updated connectors and diagnostics.
The `ModifyDBConnectionResponse` object represents the response of the "modify database connection" operation and contains the following fields:
- `connectors` (optional): An array of `DBConnection` objects representing the updated database connectors as a result of the operation. Each `DBConnection` object may contain the following fields:
- `key` (required): A string representing the unique key or identifier of the database connection.
- `db_type` (required): A string representing the type of the database (e.g., MySQL, PostgreSQL).
- `description` (optional): A string representing a description or additional information about the database connection.
- `account_name` (optional): A string representing the account name associated with the database connection.
- `username` (optional): A string representing the username used to connect to the database.
- `password` (optional): A string representing the password used to authenticate the database connection.
- `database` (optional): A string representing the name of the specific database to connect to.
- `warehouse` (optional): A string representing the warehouse for the database connection.
- `role` (optional): A string representing the role associated with the database connection.
- `path` (optional): A string representing the path to the database.
- `parameters` (optional): An object containing additional parameters related to the database connection.
- `connector_status` (optional): An array of `ConnectorStatus` objects representing the status of the database connectors. Each `ConnectorStatus` object may contain the following fields:
- `status` (required): A string representing the status of the database connection. Valid values are "completed", "indexing", "not-started".
- `schema_status` (optional): An array of `SchemaIndexingStatus` objects representing the status of the schema indexing. Each `SchemaIndexingStatus` object may contain the following fields:
- `status` (required): A string representing the status of the schema indexing. Valid values are "completed", "indexing", "not-started".
- `n_pending_indexing_tables` (required): A number representing the number of tables pending indexing.
- `n_total_tables` (required): A number representing the total number of tables.
### Get Database Connections <a name="get-database-connections"></a>
This function allows you to retrieve the list of current database connections.
```typescript
async function getConnections(params: GetDBConnectionRequest = {}, signal?: AbortSignal): Promise<GetDBConnectionResponse>;
```
#### Parameters:
- `params` (optional): An object containing the get database connection request parameters.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `GetDBConnectionResponse` object containing the list of database connections and diagnostics.
The `GetDBConnectionResponse` object represents the response of the "get database connections" operation and contains the following fields:
- `connectors` (optional): An array of `DBConnection` objects representing the list of database connectors retrieved from the server. Each `DBConnection` object may contain the following fields:
- `key` (required): A string representing the unique key or identifier of the database connection.
- `db_type` (required): A string representing the type of the database (e.g., MySQL, PostgreSQL).
- `description` (optional): A string representing a description or additional information about the database connection.
- `account_name` (optional): A string representing the account name associated with the database connection.
- `username` (optional): A string representing the username used to connect to the database.
- `password` (optional): A string representing the password used to authenticate the database connection.
- `database` (optional): A string representing the name of the specific database to connect to.
- `warehouse` (optional): A string representing the warehouse for the database connection.
- `role` (optional): A string representing the role associated with the database connection.
- `path` (optional): A string representing the path to the database.
- `parameters` (optional): An object containing additional parameters related to the database connection.
### Get Default Connection <a name="get-default-connection"></a>
This function allows you to get default database connection for subsequent API calls.
```typescript
function getDefaultConnection(): void;
```
### Activate Connection <a name="activate-connection"></a>
This function allows you to activate a specific database connection for subsequent API calls.
```typescript
function activateConnection(key: string): void;
```
#### Parameters:
- `key` (required): The key of the database connection to activate.
### Get Catalogs <a name="get-catalogs"></a>
This function allows you to fetch information about catalogs, schemas, and tables.
```typescript
async function getCatalogs(params: GetCatalogRequest = {}, signal?: AbortSignal): Promise<GetCatalogResponse>;
```
#### Parameters:
- `params` (optional): An object containing the get catalogs request parameters.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `GetCatalogResponse` object containing the list of catalogs and associated schema and table information.
The `GetCatalogResponse` object represents the response of the "get catalogs" operation and contains the following fields:
- `catalogs` (optional): An array of `Catalog` objects representing the list of catalogs retrieved from the server. Each `Catalog` object may contain the following fields:
- `name` (required): A string representing the name of the catalog.
- `schemas` (optional): An array of `Schema` objects representing the list of schemas associated with the catalog. Each `Schema` object may contain the following fields:
- `name` (required): A `SchemaName` object representing the name of the schema.
- `tables` (optional): An array of `Table` objects representing the list of tables in the schema. Each `Table` object may contain the following fields:
- `name` (required): A `TableName` object representing the name of the table.
- `columns` (optional): An array of `Column` objects representing the list of columns in the table. Each `Column` object may contain the following fields:
- `name` (required): A string representing the name of the column.
- `type` (required): A string representing the data type of the column.
- `comment` (optional): A string representing any comment or description associated with the column.
- `sample_values` (optional): An array of `ColumnSampleValues` objects representing sample values for the column. Each `ColumnSampleValues` object may contain the following fields:
- `values` (optional): An array of objects representing sample values for the column, along with their respective counts. Each object may have `value` (string) and `count` (number) properties.
- `refs` (optional): An array of `TableReference` objects representing the references to other tables. Each `TableReference` object may contain the following fields:
- `src_table` (optional): An array of `TableName` objects representing the source tables.
- `src_cols` (optional): An array of strings representing the source columns.
- `ref_table` (optional): An array of `TableName` objects representing the referenced tables.
- `ref_cols` (optional): An array of strings representing the referenced columns.
- `description` (optional): A `SchemaDescription` object representing the description of the schema.
#### Returns:
A promise resolving to a `UpdateTableDescriptionResponse` object containing the updated table description.
### Update Schema Description <a name="update-schema-description"></a>
This function allows you to update the description of a schema.
```typescript
async function updateSchemaDescription(params: UpdateSchemaDescriptionRequest, signal?: AbortSignal): Promise<UpdateSchemaDescriptionResponse>;
```
#### Parameters:
- `params` (required): An object containing the modify table request parameters.
- `schema_name` (required): A `SchemaName` object representing the name of the schema. Each `SchemaName` object may contain the following fields:
- `schema_name` (required): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `description` (optional): An object `SchemaDescription` representing the description of the schema. Each `SchemaDescription` object may contain the following fields:
- summary (optional): A string representing a summary of the schema's purpose or objective.
- detailed_steps (optional): An array of strings providing detailed steps or actions performed by the schema.
- common_tables (optional): An array of `TableDescriptionPair` objects representing the common tables in the schema. Each `TableDescriptionPair` object may contain the following fields:
- `name` (required): A string representing the name of the table.
- `description` (optional): A string representing the description of the table.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A promise resolving to a `UpdateSchemaDescriptionResponse` object containing the updated schema description.
### Update Table Description <a name="update-table-description"></a>
This function allows you to update the description of a table.
```typescript
async function updateTableDescription(params: UpdateTableDescriptionRequest, signal?: AbortSignal): Promise<UpdateTableDescriptionResponse>;
```
#### Parameters:
- `params` (required): An object containing the modify table request parameters.
- `table_name` (required): A `TableName` object representing the name of the table. Each `TableName` object may contain the following fields:
- `table_name` (required): The name of the table.
- `schema_name` (optional): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `description` (optional): A string representing the description of the table.
- `signal` (optional): An AbortSignal object for aborting the request.
## History Module <a name="history-module"></a>
The History module provides functions to access the history of generated queries.
### Get Generated Query History <a name="get-generated-query-history"></a>
This function allows you to retrieve the history of generated queries.
```typescript
async function list(params: GetGeneratedQueryHistoryRequest = {}, signal?: AbortSignal): Promise<GetGeneratedQueryHistoryResponse>;
```
#### Parameters:
- `params` (optional): An object containing the get generated query history request parameters.
- `signal` (optional): An AbortSignal object for aborting the request.
#### Returns:
A Promise resolving to a `GetGeneratedQueryHistoryResponse` object containing the list of generated query history entries.
The `GetGeneratedQueryHistoryResponse` object represents the responses of past "generated query" operations and contains the following field:
- `history` (optional): An array of `GeneratedQueryHistoryEntry` objects representing the list of generated query history entries retrieved from the server. Each `GeneratedQueryHistoryEntry` object may contain the following fields:
- `query` (optional): A `GeneratedQuery` object representing the details of the generated query. The `GeneratedQuery` object may contain the following fields:
- `uuid` (optional): A string representing the unique identifier of the generated query.
- `liked` (optional): A boolean value indicating whether the query has been liked by the user.
- `tables` (optional): An array of `TableName` objects representing the tables involved in the generated query. Each `TableName` object may contain the following fields:
- `table_name` (required): The name of the table.
- `schema_name` (optional): The name of the schema (if applicable).
- `database_name` (optional): The name of the database (if applicable).
- `semantic_context` (optional): An array of `SemanticStatement` objects representing the semantic context of the generated query. Each `SemanticStatement` object may contain the following fields:
- `id` (optional): A string representing the unique identifier of the semantic statement.
- `scope` (required): A string representing the scope of the semantic statement.
- `statement` (required): A string representing the semantic statement itself.
- `labels` (optional): An array of strings representing the labels associated with the semantic statement.
- `query` (optional): A string representing the generated query.
- `detailed_steps` (optional): An array of strings providing detailed steps or actions performed by the generated query.
- `what_changed` (optional): A string representing what changed in the query.
- `compilation_errors` (optional): An array of `CompilationError` objects representing any compilation errors that occurred during query generation. Each `CompilationError` object may contain the following fields:
- `message` (required): A string representing the compilation error message.
- `line` (optional): An array of numbers representing the line numbers where the compilation error occurred.
- `is_new` (optional): A boolean value indicating whether the generated query is new.
- `timestamp_ms` (optional): A number representing the timestamp (in milliseconds) when the query was generated.
- `request` (optional): A `QueryGenerationRequest` object representing the request used for generating the query. The `QueryGenerationRequest` object may contain the following fields:
- `search_context` (optional): An array of `SearchContext` objects that specify the database, schema, and table names related to the query. Each `SearchContext` object may contain the following fields:
- `db_name` (optional): The name of the database.
- `schema_name` (optional): The name of the schema.
- `table_name` (optional): The name of the table.
- `tweak_history` (optional): An array of `Tweak` objects representing the history of query tweaks applied during query generation. Each `Tweak` object may contain the following fields:
- `sql` (optional): A string representing the SQL tweak applied.
- `ask` (optional): A string representing the ask tweak applied.
- `ask` (optional): A string representing the "ask" query input.
- `uuid` (optional): A string representing the unique identifier of the generated query.
- `dialect` (optional): A string representing the dialect used for the query.
- `parent_uuid` (optional): A string representing the unique identifier of the parent query, if applicable.
---
That's all folks! You have completed the API documentation for the WAII API. If you have any questions or need further assistance, please refer to the contact information provided on the webpage www.waii.ai . Happy coding!
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc