Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@singlestore/client

Package Overview
Dependencies
Maintainers
0
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@singlestore/client - npm Package Compare versions

Comparing version 0.0.36 to 0.0.37

dist/api.d.mts

1024

dist/index.d.ts

@@ -1,1010 +0,20 @@

import { AnyAI, CreateChatCompletionResult } from '@singlestore/ai';
import * as mysql2_promise from 'mysql2/promise';
import { PoolOptions, Pool, ResultSetHeader, FieldPacket } from 'mysql2/promise';
export { FieldPacket, ResultSetHeader, RowDataPacket } from 'mysql2/promise';
import { Optional, Tail, Defined } from '@repo/utils';
export { escape } from 'mysql2';
import { W as WorkspaceSchema, C as CreateWorkspaceConnectionConfig, a as WorkspaceConnection } from './connection-CEGt1FKv.js';
export { d as Connection, c as ConnectionClient, b as ConnectionConfig } from './connection-CEGt1FKv.js';
import { AnyAI } from '@singlestore/ai';
import { BillingManager } from './billing.js';
import { JobManager } from './job.js';
import { OrganizationManager } from './organization.js';
import { RegionManager } from './region.js';
import { SecretManager } from './secret.js';
import { TeamManager } from './team.js';
import { WorkspaceGroupManager } from './workspace-group/index.js';
import './api.js';
import '@repo/utils';
import '@singlestore/ai/chat-completions';
import './private-connection.js';
import './region-C0w3IL49.js';
import './index-kG0brOyd.js';
type APIVersion = 1 | 2;
declare class API {
private readonly _apiKey?;
private readonly _version;
private readonly _baseURL;
constructor(_apiKey?: string | undefined, _version?: APIVersion);
execute<T = any>(url: string, { version, ...params }?: RequestInit & {
version?: APIVersion;
}): Promise<T>;
}
declare abstract class APIManager {
protected readonly _api: API;
protected abstract readonly _baseURL: string;
constructor(_api: API);
protected _execute<T = any>(...[url, params]: Partial<Parameters<API["execute"]>>): Promise<T>;
}
interface ConnectionConfig extends Partial<Omit<PoolOptions, "name" | "database">> {
}
type ConnectionClient = Pool;
declare class Connection {
config: ConnectionConfig;
client: ConnectionClient;
constructor(config: ConnectionConfig);
disconnect(): Promise<void>;
}
type ColumnName = string;
type ColumnType = any;
interface ColumnSchema {
name: ColumnName;
type: string;
nullable: boolean;
primaryKey: boolean;
autoIncrement: boolean;
default: any;
clauses: string[];
}
interface AddColumnSchema extends Optional<ColumnSchema, "nullable" | "primaryKey" | "autoIncrement" | "default" | "clauses"> {
}
interface ColumnInfo<TName extends ColumnName> {
name: TName;
type: string;
null: string;
key: string;
default: any;
extra: string;
}
declare class Column<TName extends ColumnName, TTableName extends TableName, TDatabaseName extends DatabaseName> {
private _client;
private _path;
name: TName;
tableName: TTableName;
databaseName: TDatabaseName;
constructor(_client: ConnectionClient, _path: string, name: TName, tableName: TTableName, databaseName: TDatabaseName);
static schemaToClauses(schema: Partial<ColumnSchema>): string;
static drop<TName extends ColumnName, TTableName extends TableName, TDatabaseName extends DatabaseName>(client: ConnectionClient, databaseName: TDatabaseName, tableName: TTableName, name: TName): Promise<[ResultSetHeader, FieldPacket[]]>;
static normalizeInfo<TName extends ColumnName>(info: any): ColumnInfo<TName>;
static modify<TName extends ColumnName>(client: ConnectionClient, path: string, name: TName, schema: Partial<Omit<ColumnSchema, "name">>): Promise<[ResultSetHeader, FieldPacket[]]>;
static rename<TName extends ColumnName>(client: ConnectionClient, path: string, name: TName, newName: ColumnName): Promise<[ResultSetHeader, FieldPacket[]]>;
static showInfo<TName extends ColumnName, TTableName extends TableName, TDatabaseName extends DatabaseName>(client: ConnectionClient, databaseName: TDatabaseName, tableName: TTableName, name: TName): Promise<ColumnInfo<TName>>;
drop(): Promise<[ResultSetHeader, FieldPacket[]]>;
modify(...args: Parameters<typeof Column.modify> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, FieldPacket[]]>;
rename(...[newName, ...args]: Parameters<typeof Column.rename> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, FieldPacket[]]>;
showInfo(): Promise<ColumnInfo<TName>>;
}
declare class ColumnManager<TTableName extends TableName, TTableType extends TableType, TDatabaseName extends DatabaseName> {
private _client;
tableName: TTableName;
databaseName: TDatabaseName;
private _path;
constructor(_client: ConnectionClient, tableName: TTableName, databaseName: TDatabaseName);
use<TName extends TableColumnName<TTableType> | (ColumnName & {})>(name: TName): Column<TName, TTableName, TDatabaseName>;
add<TSchema extends AddColumnSchema>(schema: TSchema): Promise<Column<TSchema["name"], TTableName, TDatabaseName>>;
drop(name: TableColumnName<TTableType> | (ColumnName & {})): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
modify(name: TableColumnName<TTableType> | (ColumnName & {}), ...args: Parameters<typeof Column.modify> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
rename(name: TableColumnName<TTableType> | (ColumnName & {}), ...args: Parameters<typeof Column.rename> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
showInfo<TName extends TableColumnName<TTableType> | (ColumnName & {})>(name: TName, ...args: Parameters<typeof Column.showInfo> extends [any, any, any, any, ...infer Rest] ? Rest : never): Promise<ColumnInfo<TName>>;
}
type MergeUnion<T> = (T extends any ? (i: T) => void : never) extends (i: infer U) => void ? {
[K in keyof U]: U[K];
} : never;
type JoinType = "INNER" | "LEFT" | "RIGHT" | "FULL";
type JoinOperator = "=" | "<" | ">" | "<=" | ">=" | "!=";
type JoinClause<TTableType extends TableType, TDatabaseType extends DatabaseType, TAs extends string> = {
[K in keyof TDatabaseType["tables"]]: {
type?: JoinType;
table: K;
as: TAs;
on: [(string & {}) | keyof TTableType, JoinOperator, (string & {}) | keyof TDatabaseType["tables"][K]["columns"]];
};
}[keyof TDatabaseType["tables"]];
type ExtractJoinClauseColumns<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]> = {
[K in TJoinClauses[number] as K["as"]]: `${K["as"]}.${Extract<keyof TDatabaseType["tables"][K["table"]]["columns"], string>}`;
}[TJoinClauses[number]["as"]];
type SelectClause<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]> = ("*" | keyof TTableType | ExtractJoinClauseColumns<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses> | `${TJoinClauseAs}.*` | `${string} AS ${string}`)[];
type WhereOperator<TColumnValue> = TColumnValue extends string ? {
eq?: TColumnValue;
ne?: TColumnValue;
like?: string;
in?: TColumnValue[];
nin?: TColumnValue[];
} : TColumnValue extends number | Date ? {
eq?: TColumnValue;
ne?: TColumnValue;
gt?: TColumnValue;
gte?: TColumnValue;
lt?: TColumnValue;
lte?: TColumnValue;
in?: TColumnValue[];
nin?: TColumnValue[];
} : never;
type WhereClause<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]> = ({
[K in keyof TTableType]?: WhereOperator<TTableType[K]> | TTableType[K];
} & {
[K in TJoinClauses[number] as K["as"]]: {
[C in keyof TDatabaseType["tables"][K["table"]]["columns"] as `${K["as"]}.${Extract<C, string>}`]?: WhereOperator<TDatabaseType["tables"][K["table"]]["columns"][C]> | TDatabaseType["tables"][K["table"]]["columns"][C];
};
}[TJoinClauses[number]["as"]]) & {
OR?: WhereClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>[];
NOT?: WhereClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>;
};
type GroupByClause<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]> = ((string & {}) | keyof TTableType | ExtractJoinClauseColumns<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>)[];
type OrderByDirection = "asc" | "desc";
type OrderByClause<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]> = {
[K in (string & {}) | keyof TTableType | Extract<ExtractJoinClauseColumns<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>, string>]?: OrderByDirection;
};
interface QueryBuilderParams<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>> {
join?: TJoinClauses;
select?: TSelectClause;
where?: WhereClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>;
groupBy?: GroupByClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>;
orderBy?: OrderByClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>;
limit?: number;
offset?: number;
}
type AnyQueryBuilderParams = QueryBuilderParams<any, any, any, any, any>;
type ExtractSelectedQueryColumns<TTableType extends TableType, TDatabaseType extends DatabaseType, TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>> = TSelectClause extends (infer TColumn)[] ? MergeUnion<TColumn extends "*" ? TTableType : TColumn extends keyof TTableType ? {
[K in TColumn]: TTableType[K];
} : TColumn extends `${infer TJoinAs}.${infer TJoinColumn}` ? TJoinAs extends TJoinClauseAs ? TJoinColumn extends keyof TDatabaseType["tables"][Extract<TJoinClauses[number], {
as: TJoinAs;
}>["table"]]["columns"] ? {
[K in `${TJoinAs}_${TJoinColumn}`]: TDatabaseType["tables"][Extract<TJoinClauses[number], {
as: TJoinAs;
}>["table"]]["columns"][TJoinColumn];
} : never : never : TColumn extends `${infer TAlias}.*` ? TAlias extends TJoinClauseAs ? TDatabaseType["tables"][Extract<TJoinClauses[number], {
as: TAlias;
}>["table"]]["columns"] : never : TColumn extends `${string} AS ${infer TAs}` ? {
[K in TAs]: any;
} : never> : never;
declare class QueryBuilder<TTableType extends TableType, TDatabaseType extends DatabaseType> {
private _databaseName;
private _tableName;
constructor(_databaseName: string, _tableName: string);
buildJoinClause<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]>(clauses?: TJoinClauses): string;
buildSelectClause<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]>(clauses?: SelectClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>, joinClauses?: TJoinClauses): string;
buildFromClause(hasJoinClauses?: boolean): string;
buildWhereCondition(column: string, operator: string, value: any): string;
buildWhereClause<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]>(clauses?: WhereClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>, joinClauses?: TJoinClauses): string;
buildGroupByClause<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]>(clauses?: GroupByClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>, joinClauses?: TJoinClauses, aliases?: string[]): string;
buildOrderByClause<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[]>(clauses?: OrderByClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>, joinClauses?: TJoinClauses, aliases?: string[]): string;
buildLimitClause(limit?: number): string;
buildOffsetClause(offset?: number): string;
buildClauses<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>>(params?: QueryBuilderParams<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause>): {
select: string;
from: string;
join: string;
where: string;
groupBy: string;
orderBy: string;
limit: string;
offset: string;
};
buildQuery<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TTableType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses>>(params?: QueryBuilderParams<TTableType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause>): string;
}
type TableName = string;
interface TableType extends Record<TableName, ColumnType> {
}
interface TableSchema<TName extends TableName, TType extends TableType> {
name: TName;
columns: {
[K in keyof TType]: Omit<AddColumnSchema, "name">;
};
primaryKeys: string[];
fulltextKeys: string[];
clauses: string[];
}
interface CreateTableSchema<TName extends TableName, TType extends TableType> extends Optional<TableSchema<TName, TType>, "primaryKeys" | "fulltextKeys" | "clauses"> {
}
interface TableInfo<TName extends TableName> {
name: TName;
}
interface TableInfoExtended<TName extends TableName> extends TableInfo<TName> {
tableType: string;
distributed: boolean;
storageType: string;
}
type TableColumnName<TType extends TableType> = Extract<keyof TType, string>;
type VectorScoreKey = "v_score";
declare class Table<TName extends TableName, TType extends TableType, TDatabaseType extends DatabaseType, TAI extends AnyAI | undefined> {
private _client;
name: TName;
databaseName: TDatabaseType["name"];
private _ai?;
private _path;
vScoreKey: VectorScoreKey;
column: ColumnManager<TName, TType, TDatabaseType["name"]>;
constructor(_client: ConnectionClient, name: TName, databaseName: TDatabaseType["name"], _ai?: TAI | undefined);
private get ai();
static schemaToClauses(schema: CreateTableSchema<TableName, TableType>): string;
static normalizeInfo<TName extends TableName, TExtended extends boolean, _ReturnType = TExtended extends true ? TableInfoExtended<TName> : TableInfo<TName>>(info: any, extended?: TExtended): _ReturnType;
static drop<TName extends TableName, TDatabaseName extends DatabaseName>(client: ConnectionClient, databaseName: TDatabaseName, name: TName): Promise<[ResultSetHeader, FieldPacket[]]>;
static truncate<TName extends TableName, TDatabaseName extends DatabaseName>(client: ConnectionClient, databaseName: TDatabaseName, tableName: TName): Promise<[ResultSetHeader, FieldPacket[]]>;
static rename<TName extends TableName, TDatabaseName extends DatabaseName>(client: ConnectionClient, databaseName: TDatabaseName, name: TName, newName: TableName): Promise<[ResultSetHeader, FieldPacket[]]>;
drop(): Promise<[ResultSetHeader, FieldPacket[]]>;
showInfo<TExtended extends boolean = false>(extended?: TExtended): Promise<TExtended extends true ? TableInfoExtended<TName> : TableInfo<TName>>;
showColumnsInfo(): Promise<ColumnInfo<Extract<keyof TType, string>>[]>;
truncate(): Promise<[ResultSetHeader, FieldPacket[]]>;
rename(...[newName, ...args]: Parameters<typeof Table.rename> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, FieldPacket[]]>;
insert(values: Partial<TType> | Partial<TType>[]): Promise<[ResultSetHeader, FieldPacket[]][]>;
find<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TType, TDatabaseType, TJoinClauseAs, TJoinClauses>>(params?: QueryBuilderParams<TType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause>): Promise<ExtractSelectedQueryColumns<TType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause>[]>;
update(values: Partial<TType>, where: WhereClause<TType, TDatabaseType, any, any>): Promise<[ResultSetHeader, FieldPacket[]]>;
delete(where?: WhereClause<TType, TDatabaseType, any, any>): Promise<[ResultSetHeader, FieldPacket[]]>;
vectorSearch<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TType, TDatabaseType, TJoinClauseAs, TJoinClauses>, TParams extends {
prompt: string;
vectorColumn: TableColumnName<TType>;
embeddingParams?: TAI extends AnyAI ? Parameters<TAI["embeddings"]["create"]>[1] : never;
}>(params: TParams, queryParams?: QueryBuilderParams<TType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause>): Promise<(ExtractSelectedQueryColumns<TType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause> & {
v_score: number;
})[]>;
createChatCompletion<TJoinClauseAs extends string, TJoinClauses extends JoinClause<TType, TDatabaseType, TJoinClauseAs>[], TSelectClause extends SelectClause<TType, TDatabaseType, TJoinClauseAs, TJoinClauses>, TParams extends Parameters<this["vectorSearch"]>[0] & (TAI extends AnyAI ? Parameters<TAI["chatCompletions"]["create"]>[0] : never) & {
template?: string;
}>(params: TParams, queryParams?: QueryBuilderParams<TType, TDatabaseType, TJoinClauseAs, TJoinClauses, TSelectClause>): Promise<CreateChatCompletionResult<TParams["stream"]>>;
}
declare class TableManager<TDatabaseType extends DatabaseType, TAI extends AnyAI | undefined> {
private _client;
private _ai;
databaseName: TDatabaseType["name"];
constructor(_client: ConnectionClient, _ai: TAI, databaseName: TDatabaseType["name"]);
static create<TName extends TableName, TType extends TableType, TDatabaseType extends DatabaseType, TAI extends AnyAI | undefined>(client: ConnectionClient, databaseName: TDatabaseType["name"], schema: CreateTableSchema<TName, TType>, ai?: TAI): Promise<Table<TName, TType, TDatabaseType, TAI>>;
use<TName extends DatabaseTableName<TDatabaseType> | (TableName & {}), TType>(name: TName): Table<TName, TType extends TableType ? TType : TName extends DatabaseTableName<TDatabaseType> ? TDatabaseType["tables"][TName] : TableType, TDatabaseType, TAI>;
create<TName extends TableName, TType extends TableType>(schema: CreateTableSchema<TName, TType>): Promise<Table<TName, TType, TDatabaseType, TAI>>;
drop(name: DatabaseTableName<TDatabaseType> | (TableName & {}), ...args: Parameters<typeof Table.drop> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
truncate(name: DatabaseTableName<TDatabaseType> | (TableName & {}), ...args: Parameters<typeof Table.truncate> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
rename(name: DatabaseTableName<TDatabaseType> | (TableName & {}), ...args: Parameters<typeof Table.rename> extends [any, any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
}
type DatabaseName = string;
interface DatabaseType {
name: DatabaseName;
tables: Record<PropertyKey, TableType>;
}
interface DatabaseSchema<TType extends DatabaseType> {
name: TType["name"];
tables?: {
[K in keyof TType["tables"]]: Omit<CreateTableSchema<Extract<K, string>, TType["tables"][K]>, "name">;
};
}
interface DatabaseInfo<TType extends DatabaseType> {
name: TType["name"];
}
interface DatabaseInfoExtended<TType extends DatabaseType> extends DatabaseInfo<TType> {
commits: number;
role: string;
state: string;
position: string;
details: string;
asyncSlaves: number;
syncSlaves: string;
consensusSlaves: number;
committedPosition: string;
hardenedPosition: string;
replayPosition: string;
term: number;
lastPageTerm: number;
memoryMBs: number;
pendingIOs: number;
pendingBlobFSyncs: number;
}
type DatabaseTableName<TType extends DatabaseType> = Extract<keyof TType["tables"], string>;
type InferDatabaseType<T> = T extends Database<infer TType, any, any> ? TType : never;
type DatabaseTablesToRecords<TTables extends DatabaseType["tables"]> = {
[K in keyof TTables]: TTables[K][];
};
type AnyDatabase = Database<any, any, any>;
declare class Database<TType extends DatabaseType, TWorkspaceName extends WorkspaceSchema["name"] | undefined, TAI extends AnyAI | undefined> {
private _client;
private _ai;
name: TType["name"];
workspaceName: TWorkspaceName;
table: TableManager<TType, TAI>;
constructor(_client: ConnectionClient, _ai: TAI, name: TType["name"], workspaceName: TWorkspaceName);
static drop<TName extends DatabaseName>(client: ConnectionClient, name: TName): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
static normalizeInfo<TType extends DatabaseType, TExtended extends boolean, _ReturnType = TExtended extends true ? DatabaseInfoExtended<TType> : DatabaseInfo<TType>>(info: any, extended?: TExtended): _ReturnType;
drop(...args: Parameters<typeof Database.drop> extends [any, any, ...infer Rest] ? Rest : never): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
showInfo<TExtended extends boolean = false>(extended?: TExtended): Promise<TExtended extends true ? DatabaseInfoExtended<TType> : DatabaseInfo<TType>>;
showTablesInfo<TExtended extends boolean = false>(extended?: TExtended): Promise<(TExtended extends true ? TableInfoExtended<Extract<keyof TType["tables"], string>> : TableInfo<Extract<keyof TType["tables"], string>>)[]>;
describe(): Promise<{
tables: {
columns: ColumnInfo<Extract<keyof (Extract<keyof TType["tables"], string> extends infer T ? T extends Extract<keyof TType["tables"], string> ? T extends Extract<keyof TType["tables"], string> ? TType["tables"][T] : TableType : never : never), string>>[];
tableType: string;
distributed: boolean;
storageType: string;
name: Extract<keyof TType["tables"], string>;
}[];
commits: number;
role: string;
state: string;
position: string;
details: string;
asyncSlaves: number;
syncSlaves: string;
consensusSlaves: number;
committedPosition: string;
hardenedPosition: string;
replayPosition: string;
term: number;
lastPageTerm: number;
memoryMBs: number;
pendingIOs: number;
pendingBlobFSyncs: number;
name: TType["name"];
}>;
query<TReturnType extends any[]>(statement: string): Promise<TReturnType[]>;
}
declare class DatabaseManager<TWorkspaceName extends WorkspaceSchema["name"] | undefined, TAI extends AnyAI | undefined> {
private _client;
private _ai;
workspaceName: TWorkspaceName;
constructor(_client: ConnectionClient, _ai: TAI, workspaceName: TWorkspaceName);
use<TType extends DatabaseType>(name: TType["name"]): Database<TType, TWorkspaceName, TAI>;
create<TType extends DatabaseType>(schema: DatabaseSchema<TType>): Promise<Database<TType, TWorkspaceName, TAI>>;
drop(...args: Tail<Parameters<typeof Database.drop>>): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
}
interface CreateWorkspaceConnectionConfig<TName extends WorkspaceSchema["name"] | undefined, TAI extends AnyAI | undefined> extends ConnectionConfig {
name?: TName;
ai?: TAI;
}
declare class WorkspaceConnection<TName extends WorkspaceSchema["name"] | undefined, TAI extends AnyAI | undefined> extends Connection {
name: TName;
private _ai;
database: DatabaseManager<TName, TAI>;
constructor({ name, ai, ...config }: CreateWorkspaceConnectionConfig<TName, TAI>);
static create<TName extends WorkspaceSchema["name"] | undefined, TAI extends AnyAI | undefined>(config: CreateWorkspaceConnectionConfig<TName, TAI>): WorkspaceConnection<TName, TAI>;
}
interface PrivateConnectionSchema {
privateConnectionID: string;
workspaceGroupID: string;
workspaceID: string;
serviceName: string;
type: "INBOUND" | "OUTBOUND";
status: "PENDING" | "ACTIVE" | "DELETED";
allowList: string;
outboundAllowList: string;
createdAt: string;
deletedAt: string;
updatedAt: string;
activeAt: string;
}
interface PrivateConnection extends Omit<PrivateConnectionSchema, "createdAt" | "deletedAt" | "updatedAt" | "activeAt"> {
createdAt: Date;
deletedAt: Date;
updatedAt: Date;
activeAt: Date;
}
interface GetWorkspacePrivateConnectionParams<TIsKai extends boolean | undefined> {
isKai?: TIsKai;
}
declare class WorkspacePrivateConnectionManager extends APIManager {
private _workspaceID;
private _groupID;
protected _baseURL: string;
constructor(api: API, _workspaceID: WorkspaceSchema["workspaceID"], _groupID: WorkspaceSchema["workspaceGroupID"]);
static getBaseURL(workspaceID: WorkspaceSchema["workspaceID"]): string;
get<TIsKai extends boolean | undefined = undefined>(params?: GetWorkspacePrivateConnectionParams<TIsKai>): Promise<TIsKai extends undefined ? PrivateConnectionSchema[] : {
serviceName: string;
}>;
outbundAllowList(): Promise<{
outboundAllowList: string;
}[]>;
}
type WorkspaceSize = "S-00";
interface WorkspaceResumeAttachmentSchema {
attachment: "READWRITE" | "READONLY";
database: string;
error: string;
success: boolean;
}
interface WorkspaceResumeAttachment extends Omit<WorkspaceResumeAttachmentSchema, "attachment"> {
type: WorkspaceResumeAttachmentSchema["attachment"];
}
interface WorkspaceAutoSuspendSchema {
suspendType: "IDLE" | "SCHEDULED";
idleAfterSeconds: number;
idleChangedAt: string | undefined;
scheduledChangedAt: string | undefined;
scheduledSuspendAt: string | undefined;
suspendTypeChangedAt: string | undefined;
}
interface WorkspaceAutoSuspend extends Omit<WorkspaceAutoSuspendSchema, "idleChangedAt" | "scheduledChangedAt" | "scheduledSuspendAt" | "suspendTypeChangedAt"> {
idleChangedAt: Date | undefined;
scheduledChangedAt: Date | undefined;
scheduledSuspendAt: Date | undefined;
suspendTypeChangedAt: Date | undefined;
}
interface WorkspaceSchema {
workspaceID: string;
workspaceGroupID: string;
name: string;
endpoint: string;
size: WorkspaceSize;
state: "ACTIVE" | "PENDING" | "SUSPENDED" | "FAILED" | "TERMINATED";
scaleFactor: 1 | 2 | 4;
scalingProgress: number | undefined;
cacheConfig: 1 | 2 | 4;
kaiEnabled: boolean;
deploymentType: "PRODUCTION" | "NON-PRODUCTION";
createdAt: string;
lastResumedAt: string | undefined;
terminatedAt: string | undefined;
autoSuspend: WorkspaceAutoSuspendSchema | undefined;
resumeAttachments: WorkspaceResumeAttachmentSchema[];
}
interface UpdateWorkspaceBody extends Partial<Pick<WorkspaceSchema, "size" | "deploymentType" | "cacheConfig" | "scaleFactor">> {
enableKai?: boolean;
autoSuspend?: {
suspendType?: WorkspaceAutoSuspendSchema["suspendType"] | "DISABLED";
suspendAfterSeconds?: number;
};
}
interface ResumeWorkspaceBody {
disableAutoSuspend?: boolean;
}
interface ConnectWorkspaceConfig$1<TName extends WorkspaceSchema["name"] | undefined, TAI extends AnyAI | undefined> extends Omit<CreateWorkspaceConnectionConfig<TName, TAI>, "name" | "host" | "ai"> {
}
declare class Workspace<TName extends WorkspaceSchema["name"], TAI extends AnyAI | undefined> extends APIManager {
private _ai;
id: WorkspaceSchema["workspaceID"];
groupID: WorkspaceSchema["workspaceGroupID"];
name: TName;
endpoint: WorkspaceSchema["endpoint"];
size: WorkspaceSchema["size"];
state: WorkspaceSchema["state"];
scaleFactor: WorkspaceSchema["scaleFactor"];
scalingProgress: WorkspaceSchema["scalingProgress"];
cacheConfig: WorkspaceSchema["cacheConfig"];
kaiEnabled: WorkspaceSchema["kaiEnabled"];
deploymentType: WorkspaceSchema["deploymentType"];
createdAt: Date;
lastResumedAt: Date | undefined;
terminatedAt: Date | undefined;
autoSuspend: WorkspaceAutoSuspend | undefined;
resumeAttachments: WorkspaceResumeAttachment[] | undefined;
protected _baseURL: string;
privateConnection: WorkspacePrivateConnectionManager;
constructor(api: API, _ai: TAI, id: WorkspaceSchema["workspaceID"], groupID: WorkspaceSchema["workspaceGroupID"], name: TName, endpoint: WorkspaceSchema["endpoint"], size: WorkspaceSchema["size"], state: WorkspaceSchema["state"], scaleFactor: WorkspaceSchema["scaleFactor"], scalingProgress: WorkspaceSchema["scalingProgress"], cacheConfig: WorkspaceSchema["cacheConfig"], kaiEnabled: WorkspaceSchema["kaiEnabled"], deploymentType: WorkspaceSchema["deploymentType"], createdAt: Date, lastResumedAt: Date | undefined, terminatedAt: Date | undefined, autoSuspend: WorkspaceAutoSuspend | undefined, resumeAttachments: WorkspaceResumeAttachment[] | undefined);
static getBaseURL(id: WorkspaceSchema["workspaceID"]): string;
static update(api: API, id: WorkspaceSchema["workspaceID"], body: UpdateWorkspaceBody): Promise<WorkspaceSchema["workspaceID"]>;
static delete(api: API, id: WorkspaceSchema["workspaceID"]): Promise<WorkspaceSchema["workspaceID"]>;
static resume(api: API, id: WorkspaceSchema["workspaceID"], body?: ResumeWorkspaceBody): Promise<WorkspaceSchema["workspaceID"]>;
static suspend(api: API, id: WorkspaceSchema["workspaceID"]): Promise<WorkspaceSchema["workspaceID"]>;
static getState(api: API, id: WorkspaceSchema["workspaceID"]): Promise<WorkspaceSchema["state"]>;
connect(config: ConnectWorkspaceConfig$1<TName, TAI>): WorkspaceConnection<TName, TAI>;
update(body: UpdateWorkspaceBody): Promise<string>;
delete(): Promise<string>;
resume(body?: ResumeWorkspaceBody): Promise<string>;
suspend(): Promise<string>;
getState(): Promise<"ACTIVE" | "PENDING" | "SUSPENDED" | "FAILED" | "TERMINATED">;
}
type BillingMetric = "ComputeCredit" | "StorageAvgByte";
interface BillingUsageSchema {
resourceID: string;
resourceName: string;
resourceType: string;
startTime: string;
endTime: string;
value: string;
}
interface StorageAvgByteBillingUsageSchema extends BillingUsageSchema {
}
interface StorageAvgByteBillingUsage extends Omit<StorageAvgByteBillingUsageSchema, "startTime" | "endTime"> {
startTime: Date;
endTime: Date;
}
interface ComputeCreditBillingUsageSchema extends BillingUsageSchema {
ownerID: string | null | undefined;
}
interface ComputeCreditBillingUsage extends Omit<ComputeCreditBillingUsageSchema, "startTime" | "endTime"> {
startTime: Date;
endTime: Date;
}
interface BillingSchema<T extends BillingMetric> {
metric: T;
description: string;
Usage: (T extends "ComputeCredit" ? ComputeCreditBillingUsageSchema : StorageAvgByteBillingUsageSchema)[];
}
interface Billing<TMetric extends BillingMetric, TUsage extends StorageAvgByteBillingUsage | ComputeCreditBillingUsage> {
metric: TMetric;
description: string;
usage: TUsage[];
}
interface StorageAvgByteBilling extends Billing<"StorageAvgByte", StorageAvgByteBillingUsage> {
}
interface ComputeCreditBilling extends Billing<"ComputeCredit", ComputeCreditBillingUsage> {
}
interface GetBillingParams {
metric: BillingMetric;
startTime: Date;
endTime: Date;
aggregateBy?: "hour" | "day" | "month";
}
declare class BillingManager extends APIManager {
protected _baseURL: string;
get<T extends GetBillingParams, _TReturnType = T["metric"] extends "ComputeCredit" ? ComputeCreditBilling[] : StorageAvgByteBilling[]>({ metric, startTime, endTime, aggregateBy }: T): Promise<_TReturnType>;
}
interface JobRuntime {
name: "notebooks-cpu-small" | "notebooks-cpu-medium" | "notebooks-gpu-t4";
description: string;
}
interface JobMetadata {
count: number;
avgDurationInSeconds: number | null;
maxDurationInSeconds: number | null;
status: "Unknown" | "Scheduled" | "Running" | "Completed" | "Failed" | "Error" | "Canceled";
}
interface JobScheduleSchema {
mode: "Recurring" | "Once";
startAt: string | null;
executionIntervalInMinutes: number | null;
}
interface JobSchedule extends Omit<JobScheduleSchema, "startAt"> {
startAt: Date | null;
}
interface JobTargetConfig {
targetID: string;
targetType: "Workspace" | "Cluster" | "VirtualWorkspace";
resumeTarget: boolean;
databaseName: string;
}
interface JobExecutionConfig {
notebookPath: string;
createSnapshot: boolean;
maxAllowedExecutionDurationInMinutes: number;
}
interface JobSchema {
jobID: string;
name: string;
description: string | null;
enqueuedBy: string;
jobMetadata: JobMetadata[];
schedule: JobScheduleSchema;
targetConfig: JobTargetConfig;
executionConfig: JobExecutionConfig;
completedExecutionsCount: number;
createdAt: string;
terminatedAt: string | null;
}
interface JobParameter {
type: "string" | "integer" | "float" | "boolean";
name: string;
value: string;
}
interface JobExecutionSchema {
id: string;
number: number;
jobID: string;
scheduledStartTime: string;
startedAt: string | null;
finishedAt: string | null;
snapshotNotebookPath: string | null;
status: "Scheduled" | "Running" | "Completed" | "Failed";
}
interface JobExecution extends Omit<JobExecutionSchema, "scheduledStartTime" | "startedAt" | "finishedAt"> {
scheduledStartTime: Date;
startedAt: Date | null;
finishedAt: Date | null;
}
declare class Job extends APIManager {
id: JobSchema["jobID"];
name: JobSchema["name"];
description: JobSchema["description"];
enqueuedBy: JobSchema["enqueuedBy"];
executionConfig: JobSchema["executionConfig"];
metadata: JobSchema["jobMetadata"];
targetConfig: JobSchema["targetConfig"];
completedExecutionsCount: JobSchema["completedExecutionsCount"];
schedule: JobSchedule;
createdAt: Date;
terminatedAt: Date | null;
protected _baseURL: string;
constructor(_api: API, id: JobSchema["jobID"], name: JobSchema["name"], description: JobSchema["description"], enqueuedBy: JobSchema["enqueuedBy"], executionConfig: JobSchema["executionConfig"], metadata: JobSchema["jobMetadata"], targetConfig: JobSchema["targetConfig"], completedExecutionsCount: JobSchema["completedExecutionsCount"], schedule: JobSchedule, createdAt: Date, terminatedAt: Date | null);
static getBaseURL(id: JobSchema["jobID"]): string;
static delete(api: API, id: JobSchema["jobID"]): Promise<boolean>;
static getExecutions(api: API, id: JobSchema["jobID"], start: number, end: number): Promise<JobExecution[]>;
static getParameters(api: API, id: JobSchema["jobID"]): Promise<JobParameter[]>;
delete(): Promise<boolean>;
getExecutions(start: number, end: number): Promise<JobExecution[]>;
getParameters(): Promise<JobParameter[]>;
}
interface CreateJobBody {
name?: JobSchema["name"];
description?: JobSchema["description"];
executionConfig: {
runtimeName?: string;
notebookPath: string;
createSnapshot?: boolean;
};
parameters?: JobParameter[];
schedule: Optional<JobSchedule, "executionIntervalInMinutes" | "startAt">;
targetConfig?: Optional<JobTargetConfig, "databaseName" | "resumeTarget">;
}
declare class JobManager extends APIManager {
protected _baseURL: string;
private _create;
create(body: CreateJobBody): Promise<Job>;
get(id: JobSchema["jobID"]): Promise<Job>;
delete(...args: Tail<Parameters<typeof Job.delete>>): Promise<boolean>;
getExecutions(...args: Tail<Parameters<typeof Job.getExecutions>>): Promise<JobExecution[]>;
getParameters(...args: Tail<Parameters<typeof Job.getParameters>>): Promise<JobParameter[]>;
getRuntimes(): Promise<JobRuntime[]>;
}
interface OrganizationSchema {
orgID: string;
name: string;
}
interface Organization extends Omit<OrganizationSchema, "orgID"> {
id: string;
}
declare class OrganizationManager extends APIManager {
protected _baseURL: string;
get(): Promise<Organization>;
}
type RegionProvider = "AWS" | "GCP" | "Azure";
type RegionName = "US West 2 (Oregon)" | "US East 1 (N. Virginia)" | "Europe West 1 (Ireland)" | "Europe Central 1 (Frankfurt)" | "US East 1 (N. Virginia) - HD2" | "Asia Pacific Northeast 2 (Seoul)" | "Asia Pacific Southeast 1 (Singapore)" | "Asia Pacific Southeast 3 (Jakarta)" | "Europe West 2 (London)" | "Middle East 1 (UAE)" | "Asia Pacific Southeast 2 (Sydney)" | "US East 2 (Ohio)" | "Europe West 3 (Paris)" | "Canada Central 1 (Montreal)" | "Africa South 1 (Cape Town)" | "South America East 1 (Sao Paulo)" | "Asia Pacific South 1 (Mumbai)" | "Europe North 1 (Stockholm)";
interface RegionSchema {
regionID: string;
region: RegionName;
provider: RegionProvider;
}
interface Region extends Omit<RegionSchema, "regionID" | "region"> {
id: string;
name: RegionName;
}
declare class RegionManager extends APIManager {
protected _baseURL: string;
get<T extends {
id: RegionSchema["regionID"];
} | {
name: RegionSchema["region"];
} | undefined = undefined, _ReturnType = T extends {
id: RegionSchema["regionID"];
} | {
name: RegionSchema["region"];
} ? Region | undefined : Region[]>(where?: T): Promise<_ReturnType>;
}
interface SecretSchema {
secretID: string;
name: string;
value: string | undefined;
lastUpdatedBy: string;
lastUpdatedAt: string;
createdBy: string;
createdAt: string;
}
declare class Secret extends APIManager {
id: SecretSchema["secretID"];
name: SecretSchema["name"];
value: SecretSchema["value"];
lastUpdatedBy: SecretSchema["lastUpdatedBy"];
lastUpdatedAt: Date;
createdBy: SecretSchema["createdBy"];
createdAt: Date;
protected _baseURL: string;
constructor(api: API, id: SecretSchema["secretID"], name: SecretSchema["name"], value: SecretSchema["value"], lastUpdatedBy: SecretSchema["lastUpdatedBy"], lastUpdatedAt: Date, createdBy: SecretSchema["createdBy"], createdAt: Date);
static getBaseURL(id: SecretSchema["secretID"]): string;
static update(api: API, id: SecretSchema["secretID"], value: Defined<SecretSchema["value"]>): Promise<Secret>;
static delete(api: API, id: SecretSchema["secretID"]): Promise<SecretSchema["secretID"]>;
update(value: Defined<SecretSchema["value"]>): Promise<Secret>;
delete(): Promise<string>;
}
interface CreateSecretBody {
name: SecretSchema["name"];
value: Defined<SecretSchema["value"]>;
}
declare class SecretManager extends APIManager {
protected _baseURL: string;
private _create;
create(body: CreateSecretBody): Promise<Secret>;
get<T extends {
id: SecretSchema["secretID"];
} | {
name: SecretSchema["name"];
} | undefined = undefined, _TReturnType = T extends undefined ? Secret[] : Secret | undefined>(where?: T): Promise<_TReturnType>;
update(...args: Tail<Parameters<typeof Secret.update>>): Promise<Secret>;
delete(...args: Tail<Parameters<typeof Secret.delete>>): Promise<string>;
}
interface TeamMemberTeamSchema {
teamID: string;
name: string;
description: string;
}
interface TeamMemberTeam extends Omit<TeamMemberTeamSchema, "teamID"> {
id: string;
}
interface TeamMemberUserSchema {
userID: string;
firstName: string;
lastName: string;
email: string;
}
interface TeamMemberUser extends Omit<TeamMemberUserSchema, "userID"> {
id: string;
}
interface TeamSchema {
teamID: string;
name: string;
description: string;
memberTeams: TeamMemberTeamSchema[] | undefined;
memberUsers: TeamMemberUserSchema[] | undefined;
createdAt: string;
}
interface UpdateTeamBody extends Partial<Pick<TeamSchema, "name" | "description">> {
}
declare class Team extends APIManager {
id: TeamSchema["teamID"];
name: TeamSchema["name"];
description: TeamSchema["description"];
memberTeams: TeamMemberTeam[] | undefined;
memberUsers: TeamMemberUser[] | undefined;
createdAt: Date;
protected _baseURL: string;
constructor(api: API, id: TeamSchema["teamID"], name: TeamSchema["name"], description: TeamSchema["description"], memberTeams: TeamMemberTeam[] | undefined, memberUsers: TeamMemberUser[] | undefined, createdAt: Date);
static getBaseURL(id: TeamSchema["teamID"]): string;
static update(api: API, id: TeamSchema["teamID"], body: UpdateTeamBody): Promise<TeamSchema["teamID"]>;
static delete(api: API, id: TeamSchema["teamID"]): Promise<TeamSchema["teamID"]>;
static addMemberTeams(api: API, id: TeamSchema["teamID"], teamIDs: TeamMemberTeamSchema["teamID"][]): Promise<TeamSchema["teamID"]>;
static removeMemberTeams(api: API, id: TeamSchema["teamID"], teamIDs: TeamMemberTeamSchema["teamID"][]): Promise<TeamSchema["teamID"]>;
static addMemberUsers(api: API, id: TeamSchema["teamID"], userIDs: TeamMemberUserSchema["userID"][]): Promise<TeamSchema["teamID"]>;
static removeMemberUsers(api: API, id: TeamSchema["teamID"], userIDs: TeamMemberUserSchema["userID"][]): Promise<TeamSchema["teamID"]>;
update(body: UpdateTeamBody): Promise<string>;
delete(): Promise<string>;
addMemberTeams(teamIDs: TeamMemberTeamSchema["teamID"][]): Promise<string>;
removeMemberTeams(teamIDs: TeamMemberTeamSchema["teamID"][]): Promise<string>;
addMemberUsers(userIDs: TeamMemberUserSchema["userID"][]): Promise<string>;
removeMemberUsers(userIDs: TeamMemberUserSchema["userID"][]): Promise<string>;
}
interface CreateTeamBody {
name: TeamSchema["name"];
description?: TeamSchema["description"];
memberTeams?: TeamMemberTeamSchema["teamID"][];
memberUsers?: TeamMemberUserSchema["userID"][];
}
declare class TeamManager extends APIManager {
protected _baseURL: string;
private _create;
create({ memberTeams, memberUsers, ...body }: CreateTeamBody): Promise<Team>;
get<T extends {
id: TeamSchema["teamID"];
} | {
name: TeamSchema["name"];
} | {
description: TeamSchema["description"];
} | undefined = undefined, _TReturnType = T extends undefined ? Team[] : Team | undefined>(where?: T): Promise<_TReturnType>;
update(...args: Parameters<typeof Team.update> extends [any, ...infer Rest] ? Rest : never): Promise<string>;
delete(...args: Tail<Parameters<typeof Team.delete>>): Promise<string>;
addMemberTeams(...args: Tail<Parameters<typeof Team.addMemberTeams>>): Promise<string>;
removeMemberTeams(...args: Tail<Parameters<typeof Team.removeMemberTeams>>): Promise<string>;
addMemberUsers(...args: Tail<Parameters<typeof Team.addMemberUsers>>): Promise<string>;
removeMemberUsers(...args: Tail<Parameters<typeof Team.removeMemberUsers>>): Promise<string>;
}
interface CreateWorkspaceBody extends Pick<WorkspaceSchema, "name">, Partial<Pick<WorkspaceSchema, "cacheConfig" | "scaleFactor" | "size">>, Pick<UpdateWorkspaceBody, "enableKai" | "autoSuspend"> {
}
type GetWorkspaceSelectParam = (keyof WorkspaceSchema)[] | undefined;
type GetWorkspaceWhereParam = {
id: WorkspaceSchema["workspaceID"];
} | {
name: WorkspaceSchema["name"];
} | undefined;
interface GetWorkspaceParams<TSelect extends GetWorkspaceSelectParam = undefined, TWhere extends GetWorkspaceWhereParam = undefined> {
select?: TSelect;
where?: TWhere;
includeTerminated?: boolean;
}
type WorkspaceBySelect<TSelect extends GetWorkspaceSelectParam> = TSelect extends (keyof Workspace<any, any>)[] ? Pick<Workspace<any, any>, TSelect[number]> : Workspace<any, any>;
declare class WorkspaceManager<TAI extends AnyAI | undefined> extends APIManager {
private _ai;
private _workspaceGroupID;
protected _baseURL: string;
constructor(api: API, _ai: TAI, _workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"]);
private _create;
create(body: CreateWorkspaceBody): Promise<Workspace<any, any> | undefined>;
get<TSelect extends GetWorkspaceSelectParam = undefined, TWhere extends GetWorkspaceWhereParam = undefined, _TReturnType = TWhere extends {
id: WorkspaceSchema["workspaceID"];
} ? WorkspaceBySelect<TSelect> | undefined : WorkspaceBySelect<TSelect>[]>({ where, select, includeTerminated }?: GetWorkspaceParams<TSelect, TWhere>): Promise<_TReturnType>;
update(...args: Tail<Parameters<typeof Workspace.update>>): Promise<string>;
delete(...args: Tail<Parameters<typeof Workspace.delete>>): Promise<string>;
resume(...args: Tail<Parameters<typeof Workspace.resume>>): Promise<string>;
suspend(...args: Tail<Parameters<typeof Workspace.suspend>>): Promise<string>;
getState(...args: Tail<Parameters<typeof Workspace.getState>>): Promise<"ACTIVE" | "PENDING" | "SUSPENDED" | "FAILED" | "TERMINATED">;
}
type WorkspaceGroupStageContent = string | any[];
interface WorkspaceGroupStageSchema {
name: string;
content: WorkspaceGroupStageContent;
type: "json" | "directory" | null;
path: string;
format: string | null;
mimetype: string | null;
size: number;
writable: boolean;
created: string;
last_modified: string;
}
interface UpdateWorkspaceGroupStageBody {
newPath?: WorkspaceGroupStageSchema["path"];
}
declare class WorkspaceGroupStage extends APIManager {
private _workspaceGroupID;
name: WorkspaceGroupStageSchema["name"];
content: WorkspaceGroupStageSchema["content"];
type: WorkspaceGroupStageSchema["type"];
path: WorkspaceGroupStageSchema["path"];
format: WorkspaceGroupStageSchema["format"];
mimetype: WorkspaceGroupStageSchema["mimetype"];
size: WorkspaceGroupStageSchema["size"];
writable: WorkspaceGroupStageSchema["writable"];
createdAt: Date | undefined;
modifiedAt: Date | undefined;
protected _baseURL: string;
constructor(api: API, _workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"], name: WorkspaceGroupStageSchema["name"], content: WorkspaceGroupStageSchema["content"], type: WorkspaceGroupStageSchema["type"], path: WorkspaceGroupStageSchema["path"], format: WorkspaceGroupStageSchema["format"], mimetype: WorkspaceGroupStageSchema["mimetype"], size: WorkspaceGroupStageSchema["size"], writable: WorkspaceGroupStageSchema["writable"], createdAt: Date | undefined, modifiedAt: Date | undefined);
static getBaseURL(workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"], path: WorkspaceGroupStageSchema["path"]): string;
static serializePath(path?: WorkspaceGroupStageSchema["path"]): string;
static formatPath(id: WorkspaceGroupSchema["workspaceGroupID"], path?: WorkspaceGroupStageSchema["path"]): string;
static mergePaths(...paths: (string | undefined)[]): string;
static get(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], path?: WorkspaceGroupStageSchema["path"]): Promise<WorkspaceGroupStage>;
static update(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], path: WorkspaceGroupStageSchema["path"], body: UpdateWorkspaceGroupStageBody): Promise<Pick<WorkspaceGroupStage, "name" | "path">>;
static delete(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], path: WorkspaceGroupStage["path"]): Promise<Pick<WorkspaceGroupStage, "name" | "path">>;
static createFolder(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], path: WorkspaceGroupStage["path"], name: string): Promise<WorkspaceGroupStage>;
static uploadFile(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], path: WorkspaceGroupStage["path"], file: File): Promise<void>;
get(path?: WorkspaceGroupStage["path"]): Promise<WorkspaceGroupStage>;
update(body: UpdateWorkspaceGroupStageBody, path?: WorkspaceGroupStage["path"]): Promise<Pick<WorkspaceGroupStage, "name" | "path">>;
delete(path?: WorkspaceGroupStage["path"]): Promise<Pick<WorkspaceGroupStage, "name" | "path">>;
createFolder(name: string, path?: WorkspaceGroupStage["path"]): Promise<WorkspaceGroupStage>;
uploadFile(file: File, path?: WorkspaceGroupStage["path"]): Promise<void>;
}
declare class WorkspaceGroupStageManager extends APIManager {
private _workspaceGroupID;
protected _baseURL: string;
constructor(api: API, _workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"]);
static getBaseURL(workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"]): string;
get(...args: Parameters<typeof WorkspaceGroupStage.get> extends [any, any, ...infer Rest] ? Rest : never): Promise<WorkspaceGroupStage>;
update(...args: Parameters<typeof WorkspaceGroupStage.update> extends [any, any, ...infer Rest] ? Rest : never): Promise<Pick<WorkspaceGroupStage, "name" | "path">>;
delete(...args: Parameters<typeof WorkspaceGroupStage.delete> extends [any, any, ...infer Rest] ? Rest : never): Promise<Pick<WorkspaceGroupStage, "name" | "path">>;
createFolder(...args: Parameters<typeof WorkspaceGroupStage.createFolder> extends [any, any, ...infer Rest] ? Rest : never): Promise<WorkspaceGroupStage>;
}
interface ReplicatedDatabaseSchema {
region: RegionName;
databaseName: string;
duplicationState: "Pending" | "Active" | "Inactive" | "Error";
}
interface StorageDRStatusSchema {
compute: {
storageDRType: "Failover" | "Failback" | "PreProvisionStart" | "PreProvisionStop";
storageDRState: "Active" | "Completed" | "Failed" | "Expired" | "Canceled";
completedAttachments: number;
completedWorkspaces: number;
totalAttachments: number;
totalWorkspaces: number;
};
storage: ReplicatedDatabaseSchema[];
}
declare class WorkspaceGroupStorageManager extends APIManager {
private _workspaceGroupID;
protected _baseURL: string;
constructor(api: API, _workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"]);
static getBaseURL(workspaceGroupID: WorkspaceGroupSchema["workspaceGroupID"]): string;
getStatus(): Promise<StorageDRStatusSchema>;
getRegions(): Promise<Region[]>;
}
interface WorkspaceGroupUpdateWindowSchema {
day: number;
hour: number;
}
interface WorkspaceGroupUpdateWindow extends Omit<WorkspaceGroupUpdateWindowSchema, "day"> {
day: "mo" | "tu" | "we" | "th" | "fr" | "sa" | "su";
}
interface WorkspaceGroupSchema {
workspaceGroupID: string;
name: string;
regionID: string;
state: "ACTIVE" | "PENDING" | "FAILED" | "TERMINATED";
smartDRStatus: "ACTIVE" | "STANDBY" | undefined;
allowAllTraffic: boolean | undefined;
firewallRanges: string[];
updateWindow: WorkspaceGroupUpdateWindowSchema;
createdAt: string;
expiresAt: string | undefined;
terminatedAt: string | undefined;
}
interface UpdateWorkspaceGroupBody extends Partial<Pick<WorkspaceGroupSchema, "name" | "allowAllTraffic" | "firewallRanges">> {
expiresAt?: Date;
adminPassword?: string;
updateWindow?: WorkspaceGroupUpdateWindow;
}
declare const updateWindowDaysMap: Record<number, WorkspaceGroupUpdateWindow["day"]>;
declare class WorkspaceGroup<TAI extends AnyAI | undefined> extends APIManager {
private _ai;
private _organization;
id: WorkspaceGroupSchema["workspaceGroupID"];
name: WorkspaceGroupSchema["name"];
regionID: WorkspaceGroupSchema["regionID"];
state: WorkspaceGroupSchema["state"];
smartDRStatus: WorkspaceGroupSchema["smartDRStatus"];
allowAllTraffic: WorkspaceGroupSchema["allowAllTraffic"];
firewallRanges: WorkspaceGroupSchema["firewallRanges"];
updateWindow: WorkspaceGroupUpdateWindow | undefined;
createdAt: Date;
expiresAt: Date | undefined;
terminatedAt: Date | undefined;
protected _baseURL: string;
stage: WorkspaceGroupStageManager;
storage: WorkspaceGroupStorageManager;
workspace: WorkspaceManager<TAI>;
constructor(api: API, _ai: TAI, _organization: OrganizationManager, id: WorkspaceGroupSchema["workspaceGroupID"], name: WorkspaceGroupSchema["name"], regionID: WorkspaceGroupSchema["regionID"], state: WorkspaceGroupSchema["state"], smartDRStatus: WorkspaceGroupSchema["smartDRStatus"], allowAllTraffic: WorkspaceGroupSchema["allowAllTraffic"], firewallRanges: WorkspaceGroupSchema["firewallRanges"], updateWindow: WorkspaceGroupUpdateWindow | undefined, createdAt: Date, expiresAt: Date | undefined, terminatedAt: Date | undefined);
static getBaseURL(id: WorkspaceGroupSchema["workspaceGroupID"]): string;
static serializeUpdateWindow(updateWindow: WorkspaceGroupUpdateWindow): WorkspaceGroupUpdateWindowSchema;
static update(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], body: UpdateWorkspaceGroupBody): Promise<WorkspaceGroupSchema["workspaceGroupID"]>;
static delete(api: API, id: WorkspaceGroupSchema["workspaceGroupID"], force?: boolean): Promise<WorkspaceGroupSchema["workspaceGroupID"]>;
update(...args: Parameters<typeof WorkspaceGroup.update> extends [any, any, ...infer Rest] ? Rest : never): Promise<string>;
delete(...args: Parameters<typeof WorkspaceGroup.delete> extends [any, any, ...infer Rest] ? Rest : never): Promise<string>;
getPrivateConnections(): Promise<PrivateConnection[]>;
getMetrics(): Promise<string>;
}
interface CreateWorkspaceGroupBody {
name: WorkspaceGroupSchema["name"];
adminPassword?: string;
allowAllTraffic?: boolean;
firewallRanges?: string[];
regionName: RegionName;
updateWindow?: WorkspaceGroupUpdateWindow;
dataBucketKMSKeyID?: string;
backupBucketKMSKeyID?: string;
expiresAt?: Date;
}
type GetWorkspaceGroupSelectParam = (keyof WorkspaceGroupSchema)[] | undefined;
type GetWorkspaceGroupWhereParam = {
id: WorkspaceGroupSchema["workspaceGroupID"];
} | {
name: WorkspaceGroupSchema["name"];
} | undefined;
interface GetWorkspaceGroupParams<TSelect extends GetWorkspaceGroupSelectParam = undefined, TWhere extends GetWorkspaceGroupWhereParam = undefined> {
select?: TSelect;
where?: TWhere;
includeTerminated?: boolean;
}
type WorkspaceGroupBySelect<TSelect extends GetWorkspaceGroupSelectParam> = TSelect extends (keyof WorkspaceGroup<any>)[] ? Pick<WorkspaceGroup<any>, TSelect[number]> : WorkspaceGroup<any>;
declare class WorkspaceGroupManager<TAI extends AnyAI | undefined> extends APIManager {
private _ai;
private _organization;
private _region;
protected _baseURL: string;
constructor(_api: API, _ai: TAI, _organization: OrganizationManager, _region: RegionManager);
private _create;
create({ regionName, firewallRanges, ...body }: CreateWorkspaceGroupBody): Promise<{
workspaceGroup: WorkspaceGroup<TAI>;
adminPassword: string | undefined;
}>;
get<TSelect extends GetWorkspaceGroupSelectParam = undefined, TWhere extends GetWorkspaceGroupWhereParam = undefined, _TReturnType = TWhere extends {
id: WorkspaceGroupSchema["workspaceGroupID"];
} ? WorkspaceGroupBySelect<TSelect> | undefined : WorkspaceGroupBySelect<TSelect>[]>({ where, select, includeTerminated }?: GetWorkspaceGroupParams<TSelect, TWhere>): Promise<_TReturnType>;
update(...args: Tail<Parameters<typeof WorkspaceGroup.update>>): Promise<string>;
delete(...args: Tail<Parameters<typeof WorkspaceGroup.delete>>): Promise<string>;
}
interface SingleStoreClientConfig<TAI extends AnyAI | undefined> {

@@ -1030,2 +40,2 @@ ai?: TAI;

export { API, APIManager, type APIVersion, type AddColumnSchema, type AnyDatabase, type AnyQueryBuilderParams, type Billing, BillingManager, type BillingMetric, type BillingSchema, type BillingUsageSchema, Column, type ColumnInfo, ColumnManager, type ColumnName, type ColumnSchema, type ColumnType, type ComputeCreditBilling, type ComputeCreditBillingUsage, type ComputeCreditBillingUsageSchema, type ConnectWorkspaceConfig, Connection, type ConnectionClient, type ConnectionConfig, type CreateJobBody, type CreateSecretBody, type CreateTableSchema, type CreateTeamBody, type CreateWorkspaceConnectionConfig, type CreateWorkspaceGroupBody, Database, type DatabaseInfo, type DatabaseInfoExtended, DatabaseManager, type DatabaseName, type DatabaseSchema, type DatabaseTableName, type DatabaseTablesToRecords, type DatabaseType, type ExtractJoinClauseColumns, type ExtractSelectedQueryColumns, type GetBillingParams, type GetWorkspaceGroupParams, type GetWorkspaceGroupSelectParam, type GetWorkspaceGroupWhereParam, type GetWorkspaceParams, type GetWorkspacePrivateConnectionParams, type GetWorkspaceSelectParam, type GetWorkspaceWhereParam, type GroupByClause, type InferDatabaseType, Job, type JobExecution, type JobExecutionConfig, type JobExecutionSchema, JobManager, type JobMetadata, type JobParameter, type JobRuntime, type JobSchedule, type JobScheduleSchema, type JobSchema, type JobTargetConfig, type JoinClause, type OrderByClause, type OrderByDirection, type Organization, OrganizationManager, type OrganizationSchema, type PrivateConnection, type PrivateConnectionSchema, QueryBuilder, type QueryBuilderParams, type Region, RegionManager, type RegionName, type RegionProvider, type RegionSchema, type ReplicatedDatabaseSchema, type ResumeWorkspaceBody, Secret, SecretManager, type SecretSchema, type SelectClause, SingleStoreClient, type SingleStoreClientConfig, type StorageAvgByteBilling, type StorageAvgByteBillingUsage, type StorageAvgByteBillingUsageSchema, type StorageDRStatusSchema, Table, type TableColumnName, type TableInfo, type TableInfoExtended, TableManager, type TableName, type TableSchema, type TableType, Team, TeamManager, type TeamMemberTeam, type TeamMemberTeamSchema, type TeamMemberUser, type TeamMemberUserSchema, type TeamSchema, type UpdateTeamBody, type UpdateWorkspaceBody, type UpdateWorkspaceGroupBody, type UpdateWorkspaceGroupStageBody, type VectorScoreKey, type WhereClause, type WhereOperator, Workspace, type WorkspaceAutoSuspend, type WorkspaceAutoSuspendSchema, WorkspaceConnection, WorkspaceGroup, WorkspaceGroupManager, type WorkspaceGroupSchema, WorkspaceGroupStage, type WorkspaceGroupStageContent, WorkspaceGroupStageManager, type WorkspaceGroupStageSchema, WorkspaceGroupStorageManager, type WorkspaceGroupUpdateWindow, type WorkspaceGroupUpdateWindowSchema, WorkspaceManager, WorkspacePrivateConnectionManager, type WorkspaceResumeAttachment, type WorkspaceResumeAttachmentSchema, type WorkspaceSchema, type WorkspaceSize, updateWindowDaysMap };
export { type ConnectWorkspaceConfig, SingleStoreClient, type SingleStoreClientConfig };

@@ -23,3 +23,3 @@ "use strict";

__export(src_exports, {
QueryBuilder: () => QueryBuilder,
Connection: () => Connection,
SingleStoreClient: () => SingleStoreClient,

@@ -29,4 +29,18 @@ escape: () => import_mysql22.escape

module.exports = __toCommonJS(src_exports);
var import_mysql22 = require("mysql2");
// src/api/index.ts
// src/connection.ts
var import_promise = require("mysql2/promise");
var Connection = class {
constructor(config) {
this.config = config;
this.client = (0, import_promise.createPool)({ multipleStatements: true, ...this.config });
}
client;
async disconnect() {
await this.client.end();
}
};
// src/api/api.ts
var API = class {

@@ -109,3 +123,3 @@ constructor(_apiKey, _version = 1) {

// src/job/index.ts
// src/job/job.ts
var Job = class _Job extends APIManager {

@@ -243,3 +257,3 @@ constructor(_api, id, name, description, enqueuedBy, executionConfig, metadata, targetConfig, completedExecutionsCount, schedule, createdAt, terminatedAt) {

// src/secret/index.ts
// src/secret/secret.ts
var Secret = class _Secret extends APIManager {

@@ -343,3 +357,3 @@ constructor(api, id, name, value, lastUpdatedBy, lastUpdatedAt, createdBy, createdAt) {

// src/team/index.ts
// src/team/team.ts
var Team = class _Team extends APIManager {

@@ -486,16 +500,3 @@ constructor(api, id, name, description, memberTeams, memberUsers, createdAt) {

// src/connection.ts
var import_promise = require("mysql2/promise");
var Connection = class {
constructor(config) {
this.config = config;
this.client = (0, import_promise.createPool)({ multipleStatements: true, ...this.config });
}
client;
async disconnect() {
await this.client.end();
}
};
// src/column/index.ts
// src/column/column.ts
var Column = class _Column {

@@ -752,3 +753,3 @@ constructor(_client, _path, name, tableName, databaseName) {

// src/table/index.ts
// src/table/table.ts
var Table = class _Table {

@@ -915,3 +916,3 @@ constructor(_client, name, databaseName, _ai) {

// src/database/index.ts
// src/database/database.ts
var Database = class _Database {

@@ -1033,12 +1034,2 @@ constructor(_client, _ai, name, workspaceName) {

// ../utils/dist/index.mjs
function getKeyByValue(object, value) {
for (const key in object) {
if (object[key] === value) {
return key;
}
}
return void 0;
}
// src/workspace/private-connection/manager.ts

@@ -1068,3 +1059,3 @@ var import_url = require("url");

// src/workspace/index.ts
// src/workspace/workspace.ts
var Workspace = class _Workspace extends APIManager {

@@ -1234,3 +1225,13 @@ constructor(api, _ai, id, groupID, name, endpoint, size, state, scaleFactor, scalingProgress, cacheConfig, kaiEnabled, deploymentType, createdAt, lastResumedAt, terminatedAt, autoSuspend, resumeAttachments) {

// src/workspace-group/stage/index.ts
// ../utils/dist/index.mjs
function getKeyByValue(object, value) {
for (const key in object) {
if (object[key] === value) {
return key;
}
}
return void 0;
}
// src/workspace-group/stage/stage.ts
var WorkspaceGroupStage = class _WorkspaceGroupStage extends APIManager {

@@ -1395,3 +1396,3 @@ constructor(api, _workspaceGroupID, name, content, type, path, format, mimetype, size, writable, createdAt, modifiedAt) {

// src/workspace-group/index.ts
// src/workspace-group/workspace-group.ts
var updateWindowDaysMap = {

@@ -1556,4 +1557,3 @@ 0: "su",

// src/index.ts
var import_mysql22 = require("mysql2");
// src/client.ts
var SingleStoreClient = class {

@@ -1586,3 +1586,3 @@ _ai;

0 && (module.exports = {
QueryBuilder,
Connection,
SingleStoreClient,

@@ -1589,0 +1589,0 @@ escape

{
"name": "@singlestore/client",
"version": "0.0.36",
"version": "0.0.37",
"license": "Apache-2.0",

@@ -18,2 +18,92 @@ "sideEffects": false,

"require": "./dist/index.js"
},
"./api": {
"types": "./dist/api.d.ts",
"import": "./dist/api.mjs",
"require": "./dist/api.js"
},
"./billing": {
"types": "./dist/billing.d.ts",
"import": "./dist/billing.mjs",
"require": "./dist/billing.js"
},
"./column": {
"types": "./dist/column.d.ts",
"import": "./dist/column.mjs",
"require": "./dist/column.js"
},
"./connection": {
"types": "./dist/connection.d.ts",
"import": "./dist/connection.mjs",
"require": "./dist/connection.js"
},
"./database": {
"types": "./dist/database.d.ts",
"import": "./dist/database.mjs",
"require": "./dist/database.js"
},
"./job": {
"types": "./dist/job.d.ts",
"import": "./dist/job.mjs",
"require": "./dist/job.js"
},
"./organization": {
"types": "./dist/organization.d.ts",
"import": "./dist/organization.mjs",
"require": "./dist/organization.js"
},
"./private-connection": {
"types": "./dist/private-connection.d.ts",
"import": "./dist/private-connection.mjs",
"require": "./dist/private-connection.js"
},
"./query": {
"types": "./dist/query.d.ts",
"import": "./dist/query.mjs",
"require": "./dist/query.js"
},
"./region": {
"types": "./dist/region.d.ts",
"import": "./dist/region.mjs",
"require": "./dist/region.js"
},
"./secret": {
"types": "./dist/secret.d.ts",
"import": "./dist/secret.mjs",
"require": "./dist/secret.js"
},
"./table": {
"types": "./dist/table.d.ts",
"import": "./dist/table.mjs",
"require": "./dist/table.js"
},
"./team": {
"types": "./dist/team.d.ts",
"import": "./dist/team.mjs",
"require": "./dist/team.js"
},
"./workspace": {
"types": "./dist/workspace/index.d.ts",
"import": "./dist/workspace/index.mjs",
"require": "./dist/workspace/index.js"
},
"./workspace/private-connection": {
"types": "./dist/workspace/private-connection.d.ts",
"import": "./dist/workspace/private-connection.mjs",
"require": "./dist/workspace/private-connection.js"
},
"./workspace-group": {
"types": "./dist/workspace-group/index.d.ts",
"import": "./dist/workspace-group/index.mjs",
"require": "./dist/workspace-group/index.js"
},
"./stage": {
"types": "./dist/workspace-group/stage.d.ts",
"import": "./dist/workspace-group/stage.mjs",
"require": "./dist/workspace-group/stage.js"
},
"./storage": {
"types": "./dist/workspace-group/storage.d.ts",
"import": "./dist/workspace-group/storage.mjs",
"require": "./dist/workspace-group/storage.js"
}

@@ -20,0 +110,0 @@ },

@@ -5,24 +5,202 @@ # SingleStore Client

<details>
<summary>
## Table of Contents
</summary>
- [Installation](#installation)
- [Usage Examples](#usage-examples)
- [Create an Instance](#create-an-instance)
- [Connect to a Workspace](#connect-to-a-workspace)
- [Create a Database](#create-a-database)
- [Use a Database](#use-a-database)
- [Create a Table](#create-a-table)
- [Insert Values](#insert-values)
- [Find Values](#find-values)
- [Find Values by a Condition](#find-values-by-a-condition)
- [Update Values by a Condition](#update-values-by-a-condition)
- [Add AI Functionality](#add-ai-functionality)
- [Perform a Vector Search](#perform-a-vector-search)
- [Create a Chat Completion Stream](#create-a-chat-completion-stream)
- [Advanced Usage](#advanced-usage)
- [Usage](#usage)
- [Initialization](#initialization)
- [Default](#default)
- [With Management API Access](#with-management-api-access)
- [With AI Functionality](#with-ai-functionality)
- [Additional Notes](#additional-notes)
- [Organization](#organization)
- [Get Current Organization](#get-current-organization)
- [Workspace Group](#workspace-group)
- [Get Workspace Group](#get-workspace-group)
- [All Workspace Groups](#all-workspace-groups)
- [By Workspace Group ID](#by-workspace-group-id)
- [By Workspace Group Name](#by-workspace-group-name)
- [Additional Notes](#additional-notes-1)
- [Create Workspace Group](#create-workspace-group)
- [Additional Notes](#additional-notes-2)
- [Update Workspace Group](#update-workspace-group)
- [By Workspace Group ID](#by-workspace-group-id-1)
- [Selected Workspace Group](#selected-workspace-group)
- [Additional Notes](#additional-notes-3)
- [Delete Workspace Group](#delete-workspace-group)
- [By Workspace Group ID](#by-workspace-group-id-2)
- [Selected Workspace Group](#selected-workspace-group-1)
- [Additional Notes](#additional-notes-4)
- [Get Metrics](#get-metrics)
- [Get Private Connections](#get-private-connections)
- [Workspace](#workspace)
- [Connect Workspace](#connect-workspace)
- [Using Client](#using-client)
- [Using Workspace Group](#using-workspace-group)
- [Get Workspace](#get-workspace)
- [All Workspaces](#all-workspaces)
- [By Workspace ID](#by-workspace-id)
- [By Workspace Name](#by-workspace-name)
- [Additional Notes](#additional-notes-5)
- [Create Workspace](#create-workspace)
- [Additional Notes](#additional-notes-6)
- [Update Workspace](#update-workspace)
- [By Workspace ID](#by-workspace-id-1)
- [Selected Workspace](#selected-workspace)
- [Additional Notes](#additional-notes-7)
- [Delete Workspace](#delete-workspace)
- [By Workspace ID](#by-workspace-id-2)
- [Selected Workspace](#selected-workspace-1)
- [Get Workspace State](#get-workspace-state)
- [By Workspace ID](#by-workspace-id-3)
- [Selected Workspace](#selected-workspace-2)
- [Resume Workspace](#resume-workspace)
- [By Workspace ID](#by-workspace-id-4)
- [Selected Workspace](#selected-workspace-3)
- [Additional Notes](#additional-notes-8)
- [Suspend Workspace](#suspend-workspace)
- [By Workspace ID](#by-workspace-id-5)
- [Selected Workspace](#selected-workspace-4)
- [Database](#database)
- [Use Database](#use-database)
- [Create Database](#create-database)
- [Drop Database](#drop-database)
- [By Database Name](#by-database-name)
- [Selected Database](#selected-database)
- [Query Database](#query-database)
- [Additional Notes](#additional-notes-9)
- [Describe Database](#describe-database)
- [Show Database Info](#show-database-info)
- [Show Database Tables Info](#show-database-tables-info)
- [Table](#table)
- [Use Table](#use-table)
- [Create Table](#create-table)
- [Drop Table](#drop-table)
- [By Table Name](#by-table-name)
- [Selected Table](#selected-table)
- [Truncate Table](#truncate-table)
- [By Table Name](#by-table-name-1)
- [Selected Table](#selected-table-1)
- [Rename Table](#rename-table)
- [By Table Name](#by-table-name-2)
- [Selected Table](#selected-table-2)
- [Show Table Info](#show-table-info)
- [Show Table Columns Info](#show-table-columns-info)
- [Insert Table Value](#insert-table-value)
- [Single Value](#single-value)
- [Multiple Values](#multiple-values)
- [Find Table Values](#find-table-values)
- [Find All Values](#find-all-values)
- [Find Values By Condition](#find-values-by-condition)
- [Additional Notes](#additional-notes-10)
- [Update Table Values](#update-table-values)
- [Delete Table Values](#delete-table-values)
- [Additional Notes](#additional-notes-11)
- [Table Vector Search](#table-vector-search)
- [Basic](#basic)
- [With Conitoins](#with-conditions)
- [Additional Notes](#additional-notes-12)
- [Create Table Chat Completion](#create-table-chat-completion)
- [As String](#as-string)
- [As Stream](#as-stream)
- [With Custom Tools](#with-custom-tools)
- [Additional Notes](#additional-notes-13)
- [Column](#column)
- [Use Column](#use-column)
- [Add Column](#add-column)
- [Modify Column](#modify-column)
- [By Column Name](#by-column-name)
- [Selected Column](#selected-column)
- [Rename Column](#rename-column)
- [By Column Name](#by-column-name-1)
- [Selected Column](#selected-column-1)
- [Drop Column](#drop-column)
- [By Column Name](#by-column-name-2)
- [Selected Column](#selected-column-2)
- [Show Column Info](#show-column-info)
- [By Column Name](#by-column-name-3)
- [Selected Column](#selected-column-3)
- [Billing](#billing)
- [Get Billing](#get-billing)
- [Region](#region)
- [Get All Regions](#get-all-regions)
- [Get Region by ID](#get-region-by-id)
- [Get Region by Name](#get-region-by-name)
- [Additional Notes](#additional-notes-14)
- [Team](#team)
- [Get Team](#get-team)
- [Get All Teams](#get-all-teams)
- [Get Team by ID](#get-team-by-id)
- [Get Team by Name](#get-team-by-name)
- [Get Team by Description](#get-team-by-description)
- [Create Team](#create-team)
- [Update Team](#update-team)
- [By Team ID](#by-team-id)
- [Selected Team](#selected-team)
- [Delete Team](#delete-team)
- [By Team ID](#by-team-id-1)
- [Selected Team](#selected-team-1)
- [Add Team Member](#add-team-member)
- [Add Team](#add-team)
- [By Team ID](#by-team-id-2)
- [Selected Team](#selected-team-2)
- [Add User](#add-user)
- [By Team ID](#by-team-id-3)
- [Selected Team](#selected-team-3)
- [Remove Team Member](#remove-team-member)
- [Remove Team](#remove-team)
- [By Team ID](#by-team-id-4)
- [Selected Team](#selected-team-4)
- [Remove User](#remove-user)
- [By Team ID](#by-team-id-5)
- [Selected Team](#selected-team-5)
- [Job](#job)
- [Get Job](#get-job)
- [Create Job](#create-job)
- [Delete Job](#delete-job)
- [By Job ID](#by-job-id)
- [Selected Job](#selected-job)
- [Get Job Executions](#get-job-executions)
- [By Job ID](#by-job-id-1)
- [Selected Job](#selected-job-1)
- [Get Job Parameters](#get-job-parameters)
- [By Job ID](#by-job-id-2)
- [Selected Job](#selected-job-2)
- [Get Job Runtimes](#get-job-runtimes)
- [Secret](#secret)
- [Get Secret](#get-secret)
- [By Secret ID](#by-secret-id)
- [By Secret name](#by-secret-name)
- [Create Secret](#create-secret)
- [Update Secret](#update-secret)
- [By Secret ID](#by-secret-id)
- [Selected Secret](#selected-secret)
- [Delete Secret](#delete-secret)
- [By Secret ID](#by-secret-id-1)
- [Selected Secret](#selected-secret-1)
- [Stage](#stage)
- [Get All Stage](#get-all-stage)
- [Get Stage Folder](#get-stage-folder)
- [Get Stage File](#get-stage-file)
- [Update Stage](#update-stage)
- [By Stage Path](#by-stage-path)
- [Selected Stage](#selected-stage)
- [Create Stage Folder](#create-stage-folder)
- [In Stage Path](#in-stage-path)
- [In Selected Stage](#in-selected-stage)
- [Delete Stage](#delete-stage)
- [By Stage Path](#by-stage-path-1)
- [Selected Stage](#selected-stage-1)
- [Storage](#storage)
- [Get Storage Regions](#get-storage-regions)
- [Get Storage Status](#get-storage-status)
</details>
## Installation
To install the `@singlestore/client` package, run the following command:
```bash

@@ -32,8 +210,12 @@ npm install @singlestore/client

## Usage Examples
## Usage
### Create an Instance
### Initialization
Instantiate the `SingleStoreClient` to interact with the SingleStore.
The SingleStoreClient can be initialized in multiple ways, depending on your needs. Below are examples of how to initialize the client in various scenarios.
#### Default
Use this method if you don’t need Management API access or AI integration.
```ts

@@ -45,138 +227,408 @@ import { SingleStoreClient } from "@singlestore/client";

### Connect to a Workspace
#### With Management API Access
Connect to a specific workspace using your workspace credentials.
This method is used when you need to access SingleStore's management API.
```ts
const connection = client.connect({
host: "<DATABASE_HOST>",
user: "<DATABASE_USER>",
password: "<DATABASE_PASSWORD>",
import { SingleStoreClient } from "@singlestore/client";
const client = new SingleStoreClient({ apiKey: "<SINGLESTORE_API_KEY>" });
```
#### With AI Functionality
If you want to integrate AI features, use this method. You need to pass an AI instance with the required API key.
```bash
npm install @singlestore/ai
```
```ts
import { AI } from "@singlestore/ai";
import { SingleStoreClient } from "@singlestore/client";
const ai = new AI({ openAIApiKey: "<OPENAI_API_KEY>" });
const client = new SingleStoreClient({ ai });
```
#### Additional Notes
- The SingleStoreClient class is flexible, allowing you to pass only the features you need (e.g., AI, API key). It will automatically configure the services based on the provided options.
- You can also use custom LLMs instead of the pre-installed OpenAI. To do this, see the [`@singlestore/ai`](https://github.com/singlestore-labs/singlestore/tree/main/packages/ai) package [documentation](https://github.com/singlestore-labs/singlestore/blob/main/packages/ai/README.md).
---
### Organization
#### Get Current Organization
Returns the current organization if an API key was provided during initialization.
```ts
const organization = await client.organization.get();
```
---
### Workspace Group
#### Get Workspace Group
##### All Workspace Groups
```ts
const workspaceGroups = await client.workspaceGroup.get();
```
##### By Workspace Group ID
```ts
const workspaceGroup = await client.workspaceGroup.get({
where: { id: "<WORKSPACE_GROUP_ID>" },
});
```
### Create a Database
##### By Workspace Group Name
Create a new database within the connected workspace.
```ts
const workspaceGroup = await client.workspaceGroup.get({
where: { name: "<WORKSPACE_GROUP_NAME>" },
});
```
##### Additional Notes
- To include terminated workspace groups, add the `includeTerminated: true` parameter to the `workspaceGroup.get` options object.
- To select specific fields from a workspace group, add the `select: ['<FIELD_NAME_TO_SELECT>']` parameter to the `workspaceGroup.get` options object.
---
#### Create Workspace Group
```ts
const database = await connection.database.create({ name: "my_database" });
const { workspaceGroup, adminPassword } = await client.workspaceGroup.create({
name: "<WORKSPACE_GROUP_NAME>",
regionName: "US West 2 (Oregon)",
adminPassword: "<WORKSPACE_GROUP_PASSWORD>",
allowAllTraffic: false,
firewallRanges: ["IP_ADDRESS"],
dataBucketKMSKeyID: "<ID>",
backupBucketKMSKeyID: "<ID>",
updateWindow: { day: "mo", hour: 12 },
expiresAt: new Date("2025-01-01"),
});
```
### Use a Database
##### Additional Notes
Select and use an existing database.
- Only the `name` and `regionName` fields are required to create a workspace group. All other fields are optional.
- If the `adminPassword` value is not provided, a generated password is returned.
- To find all available `regionName` values, refer to this [link](https://github.com/singlestore-labs/singlestore/blob/main/packages/client/src/region/region.ts#L3).
---
#### Update Workspace Group
You can update a workspace group by specifying the workspace group ID or by calling the `update` method on a selected Workspace Group instance.
##### By Workspace Group ID
```ts
const database = await connection.database.use("my_database");
await client.workspaceGroup.update("<WORKSPACE_GROUP_ID>", {
name: "<NEW_WORKSPACE_GROUP_NAME>",
adminPassword: "<NEW_WORKSPACE_GROUP_PASSWORD>",
allowAllTraffic: true,
firewallRanges: ["<NEW_IP_ADDRESS>"],
updateWindow: { day: "mo", hour: 12 },
expiresAt: new Date("2025-01-01"),
});
```
### Create a Table
##### Selected Workspace Group
Create a table within the selected database with specified columns and attributes.
Updates the currently selected workspace group.
```ts
const usersTable = await database.table.create({
name: "users",
columns: {
id: { type: "BIGINT", autoIncrement: true, primaryKey: true },
name: { type: "VARCHAR(32)" },
role: { type: "VARCHAR(32)" },
},
await workspaceGroup.update({
name: "<NEW_WORKSPACE_GROUP_NAME>",
adminPassword: "<NEW_WORKSPACE_GROUP_PASSWORD>",
allowAllTraffic: true,
firewallRanges: ["<NEW_IP_ADDRESS>"],
updateWindow: { day: "mo", hour: 12 },
expiresAt: new Date("2025-01-01"),
});
```
### Insert Values
##### Additional Notes
Insert multiple records into a table.
- All fields are optional when updating a workspace group.
---
#### Delete Workspace Group
You can delete a workspace group by specifying the workspace group ID or by calling the `delete` method on a selected Workspace Group instance.
##### By Workspace Group ID
```ts
await usersTable.insert([
{ name: "User 1", role: "admin" },
{ name: "User 2", role: "visitor" },
]);
await client.workspaceGroup.delete("<WORKSPACE_GROUP_ID>", false);
```
### Find Values
##### Selected Workspace Group
Retrieve all records from a table.
Deletes the currently selected workspace group.
```ts
const users = await usersTable.find();
await workspaceGroup.delete(false);
```
### Find Values by a Condition
##### Additional Notes
Retrieve records that match specific conditions.
- To forcibly delete a workspace group, set the optional `force` argument to `true`.
---
#### Get Metrics
```ts
const admins = await usersTable.find({ where: { role: "admin" } });
const metrics = await workspaceGroup.getMetrics();
```
### Update Values by a Condition
---
Update records that meet certain conditions.
#### Get Private Connections
```ts
await usersTable.update({ role: "admin" }, { name: "User 2" });
const privateConnections = await workspaceGroup.getPrivateConnections();
```
### Add AI Functionality
---
Integrate AI capabilities using the SingleStore AI package.
### Workspace
#### Connect Workspace
##### Using Client
```ts
import { AI } from "@singlestore/ai";
import { SingleStoreClient } from "@singlestore/client";
const connection = client.connect({
host: "<WORKSPACE_HOST>",
user: "<WORKSPACE_USER>",
password: "<WORKSPACE_PASSWORD>",
port: <WORKSPACE_PORT>
});
```
const ai = new AI({ openAIApiKey: "<OPENAI_API_KEY>" });
const client = new SingleStoreClient({ ai });
##### Using Workspace Group
```ts
const workspace = await workspaceGroup.workspace.get({
where: { id: "<WORKSPACE_ID>" },
});
if (workspace) {
const connection = workspace.connect({
user: "<WORKSPACE_USER>",
password: "<WORKSPACE_PASSWORD>",
port: <WORKSPACE_PORT>,
});
}
```
### Perform a Vector Search
---
Execute a vector search on a table to find relevant records.
#### Get Workspace
##### All Workspaces
```ts
const results = await usersTable.vectorSearch(
{ prompt: "A 4k monitor", vectorColumn: "description_v" },
{ select: ["name", "description", "price"], limit: 1 },
);
const workspace = await workspaceGroup.workspace.get();
```
### Create a Chat Completion Stream
##### By Workspace ID
Generate a chat completion or stream based on prompt and vector search results.
```ts
const workspace = await workspaceGroup.workspace.get({
where: { id: "<WORKSPACE_ID>" },
});
```
##### By Workspace Name
```ts
const stream = await usersTable.createChatCompletion(
{ prompt: "Find a 4k monitor", vectorColumn: "description_v", stream: true },
{ select: ["name", "description", "price"], limit: 1 },
);
const workspace = await workspaceGroup.workspace.get({
where: { name: "<WORKSPACE_NAME>" },
});
```
const onChunk: OnChatCompletionChunk = (chunk) => console.log(chunk);
##### Additional Notes
const chatCompletion = await ai.chatCompletions.handleStream(stream, onChunk);
console.log(chatCompletion);
- To include terminated workspaces, add the `includeTerminated: true` parameter to the `workspaceGroup.workspace.get` options object.
- To select specific fields from a workspace group, add the `select: ['<FIELD_NAME_TO_SELECT>']` parameter to the `workspaceGroup.workspace.get` options object.
---
#### Create Workspace
```ts
const workspace = await workspaceGroup.workspace.create({
name: "WORKSPACE_NAME",
size: "S-00",
enableKai: true,
cacheConfig: 1,
scaleFactor: 1,
autoSuspend: {
suspendType: "SCHEDULED",
suspendAfterSeconds: 1200,
},
});
```
### Advanced Usage
##### Additional Notes
A more complex example demonstrating advanced queries and table joins.
- Only the `name` field is required to create a workspace. All other fields are optional.
- To find all available `size` values, refer to the [SingleStore Helios Pricing](https://www.singlestore.com/cloud-pricing/) page.
---
#### Update Workspace
##### By Workspace ID
```ts
interface StoreDatabase {
name: "store_database";
await workspaceGroup.workspace.update("<WORKSPACE_ID>", {
size: "S-00",
enableKai: true,
cacheConfig: 1,
scaleFactor: 1,
deploymentType: "PRODUCTION",
autoSuspend: {
suspendType: "SCHEDULED",
suspendAfterSeconds: 1200,
},
});
```
##### Selected Workspace
```ts
await workspace.update({
size: "S-00",
enableKai: true,
cacheConfig: 1,
scaleFactor: 1,
deploymentType: "PRODUCTION",
autoSuspend: {
suspendType: "SCHEDULED",
suspendAfterSeconds: 1200,
},
});
```
##### Additional Notes
- All fields are optional when updating a workspace.
---
#### Delete Workspace
##### By Workspace ID
```ts
await workspaceGroup.workspace.delete("<WORKSPACE_ID>");
```
##### Selected Workspace
```ts
await workspace.delete();
```
---
#### Get Workspace State
##### By Workspace ID
```ts
const state = await workspaceGroup.workspace.getState("<WORKSPACE_ID>");
```
##### Selected Workspace
```ts
const state = await workspace.getState();
```
---
#### Resume Workspace
##### By Workspace ID
```ts
await workspaceGroup.workspace.resume("<WORKSPACE_ID>", { disableAutoSuspend: false });
```
##### Selected Workspace
```ts
await workspace.resume({ disableAutoSuspend: false });
```
##### Additional Notes
- The `disableAutoSuspend` parameter is optional.
---
#### Suspend Workspace
##### By Workspace ID
```ts
await workspaceGroup.workspace.suspend("<WORKSPACE_ID>");
```
##### Selected Workspace
```ts
await workspace.suspend();
```
---
### Database
#### Use Database
The `use` method allows you to interact with a specific database within the connection. You can optionally provide a generic `DatabaseSchema` to describe the database schema and its tables.
```ts
interface DatabaseSchema extends DatabaseType {
name: "<DATABASE_NAME>";
tables: {
products: {
users: {
id: number;
name: string;
description: string;
price: number;
category_id: number;
description_v: string;
};
categories: {
};
}
const database = connection.database.use<DatabaseSchema>("<DATABASE_NAME>");
```
---
#### Create Database
The `create` method allows you to create a database within the connection. You can optionally provide a generic `DatabaseSchema` to describe the database schema and its tables.
```ts
interface DatabaseSchema extends DatabaseType {
name: "<DATABASE_NAME>";
tables: {
users: {
id: number;
name: string;
};

@@ -186,30 +638,976 @@ };

const client = new SingleStoreClient({ ai });
const database = await connection.database.create<DatabaseSchema>({
name: "<DATABASE_NAME>",
tables: {
users: {
columns: {
id: {
type: "BIGINT",
autoIncrement: true, // Optional
primaryKey: true, // Optional
nullable: false, // Optional
default: 0, // Optional
clauses: ["<CUSTOM_CLAUSE>"], // Optional
},
},
clauses: ["<CUSTOM_CLAUSE>"], // Optional
fulltextKeys: ["<COLUMN_NAME>"], // Optional
primaryKeys: ["<COLUMN_NAME>"], // Optional
},
},
});
```
const connection = client.connect({
host: "<DATABASE_HOST>",
user: "<DATABASE_USER>",
password: "<DATABASE_PASSWORD>",
---
#### Drop Database
##### By Database Name
```ts
await connection.database.drop("<DATABASE_NAME>");
```
##### Selected Database
```ts
await database.drop();
```
---
#### Query Database
The `query` method allows you to execute a MySQL query on the database and retrieve the result. The query result is returned as an array of rows, where each row is represented as an object with column names as keys and the corresponding values.
```ts
type RowType = { [K: string]: any }[];
const [rows] = await database.query<RowType>("<MYSQL_QUERY>");
```
##### Additional Notes
- Ensure that the query string is properly formatted to prevent SQL errors.
- The `RowType` is a flexible type that can accommodate various column structures in the query result.
---
#### Describe Database
```ts
const info = await database.describe();
```
---
#### Show Database Info
The `showInfo` method allows you to retrieve information about the database. You can optionally request extended information by setting the `isExtended` argument to `true`.
```ts
const info = await database.showInfo(true);
```
---
#### Show Database Tables Info
The `showTablesInfo` method allows you to retrieve information about the database tables. You can optionally request extended information by setting the `isExtended` argument to `true`.
```ts
const tablesInfo = await database.showTablesInfo(true);
```
---
### Table
#### Use Table
The `use` method allows you to access a specific table within the database. It optionally accepts a table name and schema, providing an interface to interact with the table for querying and manipulation.
```ts
type TableName = "<TABLE_NAME>";
type TableSchema = { [K: string]: any };
const table = database.table.use<TableName, TableSchema>("<TABLE_NAME>");
```
---
#### Create Table
The `create` method allows you to create a new table in the database. You can define the table name and schema, specifying columns and their properties such as data types, constraints, and default values.
```ts
type TableName = "<TABLE_NAME>";
type TableSchema = { id: number };
const table = await database.table.create<TableName, TableSchema>({
name: "<TABLE_NAME>",
columns: {
id: {
type: "BIGINT",
autoIncrement: true, // Optional
primaryKey: true, // Optional
nullable: false, // Optional
default: 0, // Optional
clauses: ["<CUSTOM_CLAUSE>"], // Optional
},
},
});
```
const database = connection.database.use<StoreDatabase>("store_database");
---
const products = await database.table.use("products").find({
select: ["id", "name", "description", "price", "category.name"],
#### Drop Table
##### By Table Name
```ts
await database.table.drop("<TABLE_NAME>");
```
##### Selected Table
```ts
await table.drop();
```
---
#### Truncate Table
##### By Table Name
```ts
await database.table.truncate("<TABLE_NAME>");
```
##### Selected Table
```ts
await table.truncate();
```
---
#### Rename Table
##### By Table Name
```ts
await database.table.rename("<TABLE_NAME>", "<TABLE_NEW_NAME>");
```
##### Selected Table
```ts
await table.rename("<TABLE_NEW_NAME>");
```
---
#### Show Table Info
The `showInfo` method allows you to retrieve information about the table. You can optionally request extended information by setting the `isExtended` argument to `true`.
```ts
const tableInfo = await table.showInfo(true);
```
---
#### Show Table Columns Info
The `showInfo` method allows you to retrieve information about the table columns.
```ts
const tableColumnsInfo = await table.showColumnsInfo();
```
---
#### Insert Table Value
The `insert` method allows you to insert data into a table. You can insert a single value or multiple values at once by providing an object or an array of objects that map column names to values.
##### Single Value
```ts
await table.insert({columnName: <VALUE>})
```
##### Multiple Values
```ts
await table.insert([{columnName: <VALUE>}, {columnName: <VALUE_2>}])
```
---
#### Find Table Values
The `find` method allows you to retrieve values from a table, with optional support for conditions, joins, grouping, ordering, and pagination. You can either fetch all values from a table or apply conditions to narrow down th
##### Find All Values
Retrieves all values from the table without any conditions.
```ts
const values = await table.find();
```
##### Find Values By Condition
Retrieves values from the table based on the specified conditions. You can customize the query with select, join, where, groupBy, orderBy, limit, and offset options.
```ts
const values = await table.find({
select: ["<COLUMN_NAME>", "COUNT(*) AS count"], // Optional
join: [
{
table: "categories",
as: "category",
on: ["category_id", "=", "id"],
type: "FULL", // Supported values: "INNER" | "LEFT" | "RIGHT" | "FULL"
table: "<JOIN_TABLE_NAME>",
as: "<JOIN_TABLE_AS>",
on: [
"<COLUMN_NAME>",
"=", // Supported values: "=" | "<" | ">" | "<=" | ">=" | "!="
"<JOIN_COLUMN_NAME>",
],
},
],
where: {
"category.id": 1,
"price": { gte: 500 },
], // Optional
where: { columnName: "<COLUMN_VALUE>" }, // Optional
groupBy: ["<COLUMN_NAME>"], // Optional
orderBy: {
columnName: "asc", // Supported values: "asc" | "desc"
}, // Optional
limit: 10, // Optional
offset: 10, // Optional
});
```
##### Additional Notes
- The `COUNT(*) AS count` pattern follows the `clause AS alias` structure, where `COUNT(*)` is the `clause` and `count` is the `alias`.
- Ensure that joins, conditions, and selected columns are appropriate for the table schema and the data you're trying to retrieve.
---
#### Update Table Values
The `update` method allows you to modify existing values in the table. You provide the new values to update, along with a condition to specify which rows should be updated.
```ts
await table.update(
{ columnName: "<NEW_COLUMN_VALUE>" }, // New value
{ columnName: "<COLUMN_VALUE>" }, // Where condition
);
```
---
#### Delete Table Values
The `delete` method allows you to remove rows from the table that match a specified condition.
```ts
await table.delete({ columnName: "<COLUMN_VALUE>" });
```
##### Additional Notes
- Be cautious when using the `delete` method, especially if the where condition is broad, as it could result in the removal of multiple rows.
- If no where condition is provided, all rows in the table will be deleted. It’s best practice to always provide a where clause to avoid accidental data loss.
---
#### Table Vector Search
The `vectorSearch` method allows you to perform searches using vector-based embeddings in a specified column. This is particularly useful for tasks such as semantic search, where results are based on the similarity of vector representations of text or data.
##### Basic
Performs a vector search based on a prompt, returning rows from the table that match the vector similarity.
```ts
const rows = await table.vectorSearch({
prompt: "<PROMPT>",
vectorColumn: "<VECTOR_COLUMN_NAME>",
embeddingParams: {
model: "<MODEL_NAME>", // Optional
dimensions: "<VECTOR_DIMENSTION>", // Optional
}, // Optional
});
```
##### With Conditions
Performs a vector search with additional conditions such as selected columns, joins, filtering, grouping, ordering, and pagination.
```ts
const rows = await table.vectorSearch(
{
prompt: "<PROMPT>",
vectorColumn: "<VECTOR_COLUMN_NAME>",
embeddingParams: {
model: "<MODEL_NAME>", // Optional
dimensions: "<VECTOR_DIMENSTION>", // Optional
},
}, // Optional
{
select: ["<COLUMN_NAME>"], // Optional
join: [
{
type: "FULL", // Supported values: "INNER" | "LEFT" | "RIGHT" | "FULL"
table: "<JOIN_TABLE_NAME>",
as: "<JOIN_TABLE_AS>",
on: [
"<COLUMN_NAME>",
"=", // Supported values: "=" | "<" | ">" | "<=" | ">=" | "!="
"<JOIN_COLUMN_NAME>",
],
},
], // Optional
where: { columnName: "<COLUMN_VALUE>" }, // Optional
groupBy: ["<COLUMN_NAME>"], // Optional
orderBy: {
columnName: "asc", // Supported values: "asc" | "desc"
}, // Optional
limit: 10, // Optional
offset: 10, // Optional
}, // Optional
);
```
##### Additional Notes
- The `vectorSearch` method returns both the table rows and a `v_score` field, which reflects the similarity score of each row to the search prompt.
- Conditions such as `select`, `join`, `where`, and others can be used to refine the results further, similar to standard SQL queries.
---
#### Create Table Chat Completion
The `createChatCompletion` method allows you to generate chat completions based on a vector search within a table. Depending on the `stream` option, you can retrieve the results either as a complete string or in a streamed fashion, with optional custom tools for enhancing functionality.
##### As String
Performs a chat completion based on a vector search and returns the result as a complete string.
```ts
const chatCompletion = await table.createChatCompletion(
{
model: "<MODEL_NAME>", // Optional
prompt: "<PROMPT>",
systemRole: "<SYSTEM_ROLE>", // Optional
vectorColumn: "<VECTOR_COLUMN_NAME>",
stream: false,
temperature: 0, // Optional
embeddingParams: {
model: "<MODEL_NAME>", // Optional
dimensions: "<VECTOR_DIMENSTION>", // Optional
}, // Optional
},
orderBy: { price: "desc" },
limit: 5,
{
select: ["<COLUMN_NAME>"], // Optional
where: { columnName: "<COLUMN_VALUE>" }, // Optional
limit: 1, // Optional
}, // Optional
);
```
##### As Stream
Performs a chat completion and returns the result as a stream of data chunks.
```ts
const stream = await table.createChatCompletion(
{
stream: true,
...
},
);
const chatCompletion = await ai.chatCompletions.handleStream(stream, (chunk) => {
console.log(chunk);
});
```
console.log(products);
##### With Custom Tools
You can also integrate custom tools to extend the functionality of the chat completion.
```ts
import { ChatCompletionTool } from "@singlestore/ai/chat-completions";
import { z } from "zod";
const customTool = new ChatCompletionTool({
name: "<TOOL_NAME>",
description: "<TOOL_DESCRIPTION>",
params: z.object({ paramName: z.string().describe("<PARAM_DESCRIPTION>") }),
call: async (params) => {
const value = await anyFnCall(params);
return { name: "<TOOL_NAME>", params, value: JSON.stringify(value) };
},
});
await table.createChatCompletion({
tools: [customTool],
...
});
```
##### Additional Notes
- The second argument of the `createChatCompletion` method accepts the same options as the second argument of the `vectorSearch` method, such as `select`, `where`, and `limit`.
- When using `stream: true`, the `handleStream` function is used to process the stream. It accepts a callback as the second argument, which handles each new chunk of data as it arrives.
---
### Column
##### Use Column
```ts
const column = table.column.use("<COLUMN_NAME>");
```
---
#### Add Column
```ts
const column = await table.column.add({
name: "<NEW_COLUMN_NAME>",
type: "BIGINT",
autoIncrement: false, // Optional
primaryKey: false, // Optional
nullable: true, // Optional
default: 0, // Optional
clauses: ["<CUSTOM_CLAUSE>"], // Optional
});
```
---
#### Modify Column
##### By Column Name
```ts
await table.column.modify("<COLUMN_NAME>", {
type: "BIGINT",
autoIncrement: false, // Optional
primaryKey: false, // Optional
nullable: true, // Optional
default: 0, // Optional
clauses: ["<CUSTOM_CLAUSE>"], // Optional
});
```
##### Selected Column
```ts
await column.modify(...)
```
---
#### Rename Column
##### By Column Name
```ts
await table.column.rename("<COLUMN_NAME>", "<NEW_COLUMN_NAME>");
```
##### Selected Column
```ts
await column.modify("<NEW_COLUMN_NAME>");
```
---
#### Drop Column
##### By Column Name
```ts
await table.column.drop("<COLUMN_NAME>");
```
##### Selected Column
```ts
await column.drop();
```
---
#### Show Column Info
##### By Column Name
```ts
await table.column.showInfo("<COLUMN_NAME>");
```
##### Selected Column
```ts
await column.showInfo();
```
---
### Billing
#### Get Billing
```ts
const billing = await client.billing.get({
metric: "ComputeCredit", // Supported values: "ComputeCredit" | "StorageAvgByte"
startTime: new Date("2024-01-01"),
endTime: new Date("2024-01-09"),
aggregateBy: "month", // Supported values: "hour", "day", "month"; Optional
});
```
---
### Region
#### Get Region
##### Get All Regions
```ts
const regions = await client.region.get();
```
##### Get Region By ID
```ts
const region = await client.region.get({ id: "<REGION_ID>" });
```
##### Get Region By Name
```ts
const region = await client.region.get({ name: "<REGION_NAME>" });
```
##### Additional Notes
- To find all available region names, follow this [link](https://github.com/singlestore-labs/singlestore/blob/67e9c837465c130525300a8fdff7acb9abc6e056/packages/client/src/region/region.ts#L3)
---
### Team
#### Get Team
##### Get All Teams
```ts
const teams = await client.team.get();
```
##### Get Team By ID
```ts
const team = await client.team.get({ id: "<TEAM_ID>" });
```
##### Get Team By Name
```ts
const team = await client.team.get({ name: "<TEAM_NAME>" });
```
##### Get Team By Description
```ts
const team = await client.team.get({ description: "<TEAM_DESCRIPTION>" });
```
---
#### Create Team
```ts
const team = await client.team.create({
name: "<TEAM_NAME>",
description: "<TEAM_DESCRIPTION>", // Optional
memberTeams: ["<TEAM_ID>"], // Optional
memberUsers: ["<USER_ID>"], // Optional
});
```
---
#### Update Team
##### By Team ID
```ts
await client.team.update("<TEAM_ID>", {
name: "<NEW_TEAM_NAME>", // Optional
description: "<NEW_TEAM_DESCRIPTION>", // Optional
});
```
##### Selected Team
```ts
await team.update(...);
```
---
#### Delete Team
##### By Team ID
```ts
await client.team.delete("<TEAM_ID>");
```
##### Selected Team
```ts
await team.delete();
```
---
#### Add Team Member
##### Add Team
###### By Team ID
```ts
await client.team.addMemberTeams("<TEAM_ID>", ["<ADD_TEAM_ID>"]);
```
###### Selected Team
```ts
await team.addMemberTeams(["<ADD_TEAM_ID>"]);
```
##### Add User
###### By Team ID
```ts
await client.team.addMemberUsers("<TEAM_ID>", ["<ADD_USER_ID>"]);
```
###### Selected Team
```ts
await team.addMemberUsers(["<ADD_USER_ID>"]);
```
---
#### Remove Team Member
##### Remove Team
###### By Team ID
```ts
await client.team.removeMemberTeams("<TEAM_ID>", ["<REMOVE_TEAM_ID>"]);
```
###### Selected Team
```ts
await team.removeMemberTeams(["<REMOVE_TEAM_ID>"]);
```
##### Remove User
###### By Team ID
```ts
await client.team.removeMemberUsers("<TEAM_ID>", ["<REMOVE_USER_ID>"]);
```
###### Selected Team
```ts
await team.removeMemberUsers(["<REMOVE_USER_ID>"]);
```
---
### Job
#### Get Job
```ts
const job = client.job.get("<JOB_ID>");
```
---
#### Create Job
```ts
const job = await client.job.create({
name: "<JOB_NAME>", // Optional
description: "<JOB_DESCRIPTION>", // Optional
executionConfig: {
notebookPath: "<NOTEBOOK_NAME.ipynb>",
createSnapshot: true,
runtimeName: "notebooks-cpu-small",
},
schedule: {
mode: "Recurring", // Supported values: "Once" | "Recurring"
executionIntervalInMinutes: 60,
startAt: new Date("2025-01-01"),
},
targetConfig: {
databaseName: "<DATABASE_NAME>",
resumeTarget: true,
targetID: "<TARGET_ID>",
targetType: "Workspace", // Supported values: "Workspace" | "Cluster" | "VirtualWorkspace"
}, // Optional
});
```
---
#### Delete Job
##### By Job ID
```ts
await client.job.delete("<JOB_ID>");
```
##### Selected Job
```ts
await job.delete();
```
---
#### Get Job Executions
##### By Job ID
```ts
const executions = await client.job.getExecutions("<JOB_ID>", 1, 10);
```
##### Selected Job
```ts
const executions = await job.getExecutions(1, 10);
```
---
#### Get Job Parameters
##### By Job ID
```ts
const parameters = await client.job.getParameters("<JOB_ID>");
```
##### Selected Job
```ts
const parameters = await job.getParameters();
```
---
#### Get Job Runtimes
```ts
const runtimes = await client.job.getRuntimes();
```
---
### Secret
#### Get Secret
##### Get All Secrets
```ts
const secrets = await client.secret.get();
```
##### Get By Secret ID
```ts
const secret = await client.secret.get({ id: "<SECRET_ID>" });
```
##### Get By Secret Name
```ts
const secret = await client.secret.get({ name: "<SECRET_NAME>" });
```
---
#### Create Secret
```ts
const secret = await client.secret.create({
name: "<SECRET_NAME>",
value: "<SECRET_VALUE>",
});
```
---
#### Update Secret
##### By Secret ID
```ts
const secret = await client.secret.update("<SECRET_ID>", "<NEW_SECRET_VALUE>");
```
##### Selected Secret
```ts
const secret = await secret.update("<NEW_SECRET_VALUE>");
```
---
#### Delete Secret
##### By Secret ID
```ts
await client.secret.delete("<SECRET_ID>");
```
##### Selected Secret
```ts
await secret.delete();
```
---
### Stage
- Folder path example: `folderName/`
- File path example: `folderName/fileName.json`
#### Get All Stage
```ts
const stage = await workspaceGroup.stage.get();
```
#### Get Stage Folder
```ts
const stage = await workspaceGroup.stage.get("<STAGE_PATH>/");
```
```ts
const nextStage = await stage.get("<STAGE_PATH>/");
```
#### Get Stage File
```ts
const stage = await workspaceGroup.stage.get("<STAGE_PATH>");
```
```ts
const nextStage = await stage.get("<STAGE_PATH>");
```
---
#### Update Stage
##### By Stage Path
```ts
await workspaceGroup.stage.update("<STAGE_PATH>", { newPath: "<NEW_STAGE_PATH>" });
```
##### Selected Stage
```ts
await stage.update({ newPath: "<NEW_STAGE_PATH>" });
```
##### Additional Notes
---
#### Create Stage Folder
##### In Stage Path
```ts
const newStage = await workspaceGroup.stage.createFolder("<NEW_STAGE_PATH>", "NEW_STAGE_NAME");
```
##### In Selected Stage
```ts
const newStage = stage.createFolder(
"<NEW_STAGE_NAME>",
"<NEW_STAGE_PATH>", // Optional
);
```
---
#### Delete Stage
##### By Stage Path
```ts
await workspaceGroup.stage.delete("<STAGE_PATH>");
```
##### Selected Stage
```ts
await stage.delete();
```
---
### Storage
#### Get Storage Regions
```ts
const regions = await workspaceGroup.storage.getRegions();
```
---
#### Get Storage Status
```ts
const status = await workspaceGroup.storage.getStatus();
```
---

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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