This commit is contained in:
2026-03-08 08:32:12 +01:00
parent 9e922be199
commit c7f2f22b32
38 changed files with 222 additions and 445 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bun
#!/usr/bin/env node
/**
* # Declare Global Variables
*/
+4 -4
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bun
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -13,9 +13,9 @@ const restore_1 = __importDefault(require("./restore"));
* # Describe Program
*/
commander_1.program
.name(`bun-sqlite`)
.description(`SQLite manager for Bun`)
.version(`1.0.0`);
.name(`nsqlite`)
.description(`SQLite manager for Node JS`)
.version(`1.1.0`);
/**
* # Declare Commands
*/
+1 -1
View File
@@ -1,5 +1,5 @@
export declare const AppData: {
readonly ConfigFileName: "bun-sqlite.config.ts";
readonly ConfigFileName: "nsqlite.config.ts";
readonly MaxBackups: 10;
readonly DefaultBackupDirName: ".backups";
};
+1 -1
View File
@@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppData = void 0;
exports.AppData = {
ConfigFileName: "bun-sqlite.config.ts",
ConfigFileName: "nsqlite.config.ts",
MaxBackups: 10,
DefaultBackupDirName: ".backups",
};
+2 -2
View File
@@ -1,2 +1,2 @@
import type { BunSQLiteConfigReturn } from "../types";
export default function init(): BunSQLiteConfigReturn;
import type { NSQLiteConfigReturn } from "../types";
export default function init(): NSQLiteConfigReturn;
+2 -2
View File
@@ -1,7 +1,7 @@
import type { BUN_SQLITE_TableSchemaType } from "../../types";
import type { NSQLITE_TableSchemaType } from "../../types";
type Param = {
paradigm: "JavaScript" | "TypeScript" | undefined;
table: BUN_SQLITE_TableSchemaType;
table: NSQLITE_TableSchemaType;
query?: any;
typeDefName?: string;
allValuesOptional?: boolean;
+2 -2
View File
@@ -8,8 +8,8 @@ function generateTypeDefinition({ paradigm, table, query, typeDefName, allValues
tdName = typeDefName
? typeDefName
: dbName
? `BUN_SQLITE_${dbName}_${table.tableName}`.toUpperCase()
: `BUN_SQLITE_${query.single}_${query.single_table}`.toUpperCase();
? `NSQLITE_${dbName}_${table.tableName}`.toUpperCase()
: `NSQLITE_${query.single}_${query.single_table}`.toUpperCase();
const fields = table.fields;
function typeMap(schemaType) {
var _a, _b, _c;
+3 -3
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bun
import type { BUN_SQLITE_DatabaseSchemaType } from "../../types";
#!/usr/bin/env node
import type { NSQLITE_DatabaseSchemaType } from "../../types";
declare class SQLiteSchemaManager {
private db;
private db_manager_table_name;
private recreate_vector_table;
private db_schema;
constructor({ schema, recreate_vector_table, }: {
schema: BUN_SQLITE_DatabaseSchemaType;
schema: NSQLITE_DatabaseSchemaType;
recreate_vector_table?: boolean;
});
private createDbManagerTable;
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bun
#!/usr/bin/env node
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+2 -2
View File
@@ -1,6 +1,6 @@
import type { BUN_SQLITE_DatabaseSchemaType } from "../../types";
import type { NSQLITE_DatabaseSchemaType } from "../../types";
type Params = {
dbSchema?: BUN_SQLITE_DatabaseSchemaType;
dbSchema?: NSQLITE_DatabaseSchemaType;
};
export default function dbSchemaToType(params?: Params): string[] | undefined;
export {};
+3 -3
View File
@@ -11,7 +11,7 @@ function dbSchemaToType(params) {
let datasquirelSchema = params === null || params === void 0 ? void 0 : params.dbSchema;
if (!datasquirelSchema)
return;
let tableNames = `export const BunSQLiteTables = [\n${datasquirelSchema.tables
let tableNames = `export const NSQLiteTables = [\n${datasquirelSchema.tables
.map((tbl) => ` "${tbl.tableName}",`)
.join("\n")}\n] as const`;
const dbTablesSchemas = datasquirelSchema.tables;
@@ -33,7 +33,7 @@ function dbSchemaToType(params) {
const defObj = (0, db_generate_type_defs_1.default)({
paradigm: "TypeScript",
table: final_table,
typeDefName: `BUN_SQLITE_${defDbName}_${final_table.tableName.toUpperCase()}`,
typeDefName: `NSQLITE_${defDbName}_${final_table.tableName.toUpperCase()}`,
allValuesOptional: true,
addExport: true,
});
@@ -44,7 +44,7 @@ function dbSchemaToType(params) {
})
.filter((schm) => typeof schm == "string");
const allTd = (defNames === null || defNames === void 0 ? void 0 : defNames[0])
? `export type BUN_SQLITE_${defDbName}_ALL_TYPEDEFS = ${defNames.join(` & `)}`
? `export type NSQLITE_${defDbName}_ALL_TYPEDEFS = ${defNames.join(` & `)}`
: ``;
return [tableNames, ...schemas, allTd];
}
+2 -2
View File
@@ -1,6 +1,6 @@
import type { BUN_SQLITE_DatabaseSchemaType } from "../../types";
import type { NSQLITE_DatabaseSchemaType } from "../../types";
type Params = {
dbSchema: BUN_SQLITE_DatabaseSchemaType;
dbSchema: NSQLITE_DatabaseSchemaType;
dst_file: string;
};
export default function dbSchemaToTypeDef({ dbSchema, dst_file }: Params): void;
+2 -2
View File
@@ -1,2 +1,2 @@
import type { BUN_SQLITE_DatabaseSchemaType } from "../../types";
export declare const DbSchema: BUN_SQLITE_DatabaseSchemaType;
import type { NSQLITE_DatabaseSchemaType } from "../../types";
export declare const DbSchema: NSQLITE_DatabaseSchemaType;
+39 -39
View File
@@ -1,32 +1,32 @@
import type { RequestOptions } from "https";
export type BUN_SQLITE_DatabaseFullName = string;
export type NSQLITE_DatabaseFullName = string;
export declare const UsersOmitedFields: readonly ["password", "social_id", "verification_status", "date_created", "date_created_code", "date_created_timestamp", "date_updated", "date_updated_code", "date_updated_timestamp"];
export interface BUN_SQLITE_DatabaseSchemaType {
export interface NSQLITE_DatabaseSchemaType {
id?: string | number;
dbName?: string;
dbSlug?: string;
dbFullName?: string;
dbDescription?: string;
dbImage?: string;
tables: BUN_SQLITE_TableSchemaType[];
childrenDatabases?: BUN_SQLITE_ChildrenDatabaseObject[];
tables: NSQLITE_TableSchemaType[];
childrenDatabases?: NSQLITE_ChildrenDatabaseObject[];
childDatabase?: boolean;
childDatabaseDbId?: string | number;
updateData?: boolean;
collation?: (typeof MariaDBCollations)[number];
}
export interface BUN_SQLITE_ChildrenDatabaseObject {
export interface NSQLITE_ChildrenDatabaseObject {
dbId?: string | number;
}
export declare const MariaDBCollations: readonly ["utf8mb4_bin", "utf8mb4_unicode_520_ci"];
export interface BUN_SQLITE_TableSchemaType {
export interface NSQLITE_TableSchemaType {
id?: string | number;
tableName: string;
tableDescription?: string;
fields: BUN_SQLITE_FieldSchemaType[];
indexes?: BUN_SQLITE_IndexSchemaType[];
uniqueConstraints?: BUN_SQLITE_UniqueConstraintSchemaType[];
childrenTables?: BUN_SQLITE_ChildrenTablesType[];
fields: NSQLITE_FieldSchemaType[];
indexes?: NSQLITE_IndexSchemaType[];
uniqueConstraints?: NSQLITE_UniqueConstraintSchemaType[];
childrenTables?: NSQLITE_ChildrenTablesType[];
/**
* Whether this is a child table
*/
@@ -61,7 +61,7 @@ export interface BUN_SQLITE_TableSchemaType {
isVector?: boolean;
vectorType?: string;
}
export interface BUN_SQLITE_ChildrenTablesType {
export interface NSQLITE_ChildrenTablesType {
tableId?: string | number;
dbId?: string | number;
}
@@ -96,18 +96,18 @@ export declare const TextFieldTypesArray: readonly [{
readonly title: "Code";
readonly value: "code";
}];
export declare const BUN_SQLITE_DATATYPES: readonly [{
export declare const NSQLITE_DATATYPES: readonly [{
readonly value: "TEXT";
}, {
readonly value: "INTEGER";
}];
export type BUN_SQLITE_FieldSchemaType = {
export type NSQLITE_FieldSchemaType = {
id?: number | string;
fieldName?: string;
fieldDescription?: string;
originName?: string;
updatedField?: boolean;
dataType: (typeof BUN_SQLITE_DATATYPES)[number]["value"];
dataType: (typeof NSQLITE_DATATYPES)[number]["value"];
nullValue?: boolean;
notNullValue?: boolean;
primaryKey?: boolean;
@@ -115,7 +115,7 @@ export type BUN_SQLITE_FieldSchemaType = {
autoIncrement?: boolean;
defaultValue?: string | number;
defaultValueLiteral?: string;
foreignKey?: BUN_SQLITE_ForeignKeyType;
foreignKey?: NSQLITE_ForeignKeyType;
defaultField?: boolean;
plainText?: boolean;
unique?: boolean;
@@ -156,7 +156,7 @@ CREATE VIRTUAL TABLE documents USING vec0(
-- INSERTING (Notice: No '+' here)
INSERT INTO documents(embedding, title, raw_body)
VALUES (vec_f32(?), 'Bun Docs', 'Bun is a fast JavaScript runtime...');
VALUES (vec_f32(?), 'Node Docs', 'Node is a fast JavaScript runtime...');
-- QUERYING (Notice: No '+' here)
SELECT title, raw_body
@@ -168,7 +168,7 @@ WHERE embedding MATCH ? AND k = 1;
} & {
[key in (typeof TextFieldTypesArray)[number]["value"]]?: boolean;
};
export interface BUN_SQLITE_ForeignKeyType {
export interface NSQLITE_ForeignKeyType {
foreignKeyName?: string;
destinationTableName?: string;
destinationTableColumnName?: string;
@@ -176,28 +176,28 @@ export interface BUN_SQLITE_ForeignKeyType {
cascadeDelete?: boolean;
cascadeUpdate?: boolean;
}
export interface BUN_SQLITE_IndexSchemaType {
export interface NSQLITE_IndexSchemaType {
id?: string | number;
indexName?: string;
indexType?: (typeof IndexTypes)[number];
indexTableFields?: BUN_SQLITE_IndexTableFieldType[];
indexTableFields?: NSQLITE_IndexTableFieldType[];
alias?: string;
newTempIndex?: boolean;
}
export interface BUN_SQLITE_UniqueConstraintSchemaType {
export interface NSQLITE_UniqueConstraintSchemaType {
id?: string | number;
constraintName?: string;
alias?: string;
constraintTableFields?: BUN_SQLITE_UniqueConstraintFieldType[];
constraintTableFields?: NSQLITE_UniqueConstraintFieldType[];
}
export interface BUN_SQLITE_UniqueConstraintFieldType {
export interface NSQLITE_UniqueConstraintFieldType {
value: string;
}
export interface BUN_SQLITE_IndexTableFieldType {
export interface NSQLITE_IndexTableFieldType {
value: string;
dataType: string;
}
export interface BUN_SQLITE_MYSQL_SHOW_INDEXES_Type {
export interface NSQLITE_MYSQL_SHOW_INDEXES_Type {
Key_name: string;
Table: string;
Column_name: string;
@@ -207,7 +207,7 @@ export interface BUN_SQLITE_MYSQL_SHOW_INDEXES_Type {
Index_comment: string;
Comment: string;
}
export interface BUN_SQLITE_MYSQL_SHOW_COLUMNS_Type {
export interface NSQLITE_MYSQL_SHOW_COLUMNS_Type {
Field: string;
Type: string;
Null: string;
@@ -215,7 +215,7 @@ export interface BUN_SQLITE_MYSQL_SHOW_COLUMNS_Type {
Default: string;
Extra: string;
}
export interface BUN_SQLITE_MARIADB_SHOW_INDEXES_TYPE {
export interface NSQLITE_MARIADB_SHOW_INDEXES_TYPE {
Table: string;
Non_unique: 0 | 1;
Key_name: string;
@@ -230,12 +230,12 @@ export interface BUN_SQLITE_MARIADB_SHOW_INDEXES_TYPE {
Index_comment?: string;
Ignored?: "YES" | "NO";
}
export interface BUN_SQLITE_MYSQL_FOREIGN_KEYS_Type {
export interface NSQLITE_MYSQL_FOREIGN_KEYS_Type {
CONSTRAINT_NAME: string;
CONSTRAINT_SCHEMA: string;
TABLE_NAME: string;
}
export interface BUN_SQLITE_MYSQL_user_databases_Type {
export interface NSQLITE_MYSQL_user_databases_Type {
id: number;
user_id: number;
db_full_name: string;
@@ -362,7 +362,7 @@ export interface GetReturn<R extends any = any> {
payload?: R;
msg?: string;
error?: string;
schema?: BUN_SQLITE_TableSchemaType;
schema?: NSQLITE_TableSchemaType;
finalQuery?: string;
}
export interface GetSchemaRequestQuery {
@@ -383,7 +383,7 @@ export interface PostReturn {
payload?: Object[] | string | PostInsertReturn;
msg?: string;
error?: any;
schema?: BUN_SQLITE_TableSchemaType;
schema?: NSQLITE_TableSchemaType;
}
export interface PostDataPayload {
action: "insert" | "update" | "delete";
@@ -615,8 +615,8 @@ export type ServerQueryParamsJoinMatchSourceTargetObject = {
export type ApiConnectBody = {
url: string;
key: string;
database: BUN_SQLITE_MYSQL_user_databases_Type;
dbSchema: BUN_SQLITE_DatabaseSchemaType;
database: NSQLITE_MYSQL_user_databases_Type;
dbSchema: NSQLITE_DatabaseSchemaType;
type: "pull" | "push";
user_id?: string | number;
};
@@ -876,7 +876,7 @@ export type APIResponseObject<T extends {
countQueryObject?: ResponseQueryObject;
status?: number;
count?: number;
errors?: BUNSQLITEErrorObject[];
errors?: NSQLITEErrorObject[];
debug?: any;
batchPayload?: any[][] | null;
errorData?: any;
@@ -965,7 +965,7 @@ export type DefaultEntryType = {
[k: string]: string | number | null;
};
export declare const IndexTypes: readonly ["regular", "full_text", "vector"];
export type BUNSQLITEErrorObject = {
export type NSQLITEErrorObject = {
sql?: string;
sqlValues?: any[];
error?: string;
@@ -986,7 +986,7 @@ export type SQLInsertGenParams = {
tableName: string;
dbFullName?: string;
};
export type BunSQLiteConfig = {
export type NSQLiteConfig = {
db_name: string;
/**
* The Name of the Database Schema File. Eg `db_schema.ts`. This is
@@ -1008,8 +1008,8 @@ export type BunSQLiteConfig = {
*/
typedef_file_path?: string;
};
export type BunSQLiteConfigReturn = {
config: BunSQLiteConfig;
dbSchema: BUN_SQLITE_DatabaseSchemaType;
export type NSQLiteConfigReturn = {
config: NSQLiteConfig;
dbSchema: NSQLITE_DatabaseSchemaType;
};
export declare const DefaultFields: BUN_SQLITE_FieldSchemaType[];
export declare const DefaultFields: NSQLITE_FieldSchemaType[];
+2 -2
View File
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultFields = exports.IndexTypes = exports.DockerComposeServices = exports.QueryFields = exports.DsqlCrudActions = exports.DataCrudRequestMethodsLowerCase = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.BUN_SQLITE_DATATYPES = exports.TextFieldTypesArray = exports.MariaDBCollations = exports.UsersOmitedFields = void 0;
exports.DefaultFields = exports.IndexTypes = exports.DockerComposeServices = exports.QueryFields = exports.DsqlCrudActions = exports.DataCrudRequestMethodsLowerCase = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.NSQLITE_DATATYPES = exports.TextFieldTypesArray = exports.MariaDBCollations = exports.UsersOmitedFields = void 0;
exports.UsersOmitedFields = [
"password",
"social_id",
@@ -28,7 +28,7 @@ exports.TextFieldTypesArray = [
{ title: "Shell", value: "shell" },
{ title: "Code", value: "code" },
];
exports.BUN_SQLITE_DATATYPES = [
exports.NSQLITE_DATATYPES = [
{ value: "TEXT" },
{ value: "INTEGER" },
];
+3 -3
View File
@@ -1,6 +1,6 @@
import { type BUN_SQLITE_DatabaseSchemaType } from "../types";
import { type NSQLITE_DatabaseSchemaType } from "../types";
type Params = {
dbSchema: BUN_SQLITE_DatabaseSchemaType;
dbSchema: NSQLITE_DatabaseSchemaType;
};
export default function ({ dbSchema }: Params): BUN_SQLITE_DatabaseSchemaType;
export default function ({ dbSchema }: Params): NSQLITE_DatabaseSchemaType;
export {};
+2 -2
View File
@@ -1,6 +1,6 @@
import type { BunSQLiteConfig } from "../types";
import type { NSQLiteConfig } from "../types";
type Params = {
config: BunSQLiteConfig;
config: NSQLiteConfig;
};
export default function grabDBBackupFileName({ config }: Params): string;
export {};
+2 -2
View File
@@ -1,6 +1,6 @@
import type { BunSQLiteConfig } from "../types";
import type { NSQLiteConfig } from "../types";
type Params = {
config: BunSQLiteConfig;
config: NSQLiteConfig;
};
export default function grabDBDir({ config }: Params): {
db_dir: string;
+2 -2
View File
@@ -1,6 +1,6 @@
import type { BunSQLiteConfig } from "../types";
import type { NSQLiteConfig } from "../types";
type Params = {
config: BunSQLiteConfig;
config: NSQLiteConfig;
};
export default function grabSortedBackups({ config }: Params): string[];
export {};
+2 -2
View File
@@ -1,6 +1,6 @@
import type { BunSQLiteConfig } from "../types";
import type { NSQLiteConfig } from "../types";
type Params = {
config: BunSQLiteConfig;
config: NSQLiteConfig;
};
export default function trimBackups({ config }: Params): void;
export {};