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
44
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.6 to 0.0.7

97

dist/index.d.ts
import * as _singlestore_ai from '@singlestore/ai';
import { AI } from '@singlestore/ai';
import * as mysql2 from 'mysql2';
import * as mysql2_promise from 'mysql2/promise';
import { PoolOptions, Pool, ResultSetHeader, RowDataPacket } from 'mysql2/promise';
export { ResultSetHeader, RowDataPacket } from 'mysql2/promise';
import * as mysql2 from 'mysql2';

@@ -29,2 +29,10 @@ interface WorkspaceConnectionConfig extends Partial<Omit<PoolOptions, "database">> {

}
interface ColumnShowInfo<T extends string = string> {
name: T;
type: string;
null: string;
key: string;
default: any;
extra: string;
}
declare class WorkspaceColumn {

@@ -40,3 +48,5 @@ private _connection;

static drop(connection: WorkspaceConnection, databaseName: string, tableName: string, name: string): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
static normalizeShowInfo<T extends string>(info: any): ColumnShowInfo<T>;
drop(): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
showInfo(): Promise<ColumnShowInfo<string>>;
modify(schema: Partial<Omit<WorkspaceColumnSchema, "name">>): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;

@@ -124,3 +134,9 @@ rename(newName: string): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;

}
declare class WorkspaceTable<T extends WorkspaceTableType> {
interface TableShowInfo<T extends string = string> {
name: T;
tableType: string;
distributed: boolean;
storageType: string;
}
declare class WorkspaceTable<T extends WorkspaceTableType, _ColumnNames extends Extract<keyof T["columns"], string> = Extract<keyof T["columns"], string>> {
private _connection;

@@ -135,8 +151,11 @@ databaseName: string;

static schemaToClauses(schema: WorkspaceTableSchema<any>): string;
static create<T extends WorkspaceTableType>(connection: WorkspaceConnection, databaseName: string, schema: WorkspaceTableSchema<T>, ai?: AI): Promise<WorkspaceTable<T>>;
static create<T extends WorkspaceTableType>(connection: WorkspaceConnection, databaseName: string, schema: WorkspaceTableSchema<T>, ai?: AI): Promise<WorkspaceTable<T, Extract<keyof T["columns"], string>>>;
static drop(connection: WorkspaceConnection, databaseName: string, name: string): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
static normalizeShowInfo<T extends string, U extends boolean>(info: any, extended?: U): U extends true ? TableShowInfo<T> : Pick<TableShowInfo<T>, "name">;
drop(): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
column(name: keyof T["columns"] | (string & {})): WorkspaceColumn;
showInfo<U extends boolean>(extended?: U): Promise<U extends true ? TableShowInfo<string> : Pick<TableShowInfo<string>, "name">>;
column(name: _ColumnNames | (string & {})): WorkspaceColumn;
addColumn(schema: WorkspaceColumnSchema): Promise<WorkspaceColumn>;
dropColumn(name: ({} & string) | Extract<keyof T["columns"], string>): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
dropColumn(name: _ColumnNames | ({} & string)): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
showColumnsInfo(): Promise<ColumnShowInfo<_ColumnNames>[]>;
truncate(): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;

@@ -152,3 +171,3 @@ rename(newName: string): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;

prompt: string;
vColumn: Extract<keyof T["columns"], string>;
vColumn: _ColumnNames;
}, ...U]): Promise<(ExtractQueryColumns<_S, ExtractQueryOptions<U>> & {

@@ -162,3 +181,3 @@ v_score: number;

prompt: string;
vColumn: Extract<keyof T["columns"], string>;
vColumn: _ColumnNames;
template?: string;

@@ -169,3 +188,3 @@ } & _O,

prompt: string;
vColumn: Extract<keyof T["columns"], string>;
vColumn: _ColumnNames;
template?: string;

@@ -176,3 +195,3 @@ } & _O, "prompt" | "vColumn" | "template" | "systemRole"> & {

prompt: string;
vColumn: Extract<keyof T["columns"], string>;
vColumn: _ColumnNames;
template?: string;

@@ -198,14 +217,39 @@ } & _O, "prompt" | "vColumn" | "template" | "systemRole"> & {

}
declare class WorkspaceDatabase<T extends WorkspaceDatabaseType> {
interface DatabaseShowInfo<T extends string = string> {
name: T;
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;
}
declare class WorkspaceDatabase<T extends WorkspaceDatabaseType, _TableNames extends Extract<keyof T["tables"], string> = Extract<keyof T["tables"], string>> {
private _connection;
workspaceName: string;
name: string;
workspaceName?: string | undefined;
private _ai?;
constructor(_connection: WorkspaceConnection, workspaceName: string, name: string, _ai?: AI | undefined);
static create<T extends WorkspaceDatabaseType>(connection: WorkspaceConnection, workspaceName: string, schema: WorkspaceDatabaseSchema<T>, ai?: AI): Promise<WorkspaceDatabase<T>>;
constructor(_connection: WorkspaceConnection, name: string, workspaceName?: string | undefined, _ai?: AI | undefined);
static create<T extends WorkspaceDatabaseType>(connection: WorkspaceConnection, schema: WorkspaceDatabaseSchema<T>, workspaceName?: string, ai?: AI): Promise<WorkspaceDatabase<T, Extract<keyof T["tables"], string>>>;
static drop(connection: WorkspaceConnection, name: string): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
static normalizeShowInfo<T extends string, U extends boolean>(info: {
Database: T;
[K: string]: any;
}, extended?: U): U extends true ? DatabaseShowInfo<T> : Pick<DatabaseShowInfo<T>, "name">;
drop(): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
table<U, K extends keyof T["tables"] | (string & {}) = keyof T["tables"] | (string & {})>(name: K): WorkspaceTable<U extends WorkspaceTableType ? U : T["tables"][K]>;
createTable<T extends WorkspaceTableType>(schema: WorkspaceTableSchema<T>): Promise<WorkspaceTable<T>>;
dropTable(name: ({} & string) | Extract<keyof T["tables"], string>): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
showInfo<U extends boolean>(extended?: U): Promise<U extends true ? DatabaseShowInfo<string> : Pick<DatabaseShowInfo<string>, "name">>;
table<U, K extends _TableNames | (string & {}) = _TableNames | (string & {})>(name: K): WorkspaceTable<U extends WorkspaceTableType ? U : T["tables"][K], Extract<keyof (U extends WorkspaceTableType ? U : T["tables"][K])["columns"], string>>;
createTable<T extends WorkspaceTableType>(schema: WorkspaceTableSchema<T>): Promise<WorkspaceTable<T, Extract<keyof T["columns"], string>>>;
dropTable(name: _TableNames | ({} & string)): Promise<[ResultSetHeader, mysql2_promise.FieldPacket[]]>;
showTablesInfo<U extends boolean>(extended?: U): Promise<(U extends true ? TableShowInfo<_TableNames> : Pick<TableShowInfo<_TableNames>, "name">)[]>;
query<T extends any[]>(statement: string): Promise<T>;

@@ -223,13 +267,14 @@ }

}
declare class Workspace<T extends WorkspaceType> {
declare class Workspace<T extends WorkspaceType, _DatabaseNames extends Extract<keyof T["databases"], string> = Extract<keyof T["databases"], string>> {
connection: WorkspaceConnection;
name: string;
name?: string | undefined;
private _ai?;
constructor(connection: WorkspaceConnection, name: string, _ai?: AI | undefined);
static connect<T extends WorkspaceType>({ ai, name, ...config }: Pick<WorkspaceSchema<T>, "name"> & Omit<WorkspaceConnectionConfig, "name"> & {
constructor(connection: WorkspaceConnection, name?: string | undefined, _ai?: AI | undefined);
static connect<T extends WorkspaceType>({ ai, name, ...config }: Partial<Pick<WorkspaceSchema<T>, "name">> & Omit<WorkspaceConnectionConfig, "name"> & {
ai?: AI;
}): Workspace<T>;
database<U, K extends keyof T["databases"] | (string & {}) = keyof T["databases"] | (string & {})>(name: K): WorkspaceDatabase<U extends WorkspaceDatabaseType ? U : T["databases"][K]>;
createDatabase<T extends WorkspaceDatabaseType>(schema: WorkspaceDatabaseSchema<T>): Promise<WorkspaceDatabase<T>>;
dropDatabase(name: ({} & string) | Extract<keyof T["databases"], string>): Promise<[mysql2.ResultSetHeader, mysql2.FieldPacket[]]>;
}): Workspace<T, Extract<keyof T["databases"], string>>;
database<U, K extends _DatabaseNames | (string & {}) = _DatabaseNames | (string & {})>(name: K): WorkspaceDatabase<U extends WorkspaceDatabaseType ? U : T["databases"][K], Extract<keyof (U extends WorkspaceDatabaseType ? U : T["databases"][K])["tables"], string>>;
createDatabase<T extends WorkspaceDatabaseType>(schema: WorkspaceDatabaseSchema<T>): Promise<WorkspaceDatabase<T, Extract<keyof T["tables"], string>>>;
dropDatabase(name: _DatabaseNames | ({} & string)): Promise<[mysql2.ResultSetHeader, mysql2.FieldPacket[]]>;
showDatabasesInfo<U extends boolean>(extended?: U): Promise<(U extends true ? DatabaseShowInfo<_DatabaseNames> : Pick<DatabaseShowInfo<_DatabaseNames>, "name">)[]>;
}

@@ -242,5 +287,5 @@

});
workspace<T extends WorkspaceType>(config: Omit<Parameters<typeof Workspace.connect>[0], "ai">): Workspace<T>;
workspace<T extends WorkspaceType>(config: Omit<Parameters<typeof Workspace.connect>[0], "ai">): Workspace<T, Extract<keyof T["databases"], string>>;
}
export { type DatabaseTablesToRecords, QueryBuilder, type QueryBuilderArgs, type QueryFilters, QueryFiltersBuilder, type QueryOptions, QueryOptionsBuilder, type QuerySchema, SingleStoreClient, Workspace, WorkspaceColumn, type WorkspaceColumnSchema, type WorkspaceColumnType, WorkspaceConnection, type WorkspaceConnectionConfig, WorkspaceDatabase, type WorkspaceDatabaseSchema, type WorkspaceDatabaseType, type WorkspaceSchema, WorkspaceTable, type WorkspaceTableSchema, type WorkspaceTableType, type WorkspaceType };
export { type ColumnShowInfo, type DatabaseShowInfo, type DatabaseTablesToRecords, QueryBuilder, type QueryBuilderArgs, type QueryFilters, QueryFiltersBuilder, type QueryOptions, QueryOptionsBuilder, type QuerySchema, SingleStoreClient, type TableShowInfo, Workspace, WorkspaceColumn, type WorkspaceColumnSchema, type WorkspaceColumnType, WorkspaceConnection, type WorkspaceConnectionConfig, WorkspaceDatabase, type WorkspaceDatabaseSchema, type WorkspaceDatabaseType, type WorkspaceSchema, WorkspaceTable, type WorkspaceTableSchema, type WorkspaceTableType, type WorkspaceType };

@@ -123,5 +123,23 @@ "use strict";

}
static normalizeShowInfo(info) {
return {
name: info.Field,
type: info.Type,
null: info.Null,
key: info.Key,
default: info.Default,
extra: info.Extra
};
}
drop() {
return _WorkspaceColumn.drop(this._connection, this.databaseName, this.tableName, this.name);
}
showInfo() {
return __async(this, null, function* () {
const result = yield this._connection.client.query(
`SHOW COLUMNS IN ${this.tableName} IN ${this.databaseName} LIKE '${this.name}'`
);
return _WorkspaceColumn.normalizeShowInfo(result[0][0]);
});
}
modify(schema) {

@@ -312,5 +330,30 @@ const clauses = _WorkspaceColumn.schemaToClauses(__spreadProps(__spreadValues({ type: "" }, schema), { name: this.name }));

}
static normalizeShowInfo(info, extended) {
const nameKey = Object.keys(info).find((key) => key.startsWith("Tables_in_"));
const name = info[nameKey];
let result = { name };
if (extended) {
result = __spreadProps(__spreadValues({}, result), {
tableType: info.Table_type,
distributed: !!info.distributed,
storageType: info.Storage_type
});
}
return result;
}
drop() {
return _WorkspaceTable.drop(this._connection, this.databaseName, this.name);
}
showInfo(extended) {
return __async(this, null, function* () {
const clauses = [`SHOW TABLES IN ${this.databaseName}`];
if (extended) clauses.push("EXTENDED");
clauses.push(`LIKE '${this.name}'`);
const result = yield this._connection.client.query(clauses.join(" "));
return _WorkspaceTable.normalizeShowInfo(
__spreadProps(__spreadValues({}, result[0][0]), { [`Tables_in_${this.databaseName}`]: this.name }),
extended
);
});
}
column(name) {

@@ -325,2 +368,10 @@ return new WorkspaceColumn(this._connection, this.databaseName, this.name, name);

}
showColumnsInfo() {
return __async(this, null, function* () {
const result = yield this._connection.client.query(
`SHOW COLUMNS IN ${this.name} IN ${this.databaseName}`
);
return result[0].map((result2) => WorkspaceColumn.normalizeShowInfo(result2));
});
}
truncate() {

@@ -405,9 +456,9 @@ return this._connection.client.execute(` TRUNCATE TABLE ${this._path}

var WorkspaceDatabase = class _WorkspaceDatabase {
constructor(_connection, workspaceName, name, _ai) {
constructor(_connection, name, workspaceName, _ai) {
this._connection = _connection;
this.name = name;
this.workspaceName = workspaceName;
this.name = name;
this._ai = _ai;
}
static create(connection, workspaceName, schema, ai) {
static create(connection, schema, workspaceName, ai) {
return __async(this, null, function* () {

@@ -422,3 +473,3 @@ const clauses = [`CREATE DATABASE IF NOT EXISTS ${schema.name}`];

);
return new _WorkspaceDatabase(connection, workspaceName, schema.name, ai);
return new _WorkspaceDatabase(connection, schema.name, workspaceName, ai);
});

@@ -429,5 +480,38 @@ }

}
static normalizeShowInfo(info, extended) {
let result = { name: info.Database };
if (extended) {
result = __spreadProps(__spreadValues({}, result), {
commits: info.Commits,
role: info.Role,
state: info.State,
position: info.Position,
details: info.Details,
asyncSlaves: info.AsyncSlaves,
syncSlaves: info.SyncSlaves,
consensusSlaves: info.ConsensusSlaves,
committedPosition: info.CommittedPosition,
hardenedPosition: info.HardenedPosition,
replayPosition: info.ReplayPosition,
term: info.Term,
lastPageTerm: info.LastPageTerm,
memoryMBs: info["Memory (MBs)"],
pendingIOs: info["Pending IOs"],
pendingBlobFSyncs: info["Pending blob fsyncs"]
});
}
return result;
}
drop() {
return _WorkspaceDatabase.drop(this._connection, this.name);
}
showInfo(extended) {
return __async(this, null, function* () {
const clauses = ["SHOW DATABASES"];
if (extended) clauses.push("EXTENDED");
clauses.push(`LIKE '${this.name}'`);
const result = yield this._connection.client.query(clauses.join(" "));
return _WorkspaceDatabase.normalizeShowInfo(__spreadProps(__spreadValues({}, result[0][0]), { Database: this.name }), extended);
});
}
table(name) {

@@ -447,2 +531,10 @@ return new WorkspaceTable(

}
showTablesInfo(extended) {
return __async(this, null, function* () {
const clauses = [`SHOW TABLES IN ${this.name}`];
if (extended) clauses.push("EXTENDED");
const result = yield this._connection.client.query(clauses.join(" "));
return result[0].map((result2) => WorkspaceTable.normalizeShowInfo(result2, extended));
});
}
query(statement) {

@@ -478,4 +570,4 @@ return __async(this, null, function* () {

this.connection,
name,
this.name,
name,
this._ai

@@ -485,3 +577,3 @@ );

createDatabase(schema) {
return WorkspaceDatabase.create(this.connection, this.name, schema, this._ai);
return WorkspaceDatabase.create(this.connection, schema, this.name, this._ai);
}

@@ -491,2 +583,10 @@ dropDatabase(name) {

}
showDatabasesInfo(extended) {
return __async(this, null, function* () {
const clauses = ["SHOW DATABASES"];
if (extended) clauses.push("EXTENDED");
const result = yield this.connection.client.query(clauses.join(" "));
return result[0].map((result2) => WorkspaceDatabase.normalizeShowInfo(result2, extended));
});
}
};

@@ -493,0 +593,0 @@

{
"name": "@singlestore/client",
"version": "0.0.6",
"version": "0.0.7",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "sideEffects": false,

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